From de5b7bf828752d54eb4d7dd876d6324923ae6b43 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 12 Feb 2023 10:54:47 +0100 Subject: [PATCH] Allow registration of simple packet handlers over extending an abstract class --- .../com/viaversion/viaversion/api/ViaAPI.java | 2 +- .../api/protocol/AbstractProtocol.java | 168 ++++++++-------- .../viaversion/api/protocol/Protocol.java | 185 ++++++++++++------ .../api/protocol/remapper/PacketHandlers.java | 161 +++++++++++++++ .../api/protocol/remapper/PacketRemapper.java | 10 +- .../api/protocol/remapper/ValueReader.java | 1 + .../api/protocol/remapper/ValueWriter.java | 1 + .../protocol/packet/PacketWrapperImpl.java | 4 +- .../protocols/base/BaseProtocol.java | 6 +- .../protocols/base/BaseProtocol1_7.java | 14 +- .../Protocol1_10To1_9_3_4.java | 42 ++-- .../Protocol1_11_1To1_11.java | 5 +- .../Protocol1_11To1_10.java | 54 ++--- .../packets/InventoryPackets.java | 6 +- .../Protocol1_12_2To1_12_1.java | 10 +- .../Protocol1_12To1_11_1.java | 30 +-- .../packets/InventoryPackets.java | 10 +- .../Protocol1_13_1To1_13.java | 18 +- .../packets/EntityPackets.java | 14 +- .../packets/InventoryPackets.java | 12 +- .../packets/WorldPackets.java | 18 +- .../Protocol1_13_2To1_13_1.java | 10 +- .../packets/EntityPackets.java | 14 +- .../packets/InventoryPackets.java | 30 +-- .../packets/WorldPackets.java | 6 +- .../Protocol1_13To1_12_2.java | 110 +++++------ .../packets/EntityPackets.java | 22 +-- .../packets/InventoryPackets.java | 34 ++-- .../packets/WorldPackets.java | 45 ++--- .../packets/EntityPackets.java | 10 +- .../Protocol1_14_3To1_14_2.java | 6 +- .../Protocol1_14_4To1_14_3.java | 6 +- .../Protocol1_14To1_13_2.java | 6 +- .../packets/EntityPackets.java | 30 +-- .../packets/InventoryPackets.java | 20 +- .../packets/PlayerPackets.java | 38 ++-- .../packets/WorldPackets.java | 46 ++--- .../Protocol1_15To1_14_4.java | 6 +- .../packets/EntityPackets.java | 18 +- .../packets/WorldPackets.java | 10 +- .../Protocol1_16_2To1_16_1.java | 10 +- .../packets/EntityPackets.java | 10 +- .../packets/InventoryPackets.java | 10 +- .../packets/WorldPackets.java | 10 +- .../Protocol1_16_4To1_16_3.java | 6 +- .../Protocol1_16To1_15_2.java | 26 +-- .../packets/EntityPackets.java | 22 +-- .../packets/InventoryPackets.java | 26 +-- .../packets/WorldPackets.java | 14 +- .../Protocol1_17_1To1_17.java | 22 +-- .../Protocol1_17To1_16_4.java | 30 +-- .../packets/EntityPackets.java | 26 +-- .../packets/InventoryPackets.java | 18 +- .../packets/WorldPackets.java | 14 +- .../Protocol1_18_2To1_18.java | 18 +- .../Protocol1_18To1_17_1.java | 6 +- .../packets/EntityPackets.java | 10 +- .../packets/InventoryPackets.java | 10 +- .../packets/WorldPackets.java | 18 +- .../Protocol1_19_1To1_19.java | 42 ++-- .../Protocol1_19_3To1_19_1.java | 38 ++-- .../packets/EntityPackets.java | 14 +- .../packets/InventoryPackets.java | 12 +- .../packets/EntityPackets.java | 18 +- .../Protocol1_19To1_18_2.java | 54 ++--- .../packets/EntityPackets.java | 30 +-- .../packets/InventoryPackets.java | 22 +-- .../packets/WorldPackets.java | 10 +- .../Protocol1_9_1_2To1_9_3_4.java | 18 +- .../Protocol1_9_1To1_9.java | 10 +- .../Protocol1_9_3To1_9_1_2.java | 22 +-- .../protocol1_9to1_8/Protocol1_9To1_8.java | 6 +- .../packets/EntityPackets.java | 50 ++--- .../packets/InventoryPackets.java | 42 ++-- .../packets/PlayerPackets.java | 86 ++++---- .../packets/SpawnPackets.java | 30 +-- .../packets/WorldPackets.java | 42 ++-- .../Protocol1_9To1_9_1.java | 10 +- .../viaversion/rewriter/BlockRewriter.java | 30 +-- .../viaversion/rewriter/CommandRewriter.java | 10 +- .../rewriter/ComponentRewriter.java | 18 +- .../viaversion/rewriter/EntityRewriter.java | 30 +-- .../viaversion/rewriter/ItemRewriter.java | 66 +++---- .../viaversion/rewriter/RecipeRewriter.java | 10 +- .../viaversion/rewriter/SoundRewriter.java | 10 +- .../rewriter/StatisticsRewriter.java | 6 +- .../viaversion/rewriter/TagRewriter.java | 10 +- 87 files changed, 1261 insertions(+), 1029 deletions(-) create mode 100644 api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/PacketHandlers.java diff --git a/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java b/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java index 517e617aa..2330ca82f 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java +++ b/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java @@ -64,7 +64,7 @@ public interface ViaAPI { * @return API version incremented with meaningful API changes */ default int apiVersion() { - return 15; + return 16; } /** diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/AbstractProtocol.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/AbstractProtocol.java index 2dfe2743f..f3d943011 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/AbstractProtocol.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/AbstractProtocol.java @@ -32,25 +32,25 @@ import com.viaversion.viaversion.api.protocol.packet.PacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; import com.viaversion.viaversion.api.protocol.packet.State; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.exception.CancelException; import com.viaversion.viaversion.exception.InformativeException; -import org.checkerframework.checker.nullness.qual.Nullable; - import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; +import org.checkerframework.checker.nullness.qual.Nullable; public abstract class AbstractProtocol implements Protocol { private final Map serverbound = new HashMap<>(); private final Map clientbound = new HashMap<>(); private final Map, Object> storedObjects = new HashMap<>(); // currently only used for MetadataRewriters - protected final Class oldClientboundPacketEnum; - protected final Class newClientboundPacketEnum; - protected final Class oldServerboundPacketEnum; - protected final Class newServerboundPacketEnum; + protected final Class unmappedClientboundPacketType; + protected final Class mappedClientboundPacketType; + protected final Class mappedServerboundPacketType; + protected final Class unmappedServerboundPacketType; private boolean initialized; protected AbstractProtocol() { @@ -58,14 +58,14 @@ public abstract class AbstractProtocol oldClientboundPacketEnum, @Nullable Class clientboundPacketEnum, - @Nullable Class oldServerboundPacketEnum, @Nullable Class serverboundPacketEnum) { - this.oldClientboundPacketEnum = oldClientboundPacketEnum; - this.newClientboundPacketEnum = clientboundPacketEnum; - this.oldServerboundPacketEnum = oldServerboundPacketEnum; - this.newServerboundPacketEnum = serverboundPacketEnum; + protected AbstractProtocol(@Nullable Class unmappedClientboundPacketType, @Nullable Class mappedClientboundPacketType, + @Nullable Class mappedServerboundPacketType, @Nullable Class unmappedServerboundPacketType) { + this.unmappedClientboundPacketType = unmappedClientboundPacketType; + this.mappedClientboundPacketType = mappedClientboundPacketType; + this.mappedServerboundPacketType = mappedServerboundPacketType; + this.unmappedServerboundPacketType = unmappedServerboundPacketType; } @Override @@ -76,24 +76,24 @@ public abstract class AbstractProtocol newClientboundPackets = new HashMap<>(newConstants.length); for (C2 newConstant : newConstants) { newClientboundPackets.put(newConstant.getName(), newConstant); } - for (C1 packet : oldClientboundPacketEnum.getEnumConstants()) { + for (C1 packet : unmappedClientboundPacketType.getEnumConstants()) { C2 mappedPacket = newClientboundPackets.get(packet.getName()); if (mappedPacket == null) { // Packet doesn't exist on new client @@ -109,13 +109,13 @@ public abstract class AbstractProtocol oldServerboundConstants = new HashMap<>(oldConstants.length); for (S1 oldConstant : oldConstants) { oldServerboundConstants.put(oldConstant.getName(), oldConstant); } - for (S2 packet : newServerboundPacketEnum.getEnumConstants()) { + for (S2 packet : unmappedServerboundPacketType.getEnumConstants()) { S1 mappedPacket = oldServerboundConstants.get(packet.getName()); if (mappedPacket == null) { // Packet doesn't exist on old server @@ -156,9 +156,9 @@ public abstract class AbstractProtocol en.getName().equals(packetType.getName())).findAny().orElse(null); + //noinspection unchecked + C2 mappedPacket = unmappedClientboundPacketType == mappedClientboundPacketType ? (C2) packetType + : Arrays.stream(mappedClientboundPacketType.getEnumConstants()).filter(en -> en.getName().equals(packetType.getName())).findAny().orElse(null); Preconditions.checkNotNull(mappedPacket, "Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " could not be automatically mapped!"); - registerClientbound(packetType, mappedPacket, packetRemapper); + registerClientbound(packetType, mappedPacket, handler); } @Override - public void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketRemapper packetRemapper, boolean override) { - register(clientbound, packetType, mappedPacketType, oldClientboundPacketEnum, newClientboundPacketEnum, packetRemapper, override); + public void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketHandler handler, boolean override) { + register(clientbound, packetType, mappedPacketType, unmappedClientboundPacketType, mappedClientboundPacketType, handler, override); } @Override public void cancelClientbound(C1 packetType) { - registerClientbound(packetType, null, new PacketRemapper() { + registerClientbound(packetType, null, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(PacketWrapper::cancel); } }); } @Override - public void registerServerbound(S2 packetType, @Nullable PacketRemapper packetRemapper) { - checkPacketType(packetType, newServerboundPacketEnum == null || packetType.getClass() == newServerboundPacketEnum); + public void registerServerbound(S2 packetType, @Nullable PacketHandler handler) { + checkPacketType(packetType, unmappedServerboundPacketType == null || packetType.getClass() == unmappedServerboundPacketType); - S1 mappedPacket = oldServerboundPacketEnum == newServerboundPacketEnum ? (S1) packetType - : Arrays.stream(oldServerboundPacketEnum.getEnumConstants()).filter(en -> en.getName().equals(packetType.getName())).findAny().orElse(null); + //noinspection unchecked + S1 mappedPacket = mappedServerboundPacketType == unmappedServerboundPacketType ? (S1) packetType + : Arrays.stream(mappedServerboundPacketType.getEnumConstants()).filter(en -> en.getName().equals(packetType.getName())).findAny().orElse(null); Preconditions.checkNotNull(mappedPacket, "Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " could not be automatically mapped!"); - registerServerbound(packetType, mappedPacket, packetRemapper); + registerServerbound(packetType, mappedPacket, handler); } @Override - public void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper, boolean override) { - register(serverbound, packetType, mappedPacketType, newServerboundPacketEnum, oldServerboundPacketEnum, packetRemapper, override); + public void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketHandler handler, boolean override) { + register(serverbound, packetType, mappedPacketType, unmappedServerboundPacketType, mappedServerboundPacketType, handler, override); } @Override public void cancelServerbound(S2 packetType) { - registerServerbound(packetType, null, new PacketRemapper() { + registerServerbound(packetType, null, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(PacketWrapper::cancel); } }); @@ -262,12 +264,12 @@ public abstract class AbstractProtocol packetMap, PacketType packetType, @Nullable PacketType mappedPacketType, Class unmappedPacketEnum, Class mappedPacketEnum, - @Nullable PacketRemapper remapper, boolean override) { + @Nullable PacketHandler handler, boolean override) { checkPacketType(packetType, unmappedPacketEnum == null || packetType.getClass() == unmappedPacketEnum); checkPacketType(mappedPacketType, mappedPacketType == null || mappedPacketEnum == null || mappedPacketType.getClass() == mappedPacketEnum); Preconditions.checkArgument(mappedPacketType == null || packetType.state() == mappedPacketType.state(), "Packet type state does not match mapped packet type state"); - ProtocolPacket protocolPacket = new ProtocolPacket(packetType.state(), packetType, mappedPacketType, remapper); + ProtocolPacket protocolPacket = new ProtocolPacket(packetType.state(), packetType, mappedPacketType, handler); Packet packet = new Packet(packetType.state(), packetType.getId()); if (!override && packetMap.containsKey(packet)) { Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" + @@ -319,13 +321,24 @@ public abstract class AbstractProtocol packetTypeClass = state == State.PLAY ? (direction == Direction.CLIENTBOUND ? oldClientboundPacketEnum : newServerboundPacketEnum) : null; + Class packetTypeClass = state == State.PLAY ? (direction == Direction.CLIENTBOUND ? unmappedClientboundPacketType : unmappedServerboundPacketType) : null; if (packetTypeClass != null) { PacketType[] enumConstants = packetTypeClass.getEnumConstants(); - PacketType packetType = oldId < enumConstants.length && oldId >= 0 ? enumConstants[oldId] : null; - Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName() + " IN REMAP OF " + packetType + " (" + toNiceHex(oldId) + ")"); + PacketType packetType = unmappedPacketId < enumConstants.length && unmappedPacketId >= 0 ? enumConstants[unmappedPacketId] : null; + Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName() + " IN REMAP OF " + packetType + " (" + toNiceHex(unmappedPacketId) + ")"); } else { Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName() - + " IN REMAP OF " + toNiceHex(oldId) + "->" + toNiceHex(newId)); + + " IN REMAP OF " + toNiceHex(unmappedPacketId) + "->" + toNiceHex(mappedPacketId)); } throw e; } @@ -365,7 +378,7 @@ public abstract class AbstractProtocol old clientbound packet types - * @param new clientbound packet types - * @param old serverbound packet types - * @param new serverbound packet types + * @param unmapped ("old") clientbound packet types + * @param mapped ("new") clientbound packet types + * @param mapped ("old") serverbound packet types + * @param unmapped ("new") serverbound packet types * @see SimpleProtocol for a helper class if you do not want to define any of the types above */ public interface Protocol { - default void registerServerbound(State state, int oldPacketID, int newPacketID) { - registerServerbound(state, oldPacketID, newPacketID, null); + default void registerServerbound(State state, int unmappedPacketId, int mappedPacketId) { + registerServerbound(state, unmappedPacketId, mappedPacketId, (PacketHandler) null); } - default void registerServerbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) { - registerServerbound(state, oldPacketID, newPacketID, packetRemapper, false); + default void registerServerbound(State state, int unmappedPacketId, int mappedPacketId, PacketHandler handler) { + registerServerbound(state, unmappedPacketId, mappedPacketId, handler, false); } /** * Registers a serverbound packet, with id transformation and remapper. * - * @param state state which the packet is sent in. - * @param oldPacketID old packet ID - * @param newPacketID new packet ID - * @param packetRemapper remapper to use for the packet - * @param override whether an existing mapper should be overridden - * @see #registerServerbound(ServerboundPacketType, ServerboundPacketType, PacketRemapper, boolean) + * @param state state which the packet is sent in. + * @param unmappedPacketId unmapped packet id + * @param mappedPacketId mapped packet id + * @param handler packet handler + * @param override whether an existing mapper should be overridden + * @see #registerServerbound(ServerboundPacketType, ServerboundPacketType, PacketHandler, boolean) */ - void registerServerbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override); + void registerServerbound(State state, int unmappedPacketId, int mappedPacketId, PacketHandler handler, boolean override); - /** - * @deprecated use {@link #cancelServerbound(State, int)} - */ - @Deprecated/*(forRemoval = true)*/ - void cancelServerbound(State state, int oldPacketID, int newPacketID); + void cancelServerbound(State state, int mappedPacketId); - void cancelServerbound(State state, int newPacketID); - - default void registerClientbound(State state, int oldPacketID, int newPacketID) { - registerClientbound(state, oldPacketID, newPacketID, null); + default void registerClientbound(State state, int unmappedPacketId, int mappedPacketId) { + registerClientbound(state, unmappedPacketId, mappedPacketId, (PacketHandler) null); } - default void registerClientbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) { - registerClientbound(state, oldPacketID, newPacketID, packetRemapper, false); + default void registerClientbound(State state, int unmappedPacketId, int mappedPacketId, PacketHandler handler) { + registerClientbound(state, unmappedPacketId, mappedPacketId, handler, false); } - /** - * @deprecated use {@link #cancelClientbound(State, int)} - */ - @Deprecated/*(forRemoval = true)*/ - void cancelClientbound(State state, int oldPacketID, int newPacketID); - - void cancelClientbound(State state, int oldPacketID); + void cancelClientbound(State state, int unmappedPacketId); /** * Registers a clientbound packet, with id transformation and remapper. * - * @param state state which the packet is sent in. - * @param oldPacketID old packet ID - * @param newPacketID new packet ID - * @param packetRemapper remapper to use for the packet - * @param override whether an existing mapper should be overridden - * @see #registerClientbound(ClientboundPacketType, ClientboundPacketType, PacketRemapper, boolean) + * @param state state which the packet is sent in. + * @param unmappedPacketId unmapped packet id + * @param mappedPacketId mapped packet id + * @param handler packet handler + * @param override whether an existing mapper should be overridden + * @see #registerClientbound(ClientboundPacketType, ClientboundPacketType, PacketHandler, boolean) */ - void registerClientbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override); + void registerClientbound(State state, int unmappedPacketId, int mappedPacketId, PacketHandler handler, boolean override); // --------------------------------------------------------------------------------------- /** * Registers a clientbound protocol and automatically maps it to the new id. * - * @param packetType clientbound packet type the server sends - * @param packetRemapper remapper + * @param packetType clientbound packet type the server sends + * @param handler packet handler */ - void registerClientbound(C1 packetType, @Nullable PacketRemapper packetRemapper); + void registerClientbound(C1 packetType, @Nullable PacketHandler handler); /** * Maps a packet type to another packet type without a packet handler. @@ -121,7 +110,7 @@ public interface Protocol getEntityRewriter() { return null; } @@ -328,7 +319,7 @@ public interface Protocol getItemRewriter() { return null; } @@ -340,4 +331,68 @@ public interface Protocol packetHandlers = new ArrayList<>(); + + protected PacketHandlers() { + register(); + } + + static PacketHandler fromRemapper(List valueRemappers) { + final PacketHandlers handlers = new PacketHandlers() { + @Override + public void register() { + } + }; + handlers.packetHandlers.addAll(valueRemappers); + return handlers; + } + + /** + * Reads and writes the given type. + * + * @param type type to map + */ + public void map(Type type) { + handler(wrapper -> wrapper.write(type, wrapper.read(type))); + } + + /** + * Reads the first given type and writes the second given type. + * + * @param oldType old type + * @param newType new type + */ + public void map(Type oldType, Type newType) { + handler(wrapper -> wrapper.write(newType, wrapper.read(oldType))); + } + + /** + * Maps a type from an old type to a transformed new type. + * + * @param old value type + * @param new value type + * @param oldType old type + * @param newType new type + * @param transformer transformer to produce the new type + */ + public void map(Type oldType, Type newType, Function transformer) { + map(oldType, new ValueTransformer(newType) { + @Override + public T2 transform(PacketWrapper wrapper, T1 inputValue) { + return transformer.apply(inputValue); + } + }); + } + + /** + * Maps a type from an old type to a transformed new type based on their input type. + * + * @param old value type + * @param new value type + * @param transformer transformer to produce the new type + */ + public void map(ValueTransformer transformer) { + if (transformer.getInputType() == null) { + throw new IllegalArgumentException("Use map(Type, ValueTransformer) for value transformers without specified input type!"); + } + map(transformer.getInputType(), transformer); + } + + /** + * Maps a type from an old type to a transformed new type. + * + * @param old value type + * @param new value type + * @param oldType old type + * @param transformer transformer to produce the new type + */ + public void map(Type oldType, ValueTransformer transformer) { + map(new TypeRemapper<>(oldType), transformer); + } + + /** + * Maps a type using a basic ValueReader to a ValueWriter. + * + * @param inputReader reader to read with + * @param outputWriter writer to write with + * @param read/write type + */ + public void map(ValueReader inputReader, ValueWriter outputWriter) { + handler(wrapper -> outputWriter.write(wrapper, inputReader.read(wrapper))); + } + + /** + * Adds a packet handler. + * + * @param handler packet handler + */ + public void handler(PacketHandler handler) { + packetHandlers.add(handler); + } + + /** + * Writes a value. + * + * @param type type to write + * @param value value to write + */ + public void create(Type type, T value) { + handler(wrapper -> wrapper.write(type, value)); + } + + /** + * Reads (and thus removes) the given type. + * + * @param type type to read + */ + public void read(Type type) { + handler(wrapper -> wrapper.read(type)); + } + + /** + * Registers the handlers for this packet. + */ + protected abstract void register(); + + @Override + public final void handle(PacketWrapper wrapper) throws Exception { + for (PacketHandler handler : packetHandlers) { + handler.handle(wrapper); + } + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/PacketRemapper.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/PacketRemapper.java index f0f802932..8282cfdbf 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/PacketRemapper.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/PacketRemapper.java @@ -26,11 +26,14 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.exception.CancelException; import com.viaversion.viaversion.exception.InformativeException; - import java.util.ArrayList; import java.util.List; import java.util.function.Function; +/** + * @deprecated use {@link PacketHandlers} or directly implement {@link PacketHandler} + */ +@Deprecated/*(forRemoval = true)*/ public abstract class PacketRemapper { private final List valueRemappers = new ArrayList<>(); @@ -145,6 +148,10 @@ public abstract class PacketRemapper { */ public abstract void registerMap(); + public PacketHandler asPacketHandler() { + return PacketHandlers.fromRemapper(this.valueRemappers); + } + /** * Processes a packet wrapper. * @@ -152,6 +159,7 @@ public abstract class PacketRemapper { * @throws InformativeException if packet reading or writing fails * @throws CancelException if the packet should be cancelled */ + @Deprecated public void remap(PacketWrapper packetWrapper) throws Exception { try { for (PacketHandler handler : valueRemappers) { diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/ValueReader.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/ValueReader.java index 865a7c3c4..cd572c44e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/ValueReader.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/ValueReader.java @@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; @FunctionalInterface public interface ValueReader { + /** * Reads value from a PacketWrapper * diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/ValueWriter.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/ValueWriter.java index 2cfa8fcbb..6f0905e22 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/ValueWriter.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/remapper/ValueWriter.java @@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; @FunctionalInterface public interface ValueWriter { + /** * Write a value to a packet * diff --git a/common/src/main/java/com/viaversion/viaversion/protocol/packet/PacketWrapperImpl.java b/common/src/main/java/com/viaversion/viaversion/protocol/packet/PacketWrapperImpl.java index d16c32251..bb014a5a5 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocol/packet/PacketWrapperImpl.java +++ b/common/src/main/java/com/viaversion/viaversion/protocol/packet/PacketWrapperImpl.java @@ -76,6 +76,7 @@ public class PacketWrapperImpl implements PacketWrapper { for (Pair packetValue : packetValues) { if (packetValue.key() != type) continue; if (currentIndex == index) { + //noinspection unchecked return (T) packetValue.value(); } currentIndex++; @@ -145,6 +146,7 @@ public class PacketWrapperImpl implements PacketWrapper { if (rtype == type || (type.getBaseClass() == rtype.getBaseClass() && type.getOutputClass() == rtype.getOutputClass())) { + //noinspection unchecked return (T) read.value(); } else if (rtype == Type.NOTHING) { return read(type); // retry @@ -169,7 +171,7 @@ public class PacketWrapperImpl implements PacketWrapper { if (value != null && !expectedType.getOutputClass().isAssignableFrom(value.getClass())) { // Attempt conversion if (expectedType instanceof TypeConverter) { - return ((TypeConverter) expectedType).from(value); + return ((TypeConverter) expectedType).from(value); } Via.getPlatform().getLogger().warning("Possible type mismatch: " + value.getClass().getName() + " -> " + expectedType.getOutputClass()); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java index ddf1de0aa..203c1e93c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java @@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.protocol.ProtocolPipeline; import com.viaversion.viaversion.api.protocol.packet.Direction; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.VersionProvider; import com.viaversion.viaversion.api.type.Type; @@ -40,9 +40,9 @@ public class BaseProtocol extends AbstractProtocol { @Override protected void registerPackets() { // Handshake Packet - registerServerbound(ServerboundHandshakePackets.CLIENT_INTENTION, new PacketRemapper() { + registerServerbound(ServerboundHandshakePackets.CLIENT_INTENTION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { int protocolVersion = wrapper.passthrough(Type.VAR_INT); wrapper.passthrough(Type.STRING); // Server Address diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol1_7.java b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol1_7.java index edb9e5c09..03baad0a5 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol1_7.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol1_7.java @@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.protocol.ProtocolPathEntry; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.VersionProvider; import com.viaversion.viaversion.api.type.Type; @@ -50,9 +50,9 @@ public class BaseProtocol1_7 extends AbstractProtocol { /* Outgoing Packets */ // Status Response Packet - registerClientbound(ClientboundStatusPackets.STATUS_RESPONSE, new PacketRemapper() { // Status Response Packet + registerClientbound(ClientboundStatusPackets.STATUS_RESPONSE, new PacketHandlers() { // Status Response Packet @Override - public void registerMap() { + public void register() { map(Type.STRING); handler(new PacketHandler() { @Override @@ -125,9 +125,9 @@ public class BaseProtocol1_7 extends AbstractProtocol { }); // Login Success Packet - registerClientbound(ClientboundLoginPackets.GAME_PROFILE, new PacketRemapper() { + registerClientbound(ClientboundLoginPackets.GAME_PROFILE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -162,9 +162,9 @@ public class BaseProtocol1_7 extends AbstractProtocol { /* Incoming Packets */ // Login Start Packet - registerServerbound(ServerboundLoginPackets.HELLO, new PacketRemapper() { + registerServerbound(ServerboundLoginPackets.HELLO, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(final PacketWrapper wrapper) throws Exception { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java index a69c26583..f282e4263 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java @@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; import com.viaversion.viaversion.api.rewriter.ItemRewriter; import com.viaversion.viaversion.api.type.Type; @@ -71,9 +71,9 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol { - private final ItemRewriter itemRewriter = new InventoryPackets(this); + private final InventoryPackets itemRewriter = new InventoryPackets(this); public Protocol1_11_1To1_11() { super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class); @@ -37,7 +36,7 @@ public class Protocol1_11_1To1_11 extends AbstractProtocol(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND); - registerClientbound(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketRemapper() { + registerClientbound(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Collected entity id map(Type.VAR_INT); // 1 - Collector entity id @@ -129,9 +129,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); @@ -276,9 +276,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol Trading - protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); // 0 - Channel handler(new PacketHandler() { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12_2to1_12_1/Protocol1_12_2To1_12_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12_2to1_12_1/Protocol1_12_2To1_12_1.java index 5e8cc9b8e..83cb90e32 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12_2to1_12_1/Protocol1_12_2To1_12_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12_2to1_12_1/Protocol1_12_2To1_12_1.java @@ -18,7 +18,7 @@ package com.viaversion.viaversion.protocols.protocol1_12_2to1_12_1; import com.viaversion.viaversion.api.protocol.AbstractProtocol; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1; import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1; @@ -31,16 +31,16 @@ public class Protocol1_12_2To1_12_1 extends AbstractProtocol { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); @@ -197,9 +197,9 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol Trading - protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); // 0 - Channel handler(new PacketHandler() { @@ -75,9 +75,9 @@ public class InventoryPackets extends ItemRewriter(Type.STRING) { @Override @@ -72,9 +72,9 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol { @@ -93,9 +93,9 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol recipeRewriter = new RecipeRewriter1_13_2<>(protocol); - protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { int size = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < size; i++) { // First id, then type String id = wrapper.passthrough(Type.STRING); String type = wrapper.passthrough(Type.STRING).replace("minecraft:", ""); - recipeRewriter.handle(wrapper, type); + recipeRewriter.handleRecipeType(wrapper, type); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/packets/WorldPackets.java index 32726deed..8cca6ac6f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/packets/WorldPackets.java @@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; @@ -36,9 +36,9 @@ public class WorldPackets { public static void register(Protocol1_13_1To1_13 protocol) { BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION); - protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -65,9 +65,9 @@ public class WorldPackets { blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE); blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE); - protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // Effect Id map(Type.POSITION); // Location map(Type.INT); // Data @@ -105,9 +105,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.JOIN_GAME, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Entity ID map(Type.UNSIGNED_BYTE); // 1 - Gamemode map(Type.INT); // 2 - Dimension @@ -124,9 +124,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Dimension ID handler(new PacketHandler() { @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java index df83248fd..0d3699ea0 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java @@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets.EntityPackets; import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets.InventoryPackets; @@ -41,16 +41,16 @@ public class Protocol1_13_2To1_13_1 extends AbstractProtocol componentRewriter.processText(wrapper.passthrough(Type.COMPONENT))); } }); - registerClientbound(State.STATUS, 0x00, 0x00, new PacketRemapper() { + registerClientbound(State.STATUS, 0x00, 0x00, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); handler(new PacketHandler() { @Override @@ -198,9 +198,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol componentRewriter.processText(wrapper.passthrough(Type.COMPONENT))); // Title } }); - registerClientbound(ClientboundPackets1_12_1.COOLDOWN, new PacketRemapper() { + registerClientbound(ClientboundPackets1_12_1.COOLDOWN, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -361,9 +361,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol wrapper.write(Type.STRING, "viaversion:legacy/" + wrapper.read(Type.VAR_INT))); } @@ -394,9 +394,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol(this).registerSound(ClientboundPackets1_12_1.SOUND); - registerClientbound(ClientboundPackets1_12_1.TAB_LIST, new PacketRemapper() { + registerClientbound(ClientboundPackets1_12_1.TAB_LIST, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -640,9 +640,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol Plugin Message - registerServerbound(ServerboundPackets1_13.EDIT_BOOK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() { + registerServerbound(ServerboundPackets1_13.EDIT_BOOK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -756,9 +756,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol Plugin Message - registerServerbound(ServerboundPackets1_13.PICK_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() { + registerServerbound(ServerboundPackets1_13.PICK_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -768,9 +768,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol { @@ -786,9 +786,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol Plugin Message - registerServerbound(ServerboundPackets1_13.RENAME_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() { + registerServerbound(ServerboundPackets1_13.RENAME_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { wrapper.write(Type.STRING, "MC|ItemName"); // Channel }); @@ -829,9 +829,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol Plugin Message - registerServerbound(ServerboundPackets1_13.SELECT_TRADE, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() { + registerServerbound(ServerboundPackets1_13.SELECT_TRADE, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { wrapper.write(Type.STRING, "MC|TrSel"); // Channel }); @@ -840,9 +840,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol Plugin Message - registerServerbound(ServerboundPackets1_13.SET_BEACON_EFFECT, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() { + registerServerbound(ServerboundPackets1_13.SET_BEACON_EFFECT, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { wrapper.write(Type.STRING, "MC|Beacon"); // Channel }); @@ -852,9 +852,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol Plugin Message - registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() { + registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> wrapper.write(Type.STRING, "MC|AutoCmd")); handler(POS_TO_3_INT); map(Type.STRING); // Command @@ -878,9 +878,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol Plugin Message - registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK_MINECART, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() { + registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK_MINECART, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -895,9 +895,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol 0x24 in InventoryPackets // New 0x25 - Update Structure Block -> Message Channel - registerServerbound(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() { + registerServerbound(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { wrapper.write(Type.STRING, "MC|Struct"); // Channel }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/EntityPackets.java index 27065d6e5..118025f57 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/EntityPackets.java @@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_12; import com.viaversion.viaversion.api.type.types.version.Types1_13; @@ -35,9 +35,9 @@ public class EntityPackets { public static void register(Protocol1_13To1_12_2 protocol) { MetadataRewriter1_13To1_12_2 metadataRewriter = protocol.get(MetadataRewriter1_13To1_12_2.class); - protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_ENTITY, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_ENTITY, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity id map(Type.UUID); // 1 - UUID map(Type.BYTE); // 2 - Type @@ -93,9 +93,9 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_MOB, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_MOB, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.UUID); // 1 - Entity UUID map(Type.VAR_INT); // 2 - Entity Type @@ -114,9 +114,9 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PLAYER, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PLAYER, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.UUID); // 1 - Player UUID map(Type.DOUBLE); // 2 - X @@ -130,9 +130,9 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_12_1.JOIN_GAME, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.JOIN_GAME, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Entity ID map(Type.UNSIGNED_BYTE); // 1 - Gamemode map(Type.INT); // 2 - Dimension @@ -147,9 +147,9 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_12_1.ENTITY_EFFECT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.ENTITY_EFFECT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // Entity id map(Type.BYTE); // Effect id map(Type.BYTE); // Amplifier diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java index 90b3a39af..5121445ee 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java @@ -31,7 +31,7 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter; @@ -59,9 +59,9 @@ public class InventoryPackets extends ItemRewriter Trading - protocol.registerClientbound(ClientboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); // 0 - Channel handler(new PacketHandler() { @@ -199,9 +199,9 @@ public class InventoryPackets extends ItemRewriter { @@ -200,9 +199,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_12_1.MULTI_BLOCK_CHANGE, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.MULTI_BLOCK_CHANGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Chunk X map(Type.INT); // 1 - Chunk Z map(Type.BLOCK_CHANGE_RECORD_ARRAY); // 2 - Records @@ -257,9 +256,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_12_1.EXPLOSION, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.EXPLOSION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { if (!Via.getConfig().isServersideBlockConnections()) return; @@ -299,9 +298,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_12_1.UNLOAD_CHUNK, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.UNLOAD_CHUNK, new PacketHandlers() { @Override - public void registerMap() { + public void register() { if (Via.getConfig().isServersideBlockConnections()) { handler(wrapper -> { int x = wrapper.passthrough(Type.INT); @@ -312,9 +311,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_12_1.NAMED_SOUND, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.NAMED_SOUND, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); handler(wrapper -> { String sound = wrapper.get(Type.STRING, 0).replace("minecraft:", ""); @@ -324,9 +323,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_12_1.CHUNK_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.CHUNK_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); BlockStorage storage = wrapper.user().get(BlockStorage.class); @@ -461,11 +460,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PARTICLE, new - - PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PARTICLE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Particle ID map(Type.BOOLEAN); // 1 - Long Distance map(Type.FLOAT); // 2 - X diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java index d140d85a8..ab7f8d7bb 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java @@ -18,7 +18,7 @@ package com.viaversion.viaversion.protocols.protocol1_14_1to1_14.packets; import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.Protocol1_14_1To1_14; @@ -30,9 +30,9 @@ public class EntityPackets { public static void register(Protocol1_14_1To1_14 protocol) { MetadataRewriter1_14_1To1_14 metadataRewriter = protocol.get(MetadataRewriter1_14_1To1_14.class); - protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.UUID); // 1 - Entity UUID map(Type.VAR_INT); // 2 - Entity Type @@ -53,9 +53,9 @@ public class EntityPackets { metadataRewriter.registerRemoveEntities(ClientboundPackets1_14.DESTROY_ENTITIES); - protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PLAYER, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PLAYER, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.UUID); // 1 - Player UUID map(Type.DOUBLE); // 2 - X diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_3to1_14_2/Protocol1_14_3To1_14_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_3to1_14_2/Protocol1_14_3To1_14_2.java index febcffa31..9497d39eb 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_3to1_14_2/Protocol1_14_3To1_14_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_3to1_14_2/Protocol1_14_3To1_14_2.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_14_3to1_14_2; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; @@ -33,9 +33,9 @@ public class Protocol1_14_3To1_14_2 extends AbstractProtocol recipeRewriter = new RecipeRewriter1_13_2<>(protocol); - protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { int size = wrapper.passthrough(Type.VAR_INT); int deleted = 0; @@ -220,7 +220,7 @@ public class InventoryPackets extends ItemRewriter blockRewriter = new BlockRewriter<>(protocol, null); - protocol.registerClientbound(ClientboundPackets1_13.BLOCK_BREAK_ANIMATION, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.BLOCK_BREAK_ANIMATION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); map(Type.POSITION, Type.POSITION1_14); map(Type.BYTE); } }); - protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.POSITION, Type.POSITION1_14); } }); - protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ACTION, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ACTION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.POSITION, Type.POSITION1_14); // Location map(Type.UNSIGNED_BYTE); // Action id map(Type.UNSIGNED_BYTE); // Action param @@ -86,9 +86,9 @@ public class WorldPackets { }); } }); - protocol.registerClientbound(ClientboundPackets1_13.BLOCK_CHANGE, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.BLOCK_CHANGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.POSITION, Type.POSITION1_14); map(Type.VAR_INT); handler(new PacketHandler() { @@ -102,9 +102,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_13.SERVER_DIFFICULTY, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.SERVER_DIFFICULTY, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); handler(new PacketHandler() { @Override @@ -117,9 +117,9 @@ public class WorldPackets { blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE); - protocol.registerClientbound(ClientboundPackets1_13.EXPLOSION, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.EXPLOSION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.FLOAT); // X map(Type.FLOAT); // Y map(Type.FLOAT); // Z @@ -140,9 +140,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -271,9 +271,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // Effect Id map(Type.POSITION, Type.POSITION1_14); // Location map(Type.INT); // Data @@ -292,9 +292,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_13.MAP_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.MAP_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); map(Type.BYTE); map(Type.BOOLEAN); @@ -307,9 +307,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Dimension ID handler(new PacketHandler() { @Override @@ -341,9 +341,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_13.SPAWN_POSITION, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_13.SPAWN_POSITION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.POSITION, Type.POSITION1_14); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java index b0bf594db..5e46dc121 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java @@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types; import com.viaversion.viaversion.api.protocol.AbstractProtocol; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; @@ -60,9 +60,9 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol(this).register(ClientboundPackets1_14.STATISTICS); - registerServerbound(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() { + registerServerbound(ServerboundPackets1_14.EDIT_BOOK, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> itemRewriter.handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/EntityPackets.java index 08e418a62..fe6f619e6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/EntityPackets.java @@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; @@ -39,9 +39,9 @@ public class EntityPackets { metadataRewriter.registerTrackerWithData(ClientboundPackets1_14.SPAWN_ENTITY, Entity1_15Types.FALLING_BLOCK); - protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.UUID); // 1 - Entity UUID map(Type.VAR_INT); // 2 - Entity Type @@ -60,9 +60,9 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PLAYER, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PLAYER, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.UUID); // 1 - Player UUID map(Type.DOUBLE); // 2 - X @@ -80,17 +80,17 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_14.RESPAWN, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_14.RESPAWN, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); handler(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed } }); - protocol.registerClientbound(ClientboundPackets1_14.JOIN_GAME, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_14.JOIN_GAME, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Entity ID map(Type.UNSIGNED_BYTE); // 1 - Gamemode map(Type.INT); // 2 - Dimension diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/WorldPackets.java index 3f91f72b3..349043fee 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/WorldPackets.java @@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type; @@ -41,9 +41,9 @@ public class WorldPackets { blockRewriter.registerMultiBlockChange(ClientboundPackets1_14.MULTI_BLOCK_CHANGE); blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING); - protocol.registerClientbound(ClientboundPackets1_14.CHUNK_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_14.CHUNK_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -90,9 +90,9 @@ public class WorldPackets { }); blockRewriter.registerEffect(ClientboundPackets1_14.EFFECT, 1010, 2001); - protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PARTICLE, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PARTICLE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Particle ID map(Type.BOOLEAN); // 1 - Long Distance map(Type.FLOAT, Type.DOUBLE); // 2 - X diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/Protocol1_16_2To1_16_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/Protocol1_16_2To1_16_1.java index 3b5f11d70..1286fdaf3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/Protocol1_16_2To1_16_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/Protocol1_16_2To1_16_1.java @@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types; import com.viaversion.viaversion.api.protocol.AbstractProtocol; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.data.MappingData; @@ -64,9 +64,9 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol { int recipeType = wrapper.read(Type.VAR_INT); boolean open = wrapper.read(Type.BOOLEAN); @@ -83,9 +83,9 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol { String recipe = wrapper.read(Type.STRING); wrapper.write(Type.VAR_INT, 0); // Shown diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/EntityPackets.java index eee0c45e7..1666fd1c6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/EntityPackets.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_16; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1; @@ -37,9 +37,9 @@ public class EntityPackets { metadataRewriter.registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_16.METADATA_LIST); metadataRewriter.registerRemoveEntities(ClientboundPackets1_16.DESTROY_ENTITIES); - protocol.registerClientbound(ClientboundPackets1_16.JOIN_GAME, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_16.JOIN_GAME, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // Entity ID handler(wrapper -> { short gamemode = wrapper.read(Type.UNSIGNED_BYTE); @@ -67,9 +67,9 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_16.RESPAWN, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_16.RESPAWN, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { String dimensionType = wrapper.read(Type.STRING); wrapper.write(Type.NBT, getDimensionData(dimensionType)); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/InventoryPackets.java index 342577fd7..c6d3a79e9 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/InventoryPackets.java @@ -17,7 +17,7 @@ */ package com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2; @@ -40,9 +40,9 @@ public class InventoryPackets extends ItemRewriter { wrapper.passthrough(Type.VAR_INT); wrapper.passthrough(Type.BOOLEAN); // Open @@ -62,9 +62,9 @@ public class InventoryPackets extends ItemRewriter handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/WorldPackets.java index e70cc3825..b48c2c15d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/WorldPackets.java @@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1; @@ -46,9 +46,9 @@ public class WorldPackets { blockRewriter.registerBlockChange(ClientboundPackets1_16.BLOCK_CHANGE); blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16.ACKNOWLEDGE_PLAYER_DIGGING); - protocol.registerClientbound(ClientboundPackets1_16.CHUNK_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_16.CHUNK_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { Chunk chunk = wrapper.read(new Chunk1_16Type()); wrapper.write(new Chunk1_16_2Type(), chunk); @@ -69,9 +69,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_16.MULTI_BLOCK_CHANGE, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_16.MULTI_BLOCK_CHANGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { wrapper.cancel(); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_4to1_16_3/Protocol1_16_4To1_16_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_4to1_16_3/Protocol1_16_4To1_16_3.java index c7c6c2241..2d2debead 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_4to1_16_3/Protocol1_16_4To1_16_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_4to1_16_3/Protocol1_16_4To1_16_3.java @@ -18,7 +18,7 @@ package com.viaversion.viaversion.protocols.protocol1_16_4to1_16_3; import com.viaversion.viaversion.api.protocol.AbstractProtocol; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2; @@ -31,9 +31,9 @@ public class Protocol1_16_4To1_16_3 extends AbstractProtocol { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java index 715d01613..b544cfd64 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java @@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.State; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.minecraft.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_16; @@ -77,9 +77,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol(this).register(ClientboundPackets1_15.STATISTICS); // Login Success - registerClientbound(State.LOGIN, 0x02, 0x02, new PacketRemapper() { + registerClientbound(State.LOGIN, 0x02, 0x02, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { // Transform string to a uuid UUID uuid = UUID.fromString(wrapper.read(Type.STRING)); @@ -89,9 +89,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol { String original = wrapper.passthrough(Type.STRING); JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class); @@ -129,9 +129,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol { @@ -148,9 +148,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol { wrapper.passthrough(Type.VAR_INT); // Entity Id int action = wrapper.passthrough(Type.VAR_INT); @@ -172,9 +172,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol { String channel = wrapper.passthrough(Type.STRING); if (channel.length() > 32) { @@ -209,9 +209,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol { wrapper.passthrough(Type.BYTE); // Flying and walking speed - not important anyways diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java index fc6e65778..2e322f445 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java @@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.WorldIdentifiers; import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.api.type.types.version.Types1_16; @@ -159,9 +159,9 @@ public class EntityPackets { MetadataRewriter1_16To1_15_2 metadataRewriter = protocol.get(MetadataRewriter1_16To1_15_2.class); // Spawn lightning -> Spawn entity - protocol.registerClientbound(ClientboundPackets1_15.SPAWN_GLOBAL_ENTITY, ClientboundPackets1_16.SPAWN_ENTITY, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_15.SPAWN_GLOBAL_ENTITY, ClientboundPackets1_16.SPAWN_ENTITY, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { int entityId = wrapper.passthrough(Type.VAR_INT); byte type = wrapper.read(Type.BYTE); @@ -195,9 +195,9 @@ public class EntityPackets { metadataRewriter.registerMetadataRewriter(ClientboundPackets1_15.ENTITY_METADATA, Types1_14.METADATA_LIST, Types1_16.METADATA_LIST); metadataRewriter.registerRemoveEntities(ClientboundPackets1_15.DESTROY_ENTITIES); - protocol.registerClientbound(ClientboundPackets1_15.RESPAWN, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_15.RESPAWN, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(DIMENSION_HANDLER); map(Type.LONG); // Seed map(Type.UNSIGNED_BYTE); // Gamemode @@ -212,9 +212,9 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_15.JOIN_GAME, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_15.JOIN_GAME, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // Entity ID map(Type.UNSIGNED_BYTE); // Gamemode handler(wrapper -> { @@ -239,9 +239,9 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_15.ENTITY_PROPERTIES, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_15.ENTITY_PROPERTIES, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { wrapper.passthrough(Type.VAR_INT); int size = wrapper.passthrough(Type.INT); @@ -285,9 +285,9 @@ public class EntityPackets { } }); - protocol.registerServerbound(ServerboundPackets1_16.ANIMATION, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_16.ANIMATION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class); // Don't send an arm swing if the player has an inventory opened. diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java index 91c41e9c6..d0c165746 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java @@ -27,7 +27,7 @@ import com.github.steveice10.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.UUIDIntArrayType; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14; @@ -57,9 +57,9 @@ public class InventoryPackets extends ItemRewriter { InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class); @@ -88,9 +88,9 @@ public class InventoryPackets extends ItemRewriter { @@ -131,9 +131,9 @@ public class InventoryPackets extends ItemRewriter { InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class); inventoryTracker.setInventory((short) -1); @@ -141,9 +141,9 @@ public class InventoryPackets extends ItemRewriter handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java index a8dbd0711..8e9ca20d4 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java @@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.UUIDIntArrayType; import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; @@ -51,18 +51,18 @@ public class WorldPackets { blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE); blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING); - protocol.registerClientbound(ClientboundPackets1_15.UPDATE_LIGHT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_15.UPDATE_LIGHT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // x map(Type.VAR_INT); // y handler(wrapper -> wrapper.write(Type.BOOLEAN, true)); // Take neighbour's light into account as well } }); - protocol.registerClientbound(ClientboundPackets1_15.CHUNK_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_15.CHUNK_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { Chunk chunk = wrapper.read(new Chunk1_15Type()); wrapper.write(new Chunk1_16Type(), chunk); @@ -98,9 +98,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_15.BLOCK_ENTITY_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_15.BLOCK_ENTITY_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { Position position = wrapper.passthrough(Type.POSITION1_14); short action = wrapper.passthrough(Type.UNSIGNED_BYTE); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17_1to1_17/Protocol1_17_1To1_17.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17_1to1_17/Protocol1_17_1To1_17.java index 1bf22014b..2026125e8 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17_1to1_17/Protocol1_17_1To1_17.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17_1to1_17/Protocol1_17_1To1_17.java @@ -23,7 +23,7 @@ import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.AbstractProtocol; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.StringType; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17; @@ -40,9 +40,9 @@ public final class Protocol1_17_1To1_17 extends AbstractProtocol { // Aaaaand back to an array again! int entityId = wrapper.read(Type.VAR_INT); @@ -51,17 +51,17 @@ public final class Protocol1_17_1To1_17 extends AbstractProtocol { @@ -74,17 +74,17 @@ public final class Protocol1_17_1To1_17 extends AbstractProtocol { CompoundTag tag = new CompoundTag(); Item item = new DataItem(942, (byte) 1, (short) 0, tag); // Magic value for writable books diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java index 0938915fc..d395603eb 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java @@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.minecraft.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_17; @@ -59,9 +59,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol { // Tags are now generically written with resource location - 5 different Vanilla types wrapper.write(Type.VAR_INT, 5); @@ -95,9 +95,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol { wrapper.passthrough(Type.STRING); wrapper.passthrough(Type.STRING); @@ -107,9 +107,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol { wrapper.passthrough(Type.VAR_INT); wrapper.passthrough(Type.BYTE); @@ -128,9 +128,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol { // Title packet actions have been split into individual packets (the content hasn't changed) int type = wrapper.read(Type.VAR_INT); @@ -165,9 +165,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol { // Angle (which Mojang just forgot to write to the buffer, lol) @@ -190,9 +190,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol { int[] entityIds = wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE); wrapper.cancel(); @@ -70,9 +70,9 @@ public final class EntityPackets extends EntityRewriter { CompoundTag dimensionData = wrapper.passthrough(Type.NBT); addNewDimensionData(dimensionData); @@ -106,9 +106,9 @@ public final class EntityPackets extends EntityRewriter { // Collection length is now a var int @@ -117,9 +117,9 @@ public final class EntityPackets extends EntityRewriter { // Combat packet actions have been split into individual packets (the content hasn't changed) int type = wrapper.read(Type.VAR_INT); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/InventoryPackets.java index a6de315e5..478615439 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/InventoryPackets.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2; @@ -50,16 +50,16 @@ public final class InventoryPackets extends ItemRewriter handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); } }); - protocol.registerServerbound(ServerboundPackets1_17.CLICK_WINDOW, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_17.CLICK_WINDOW, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); // Window Id map(Type.SHORT); // Slot map(Type.BYTE); // Button @@ -92,9 +92,9 @@ public final class InventoryPackets extends ItemRewriter { short inventoryId = wrapper.read(Type.UNSIGNED_BYTE); short confirmationId = wrapper.read(Type.SHORT); @@ -115,9 +115,9 @@ public final class InventoryPackets extends ItemRewriter { int id = wrapper.read(Type.INT); // Check extra bit for fast dismissal diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/WorldPackets.java index eea52fb40..fc6fff8a6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/WorldPackets.java @@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type; @@ -48,9 +48,9 @@ public final class WorldPackets { blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_16_2.MULTI_BLOCK_CHANGE); blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16_2.ACKNOWLEDGE_PLAYER_DIGGING); - protocol.registerClientbound(ClientboundPackets1_16_2.WORLD_BORDER, null, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_16_2.WORLD_BORDER, null, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { // Border packet actions have been split into individual packets (the content hasn't changed) int type = wrapper.read(Type.VAR_INT); @@ -83,9 +83,9 @@ public final class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_16_2.UPDATE_LIGHT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_16_2.UPDATE_LIGHT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // x map(Type.VAR_INT); // y map(Type.BOOLEAN); // trust edges @@ -127,9 +127,9 @@ public final class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_16_2.CHUNK_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_16_2.CHUNK_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { Chunk chunk = wrapper.read(new Chunk1_16_2Type()); if (!chunk.isFullChunk()) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18_2to1_18/Protocol1_18_2To1_18.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18_2to1_18/Protocol1_18_2To1_18.java index 1bc156d53..3102aec33 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18_2to1_18/Protocol1_18_2To1_18.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18_2to1_18/Protocol1_18_2To1_18.java @@ -23,7 +23,7 @@ import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.protocol.AbstractProtocol; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; @@ -41,25 +41,25 @@ public final class Protocol1_18_2To1_18 extends AbstractProtocol addTagPrefix(wrapper.passthrough(Type.NBT))); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/Protocol1_18To1_17_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/Protocol1_18To1_17_1.java index c1aec5d3f..b07902e4d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/Protocol1_18To1_17_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/Protocol1_18To1_17_1.java @@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types; import com.viaversion.viaversion.api.protocol.AbstractProtocol; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.minecraft.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_18; @@ -67,9 +67,9 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol(this).register(ClientboundPackets1_17_1.STATISTICS); - registerServerbound(ServerboundPackets1_17.CLIENT_SETTINGS, new PacketRemapper() { + registerServerbound(ServerboundPackets1_17.CLIENT_SETTINGS, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); // Language map(Type.BYTE); // View distance map(Type.VAR_INT); // Chat visibility diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/EntityPackets.java index ed07e7f6e..f615e8051 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/EntityPackets.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets; import com.viaversion.viaversion.api.data.entity.EntityTracker; import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types; import com.viaversion.viaversion.api.minecraft.entities.EntityType; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.Particle; import com.viaversion.viaversion.api.type.types.version.Types1_17; @@ -40,9 +40,9 @@ public final class EntityPackets extends EntityRewriter { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/InventoryPackets.java index 876d83237..a62dd7c21 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/InventoryPackets.java @@ -18,7 +18,7 @@ package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets; import com.viaversion.viaversion.api.data.ParticleMappings; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16; import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1; @@ -41,9 +41,9 @@ public final class InventoryPackets extends ItemRewriter { final short id = wrapper.read(Type.UNSIGNED_BYTE); @@ -57,9 +57,9 @@ public final class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_17_1.UPDATE_LIGHT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_17_1.UPDATE_LIGHT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { final int chunkX = wrapper.passthrough(Type.VAR_INT); final int chunkZ = wrapper.passthrough(Type.VAR_INT); @@ -101,9 +101,9 @@ public final class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_17_1.CHUNK_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_17_1.CHUNK_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user()); final Chunk oldChunk = wrapper.read(new Chunk1_17Type(tracker.currentWorldSectionHeight())); @@ -199,9 +199,9 @@ public final class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_17_1.UNLOAD_CHUNK, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_17_1.UNLOAD_CHUNK, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { final int chunkX = wrapper.passthrough(Type.INT); final int chunkZ = wrapper.passthrough(Type.INT); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java index 3bb6eee27..22cae62dd 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java @@ -31,7 +31,7 @@ import com.viaversion.viaversion.api.minecraft.ProfileKey; import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.State; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.libs.kyori.adventure.text.Component; import com.viaversion.viaversion.libs.kyori.adventure.text.TranslatableComponent; @@ -97,9 +97,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol { final int type = wrapper.read(Type.VAR_INT); @@ -108,9 +108,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol { // Back to system chat final JsonElement signedContent = wrapper.read(Type.COMPONENT); @@ -135,9 +135,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol { // Profile keys are not compatible; replace it with an empty one @@ -219,9 +219,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol { if (wrapper.user().has(NonceStorage.class)) { @@ -234,9 +234,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol { final NonceStorage nonceStorage = wrapper.user().remove(NonceStorage.class); @@ -254,9 +254,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java index f915fd746..155d14713 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java @@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.BitSetType; import com.viaversion.viaversion.api.type.types.ByteArrayType; @@ -79,9 +79,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol soundRewriter = new SoundRewriter<>(this); - registerClientbound(ClientboundPackets1_19_1.ENTITY_SOUND, new PacketRemapper() { + registerClientbound(ClientboundPackets1_19_1.ENTITY_SOUND, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // Sound id handler(soundRewriter.getSoundHandler()); handler(wrapper -> { @@ -91,9 +91,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol { @@ -103,9 +103,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol { wrapper.write(Type.VAR_INT, 0); wrapper.passthrough(Type.STRING); // Sound identifier @@ -152,9 +152,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol { final PlayerMessageSignature signature = wrapper.read(Type.PLAYER_MESSAGE_SIGNATURE); @@ -210,9 +210,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol { final int action = wrapper.read(Type.VAR_INT); if (action == 4) { // Remove player diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/InventoryPackets.java index 90ad0c53e..f6d2d43b4 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/InventoryPackets.java @@ -18,7 +18,7 @@ package com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.packets; import com.viaversion.viaversion.api.minecraft.item.Item; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type; @@ -58,9 +58,9 @@ public final class InventoryPackets extends ItemRewriter recipeRewriter = new RecipeRewriter1_16<>(protocol); - protocol.registerClientbound(ClientboundPackets1_19_1.DECLARE_RECIPES, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_19_1.DECLARE_RECIPES, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { final int size = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < size; i++) { @@ -123,7 +123,7 @@ public final class InventoryPackets extends ItemRewriter { final short action = wrapper.read(Type.UNSIGNED_BYTE); @@ -89,18 +89,18 @@ public final class EntityPackets extends EntityRewriter { final int entityId = wrapper.read(Type.INT); final byte event = wrapper.read(Type.BYTE); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java index 590c6d160..db950b1ca 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java @@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.platform.providers.ViaProviders; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.minecraft.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_19; @@ -77,9 +77,9 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol soundRewriter = new SoundRewriter<>(this); - registerClientbound(ClientboundPackets1_18.SOUND, new PacketRemapper() { + registerClientbound(ClientboundPackets1_18.SOUND, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // Sound id map(Type.VAR_INT); // Source map(Type.INT); // X @@ -91,9 +91,9 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol commandRewriter = new CommandRewriter<>(this); - registerClientbound(ClientboundPackets1_18.DECLARE_COMMANDS, new PacketRemapper() { + registerClientbound(ClientboundPackets1_18.DECLARE_COMMANDS, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { final int size = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < size; i++) { @@ -180,9 +180,9 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol { final int type = wrapper.read(Type.BYTE); @@ -192,9 +192,9 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol { final byte[] publicKey = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); @@ -245,17 +245,17 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol { if (wrapper.read(Type.BOOLEAN)) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java index f3e43981d..d4fc48c46 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java @@ -31,7 +31,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_18; import com.viaversion.viaversion.api.type.types.version.Types1_19; @@ -96,9 +96,9 @@ public final class EntityPackets extends EntityRewriter { @@ -159,9 +159,9 @@ public final class EntityPackets extends EntityRewriter writeDimensionKey(wrapper, wrapper.user().get(DimensionRegistryStorage.class))); map(Type.STRING); // World map(Type.LONG); // Seed @@ -266,9 +266,9 @@ public final class EntityPackets extends EntityRewriter { final int action = wrapper.passthrough(Type.VAR_INT); final int entries = wrapper.passthrough(Type.VAR_INT); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java index a8c4740b6..2ca6448f3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_19to1_18_2.packets; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; @@ -41,9 +41,9 @@ public final class InventoryPackets extends ItemRewriter { final int size = wrapper.read(Type.UNSIGNED_BYTE); @@ -92,18 +92,18 @@ public final class InventoryPackets extends ItemRewriter { final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user()); Preconditions.checkArgument(tracker.biomesSent() != 0, "Biome count not set"); @@ -65,9 +65,9 @@ public final class WorldPackets { } }); - protocol.registerServerbound(ServerboundPackets1_19.SET_BEACON_EFFECT, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_19.SET_BEACON_EFFECT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { // Primary effect if (wrapper.read(Type.BOOLEAN)) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_1_2to1_9_3_4/Protocol1_9_1_2To1_9_3_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_1_2to1_9_3_4/Protocol1_9_1_2To1_9_3_4.java index b607fe7ed..fe7c04170 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_1_2to1_9_3_4/Protocol1_9_1_2To1_9_3_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_1_2to1_9_3_4/Protocol1_9_1_2To1_9_3_4.java @@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.chunks.BlockEntity; import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type; @@ -46,9 +46,9 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol { if (wrapper.isReadable(Type.COMPONENT, 0)) { // Already written as json somewhere else diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/EntityPackets.java index 10b486d40..e324c9ba7 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/EntityPackets.java @@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_8; @@ -54,10 +54,10 @@ public class EntityPackets { public static void register(Protocol1_9To1_8 protocol) { // Attach Entity Packet - protocol.registerClientbound(ClientboundPackets1_8.ATTACH_ENTITY, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.ATTACH_ENTITY, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Entity ID map(Type.INT); // 1 - Vehicle @@ -90,10 +90,10 @@ public class EntityPackets { }); } }); - protocol.registerClientbound(ClientboundPackets1_8.ENTITY_TELEPORT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.ENTITY_TELEPORT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.INT, SpawnPackets.toNewDouble); // 1 - X - Needs to be divide by 32 map(Type.INT, SpawnPackets.toNewDouble); // 2 - Y - Needs to be divide by 32 @@ -122,10 +122,10 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.ENTITY_POSITION_AND_ROTATION, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.ENTITY_POSITION_AND_ROTATION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.BYTE, toNewShort); // 1 - X map(Type.BYTE, toNewShort); // 2 - Y @@ -137,10 +137,10 @@ public class EntityPackets { map(Type.BOOLEAN); // 6 - On Ground } }); - protocol.registerClientbound(ClientboundPackets1_8.ENTITY_POSITION, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.ENTITY_POSITION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.BYTE, toNewShort); // 1 - X map(Type.BYTE, toNewShort); // 2 - Y @@ -149,10 +149,10 @@ public class EntityPackets { map(Type.BOOLEAN); // 4 - On Ground } }); - protocol.registerClientbound(ClientboundPackets1_8.ENTITY_EQUIPMENT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.ENTITY_EQUIPMENT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID // 1 - Slot ID map(Type.SHORT, new ValueTransformer(Type.VAR_INT) { @@ -197,10 +197,10 @@ public class EntityPackets { }); } }); - protocol.registerClientbound(ClientboundPackets1_8.ENTITY_METADATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.ENTITY_METADATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Types1_8.METADATA_LIST, Types1_9.METADATA_LIST); // 1 - Metadata List handler(new PacketHandler() { @@ -243,9 +243,9 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.ENTITY_EFFECT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.ENTITY_EFFECT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.BYTE); // 1 - Effect ID map(Type.BYTE); // 2 - Amplifier @@ -264,9 +264,9 @@ public class EntityPackets { protocol.cancelClientbound(ClientboundPackets1_8.UPDATE_ENTITY_NBT); - protocol.registerClientbound(ClientboundPackets1_8.COMBAT_EVENT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.COMBAT_EVENT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); //Event id handler(new PacketHandler() { @Override @@ -281,9 +281,9 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.ENTITY_PROPERTIES, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.ENTITY_PROPERTIES, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); handler(new PacketHandler() { @Override @@ -338,9 +338,9 @@ public class EntityPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.ENTITY_ANIMATION, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.ENTITY_ANIMATION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.UNSIGNED_BYTE); // 1 - Animation handler(new PacketHandler() { @@ -356,10 +356,10 @@ public class EntityPackets { /* Incoming Packets */ - protocol.registerServerbound(ServerboundPackets1_9.ENTITY_ACTION, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.ENTITY_ACTION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Player ID map(Type.VAR_INT); // 1 - Action map(Type.VAR_INT); // 2 - Jump @@ -377,10 +377,10 @@ public class EntityPackets { } }); - protocol.registerServerbound(ServerboundPackets1_9.INTERACT_ENTITY, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.INTERACT_ENTITY, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID (Target) map(Type.VAR_INT); // 1 - Action Type diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/InventoryPackets.java index d8e7327df..55361ee62 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/InventoryPackets.java @@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9; @@ -35,10 +35,10 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.InventoryTra public class InventoryPackets { public static void register(Protocol1_9To1_8 protocol) { - protocol.registerClientbound(ClientboundPackets1_8.WINDOW_PROPERTY, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.WINDOW_PROPERTY, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.SHORT); // 1 - Property Key map(Type.SHORT); // 2 - Property Value @@ -74,10 +74,10 @@ public class InventoryPackets { }); } }); - protocol.registerClientbound(ClientboundPackets1_8.OPEN_WINDOW, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.OPEN_WINDOW, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.STRING); // 1 - Window Type map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 2 - Window Title @@ -104,9 +104,9 @@ public class InventoryPackets { }); } }); - protocol.registerClientbound(ClientboundPackets1_8.SET_SLOT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.SET_SLOT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.SHORT); // 1 - Slot ID map(Type.ITEM); // 2 - Slot Value @@ -154,10 +154,10 @@ public class InventoryPackets { }); } }); - protocol.registerClientbound(ClientboundPackets1_8.WINDOW_ITEMS, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.WINDOW_ITEMS, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.ITEM_ARRAY); // 1 - Window Values @@ -215,10 +215,10 @@ public class InventoryPackets { }); } }); - protocol.registerClientbound(ClientboundPackets1_8.CLOSE_WINDOW, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.CLOSE_WINDOW, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); // 0 - Window ID // Inventory tracking handler(new PacketHandler() { @@ -232,10 +232,10 @@ public class InventoryPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.MAP_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.MAP_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Map ID map(Type.BYTE); // 1 - Map Scale handler(new PacketHandler() { @@ -250,10 +250,10 @@ public class InventoryPackets { /* Incoming Packets */ - protocol.registerServerbound(ServerboundPackets1_9.CREATIVE_INVENTORY_ACTION, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.CREATIVE_INVENTORY_ACTION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.SHORT); // 0 - Slot ID map(Type.ITEM); // 1 - Item handler(new PacketHandler() { @@ -303,10 +303,10 @@ public class InventoryPackets { } }); - protocol.registerServerbound(ServerboundPackets1_9.CLICK_WINDOW, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.CLICK_WINDOW, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.SHORT); // 1 - Slot ID map(Type.BYTE); // 2 - Button @@ -371,10 +371,10 @@ public class InventoryPackets { } }); - protocol.registerServerbound(ServerboundPackets1_9.CLOSE_WINDOW, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.CLOSE_WINDOW, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); // 0 - Window ID // Inventory tracking @@ -389,9 +389,9 @@ public class InventoryPackets { } }); - protocol.registerServerbound(ServerboundPackets1_9.HELD_ITEM_CHANGE, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.HELD_ITEM_CHANGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.SHORT); // 0 - Slot id // Blocking patch diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/PlayerPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/PlayerPackets.java index 533946d02..35be68de7 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/PlayerPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/PlayerPackets.java @@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; @@ -41,9 +41,9 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracke public class PlayerPackets { public static void register(Protocol1_9To1_8 protocol) { - protocol.registerClientbound(ClientboundPackets1_8.CHAT_MESSAGE, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.CHAT_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Chat Message (json) map(Type.BYTE); // 1 - Chat Positon @@ -58,24 +58,24 @@ public class PlayerPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.TAB_LIST, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.TAB_LIST, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Header map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 1 - Footer } }); - protocol.registerClientbound(ClientboundPackets1_8.DISCONNECT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.DISCONNECT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Reason } }); - protocol.registerClientbound(ClientboundPackets1_8.TITLE, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.TITLE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Action // We only handle if the title or subtitle is set then just write through. handler(wrapper -> { @@ -88,9 +88,9 @@ public class PlayerPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.PLAYER_POSITION, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.PLAYER_POSITION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.DOUBLE); // 0 - Player X map(Type.DOUBLE); // 1 - Player Y map(Type.DOUBLE); // 2 - Player Z @@ -106,9 +106,9 @@ public class PlayerPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.TEAMS, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.TEAMS, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); // 0 - Team Name map(Type.BYTE); // 1 - Mode handler(wrapper -> { @@ -167,9 +167,9 @@ public class PlayerPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.JOIN_GAME, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.JOIN_GAME, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Player ID // Parse this info handler(wrapper -> { @@ -220,9 +220,9 @@ public class PlayerPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.PLAYER_INFO, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.PLAYER_INFO, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Action map(Type.VAR_INT); // 1 - Player Count @@ -263,9 +263,9 @@ public class PlayerPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.PLUGIN_MESSAGE, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); // 0 - Channel Name handler(wrapper -> { String name = wrapper.get(Type.STRING, 0); @@ -302,9 +302,9 @@ public class PlayerPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.RESPAWN, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.RESPAWN, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Dimension map(Type.UNSIGNED_BYTE); // 1 - Difficulty map(Type.UNSIGNED_BYTE); // 2 - GameMode @@ -338,9 +338,9 @@ public class PlayerPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.GAME_EVENT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.GAME_EVENT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); //0 - Reason map(Type.FLOAT); //1 - Value @@ -358,9 +358,9 @@ public class PlayerPackets { }); /* Removed packets */ - protocol.registerClientbound(ClientboundPackets1_8.SET_COMPRESSION, null, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.SET_COMPRESSION, null, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { wrapper.cancel(); CompressionProvider provider = Via.getManager().getProviders().get(CompressionProvider.class); @@ -372,17 +372,17 @@ public class PlayerPackets { /* Incoming Packets */ - protocol.registerServerbound(ServerboundPackets1_9.TAB_COMPLETE, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.TAB_COMPLETE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); // 0 - Requested Command map(Type.BOOLEAN, Type.NOTHING); // 1 - Is Command Block } }); - protocol.registerServerbound(ServerboundPackets1_9.CLIENT_SETTINGS, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.CLIENT_SETTINGS, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); // 0 - locale map(Type.BYTE); // 1 - View Distance map(Type.VAR_INT, Type.BYTE); // 2 - Chat Mode @@ -405,9 +405,9 @@ public class PlayerPackets { } }); - protocol.registerServerbound(ServerboundPackets1_9.ANIMATION, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.ANIMATION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT, Type.NOTHING); // 0 - Hand } }); @@ -416,9 +416,9 @@ public class PlayerPackets { protocol.cancelServerbound(ServerboundPackets1_9.VEHICLE_MOVE); protocol.cancelServerbound(ServerboundPackets1_9.STEER_BOAT); - protocol.registerServerbound(ServerboundPackets1_9.PLUGIN_MESSAGE, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.PLUGIN_MESSAGE, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); // 0 - Channel Name handler(wrapper -> { String name = wrapper.get(Type.STRING, 0); @@ -446,9 +446,9 @@ public class PlayerPackets { } }); - protocol.registerServerbound(ServerboundPackets1_9.CLIENT_STATUS, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.CLIENT_STATUS, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Action ID handler(wrapper -> { int action = wrapper.get(Type.VAR_INT, 0); @@ -466,9 +466,9 @@ public class PlayerPackets { } }); - protocol.registerServerbound(ServerboundPackets1_9.PLAYER_POSITION, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.PLAYER_POSITION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.DOUBLE); // 0 - X map(Type.DOUBLE); // 1 - Y map(Type.DOUBLE); // 2 - Z @@ -476,9 +476,9 @@ public class PlayerPackets { handler(new PlayerMovementMapper()); } }); - protocol.registerServerbound(ServerboundPackets1_9.PLAYER_POSITION_AND_ROTATION, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.PLAYER_POSITION_AND_ROTATION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.DOUBLE); // 0 - X map(Type.DOUBLE); // 1 - Y map(Type.DOUBLE); // 2 - Z @@ -488,18 +488,18 @@ public class PlayerPackets { handler(new PlayerMovementMapper()); } }); - protocol.registerServerbound(ServerboundPackets1_9.PLAYER_ROTATION, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.PLAYER_ROTATION, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.FLOAT); // 0 - Yaw map(Type.FLOAT); // 1 - Pitch map(Type.BOOLEAN); // 2 - Ground handler(new PlayerMovementMapper()); } }); - protocol.registerServerbound(ServerboundPackets1_9.PLAYER_MOVEMENT, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.PLAYER_MOVEMENT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.BOOLEAN); // 0 - Ground handler(new PlayerMovementMapper()); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/SpawnPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/SpawnPackets.java index 2b0ac2406..a02bef4cd 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/SpawnPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/SpawnPackets.java @@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_8; @@ -50,9 +50,9 @@ public class SpawnPackets { }; public static void register(Protocol1_9To1_8 protocol) { - protocol.registerClientbound(ClientboundPackets1_8.SPAWN_ENTITY, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.SPAWN_ENTITY, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID handler(new PacketHandler() { @@ -138,9 +138,9 @@ public class SpawnPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.SPAWN_EXPERIENCE_ORB, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.SPAWN_EXPERIENCE_ORB, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID // Parse this info @@ -162,9 +162,9 @@ public class SpawnPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.SPAWN_GLOBAL_ENTITY, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.SPAWN_GLOBAL_ENTITY, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.BYTE); // 1 - Type // Parse this info @@ -185,9 +185,9 @@ public class SpawnPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.SPAWN_MOB, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.SPAWN_MOB, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID handler(new PacketHandler() { @@ -252,9 +252,9 @@ public class SpawnPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.SPAWN_PAINTING, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.SPAWN_PAINTING, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID // Parse this info @@ -282,9 +282,9 @@ public class SpawnPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.SPAWN_PLAYER, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.SPAWN_PLAYER, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.UUID); // 1 - Player UUID @@ -354,10 +354,10 @@ public class SpawnPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.DESTROY_ENTITIES, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.DESTROY_ENTITIES, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entities to destroy handler(new PacketHandler() { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/WorldPackets.java index 319a6005c..f6b3ef55d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -29,7 +29,7 @@ import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8; @@ -51,9 +51,9 @@ import java.util.Optional; public class WorldPackets { public static void register(Protocol1_9To1_8 protocol) { - protocol.registerClientbound(ClientboundPackets1_8.UPDATE_SIGN, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.UPDATE_SIGN, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.POSITION); // 0 - Sign Position map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 1 - Sign Line (json) map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 2 - Sign Line (json) @@ -62,9 +62,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.EFFECT, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.EFFECT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Effect ID map(Type.POSITION); // 1 - Position map(Type.INT); // 2 - Data @@ -94,9 +94,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.NAMED_SOUND, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.NAMED_SOUND, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.STRING); // 0 - Sound Name // 1 - Sound Category ID // Everything else get's written through @@ -129,9 +129,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.CHUNK_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.CHUNK_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -191,9 +191,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.MAP_BULK_CHUNK, null, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.MAP_BULK_CHUNK, null, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { wrapper.cancel(); // Cancel the packet from being sent ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); @@ -227,9 +227,9 @@ public class WorldPackets { } }); - protocol.registerClientbound(ClientboundPackets1_8.BLOCK_ENTITY_DATA, new PacketRemapper() { + protocol.registerClientbound(ClientboundPackets1_8.BLOCK_ENTITY_DATA, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.POSITION); // 0 - Block Position map(Type.UNSIGNED_BYTE); // 1 - Action map(Type.NBT); // 2 - NBT (Might not be present) @@ -266,9 +266,9 @@ public class WorldPackets { /* Incoming Packets */ - protocol.registerServerbound(ServerboundPackets1_9.UPDATE_SIGN, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.UPDATE_SIGN, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.POSITION); // 0 - Sign Position map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 1 - Sign Line (json) map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 2 - Sign Line (json) @@ -277,9 +277,9 @@ public class WorldPackets { } }); - protocol.registerServerbound(ServerboundPackets1_9.PLAYER_DIGGING, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.PLAYER_DIGGING, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // Action map(Type.POSITION); // Position handler(new PacketHandler() { @@ -309,9 +309,9 @@ public class WorldPackets { } }); - protocol.registerServerbound(ServerboundPackets1_9.USE_ITEM, null, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.USE_ITEM, null, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -375,9 +375,9 @@ public class WorldPackets { } }); - protocol.registerServerbound(ServerboundPackets1_9.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_9.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.POSITION); // 0 - Position map(Type.VAR_INT, Type.UNSIGNED_BYTE); // 1 - Block Face handler(new PacketHandler() { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_9_1/Protocol1_9To1_9_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_9_1/Protocol1_9To1_9_1.java index 0fbefa9a7..270a8c811 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_9_1/Protocol1_9To1_9_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_9_1/Protocol1_9To1_9_1.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_9to1_9_1; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9; @@ -35,9 +35,9 @@ public class Protocol1_9To1_9_1 extends AbstractProtocol { } public void registerBlockAction(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(positionType); // Location map(Type.UNSIGNED_BYTE); // Action id map(Type.UNSIGNED_BYTE); // Action param @@ -68,9 +68,9 @@ public class BlockRewriter { } public void registerBlockChange(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(positionType); map(Type.VAR_INT); handler(wrapper -> wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.VAR_INT, 0)))); @@ -79,9 +79,9 @@ public class BlockRewriter { } public void registerMultiBlockChange(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Chunk X map(Type.INT); // 1 - Chunk Z handler(wrapper -> { @@ -94,9 +94,9 @@ public class BlockRewriter { } public void registerVarLongMultiBlockChange(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.LONG); // Chunk position map(Type.BOOLEAN); // Suppress light updates handler(wrapper -> { @@ -114,9 +114,9 @@ public class BlockRewriter { } public void registerEffect(C packetType, int playRecordId, int blockBreakId) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // Effect Id map(positionType); // Location map(Type.INT); // Data @@ -134,9 +134,9 @@ public class BlockRewriter { } public void registerChunkData1_19(C packetType, ChunkTypeSupplier chunkTypeSupplier) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user()); Preconditions.checkArgument(tracker.biomesSent() != 0, "Biome count not set"); @@ -167,9 +167,9 @@ public class BlockRewriter { } public void registerBlockEntityData(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.POSITION1_14); handler(wrapper -> { final int blockEntityId = wrapper.read(Type.VAR_INT); diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/CommandRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/CommandRewriter.java index 0402e3311..75d8a02dc 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/CommandRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/CommandRewriter.java @@ -21,7 +21,7 @@ import com.google.common.base.Preconditions; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import java.util.HashMap; import java.util.Map; @@ -67,9 +67,9 @@ public class CommandRewriter { } public void registerDeclareCommands(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { int size = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < size; i++) { @@ -107,9 +107,9 @@ public class CommandRewriter { } public void registerDeclareCommands1_19(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { int size = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < size; i++) { diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/ComponentRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/ComponentRewriter.java index 4e8a6d15e..f37f2777a 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/ComponentRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/ComponentRewriter.java @@ -25,7 +25,7 @@ import com.google.gson.JsonSyntaxException; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; /** @@ -53,9 +53,9 @@ public class ComponentRewriter { * @param packetType clientbound packet type */ public void registerComponentPacket(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT))); } }); @@ -67,9 +67,9 @@ public class ComponentRewriter { } public void registerBossBar(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UUID); map(Type.VAR_INT); handler(wrapper -> { @@ -86,9 +86,9 @@ public class ComponentRewriter { * Handles sub 1.17 combat event components. */ public void registerCombatEvent(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { if (wrapper.passthrough(Type.VAR_INT) == 2) { wrapper.passthrough(Type.VAR_INT); @@ -104,9 +104,9 @@ public class ComponentRewriter { * Handles sub 1.17 title components. */ public void registerTitle(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { int action = wrapper.passthrough(Type.VAR_INT); if (action >= 0 && action <= 2) { diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java index 11264e6a5..e6c098065 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java @@ -37,7 +37,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.rewriter.RewriterBase; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.Particle; @@ -253,9 +253,9 @@ public abstract class EntityRewriter intType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { int entityId = wrapper.passthrough(intType); tracker(wrapper.user()).addEntity(entityId, entityType); @@ -350,9 +350,9 @@ public abstract class EntityRewriter { int[] entityIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); EntityTracker entityTracker = tracker(wrapper.user()); @@ -370,9 +370,9 @@ public abstract class EntityRewriter { int entityId = wrapper.passthrough(Type.VAR_INT); tracker(wrapper.user()).removeEntity(entityId); @@ -382,9 +382,9 @@ public abstract class EntityRewriter> oldMetaType, Type> newMetaType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID if (oldMetaType != null) { map(oldMetaType, newMetaType); diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java index 5ff5e92fd..4d9d030b6 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java @@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.rewriter.RewriterBase; import com.viaversion.viaversion.api.type.Type; import org.checkerframework.checker.nullness.qual.Nullable; @@ -57,9 +57,9 @@ public abstract class ItemRewriter type) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); // Window id map(type); // Items handler(itemArrayHandler(type)); @@ -68,9 +68,9 @@ public abstract class ItemRewriter { @@ -86,9 +86,9 @@ public abstract class ItemRewriter type) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); // Window id map(Type.SHORT); // Slot id map(type); // Item @@ -98,9 +98,9 @@ public abstract class ItemRewriter type) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 1 - Slot ID map(type); // 2 - Item @@ -126,9 +126,9 @@ public abstract class ItemRewriter { @@ -144,9 +144,9 @@ public abstract class ItemRewriter type) { - protocol.registerServerbound(packetType, new PacketRemapper() { + protocol.registerServerbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.SHORT); // 0 - Slot map(type); // 1 - Clicked Item @@ -156,9 +156,9 @@ public abstract class ItemRewriter type) { - protocol.registerServerbound(packetType, new PacketRemapper() { + protocol.registerServerbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.SHORT); // 1 - Slot map(Type.BYTE); // 2 - Button @@ -172,9 +172,9 @@ public abstract class ItemRewriter { int itemId = wrapper.read(Type.VAR_INT); wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewItemId(itemId)); @@ -210,9 +210,9 @@ public abstract class ItemRewriter { wrapper.passthrough(Type.VAR_INT); int size = wrapper.passthrough(Type.UNSIGNED_BYTE); @@ -240,9 +240,9 @@ public abstract class ItemRewriter { wrapper.passthrough(Type.VAR_INT); // Container id int size = wrapper.passthrough(Type.VAR_INT); @@ -266,9 +266,9 @@ public abstract class ItemRewriter type) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { wrapper.passthrough(Type.BOOLEAN); // Reset/clear int size = wrapper.passthrough(Type.VAR_INT); // Mapping size @@ -306,9 +306,9 @@ public abstract class ItemRewriter { short property = wrapper.passthrough(Type.SHORT); @@ -324,9 +324,9 @@ public abstract class ItemRewriter itemType, Type coordType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.INT); // 0 - Particle ID map(Type.BOOLEAN); // 1 - Long Distance map(coordType); // 2 - X @@ -343,9 +343,9 @@ public abstract class ItemRewriter { this.protocol = protocol; } - public void handle(PacketWrapper wrapper, String type) throws Exception { + public void handleRecipeType(PacketWrapper wrapper, String type) throws Exception { RecipeConsumer handler = recipeHandlers.get(type); if (handler != null) { handler.accept(wrapper); @@ -45,15 +45,15 @@ public abstract class RecipeRewriter { } public void registerDefaultHandler(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { int size = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < size; i++) { String type = wrapper.passthrough(Type.STRING).replace("minecraft:", ""); wrapper.passthrough(Type.STRING); // Recipe Identifier - handle(wrapper, type); + handleRecipeType(wrapper, type); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/SoundRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/SoundRewriter.java index 381457769..69063dc23 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/SoundRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/SoundRewriter.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.rewriter; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; public class SoundRewriter { @@ -39,9 +39,9 @@ public class SoundRewriter { // The same for entity sound public void registerSound(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { map(Type.VAR_INT); // Sound Id handler(getSoundHandler()); } @@ -49,9 +49,9 @@ public class SoundRewriter { } public void register1_19_3Sound(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { final int soundId = wrapper.read(Type.VAR_INT); if (soundId == 0) { diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/StatisticsRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/StatisticsRewriter.java index 4dfbb9f81..dd01c66d5 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/StatisticsRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/StatisticsRewriter.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.rewriter; import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import org.checkerframework.checker.nullness.qual.Nullable; @@ -33,9 +33,9 @@ public class StatisticsRewriter { } public void register(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(wrapper -> { int size = wrapper.passthrough(Type.VAR_INT); int newSize = size; diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java index 324126d0a..83a66945c 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java @@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; @@ -136,9 +136,9 @@ public class TagRewriter { * @param readUntilType read and process the types until (including) the given registry type */ public void register(C packetType, @Nullable RegistryType readUntilType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(getHandler(readUntilType)); } }); @@ -150,9 +150,9 @@ public class TagRewriter { * @param packetType packet type */ public void registerGeneric(C packetType) { - protocol.registerClientbound(packetType, new PacketRemapper() { + protocol.registerClientbound(packetType, new PacketHandlers() { @Override - public void registerMap() { + public void register() { handler(getGenericHandler()); } });