Fix falling block conversion

Fixes #187
This commit is contained in:
KennyTV 2020-03-15 23:31:34 +01:00
parent 8087b42c40
commit 99884107fc
3 changed files with 6 additions and 4 deletions

View File

@ -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.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
import us.myles.ViaVersion.api.remapper.PacketRemapper; 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.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
@ -24,7 +25,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Entity
super(protocol, displayType, 2); 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() { protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -41,7 +42,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Entity
EntityType entityType = setOldEntityId(wrapper); EntityType entityType = setOldEntityId(wrapper);
if (entityType == fallingBlockType) { if (entityType == fallingBlockType) {
int blockState = wrapper.get(Type.INT, 0); int blockState = wrapper.get(Type.INT, 0);
wrapper.set(Type.INT, 0, itemRewriter.toClientRewriter.rewrite(blockState)); wrapper.set(Type.INT, 0, blockStateRewriter.rewrite(blockState));
} }
}); });
} }

View File

@ -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.EntityTypeMapping;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn; 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_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.PacketWrapper;
import us.myles.ViaVersion.api.entities.Entity1_15Types; import us.myles.ViaVersion.api.entities.Entity1_15Types;
import us.myles.ViaVersion.api.entities.EntityType; import us.myles.ViaVersion.api.entities.EntityType;
@ -62,7 +63,7 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
}); });
// Spawn Object // 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 // Spawn mob packet
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {

View File

@ -22,7 +22,7 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
@Override @Override
protected void registerPackets() { protected void registerPackets() {
// Spawn Object // 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 // Spawn mob packet
registerSpawnTracker(0x03, 0x03); registerSpawnTracker(0x03, 0x03);