Actually fix particles

Fixes #2850
This commit is contained in:
Nassim Jahnke 2022-03-19 15:56:22 +01:00
parent ec740476da
commit c3fc8b5f18
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 10 additions and 6 deletions

View File

@ -54,7 +54,7 @@ public final class InventoryPackets extends ItemRewriter<Protocol1_19To1_18_2> {
map(Type.FLOAT); // 7 - Offset Z
map(Type.FLOAT); // 8 - Particle Data
map(Type.INT); // 9 - Particle Count
handler(getSpawnParticleHandler(Type.FLAT_VAR_INT_ITEM));
handler(getSpawnParticleHandler(Type.VAR_INT, Type.FLAT_VAR_INT_ITEM));
}
});

View File

@ -313,27 +313,31 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
map(Type.FLOAT); // 7 - Offset Z
map(Type.FLOAT); // 8 - Particle Data
map(Type.INT); // 9 - Particle Count
handler(getSpawnParticleHandler(itemType));
handler(getSpawnParticleHandler(Type.VAR_INT, itemType));
}
});
}
public PacketHandler getSpawnParticleHandler(Type<Item> itemType) {
return getSpawnParticleHandler(Type.INT, itemType);
}
public PacketHandler getSpawnParticleHandler(Type<Integer> idType, Type<Item> itemType) {
return wrapper -> {
int id = wrapper.get(Type.INT, 0);
int id = wrapper.get(idType, 0);
if (id == -1) return;
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
if (mappings.isBlockParticle(id)) {
int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
int data = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewBlockStateId(data));
} else if (mappings.isItemParticle(id)) {
handleItemToClient(wrapper.passthrough(itemType));
}
int newId = protocol.getMappingData().getNewParticleId(id);
if (newId != id) {
wrapper.set(Type.INT, 0, newId);
wrapper.set(idType, 0, newId);
}
};
}