From 040558e01f5398f29c4669d4da5c0f443c284c0a Mon Sep 17 00:00:00 2001 From: KennyTV Date: Fri, 8 May 2020 09:21:16 +0200 Subject: [PATCH] Remap smithing inventory to anvil --- .../Protocol1_15_2To1_16.java | 19 ++++++++++++++++++- .../packets/EntityPackets1_16.java | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java index f4574c18..97b8edb6 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java @@ -37,11 +37,28 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol { translatableRewriter.registerChatMessage(0x0F, 0x0F); translatableRewriter.registerCombatEvent(0x33, 0x33); translatableRewriter.registerDisconnect(0x1B, 0x1B); - translatableRewriter.registerOpenWindow(0x2F, 0x2F); translatableRewriter.registerPlayerList(0x54, 0x54); translatableRewriter.registerTitle(0x50, 0x50); translatableRewriter.registerPing(); + // Open Window + registerOutgoing(State.PLAY, 0x2F, 0x2F, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // Window Id + map(Type.VAR_INT); // Window Type + handler(wrapper -> wrapper.write(Type.STRING, translatableRewriter.processTranslate(wrapper.read(Type.STRING)))); + handler(wrapper -> { + int windowType = wrapper.get(Type.VAR_INT, 1); + if (windowType == 20) { // Smithing table + wrapper.set(Type.VAR_INT, 1, 7); // Open anvil inventory + } else if (windowType > 20) { + wrapper.set(Type.VAR_INT, 1, --windowType); + } + }); + } + }); + SoundRewriter soundRewriter = new SoundRewriter(this, id -> BackwardsMappings.soundMappings.getNewId(id), stringId -> BackwardsMappings.soundMappings.getNewId(stringId)); soundRewriter.registerSound(0x51, 0x51); 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 77c10600..7607cdf9 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 @@ -40,7 +40,7 @@ public class EntityPackets1_16 extends EntityRewriter { map(Type.LONG); map(Type.BYTE); map(Type.STRING); - map(Type.BOOLEAN, Type.NOTHING); // save all playerdata + map(Type.BOOLEAN, Type.NOTHING); // save all playerdata //TODO clear if false? handler(wrapper -> { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); clientWorld.setEnvironment(wrapper.get(Type.INT, 0));