Fix dust particle writing

The double/float inconsistency was fixed in 21w03a, yay
This commit is contained in:
KennyTV 2021-01-21 09:26:56 +01:00
parent 14bfb8d147
commit e679a0c2b0
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 2 additions and 38 deletions

View File

@ -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.types.MetaType1_17;
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.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
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();
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} else if (metadata.getMetaType() == MetaType1_17.PARTICLE) {
Particle particle = (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);
rewriteParticle((Particle) metadata.getValue());
}
if (type == null) return;

View File

@ -20,6 +20,7 @@ public class InventoryPackets {
itemRewriter.registerSetSlot(ClientboundPackets1_16_2.SET_SLOT, 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.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);
@ -32,33 +33,6 @@ public class InventoryPackets {
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) {