3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-04 23:30:24 +01:00

Actually fix particles

Fixes #2850
Dieser Commit ist enthalten in:
Nassim Jahnke 2022-03-19 15:56:22 +01:00
Ursprung ec740476da
Commit c3fc8b5f18
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 10 neuen und 6 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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