diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriter.java index 29238ffd..0d657662 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriter.java @@ -20,17 +20,17 @@ package com.viaversion.viabackwards.api.rewriters; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; -import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_14; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.version.Types1_14; public abstract class EntityRewriter extends EntityRewriterBase { protected EntityRewriter(T protocol) { - this(protocol, MetaType1_14.OptChat, MetaType1_14.Boolean); + this(protocol, Types1_14.META_TYPES.optionalComponentType, Types1_14.META_TYPES.booleanType); } protected EntityRewriter(T protocol, MetaType displayType, MetaType displayVisibilityType) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/packets/EntityPackets1_13_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/packets/EntityPackets1_13_2.java index b452b0b8..bef71a85 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/packets/EntityPackets1_13_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/packets/EntityPackets1_13_2.java @@ -19,8 +19,6 @@ package com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.packets; import com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; -import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13; -import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13_2; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; @@ -54,9 +52,7 @@ public class EntityPackets1_13_2 { @Override public void handle(PacketWrapper wrapper) throws Exception { for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) { - if (metadata.metaType() == MetaType1_13_2.Slot) { - metadata.setMetaType(MetaType1_13.Slot); - } + metadata.setMetaType(Types1_13.META_TYPES.byId(metadata.metaType().typeId())); } } }); @@ -79,9 +75,7 @@ public class EntityPackets1_13_2 { @Override public void handle(PacketWrapper wrapper) throws Exception { for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) { - if (metadata.metaType() == MetaType1_13_2.Slot) { - metadata.setMetaType(MetaType1_13.Slot); - } + metadata.setMetaType(Types1_13.META_TYPES.byId(metadata.metaType().typeId())); } } }); @@ -98,9 +92,7 @@ public class EntityPackets1_13_2 { @Override public void handle(PacketWrapper wrapper) throws Exception { for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) { - if (metadata.metaType() == MetaType1_13_2.Slot) { - metadata.setMetaType(MetaType1_13.Slot); - } + metadata.setMetaType(Types1_13.META_TYPES.byId(metadata.metaType().typeId())); } } }); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java index 8a891334..e5a4aecb 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java @@ -33,12 +33,12 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types; 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.api.minecraft.metadata.types.MetaType1_13_2; 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.api.type.types.version.Types1_13; +import com.viaversion.viaversion.api.type.types.version.Types1_13_2; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; @@ -289,7 +289,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit return; } List metadataList = new ArrayList<>(); - metadataList.add(new Metadata(16, MetaType1_13_2.VarInt, armorType)); + metadataList.add(new Metadata(16, Types1_13_2.META_TYPES.varIntType, armorType)); wrapper.write(Types1_13.METADATA_LIST, metadataList); } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java index 7ce687f5..8214fe04 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java @@ -25,7 +25,6 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2T import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage; import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositionStorage1_14; import com.viaversion.viaversion.api.data.entity.EntityTracker; -import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.VillagerData; import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; @@ -34,7 +33,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType; 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_13_2; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; @@ -52,7 +50,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { int typeId = meta.metaType().typeId(); if (typeId <= 15) { - meta.setMetaType(MetaType1_13_2.byId(typeId)); + meta.setMetaType(Types1_13_2.META_TYPES.byId(typeId)); } MetaType type = meta.metaType(); - if (type == MetaType1_13_2.Slot) { + if (type == Types1_13_2.META_TYPES.itemType) { Item item = (Item) meta.getValue(); meta.setValue(protocol.getItemRewriter().handleItemToClient(item)); - } else if (type == MetaType1_13_2.BlockID) { + } else if (type == Types1_13_2.META_TYPES.blockStateType) { int blockstate = (Integer) meta.getValue(); meta.setValue(protocol.getMappingData().getNewBlockStateId(blockstate)); } @@ -415,7 +413,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { - meta.setMetaType(MetaType1_13_2.VarInt); + meta.setMetaType(Types1_13_2.META_TYPES.varIntType); Integer value = (Integer) meta.getValue(); if (value == null) { meta.setValue(0); @@ -428,7 +426,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { VillagerData villagerData = (VillagerData) meta.getValue(); - meta.setTypeAndValue(MetaType1_13_2.VarInt, villagerDataToProfession(villagerData)); + meta.setTypeAndValue(Types1_13_2.META_TYPES.varIntType, villagerDataToProfession(villagerData)); if (meta.id() == 16) { event.setIndex(15); // decreased by 2 again in one of the following handlers } @@ -441,13 +439,13 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { byte value = (byte) meta.getValue(); if ((value & 4) != 0) { - event.createExtraMeta(new Metadata(14, MetaType1_13_2.Boolean, true)); + event.createExtraMeta(new Metadata(14, Types1_13_2.META_TYPES.booleanType, true)); } }); filter().filterFamily(Entity1_14Types.ZOMBIE).index(13).handler((event, meta) -> { byte value = (byte) meta.getValue(); if ((value & 4) != 0) { - event.createExtraMeta(new Metadata(16, MetaType1_13_2.Boolean, true)); + event.createExtraMeta(new Metadata(16, Types1_13_2.META_TYPES.booleanType, true)); } }); @@ -482,7 +480,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { event.setIndex(15); - meta.setTypeAndValue(MetaType1_13_2.VarInt, 0); + meta.setTypeAndValue(Types1_13_2.META_TYPES.varIntType, 0); }); filter().type(Entity1_14Types.CAT).handler((event, meta) -> { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java index e74c23e5..f5c1b32f 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java @@ -24,7 +24,6 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; 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.api.minecraft.metadata.types.MetaType1_13; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; @@ -141,13 +140,13 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter { - if (meta.metaType() == MetaType1_13.Slot) { + if (meta.metaType() == Types1_13.META_TYPES.itemType) { protocol.getItemRewriter().handleItemToClient((Item) meta.getValue()); - } else if (meta.metaType() == MetaType1_13.BlockID) { + } else if (meta.metaType() == Types1_13.META_TYPES.blockStateType) { // Convert to new block id int data = (int) meta.getValue(); meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); - } else if (meta.metaType() == MetaType1_13.PARTICLE) { + } else if (meta.metaType() == Types1_13.META_TYPES.particleType) { rewriteParticle((Particle) meta.getValue()); } }); 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 e48b4017..78a242f3 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 @@ -24,7 +24,6 @@ import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateR import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types; 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_14; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; @@ -199,7 +198,7 @@ public class EntityPackets1_15 extends EntityRewriter { @Override protected void registerRewrites() { - registerMetaTypeHandler(MetaType1_14.Slot, MetaType1_14.BlockID, MetaType1_14.PARTICLE, null); + registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, Types1_14.META_TYPES.particleType, null); filter().filterFamily(Entity1_15Types.LIVINGENTITY).removeIndex(12); @@ -207,8 +206,8 @@ public class EntityPackets1_15 extends EntityRewriter { filter().type(Entity1_15Types.BEE).cancel(16); mapEntityTypeWithData(Entity1_15Types.BEE, Entity1_15Types.PUFFERFISH).jsonName("Bee").spawnMetadata(storage -> { - storage.add(new Metadata(14, MetaType1_14.Boolean, false)); - storage.add(new Metadata(15, MetaType1_14.VarInt, 2)); + 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); @@ -217,7 +216,7 @@ public class EntityPackets1_15 extends EntityRewriter { // Redundant health removed in 1.15 filter().type(Entity1_15Types.WOLF).addIndex(17); filter().type(Entity1_15Types.WOLF).index(8).handler((event, meta) -> { - event.createExtraMeta(new Metadata(17/*WOLF_HEALTH*/, MetaType1_14.Float, event.meta().value())); + event.createExtraMeta(new Metadata(17/*WOLF_HEALTH*/, Types1_14.META_TYPES.floatType, event.meta().value())); }); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java index 7af522ae..49ba0eda 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java @@ -29,7 +29,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType; 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_14; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; @@ -251,16 +250,16 @@ public class EntityPackets1_16 extends EntityRewriter { @Override protected void registerRewrites() { filter().handler((event, meta) -> { - meta.setMetaType(MetaType1_14.byId(meta.metaType().typeId())); + meta.setMetaType(Types1_14.META_TYPES.byId(meta.metaType().typeId())); MetaType type = meta.metaType(); - if (type == MetaType1_14.Slot) { + if (type == Types1_14.META_TYPES.itemType) { meta.setValue(protocol.getItemRewriter().handleItemToClient((Item) meta.getValue())); - } else if (type == MetaType1_14.BlockID) { + } else if (type == Types1_14.META_TYPES.blockStateType) { meta.setValue(protocol.getMappingData().getNewBlockStateId((int) meta.getValue())); - } else if (type == MetaType1_14.PARTICLE) { + } else if (type == Types1_14.META_TYPES.particleType) { rewriteParticle((Particle) meta.getValue()); - } else if (type == MetaType1_14.OptChat) { + } else if (type == Types1_14.META_TYPES.optionalComponentType) { JsonElement text = meta.value(); if (text != null) { protocol.getTranslatableRewriter().processText(text); @@ -285,7 +284,7 @@ public class EntityPackets1_16 extends EntityRewriter { filter().type(Entity1_16Types.STRIDER).index(15).handler((event, meta) -> { boolean baby = meta.value(); - meta.setTypeAndValue(MetaType1_14.VarInt, baby ? 1 : 3); + meta.setTypeAndValue(Types1_14.META_TYPES.varIntType, baby ? 1 : 3); }); filter().type(Entity1_16Types.STRIDER).cancel(16); filter().type(Entity1_16Types.STRIDER).cancel(17); @@ -318,7 +317,7 @@ public class EntityPackets1_16 extends EntityRewriter { int angerTime = meta.value(); byte tameableMask = (byte) (angerTime > 0 ? previousMask | 2 : previousMask & -3); - event.createExtraMeta(new Metadata(16, MetaType1_14.Byte, tameableMask)); + event.createExtraMeta(new Metadata(16, Types1_14.META_TYPES.byteType, tameableMask)); event.cancel(); }); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java index 28c906c7..a3d57d54 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java @@ -23,7 +23,6 @@ import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_ import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types; import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types; import com.viaversion.viaversion.api.minecraft.entities.EntityType; -import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_16; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_16; @@ -104,7 +103,8 @@ public class EntityPackets1_16_2 extends EntityRewriter @Override protected void registerRewrites() { - registerMetaTypeHandler(MetaType1_16.ITEM, MetaType1_16.BLOCK_STATE, MetaType1_16.PARTICLE, MetaType1_16.OPT_COMPONENT); + registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, + Types1_16.META_TYPES.particleType, Types1_16.META_TYPES.optionalComponentType); mapTypes(Entity1_16_2Types.values(), Entity1_16Types.class); mapEntityTypeWithData(Entity1_16_2Types.PIGLIN_BRUTE, Entity1_16_2Types.PIGLIN).jsonName("Piglin Brute"); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java index e979ae3e..60aaf251 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java @@ -24,7 +24,6 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types; import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; -import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_16; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.Particle; @@ -155,10 +154,10 @@ public final class EntityPackets1_17 extends EntityRewriter { - meta.setMetaType(MetaType1_16.byId(meta.metaType().typeId())); + meta.setMetaType(Types1_16.META_TYPES.byId(meta.metaType().typeId())); MetaType type = meta.metaType(); - if (type == MetaType1_16.PARTICLE) { + if (type == Types1_16.META_TYPES.particleType) { Particle particle = (Particle) meta.getValue(); if (particle.getId() == 15) { // Dust / Dust Transition // Remove transition target color values 4-6 @@ -171,7 +170,7 @@ public final class EntityPackets1_17 extends EntityRewriter { - meta.setMetaType(MetaType1_17.byId(meta.metaType().typeId())); + meta.setMetaType(Types1_17.META_TYPES.byId(meta.metaType().typeId())); MetaType type = meta.metaType(); - if (type == MetaType1_17.PARTICLE) { + if (type == Types1_17.META_TYPES.particleType) { Particle particle = (Particle) meta.getValue(); if (particle.getId() == 3) { // Block marker Particle.ParticleData data = particle.getArguments().remove(0); @@ -128,7 +127,7 @@ public final class EntityPackets1_18 extends EntityRewriter