From 99884107fc9fa37c230e18682a45fe39ec8ec3d4 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Sun, 15 Mar 2020 23:31:34 +0100 Subject: [PATCH] Fix falling block conversion Fixes #187 --- .../nl/matsv/viabackwards/api/rewriters/EntityRewriter.java | 5 +++-- .../protocol1_14_4to1_15/packets/EntityPackets1_15.java | 3 ++- .../protocol1_15_2to1_16/packets/EntityPackets1_16.java | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/api/rewriters/EntityRewriter.java b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/EntityRewriter.java index 3dd8e2e6..ce0f9cac 100644 --- a/core/src/main/java/nl/matsv/viabackwards/api/rewriters/EntityRewriter.java +++ b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/EntityRewriter.java @@ -9,6 +9,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.MetaType; import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14; import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.rewriters.IdRewriteFunction; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; @@ -24,7 +25,7 @@ public abstract class EntityRewriter extends Entity super(protocol, displayType, 2); } - public void registerSpawnTrackerWithData(int oldPacketId, int newPacketId, EntityType fallingBlockType, ItemRewriter itemRewriter) { + public void registerSpawnTrackerWithData(int oldPacketId, int newPacketId, EntityType fallingBlockType, IdRewriteFunction blockStateRewriter) { protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { @Override public void registerMap() { @@ -41,7 +42,7 @@ public abstract class EntityRewriter extends Entity EntityType entityType = setOldEntityId(wrapper); if (entityType == fallingBlockType) { int blockState = wrapper.get(Type.INT, 0); - wrapper.set(Type.INT, 0, itemRewriter.toClientRewriter.rewrite(blockState)); + wrapper.set(Type.INT, 0, blockStateRewriter.rewrite(blockState)); } }); } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java index 22ebd0d9..04c29db0 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java @@ -6,6 +6,7 @@ import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15; import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping; import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn; import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ParticleMapping; +import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.entities.Entity1_15Types; import us.myles.ViaVersion.api.entities.EntityType; @@ -62,7 +63,7 @@ public class EntityPackets1_15 extends EntityRewriter { }); // Spawn Object - registerSpawnTrackerWithData(0x00, 0x00, Entity1_15Types.EntityType.FALLING_BLOCK, protocol.getBlockItemPackets()); + registerSpawnTrackerWithData(0x00, 0x00, Entity1_15Types.EntityType.FALLING_BLOCK, Protocol1_15_2To1_16::getNewBlockStateId); // Spawn mob packet protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() { diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java index 6aed5f6c..aeb115b5 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java @@ -22,7 +22,7 @@ public class EntityPackets1_16 extends EntityRewriter { @Override protected void registerPackets() { // Spawn Object - registerSpawnTrackerWithData(0x00, 0x00, Entity1_16Types.EntityType.FALLING_BLOCK, protocol.getBlockItemPackets()); + registerSpawnTrackerWithData(0x00, 0x00, Entity1_16Types.EntityType.FALLING_BLOCK, Protocol1_15_2To1_16::getNewBlockStateId); // Spawn mob packet registerSpawnTracker(0x03, 0x03);