From 3cd91d87a450b503dfd76c0792e1c8c6a29f95cf Mon Sep 17 00:00:00 2001 From: Matsv Date: Sat, 19 Jan 2019 12:50:33 +0100 Subject: [PATCH] Rewrite meta types --- .../packets/EntityPackets1_13.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java index 42203310..9eab3679 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java @@ -10,6 +10,8 @@ import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.EntityTypeMapping; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping; import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.minecraft.metadata.Metadata; +import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_12; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.type.Type; @@ -332,7 +334,39 @@ public class EntityPackets1_13 extends EntityRewriter { @Override protected void registerRewrites() { + + // Rewrite types + this.registerMetaHandler().handle(e -> { + Metadata meta = e.getData(); + int typeId = meta.getMetaType().getTypeID(); + + // Rewrite optional chat to chat + if (typeId == 5) { + meta.setMetaType(MetaType1_12.Chat); + + if (meta.getValue() == null) { + meta.setValue(""); + } + } + + // Discontinue particles + else if (typeId == 15) { + meta.setMetaType(MetaType1_12.Discontinued); + } + + // Rewrite to 1.12 ids + else if (typeId > 5) { + meta.setMetaType(MetaType1_12.byId( + typeId - 1 + )); + } + + return e.getData(); + }); + + // TODO Remove everything for now this.registerMetaHandler().removed(); - } + + } }