diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/packets/InventoryPackets.java index bb25bc09d..2aad39989 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/packets/InventoryPackets.java @@ -20,10 +20,11 @@ package com.viaversion.viaversion.protocols.protocol1_10to1_9_3.packets; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4; +import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import com.viaversion.viaversion.rewriter.ItemRewriter; -public class InventoryPackets extends ItemRewriter { +public class InventoryPackets extends ItemRewriter { public InventoryPackets(Protocol1_10To1_9_3_4 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11_1to1_11/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11_1to1_11/packets/InventoryPackets.java index 2b0dd8c28..ed863e89b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11_1to1_11/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11_1to1_11/packets/InventoryPackets.java @@ -20,10 +20,11 @@ package com.viaversion.viaversion.protocols.protocol1_11_1to1_11.packets; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_11_1to1_11.Protocol1_11_1To1_11; +import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import com.viaversion.viaversion.rewriter.ItemRewriter; -public class InventoryPackets extends ItemRewriter { +public class InventoryPackets extends ItemRewriter { public InventoryPackets(Protocol1_11_1To1_11 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java index 78647c717..acba73387 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java @@ -28,7 +28,6 @@ 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.ValueTransformer; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_9; import com.viaversion.viaversion.protocols.protocol1_11to1_10.data.PotionColorMapping; @@ -39,7 +38,6 @@ import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1 import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -import com.viaversion.viaversion.rewriter.EntityRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.util.Pair; @@ -51,8 +49,8 @@ public class Protocol1_11To1_10 extends AbstractProtocol(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND); registerClientbound(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketRemapper() { @Override @@ -382,12 +380,12 @@ public class Protocol1_11To1_10 extends AbstractProtocol { +public class MetadataRewriter1_11To1_10 extends EntityRewriter { public MetadataRewriter1_11To1_10(Protocol1_11To1_10 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/packets/InventoryPackets.java index 58860e7c8..02260f1dc 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/packets/InventoryPackets.java @@ -28,7 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import com.viaversion.viaversion.rewriter.ItemRewriter; -public class InventoryPackets extends ItemRewriter { +public class InventoryPackets extends ItemRewriter { public InventoryPackets(Protocol1_11To1_10 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java index f2f7fc34c..55243b220 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java @@ -34,7 +34,6 @@ 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.version.ProtocolVersion; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_12; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -48,13 +47,12 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; -import com.viaversion.viaversion.rewriter.EntityRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; public class Protocol1_12To1_11_1 extends AbstractProtocol { - private final EntityRewriter metadataRewriter = new MetadataRewriter1_12To1_11_1(this); - private final ItemRewriter itemRewriter = new InventoryPackets(this); + private final MetadataRewriter1_12To1_11_1 metadataRewriter = new MetadataRewriter1_12To1_11_1(this); + private final InventoryPackets itemRewriter = new InventoryPackets(this); public Protocol1_12To1_11_1() { super(ClientboundPackets1_9_3.class, ClientboundPackets1_12.class, ServerboundPackets1_9_3.class, ServerboundPackets1_12.class); @@ -192,7 +190,7 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND); // New packet at 0x01 @@ -273,12 +271,12 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol ACHIEVEMENT_TEXT_REWRITER = new ComponentRewriter() { @Override protected void handleTranslate(JsonObject object, String translate) { String text = AchievementTranslationMapping.get(translate); @@ -108,7 +109,7 @@ public class TranslateRewriter { JsonElement translate = obj.get("translate"); if (translate != null) { if (translate.getAsString().startsWith("chat.type.achievement")) { - achievementTextRewriter.processText(obj); + ACHIEVEMENT_TEXT_REWRITER.processText(obj); } } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/metadata/MetadataRewriter1_12To1_11_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/metadata/MetadataRewriter1_12To1_11_1.java index a48dc42d1..b34081db9 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/metadata/MetadataRewriter1_12To1_11_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/metadata/MetadataRewriter1_12To1_11_1.java @@ -23,11 +23,12 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1; +import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.rewriter.EntityRewriter; import java.util.List; -public class MetadataRewriter1_12To1_11_1 extends EntityRewriter { +public class MetadataRewriter1_12To1_11_1 extends EntityRewriter { public MetadataRewriter1_12To1_11_1(Protocol1_12To1_11_1 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java index e651b863d..90a482f02 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java @@ -30,7 +30,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac import com.viaversion.viaversion.rewriter.ItemRewriter; import org.checkerframework.checker.nullness.qual.Nullable; -public class InventoryPackets extends ItemRewriter { +public class InventoryPackets extends ItemRewriter { public InventoryPackets(Protocol1_12To1_11_1 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java index bcc360a79..0c8a40099 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java @@ -28,8 +28,6 @@ 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.ValueTransformer; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.metadata.MetadataRewriter1_13_1To1_13; @@ -45,8 +43,8 @@ import com.viaversion.viaversion.rewriter.TagRewriter; public class Protocol1_13_1To1_13 extends AbstractProtocol { public static final MappingData MAPPINGS = new MappingDataBase("1.13", "1.13.2", true); - private final EntityRewriter entityRewriter = new MetadataRewriter1_13_1To1_13(this); - private final ItemRewriter itemRewriter = new InventoryPackets(this); + private final MetadataRewriter1_13_1To1_13 entityRewriter = new MetadataRewriter1_13_1To1_13(this); + private final InventoryPackets itemRewriter = new InventoryPackets(this); public Protocol1_13_1To1_13() { super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class); @@ -144,8 +142,8 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol(this).register(ClientboundPackets1_13.TAGS, RegistryType.ITEM); + new StatisticsRewriter<>(this).register(ClientboundPackets1_13.STATISTICS); } @Override @@ -162,12 +160,12 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol { +public class MetadataRewriter1_13_1To1_13 extends EntityRewriter { public MetadataRewriter1_13_1To1_13(Protocol1_13_1To1_13 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java index 9ede619c9..81999fd6a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java @@ -28,7 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.RecipeRewri import com.viaversion.viaversion.rewriter.ItemRewriter; import com.viaversion.viaversion.rewriter.RecipeRewriter; -public class InventoryPackets extends ItemRewriter { +public class InventoryPackets extends ItemRewriter { public InventoryPackets(Protocol1_13_1To1_13 protocol) { super(protocol); @@ -77,7 +77,7 @@ public class InventoryPackets extends ItemRewriter { registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM); - RecipeRewriter recipeRewriter = new RecipeRewriter1_13_2(protocol); + RecipeRewriter recipeRewriter = new RecipeRewriter1_13_2<>(protocol); protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() { @Override public void registerMap() { 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 2d6e86606..f52026581 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 @@ -19,11 +19,11 @@ package com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; -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.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; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; @@ -31,8 +31,8 @@ import com.viaversion.viaversion.rewriter.BlockRewriter; public class WorldPackets { - public static void register(Protocol protocol) { - BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION); + public static void register(Protocol1_13_1To1_13 protocol) { + BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION); protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() { @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index ce206b083..5a2c4e874 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -34,8 +34,6 @@ 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.ValueTransformer; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; 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_13; @@ -61,11 +59,9 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockCon import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.TabCompleteTracker; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -import com.viaversion.viaversion.rewriter.ComponentRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.util.ChatColorUtil; import com.viaversion.viaversion.util.GsonUtil; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -78,9 +74,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol SCOREBOARD_TEAM_NAME_REWRITE = new HashMap<>(); private static final Set FORMATTING_CODES = Sets.newHashSet('k', 'l', 'm', 'n', 'o', 'r'); - private final EntityRewriter entityRewriter = new MetadataRewriter1_13To1_12_2(this); - private final ItemRewriter itemRewriter = new InventoryPackets(this); - private final ComponentRewriter componentRewriter = new ComponentRewriter1_13(this); + private final MetadataRewriter1_13To1_12_2 entityRewriter = new MetadataRewriter1_13To1_12_2(this); + private final InventoryPackets itemRewriter = new InventoryPackets(this); + private final ComponentRewriter1_13 componentRewriter = new ComponentRewriter1_13<>(this); static { SCOREBOARD_TEAM_NAME_REWRITE.put('0', 'g'); @@ -629,7 +625,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol(this).registerSound(ClientboundPackets1_12_1.SOUND); registerClientbound(ClientboundPackets1_12_1.TAB_LIST, new PacketRemapper() { @Override @@ -1045,16 +1041,16 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol extends ComponentRewriter { - public ComponentRewriter1_13(Protocol protocol) { + public ComponentRewriter1_13(Protocol protocol) { super(protocol); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/RecipeRewriter1_13_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/RecipeRewriter1_13_2.java index aa2e6ff25..fa1c64ca2 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/RecipeRewriter1_13_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/RecipeRewriter1_13_2.java @@ -19,17 +19,17 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data; import com.viaversion.viaversion.api.minecraft.item.Item; 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.type.Type; -import com.viaversion.viaversion.rewriter.ItemRewriter; import com.viaversion.viaversion.rewriter.RecipeRewriter; /** * For 1.13.2, not 1.13 (1.13 reads recipe type and id in swapped order)! */ -public class RecipeRewriter1_13_2 extends RecipeRewriter { +public class RecipeRewriter1_13_2 extends RecipeRewriter { - public RecipeRewriter1_13_2(Protocol protocol) { + public RecipeRewriter1_13_2(Protocol protocol) { super(protocol); recipeHandlers.put("crafting_shapeless", this::handleCraftingShapeless); recipeHandlers.put("crafting_shaped", this::handleCraftingShaped); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java index 96ddf8173..0fb3a7893 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java @@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.types.Particle; import com.viaversion.viaversion.api.type.types.version.Types1_13; +import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter; @@ -33,7 +34,7 @@ import com.viaversion.viaversion.rewriter.EntityRewriter; import java.util.List; -public class MetadataRewriter1_13To1_12_2 extends EntityRewriter { +public class MetadataRewriter1_13To1_12_2 extends EntityRewriter { public MetadataRewriter1_13To1_12_2(Protocol1_13To1_12_2 protocol) { super(protocol); 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 8ed918bd0..3940cd0f3 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 @@ -49,7 +49,7 @@ import java.util.List; import java.util.Locale; import java.util.Optional; -public class InventoryPackets extends ItemRewriter { +public class InventoryPackets extends ItemRewriter { private static final String NBT_TAG_NAME = "ViaVersion|" + Protocol1_13To1_12_2.class.getSimpleName(); public InventoryPackets(Protocol1_13To1_12_2 protocol) { @@ -176,12 +176,12 @@ public class InventoryPackets extends ItemRewriter { } else if (channel.equals("minecraft:register") || channel.equals("minecraft:unregister")) { String[] channels = new String(wrapper.read(Type.REMAINING_BYTES), StandardCharsets.UTF_8).split("\0"); List rewrittenChannels = new ArrayList<>(); - for (int i = 0; i < channels.length; i++) { - String rewritten = getNewPluginChannelId(channels[i]); + for (String s : channels) { + String rewritten = getNewPluginChannelId(s); if (rewritten != null) { rewrittenChannels.add(rewritten); } else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { - Via.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + channels[i]); + Via.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + s); } } if (!rewrittenChannels.isEmpty()) { @@ -243,12 +243,12 @@ public class InventoryPackets extends ItemRewriter { } else if (channel.equals("REGISTER") || channel.equals("UNREGISTER")) { String[] channels = new String(wrapper.read(Type.REMAINING_BYTES), StandardCharsets.UTF_8).split("\0"); List rewrittenChannels = new ArrayList<>(); - for (int i = 0; i < channels.length; i++) { - String rewritten = getOldPluginChannelId(channels[i]); + for (String s : channels) { + String rewritten = getOldPluginChannelId(s); if (rewritten != null) { rewrittenChannels.add(rewritten); } else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { - Via.getPlatform().getLogger().warning("Ignoring plugin channel in incoming REGISTER: " + channels[i]); + Via.getPlatform().getLogger().warning("Ignoring plugin channel in incoming REGISTER: " + s); } } wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8)); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java index 77e10d197..375df5cdb 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java @@ -22,11 +22,12 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.Protocol1_14_1To1_14; +import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import com.viaversion.viaversion.rewriter.EntityRewriter; import java.util.List; -public class MetadataRewriter1_14_1To1_14 extends EntityRewriter { +public class MetadataRewriter1_14_1To1_14 extends EntityRewriter { public MetadataRewriter1_14_1To1_14(Protocol1_14_1To1_14 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java index e1ab2ebd0..d30f72e6e 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java @@ -22,8 +22,6 @@ 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.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; 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_13_2; @@ -48,8 +46,8 @@ import org.checkerframework.checker.nullness.qual.Nullable; public class Protocol1_14To1_13_2 extends AbstractProtocol { public static final MappingData MAPPINGS = new MappingData(); - private final EntityRewriter metadataRewriter = new MetadataRewriter1_14To1_13_2(this); - private final ItemRewriter itemRewriter = new InventoryPackets(this); + private final MetadataRewriter1_14To1_13_2 metadataRewriter = new MetadataRewriter1_14To1_13_2(this); + private final InventoryPackets itemRewriter = new InventoryPackets(this); public Protocol1_14To1_13_2() { super(ClientboundPackets1_13.class, ClientboundPackets1_14.class, ServerboundPackets1_13.class, ServerboundPackets1_14.class); @@ -64,13 +62,13 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol(this).registerSound(ClientboundPackets1_13.SOUND); + new StatisticsRewriter<>(this).register(ClientboundPackets1_13.STATISTICS); - ComponentRewriter componentRewriter = new ComponentRewriter1_14(this); + ComponentRewriter componentRewriter = new ComponentRewriter1_14<>(this); componentRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE); - CommandRewriter commandRewriter = new CommandRewriter(this) { + CommandRewriter commandRewriter = new CommandRewriter(this) { @Override public @Nullable String handleArgumentType(String argumentType) { if (argumentType.equals("minecraft:nbt")) { @@ -184,12 +182,12 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol extends ComponentRewriter1_13 { - public ComponentRewriter1_14(Protocol protocol) { + public ComponentRewriter1_14(Protocol protocol) { super(protocol); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/data/RecipeRewriter1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/data/RecipeRewriter1_14.java index 38afeae50..08ba61c49 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/data/RecipeRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/data/RecipeRewriter1_14.java @@ -19,14 +19,14 @@ package com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data; import com.viaversion.viaversion.api.minecraft.item.Item; 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.type.Type; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.RecipeRewriter1_13_2; -import com.viaversion.viaversion.rewriter.ItemRewriter; -public class RecipeRewriter1_14 extends RecipeRewriter1_13_2 { +public class RecipeRewriter1_14 extends RecipeRewriter1_13_2 { - public RecipeRewriter1_14(Protocol protocol) { + public RecipeRewriter1_14(Protocol protocol) { super(protocol); recipeHandlers.put("stonecutting", this::handleStonecutting); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java index 4fb951a85..81f78386b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java @@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.Particle; import com.viaversion.viaversion.api.type.types.version.Types1_14; +import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14; @@ -37,7 +38,7 @@ import com.viaversion.viaversion.rewriter.EntityRewriter; import java.util.List; -public class MetadataRewriter1_14To1_13_2 extends EntityRewriter { +public class MetadataRewriter1_14To1_13_2 extends EntityRewriter { public MetadataRewriter1_14To1_13_2(Protocol1_14To1_13_2 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java index 71f17d572..53e34a1c6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java @@ -45,10 +45,10 @@ import com.viaversion.viaversion.rewriter.RecipeRewriter; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; -public class InventoryPackets extends ItemRewriter { +public class InventoryPackets extends ItemRewriter { private static final String NBT_TAG_NAME = "ViaVersion|" + Protocol1_14To1_13_2.class.getSimpleName(); private static final Set REMOVED_RECIPE_TYPES = Sets.newHashSet("crafting_special_banneraddpattern", "crafting_special_repairitem"); - private static final ComponentRewriter COMPONENT_REWRITER = new ComponentRewriter() { + private static final ComponentRewriter COMPONENT_REWRITER = new ComponentRewriter() { @Override protected void handleTranslate(JsonObject object, String translate) { super.handleTranslate(object, translate); @@ -202,7 +202,7 @@ public class InventoryPackets extends ItemRewriter { registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM); - RecipeRewriter recipeRewriter = new RecipeRewriter1_13_2(protocol); + RecipeRewriter recipeRewriter = new RecipeRewriter1_13_2<>(protocol); protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() { @Override public void registerMap() { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java index 106246c08..33aeb1fbc 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java @@ -55,7 +55,7 @@ public class WorldPackets { } public static void register(Protocol1_14To1_13_2 protocol) { - BlockRewriter blockRewriter = new BlockRewriter(protocol, null); + BlockRewriter blockRewriter = new BlockRewriter<>(protocol, null); protocol.registerClientbound(ClientboundPackets1_13.BLOCK_BREAK_ANIMATION, new PacketRemapper() { @Override 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 c1b26c7db..b0bf594db 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 @@ -22,8 +22,6 @@ 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.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; 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; @@ -40,9 +38,9 @@ import com.viaversion.viaversion.rewriter.TagRewriter; public class Protocol1_15To1_14_4 extends AbstractProtocol { public static final MappingData MAPPINGS = new MappingData(); - private final EntityRewriter metadataRewriter = new MetadataRewriter1_15To1_14_4(this); - private final ItemRewriter itemRewriter = new InventoryPackets(this); - private TagRewriter tagRewriter; + private final MetadataRewriter1_15To1_14_4 metadataRewriter = new MetadataRewriter1_15To1_14_4(this); + private final InventoryPackets itemRewriter = new InventoryPackets(this); + private TagRewriter tagRewriter; public Protocol1_15To1_14_4() { super(ClientboundPackets1_14.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class); @@ -56,11 +54,11 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound(ClientboundPackets1_14.ENTITY_SOUND); // Entity Sound Effect (added somewhere in 1.14) soundRewriter.registerSound(ClientboundPackets1_14.SOUND); - new StatisticsRewriter(this).register(ClientboundPackets1_14.STATISTICS); + new StatisticsRewriter<>(this).register(ClientboundPackets1_14.STATISTICS); registerServerbound(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() { @Override @@ -69,7 +67,7 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol(this); tagRewriter.register(ClientboundPackets1_14.TAGS, RegistryType.ENTITY); } @@ -94,12 +92,12 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol { +public class MetadataRewriter1_15To1_14_4 extends EntityRewriter { public MetadataRewriter1_15To1_14_4(Protocol1_15To1_14_4 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java index 216420d8e..6fbbf872f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java @@ -24,7 +24,7 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.RecipeRewri import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4; import com.viaversion.viaversion.rewriter.ItemRewriter; -public class InventoryPackets extends ItemRewriter { +public class InventoryPackets extends ItemRewriter { public InventoryPackets(Protocol1_15To1_14_4 protocol) { super(protocol); @@ -39,7 +39,7 @@ public class InventoryPackets extends ItemRewriter { registerEntityEquipment(ClientboundPackets1_14.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM); registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); - new RecipeRewriter1_14(protocol).registerDefaultHandler(ClientboundPackets1_14.DECLARE_RECIPES); + new RecipeRewriter1_14<>(protocol).registerDefaultHandler(ClientboundPackets1_14.DECLARE_RECIPES); registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); 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 e9956a74c..bb90ee498 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 @@ -32,7 +32,7 @@ import com.viaversion.viaversion.rewriter.BlockRewriter; public class WorldPackets { public static void register(Protocol1_15To1_14_4 protocol) { - BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14); + BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); blockRewriter.registerBlockAction(ClientboundPackets1_14.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_14.BLOCK_CHANGE); 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 412b147d0..3b5f11d70 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 @@ -18,11 +18,10 @@ package com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1; 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.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; 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; @@ -32,7 +31,6 @@ import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets.Invent import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets.WorldPackets; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16; -import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -40,9 +38,9 @@ import com.viaversion.viaversion.rewriter.TagRewriter; public class Protocol1_16_2To1_16_1 extends AbstractProtocol { public static final MappingData MAPPINGS = new MappingData(); - private final EntityRewriter metadataRewriter = new MetadataRewriter1_16_2To1_16_1(this); - private final ItemRewriter itemRewriter = new InventoryPackets(this); - private TagRewriter tagRewriter; + private final MetadataRewriter1_16_2To1_16_1 metadataRewriter = new MetadataRewriter1_16_2To1_16_1(this); + private final InventoryPackets itemRewriter = new InventoryPackets(this); + private TagRewriter tagRewriter; public Protocol1_16_2To1_16_1() { super(ClientboundPackets1_16.class, ClientboundPackets1_16_2.class, ServerboundPackets1_16.class, ServerboundPackets1_16_2.class); @@ -56,12 +54,12 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol(this); tagRewriter.register(ClientboundPackets1_16.TAGS, RegistryType.ENTITY); - new StatisticsRewriter(this).register(ClientboundPackets1_16.STATISTICS); + new StatisticsRewriter<>(this).register(ClientboundPackets1_16.STATISTICS); - SoundRewriter soundRewriter = new SoundRewriter(this); + SoundRewriter soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound(ClientboundPackets1_16.SOUND); soundRewriter.registerSound(ClientboundPackets1_16.ENTITY_SOUND); @@ -125,12 +123,12 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol { +public class MetadataRewriter1_16_2To1_16_1 extends EntityRewriter { public MetadataRewriter1_16_2To1_16_1(Protocol1_16_2To1_16_1 protocol) { super(protocol); 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 f1c49ede1..342577fd7 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 @@ -25,7 +25,7 @@ import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPacke import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16; import com.viaversion.viaversion.rewriter.ItemRewriter; -public class InventoryPackets extends ItemRewriter { +public class InventoryPackets extends ItemRewriter { public InventoryPackets(Protocol1_16_2To1_16_1 protocol) { super(protocol); @@ -58,7 +58,7 @@ public class InventoryPackets extends ItemRewriter { } }); - new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_16.DECLARE_RECIPES); + new RecipeRewriter1_16<>(protocol).registerDefaultHandler(ClientboundPackets1_16.DECLARE_RECIPES); registerClickWindow(ServerboundPackets1_16_2.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION, 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 8bd472de6..120744d8d 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 @@ -21,7 +21,6 @@ import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_16_2; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; -import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; @@ -31,7 +30,6 @@ import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_1 import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type; import com.viaversion.viaversion.rewriter.BlockRewriter; - import java.util.ArrayList; import java.util.List; @@ -39,8 +37,8 @@ public class WorldPackets { private static final BlockChangeRecord[] EMPTY_RECORDS = new BlockChangeRecord[0]; - public static void register(Protocol protocol) { - BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14); + public static void register(Protocol1_16_2To1_16_1 protocol) { + BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); blockRewriter.registerBlockAction(ClientboundPackets1_16.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_16.BLOCK_CHANGE); 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 bcc8346bb..715d01613 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 @@ -28,8 +28,6 @@ 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.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; 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; @@ -43,12 +41,10 @@ import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.EntityPa import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.InventoryPackets; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.WorldPackets; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16; -import com.viaversion.viaversion.rewriter.ComponentRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.GsonUtil; - import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -58,10 +54,10 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol tagRewriter; public Protocol1_16To1_15_2() { super(ClientboundPackets1_15.class, ClientboundPackets1_16.class, ServerboundPackets1_14.class, ServerboundPackets1_16.class); @@ -75,10 +71,10 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol(this); tagRewriter.register(ClientboundPackets1_15.TAGS, RegistryType.ENTITY); - new StatisticsRewriter(this).register(ClientboundPackets1_15.STATISTICS); + new StatisticsRewriter<>(this).register(ClientboundPackets1_15.STATISTICS); // Login Success registerClientbound(State.LOGIN, 0x02, 0x02, new PacketRemapper() { @@ -148,7 +144,7 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound(ClientboundPackets1_15.SOUND); soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND); @@ -293,16 +289,16 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol extends RecipeRewriter1_14 { - public RecipeRewriter1_16(Protocol protocol) { + public RecipeRewriter1_16(Protocol protocol) { super(protocol); recipeHandlers.put("smithing", this::handleSmithing); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/data/TranslationMappings.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/data/TranslationMappings.java index 3101f5335..d5e61748f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/data/TranslationMappings.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/data/TranslationMappings.java @@ -20,16 +20,16 @@ package com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; -import com.viaversion.viaversion.api.protocol.Protocol; +import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; +import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2; import com.viaversion.viaversion.rewriter.ComponentRewriter; - import java.util.HashMap; import java.util.Map; -public class TranslationMappings extends ComponentRewriter { +public class TranslationMappings extends ComponentRewriter { private final Map mappings = new HashMap<>(); - public TranslationMappings(Protocol protocol) { + public TranslationMappings(Protocol1_16To1_15_2 protocol) { super(protocol); mappings.put("attribute.name.generic.armorToughness", "attribute.name.generic.armor_toughness"); mappings.put("attribute.name.generic.attackDamage", "attribute.name.generic.attack_damage"); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/metadata/MetadataRewriter1_16To1_15_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/metadata/MetadataRewriter1_16To1_15_2.java index dc579617d..62336d3fb 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/metadata/MetadataRewriter1_16To1_15_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/metadata/MetadataRewriter1_16To1_15_2.java @@ -25,12 +25,13 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.types.Particle; import com.viaversion.viaversion.api.type.types.version.Types1_16; +import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2; import com.viaversion.viaversion.rewriter.EntityRewriter; import java.util.List; -public class MetadataRewriter1_16To1_15_2 extends EntityRewriter { +public class MetadataRewriter1_16To1_15_2 extends EntityRewriter { public MetadataRewriter1_16To1_15_2(Protocol1_16To1_15_2 protocol) { super(protocol); 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 3476d2407..91c41e9c6 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 @@ -40,7 +40,7 @@ import com.viaversion.viaversion.rewriter.ItemRewriter; import java.util.UUID; -public class InventoryPackets extends ItemRewriter { +public class InventoryPackets extends ItemRewriter { public InventoryPackets(Protocol1_16To1_15_2 protocol) { super(protocol); @@ -126,7 +126,7 @@ public class InventoryPackets extends ItemRewriter { } }); - new RecipeRewriter1_14(protocol).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES); + new RecipeRewriter1_14<>(protocol).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES); registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, 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 9c9ecb11a..81b8b30a0 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 @@ -42,7 +42,7 @@ import java.util.UUID; public class WorldPackets { public static void register(Protocol1_16To1_15_2 protocol) { - BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14); + BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); blockRewriter.registerBlockAction(ClientboundPackets1_15.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_15.BLOCK_CHANGE); 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 50fa21deb..fee7c3d24 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 @@ -26,8 +26,6 @@ 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.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; 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; @@ -46,9 +44,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol tagRewriter = new TagRewriter<>(this); public Protocol1_17To1_16_4() { super(ClientboundPackets1_16_2.class, ClientboundPackets1_17.class, ServerboundPackets1_16_2.class, ServerboundPackets1_17.class); @@ -91,9 +89,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol(this).register(ClientboundPackets1_16_2.STATISTICS); - SoundRewriter soundRewriter = new SoundRewriter(this); + SoundRewriter soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND); soundRewriter.registerSound(ClientboundPackets1_16_2.ENTITY_SOUND); @@ -246,12 +244,12 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol { +public final class EntityPackets extends EntityRewriter { public EntityPackets(Protocol1_17To1_16_4 protocol) { super(protocol); 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 f28ed79ac..a6de315e5 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 @@ -30,7 +30,7 @@ import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPacke import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.storage.InventoryAcknowledgements; import com.viaversion.viaversion.rewriter.ItemRewriter; -public final class InventoryPackets extends ItemRewriter { +public final class InventoryPackets extends ItemRewriter { public InventoryPackets(Protocol1_17To1_16_4 protocol) { super(protocol); @@ -46,7 +46,7 @@ public final class InventoryPackets extends ItemRewriter { registerEntityEquipmentArray(ClientboundPackets1_16_2.ENTITY_EQUIPMENT); registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE); - new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_16_2.DECLARE_RECIPES); + new RecipeRewriter1_16<>(protocol).registerDefaultHandler(ClientboundPackets1_16_2.DECLARE_RECIPES); registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); 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 af245b6ac..7a6d0cb7d 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 @@ -39,7 +39,7 @@ import java.util.List; public final class WorldPackets { public static void register(Protocol1_17To1_16_4 protocol) { - BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14); + BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); blockRewriter.registerBlockAction(ClientboundPackets1_16_2.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_16_2.BLOCK_CHANGE); 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 4bf3ee814..1bc156d53 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 @@ -37,7 +37,7 @@ public final class Protocol1_18_2To1_18 extends AbstractProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:fall_damage_resetting"); tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS); 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 bd244a038..c1aec5d3f 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 @@ -33,8 +33,6 @@ import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets.EntityPa import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets.InventoryPackets; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets.WorldPackets; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.storage.ChunkLightStorage; -import com.viaversion.viaversion.rewriter.EntityRewriter; -import com.viaversion.viaversion.rewriter.ItemRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -42,8 +40,8 @@ import com.viaversion.viaversion.rewriter.TagRewriter; public final class Protocol1_18To1_17_1 extends AbstractProtocol { public static final MappingData MAPPINGS = new MappingData(); - private final EntityRewriter entityRewriter = new EntityPackets(this); - private final ItemRewriter itemRewriter = new InventoryPackets(this); + private final EntityPackets entityRewriter = new EntityPackets(this); + private final InventoryPackets itemRewriter = new InventoryPackets(this); public Protocol1_18To1_17_1() { super(ClientboundPackets1_17_1.class, ClientboundPackets1_18.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class); @@ -55,11 +53,11 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound(ClientboundPackets1_17_1.SOUND); soundRewriter.registerSound(ClientboundPackets1_17_1.ENTITY_SOUND); - final TagRewriter tagRewriter = new TagRewriter(this); + final TagRewriter tagRewriter = new TagRewriter<>(this); tagRewriter.registerGeneric(ClientboundPackets1_17_1.TAGS); tagRewriter.addEmptyTags(RegistryType.BLOCK, "minecraft:lava_pool_stone_cannot_replace", "minecraft:big_dripleaf_placeable", "minecraft:wolves_spawnable_on", "minecraft:rabbits_spawnable_on", "minecraft:polar_bears_spawnable_on_in_frozen_ocean", "minecraft:parrots_spawnable_on", @@ -67,7 +65,7 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol(this).register(ClientboundPackets1_17_1.STATISTICS); registerServerbound(ServerboundPackets1_17.CLIENT_SETTINGS, new PacketRemapper() { @Override @@ -108,12 +106,12 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol getEntityRewriter() { + public EntityPackets getEntityRewriter() { return entityRewriter; } @Override - public ItemRewriter getItemRewriter() { + public InventoryPackets getItemRewriter() { return itemRewriter; } } 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 7eb88f1b4..ed07e7f6e 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 @@ -30,7 +30,7 @@ import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.Protocol1_18To1_ import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.storage.ChunkLightStorage; import com.viaversion.viaversion.rewriter.EntityRewriter; -public final class EntityPackets extends EntityRewriter { +public final class EntityPackets extends EntityRewriter { public EntityPackets(final Protocol1_18To1_17_1 protocol) { super(protocol); 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 a7f0dd812..876d83237 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 @@ -26,7 +26,7 @@ import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPacke import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.Protocol1_18To1_17_1; import com.viaversion.viaversion.rewriter.ItemRewriter; -public final class InventoryPackets extends ItemRewriter { +public final class InventoryPackets extends ItemRewriter { public InventoryPackets(Protocol1_18To1_17_1 protocol) { super(protocol); @@ -97,7 +97,7 @@ public final class InventoryPackets extends ItemRewriter { } }); - new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_17_1.DECLARE_RECIPES); + new RecipeRewriter1_16<>(protocol).registerDefaultHandler(ClientboundPackets1_17_1.DECLARE_RECIPES); registerClickWindow1_17_1(ServerboundPackets1_17.CLICK_WINDOW); registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); 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 66b7158e8..f915fd746 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 @@ -28,8 +28,6 @@ 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.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.BitSetType; import com.viaversion.viaversion.api.type.types.ByteArrayType; @@ -48,7 +46,6 @@ import com.viaversion.viaversion.rewriter.CommandRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; - import java.util.UUID; public final class Protocol1_19_3To1_19_1 extends AbstractProtocol { @@ -68,7 +65,7 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol tagRewriter = new TagRewriter<>(this); // Flint and steel was hardcoded before 1.19.3 to ignite a creeper; has been moved to a tag - adding this ensures offhand doesn't trigger as well tagRewriter.addTagRaw(RegistryType.ITEM, "minecraft:creeper_igniters", 733); // 733 = flint_and_steel 1.19.3 @@ -81,7 +78,7 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol soundRewriter = new SoundRewriter<>(this); registerClientbound(ClientboundPackets1_19_1.ENTITY_SOUND, new PacketRemapper() { @Override public void registerMap() { @@ -117,9 +114,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol(this).register(ClientboundPackets1_19_1.STATISTICS); - final CommandRewriter commandRewriter = new CommandRewriter(this) { + final CommandRewriter commandRewriter = new CommandRewriter(this) { @Override public void handleArgument(final PacketWrapper wrapper, final String argumentType) throws Exception { switch (argumentType) { @@ -248,7 +245,7 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol { // Remove signature - final byte[] signature = wrapper.read(OPTIONAL_MESSAGE_SIGNATURE_BYTES_TYPE); + wrapper.read(OPTIONAL_MESSAGE_SIGNATURE_BYTES_TYPE); // Signature wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, EMPTY_BYTES); wrapper.write(Type.BOOLEAN, false); // No signed preview @@ -315,12 +312,12 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol extends RecipeRewriter1_16 { - public RecipeRewriter1_19_3(final Protocol protocol) { + public RecipeRewriter1_19_3(final Protocol protocol) { super(protocol); recipeHandlers.put("crafting_special_armordye", this::handleSimpleRecipe); recipeHandlers.put("crafting_special_bookcloning", this::handleSimpleRecipe); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java index 30ccc0e4e..3fa2b41b6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java @@ -34,7 +34,7 @@ import com.viaversion.viaversion.rewriter.EntityRewriter; import java.util.BitSet; import java.util.UUID; -public final class EntityPackets extends EntityRewriter { +public final class EntityPackets extends EntityRewriter { private static final BitSetType PROFILE_ACTIONS_ENUM_TYPE = new BitSetType(6); 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 368477cd7..90ad0c53e 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 @@ -28,7 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPac import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.rewriter.ItemRewriter; -public final class InventoryPackets extends ItemRewriter { +public final class InventoryPackets extends ItemRewriter { private static final int MISC_CRAFTING_BOOK_CATEGORY = 0; @@ -38,7 +38,7 @@ public final class InventoryPackets extends ItemRewriter @Override public void registerPackets() { - final BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14); + final BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); blockRewriter.registerBlockAction(ClientboundPackets1_19_1.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_19_1.BLOCK_CHANGE); blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_19_1.MULTI_BLOCK_CHANGE); @@ -57,7 +57,7 @@ public final class InventoryPackets extends ItemRewriter registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_1.WINDOW_PROPERTY); registerSpawnParticle1_19(ClientboundPackets1_19_1.SPAWN_PARTICLE); - final RecipeRewriter1_16 recipeRewriter = new RecipeRewriter1_16(protocol); + final RecipeRewriter1_16 recipeRewriter = new RecipeRewriter1_16<>(protocol); protocol.registerClientbound(ClientboundPackets1_19_1.DECLARE_RECIPES, new PacketRemapper() { @Override public void registerMap() { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/Protocol1_19_4To1_19_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/Protocol1_19_4To1_19_3.java index f83ab3815..76dfd242b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/Protocol1_19_4To1_19_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/Protocol1_19_4To1_19_3.java @@ -41,7 +41,7 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol commandRewriter = new CommandRewriter(this) { @Override public void handleArgument(final PacketWrapper wrapper, final String argumentType) throws Exception { if (argumentType.equals("minecraft:time")) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/packets/EntityPackets.java index 66e9397fc..3a8dcb543 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/packets/EntityPackets.java @@ -31,7 +31,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPac import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.Protocol1_19_4To1_19_3; import com.viaversion.viaversion.rewriter.EntityRewriter; -public final class EntityPackets extends EntityRewriter { +public final class EntityPackets extends EntityRewriter { public EntityPackets(final Protocol1_19_4To1_19_3 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/rewriter/CommandRewriter1_19_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/rewriter/CommandRewriter1_19_3.java index 13a63e5f0..1505e8a18 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/rewriter/CommandRewriter1_19_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/rewriter/CommandRewriter1_19_3.java @@ -18,12 +18,13 @@ package com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.rewriter; import com.viaversion.viaversion.api.protocol.Protocol; +import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.rewriter.CommandRewriter; -public class CommandRewriter1_19_3 extends CommandRewriter { +public class CommandRewriter1_19_3 extends CommandRewriter { - public CommandRewriter1_19_3(Protocol protocol) { + public CommandRewriter1_19_3(Protocol protocol) { super(protocol); this.parserHandlers.put("minecraft:time", wrapper -> wrapper.passthrough(Type.INT)); // Minimum } 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 28aa247a5..590c6d160 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 @@ -26,8 +26,6 @@ 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.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; 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; @@ -51,7 +49,6 @@ import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.CipherUtil; - import java.util.concurrent.ThreadLocalRandom; public final class Protocol1_19To1_18_2 extends AbstractProtocol { @@ -70,7 +67,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS); entityRewriter.register(); @@ -79,7 +76,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol soundRewriter = new SoundRewriter<>(this); registerClientbound(ClientboundPackets1_18.SOUND, new PacketRemapper() { @Override public void registerMap() { @@ -120,7 +117,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol(this).register(ClientboundPackets1_18.STATISTICS); final PacketHandler titleHandler = wrapper -> { final JsonElement component = wrapper.read(Type.COMPONENT); @@ -143,7 +140,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol commandRewriter = new CommandRewriter<>(this); registerClientbound(ClientboundPackets1_18.DECLARE_COMMANDS, new PacketRemapper() { @Override public void registerMap() { @@ -320,12 +317,12 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol { +public final class EntityPackets extends EntityRewriter { private static final String CHAT_REGISTRY_SNBT = "{\n" + " \"minecraft:chat_type\": {\n" + 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 a87b33e02..a8c4740b6 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 @@ -28,7 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPacke import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.provider.AckSequenceProvider; import com.viaversion.viaversion.rewriter.ItemRewriter; -public final class InventoryPackets extends ItemRewriter { +public final class InventoryPackets extends ItemRewriter { public InventoryPackets(Protocol1_19To1_18_2 protocol) { super(protocol); @@ -122,7 +122,7 @@ public final class InventoryPackets extends ItemRewriter { } }); - new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_18.DECLARE_RECIPES); + new RecipeRewriter1_16<>(protocol).registerDefaultHandler(ClientboundPackets1_18.DECLARE_RECIPES); } private PacketHandler sequenceHandler() { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java index 62dae9b5f..6321b4a0d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java @@ -35,7 +35,7 @@ import com.viaversion.viaversion.util.MathUtil; public final class WorldPackets { public static void register(final Protocol1_19To1_18_2 protocol) { - final BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14); + final BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); blockRewriter.registerBlockAction(ClientboundPackets1_18.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_18.BLOCK_CHANGE); blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_18.MULTI_BLOCK_CHANGE); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/metadata/MetadataRewriter1_9To1_8.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/metadata/MetadataRewriter1_9To1_8.java index ba8d9c348..aeb2ceb9e 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/metadata/MetadataRewriter1_9To1_8.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/metadata/MetadataRewriter1_9To1_8.java @@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_8; +import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ItemRewriter; import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; import com.viaversion.viaversion.rewriter.EntityRewriter; @@ -33,7 +34,7 @@ import com.viaversion.viaversion.rewriter.EntityRewriter; import java.util.List; import java.util.UUID; -public class MetadataRewriter1_9To1_8 extends EntityRewriter { +public class MetadataRewriter1_9To1_8 extends EntityRewriter { public MetadataRewriter1_9To1_8(Protocol1_9To1_8 protocol) { super(protocol); @@ -99,8 +100,6 @@ public class MetadataRewriter1_9To1_8 extends EntityRewriter { } break; case Float: - metadata.setValue(value); - break; case String: metadata.setValue(value); break; diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java index 12b29bc60..38cd08811 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java @@ -35,16 +35,16 @@ import com.viaversion.viaversion.util.MathUtil; import java.util.List; -public class BlockRewriter { - private final Protocol protocol; +public class BlockRewriter { + private final Protocol protocol; private final Type positionType; - public BlockRewriter(Protocol protocol, Type positionType) { + public BlockRewriter(Protocol protocol, Type positionType) { this.protocol = protocol; this.positionType = positionType; } - public void registerBlockAction(ClientboundPacketType packetType) { + public void registerBlockAction(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -67,7 +67,7 @@ public class BlockRewriter { }); } - public void registerBlockChange(ClientboundPacketType packetType) { + public void registerBlockChange(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -78,7 +78,7 @@ public class BlockRewriter { }); } - public void registerMultiBlockChange(ClientboundPacketType packetType) { + public void registerMultiBlockChange(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -93,7 +93,7 @@ public class BlockRewriter { }); } - public void registerVarLongMultiBlockChange(ClientboundPacketType packetType) { + public void registerVarLongMultiBlockChange(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -108,12 +108,12 @@ public class BlockRewriter { }); } - public void registerAcknowledgePlayerDigging(ClientboundPacketType packetType) { + public void registerAcknowledgePlayerDigging(C packetType) { // Same exact handler registerBlockChange(packetType); } - public void registerEffect(ClientboundPacketType packetType, int playRecordId, int blockBreakId) { + public void registerEffect(C packetType, int playRecordId, int blockBreakId) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -133,7 +133,7 @@ public class BlockRewriter { }); } - public void registerChunkData1_19(ClientboundPacketType packetType, ChunkTypeSupplier chunkTypeSupplier) { + public void registerChunkData1_19(C packetType, ChunkTypeSupplier chunkTypeSupplier) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -166,7 +166,7 @@ public class BlockRewriter { }); } - public void registerBlockEntityData(ClientboundPacketType packetType) { + public void registerBlockEntityData(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { 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 ddeb31092..0402e3311 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/CommandRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/CommandRewriter.java @@ -29,11 +29,11 @@ import java.util.Map; /** * Abstract rewriter for the declare commands packet to handle argument type name and content changes. */ -public class CommandRewriter { - protected final Protocol protocol; +public class CommandRewriter { + protected final Protocol protocol; protected final Map parserHandlers = new HashMap<>(); - public CommandRewriter(Protocol protocol) { + public CommandRewriter(Protocol protocol) { this.protocol = protocol; // Register default parsers @@ -57,30 +57,16 @@ public class CommandRewriter { if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.LONG); // Min Value if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.LONG); // Max Value }); - this.parserHandlers.put("brigadier:string", wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Flags - }); - this.parserHandlers.put("minecraft:entity", wrapper -> { - wrapper.passthrough(Type.BYTE); // Flags - }); - this.parserHandlers.put("minecraft:score_holder", wrapper -> { - wrapper.passthrough(Type.BYTE); // Flags - }); - this.parserHandlers.put("minecraft:resource", wrapper -> { - wrapper.passthrough(Type.STRING); // Resource location - }); - this.parserHandlers.put("minecraft:resource_or_tag", wrapper -> { - wrapper.passthrough(Type.STRING); // Resource location/tag - }); - this.parserHandlers.put("minecraft:resource_or_tag_key", wrapper -> { - wrapper.passthrough(Type.STRING); // Resource location - }); - this.parserHandlers.put("minecraft:resource_key", wrapper -> { - wrapper.passthrough(Type.STRING); // Resource location/tag - }); + this.parserHandlers.put("brigadier:string", wrapper -> wrapper.passthrough(Type.VAR_INT)); // Flags + this.parserHandlers.put("minecraft:entity", wrapper -> wrapper.passthrough(Type.BYTE)); // Flags + this.parserHandlers.put("minecraft:score_holder", wrapper -> wrapper.passthrough(Type.BYTE)); // Flags + this.parserHandlers.put("minecraft:resource", wrapper -> wrapper.passthrough(Type.STRING)); // Resource location + this.parserHandlers.put("minecraft:resource_or_tag", wrapper -> wrapper.passthrough(Type.STRING)); // Resource location/tag + this.parserHandlers.put("minecraft:resource_or_tag_key", wrapper -> wrapper.passthrough(Type.STRING)); // Resource location + this.parserHandlers.put("minecraft:resource_key", wrapper -> wrapper.passthrough(Type.STRING)); // Resource location/tag } - public void registerDeclareCommands(ClientboundPacketType packetType) { + public void registerDeclareCommands(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -120,7 +106,7 @@ public class CommandRewriter { }); } - public void registerDeclareCommands1_19(ClientboundPacketType packetType) { + public void registerDeclareCommands1_19(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { 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 5c78aada5..4e8a6d15e 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/ComponentRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/ComponentRewriter.java @@ -32,10 +32,10 @@ import com.viaversion.viaversion.api.type.Type; * Handles json chat components, containing methods to override certain parts of the handling. * Also contains methods to register a few of the packets using components. */ -public class ComponentRewriter { - protected final Protocol protocol; +public class ComponentRewriter { + protected final Protocol protocol; - public ComponentRewriter(Protocol protocol) { + public ComponentRewriter(Protocol protocol) { this.protocol = protocol; } @@ -52,7 +52,7 @@ public class ComponentRewriter { * * @param packetType clientbound packet type */ - public void registerComponentPacket(ClientboundPacketType packetType) { + public void registerComponentPacket(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -62,11 +62,11 @@ public class ComponentRewriter { } @Deprecated/*(forRemoval = true)**/ - public void registerChatMessage(ClientboundPacketType packetType) { + public void registerChatMessage(C packetType) { registerComponentPacket(packetType); } - public void registerBossBar(ClientboundPacketType packetType) { + public void registerBossBar(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -85,7 +85,7 @@ public class ComponentRewriter { /** * Handles sub 1.17 combat event components. */ - public void registerCombatEvent(ClientboundPacketType packetType) { + public void registerCombatEvent(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -103,7 +103,7 @@ public class ComponentRewriter { /** * Handles sub 1.17 title components. */ - public void registerTitle(ClientboundPacketType packetType) { + public void registerTitle(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -198,7 +198,7 @@ public class ComponentRewriter { } } - public T getProtocol() { + public > T getProtocol() { return (T) protocol; } } 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 9c58a8337..6c9bde78c 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java @@ -54,7 +54,8 @@ import java.util.Map; import java.util.logging.Logger; import java.util.stream.Collectors; -public abstract class EntityRewriter extends RewriterBase implements com.viaversion.viaversion.api.rewriter.EntityRewriter { +public abstract class EntityRewriter> + extends RewriterBase implements com.viaversion.viaversion.api.rewriter.EntityRewriter { private static final Metadata[] EMPTY_ARRAY = new Metadata[0]; protected final List metadataFilters = new ArrayList<>(); protected final boolean trackMappedType; @@ -245,7 +246,7 @@ public abstract class EntityRewriter extends RewriterBase }); } - public void registerTracker(ClientboundPacketType packetType) { + public void registerTracker(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -257,7 +258,7 @@ public abstract class EntityRewriter extends RewriterBase }); } - public void registerTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType) { + public void registerTrackerWithData(C packetType, EntityType fallingBlockType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -282,7 +283,7 @@ public abstract class EntityRewriter extends RewriterBase }); } - public void registerTrackerWithData1_19(ClientboundPacketType packetType, EntityType fallingBlockType) { + public void registerTrackerWithData1_19(C packetType, EntityType fallingBlockType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -315,7 +316,7 @@ public abstract class EntityRewriter extends RewriterBase * @param entityType entity type * @param intType int type of the entity id */ - public void registerTracker(ClientboundPacketType packetType, EntityType entityType, Type intType) { + public void registerTracker(C packetType, EntityType entityType, Type intType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -333,7 +334,7 @@ public abstract class EntityRewriter extends RewriterBase * @param packetType packet type * @param entityType entity type */ - public void registerTracker(ClientboundPacketType packetType, EntityType entityType) { + public void registerTracker(C packetType, EntityType entityType) { registerTracker(packetType, entityType, Type.VAR_INT); } @@ -342,7 +343,7 @@ public abstract class EntityRewriter extends RewriterBase * * @param packetType remove entities packet type */ - public void registerRemoveEntities(ClientboundPacketType packetType) { + public void registerRemoveEntities(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -362,7 +363,7 @@ public abstract class EntityRewriter extends RewriterBase * * @param packetType remove entities packet type */ - public void registerRemoveEntity(ClientboundPacketType packetType) { + public void registerRemoveEntity(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -374,7 +375,7 @@ public abstract class EntityRewriter extends RewriterBase }); } - public void registerMetadataRewriter(ClientboundPacketType packetType, @Nullable Type> oldMetaType, Type> newMetaType) { + public void registerMetadataRewriter(C packetType, @Nullable Type> oldMetaType, Type> newMetaType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -393,7 +394,7 @@ public abstract class EntityRewriter extends RewriterBase }); } - public void registerMetadataRewriter(ClientboundPacketType packetType, Type> metaType) { + public void registerMetadataRewriter(C packetType, Type> metaType) { registerMetadataRewriter(packetType, null, metaType); } 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 d459e205b..5ff5e92fd 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java @@ -29,14 +29,15 @@ import com.viaversion.viaversion.api.rewriter.RewriterBase; import com.viaversion.viaversion.api.type.Type; import org.checkerframework.checker.nullness.qual.Nullable; -public abstract class ItemRewriter extends RewriterBase implements com.viaversion.viaversion.api.rewriter.ItemRewriter { +public abstract class ItemRewriter> extends RewriterBase implements com.viaversion.viaversion.api.rewriter.ItemRewriter { protected ItemRewriter(T protocol) { super(protocol); } // These two methods always return the same item instance *for now* - // It is made this way so it's easy to handle new instance creation/implementation changes + // It is made this way, so it's easy to handle new instance creation/implementation changes @Override public @Nullable Item handleItemToClient(@Nullable Item item) { if (item == null) return null; @@ -55,7 +56,7 @@ public abstract class ItemRewriter extends RewriterBase i return item; } - public void registerWindowItems(ClientboundPacketType packetType, Type type) { + public void registerWindowItems(C packetType, Type type) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -66,7 +67,7 @@ public abstract class ItemRewriter extends RewriterBase i }); } - public void registerWindowItems1_17_1(ClientboundPacketType packetType) { + public void registerWindowItems1_17_1(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -84,7 +85,7 @@ public abstract class ItemRewriter extends RewriterBase i }); } - public void registerSetSlot(ClientboundPacketType packetType, Type type) { + public void registerSetSlot(C packetType, Type type) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -96,7 +97,7 @@ public abstract class ItemRewriter extends RewriterBase i }); } - public void registerSetSlot1_17_1(ClientboundPacketType packetType) { + public void registerSetSlot1_17_1(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -110,7 +111,7 @@ public abstract class ItemRewriter extends RewriterBase i } // Sub 1.16 - public void registerEntityEquipment(ClientboundPacketType packetType, Type type) { + public void registerEntityEquipment(C packetType, Type type) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -124,7 +125,7 @@ public abstract class ItemRewriter extends RewriterBase i } // 1.16+ - public void registerEntityEquipmentArray(ClientboundPacketType packetType) { + public void registerEntityEquipmentArray(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -142,7 +143,7 @@ public abstract class ItemRewriter extends RewriterBase i }); } - public void registerCreativeInvAction(ServerboundPacketType packetType, Type type) { + public void registerCreativeInvAction(S packetType, Type type) { protocol.registerServerbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -154,7 +155,7 @@ public abstract class ItemRewriter extends RewriterBase i }); } - public void registerClickWindow(ServerboundPacketType packetType, Type type) { + public void registerClickWindow(S packetType, Type type) { protocol.registerServerbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -170,7 +171,7 @@ public abstract class ItemRewriter extends RewriterBase i }); } - public void registerClickWindow1_17_1(ServerboundPacketType packetType) { + public void registerClickWindow1_17_1(S packetType) { protocol.registerServerbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -195,7 +196,7 @@ public abstract class ItemRewriter extends RewriterBase i }); } - public void registerSetCooldown(ClientboundPacketType packetType) { + public void registerSetCooldown(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -208,7 +209,7 @@ public abstract class ItemRewriter extends RewriterBase i } // 1.14.4+ - public void registerTradeList(ClientboundPacketType packetType) { + public void registerTradeList(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -238,7 +239,7 @@ public abstract class ItemRewriter extends RewriterBase i }); } - public void registerTradeList1_19(ClientboundPacketType packetType) { + public void registerTradeList1_19(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -264,7 +265,7 @@ public abstract class ItemRewriter extends RewriterBase i }); } - public void registerAdvancements(ClientboundPacketType packetType, Type type) { + public void registerAdvancements(C packetType, Type type) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -304,7 +305,7 @@ public abstract class ItemRewriter extends RewriterBase i }); } - public void registerWindowPropertyEnchantmentHandler(ClientboundPacketType packetType) { + public void registerWindowPropertyEnchantmentHandler(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -322,7 +323,7 @@ public abstract class ItemRewriter extends RewriterBase i } // Not the very best place for this, but has to stay here until *everything* is abstracted - public void registerSpawnParticle(ClientboundPacketType packetType, Type itemType, Type coordType) { + public void registerSpawnParticle(C packetType, Type itemType, Type coordType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -341,7 +342,7 @@ public abstract class ItemRewriter extends RewriterBase i }); } - public void registerSpawnParticle1_19(ClientboundPacketType packetType) { + public void registerSpawnParticle1_19(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/RecipeRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/RecipeRewriter.java index e06c90f69..dfa60c7bf 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/RecipeRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/RecipeRewriter.java @@ -28,12 +28,12 @@ import org.checkerframework.checker.nullness.qual.Nullable; import java.util.HashMap; import java.util.Map; -public abstract class RecipeRewriter { +public abstract class RecipeRewriter { - protected final Protocol protocol; + protected final Protocol protocol; protected final Map recipeHandlers = new HashMap<>(); - protected RecipeRewriter(Protocol protocol) { + protected RecipeRewriter(Protocol protocol) { this.protocol = protocol; } @@ -44,7 +44,7 @@ public abstract class RecipeRewriter { } } - public void registerDefaultHandler(ClientboundPacketType packetType) { + public void registerDefaultHandler(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -52,7 +52,7 @@ public abstract class RecipeRewriter { int size = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < size; i++) { String type = wrapper.passthrough(Type.STRING).replace("minecraft:", ""); - String id = wrapper.passthrough(Type.STRING); // Recipe Identifier + wrapper.passthrough(Type.STRING); // Recipe Identifier handle(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 3cc7d2fec..381457769 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/SoundRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/SoundRewriter.java @@ -23,22 +23,22 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; -public class SoundRewriter { - protected final Protocol protocol; +public class SoundRewriter { + protected final Protocol protocol; protected final IdRewriteFunction idRewriter; - public SoundRewriter(Protocol protocol) { + public SoundRewriter(Protocol protocol) { this.protocol = protocol; this.idRewriter = id -> protocol.getMappingData().getSoundMappings().getNewId(id); } - public SoundRewriter(Protocol protocol, IdRewriteFunction idRewriter) { + public SoundRewriter(Protocol protocol, IdRewriteFunction idRewriter) { this.protocol = protocol; this.idRewriter = idRewriter; } // The same for entity sound - public void registerSound(ClientboundPacketType packetType) { + public void registerSound(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -48,7 +48,7 @@ public class SoundRewriter { }); } - public void register1_19_3Sound(ClientboundPacketType packetType) { + public void register1_19_3Sound(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { 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 5f68f22ff..4dfbb9f81 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/StatisticsRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/StatisticsRewriter.java @@ -24,15 +24,15 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; import org.checkerframework.checker.nullness.qual.Nullable; -public class StatisticsRewriter { - private final Protocol protocol; - private final int customStatsCategory = 8; // Make this changeable if it differs in a future version +public class StatisticsRewriter { + private static final int CUSTOM_STATS_CATEGORY = 8; // Make this changeable if it differs in a future version + private final Protocol protocol; - public StatisticsRewriter(Protocol protocol) { + public StatisticsRewriter(Protocol protocol) { this.protocol = protocol; } - public void register(ClientboundPacketType packetType) { + public void register(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -43,7 +43,7 @@ public class StatisticsRewriter { int categoryId = wrapper.read(Type.VAR_INT); int statisticId = wrapper.read(Type.VAR_INT); int value = wrapper.read(Type.VAR_INT); - if (categoryId == customStatsCategory && protocol.getMappingData().getStatisticsMappings() != null) { + if (categoryId == CUSTOM_STATS_CATEGORY && protocol.getMappingData().getStatisticsMappings() != null) { // Rewrite custom statistics id statisticId = protocol.getMappingData().getStatisticsMappings().getNewId(statisticId); if (statisticId == -1) { 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 03791b710..324126d0a 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java @@ -39,14 +39,14 @@ import java.util.List; import java.util.Map; import java.util.Set; -public class TagRewriter { +public class TagRewriter { private static final int[] EMPTY_ARRAY = {}; - private final Protocol protocol; + private final Protocol protocol; private final Map> newTags = new EnumMap<>(RegistryType.class); private final Map> toRename = new EnumMap<>(RegistryType.class); private final Set toRemove = new HashSet<>(); - public TagRewriter(Protocol protocol) { + public TagRewriter(Protocol protocol) { this.protocol = protocol; } @@ -135,7 +135,7 @@ public class TagRewriter { * @param packetType packet type * @param readUntilType read and process the types until (including) the given registry type */ - public void register(ClientboundPacketType packetType, @Nullable RegistryType readUntilType) { + public void register(C packetType, @Nullable RegistryType readUntilType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -149,7 +149,7 @@ public class TagRewriter { * * @param packetType packet type */ - public void registerGeneric(ClientboundPacketType packetType) { + public void registerGeneric(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() {