From 4cd65dd956b9bc9f3ae86e9da693264a0e4e36cd Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 19 Oct 2023 11:50:31 +1000 Subject: [PATCH] 23w42a (if the ci manages to find VV) --- .../Protocol1_10To1_11.java | 4 +- .../packets/BlockItemPackets1_11.java | 10 +- .../packets/EntityPackets1_11.java | 90 +++++++-------- .../Protocol1_11_1To1_12.java | 4 +- .../packets/BlockItemPackets1_12.java | 2 +- .../packets/EntityPackets1_12.java | 46 ++++---- .../Protocol1_11To1_11_1.java | 4 +- .../packets/EntityPackets1_11_1.java | 22 ++-- .../packets/ItemPackets1_11_1.java | 2 +- .../Protocol1_12_2To1_13.java | 4 +- .../data/ParticleMapping.java | 2 +- .../packets/BlockItemPackets1_13.java | 16 +-- .../packets/EntityPackets1_13.java | 74 ++++++------ .../packets/PlayerPacket1_13.java | 8 +- .../Protocol1_13_1To1_13_2.java | 4 +- .../packets/InventoryPackets1_13_2.java | 16 +-- .../packets/WorldPackets1_13_2.java | 2 +- .../Protocol1_13_2To1_14.java | 4 +- .../packets/BlockItemPackets1_14.java | 6 +- .../packets/EntityPackets1_14.java | 106 +++++++++--------- .../packets/PlayerPackets1_14.java | 2 +- .../Protocol1_13To1_13_1.java | 10 +- .../packets/EntityPackets1_13_1.java | 28 ++--- .../packets/InventoryPackets1_13_1.java | 18 +-- .../Protocol1_14_4To1_15.java | 4 +- .../data/EntityTypeMapping.java | 4 +- .../packets/EntityPackets1_15.java | 40 +++---- .../Protocol1_14To1_14_1.java | 4 +- .../packets/EntityPackets1_14_1.java | 22 ++-- .../Protocol1_15_2To1_16.java | 6 +- .../packets/BlockItemPackets1_16.java | 2 +- .../packets/EntityPackets1_16.java | 64 +++++------ .../Protocol1_16_1To1_16_2.java | 4 +- .../packets/EntityPackets1_16_2.java | 24 ++-- .../Protocol1_16_4To1_17.java | 4 +- .../packets/EntityPackets1_17.java | 38 +++---- .../Protocol1_17_1To1_18.java | 4 +- .../packets/EntityPackets1_18.java | 4 +- .../Protocol1_18_2To1_19.java | 4 +- .../packets/EntityPackets1_19.java | 42 +++---- .../Protocol1_19_1To1_19_3.java | 4 +- .../packets/EntityPackets1_19_3.java | 14 +-- .../Protocol1_19_3To1_19_4.java | 4 +- .../packets/EntityPackets1_19_4.java | 36 +++--- .../Protocol1_19_4To1_20.java | 4 +- .../packets/EntityPackets1_20.java | 12 +- .../Protocol1_19To1_19_1.java | 4 +- .../packets/EntityPackets1_19_1.java | 8 +- .../Protocol1_20_2To1_20_3.java | 35 +++--- .../BlockItemPacketRewriter1_20_3.java | 57 ++++++++++ .../rewriter/EntityPacketRewriter1_20_3.java | 60 +++++++++- .../rewriter/ItemPacketRewriter1_20_3.java | 36 ------ .../Protocol1_20To1_20_2.java | 4 +- .../BlockItemPacketRewriter1_20_2.java | 4 +- .../rewriter/EntityPacketRewriter1_20_2.java | 12 +- .../Protocol1_9_4To1_10.java | 6 +- .../packets/BlockItemPackets1_10.java | 2 +- .../packets/EntityPackets1_10.java | 34 +++--- .../data/mappings-1.20.3to1.20.2.nbt | Bin 851 -> 1362 bytes gradle.properties | 2 +- gradle/libs.versions.toml | 2 +- .../template/protocol/Protocol1_98To_99.java | 8 +- .../rewriter/BlockItemPacketRewriter1_99.java | 15 +-- .../rewriter/EntityPacketRewriter1_99.java | 18 +-- 64 files changed, 609 insertions(+), 526 deletions(-) create mode 100644 common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java delete mode 100644 common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/ItemPacketRewriter1_20_3.java diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java index a8eb4eac..b2b154a3 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java @@ -26,7 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.EntityPac import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets1_11; import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11; import com.viaversion.viaversion.data.entity.EntityTrackerBase; 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; @@ -60,7 +60,7 @@ public class Protocol1_10To1_11 extends BackwardsProtocol { - Item[] stacks = wrapper.get(Type.ITEM_ARRAY, 0); + Item[] stacks = wrapper.get(Type.ITEM1_8_ARRAY, 0); for (int i = 0; i < stacks.length; i++) stacks[i] = handleItemToClient(stacks[i]); @@ -108,7 +108,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter Entity1_11Types.ObjectType.findById(id).orElse(null))); + handler(getObjectRewriter(id -> EntityTypes1_11.ObjectType.findById(id).orElse(null))); // Handle FallingBlock blocks handler(wrapper -> { - Optional type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); - if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) { + Optional type = EntityTypes1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0)); + if (type.isPresent() && type.get() == EntityTypes1_12.ObjectType.FALLING_BLOCK) { int objectData = wrapper.get(Type.INT, 0); int objType = objectData & 4095; int data = objectData >> 12 & 15; @@ -104,8 +104,8 @@ public class EntityPackets1_11 extends LegacyEntityRewriter { // Sub 1.11 clients will cry if the list is empty List metadata = wrapper.get(Types1_9.METADATA_LIST, 0); @@ -204,37 +204,37 @@ public class EntityPackets1_11 extends LegacyEntityRewriter storage.add(getSkeletonTypeMeta(1))); - mapEntityTypeWithData(Entity1_11Types.EntityType.STRAY, Entity1_11Types.EntityType.SKELETON).plainName().spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2))); + mapEntityTypeWithData(EntityTypes1_11.EntityType.WITHER_SKELETON, EntityTypes1_11.EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1))); + mapEntityTypeWithData(EntityTypes1_11.EntityType.STRAY, EntityTypes1_11.EntityType.SKELETON).plainName().spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2))); // Zombies - mapEntityTypeWithData(Entity1_11Types.EntityType.HUSK, Entity1_11Types.EntityType.ZOMBIE).plainName().spawnMetadata(storage -> handleZombieType(storage, 6)); - mapEntityTypeWithData(Entity1_11Types.EntityType.ZOMBIE_VILLAGER, Entity1_11Types.EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 1)); + mapEntityTypeWithData(EntityTypes1_11.EntityType.HUSK, EntityTypes1_11.EntityType.ZOMBIE).plainName().spawnMetadata(storage -> handleZombieType(storage, 6)); + mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_VILLAGER, EntityTypes1_11.EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 1)); // Horses - mapEntityTypeWithData(Entity1_11Types.EntityType.HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent. - mapEntityTypeWithData(Entity1_11Types.EntityType.DONKEY, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1))); - mapEntityTypeWithData(Entity1_11Types.EntityType.MULE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2))); - mapEntityTypeWithData(Entity1_11Types.EntityType.SKELETON_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4))); - mapEntityTypeWithData(Entity1_11Types.EntityType.ZOMBIE_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3))); + mapEntityTypeWithData(EntityTypes1_11.EntityType.HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent. + mapEntityTypeWithData(EntityTypes1_11.EntityType.DONKEY, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1))); + mapEntityTypeWithData(EntityTypes1_11.EntityType.MULE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2))); + mapEntityTypeWithData(EntityTypes1_11.EntityType.SKELETON_HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4))); + mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3))); // New mobs - mapEntityTypeWithData(Entity1_11Types.EntityType.EVOCATION_FANGS, Entity1_11Types.EntityType.SHULKER); - mapEntityTypeWithData(Entity1_11Types.EntityType.EVOCATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).plainName(); - mapEntityTypeWithData(Entity1_11Types.EntityType.VEX, Entity1_11Types.EntityType.BAT).plainName(); - mapEntityTypeWithData(Entity1_11Types.EntityType.VINDICATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).plainName().spawnMetadata(storage -> storage.add(new Metadata(13, MetaType1_9.VarInt, 4))); // Base Profession - mapEntityTypeWithData(Entity1_11Types.EntityType.LIAMA, Entity1_11Types.EntityType.HORSE).plainName().spawnMetadata(storage -> storage.add(getHorseMetaType(1))); - mapEntityTypeWithData(Entity1_11Types.EntityType.LIAMA_SPIT, Entity1_11Types.EntityType.SNOWBALL); + mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOCATION_FANGS, EntityTypes1_11.EntityType.SHULKER); + mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOCATION_ILLAGER, EntityTypes1_11.EntityType.VILLAGER).plainName(); + mapEntityTypeWithData(EntityTypes1_11.EntityType.VEX, EntityTypes1_11.EntityType.BAT).plainName(); + mapEntityTypeWithData(EntityTypes1_11.EntityType.VINDICATION_ILLAGER, EntityTypes1_11.EntityType.VILLAGER).plainName().spawnMetadata(storage -> storage.add(new Metadata(13, MetaType1_9.VarInt, 4))); // Base Profession + mapEntityTypeWithData(EntityTypes1_11.EntityType.LIAMA, EntityTypes1_11.EntityType.HORSE).plainName().spawnMetadata(storage -> storage.add(getHorseMetaType(1))); + mapEntityTypeWithData(EntityTypes1_11.EntityType.LIAMA_SPIT, EntityTypes1_11.EntityType.SNOWBALL); - mapObjectType(Entity1_11Types.ObjectType.LIAMA_SPIT, Entity1_11Types.ObjectType.SNOWBALL, -1); + mapObjectType(EntityTypes1_11.ObjectType.LIAMA_SPIT, EntityTypes1_11.ObjectType.SNOWBALL, -1); // Replace with endertorchthingies - mapObjectType(Entity1_11Types.ObjectType.EVOCATION_FANGS, Entity1_11Types.ObjectType.FALLING_BLOCK, 198 | 1 << 12); + mapObjectType(EntityTypes1_11.ObjectType.EVOCATION_FANGS, EntityTypes1_11.ObjectType.FALLING_BLOCK, 198 | 1 << 12); // Handle ElderGuardian & target metadata - filter().filterFamily(Entity1_11Types.EntityType.GUARDIAN).index(12).handler((event, meta) -> { + filter().filterFamily(EntityTypes1_11.EntityType.GUARDIAN).index(12).handler((event, meta) -> { boolean b = (boolean) meta.getValue(); int bitmask = b ? 0x02 : 0; - if (event.entityType() == Entity1_11Types.EntityType.ELDER_GUARDIAN) { + if (event.entityType() == EntityTypes1_11.EntityType.ELDER_GUARDIAN) { bitmask |= 0x04; } @@ -242,12 +242,12 @@ public class EntityPackets1_11 extends LegacyEntityRewriter { + filter().filterFamily(EntityTypes1_11.EntityType.ZOMBIE).handler((event, meta) -> { switch (meta.id()) { case 13: event.cancel(); @@ -267,18 +267,18 @@ public class EntityPackets1_11 extends LegacyEntityRewriter { + filter().type(EntityTypes1_11.EntityType.EVOCATION_ILLAGER).index(12).handler((event, meta) -> { event.setIndex(13); meta.setTypeAndValue(MetaType1_9.VarInt, ((Byte) meta.getValue()).intValue()); // Change the profession for the states }); // Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ): - filter().type(Entity1_11Types.EntityType.VEX).index(12).handler((event, meta) -> { + filter().type(EntityTypes1_11.EntityType.VEX).index(12).handler((event, meta) -> { meta.setValue((byte) 0x00); }); // Handle VindicationIllager - filter().type(Entity1_11Types.EntityType.VINDICATION_ILLAGER).index(12).handler((event, meta) -> { + filter().type(EntityTypes1_11.EntityType.VINDICATION_ILLAGER).index(12).handler((event, meta) -> { event.setIndex(13); meta.setTypeAndValue(MetaType1_9.VarInt, ((Number) meta.getValue()).intValue() == 1 ? 2 : 4); }); @@ -288,7 +288,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter { + filter().filterFamily(EntityTypes1_11.EntityType.ABSTRACT_HORSE).index(13).handler((event, meta) -> { StoredEntityData data = storedEntityData(event); byte b = (byte) meta.getValue(); if (data.has(ChestedHorseStorage.class) && data.get(ChestedHorseStorage.class).isChested()) { @@ -298,7 +298,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter { + filter().filterFamily(EntityTypes1_11.EntityType.CHESTED_HORSE).handler((event, meta) -> { StoredEntityData data = storedEntityData(event); if (!data.has(ChestedHorseStorage.class)) { data.put(new ChestedHorseStorage()); @@ -306,10 +306,10 @@ public class EntityPackets1_11 extends LegacyEntityRewriter { + filter().filterFamily(EntityTypes1_11.EntityType.CHESTED_HORSE).index(15).handler((event, meta) -> { StoredEntityData data = storedEntityData(event); ChestedHorseStorage storage = data.get(ChestedHorseStorage.class); boolean b = (boolean) meta.getValue(); @@ -318,7 +318,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter { + filter().type(EntityTypes1_11.EntityType.LIAMA).handler((event, meta) -> { StoredEntityData data = storedEntityData(event); ChestedHorseStorage storage = data.get(ChestedHorseStorage.class); @@ -341,17 +341,17 @@ public class EntityPackets1_11 extends LegacyEntityRewriter { + filter().type(EntityTypes1_11.EntityType.VILLAGER).index(13).handler((event, meta) -> { if ((int) meta.getValue() == 5) { meta.setValue(0); } }); // handle new Shulker color meta - filter().type(Entity1_11Types.EntityType.SHULKER).cancel(15); + filter().type(EntityTypes1_11.EntityType.SHULKER).cancel(15); } /* @@ -393,11 +393,11 @@ public class EntityPackets1_11 extends LegacyEntityRewriter Trading diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/EntityPackets1_12.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/EntityPackets1_12.java index 9ec14e9a..8c8a78bd 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/EntityPackets1_12.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/EntityPackets1_12.java @@ -24,7 +24,7 @@ import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ParrotStor import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker; import com.viaversion.viabackwards.utils.Block; import com.viaversion.viaversion.api.data.entity.StoredEntityData; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12; @@ -62,12 +62,12 @@ public class EntityPackets1_12 extends LegacyEntityRewriter Entity1_12Types.ObjectType.findById(id).orElse(null))); + handler(getObjectRewriter(id -> EntityTypes1_12.ObjectType.findById(id).orElse(null))); // Handle FallingBlock blocks handler(wrapper -> { - Optional type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); - if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) { + Optional type = EntityTypes1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0)); + if (type.isPresent() && type.get() == EntityTypes1_12.ObjectType.FALLING_BLOCK) { int objectData = wrapper.get(Type.INT, 0); int objType = objectData & 4095; int data = objectData >> 12 & 15; @@ -83,8 +83,8 @@ public class EntityPackets1_12 extends LegacyEntityRewriter storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00))); - mapEntityTypeWithData(Entity1_12Types.EntityType.ILLUSION_ILLAGER, Entity1_12Types.EntityType.EVOCATION_ILLAGER).plainName(); + mapEntityTypeWithData(EntityTypes1_12.EntityType.PARROT, EntityTypes1_12.EntityType.BAT).plainName().spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00))); + mapEntityTypeWithData(EntityTypes1_12.EntityType.ILLUSION_ILLAGER, EntityTypes1_12.EntityType.EVOCATION_ILLAGER).plainName(); filter().handler((event, meta) -> { if (meta.metaType() == MetaType1_12.Chat) { @@ -214,10 +214,10 @@ public class EntityPackets1_12 extends LegacyEntityRewriter { + filter().type(EntityTypes1_12.EntityType.ILLUSION_ILLAGER).index(0).handler((event, meta) -> { byte mask = (byte) meta.getValue(); if ((mask & 0x20) == 0x20) { @@ -228,15 +228,15 @@ public class EntityPackets1_12 extends LegacyEntityRewriter { + filter().filterFamily(EntityTypes1_12.EntityType.PARROT).handler((event, meta) -> { StoredEntityData data = storedEntityData(event); if (!data.has(ParrotStorage.class)) { data.put(new ParrotStorage()); } }); // Parrot remove animal metadata - filter().type(Entity1_12Types.EntityType.PARROT).cancel(12); // Is baby - filter().type(Entity1_12Types.EntityType.PARROT).index(13).handler((event, meta) -> { + filter().type(EntityTypes1_12.EntityType.PARROT).cancel(12); // Is baby + filter().type(EntityTypes1_12.EntityType.PARROT).index(13).handler((event, meta) -> { StoredEntityData data = storedEntityData(event); ParrotStorage storage = data.get(ParrotStorage.class); boolean isSitting = (((byte) meta.getValue()) & 0x01) == 0x01; @@ -260,11 +260,11 @@ public class EntityPackets1_12 extends LegacyEntityRewriter { + filter().type(EntityTypes1_12.EntityType.PLAYER).index(15).handler((event, meta) -> { CompoundTag tag = (CompoundTag) meta.getValue(); ShoulderTracker tracker = event.user().get(ShoulderTracker.class); @@ -283,7 +283,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter { + filter().type(EntityTypes1_12.EntityType.PLAYER).index(16).handler((event, meta) -> { CompoundTag tag = (CompoundTag) event.meta().getValue(); ShoulderTracker tracker = event.user().get(ShoulderTracker.class); @@ -304,11 +304,11 @@ public class EntityPackets1_12 extends LegacyEntityRewriter Entity1_11Types.ObjectType.findById(id).orElse(null))); + handler(getObjectRewriter(id -> EntityTypes1_11.ObjectType.findById(id).orElse(null))); } }); - registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB); - registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER); + registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, EntityTypes1_11.EntityType.EXPERIENCE_ORB); + registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, EntityTypes1_11.EntityType.WEATHER); protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() { @Override @@ -82,8 +82,8 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter Trading diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java index 820f53a2..edcb46be 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java @@ -33,7 +33,7 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerP import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; @@ -118,7 +118,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol { - Optional optionalType = Entity1_13Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); + Optional optionalType = EntityTypes1_13.ObjectType.findById(wrapper.get(Type.BYTE, 0)); if (!optionalType.isPresent()) return; - Entity1_13Types.ObjectType type = optionalType.get(); - if (type == Entity1_13Types.ObjectType.FALLING_BLOCK) { + EntityTypes1_13.ObjectType type = optionalType.get(); + if (type == EntityTypes1_13.ObjectType.FALLING_BLOCK) { int blockState = wrapper.get(Type.INT, 0); int combined = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(blockState); combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12); wrapper.set(Type.INT, 0, combined); - } else if (type == Entity1_13Types.ObjectType.ITEM_FRAME) { + } else if (type == EntityTypes1_13.ObjectType.ITEM_FRAME) { int data = wrapper.get(Type.INT, 0); switch (data) { case 3: @@ -111,15 +111,15 @@ public class EntityPackets1_13 extends LegacyEntityRewriter { int type = wrapper.get(Type.VAR_INT, 1); - EntityType entityType = Entity1_13Types.getTypeFromId(type, false); + EntityType entityType = EntityTypes1_13.getTypeFromId(type, false); tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType); int oldId = EntityTypeMapping.getOldId(type); @@ -170,7 +170,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter { int motive = wrapper.read(Type.VAR_INT); String title = PaintingMapping.getStringId(motive); @@ -189,7 +189,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter { + mapEntityTypeWithData(EntityTypes1_13.EntityType.PHANTOM, EntityTypes1_13.EntityType.PARROT).plainName().spawnMetadata(storage -> { // The phantom is grey/blue so let's do yellow/blue storage.add(new Metadata(15, MetaType1_12.VarInt, 3)); }); // Dolphin - mapEntityTypeWithData(Entity1_13Types.EntityType.DOLPHIN, Entity1_13Types.EntityType.SQUID).plainName(); + mapEntityTypeWithData(EntityTypes1_13.EntityType.DOLPHIN, EntityTypes1_13.EntityType.SQUID).plainName(); // Turtle - mapEntityTypeWithData(Entity1_13Types.EntityType.TURTLE, Entity1_13Types.EntityType.OCELOT).plainName(); + mapEntityTypeWithData(EntityTypes1_13.EntityType.TURTLE, EntityTypes1_13.EntityType.OCELOT).plainName(); // Rewrite Meta types filter().handler((event, meta) -> { @@ -297,36 +297,36 @@ public class EntityPackets1_13 extends LegacyEntityRewriter { + filter().type(EntityTypes1_13.EntityType.WOLF).index(17).handler((event, meta) -> { meta.setValue(15 - (int) meta.getValue()); }); // Rewrite AreaEffectCloud - filter().type(Entity1_13Types.EntityType.AREA_EFFECT_CLOUD).index(9).handler((event, meta) -> { + filter().type(EntityTypes1_13.EntityType.AREA_EFFECT_CLOUD).index(9).handler((event, meta) -> { Particle particle = (Particle) meta.getValue(); ParticleMapping.ParticleData data = ParticleMapping.getMapping(particle.getId()); @@ -354,12 +354,12 @@ public class EntityPackets1_13 extends LegacyEntityRewriter { int size = wrapper.passthrough(Type.UNSIGNED_BYTE); for (int i = 0; i < size; i++) { //Input Item - Item input = wrapper.read(Type.FLAT_ITEM); + Item input = wrapper.read(Type.ITEM1_13); wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(input)); //Output Item - Item output = wrapper.read(Type.FLAT_ITEM); + Item output = wrapper.read(Type.ITEM1_13); wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(output)); boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item if (secondItem) { //Second Item - Item second = wrapper.read(Type.FLAT_ITEM); + Item second = wrapper.read(Type.ITEM1_13); wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(second)); } @@ -383,7 +383,7 @@ public class PlayerPacket1_13 extends RewriterBase { case "MC|BEdit": wrapper.setPacketType(ServerboundPackets1_13.EDIT_BOOK); Item book = wrapper.read(Type.ITEM); - wrapper.write(Type.FLAT_ITEM, protocol.getItemRewriter().handleItemToServer(book)); + wrapper.write(Type.ITEM1_13, protocol.getItemRewriter().handleItemToServer(book)); boolean signing = channel.equals("MC|BSign"); wrapper.write(Type.BOOLEAN, signing); break; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/Protocol1_13_1To1_13_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/Protocol1_13_1To1_13_2.java index 0b30d9a9..9d596126 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/Protocol1_13_1To1_13_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/Protocol1_13_1To1_13_2.java @@ -42,7 +42,7 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol { int id = wrapper.get(Type.INT, 0); if (id == 27) { - wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM)); + wrapper.write(Type.ITEM1_13, wrapper.read(Type.FLAT_VAR_INT_ITEM)); } }); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java index 2979b34d..d2a97c51 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java @@ -28,7 +28,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets.SoundPa import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage; import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; @@ -167,7 +167,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol { int id = wrapper.get(Type.BYTE, 0); int mappedId = newEntityId(id); - Entity1_13Types.EntityType entityType = Entity1_13Types.getTypeFromId(mappedId, false); - Entity1_13Types.ObjectType objectType; - if (entityType.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT)) { - objectType = Entity1_13Types.ObjectType.MINECART; + EntityTypes1_13.EntityType entityType = EntityTypes1_13.getTypeFromId(mappedId, false); + EntityTypes1_13.ObjectType objectType; + if (entityType.isOrHasParent(EntityTypes1_13.EntityType.MINECART_ABSTRACT)) { + objectType = EntityTypes1_13.ObjectType.MINECART; int data = 0; switch (entityType) { case CHEST_MINECART: @@ -167,7 +167,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { int type = wrapper.get(Type.VAR_INT, 1); - EntityType entityType = Entity1_14Types.getTypeFromId(type); + EntityType entityType = EntityTypes1_14.getTypeFromId(type); addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType); int oldId = newEntityId(type); @@ -234,7 +234,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EXPERIENCE_ORB)); + handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), EntityTypes1_14.EXPERIENCE_ORB)); } }); @@ -246,7 +246,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.LIGHTNING_BOLT)); + handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), EntityTypes1_14.LIGHTNING_BOLT)); } }); @@ -260,7 +260,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.PAINTING)); + handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), EntityTypes1_14.PAINTING)); } }); @@ -276,7 +276,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter positionHandler.cacheEntityPosition(wrapper, true, false)); } }); @@ -291,7 +291,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { short difficulty = wrapper.user().get(DifficultyStorage.class).getDifficulty(); @@ -331,15 +331,15 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { int typeId = meta.metaType().typeId(); @@ -351,28 +351,28 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { EntityType type = event.entityType(); if (type == null) return; - if (type.isOrHasParent(Entity1_14Types.ABSTRACT_ILLAGER_BASE) || type == Entity1_14Types.RAVAGER || type == Entity1_14Types.WITCH) { + if (type.isOrHasParent(EntityTypes1_14.ABSTRACT_ILLAGER_BASE) || type == EntityTypes1_14.RAVAGER || type == EntityTypes1_14.WITCH) { int index = event.index(); if (index == 14) { event.cancel(); @@ -382,11 +382,11 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { + filter().type(EntityTypes1_14.AREA_EFFECT_CLOUD).index(10).handler((event, meta) -> { rewriteParticle((Particle) meta.getValue()); }); - filter().type(Entity1_14Types.FIREWORK_ROCKET).index(8).handler((event, meta) -> { + filter().type(EntityTypes1_14.FIREWORK_ROCKET).index(8).handler((event, meta) -> { meta.setMetaType(Types1_13_2.META_TYPES.varIntType); Integer value = (Integer) meta.getValue(); if (value == null) { @@ -394,9 +394,9 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { VillagerData villagerData = (VillagerData) meta.getValue(); @@ -406,27 +406,27 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { + filter().filterFamily(EntityTypes1_14.ABSTRACT_SKELETON).index(13).handler((event, meta) -> { byte value = (byte) meta.getValue(); if ((value & 4) != 0) { event.createExtraMeta(new Metadata(14, Types1_13_2.META_TYPES.booleanType, true)); } }); - filter().filterFamily(Entity1_14Types.ZOMBIE).index(13).handler((event, meta) -> { + filter().filterFamily(EntityTypes1_14.ZOMBIE).index(13).handler((event, meta) -> { byte value = (byte) meta.getValue(); if ((value & 4) != 0) { event.createExtraMeta(new Metadata(16, Types1_13_2.META_TYPES.booleanType, true)); } }); - filter().filterFamily(Entity1_14Types.ZOMBIE).addIndex(16); + filter().filterFamily(EntityTypes1_14.ZOMBIE).addIndex(16); // Remove bed location - filter().filterFamily(Entity1_14Types.LIVINGENTITY).handler((event, meta) -> { + filter().filterFamily(EntityTypes1_14.LIVINGENTITY).handler((event, meta) -> { int index = event.index(); if (index == 12) { Position position = (Position) meta.getValue(); @@ -452,12 +452,12 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { + filter().type(EntityTypes1_14.OCELOT).index(13).handler((event, meta) -> { event.setIndex(15); meta.setTypeAndValue(Types1_13_2.META_TYPES.varIntType, 0); }); - filter().type(Entity1_14Types.CAT).handler((event, meta) -> { + filter().type(EntityTypes1_14.CAT).handler((event, meta) -> { if (event.index() == 15) { meta.setValue(1); } else if (event.index() == 13) { @@ -501,6 +501,6 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { @Override public void register() { map(Type.UNSIGNED_BYTE); - map(Type.BOOLEAN, Type.NOTHING); // Locked + read(Type.BOOLEAN); // Locked handler(wrapper -> { byte difficulty = wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue(); wrapper.user().get(DifficultyStorage.class).setDifficulty(difficulty); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java index 160c6dd3..e66ce219 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java @@ -27,7 +27,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets.Invento import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets1_13_1; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.RegistryType; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; @@ -88,10 +88,10 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol { - itemRewriter.handleItemToServer(wrapper.get(Type.FLAT_ITEM, 0)); + itemRewriter.handleItemToServer(wrapper.get(Type.ITEM1_13, 0)); wrapper.write(Type.VAR_INT, 0); }); } @@ -182,7 +182,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol { int entityId = wrapper.get(Type.VAR_INT, 0); byte type = wrapper.get(Type.BYTE, 0); - Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, true); + EntityTypes1_13.EntityType entType = EntityTypes1_13.getTypeFromId(type, true); if (entType == null) { ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type); return; } // Rewrite falling block - if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) { + if (entType.is(EntityTypes1_13.EntityType.FALLING_BLOCK)) { int data = wrapper.get(Type.INT, 0); wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(data)); } @@ -74,8 +74,8 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter { + filter().filterFamily(EntityTypes1_13.EntityType.MINECART_ABSTRACT).index(9).handler((event, meta) -> { int data = (int) meta.getValue(); meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); }); @@ -164,11 +164,11 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter { String channel = wrapper.passthrough(Type.STRING); @@ -44,16 +44,16 @@ public class InventoryPackets1_13_1 extends ItemRewriter= 5 ? entityId - 1 : entityId; } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java index d7f95871..b32d64d0 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java @@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15; import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping; import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; @@ -64,7 +64,7 @@ public class EntityPackets1_15 extends EntityRewriter { int type = wrapper.get(Type.VAR_INT, 1); - EntityType entityType = Entity1_15Types.getTypeFromId(type); + EntityType entityType = EntityTypes1_15.getTypeFromId(type); tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType); wrapper.set(Type.VAR_INT, 1, EntityTypeMapping.getOldEntityId(type)); }); @@ -96,7 +96,7 @@ public class EntityPackets1_15 extends EntityRewriter { boolean immediateRespawn = !wrapper.read(Type.BOOLEAN); // Inverted @@ -123,9 +123,9 @@ public class EntityPackets1_15 extends EntityRewriter wrapper.write(Types1_14.METADATA_LIST, new ArrayList<>())); // Metadata is no longer sent in 1.15, so we have to send an empty one - handler(getTrackerHandler(Entity1_15Types.PLAYER, Type.VAR_INT)); + handler(getTrackerHandler(EntityTypes1_15.PLAYER, Type.VAR_INT)); } }); @@ -155,7 +155,7 @@ public class EntityPackets1_15 extends EntityRewriter { int entityId = wrapper.get(Type.VAR_INT, 0); EntityType entityType = tracker(wrapper.user()).entityType(entityId); - if (entityType != Entity1_15Types.BEE) return; + if (entityType != EntityTypes1_15.BEE) return; int size = wrapper.get(Type.INT, 0); int newSize = size; @@ -195,29 +195,29 @@ public class EntityPackets1_15 extends EntityRewriter { + mapEntityTypeWithData(EntityTypes1_15.BEE, EntityTypes1_15.PUFFERFISH).jsonName().spawnMetadata(storage -> { storage.add(new Metadata(14, Types1_14.META_TYPES.booleanType, false)); storage.add(new Metadata(15, Types1_14.META_TYPES.varIntType, 2)); }); - filter().type(Entity1_15Types.ENDERMAN).cancel(16); - filter().type(Entity1_15Types.TRIDENT).cancel(10); + filter().type(EntityTypes1_15.ENDERMAN).cancel(16); + filter().type(EntityTypes1_15.TRIDENT).cancel(10); // Redundant health removed in 1.15 - filter().type(Entity1_15Types.WOLF).addIndex(17); - filter().type(Entity1_15Types.WOLF).index(8).handler((event, meta) -> { + filter().type(EntityTypes1_15.WOLF).addIndex(17); + filter().type(EntityTypes1_15.WOLF).index(8).handler((event, meta) -> { event.createExtraMeta(new Metadata(17/*WOLF_HEALTH*/, Types1_14.META_TYPES.floatType, event.meta().value())); }); } @Override public EntityType typeFromId(int typeId) { - return Entity1_15Types.getTypeFromId(typeId); + return EntityTypes1_15.getTypeFromId(typeId); } @Override diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14to1_14_1/Protocol1_14To1_14_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14to1_14_1/Protocol1_14To1_14_1.java index 2bf7ca62..5ad5c381 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14to1_14_1/Protocol1_14To1_14_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14to1_14_1/Protocol1_14To1_14_1.java @@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_14to1_14_1; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.packets.EntityPackets1_14_1; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; @@ -40,7 +40,7 @@ public class Protocol1_14To1_14_1 extends BackwardsProtocol metadata = wrapper.get(Types1_14.METADATA_LIST, 0); handleMetadata(entityId, metadata, wrapper.user()); @@ -90,13 +90,13 @@ public class EntityPackets1_14_1 extends LegacyEntityRewriter translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT))); map(Type.BYTE); - map(Type.UUID, Type.NOTHING); // Sender + read(Type.UUID); // Sender } }); @@ -171,7 +171,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol { EntityType entityType = typeFromId(wrapper.get(Type.VAR_INT, 1)); - if (entityType == Entity1_16Types.LIGHTNING_BOLT) { + if (entityType == EntityTypes1_16.LIGHTNING_BOLT) { // Map to old weather entity packet wrapper.cancel(); @@ -93,7 +93,7 @@ public class EntityPackets1_16 extends EntityRewriter { WorldNameTracker worldNameTracker = wrapper.user().get(WorldNameTracker.class); @@ -162,7 +162,7 @@ public class EntityPackets1_16 extends EntityRewriter { ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); clientChunks.setEnvironment(wrapper.get(Type.INT, 1)); - tracker(wrapper.user()).addEntity(wrapper.get(Type.INT, 0), Entity1_16Types.PLAYER); + tracker(wrapper.user()).addEntity(wrapper.get(Type.INT, 0), EntityTypes1_16.PLAYER); wrapper.write(Type.STRING, "default"); // Level type @@ -178,10 +178,10 @@ public class EntityPackets1_16 extends EntityRewriter { + filter().type(EntityTypes1_16.STRIDER).index(15).handler((event, meta) -> { boolean baby = meta.value(); meta.setTypeAndValue(Types1_14.META_TYPES.varIntType, baby ? 1 : 3); }); - filter().type(Entity1_16Types.STRIDER).cancel(16); - filter().type(Entity1_16Types.STRIDER).cancel(17); - filter().type(Entity1_16Types.STRIDER).cancel(18); + filter().type(EntityTypes1_16.STRIDER).cancel(16); + filter().type(EntityTypes1_16.STRIDER).cancel(17); + filter().type(EntityTypes1_16.STRIDER).cancel(18); - filter().type(Entity1_16Types.FISHING_BOBBER).cancel(8); + filter().type(EntityTypes1_16.FISHING_BOBBER).cancel(8); - filter().filterFamily(Entity1_16Types.ABSTRACT_ARROW).cancel(8); - filter().filterFamily(Entity1_16Types.ABSTRACT_ARROW).handler((event, meta) -> { + filter().filterFamily(EntityTypes1_16.ABSTRACT_ARROW).cancel(8); + filter().filterFamily(EntityTypes1_16.ABSTRACT_ARROW).handler((event, meta) -> { if (event.index() >= 8) { event.setIndex(event.index() + 1); } }); - filter().type(Entity1_16Types.WOLF).index(16).handler((event, meta) -> { + filter().type(EntityTypes1_16.WOLF).index(16).handler((event, meta) -> { byte mask = meta.value(); StoredEntityData data = tracker(event.user()).entityData(event.entityId()); data.put(new WolfDataMaskStorage(mask)); }); - filter().type(Entity1_16Types.WOLF).index(20).handler((event, meta) -> { + filter().type(EntityTypes1_16.WOLF).index(20).handler((event, meta) -> { StoredEntityData data = tracker(event.user()).entityDataIfPresent(event.entityId()); byte previousMask = 0; if (data != null) { @@ -314,6 +314,6 @@ public class EntityPackets1_16 extends EntityRewriter { @@ -80,7 +80,7 @@ public final class EntityPackets1_17 extends EntityRewriter { CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); @@ -183,29 +183,29 @@ public final class EntityPackets1_17 extends EntityRewriter { + filter().filterFamily(EntityTypes1_19.MINECART_ABSTRACT).index(11).handler((event, meta) -> { final int data = (int) meta.getValue(); meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); }); - filter().type(Entity1_19Types.PAINTING).index(8).handler((event, meta) -> { + filter().type(EntityTypes1_19.PAINTING).index(8).handler((event, meta) -> { event.cancel(); final StoredEntityData entityData = tracker(event.user()).entityDataIfPresent(event.entityId()); @@ -298,30 +298,30 @@ public final class EntityPackets1_19 extends EntityRewriter meta.setMetaType(Types1_18.META_TYPES.varIntType)); + filter().type(EntityTypes1_19.CAT).index(19).handler((event, meta) -> meta.setMetaType(Types1_18.META_TYPES.varIntType)); - filter().type(Entity1_19Types.FROG).cancel(16); // Age - filter().type(Entity1_19Types.FROG).cancel(17); // Variant - filter().type(Entity1_19Types.FROG).cancel(18); // Tongue target + filter().type(EntityTypes1_19.FROG).cancel(16); // Age + filter().type(EntityTypes1_19.FROG).cancel(17); // Variant + filter().type(EntityTypes1_19.FROG).cancel(18); // Tongue target - filter().type(Entity1_19Types.WARDEN).cancel(16); // Anger + filter().type(EntityTypes1_19.WARDEN).cancel(16); // Anger - filter().type(Entity1_19Types.GOAT).cancel(18); - filter().type(Entity1_19Types.GOAT).cancel(19); + filter().type(EntityTypes1_19.GOAT).cancel(18); + filter().type(EntityTypes1_19.GOAT).cancel(19); } @Override public void onMappingDataLoaded() { mapTypes(); - mapEntityTypeWithData(Entity1_19Types.FROG, Entity1_19Types.RABBIT).jsonName(); - mapEntityTypeWithData(Entity1_19Types.TADPOLE, Entity1_19Types.PUFFERFISH).jsonName(); - mapEntityTypeWithData(Entity1_19Types.CHEST_BOAT, Entity1_19Types.BOAT); - mapEntityTypeWithData(Entity1_19Types.WARDEN, Entity1_19Types.IRON_GOLEM).jsonName(); - mapEntityTypeWithData(Entity1_19Types.ALLAY, Entity1_19Types.VEX).jsonName(); + mapEntityTypeWithData(EntityTypes1_19.FROG, EntityTypes1_19.RABBIT).jsonName(); + mapEntityTypeWithData(EntityTypes1_19.TADPOLE, EntityTypes1_19.PUFFERFISH).jsonName(); + mapEntityTypeWithData(EntityTypes1_19.CHEST_BOAT, EntityTypes1_19.BOAT); + mapEntityTypeWithData(EntityTypes1_19.WARDEN, EntityTypes1_19.IRON_GOLEM).jsonName(); + mapEntityTypeWithData(EntityTypes1_19.ALLAY, EntityTypes1_19.VEX).jsonName(); } @Override public EntityType typeFromId(final int typeId) { - return Entity1_19Types.getTypeFromId(typeId); + return EntityTypes1_19.getTypeFromId(typeId); } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java index 299c9450..55965035 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java @@ -31,7 +31,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1 import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.ProfileKey; import com.viaversion.viaversion.api.minecraft.RegistryType; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_3; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; @@ -351,7 +351,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol { + filter().filterFamily(EntityTypes1_19_3.MINECART_ABSTRACT).index(11).handler((event, meta) -> { final int data = (int) meta.getValue(); meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); }); - filter().type(Entity1_19_3Types.CAMEL).cancel(19); // Dashing - filter().type(Entity1_19_3Types.CAMEL).cancel(20); // Last pose change time + filter().type(EntityTypes1_19_3.CAMEL).cancel(19); // Dashing + filter().type(EntityTypes1_19_3.CAMEL).cancel(20); // Last pose change time } @Override public void onMappingDataLoaded() { mapTypes(); - mapEntityTypeWithData(Entity1_19_3Types.CAMEL, Entity1_19_3Types.DONKEY).jsonName(); + mapEntityTypeWithData(EntityTypes1_19_3.CAMEL, EntityTypes1_19_3.DONKEY).jsonName(); } @Override public EntityType typeFromId(final int typeId) { - return Entity1_19_3Types.getTypeFromId(typeId); + return EntityTypes1_19_3.getTypeFromId(typeId); } private static final class PlayerProfileUpdate { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java index 256ea0fd..5890fd55 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java @@ -24,7 +24,7 @@ import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.packets.BlockItemPackets1_19_4; import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.packets.EntityPackets1_19_4; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -117,7 +117,7 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol { + filter().filterFamily(EntityTypes1_19_4.MINECART_ABSTRACT).index(11).handler((event, meta) -> { final int blockState = meta.value(); meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); }); - filter().filterFamily(Entity1_19_4Types.BOAT).index(11).handler((event, meta) -> { + filter().filterFamily(EntityTypes1_19_4.BOAT).index(11).handler((event, meta) -> { final int boatType = meta.value(); if (boatType > 4) { // Cherry meta.setValue(boatType - 1); } }); - filter().type(Entity1_19_4Types.TEXT_DISPLAY).index(22).handler(((event, meta) -> { + filter().type(EntityTypes1_19_4.TEXT_DISPLAY).index(22).handler(((event, meta) -> { // Send as custom display name event.setIndex(2); meta.setMetaType(Types1_19_3.META_TYPES.optionalComponentType); @@ -163,7 +163,7 @@ public final class EntityPackets1_19_4 extends EntityRewriter { + filter().filterFamily(EntityTypes1_19_4.DISPLAY).handler((event, meta) -> { // TODO Maybe spawn an extra entity to ride the armor stand for blocks and items // Remove a large heap of display metadata if (event.index() > 7) { @@ -171,14 +171,14 @@ public final class EntityPackets1_19_4 extends EntityRewriter { + filter().filterFamily(EntityTypes1_19_4.MINECART_ABSTRACT).index(11).handler((event, meta) -> { final int blockState = meta.value(); meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); }); // Rotate item display by 180 degrees around the Y axis - filter().filterFamily(Entity1_19_4Types.ITEM_DISPLAY).handler((event, meta) -> { + filter().filterFamily(EntityTypes1_19_4.ITEM_DISPLAY).handler((event, meta) -> { if (event.trackedEntity().hasSentMetadata() || event.hasExtraMeta()) { return; } @@ -141,7 +141,7 @@ public final class EntityPackets1_20 extends EntityRewriter { + filter().filterFamily(EntityTypes1_19_4.ITEM_DISPLAY).index(12).handler((event, meta) -> { final Quaternion quaternion = meta.value(); meta.setValue(rotateY180(quaternion)); }); @@ -149,7 +149,7 @@ public final class EntityPackets1_20 extends EntityRewriter { +public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol { public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.20.3", "1.20.2", Protocol1_20_3To1_20_2.class); private final EntityPacketRewriter1_20_3 entityRewriter = new EntityPacketRewriter1_20_3(this); - private final ItemPacketRewriter1_20_3 itemRewriter = new ItemPacketRewriter1_20_3(this); + private final BlockItemPacketRewriter1_20_3 itemRewriter = new BlockItemPacketRewriter1_20_3(this); public Protocol1_20_2To1_20_3() { - super(ClientboundPackets1_20_2.class, ClientboundPackets1_20_2.class, ServerboundPackets1_20_2.class, ServerboundPackets1_20_2.class); + super(ClientboundPackets1_20_2.class, ClientboundPackets1_20_2.class, ServerboundPackets1_20_3.class, ServerboundPackets1_20_2.class); } @Override @@ -75,7 +76,7 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol convertComponent(wrapper)); + registerClientbound(ClientboundPackets1_20_2.OPEN_WINDOW, wrapper -> { + wrapper.passthrough(Type.VAR_INT); // Container id + + final int containerTypeId = wrapper.read(Type.VAR_INT); + final int mappedContainerTypeId = MAPPINGS.getMenuMappings().getNewId(containerTypeId); + if (mappedContainerTypeId == -1) { + wrapper.cancel(); + return; } + + wrapper.write(Type.VAR_INT, mappedContainerTypeId); + + convertComponent(wrapper); }); registerClientbound(ClientboundPackets1_20_2.TAB_LIST, wrapper -> { convertComponent(wrapper); @@ -261,7 +268,7 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol. + */ +package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter; + +import com.viaversion.viabackwards.api.rewriters.ItemRewriter; +import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3; +import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2; +import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2; +import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter.RecipeRewriter1_20_2; +import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_20_2; +import com.viaversion.viaversion.rewriter.BlockRewriter; + +public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter { + + public BlockItemPacketRewriter1_20_3(final Protocol1_20_2To1_20_3 protocol) { + super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_ARRAY); + } + + @Override + public void registerPackets() { + final BlockRewriter blockRewriter = BlockRewriter.for1_20_2(protocol); + blockRewriter.registerBlockAction(ClientboundPackets1_20_2.BLOCK_ACTION); + blockRewriter.registerBlockChange(ClientboundPackets1_20_2.BLOCK_CHANGE); + blockRewriter.registerVarLongMultiBlockChange1_20(ClientboundPackets1_20_2.MULTI_BLOCK_CHANGE); + blockRewriter.registerEffect(ClientboundPackets1_20_2.EFFECT, 1010, 2001); + blockRewriter.registerChunkData1_19(ClientboundPackets1_20_2.CHUNK_DATA, ChunkType1_20_2::new); + blockRewriter.registerBlockEntityData(ClientboundPackets1_20_2.BLOCK_ENTITY_DATA); + + registerSetCooldown(ClientboundPackets1_20_2.COOLDOWN); + registerWindowItems1_17_1(ClientboundPackets1_20_2.WINDOW_ITEMS); + registerSetSlot1_17_1(ClientboundPackets1_20_2.SET_SLOT); + registerEntityEquipmentArray(ClientboundPackets1_20_2.ENTITY_EQUIPMENT); + registerClickWindow1_17_1(ServerboundPackets1_20_2.CLICK_WINDOW); + registerTradeList1_19(ClientboundPackets1_20_2.TRADE_LIST); + registerCreativeInvAction(ServerboundPackets1_20_2.CREATIVE_INVENTORY_ACTION); + registerWindowPropertyEnchantmentHandler(ClientboundPackets1_20_2.WINDOW_PROPERTY); + registerSpawnParticle1_19(ClientboundPackets1_20_2.SPAWN_PARTICLE); + + new RecipeRewriter1_20_2<>(protocol).register(ClientboundPackets1_20_2.DECLARE_RECIPES); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/EntityPacketRewriter1_20_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/EntityPacketRewriter1_20_3.java index 48c8d912..ea4884e4 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/EntityPacketRewriter1_20_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/EntityPacketRewriter1_20_3.java @@ -19,11 +19,15 @@ package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter; import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; import com.viaversion.viaversion.api.minecraft.entities.EntityType; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; +import com.viaversion.viaversion.api.protocol.packet.State; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; +import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_20_2; import com.viaversion.viaversion.api.type.types.version.Types1_20_3; +import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundConfigurationPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2; @@ -38,6 +42,42 @@ public final class EntityPacketRewriter1_20_3 extends EntityRewriter { + final int blockState = meta.value(); + meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); + }); + + filter().type(EntityTypes1_19_4.TNT).removeIndex(9); // Block state } @Override public EntityType typeFromId(final int type) { - return Entity1_19_4Types.getTypeFromId(type); + return EntityTypes1_19_4.getTypeFromId(type); } } \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/ItemPacketRewriter1_20_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/ItemPacketRewriter1_20_3.java deleted file mode 100644 index 347dc73d..00000000 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/ItemPacketRewriter1_20_3.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards - * Copyright (C) 2023 ViaVersion and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter; - -import com.viaversion.viabackwards.api.rewriters.ItemRewriter; -import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3; -import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2; -import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2; - -public final class ItemPacketRewriter1_20_3 extends ItemRewriter { - - public ItemPacketRewriter1_20_3(final Protocol1_20_2To1_20_3 protocol) { - super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_VAR_INT_ARRAY); - } - - @Override - public void registerPackets() { - registerSpawnParticle1_19(ClientboundPackets1_20_2.SPAWN_PARTICLE); - } -} \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java index ca1b8c84..7b3cef96 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java @@ -24,7 +24,7 @@ import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.rewriter.BlockI import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.rewriter.EntityPacketRewriter1_20_2; import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.storage.ConfigurationPacketStorage; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4; import com.viaversion.viaversion.api.protocol.packet.Direction; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; @@ -191,7 +191,7 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol { public BlockItemPacketRewriter1_20_2(final Protocol1_20To1_20_2 protocol) { - super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_VAR_INT_ARRAY); + super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_ARRAY); } @Override @@ -128,7 +128,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter { - final Item[] items = wrapper.read(Type.ITEM1_20_2_VAR_INT_ARRAY); + final Item[] items = wrapper.read(Type.ITEM1_20_2_ARRAY); for (final Item item : items) { handleItemToClient(item); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/rewriter/EntityPacketRewriter1_20_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/rewriter/EntityPacketRewriter1_20_2.java index 204ffbd0..68662678 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/rewriter/EntityPacketRewriter1_20_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/rewriter/EntityPacketRewriter1_20_2.java @@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.Protocol1_20To1_20_2; import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.storage.ConfigurationPacketStorage; import com.viaversion.viaversion.api.minecraft.GlobalPosition; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; @@ -53,10 +53,10 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter meta.setMetaType(Types1_20.META_TYPES.byId(meta.metaType().typeId()))); registerMetaTypeHandler(Types1_20.META_TYPES.itemType, Types1_20.META_TYPES.blockStateType, Types1_20.META_TYPES.optionalBlockStateType, Types1_20.META_TYPES.particleType, null, null); - filter().filterFamily(Entity1_19_4Types.DISPLAY).removeIndex(10); + filter().filterFamily(EntityTypes1_19_4.DISPLAY).removeIndex(10); - filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> { + filter().filterFamily(EntityTypes1_19_4.MINECART_ABSTRACT).index(11).handler((event, meta) -> { final int blockState = meta.value(); meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); }); @@ -208,6 +208,6 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter Entity1_11Types.ObjectType.findById(id).orElse(null))); + handler(getObjectRewriter(id -> EntityTypes1_11.ObjectType.findById(id).orElse(null))); // Handle FallingBlock blocks handler(wrapper -> { - Optional type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); - if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) { + Optional type = EntityTypes1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0)); + if (type.isPresent() && type.get() == EntityTypes1_12.ObjectType.FALLING_BLOCK) { int objectData = wrapper.get(Type.INT, 0); int objType = objectData & 4095; int data = objectData >> 12 & 15; @@ -79,8 +79,8 @@ public class EntityPackets1_10 extends LegacyEntityRewriter Standing up) - filter().type(Entity1_10Types.EntityType.POLAR_BEAR).index(13).handler((event, meta) -> { + filter().type(EntityTypes1_10.EntityType.POLAR_BEAR).index(13).handler((event, meta) -> { boolean b = (boolean) meta.getValue(); meta.setTypeAndValue(MetaType1_9.Byte, b ? (byte) (14 & 0x0F) : (byte) (0)); @@ -159,14 +159,14 @@ public class EntityPackets1_10 extends LegacyEntityRewriter Zombie Type) - filter().type(Entity1_10Types.EntityType.ZOMBIE).index(13).handler((event, meta) -> { + filter().type(EntityTypes1_10.EntityType.ZOMBIE).index(13).handler((event, meta) -> { if ((int) meta.getValue() == 6) { // Is type Husk meta.setValue(0); } }); // Handle Stray (index 12 -> Skeleton Type) - filter().type(Entity1_10Types.EntityType.SKELETON).index(12).handler((event, meta) -> { + filter().type(EntityTypes1_10.EntityType.SKELETON).index(12).handler((event, meta) -> { if ((int) meta.getValue() == 2) { meta.setValue(0); // Change to default skeleton } @@ -178,11 +178,11 @@ public class EntityPackets1_10 extends LegacyEntityRewriterq^r2UcMF zx)=?s*|e)iozu3+_*G3hoT{cv$`1$3R6#ndfCqPp^xYCEp2K;y64!7YH*gcokKe`} z+{HcI#{)dXBRs|vJjF9S#|&oi0x!|V9A4oy-rz0X;XOX!BR=6XzThjq;X8idCw}2K z=0!|WFg0{QC#k?&NQw=IiIG(IrT>~CnW(jiuIlYXSM|BLt0{^=b+p|W<*2md$}mB- zqRG*DE-@tS1a>2NWKuJU;HlX-IHlGv;9?w<0j)0_WUIb6=~k1`(w7s_(pTbWIUXLv zUhKmm9L5om^ckFuevIjSRA2dy$v|52vsV~inUU)g6y56we$z-3T zKN)Nw4yKBfjRUDK8G_{1(Q&PY?dL?_Gg6k$a%pFIXn)I^2<#RMjPN)ttSE-vDOK%? z*WzEQYBs%~=z@aRRZ$d_i}(8-0zC;0F~N}d3WiB+q}2B@VxzA> z+jWOB}TCUZVUI>S$?XzA0JTd7Mj(&(2o_JTIWdaYOd?ls!B>jXh}Ag^D^ zSwc9FcNqI`g!b7DCf@sbkK7*iaUgjOJoM+hmWkLOGw#cmxvx}tqHMF~^^waYrVt>C z7^X3UI1-q}9OkirMes3&SjGxgk;EF-k-`Qxkwykv*hUsP6!RPf>|hscAT|&i=nzLZ d#tBYwhI3rt5?8p!4Q_FVB1*{Hx1pvh{Q(k+E~Nkf diff --git a/gradle.properties b/gradle.properties index 3290800f..23c0416b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -projectVersion=4.9.0-23w41a-SNAPSHOT +projectVersion=4.9.0-23w42a-SNAPSHOT # Smile emoji mcVersions=1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 22d72c92..389da106 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ metadata.format.version = "1.1" [versions] # ViaVersion -viaver = "4.9.0-23w41a-SNAPSHOT" +viaver = "4.9.0-23w42a-SNAPSHOT" # Common provided netty = "4.0.20.Final" diff --git a/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To_99.java b/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To_99.java index e291b06a..ce7977b9 100644 --- a/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To_99.java +++ b/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To_99.java @@ -1,5 +1,5 @@ /* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards * Copyright (C) 2023 ViaVersion and contributors * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; import com.viaversion.viabackwards.template.protocol.rewriter.BlockItemPacketRewriter1_99; import com.viaversion.viabackwards.template.protocol.rewriter.EntityPacketRewriter1_99; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -45,7 +45,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; // ServerboundPackets1_20_2 // ClientboundConfigurationPackets1_20_2 // ServerboundConfigurationPackets1_20_2 -// Entity1_19_4Types (UNMAPPED type) +// EntityTypes1_19_4 (UNMAPPED type) // 1.99, 1.98 public final class Protocol1_98To_99 extends BackwardsProtocol { @@ -89,7 +89,7 @@ public final class Protocol1_98To_99 extends BackwardsProtocol { public BlockItemPacketRewriter1_99(final Protocol1_98To_99 protocol) { - super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_VAR_INT_ARRAY); + super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_ARRAY); } @Override public void registerPackets() { - final BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); + final BlockRewriter blockRewriter = BlockRewriter.for1_20_2(protocol); blockRewriter.registerBlockAction(ClientboundPackets1_20_2.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_20_2.BLOCK_CHANGE); blockRewriter.registerVarLongMultiBlockChange1_20(ClientboundPackets1_20_2.MULTI_BLOCK_CHANGE); blockRewriter.registerEffect(ClientboundPackets1_20_2.EFFECT, 1010, 2001); - blockRewriter.registerChunkData1_19(ClientboundPackets1_20_2.CHUNK_DATA, Chunk1_18Type::new); + blockRewriter.registerChunkData1_19(ClientboundPackets1_20_2.CHUNK_DATA, ChunkType1_20_2::new); blockRewriter.registerBlockEntityData(ClientboundPackets1_20_2.BLOCK_ENTITY_DATA); + // registerOpenWindow(ClientboundPackets1_20_2.OPEN_WINDOW); registerSetCooldown(ClientboundPackets1_20_2.COOLDOWN); registerWindowItems1_17_1(ClientboundPackets1_20_2.WINDOW_ITEMS); registerSetSlot1_17_1(ClientboundPackets1_20_2.SET_SLOT); @@ -52,7 +53,7 @@ public final class BlockItemPacketRewriter1_99 extends ItemRewriter { + filter().filterFamily(EntityTypes1_19_4.MINECART_ABSTRACT).index(11).handler((event, meta) -> { final int blockState = meta.value(); meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); }); @@ -116,11 +116,11 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter