3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01:00

Fix dust particle writing

The double/float inconsistency was fixed in 21w03a, yay
Dieser Commit ist enthalten in:
KennyTV 2021-01-21 09:26:56 +01:00
Ursprung 14bfb8d147
Commit e679a0c2b0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 2 neuen und 38 gelöschten Zeilen

Datei anzeigen

@ -8,7 +8,6 @@ import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_17; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_17;
import us.myles.ViaVersion.api.rewriters.MetadataRewriter; import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.Particle; import us.myles.ViaVersion.api.type.types.Particle;
import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4; import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.packets.InventoryPackets;
@ -32,16 +31,7 @@ public class MetadataRewriter1_17To1_16_4 extends MetadataRewriter {
int data = (int) metadata.getValue(); int data = (int) metadata.getValue();
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data)); metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} else if (metadata.getMetaType() == MetaType1_17.PARTICLE) { } else if (metadata.getMetaType() == MetaType1_17.PARTICLE) {
Particle particle = (Particle) metadata.getValue(); rewriteParticle((Particle) metadata.getValue());
if (particle.getId() == 14) {
// RGB is now encoded as doubles
for (int i = 0; i < 3; i++) {
Particle.ParticleData data = particle.getArguments().get(i);
data.setValue(((Number) data.getValue()).doubleValue());
data.setType(Type.DOUBLE);
}
}
rewriteParticle(particle);
} }
if (type == null) return; if (type == null) return;

Datei anzeigen

@ -20,6 +20,7 @@ public class InventoryPackets {
itemRewriter.registerSetSlot(ClientboundPackets1_16_2.SET_SLOT, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerSetSlot(ClientboundPackets1_16_2.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerEntityEquipmentArray(ClientboundPackets1_16_2.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerEntityEquipmentArray(ClientboundPackets1_16_2.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
new RecipeRewriter1_16(protocol, InventoryPackets::toClient).registerDefaultHandler(ClientboundPackets1_16_2.DECLARE_RECIPES); new RecipeRewriter1_16(protocol, InventoryPackets::toClient).registerDefaultHandler(ClientboundPackets1_16_2.DECLARE_RECIPES);
@ -32,33 +33,6 @@ public class InventoryPackets {
handler(wrapper -> InventoryPackets.toServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); handler(wrapper -> InventoryPackets.toServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
} }
}); });
protocol.registerOutgoing(ClientboundPackets1_16_2.SPAWN_PARTICLE, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Particle id
map(Type.BOOLEAN); // Long distance
map(Type.DOUBLE); // X
map(Type.DOUBLE); // Y
map(Type.DOUBLE); // Z
map(Type.FLOAT); // Offset X
map(Type.FLOAT); // Offset Y
map(Type.FLOAT); // Offset Z
map(Type.FLOAT); // Particle data
map(Type.INT); // Particle count
handler(wrapper -> {
int id = wrapper.get(Type.INT, 0);
if (id == 14) { // Dust
// RGB now written as doubles
wrapper.write(Type.DOUBLE, wrapper.read(Type.FLOAT).doubleValue()); // R
wrapper.write(Type.DOUBLE, wrapper.read(Type.FLOAT).doubleValue()); // G
wrapper.write(Type.DOUBLE, wrapper.read(Type.FLOAT).doubleValue()); // B
wrapper.passthrough(Type.FLOAT); // Scale
}
});
handler(itemRewriter.getSpawnParticleHandler(Type.FLAT_VAR_INT_ITEM));
}
});
} }
public static void toClient(Item item) { public static void toClient(Item item) {