diff --git a/src/main/java/net/raphimc/vialegacy/api/protocol/PreNettyBaseProtocol.java b/src/main/java/net/raphimc/vialegacy/api/protocol/PreNettyBaseProtocol.java index cef9a78..b2af6aa 100644 --- a/src/main/java/net/raphimc/vialegacy/api/protocol/PreNettyBaseProtocol.java +++ b/src/main/java/net/raphimc/vialegacy/api/protocol/PreNettyBaseProtocol.java @@ -46,7 +46,7 @@ public void register() { wrapper.read(Type.VAR_INT); // protocolVersion final String hostname = wrapper.read(Type.STRING); // hostName final int port = wrapper.read(Type.UNSIGNED_SHORT); // port - wrapper.user().put(new HandshakeStorage(wrapper.user(), hostname, port)); + wrapper.user().put(new HandshakeStorage(hostname, port)); }); } }); @@ -60,7 +60,7 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new ProtocolMetadataStorage(userConnection)); + userConnection.put(new ProtocolMetadataStorage()); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/api/splitter/PreNettySplitter.java b/src/main/java/net/raphimc/vialegacy/api/splitter/PreNettySplitter.java index df5ce1f..74935da 100644 --- a/src/main/java/net/raphimc/vialegacy/api/splitter/PreNettySplitter.java +++ b/src/main/java/net/raphimc/vialegacy/api/splitter/PreNettySplitter.java @@ -17,19 +17,17 @@ */ package net.raphimc.vialegacy.api.splitter; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.api.protocol.Protocol; import java.util.function.IntFunction; -public class PreNettySplitter extends StoredObject { +public class PreNettySplitter implements StorableObject { private final IntFunction packetTypeSupplier; private final Class> protocolClass; - public PreNettySplitter(UserConnection user, Class> protocolClass, IntFunction packetTypeSupplier) { - super(user); + public PreNettySplitter(Class> protocolClass, IntFunction packetTypeSupplier) { this.protocolClass = protocolClass; this.packetTypeSupplier = packetTypeSupplier; } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_16_2toa1_0_15/Protocola1_0_16_2toa1_0_15.java b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_16_2toa1_0_15/Protocola1_0_16_2toa1_0_15.java index 9f4aef3..cb7b833 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_16_2toa1_0_15/Protocola1_0_16_2toa1_0_15.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_16_2toa1_0_15/Protocola1_0_16_2toa1_0_15.java @@ -49,7 +49,7 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocola1_0_16_2toa1_0_15.class, ClientboundPacketsa1_0_15::getPacket)); + userConnection.put(new PreNettySplitter(Protocola1_0_16_2toa1_0_15.class, ClientboundPacketsa1_0_15::getPacket)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_17_1_0_17_4toa1_0_16_2/Protocola1_0_17_1_0_17_4toa1_0_16_2.java b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_17_1_0_17_4toa1_0_16_2/Protocola1_0_17_1_0_17_4toa1_0_16_2.java index 618b721..71df38c 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_17_1_0_17_4toa1_0_16_2/Protocola1_0_17_1_0_17_4toa1_0_16_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_17_1_0_17_4toa1_0_16_2/Protocola1_0_17_1_0_17_4toa1_0_16_2.java @@ -60,9 +60,9 @@ public void register(ViaProviders providers) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocola1_0_17_1_0_17_4toa1_0_16_2.class, ClientboundPacketsa1_0_16::getPacket)); + userConnection.put(new PreNettySplitter(Protocola1_0_17_1_0_17_4toa1_0_16_2.class, ClientboundPacketsa1_0_16::getPacket)); - userConnection.put(new TimeLockStorage(userConnection, 0)); + userConnection.put(new TimeLockStorage(0)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_17_1_0_17_4toa1_0_16_2/storage/TimeLockStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_17_1_0_17_4toa1_0_16_2/storage/TimeLockStorage.java index eb9adc5..38bccf5 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_17_1_0_17_4toa1_0_16_2/storage/TimeLockStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_0_17_1_0_17_4toa1_0_16_2/storage/TimeLockStorage.java @@ -17,15 +17,13 @@ */ package net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; -public class TimeLockStorage extends StoredObject { +public class TimeLockStorage implements StorableObject { private long time; - public TimeLockStorage(UserConnection user, final long time) { - super(user); + public TimeLockStorage(final long time) { this.time = time; } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4/Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.java b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4/Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.java index 6eebdbd..0968883 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4/Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4/Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.java @@ -37,7 +37,7 @@ protected void registerPackets() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.class, ClientboundPacketsa1_0_17::getPacket)); + userConnection.put(new PreNettySplitter(Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.class, ClientboundPacketsa1_0_17::getPacket)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1/Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1.java b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1/Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1.java index ca56b9a..e704f3b 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1/Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1/Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1.java @@ -59,7 +59,7 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1.class, ClientboundPacketsa1_1_0::getPacket)); + userConnection.put(new PreNettySplitter(Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1.class, ClientboundPacketsa1_1_0::getPacket)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_2toa1_2_0_1_2_1_1/Protocola1_2_2toa1_2_0_1_2_1_1.java b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_2toa1_2_0_1_2_1_1/Protocola1_2_2toa1_2_0_1_2_1_1.java index a562ad7..69d57df 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_2toa1_2_0_1_2_1_1/Protocola1_2_2toa1_2_0_1_2_1_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_2toa1_2_0_1_2_1_1/Protocola1_2_2toa1_2_0_1_2_1_1.java @@ -56,7 +56,7 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocola1_2_2toa1_2_0_1_2_1_1.class, ClientboundPacketsa1_2_0::getPacket)); + userConnection.put(new PreNettySplitter(Protocola1_2_2toa1_2_0_1_2_1_1.class, ClientboundPacketsa1_2_0::getPacket)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_3_1_2_3_4toa1_2_2/Protocola1_2_3_1_2_3_4toa1_2_2.java b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_3_1_2_3_4toa1_2_2/Protocola1_2_3_1_2_3_4toa1_2_2.java index 0a997d8..d7f7d63 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_3_1_2_3_4toa1_2_2/Protocola1_2_3_1_2_3_4toa1_2_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_3_1_2_3_4toa1_2_2/Protocola1_2_3_1_2_3_4toa1_2_2.java @@ -61,7 +61,7 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocola1_2_3_1_2_3_4toa1_2_2.class, ClientboundPacketsa1_2_2::getPacket)); + userConnection.put(new PreNettySplitter(Protocola1_2_3_1_2_3_4toa1_2_2.class, ClientboundPacketsa1_2_2::getPacket)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4/Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4.java b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4/Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4.java index c046bb6..342d1a9 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4/Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4/Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4.java @@ -46,7 +46,7 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4.class, ClientboundPacketsa1_2_3::getPacket)); + userConnection.put(new PreNettySplitter(Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4.class, ClientboundPacketsa1_2_3::getPacket)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocolb1_0_1_1_1toa1_2_3_5_1_2_6/Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.java b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocolb1_0_1_1_1toa1_2_3_5_1_2_6/Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.java index 0fabad9..a8d8397 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocolb1_0_1_1_1toa1_2_3_5_1_2_6/Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocolb1_0_1_1_1toa1_2_3_5_1_2_6/Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.java @@ -160,7 +160,7 @@ public void register() { wrapper.cancel(); final InventoryStorage tracker = wrapper.user().get(InventoryStorage.class); final Position pos = wrapper.read(Types1_7_6.POSITION_SHORT); // position - final CompoundTag tag = wrapper.read(Types1_7_6.COMPRESSED_NBT); // data + final CompoundTag tag = wrapper.read(Types1_7_6.NBT); // data if (tag.get("x").asInt() != pos.x() || tag.get("y").asInt() != pos.y() || tag.get("z").asInt() != pos.z()) { return; @@ -365,7 +365,7 @@ public void register() { wrapper.write(Type.INT, tracker.openContainerPos.x()); wrapper.write(Type.SHORT, (short) tracker.openContainerPos.y()); wrapper.write(Type.INT, tracker.openContainerPos.z()); - wrapper.write(Types1_7_6.COMPRESSED_NBT, tag); + wrapper.write(Types1_7_6.NBT, tag); }); } }); @@ -384,7 +384,7 @@ public void register() { tag.put("Text2", new StringTag(wrapper.read(Typesb1_7_0_3.STRING))); // line 2 tag.put("Text3", new StringTag(wrapper.read(Typesb1_7_0_3.STRING))); // line 3 tag.put("Text4", new StringTag(wrapper.read(Typesb1_7_0_3.STRING))); // line 4 - wrapper.write(Types1_7_6.COMPRESSED_NBT, tag); // data + wrapper.write(Types1_7_6.NBT, tag); // data }); } }); @@ -528,9 +528,9 @@ public void register(ViaProviders providers) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class, ClientboundPacketsa1_2_6::getPacket)); + userConnection.put(new PreNettySplitter(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class, ClientboundPacketsa1_2_6::getPacket)); - userConnection.put(new InventoryStorage(userConnection)); + userConnection.put(new InventoryStorage()); if (Via.getManager().getProviders().get(AlphaInventoryProvider.class).usesInventoryTracker()) { userConnection.put(new AlphaInventoryTracker(userConnection)); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocolb1_0_1_1_1toa1_2_3_5_1_2_6/storage/InventoryStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocolb1_0_1_1_1toa1_2_3_5_1_2_6/storage/InventoryStorage.java index c35ec5c..73f7702 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocolb1_0_1_1_1toa1_2_3_5_1_2_6/storage/InventoryStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/alpha/protocolb1_0_1_1_1toa1_2_3_5_1_2_6/storage/InventoryStorage.java @@ -17,8 +17,7 @@ */ package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.item.Item; @@ -26,7 +25,7 @@ import java.util.Iterator; import java.util.Map; -public class InventoryStorage extends StoredObject { +public class InventoryStorage implements StorableObject { public static final byte WORKBENCH_WID = 33; public static final byte FURNACE_WID = 44; @@ -42,8 +41,7 @@ public class InventoryStorage extends StoredObject { public Position openContainerPos = null; public short selectedHotbarSlot = 0; - public InventoryStorage(UserConnection user) { - super(user); + public InventoryStorage() { this.resetPlayerInventory(); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocol1_0_0_1tob1_8_0_1/Protocol1_0_0_1tob1_8_0_1.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocol1_0_0_1tob1_8_0_1/Protocol1_0_0_1tob1_8_0_1.java index 149016a..306aeef 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocol1_0_0_1tob1_8_0_1/Protocol1_0_0_1tob1_8_0_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocol1_0_0_1tob1_8_0_1/Protocol1_0_0_1tob1_8_0_1.java @@ -66,14 +66,14 @@ public void register() { public void register() { map(Type.BYTE); // window id map(Type.SHORT); // slot - map(Types1_4_2.NBTLESS_ITEM, Types1_2_4.COMPRESSED_NBT_ITEM); // item + map(Types1_4_2.NBTLESS_ITEM, Types1_2_4.NBT_ITEM); // item } }); this.registerClientbound(ClientboundPacketsb1_8.WINDOW_ITEMS, new PacketHandlers() { @Override public void register() { map(Type.BYTE); // window id - map(Types1_4_2.NBTLESS_ITEM_ARRAY, Types1_2_4.COMPRESSED_NBT_ITEM_ARRAY); // item + map(Types1_4_2.NBTLESS_ITEM_ARRAY, Types1_2_4.NBT_ITEM_ARRAY); // item } }); @@ -82,7 +82,7 @@ public void register() { public void register() { map(Types1_7_6.POSITION_UBYTE); // position map(Type.UNSIGNED_BYTE); // direction - map(Types1_2_4.COMPRESSED_NBT_ITEM, Types1_4_2.NBTLESS_ITEM); + map(Types1_2_4.NBT_ITEM, Types1_4_2.NBTLESS_ITEM); } }); this.registerServerbound(ServerboundPackets1_0.CLICK_WINDOW, new PacketHandlers() { @@ -93,14 +93,14 @@ public void register() { map(Type.BYTE); // button map(Type.SHORT); // action map(Type.BYTE); // mode - map(Types1_2_4.COMPRESSED_NBT_ITEM, Types1_4_2.NBTLESS_ITEM); // item + map(Types1_2_4.NBT_ITEM, Types1_4_2.NBTLESS_ITEM); // item } }); this.registerServerbound(ServerboundPackets1_0.CREATIVE_INVENTORY_ACTION, new PacketHandlers() { @Override public void register() { map(Type.SHORT); // slot - map(Types1_2_4.COMPRESSED_NBT_ITEM, Typesb1_8_0_1.CREATIVE_ITEM); // item + map(Types1_2_4.NBT_ITEM, Typesb1_8_0_1.CREATIVE_ITEM); // item handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Typesb1_8_0_1.CREATIVE_ITEM, 0))); } }); @@ -114,9 +114,9 @@ public void register(ViaProviders providers) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_0_0_1tob1_8_0_1.class, ClientboundPacketsb1_8::getPacket)); + userConnection.put(new PreNettySplitter(Protocol1_0_0_1tob1_8_0_1.class, ClientboundPacketsb1_8::getPacket)); - userConnection.put(new PlayerAirTimeStorage(userConnection)); + userConnection.put(new PlayerAirTimeStorage()); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocol1_0_0_1tob1_8_0_1/storage/PlayerAirTimeStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocol1_0_0_1tob1_8_0_1/storage/PlayerAirTimeStorage.java index ad988bc..2bcb07c 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocol1_0_0_1tob1_8_0_1/storage/PlayerAirTimeStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocol1_0_0_1tob1_8_0_1/storage/PlayerAirTimeStorage.java @@ -17,17 +17,12 @@ */ package net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; -public class PlayerAirTimeStorage extends StoredObject { +public class PlayerAirTimeStorage implements StorableObject { public final int MAX_AIR = 300; public int air = MAX_AIR; public boolean sentPacket = true; - public PlayerAirTimeStorage(UserConnection user) { - super(user); - } - } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/Protocolb1_2_0_2tob1_1_2.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/Protocolb1_2_0_2tob1_1_2.java index 06cdc79..054e9ff 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/Protocolb1_2_0_2tob1_1_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/Protocolb1_2_0_2tob1_1_2.java @@ -19,7 +19,6 @@ import com.google.common.collect.Lists; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; @@ -135,11 +134,7 @@ public void register() { this.registerClientbound(ClientboundPacketsb1_1.CHUNK_DATA, new PacketHandlers() { @Override public void register() { - handler(wrapper -> { - final ClientWorld clientWorld = new ClientWorld(wrapper.user()); - clientWorld.setEnvironment(0); - BLOCK_DATA_REWRITER.remapChunk(wrapper.passthrough(Types1_1.CHUNK)); - }); + handler(wrapper -> BLOCK_DATA_REWRITER.remapChunk(wrapper.passthrough(Types1_1.CHUNK))); // chunk } }); this.registerClientbound(ClientboundPacketsb1_1.MULTI_BLOCK_CHANGE, new PacketHandlers() { @@ -203,9 +198,9 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocolb1_2_0_2tob1_1_2.class, ClientboundPacketsb1_1::getPacket)); + userConnection.put(new PreNettySplitter(Protocolb1_2_0_2tob1_1_2.class, ClientboundPacketsb1_1::getPacket)); - userConnection.put(new EntityFlagStorage(userConnection)); + userConnection.put(new EntityFlagStorage()); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/storage/EntityFlagStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/storage/EntityFlagStorage.java index 4d5ae01..3984667 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/storage/EntityFlagStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/storage/EntityFlagStorage.java @@ -17,19 +17,14 @@ */ package net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap; import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap; -public class EntityFlagStorage extends StoredObject { +public class EntityFlagStorage implements StorableObject { private final Int2IntMap animationFlags = new Int2IntOpenHashMap(); - public EntityFlagStorage(UserConnection user) { - super(user); - } - public boolean getFlag(final int entityId, final int index) { return (this.getFlagMask(entityId) & 1 << index) != 0; } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/Protocolb1_3_0_1tob1_2_0_2.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/Protocolb1_3_0_1tob1_2_0_2.java index dc66e3e..9f2c5a1 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/Protocolb1_3_0_1tob1_2_0_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/Protocolb1_3_0_1tob1_2_0_2.java @@ -140,7 +140,7 @@ public void register(ViaProviders providers) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocolb1_3_0_1tob1_2_0_2.class, ClientboundPacketsb1_2::getPacket)); + userConnection.put(new PreNettySplitter(Protocolb1_3_0_1tob1_2_0_2.class, ClientboundPacketsb1_2::getPacket)); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_4_0_1tob1_3_0_1/Protocolb1_4_0_1tob1_3_0_1.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_4_0_1tob1_3_0_1/Protocolb1_4_0_1tob1_3_0_1.java index 98583c9..d71ff09 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_4_0_1tob1_3_0_1/Protocolb1_4_0_1tob1_3_0_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_4_0_1tob1_3_0_1/Protocolb1_4_0_1tob1_3_0_1.java @@ -31,7 +31,7 @@ public Protocolb1_4_0_1tob1_3_0_1() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocolb1_4_0_1tob1_3_0_1.class, ClientboundPacketsb1_3::getPacket)); + userConnection.put(new PreNettySplitter(Protocolb1_4_0_1tob1_3_0_1.class, ClientboundPacketsb1_3::getPacket)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/Protocolb1_5_0_2tob1_4_0_1.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/Protocolb1_5_0_2tob1_4_0_1.java index bb88989..323b797 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/Protocolb1_5_0_2tob1_4_0_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/Protocolb1_5_0_2tob1_4_0_1.java @@ -190,7 +190,7 @@ private void rewriteMetadata(final List metadataList) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocolb1_5_0_2tob1_4_0_1.class, ClientboundPacketsb1_4::getPacket)); + userConnection.put(new PreNettySplitter(Protocolb1_5_0_2tob1_4_0_1.class, ClientboundPacketsb1_4::getPacket)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_6_0_6tob1_5_0_2/Protocolb1_6_0_6tob1_5_0_2.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_6_0_6tob1_5_0_2/Protocolb1_6_0_6tob1_5_0_2.java index 41f8b2c..7129d3a 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_6_0_6tob1_5_0_2/Protocolb1_6_0_6tob1_5_0_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_6_0_6tob1_5_0_2/Protocolb1_6_0_6tob1_5_0_2.java @@ -165,9 +165,9 @@ public void register(ViaProviders providers) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocolb1_6_0_6tob1_5_0_2.class, ClientboundPacketsb1_5::getPacket)); + userConnection.put(new PreNettySplitter(Protocolb1_6_0_6tob1_5_0_2.class, ClientboundPacketsb1_5::getPacket)); - userConnection.put(new WorldTimeStorage(userConnection)); + userConnection.put(new WorldTimeStorage()); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_6_0_6tob1_5_0_2/storage/WorldTimeStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_6_0_6tob1_5_0_2/storage/WorldTimeStorage.java index 75ee4db..d68acc3 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_6_0_6tob1_5_0_2/storage/WorldTimeStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_6_0_6tob1_5_0_2/storage/WorldTimeStorage.java @@ -17,15 +17,10 @@ */ package net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; -public class WorldTimeStorage extends StoredObject { +public class WorldTimeStorage implements StorableObject { public long time; - public WorldTimeStorage(UserConnection user) { - super(user); - } - } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/Protocolb1_8_0_1tob1_7_0_3.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/Protocolb1_8_0_1tob1_7_0_3.java index 5cff9f5..5aba205 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/Protocolb1_8_0_1tob1_7_0_3.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/Protocolb1_8_0_1tob1_7_0_3.java @@ -352,10 +352,10 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocolb1_8_0_1tob1_7_0_3.class, ClientboundPacketsb1_7::getPacket)); + userConnection.put(new PreNettySplitter(Protocolb1_8_0_1tob1_7_0_3.class, ClientboundPacketsb1_7::getPacket)); - userConnection.put(new PlayerNameTracker(userConnection)); - userConnection.put(new PlayerHealthTracker(userConnection)); + userConnection.put(new PlayerNameTracker()); + userConnection.put(new PlayerHealthTracker()); } private boolean isSword(final Item item) { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/storage/PlayerHealthTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/storage/PlayerHealthTracker.java index b29afd1..be40af2 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/storage/PlayerHealthTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/storage/PlayerHealthTracker.java @@ -17,17 +17,12 @@ */ package net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; -public class PlayerHealthTracker extends StoredObject { +public class PlayerHealthTracker implements StorableObject { private short health = 20; - public PlayerHealthTracker(UserConnection user) { - super(user); - } - public void setHealth(final short health) { this.health = health; } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/storage/PlayerNameTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/storage/PlayerNameTracker.java index 1c6506e..7d00b8c 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/storage/PlayerNameTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/storage/PlayerNameTracker.java @@ -17,17 +17,12 @@ */ package net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectArrayMap; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; -public class PlayerNameTracker extends StoredObject { +public class PlayerNameTracker implements StorableObject { public final Int2ObjectMap names = new Int2ObjectArrayMap<>(); - public PlayerNameTracker(UserConnection user) { - super(user); - } - } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/Protocola1_0_15toc0_30.java b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/Protocola1_0_15toc0_30.java index 6ce67c4..30f006b 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/Protocola1_0_15toc0_30.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/Protocola1_0_15toc0_30.java @@ -545,12 +545,12 @@ public void register(ViaProviders providers) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocola1_0_15toc0_30.class, ClientboundPacketsc0_28::getPacket)); + userConnection.put(new PreNettySplitter(Protocola1_0_15toc0_30.class, ClientboundPacketsc0_28::getPacket)); - userConnection.put(new ClassicPositionTracker(userConnection)); + userConnection.put(new ClassicPositionTracker()); userConnection.put(new ClassicOpLevelStorage(userConnection, ViaLegacy.getConfig().enableClassicFly())); - userConnection.put(new ClassicProgressStorage(userConnection)); - userConnection.put(new ClassicBlockRemapper(userConnection, i -> ClassicBlocks.MAPPING.get(i), o -> { + userConnection.put(new ClassicProgressStorage()); + userConnection.put(new ClassicBlockRemapper(i -> ClassicBlocks.MAPPING.get(i), o -> { int block = ClassicBlocks.REVERSE_MAPPING.getInt(o); if (!userConnection.getProtocolInfo().getPipeline().contains(Protocolc0_30toc0_30cpe.class)) { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicBlockRemapper.java b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicBlockRemapper.java index 47c5ff9..68c2f82 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicBlockRemapper.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicBlockRemapper.java @@ -17,19 +17,17 @@ */ package net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectFunction; import com.viaversion.viaversion.libs.fastutil.objects.Object2IntFunction; import net.raphimc.vialegacy.api.model.IdAndData; -public class ClassicBlockRemapper extends StoredObject { +public class ClassicBlockRemapper implements StorableObject { private final Int2ObjectFunction mapper; private final Object2IntFunction reverseMapper; - public ClassicBlockRemapper(UserConnection user, Int2ObjectFunction mapper, Object2IntFunction reverseMapper) { - super(user); + public ClassicBlockRemapper(Int2ObjectFunction mapper, Object2IntFunction reverseMapper) { this.mapper = mapper; this.reverseMapper = reverseMapper; } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicPositionTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicPositionTracker.java index e746e96..046e7e9 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicPositionTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicPositionTracker.java @@ -17,14 +17,13 @@ */ package net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; import net.raphimc.vialegacy.api.model.ChunkCoord; -public class ClassicPositionTracker extends StoredObject { +public class ClassicPositionTracker implements StorableObject { public double posX; public double stance; @@ -34,10 +33,6 @@ public class ClassicPositionTracker extends StoredObject { public boolean spawned; - public ClassicPositionTracker(final UserConnection user) { - super(user); - } - public void writeToPacket(final PacketWrapper wrapper) { final int x = (int) (this.posX * 32.0F); final int y = (int) (this.stance * 32.0F); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicProgressStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicProgressStorage.java index edb41da..24b72ac 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicProgressStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocola1_0_15toc0_28_30/storage/ClassicProgressStorage.java @@ -17,17 +17,12 @@ */ package net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; -public class ClassicProgressStorage extends StoredObject { +public class ClassicProgressStorage implements StorableObject { public int upperBound = 100; public int progress; // 0% - upperBound public String status = "Waiting..."; - public ClassicProgressStorage(UserConnection user) { - super(user); - } - } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_16a_02to0_0_15a_1/Protocolc0_0_16a_02to0_0_15a_1.java b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_16a_02to0_0_15a_1/Protocolc0_0_16a_02to0_0_15a_1.java index e145fb5..9c0004a 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_16a_02to0_0_15a_1/Protocolc0_0_16a_02to0_0_15a_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_16a_02to0_0_15a_1/Protocolc0_0_16a_02to0_0_15a_1.java @@ -87,7 +87,7 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocolc0_0_16a_02to0_0_15a_1.class, ClientboundPacketsc0_15a::getPacket)); + userConnection.put(new PreNettySplitter(Protocolc0_0_16a_02to0_0_15a_1.class, ClientboundPacketsc0_15a::getPacket)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_19a_06toc0_0_18a_02/Protocolc0_0_19a_06toc0_0_18a_02.java b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_19a_06toc0_0_18a_02/Protocolc0_0_19a_06toc0_0_18a_02.java index dddcedc..4580204 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_19a_06toc0_0_18a_02/Protocolc0_0_19a_06toc0_0_18a_02.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_19a_06toc0_0_18a_02/Protocolc0_0_19a_06toc0_0_18a_02.java @@ -33,7 +33,7 @@ public Protocolc0_0_19a_06toc0_0_18a_02() { @Override public void init(UserConnection userConnection) { final ClassicBlockRemapper previousRemapper = userConnection.get(ClassicBlockRemapper.class); - userConnection.put(new ClassicBlockRemapper(userConnection, previousRemapper.getMapper(), o -> { + userConnection.put(new ClassicBlockRemapper(previousRemapper.getMapper(), o -> { int block = previousRemapper.getReverseMapper().getInt(o); if (userConnection.getProtocolInfo().getPipeline().contains(Protocolc0_0_19a_06toc0_0_18a_02.class)) { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_20a_27toc0_0_19a_06/Protocolc0_27toc0_0_19a_06.java b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_20a_27toc0_0_19a_06/Protocolc0_27toc0_0_19a_06.java index 1ba4d22..992d3f6 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_20a_27toc0_0_19a_06/Protocolc0_27toc0_0_19a_06.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_0_20a_27toc0_0_19a_06/Protocolc0_27toc0_0_19a_06.java @@ -60,10 +60,10 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocolc0_27toc0_0_19a_06.class, ClientboundPacketsc0_19a::getPacket)); + userConnection.put(new PreNettySplitter(Protocolc0_27toc0_0_19a_06.class, ClientboundPacketsc0_19a::getPacket)); final ClassicBlockRemapper previousRemapper = userConnection.get(ClassicBlockRemapper.class); - userConnection.put(new ClassicBlockRemapper(userConnection, previousRemapper.getMapper(), o -> { + userConnection.put(new ClassicBlockRemapper(previousRemapper.getMapper(), o -> { int block = previousRemapper.getReverseMapper().getInt(o); if (!userConnection.getProtocolInfo().getPipeline().contains(Protocolc0_0_19a_06toc0_0_18a_02.class)) { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_0_20a_27/Protocolc0_30toc0_27.java b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_0_20a_27/Protocolc0_30toc0_27.java index 7ae2512..972c3a0 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_0_20a_27/Protocolc0_30toc0_27.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_0_20a_27/Protocolc0_30toc0_27.java @@ -34,10 +34,10 @@ public Protocolc0_30toc0_27() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocolc0_30toc0_27.class, ClientboundPacketsc0_20a::getPacket)); + userConnection.put(new PreNettySplitter(Protocolc0_30toc0_27.class, ClientboundPacketsc0_20a::getPacket)); final ClassicBlockRemapper previousRemapper = userConnection.get(ClassicBlockRemapper.class); - userConnection.put(new ClassicBlockRemapper(userConnection, previousRemapper.getMapper(), o -> { + userConnection.put(new ClassicBlockRemapper(previousRemapper.getMapper(), o -> { int block = previousRemapper.getReverseMapper().getInt(o); if (!userConnection.getProtocolInfo().getPipeline().contains(Protocolc0_27toc0_0_19a_06.class)) { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/Protocolc0_30toc0_30cpe.java b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/Protocolc0_30toc0_30cpe.java index 759060f..e28b7c1 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/Protocolc0_30toc0_30cpe.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/Protocolc0_30toc0_30cpe.java @@ -134,7 +134,7 @@ public void register() { } if (supportedExtensions.contains(ClassicProtocolExtension.BLOCK_PERMISSIONS)) { - wrapper.user().put(new ExtBlockPermissionsStorage(wrapper.user())); + wrapper.user().put(new ExtBlockPermissionsStorage()); } final PacketWrapper extensionProtocolInfo = PacketWrapper.create(ServerboundPacketsc0_30cpe.EXTENSION_PROTOCOL_INFO, wrapper.user()); @@ -344,13 +344,13 @@ public void register(ViaProviders providers) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocolc0_30toc0_30cpe.class, ClientboundPacketsc0_30cpe::getPacket)); + userConnection.put(new PreNettySplitter(Protocolc0_30toc0_30cpe.class, ClientboundPacketsc0_30cpe::getPacket)); - userConnection.put(new ExtensionProtocolMetadataStorage(userConnection)); + userConnection.put(new ExtensionProtocolMetadataStorage()); userConnection.put(new ClassicOpLevelStorage(userConnection, true)); final ClassicBlockRemapper previousRemapper = userConnection.get(ClassicBlockRemapper.class); - userConnection.put(new ClassicBlockRemapper(userConnection, i -> { + userConnection.put(new ClassicBlockRemapper(i -> { if (ClassicBlocks.MAPPING.containsKey(i)) return previousRemapper.getMapper().get(i); final ExtensionProtocolMetadataStorage extensionProtocol = userConnection.get(ExtensionProtocolMetadataStorage.class); if (extensionProtocol.hasServerExtension(ClassicProtocolExtension.CUSTOM_BLOCKS, 1)) { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/storage/ExtBlockPermissionsStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/storage/ExtBlockPermissionsStorage.java index c961feb..58fe4f5 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/storage/ExtBlockPermissionsStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/storage/ExtBlockPermissionsStorage.java @@ -17,20 +17,15 @@ */ package net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.libs.fastutil.ints.IntOpenHashSet; import com.viaversion.viaversion.libs.fastutil.ints.IntSet; -public class ExtBlockPermissionsStorage extends StoredObject { +public class ExtBlockPermissionsStorage implements StorableObject { private final IntSet placingDenied = new IntOpenHashSet(); private final IntSet breakingDenied = new IntOpenHashSet(); - public ExtBlockPermissionsStorage(final UserConnection user) { - super(user); - } - public void addPlaceable(final int block) { this.placingDenied.remove(block); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/storage/ExtensionProtocolMetadataStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/storage/ExtensionProtocolMetadataStorage.java index ab46c3e..8dc6e56 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/storage/ExtensionProtocolMetadataStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/classic/protocolc0_28_30toc0_28_30cpe/storage/ExtensionProtocolMetadataStorage.java @@ -17,13 +17,12 @@ */ package net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension; import java.util.EnumMap; -public class ExtensionProtocolMetadataStorage extends StoredObject { +public class ExtensionProtocolMetadataStorage implements StorableObject { private String serverSoftwareName = "classic"; private short extensionCount = -1; @@ -31,10 +30,6 @@ public class ExtensionProtocolMetadataStorage extends StoredObject { private final EnumMap serverExtensions = new EnumMap<>(ClassicProtocolExtension.class); - public ExtensionProtocolMetadataStorage(final UserConnection user) { - super(user); - } - public void setServerSoftwareName(final String serverSoftwareName) { if (serverSoftwareName.isEmpty()) return; this.serverSoftwareName = serverSoftwareName; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_1to1_0_0_1/Protocol1_1to1_0_0_1.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_1to1_0_0_1/Protocol1_1to1_0_0_1.java index 4a6a69a..c894dfc 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_1to1_0_0_1/Protocol1_1to1_0_0_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_1to1_0_0_1/Protocol1_1to1_0_0_1.java @@ -128,7 +128,7 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_1to1_0_0_1.class, ClientboundPackets1_0::getPacket)); + userConnection.put(new PreNettySplitter(Protocol1_1to1_0_0_1.class, ClientboundPackets1_0::getPacket)); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_1to1_0_0_1/rewriter/ItemRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_1to1_0_0_1/rewriter/ItemRewriter.java index 9fd9f58..a0f0d53 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_1to1_0_0_1/rewriter/ItemRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_1to1_0_0_1/rewriter/ItemRewriter.java @@ -32,7 +32,7 @@ public ItemRewriter(final Protocol1_1to1_0_0_1 protocol) { @Override protected void registerPackets() { - this.registerCreativeInventoryAction(ServerboundPackets1_1.CREATIVE_INVENTORY_ACTION, Types1_2_4.COMPRESSED_NBT_ITEM); + this.registerCreativeInventoryAction(ServerboundPackets1_1.CREATIVE_INVENTORY_ACTION, Types1_2_4.NBT_ITEM); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/Protocol1_2_1_3to1_1.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/Protocol1_2_1_3to1_1.java index aedfd96..3b06477 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/Protocol1_2_1_3to1_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/Protocol1_2_1_3to1_1.java @@ -320,8 +320,7 @@ public void register() { } private void handleRespawn(final int dimensionId, final UserConnection user) { - if (user.get(DimensionTracker.class).getDimensionId() != dimensionId) { - user.get(DimensionTracker.class).setDimension(dimensionId); + if (user.get(DimensionTracker.class).changeDimension(dimensionId)) { user.get(PendingBlocksTracker.class).clear(); } @@ -363,11 +362,11 @@ public void register(ViaProviders providers) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_2_1_3to1_1.class, ClientboundPackets1_1::getPacket)); + userConnection.put(new PreNettySplitter(Protocol1_2_1_3to1_1.class, ClientboundPackets1_1::getPacket)); - userConnection.put(new SeedStorage(userConnection)); + userConnection.put(new SeedStorage()); userConnection.put(new PendingBlocksTracker(userConnection)); - userConnection.put(new DimensionTracker(userConnection)); + userConnection.put(new DimensionTracker()); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/rewriter/ItemRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/rewriter/ItemRewriter.java index 7cce81f..9a2400a 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/rewriter/ItemRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/rewriter/ItemRewriter.java @@ -38,7 +38,7 @@ public ItemRewriter(final Protocol1_2_1_3to1_1 protocol) { @Override protected void registerPackets() { - this.registerCreativeInventoryAction(ServerboundPackets1_2_1.CREATIVE_INVENTORY_ACTION, Types1_2_4.COMPRESSED_NBT_ITEM); + this.registerCreativeInventoryAction(ServerboundPackets1_2_1.CREATIVE_INVENTORY_ACTION, Types1_2_4.NBT_ITEM); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/storage/DimensionTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/storage/DimensionTracker.java index c9545ac..30e0e22 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/storage/DimensionTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/storage/DimensionTracker.java @@ -17,23 +17,22 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; +import com.viaversion.viaversion.api.minecraft.Environment; -public class DimensionTracker extends StoredObject { +public class DimensionTracker implements StorableObject { - private int dimensionId = 0; + private Environment dimension = Environment.NORMAL; - public DimensionTracker(UserConnection user) { - super(user); + public boolean changeDimension(final int dimensionId) { + final Environment newDimension = Environment.getEnvironmentById(dimensionId); + final boolean dimensionChanged = newDimension != this.dimension; + this.dimension = Environment.getEnvironmentById(dimensionId); + return dimensionChanged; } - public void setDimension(final int dimensionId) { - this.dimensionId = dimensionId; - } - - public int getDimensionId() { - return this.dimensionId; + public Environment getDimension() { + return this.dimension; } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/storage/SeedStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/storage/SeedStorage.java index 5ed0fc8..f9f72ec 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/storage/SeedStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/storage/SeedStorage.java @@ -17,17 +17,12 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.biome.IWorldChunkManager; -public class SeedStorage extends StoredObject { +public class SeedStorage implements StorableObject { public long seed; public IWorldChunkManager worldChunkManager; - public SeedStorage(UserConnection user) { - super(user); - } - } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/ChunkType1_1.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/ChunkType1_1.java index 58a9d6d..2d05877 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/ChunkType1_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/ChunkType1_1.java @@ -20,7 +20,6 @@ import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.chunks.*; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.api.type.types.FixedByteArrayType; import io.netty.buffer.ByteBuf; import net.raphimc.vialegacy.api.model.IdAndData; import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.chunks.NibbleArray1_1; @@ -46,7 +45,8 @@ public Chunk read(ByteBuf byteBuf) throws Exception { final int ySize = byteBuf.readUnsignedByte() + 1; final int zSize = byteBuf.readUnsignedByte() + 1; final int chunkSize = byteBuf.readInt(); - final byte[] compressedData = new FixedByteArrayType(chunkSize).read(byteBuf); + final byte[] compressedData = new byte[chunkSize]; + byteBuf.readBytes(compressedData); final byte[] uncompressedData = new byte[(xSize * ySize * zSize * 5) / 2]; final Inflater inflater = new Inflater(); inflater.setInput(compressedData); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_4_5to1_2_1_3/Protocol1_2_4_5to1_2_1_3.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_4_5to1_2_1_3/Protocol1_2_4_5to1_2_1_3.java index ef2cddc..366cdbb 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_4_5to1_2_1_3/Protocol1_2_4_5to1_2_1_3.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_4_5to1_2_1_3/Protocol1_2_4_5to1_2_1_3.java @@ -42,7 +42,7 @@ protected void registerPackets() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_2_4_5to1_2_1_3.class, ClientboundPackets1_2_1::getPacket)); + userConnection.put(new PreNettySplitter(Protocol1_2_4_5to1_2_1_3.class, ClientboundPackets1_2_1::getPacket)); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_4_5to1_2_1_3/rewriter/ItemRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_4_5to1_2_1_3/rewriter/ItemRewriter.java index 62a90a3..65bf314 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_4_5to1_2_1_3/rewriter/ItemRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_4_5to1_2_1_3/rewriter/ItemRewriter.java @@ -33,7 +33,7 @@ public ItemRewriter(final Protocol1_2_4_5to1_2_1_3 protocol) { @Override protected void registerPackets() { - this.registerCreativeInventoryAction(ServerboundPackets1_2_4.CREATIVE_INVENTORY_ACTION, Types1_2_4.COMPRESSED_NBT_ITEM); + this.registerCreativeInventoryAction(ServerboundPackets1_2_4.CREATIVE_INVENTORY_ACTION, Types1_2_4.NBT_ITEM); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/Protocol1_3_1_2to1_2_4_5.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/Protocol1_3_1_2to1_2_4_5.java index 433646b..17bf338 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/Protocol1_3_1_2to1_2_4_5.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/Protocol1_3_1_2to1_2_4_5.java @@ -21,7 +21,6 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.ProtocolInfo; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.chunks.*; @@ -67,7 +66,6 @@ import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.metadata.MetaIndex1_8to1_7_6; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkType1_7_6; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6; import java.util.ArrayList; @@ -141,8 +139,7 @@ public void register() { map(Type.BYTE); // world height map(Type.BYTE); // max players handler(wrapper -> { - wrapper.user().get(ClientWorld.class).setEnvironment(wrapper.get(Type.BYTE, 1)); - wrapper.user().get(DimensionTracker.class).setDimension(wrapper.get(Type.BYTE, 1)); + wrapper.user().get(DimensionTracker.class).changeDimension(wrapper.get(Type.BYTE, 1)); final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); entityTracker.setPlayerID(wrapper.get(Type.INT, 0)); entityTracker.getTrackedEntities().put(entityTracker.getPlayerID(), new TrackedLivingEntity(entityTracker.getPlayerID(), new Location(8, 64, 8), EntityTypes1_10.EntityType.PLAYER)); @@ -157,7 +154,7 @@ public void register() { handler(wrapper -> { final int itemId = wrapper.read(Type.SHORT); // item id final short itemDamage = wrapper.read(Type.SHORT); // item damage - wrapper.write(Types1_7_6.COMPRESSED_ITEM, itemId < 0 ? null : new DataItem(itemId, (byte) 1, itemDamage, null)); + wrapper.write(Types1_7_6.ITEM, itemId < 0 ? null : new DataItem(itemId, (byte) 1, itemDamage, null)); }); } }); @@ -170,11 +167,7 @@ public void register() { map(Type.SHORT); // world height map(Types1_6_4.STRING); // level type handler(wrapper -> { - final int oldDim = wrapper.user().get(DimensionTracker.class).getDimensionId(); - final int newDim = wrapper.get(Type.INT, 0); - wrapper.user().get(ClientWorld.class).setEnvironment(newDim); - wrapper.user().get(DimensionTracker.class).setDimension(newDim); - if (oldDim != newDim) { + if (wrapper.user().get(DimensionTracker.class).changeDimension(wrapper.get(Type.INT, 0))) { wrapper.user().get(ChestStateTracker.class).clear(); final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); entityTracker.getTrackedEntities().clear(); @@ -459,7 +452,7 @@ public void register() { if (!load) { final Chunk chunk = new BaseChunk(chunkX, chunkZ, true, false, 0, new ChunkSection[16], null, new ArrayList<>()); - wrapper.write(Types1_7_6.getChunk(wrapper.user().get(ClientWorld.class).getEnvironment()), chunk); + wrapper.write(Types1_7_6.getChunk(wrapper.user().get(DimensionTracker.class).getDimension()), chunk); } else { wrapper.cancel(); } @@ -470,7 +463,7 @@ public void register() { @Override public void register() { handler(wrapper -> { - final Environment environment = wrapper.user().get(ClientWorld.class).getEnvironment(); + final Environment dimension = wrapper.user().get(DimensionTracker.class).getDimension(); Chunk chunk = wrapper.read(Types1_2_4.CHUNK); wrapper.user().get(ChestStateTracker.class).unload(chunk.getX(), chunk.getZ()); @@ -481,7 +474,7 @@ public void register() { for (int i = 0; i < chunk.getSections().length; i++) { final ChunkSection section = chunk.getSections()[i] = new ChunkSectionImpl(true); section.palette(PaletteType.BLOCKS).addId(0); - if (environment == Environment.NORMAL) { + if (dimension == Environment.NORMAL) { final byte[] skyLight = new byte[2048]; Arrays.fill(skyLight, (byte) 255); section.getLight().setSkyLight(skyLight); @@ -489,14 +482,14 @@ public void register() { } } - if (environment != Environment.NORMAL) { + if (dimension != Environment.NORMAL) { for (ChunkSection section : chunk.getSections()) { if (section != null) { section.getLight().setSkyLight(null); } } } - wrapper.write(Types1_7_6.getChunk(environment), chunk); + wrapper.write(Types1_7_6.getChunk(dimension), chunk); }); } }); @@ -609,14 +602,14 @@ public void register() { public void register() { map(Type.BYTE); // window id map(Type.SHORT); // slot - map(Types1_2_4.COMPRESSED_NBT_ITEM, Types1_7_6.COMPRESSED_ITEM); // item + map(Types1_2_4.NBT_ITEM, Types1_7_6.ITEM); // item } }); this.registerClientbound(ClientboundPackets1_2_4.WINDOW_ITEMS, new PacketHandlers() { @Override public void register() { map(Type.BYTE); // window id - map(Types1_2_4.COMPRESSED_NBT_ITEM_ARRAY, Types1_7_6.COMPRESSED_ITEM_ARRAY); // items + map(Types1_2_4.NBT_ITEM_ARRAY, Types1_7_6.ITEM_ARRAY); // items } }); this.registerClientbound(ClientboundPackets1_2_4.BLOCK_ENTITY_DATA, new PacketHandlers() { @@ -640,7 +633,7 @@ public void register() { tag.put("x", new IntTag(pos.x())); tag.put("y", new IntTag(pos.y())); tag.put("z", new IntTag(pos.z())); - wrapper.write(Types1_7_6.COMPRESSED_NBT, tag); + wrapper.write(Types1_7_6.NBT, tag); }); } }); @@ -730,7 +723,7 @@ public void register() { public void register() { map(Types1_7_6.POSITION_UBYTE); // position map(Type.UNSIGNED_BYTE); // direction - map(Types1_7_6.COMPRESSED_ITEM, Types1_2_4.COMPRESSED_NBT_ITEM); // item + map(Types1_7_6.ITEM, Types1_2_4.NBT_ITEM); // item read(Type.UNSIGNED_BYTE); // offset x read(Type.UNSIGNED_BYTE); // offset y read(Type.UNSIGNED_BYTE); // offset z @@ -744,15 +737,15 @@ public void register() { map(Type.BYTE); // button map(Type.SHORT); // action map(Type.BYTE); // mode - map(Types1_7_6.COMPRESSED_ITEM, Types1_2_4.COMPRESSED_NBT_ITEM); // item + map(Types1_7_6.ITEM, Types1_2_4.NBT_ITEM); // item } }); this.registerServerbound(ServerboundPackets1_3_1.CREATIVE_INVENTORY_ACTION, new PacketHandlers() { @Override public void register() { map(Type.SHORT); // slot - map(Types1_7_6.COMPRESSED_ITEM, Types1_2_4.COMPRESSED_NBT_ITEM); // item - handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_2_4.COMPRESSED_NBT_ITEM, 0))); + map(Types1_7_6.ITEM, Types1_2_4.NBT_ITEM); // item + handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_2_4.NBT_ITEM, 0))); } }); this.registerServerbound(ServerboundPackets1_3_1.PLAYER_ABILITIES, new PacketHandlers() { @@ -851,14 +844,11 @@ public void register(ViaProviders providers) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_3_1_2to1_2_4_5.class, ClientboundPackets1_2_4::getPacket)); + userConnection.put(new PreNettySplitter(Protocol1_3_1_2to1_2_4_5.class, ClientboundPackets1_2_4::getPacket)); - userConnection.put(new ChestStateTracker(userConnection)); + userConnection.put(new ChestStateTracker()); userConnection.put(new EntityTracker(userConnection)); - userConnection.put(new DimensionTracker(userConnection)); - if (!userConnection.has(ClientWorld.class)) { - userConnection.put(new ClientWorld(userConnection)); - } + userConnection.put(new DimensionTracker()); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/ChestStateTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/ChestStateTracker.java index 1e66be2..2039d59 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/ChestStateTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/ChestStateTracker.java @@ -17,22 +17,17 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.api.minecraft.Position; import java.util.HashSet; import java.util.Iterator; import java.util.Set; -public class ChestStateTracker extends StoredObject { +public class ChestStateTracker implements StorableObject { private final Set openChests = new HashSet<>(); - public ChestStateTracker(final UserConnection userConnection) { - super(userConnection); - } - public void openChest(final Position position) { this.openChests.add(position); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/DimensionTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/DimensionTracker.java index 1f4e55a..af77288 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/DimensionTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/DimensionTracker.java @@ -17,23 +17,22 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; +import com.viaversion.viaversion.api.minecraft.Environment; -public class DimensionTracker extends StoredObject { +public class DimensionTracker implements StorableObject { - private int dimensionId = 0; + private Environment dimension = Environment.NORMAL; - public DimensionTracker(UserConnection user) { - super(user); + public boolean changeDimension(final int dimensionId) { + final Environment newDimension = Environment.getEnvironmentById(dimensionId); + final boolean dimensionChanged = newDimension != this.dimension; + this.dimension = Environment.getEnvironmentById(dimensionId); + return dimensionChanged; } - public void setDimension(final int dimensionId) { - this.dimensionId = dimensionId; - } - - public int getDimensionId() { - return this.dimensionId; + public Environment getDimension() { + return this.dimension; } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/ItemType.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/ItemType.java index a4246a5..862bea1 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/ItemType.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/ItemType.java @@ -40,7 +40,7 @@ public Item read(ByteBuf buffer) throws Exception { item.setAmount(buffer.readByte()); item.setData(buffer.readShort()); if (NbtItemList.hasNbt(id)) { - item.setTag(Types1_7_6.COMPRESSED_NBT.read(buffer)); + item.setTag(Types1_7_6.NBT.read(buffer)); } return item; } @@ -54,7 +54,7 @@ public void write(ByteBuf buffer, Item item) throws Exception { buffer.writeByte(item.amount()); buffer.writeShort(item.data()); if (NbtItemList.hasNbt(item.identifier())) { - Types1_7_6.COMPRESSED_NBT.write(buffer, item.tag()); + Types1_7_6.NBT.write(buffer, item.tag()); } } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/Types1_2_4.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/Types1_2_4.java index 1745cef..2e8024e 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/Types1_2_4.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/Types1_2_4.java @@ -24,8 +24,8 @@ public class Types1_2_4 { - public static final Type COMPRESSED_NBT_ITEM = new ItemType(); - public static final Type COMPRESSED_NBT_ITEM_ARRAY = new ItemArrayType<>(COMPRESSED_NBT_ITEM); + public static final Type NBT_ITEM = new ItemType(); + public static final Type NBT_ITEM_ARRAY = new ItemArrayType<>(NBT_ITEM); public static final Type CHUNK = new ChunkType1_2_4(); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/Protocol1_4_2to1_3_1_2.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/Protocol1_4_2to1_3_1_2.java index 8afb8ab..b542f6c 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/Protocol1_4_2to1_3_1_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/Protocol1_4_2to1_3_1_2.java @@ -156,7 +156,7 @@ public void register() { @Override public void register() { map(Type.INT); // entity id - map(Types1_3_1.NBTLESS_ITEM, Types1_7_6.COMPRESSED_ITEM); + map(Types1_3_1.NBTLESS_ITEM, Types1_7_6.ITEM); map(Type.INT); // x map(Type.INT); // y map(Type.INT); // z @@ -287,10 +287,10 @@ public void register() { wrapper.passthrough(Type.INT); // window Id final int count = wrapper.passthrough(Type.UNSIGNED_BYTE); // count for (int i = 0; i < count; i++) { - wrapper.passthrough(Types1_7_6.COMPRESSED_ITEM); // item 1 - wrapper.passthrough(Types1_7_6.COMPRESSED_ITEM); // item 3 + wrapper.passthrough(Types1_7_6.ITEM); // item 1 + wrapper.passthrough(Types1_7_6.ITEM); // item 3 if (wrapper.passthrough(Type.BOOLEAN)) { // has 3 items - wrapper.passthrough(Types1_7_6.COMPRESSED_ITEM); // item 2 + wrapper.passthrough(Types1_7_6.ITEM); // item 2 } wrapper.write(Type.BOOLEAN, false); // unavailable } @@ -327,7 +327,7 @@ private void setMobHandItem(final int entityId, final Item item, final PacketWra final PacketWrapper handItem = PacketWrapper.create(ClientboundPackets1_4_2.ENTITY_EQUIPMENT, wrapper.user()); handItem.write(Type.INT, entityId); // entity id handItem.write(Type.SHORT, (short) 0); // slot - handItem.write(Types1_7_6.COMPRESSED_ITEM, item); // item + handItem.write(Types1_7_6.ITEM, item); // item wrapper.send(Protocol1_4_2to1_3_1_2.class); handItem.send(Protocol1_4_2to1_3_1_2.class); @@ -336,7 +336,7 @@ private void setMobHandItem(final int entityId, final Item item, final PacketWra @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_4_2to1_3_1_2.class, ClientboundPackets1_3_1::getPacket)); + userConnection.put(new PreNettySplitter(Protocol1_4_2to1_3_1_2.class, ClientboundPackets1_3_1::getPacket)); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/rewriter/ItemRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/rewriter/ItemRewriter.java index 61459f8..c88966d 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/rewriter/ItemRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/rewriter/ItemRewriter.java @@ -38,7 +38,7 @@ public ItemRewriter(final Protocol1_4_2to1_3_1_2 protocol) { @Override protected void registerPackets() { - this.registerCreativeInventoryAction(ServerboundPackets1_5_2.CREATIVE_INVENTORY_ACTION, Types1_7_6.COMPRESSED_ITEM); + this.registerCreativeInventoryAction(ServerboundPackets1_5_2.CREATIVE_INVENTORY_ACTION, Types1_7_6.ITEM); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/Types1_3_1.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/Types1_3_1.java index b327ba2..4d4f88a 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/Types1_3_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/Types1_3_1.java @@ -21,7 +21,6 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.metadata.MetaListType; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ItemArrayType; import java.util.List; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/Protocol1_4_4_5to1_4_2.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/Protocol1_4_4_5to1_4_2.java index c7cfd34..5ef95da 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/Protocol1_4_4_5to1_4_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/Protocol1_4_4_5to1_4_2.java @@ -104,7 +104,7 @@ private void rewriteMetadata(final List metadataList) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_4_4_5to1_4_2.class, ClientboundPackets1_4_2::getPacket)); + userConnection.put(new PreNettySplitter(Protocol1_4_4_5to1_4_2.class, ClientboundPackets1_4_2::getPacket)); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/rewriter/ItemRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/rewriter/ItemRewriter.java index b60d792..f5a4cbf 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/rewriter/ItemRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/rewriter/ItemRewriter.java @@ -32,7 +32,7 @@ public ItemRewriter(final Protocol1_4_4_5to1_4_2 protocol) { @Override protected void registerPackets() { - this.registerCreativeInventoryAction(ServerboundPackets1_5_2.CREATIVE_INVENTORY_ACTION, Types1_7_6.COMPRESSED_ITEM); + this.registerCreativeInventoryAction(ServerboundPackets1_5_2.CREATIVE_INVENTORY_ACTION, Types1_7_6.ITEM); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/Protocol1_4_6_7to1_4_4_5.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/Protocol1_4_6_7to1_4_4_5.java index 9a9c6d1..d2e7bd2 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/Protocol1_4_6_7to1_4_4_5.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/Protocol1_4_6_7to1_4_4_5.java @@ -19,8 +19,6 @@ import com.google.common.collect.Lists; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.ClientWorld; -import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; @@ -31,14 +29,12 @@ import net.raphimc.vialegacy.api.remapper.LegacyItemRewriter; import net.raphimc.vialegacy.api.splitter.PreNettySplitter; import net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.rewriter.ItemRewriter; -import net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.types.BulkChunkType1_4_4; import net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.types.Types1_4_4; import net.raphimc.vialegacy.protocols.release.protocol1_5_0_1to1_4_6_7.ClientboundPackets1_4_6; import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ServerboundPackets1_5_2; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.MetaType1_6_4; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.metadata.MetaIndex1_8to1_7_6; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.BulkChunkType1_7_6; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6; public class Protocol1_4_6_7to1_4_4_5 extends StatelessProtocol { @@ -53,36 +49,12 @@ public Protocol1_4_6_7to1_4_4_5() { protected void registerPackets() { this.itemRewriter.register(); - this.registerClientbound(ClientboundPackets1_4_4.JOIN_GAME, new PacketHandlers() { - @Override - public void register() { - map(Type.INT); // entity id - map(Types1_6_4.STRING); // level type - map(Type.BYTE); // game mode - map(Type.BYTE); // dimension id - map(Type.BYTE); // difficulty - map(Type.BYTE); // world height - map(Type.BYTE); // max players - handler(wrapper -> wrapper.user().get(ClientWorld.class).setEnvironment(wrapper.get(Type.BYTE, 1))); - } - }); - this.registerClientbound(ClientboundPackets1_4_4.RESPAWN, new PacketHandlers() { - @Override - public void register() { - map(Type.INT); // dimension id - map(Type.BYTE); // difficulty - map(Type.BYTE); // game mode - map(Type.SHORT); // world height - map(Types1_6_4.STRING); // worldType - handler(wrapper -> wrapper.user().get(ClientWorld.class).setEnvironment(wrapper.get(Type.INT, 0))); - } - }); this.registerClientbound(ClientboundPackets1_4_4.SPAWN_ITEM, ClientboundPackets1_4_6.SPAWN_ENTITY, new PacketHandlers() { @Override public void register() { handler(wrapper -> { final int entityId = wrapper.read(Type.INT); // entity id - final Item item = wrapper.read(Types1_7_6.COMPRESSED_ITEM); // item + final Item item = wrapper.read(Types1_7_6.ITEM); // item final int x = wrapper.read(Type.INT); // x final int y = wrapper.read(Type.INT); // y final int z = wrapper.read(Type.INT); // z @@ -151,11 +123,7 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_4_6_7to1_4_4_5.class, ClientboundPackets1_4_4::getPacket)); - - if (!userConnection.has(ClientWorld.class)) { - userConnection.put(new ClientWorld(userConnection)); - } + userConnection.put(new PreNettySplitter(Protocol1_4_6_7to1_4_4_5.class, ClientboundPackets1_4_4::getPacket)); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/rewriter/ItemRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/rewriter/ItemRewriter.java index c12d751..b88fd80 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/rewriter/ItemRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/rewriter/ItemRewriter.java @@ -34,7 +34,7 @@ public ItemRewriter(final Protocol1_4_6_7to1_4_4_5 protocol) { @Override protected void registerPackets() { - this.registerCreativeInventoryAction(ServerboundPackets1_5_2.CREATIVE_INVENTORY_ACTION, Types1_7_6.COMPRESSED_ITEM); + this.registerCreativeInventoryAction(ServerboundPackets1_5_2.CREATIVE_INVENTORY_ACTION, Types1_7_6.ITEM); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/types/Types1_4_4.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/types/Types1_4_4.java index a34d49e..81c9f84 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/types/Types1_4_4.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/types/Types1_4_4.java @@ -17,8 +17,11 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.types; +import com.viaversion.viaversion.api.minecraft.chunks.Chunk; +import com.viaversion.viaversion.api.type.Type; + public class Types1_4_4 { - public static final BulkChunkType1_4_4 CHUNK_BULK = new BulkChunkType1_4_4(); + public static final Type CHUNK_BULK = new BulkChunkType1_4_4(); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/Protocol1_5_0_1to1_4_6_7.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/Protocol1_5_0_1to1_4_6_7.java index a5d6467..8d627f3 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/Protocol1_5_0_1to1_4_6_7.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/Protocol1_5_0_1to1_4_6_7.java @@ -100,7 +100,7 @@ public void register() { map(Type.BYTE); // button map(Type.SHORT); // action map(Type.BYTE); // mode - map(Types1_7_6.COMPRESSED_ITEM); // item + map(Types1_7_6.ITEM); // item handler(wrapper -> { final short slot = wrapper.get(Type.SHORT, 0); final byte button = wrapper.get(Type.BYTE, 1); @@ -141,7 +141,7 @@ public void register() { wrapper.set(Type.BYTE, 1, (byte) mouseClick); wrapper.set(Type.BYTE, 2, (byte) 0); - wrapper.set(Types1_7_6.COMPRESSED_ITEM, 0, new DataItem(34, (byte) 0, (short) 0, null)); + wrapper.set(Types1_7_6.ITEM, 0, new DataItem(34, (byte) 0, (short) 0, null)); } }); } @@ -150,7 +150,7 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_5_0_1to1_4_6_7.class, ClientboundPackets1_4_6::getPacket)); + userConnection.put(new PreNettySplitter(Protocol1_5_0_1to1_4_6_7.class, ClientboundPackets1_4_6::getPacket)); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/rewriter/ItemRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/rewriter/ItemRewriter.java index 5f4043d..c2d28c4 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/rewriter/ItemRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/rewriter/ItemRewriter.java @@ -36,7 +36,7 @@ public ItemRewriter(final Protocol1_5_0_1to1_4_6_7 protocol) { @Override protected void registerPackets() { - this.registerCreativeInventoryAction(ServerboundPackets1_5_2.CREATIVE_INVENTORY_ACTION, Types1_7_6.COMPRESSED_ITEM); + this.registerCreativeInventoryAction(ServerboundPackets1_5_2.CREATIVE_INVENTORY_ACTION, Types1_7_6.ITEM); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/Protocol1_6_1to1_5_2.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/Protocol1_6_1to1_5_2.java index dead7a5..a7926a6 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/Protocol1_6_1to1_5_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/Protocol1_6_1to1_5_2.java @@ -373,10 +373,10 @@ private void handleWolfMetadata(final int entityId, final List metadat @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_6_1to1_5_2.class, ClientboundPackets1_5_2::getPacket)); + userConnection.put(new PreNettySplitter(Protocol1_6_1to1_5_2.class, ClientboundPackets1_5_2::getPacket)); - userConnection.put(new EntityTracker(userConnection)); - userConnection.put(new AttachTracker(userConnection)); + userConnection.put(new EntityTracker()); + userConnection.put(new AttachTracker()); } @Override diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/rewriter/ItemRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/rewriter/ItemRewriter.java index 392ed5b..4e20c3c 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/rewriter/ItemRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/rewriter/ItemRewriter.java @@ -35,7 +35,7 @@ public ItemRewriter(final Protocol1_6_1to1_5_2 protocol) { @Override protected void registerPackets() { - this.registerCreativeInventoryAction(ServerboundPackets1_6_4.CREATIVE_INVENTORY_ACTION, Types1_7_6.COMPRESSED_ITEM); + this.registerCreativeInventoryAction(ServerboundPackets1_6_4.CREATIVE_INVENTORY_ACTION, Types1_7_6.ITEM); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/AttachTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/AttachTracker.java index ba66b0d..da124a3 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/AttachTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/AttachTracker.java @@ -17,16 +17,11 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; -public class AttachTracker extends StoredObject { +public class AttachTracker implements StorableObject { public int vehicleEntityId = -1; public boolean lastSneakState = false; - public AttachTracker(UserConnection user) { - super(user); - } - } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/EntityTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/EntityTracker.java index 48d1b64..9bf9456 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/EntityTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/EntityTracker.java @@ -17,23 +17,18 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public class EntityTracker extends StoredObject { +public class EntityTracker implements StorableObject { private final Map entityMap = new ConcurrentHashMap<>(); private int playerID; - public EntityTracker(UserConnection user) { - super(user); - } - public int getPlayerID() { return this.playerID; } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_2to1_6_1/Protocol1_6_2to1_6_1.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_2to1_6_1/Protocol1_6_2to1_6_1.java index 4b0e6c2..48b7a00 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_2to1_6_1/Protocol1_6_2to1_6_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_2to1_6_1/Protocol1_6_2to1_6_1.java @@ -78,14 +78,14 @@ public void register() { public void register() { map(Types1_7_6.POSITION_UBYTE); // position map(Type.UNSIGNED_BYTE); // direction - map(Types1_7_6.COMPRESSED_ITEM); // item + map(Types1_7_6.ITEM); // item map(Type.UNSIGNED_BYTE); // offset x map(Type.UNSIGNED_BYTE); // offset y map(Type.UNSIGNED_BYTE); // offset z handler(wrapper -> { final Position pos = wrapper.get(Types1_7_6.POSITION_UBYTE, 0); final short direction = wrapper.get(Type.UNSIGNED_BYTE, 0); - final Item item = wrapper.get(Types1_7_6.COMPRESSED_ITEM, 0); + final Item item = wrapper.get(Types1_7_6.ITEM, 0); if (item != null && item.identifier() == ItemList1_6.sign.itemID && direction != 255 && direction != 0) { // If placed item is a sign then cancel and send a OPEN_SIGN_EDITOR packet final PacketWrapper openSignEditor = PacketWrapper.create(ClientboundPackets1_6_4.OPEN_SIGN_EDITOR, wrapper.user()); @@ -100,7 +100,7 @@ public void register() { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_6_2to1_6_1.class, ClientboundPackets1_6_1::getPacket)); + userConnection.put(new PreNettySplitter(Protocol1_6_2to1_6_1.class, ClientboundPackets1_6_1::getPacket)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/Protocol1_7_2_5to1_6_4.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/Protocol1_7_2_5to1_6_4.java index 19897df..b2e206f 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/Protocol1_7_2_5to1_6_4.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/Protocol1_7_2_5to1_6_4.java @@ -22,7 +22,6 @@ import com.viaversion.viaversion.api.connection.ProtocolInfo; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; -import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; @@ -66,8 +65,6 @@ import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.Protocol1_8to1_7_6_10; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.model.GameProfile; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkType1_7_6; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.BulkChunkType1_7_6; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.MetaType1_7_6; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6; @@ -108,8 +105,7 @@ public void register() { }); handler(wrapper -> { final byte dimensionId = wrapper.get(Type.BYTE, 0); - wrapper.user().get(DimensionTracker.class).setDimension(dimensionId); - wrapper.user().get(ClientWorld.class).setEnvironment(dimensionId); + wrapper.user().get(DimensionTracker.class).changeDimension(dimensionId); wrapper.user().put(new ChunkTracker(wrapper.user())); }); @@ -143,8 +139,8 @@ public void register() { public void register() { map(Type.INT); // entity id map(Type.SHORT); // slot - map(Types1_7_6.COMPRESSED_ITEM); // item - handler(wrapper -> itemRewriter.handleItemToClient(wrapper.get(Types1_7_6.COMPRESSED_ITEM, 0))); + map(Types1_7_6.ITEM); // item + handler(wrapper -> itemRewriter.handleItemToClient(wrapper.get(Types1_7_6.ITEM, 0))); } }); this.registerClientbound(ClientboundPackets1_6_4.RESPAWN, new PacketHandlers() { @@ -156,11 +152,7 @@ public void register() { read(Type.SHORT); // world height map(Types1_6_4.STRING, Type.STRING); // worldType handler(wrapper -> { - final int oldDim = wrapper.user().get(DimensionTracker.class).getDimensionId(); - final int newDim = wrapper.get(Type.INT, 0); - wrapper.user().get(DimensionTracker.class).setDimension(newDim); - wrapper.user().get(ClientWorld.class).setEnvironment(newDim); - if (oldDim != newDim) { + if (wrapper.user().get(DimensionTracker.class).changeDimension(wrapper.get(Type.INT, 0))) { wrapper.user().get(ChunkTracker.class).clear(); } }); @@ -421,7 +413,7 @@ public void register() { @Override public void register() { handler(wrapper -> { - final Chunk chunk = wrapper.passthrough(Types1_7_6.getChunk(wrapper.user().get(ClientWorld.class).getEnvironment())); + final Chunk chunk = wrapper.passthrough(Types1_7_6.getChunk(wrapper.user().get(DimensionTracker.class).getDimension())); wrapper.user().get(ChunkTracker.class).trackAndRemap(chunk); }); } @@ -655,8 +647,8 @@ public void register() { public void register() { map(Type.BYTE); // window id map(Type.SHORT); // slot - map(Types1_7_6.COMPRESSED_ITEM); // item - handler(wrapper -> itemRewriter.handleItemToClient(wrapper.get(Types1_7_6.COMPRESSED_ITEM, 0))); + map(Types1_7_6.ITEM); // item + handler(wrapper -> itemRewriter.handleItemToClient(wrapper.get(Types1_7_6.ITEM, 0))); } }); this.registerClientbound(ClientboundPackets1_6_4.WINDOW_ITEMS, new PacketHandlers() { @@ -664,7 +656,7 @@ public void register() { public void register() { map(Type.BYTE, Type.UNSIGNED_BYTE); // window id handler(wrapper -> { - final Item[] items = wrapper.passthrough(Types1_7_6.COMPRESSED_ITEM_ARRAY); // items + final Item[] items = wrapper.passthrough(Types1_7_6.ITEM_ARRAY); // items for (Item item : items) { itemRewriter.handleItemToClient(item); } @@ -694,7 +686,7 @@ public void register() { public void register() { map(Types1_7_6.POSITION_SHORT); // position map(Type.BYTE, Type.UNSIGNED_BYTE); // type - map(Types1_7_6.COMPRESSED_NBT); // data + map(Types1_7_6.NBT); // data } }); this.registerClientbound(ClientboundPackets1_6_4.OPEN_SIGN_EDITOR, new PacketHandlers() { @@ -798,10 +790,10 @@ public void register() { wrapper.passthrough(Type.INT); // window id final int count = wrapper.passthrough(Type.UNSIGNED_BYTE); // count for (int i = 0; i < count; i++) { - itemRewriter.handleItemToClient(wrapper.passthrough(Types1_7_6.COMPRESSED_ITEM)); // item 1 - itemRewriter.handleItemToClient(wrapper.passthrough(Types1_7_6.COMPRESSED_ITEM)); // item 3 + itemRewriter.handleItemToClient(wrapper.passthrough(Types1_7_6.ITEM)); // item 1 + itemRewriter.handleItemToClient(wrapper.passthrough(Types1_7_6.ITEM)); // item 3 if (wrapper.passthrough(Type.BOOLEAN)) { // has 3 items - itemRewriter.handleItemToClient(wrapper.passthrough(Types1_7_6.COMPRESSED_ITEM)); // item 2 + itemRewriter.handleItemToClient(wrapper.passthrough(Types1_7_6.ITEM)); // item 2 } wrapper.passthrough(Type.BOOLEAN); // unavailable } @@ -1023,8 +1015,8 @@ public void register() { public void register() { map(Types1_7_6.POSITION_UBYTE); // position map(Type.UNSIGNED_BYTE); // direction - map(Types1_7_6.COMPRESSED_ITEM); // item - handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_7_6.COMPRESSED_ITEM, 0))); + map(Types1_7_6.ITEM); // item + handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_7_6.ITEM, 0))); map(Type.UNSIGNED_BYTE); // offset x map(Type.UNSIGNED_BYTE); // offset y map(Type.UNSIGNED_BYTE); // offset z @@ -1038,8 +1030,8 @@ public void register() { map(Type.BYTE); // button map(Type.SHORT); // action map(Type.BYTE); // mode - map(Types1_7_6.COMPRESSED_ITEM); // item - handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_7_6.COMPRESSED_ITEM, 0))); + map(Types1_7_6.ITEM); // item + handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_7_6.ITEM, 0))); } }); this.registerServerbound(ServerboundPackets1_7_2.UPDATE_SIGN, new PacketHandlers() { @@ -1130,14 +1122,14 @@ public void register() { switch (channel) { case "MC|BEdit": case "MC|BSign": - final Item item = wrapper.read(Types1_7_6.COMPRESSED_ITEM); // book + final Item item = wrapper.read(Types1_7_6.ITEM); // book itemRewriter.handleItemToServer(item); - lengthPacketWrapper.write(Types1_7_6.COMPRESSED_ITEM, item); + lengthPacketWrapper.write(Types1_7_6.ITEM, item); lengthPacketWrapper.writeToBuffer(lengthBuffer); wrapper.set(Type.SHORT, 0, (short) lengthBuffer.readableBytes()); // length - wrapper.write(Types1_7_6.COMPRESSED_ITEM, item); // book + wrapper.write(Types1_7_6.ITEM, item); // book break; case "MC|AdvCdm": final byte type = wrapper.read(Type.BYTE); // command block type @@ -1185,14 +1177,11 @@ public void register(ViaProviders providers) { @Override public void init(UserConnection userConnection) { - userConnection.put(new PreNettySplitter(userConnection, Protocol1_7_2_5to1_6_4.class, ClientboundPackets1_6_4::getPacket)); + userConnection.put(new PreNettySplitter(Protocol1_7_2_5to1_6_4.class, ClientboundPackets1_6_4::getPacket)); - userConnection.put(new PlayerInfoStorage(userConnection)); - userConnection.put(new StatisticsStorage(userConnection)); - userConnection.put(new DimensionTracker(userConnection)); - if (!userConnection.has(ClientWorld.class)) { - userConnection.put(new ClientWorld(userConnection)); - } + userConnection.put(new PlayerInfoStorage()); + userConnection.put(new StatisticsStorage()); + userConnection.put(new DimensionTracker()); userConnection.put(new ChunkTracker(userConnection)); // Set again in JOIN_GAME handler for version comparisons to work if (userConnection.getChannel() != null) { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/rewriter/ItemRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/rewriter/ItemRewriter.java index 7f887f6..c88ef8d 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/rewriter/ItemRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/rewriter/ItemRewriter.java @@ -71,7 +71,7 @@ public ItemRewriter(final Protocol1_7_2_5to1_6_4 protocol) { @Override protected void registerPackets() { - this.registerCreativeInventoryAction(ServerboundPackets1_7_2.CREATIVE_INVENTORY_ACTION, Types1_7_6.COMPRESSED_ITEM); + this.registerCreativeInventoryAction(ServerboundPackets1_7_2.CREATIVE_INVENTORY_ACTION, Types1_7_6.ITEM); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/DimensionTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/DimensionTracker.java index e5e8ec2..ad862a3 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/DimensionTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/DimensionTracker.java @@ -17,23 +17,22 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; +import com.viaversion.viaversion.api.minecraft.Environment; -public class DimensionTracker extends StoredObject { +public class DimensionTracker implements StorableObject { - private int dimensionId = 0; + private Environment dimension = Environment.NORMAL; - public DimensionTracker(UserConnection user) { - super(user); + public boolean changeDimension(final int dimensionId) { + final Environment newDimension = Environment.getEnvironmentById(dimensionId); + final boolean dimensionChanged = this.dimension != newDimension; + this.dimension = newDimension; + return dimensionChanged; } - public void setDimension(final int dimensionId) { - this.dimensionId = dimensionId; - } - - public int getDimensionId() { - return this.dimensionId; + public Environment getDimension() { + return this.dimension; } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/HandshakeStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/HandshakeStorage.java index 245315c..8259737 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/HandshakeStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/HandshakeStorage.java @@ -17,16 +17,14 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; -public class HandshakeStorage extends StoredObject { +public class HandshakeStorage implements StorableObject { private final String hostname; private final int port; - public HandshakeStorage(final UserConnection user, final String hostName, final int port) { - super(user); + public HandshakeStorage(final String hostName, final int port) { this.hostname = hostName; this.port = port; } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/PlayerInfoStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/PlayerInfoStorage.java index 2b6c3a3..7037c47 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/PlayerInfoStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/PlayerInfoStorage.java @@ -17,10 +17,9 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; -public class PlayerInfoStorage extends StoredObject { +public class PlayerInfoStorage implements StorableObject { public int entityId = -1; public boolean onGround = false; @@ -30,8 +29,4 @@ public class PlayerInfoStorage extends StoredObject { public float yaw = -180; public float pitch = 0; - public PlayerInfoStorage(final UserConnection userConnection) { - super(userConnection); - } - } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/ProtocolMetadataStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/ProtocolMetadataStorage.java index 3378b01..35cfa20 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/ProtocolMetadataStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/ProtocolMetadataStorage.java @@ -17,17 +17,11 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; -public class ProtocolMetadataStorage extends StoredObject { +public class ProtocolMetadataStorage implements StorableObject { public boolean authenticate; - public boolean skipEncryption; - public ProtocolMetadataStorage(UserConnection user) { - super(user); - } - } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/StatisticsStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/StatisticsStorage.java index 1a33eb6..bc82c07 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/StatisticsStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/storage/StatisticsStorage.java @@ -17,17 +17,12 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap; import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap; -public class StatisticsStorage extends StoredObject { +public class StatisticsStorage implements StorableObject { public final Int2IntMap values = new Int2IntOpenHashMap(); - public StatisticsStorage(final UserConnection userConnection) { - super(userConnection); - } - } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/MetaType1_6_4.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/MetaType1_6_4.java index f4cdb18..ed25d04 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/MetaType1_6_4.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/MetaType1_6_4.java @@ -28,7 +28,7 @@ public enum MetaType1_6_4 implements MetaType { Int(2, Type.INT), Float(3, Type.FLOAT), String(4, Types1_6_4.STRING), - Slot(5, Types1_7_6.COMPRESSED_ITEM), + Slot(5, Types1_7_6.ITEM), Position(6, Type.VECTOR); private final int typeID; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_6_10to1_7_2_5/Protocol1_7_6_10to1_7_2_5.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_6_10to1_7_2_5/Protocol1_7_6_10to1_7_2_5.java index 4130372..9814c40 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_6_10to1_7_2_5/Protocol1_7_6_10to1_7_2_5.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_6_10to1_7_2_5/Protocol1_7_6_10to1_7_2_5.java @@ -82,11 +82,11 @@ public void register() { public void register() { map(Types1_7_6.POSITION_SHORT); // position map(Type.UNSIGNED_BYTE); // type - map(Types1_7_6.COMPRESSED_NBT); // data + map(Types1_7_6.NBT); // data handler(wrapper -> { final Position pos = wrapper.get(Types1_7_6.POSITION_SHORT, 0); final short type = wrapper.get(Type.UNSIGNED_BYTE, 0); - final CompoundTag tag = wrapper.get(Types1_7_6.COMPRESSED_NBT, 0); + final CompoundTag tag = wrapper.get(Types1_7_6.NBT, 0); if (type != 4/*skull*/) return; final ByteTag skullType = tag.get("SkullType"); if (skullType == null || skullType.asByte() != 3/*player_skull*/) return; @@ -106,7 +106,7 @@ public void register() { if (skullProfile == null || skullProfile.isOffline()) return; newTag.put("Owner", writeGameProfileToTag(skullProfile)); - wrapper.set(Types1_7_6.COMPRESSED_NBT, 0, newTag); + wrapper.set(Types1_7_6.NBT, 0, newTag); return; } } @@ -120,7 +120,7 @@ public void register() { final PacketWrapper updateSkull = PacketWrapper.create(ClientboundPackets1_7_2.BLOCK_ENTITY_DATA, wrapper.user()); updateSkull.write(Types1_7_6.POSITION_SHORT, pos); updateSkull.write(Type.UNSIGNED_BYTE, type); - updateSkull.write(Types1_7_6.COMPRESSED_NBT, newTag); + updateSkull.write(Types1_7_6.NBT, newTag); updateSkull.send(Protocol1_7_6_10to1_7_2_5.class); } catch (Throwable e) { e.printStackTrace(); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/Protocol1_8to1_7_6_10.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/Protocol1_8to1_7_6_10.java index 31d25c8..65fbb10 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/Protocol1_8to1_7_6_10.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/Protocol1_8to1_7_6_10.java @@ -22,7 +22,6 @@ import com.viaversion.viaversion.api.connection.ProtocolInfo; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; -import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; @@ -64,8 +63,6 @@ import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.rewriter.ItemRewriter; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.rewriter.TranslationRewriter; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.storage.*; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.BulkChunkType1_7_6; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkType1_7_6; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6; import java.nio.charset.StandardCharsets; @@ -138,8 +135,7 @@ public void register() { final EntityTracker tracker = wrapper.user().get(EntityTracker.class); tracker.trackEntity(entityId, EntityTypes1_10.EntityType.PLAYER); tracker.setPlayerID(entityId); - wrapper.user().get(DimensionTracker.class).setDimension(dimensionId); - wrapper.user().get(ClientWorld.class).setEnvironment(dimensionId); + wrapper.user().get(DimensionTracker.class).changeDimension(dimensionId); }); } }); @@ -155,7 +151,7 @@ public void register() { public void register() { map(Type.INT, Type.VAR_INT); // entity id map(Type.SHORT); // slot - map(Types1_7_6.COMPRESSED_ITEM, Type.ITEM1_8); // item + map(Types1_7_6.ITEM, Type.ITEM1_8); // item handler(wrapper -> itemRewriter.handleItemToClient(wrapper.get(Type.ITEM1_8, 0))); } }); @@ -181,11 +177,7 @@ public void register() { map(Type.UNSIGNED_BYTE); // gamemode map(Type.STRING); // worldType handler(wrapper -> { - final int oldDim = wrapper.user().get(DimensionTracker.class).getDimensionId(); - final int newDim = wrapper.get(Type.INT, 0); - wrapper.user().get(DimensionTracker.class).setDimension(newDim); - wrapper.user().get(ClientWorld.class).setEnvironment(newDim); - if (oldDim != newDim) { + if (wrapper.user().get(DimensionTracker.class).changeDimension(wrapper.get(Type.INT, 0))) { wrapper.user().get(ChunkTracker.class).clear(); wrapper.user().get(EntityTracker.class).clear(); } @@ -634,11 +626,11 @@ public void register() { @Override public void register() { handler(wrapper -> { - final Environment environment = wrapper.user().get(ClientWorld.class).getEnvironment(); + final Environment dimension = wrapper.user().get(DimensionTracker.class).getDimension(); - final Chunk chunk = wrapper.read(Types1_7_6.getChunk(environment)); + final Chunk chunk = wrapper.read(Types1_7_6.getChunk(dimension)); wrapper.user().get(ChunkTracker.class).trackAndRemap(chunk); - wrapper.write(ChunkType1_8.forEnvironment(environment), chunk); + wrapper.write(ChunkType1_8.forEnvironment(dimension), chunk); }); } }); @@ -934,7 +926,7 @@ public void register() { if (windowType == 4/*enchanting_table*/ && slot >= 1) slot += 1; wrapper.write(Type.SHORT, slot); }); - map(Types1_7_6.COMPRESSED_ITEM, Type.ITEM1_8); // item + map(Types1_7_6.ITEM, Type.ITEM1_8); // item handler(wrapper -> itemRewriter.handleItemToClient(wrapper.get(Type.ITEM1_8, 0))); } }); @@ -944,7 +936,7 @@ public void register() { handler(wrapper -> { final short windowId = wrapper.passthrough(Type.UNSIGNED_BYTE); // window id final short windowType = wrapper.user().get(WindowTracker.class).get(windowId); - Item[] items = wrapper.read(Types1_7_6.COMPRESSED_ITEM_ARRAY); // items + Item[] items = wrapper.read(Types1_7_6.ITEM_ARRAY); // items if (windowType == 4/*enchanting_table*/) { final Item[] old = items; items = new Item[old.length + 1]; @@ -1057,7 +1049,7 @@ public void register() { public void register() { map(Types1_7_6.POSITION_SHORT, Type.POSITION1_8); // position map(Type.UNSIGNED_BYTE); // type - map(Types1_7_6.COMPRESSED_NBT, Type.NAMED_COMPOUND_TAG); // data + map(Types1_7_6.NBT, Type.NAMED_COMPOUND_TAG); // data } }); this.registerClientbound(ClientboundPackets1_7_2.OPEN_SIGN_EDITOR, new PacketHandlers() { @@ -1178,17 +1170,17 @@ public void register() { wrapper.passthrough(Type.INT); // window id final int count = wrapper.passthrough(Type.UNSIGNED_BYTE); // count for (int i = 0; i < count; i++) { - Item item = wrapper.read(Types1_7_6.COMPRESSED_ITEM); + Item item = wrapper.read(Types1_7_6.ITEM); itemRewriter.handleItemToClient(item); wrapper.write(Type.ITEM1_8, item); // item 1 - item = wrapper.read(Types1_7_6.COMPRESSED_ITEM); + item = wrapper.read(Types1_7_6.ITEM); itemRewriter.handleItemToClient(item); wrapper.write(Type.ITEM1_8, item); // item 3 final boolean has3Items = wrapper.passthrough(Type.BOOLEAN); // has 3 items if (has3Items) { - item = wrapper.read(Types1_7_6.COMPRESSED_ITEM); + item = wrapper.read(Types1_7_6.ITEM); itemRewriter.handleItemToClient(item); wrapper.write(Type.ITEM1_8, item); // item 2 } @@ -1282,13 +1274,13 @@ public void register() { public void register() { map(Type.POSITION1_8, Types1_7_6.POSITION_UBYTE); // position map(Type.UNSIGNED_BYTE); // direction - map(Type.ITEM1_8, Types1_7_6.COMPRESSED_ITEM); // item + map(Type.ITEM1_8, Types1_7_6.ITEM); // item map(Type.UNSIGNED_BYTE); // offset x map(Type.UNSIGNED_BYTE); // offset y map(Type.UNSIGNED_BYTE); // offset z handler(wrapper -> { final short direction = wrapper.get(Type.UNSIGNED_BYTE, 0); - final Item item = wrapper.get(Types1_7_6.COMPRESSED_ITEM, 0); + final Item item = wrapper.get(Types1_7_6.ITEM, 0); itemRewriter.handleItemToServer(item); if (item != null && item.identifier() == ItemList1_6.writtenBook.itemID && direction == 255) { // If placed item is a book then cancel it and send a MC|BOpen to the client @@ -1361,16 +1353,16 @@ public void register() { map(Type.BYTE); // button map(Type.SHORT); // transaction id map(Type.BYTE); // action - map(Type.ITEM1_8, Types1_7_6.COMPRESSED_ITEM); // item - handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_7_6.COMPRESSED_ITEM, 0))); + map(Type.ITEM1_8, Types1_7_6.ITEM); // item + handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_7_6.ITEM, 0))); } }); this.registerServerbound(ServerboundPackets1_8.CREATIVE_INVENTORY_ACTION, new PacketHandlers() { @Override public void register() { map(Type.SHORT); // slot - map(Type.ITEM1_8, Types1_7_6.COMPRESSED_ITEM); // item - handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_7_6.COMPRESSED_ITEM, 0))); + map(Type.ITEM1_8, Types1_7_6.ITEM); // item + handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_7_6.ITEM, 0))); } }); this.registerServerbound(ServerboundPackets1_8.UPDATE_SIGN, new PacketHandlers() { @@ -1432,11 +1424,11 @@ public void register() { final Item item = wrapper.read(Type.ITEM1_8); // book itemRewriter.handleItemToServer(item); - lengthPacketWrapper.write(Types1_7_6.COMPRESSED_ITEM, item); + lengthPacketWrapper.write(Types1_7_6.ITEM, item); lengthPacketWrapper.writeToBuffer(lengthBuffer); wrapper.write(Type.SHORT, (short) lengthBuffer.readableBytes()); // length - wrapper.write(Types1_7_6.COMPRESSED_ITEM, item); // book + wrapper.write(Types1_7_6.ITEM, item); // book break; case "MC|TrSel": final int selectedTrade = wrapper.read(Type.INT); // selected trade @@ -1583,13 +1575,10 @@ else if (type == EntityTypes1_10.EntityType.EXPERIENCE_ORB) @Override public void init(UserConnection userConnection) { userConnection.put(new TablistStorage(userConnection)); - userConnection.put(new WindowTracker(userConnection)); + userConnection.put(new WindowTracker()); userConnection.put(new EntityTracker(userConnection)); - userConnection.put(new MapStorage(userConnection)); - userConnection.put(new DimensionTracker(userConnection)); - if (!userConnection.has(ClientWorld.class)) { - userConnection.put(new ClientWorld(userConnection)); - } + userConnection.put(new MapStorage()); + userConnection.put(new DimensionTracker()); userConnection.put(new ChunkTracker(userConnection)); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/DimensionTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/DimensionTracker.java index 75c142d..2bcf8a2 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/DimensionTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/DimensionTracker.java @@ -17,23 +17,22 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; +import com.viaversion.viaversion.api.minecraft.Environment; -public class DimensionTracker extends StoredObject { +public class DimensionTracker implements StorableObject { - private int dimensionId = 0; + private Environment dimension = Environment.NORMAL; - public DimensionTracker(UserConnection user) { - super(user); + public boolean changeDimension(final int dimensionId) { + final Environment newDimension = Environment.getEnvironmentById(dimensionId); + final boolean dimensionChanged = newDimension != this.dimension; + this.dimension = Environment.getEnvironmentById(dimensionId); + return dimensionChanged; } - public void setDimension(final int dimensionId) { - this.dimensionId = dimensionId; - } - - public int getDimensionId() { - return this.dimensionId; + public Environment getDimension() { + return this.dimension; } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/MapStorage.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/MapStorage.java index a2d7436..9c89d2a 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/MapStorage.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/MapStorage.java @@ -17,20 +17,15 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.model.MapData; -public class MapStorage extends StoredObject { +public class MapStorage implements StorableObject { private final Int2ObjectMap maps = new Int2ObjectOpenHashMap<>(); - public MapStorage(UserConnection user) { - super(user); - } - public MapData getMapData(final int id) { return this.maps.get(id); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/WindowTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/WindowTracker.java index fe6b749..432cb77 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/WindowTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/WindowTracker.java @@ -17,20 +17,15 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import java.util.HashMap; import java.util.Map; -public class WindowTracker extends StoredObject { +public class WindowTracker implements StorableObject { public final Map types = new HashMap<>(); - public WindowTracker(UserConnection user) { - super(user); - } - public short get(short windowId) { return types.getOrDefault(windowId, (short) -1); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/BulkChunkType1_7_6.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/BulkChunkType1_7_6.java index 683630c..d17a9cb 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/BulkChunkType1_7_6.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/BulkChunkType1_7_6.java @@ -19,7 +19,6 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.api.type.types.FixedByteArrayType; import com.viaversion.viaversion.util.Pair; import io.netty.buffer.ByteBuf; @@ -60,7 +59,8 @@ public Chunk[] read(ByteBuf byteBuf) throws Exception { final short chunkCount = byteBuf.readShort(); final int compressedSize = byteBuf.readInt(); final boolean hasSkyLight = this.readHasSkyLight(byteBuf); - final byte[] data = new FixedByteArrayType(compressedSize).read(byteBuf); + final byte[] data = new byte[compressedSize]; + byteBuf.readBytes(data); final int[] chunkX = new int[chunkCount]; final int[] chunkZ = new int[chunkCount]; final short[] primaryBitMask = new short[chunkCount]; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkType1_7_6.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkType1_7_6.java index 3521141..ad40417 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkType1_7_6.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkType1_7_6.java @@ -19,7 +19,6 @@ import com.viaversion.viaversion.api.minecraft.chunks.*; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.api.type.types.FixedByteArrayType; import com.viaversion.viaversion.util.Pair; import io.netty.buffer.ByteBuf; import net.raphimc.vialegacy.api.model.IdAndData; @@ -36,7 +35,7 @@ public class ChunkType1_7_6 extends Type { private final boolean hasSkyLight; - public ChunkType1_7_6(boolean hasSkyLight) { + public ChunkType1_7_6(final boolean hasSkyLight) { super(Chunk.class); this.hasSkyLight = hasSkyLight; } @@ -44,7 +43,7 @@ public ChunkType1_7_6(boolean hasSkyLight) { /** * This method is here to allow overriding the code for 1.2.5 -{@literal >} 1.3.2 because it introduced an unused int * - * @param byteBuf The buffer + * @param byteBuf The buffer */ protected void readUnusedInt(final ByteBuf byteBuf) { } @@ -52,8 +51,8 @@ protected void readUnusedInt(final ByteBuf byteBuf) { /** * This method is here to allow overriding the code for 1.2.5 -{@literal >} 1.3.2 because it introduced an unused int * - * @param byteBuf The buffer - * @param chunk The Chunk + * @param byteBuf The buffer + * @param chunk The Chunk */ protected void writeUnusedInt(final ByteBuf byteBuf, final Chunk chunk) { } @@ -67,7 +66,8 @@ public Chunk read(ByteBuf byteBuf) throws Exception { final short additionalBitMask = byteBuf.readShort(); final int compressedSize = byteBuf.readInt(); this.readUnusedInt(byteBuf); - final byte[] data = new FixedByteArrayType(compressedSize).read(byteBuf); + final byte[] data = new byte[compressedSize]; + byteBuf.readBytes(data); final byte[] uncompressedData = new byte[getSize(primaryBitMask, additionalBitMask, fullChunk, this.hasSkyLight)]; final Inflater inflater = new Inflater(); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ItemType.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ItemType.java index 34a1f89..0990dc3 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ItemType.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ItemType.java @@ -39,7 +39,7 @@ public Item read(ByteBuf buffer) throws Exception { item.setIdentifier(id); item.setAmount(buffer.readByte()); item.setData(buffer.readShort()); - item.setTag(Types1_7_6.COMPRESSED_NBT.read(buffer)); + item.setTag(Types1_7_6.NBT.read(buffer)); return item; } @@ -51,7 +51,7 @@ public void write(ByteBuf buffer, Item item) throws Exception { buffer.writeShort(item.identifier()); buffer.writeByte(item.amount()); buffer.writeShort(item.data()); - Types1_7_6.COMPRESSED_NBT.write(buffer, item.tag()); + Types1_7_6.NBT.write(buffer, item.tag()); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/MetaType1_7_6.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/MetaType1_7_6.java index 194da1b..a74e976 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/MetaType1_7_6.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/MetaType1_7_6.java @@ -27,7 +27,7 @@ public enum MetaType1_7_6 implements MetaType { Int(2, Type.INT), Float(3, Type.FLOAT), String(4, Type.STRING), - Slot(5, Types1_7_6.COMPRESSED_ITEM), + Slot(5, Types1_7_6.ITEM), Position(6, Type.VECTOR); private final int typeID; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/NBTType.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/NBTType.java index 9e8b8d1..5d3a5d5 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/NBTType.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/NBTType.java @@ -32,11 +32,8 @@ public class NBTType extends Type { - private final boolean compressed; - - public NBTType(final boolean compressed) { + public NBTType() { super(CompoundTag.class); - this.compressed = compressed; } @Override @@ -47,7 +44,7 @@ public CompoundTag read(ByteBuf buffer) throws IOException { } final ByteBuf data = buffer.readSlice(length); - try (InputStream in = this.compressed ? new GZIPInputStream(new ByteBufInputStream(data)) : new ByteBufInputStream(data)) { + try (InputStream in = new GZIPInputStream(new ByteBufInputStream(data))) { return NBTIO.readTag(in); } } @@ -61,7 +58,7 @@ public void write(ByteBuf buffer, CompoundTag nbt) throws Exception { final ByteBuf data = buffer.alloc().buffer(); try { - try (OutputStream out = this.compressed ? new GZIPOutputStream(new ByteBufOutputStream(data)) : new ByteBufOutputStream(data)) { + try (OutputStream out = new GZIPOutputStream(new ByteBufOutputStream(data))) { NBTIO.writeTag(out, nbt); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/Types1_7_6.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/Types1_7_6.java index d8c65ec..bc29d1c 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/Types1_7_6.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/Types1_7_6.java @@ -20,6 +20,7 @@ import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.Type; @@ -32,11 +33,10 @@ public class Types1_7_6 { public static final Type INT_ARRAY = new IntArrayType(); - public static final Type NBT = new NBTType(false); - public static final Type COMPRESSED_NBT = new NBTType(true); + public static final Type NBT = new NBTType(); - public static final Type COMPRESSED_ITEM = new ItemType(); - public static final Type COMPRESSED_ITEM_ARRAY = new ItemArrayType<>(COMPRESSED_ITEM); + public static final Type ITEM = new ItemType(); + public static final Type ITEM_ARRAY = new ItemArrayType<>(ITEM); public static final Type METADATA = new MetadataType(); public static final Type> METADATA_LIST = new MetaListType(METADATA); @@ -48,13 +48,12 @@ public class Types1_7_6 { public static final Type POSITION_SHORT = new PositionVarYType<>(Type.SHORT, i -> (short) i); public static final Type POSITION_INT = new PositionVarYType<>(Type.INT, i -> i); - private static final ChunkType1_7_6 CHUNK_WITH_SKYLIGHT = new ChunkType1_7_6(true); - private static final ChunkType1_7_6 CHUNK_WITHOUT_SKYLIGHT = new ChunkType1_7_6(false); + public static final Type CHUNK_WITH_SKYLIGHT = new ChunkType1_7_6(true); + public static final Type CHUNK_WITHOUT_SKYLIGHT = new ChunkType1_7_6(false); + public static final Type CHUNK_BULK = new BulkChunkType1_7_6(); - public static final BulkChunkType1_7_6 CHUNK_BULK = new BulkChunkType1_7_6(); - - public static ChunkType1_7_6 getChunk(Environment environment) { - return environment == Environment.NORMAL ? CHUNK_WITH_SKYLIGHT : CHUNK_WITHOUT_SKYLIGHT; + public static Type getChunk(final Environment dimension) { + return dimension == Environment.NORMAL ? CHUNK_WITH_SKYLIGHT : CHUNK_WITHOUT_SKYLIGHT; } }