diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataKey.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataKey.java index 499a245da..e8edcb937 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataKey.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataKey.java @@ -48,40 +48,41 @@ import com.viaversion.viaversion.api.minecraft.item.data.ToolProperties; import com.viaversion.viaversion.api.minecraft.item.data.Unbreakable; import com.viaversion.viaversion.api.minecraft.item.data.WrittenBook; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.util.Unit; public record StructuredDataKey(String identifier, Type type) { - public static final StructuredDataKey CUSTOM_DATA = new StructuredDataKey<>("custom_data", Type.COMPOUND_TAG); - public static final StructuredDataKey MAX_STACK_SIZE = new StructuredDataKey<>("max_stack_size", Type.VAR_INT); - public static final StructuredDataKey MAX_DAMAGE = new StructuredDataKey<>("max_damage", Type.VAR_INT); - public static final StructuredDataKey DAMAGE = new StructuredDataKey<>("damage", Type.VAR_INT); + public static final StructuredDataKey CUSTOM_DATA = new StructuredDataKey<>("custom_data", Types.COMPOUND_TAG); + public static final StructuredDataKey MAX_STACK_SIZE = new StructuredDataKey<>("max_stack_size", Types.VAR_INT); + public static final StructuredDataKey MAX_DAMAGE = new StructuredDataKey<>("max_damage", Types.VAR_INT); + public static final StructuredDataKey DAMAGE = new StructuredDataKey<>("damage", Types.VAR_INT); public static final StructuredDataKey UNBREAKABLE = new StructuredDataKey<>("unbreakable", Unbreakable.TYPE); - public static final StructuredDataKey CUSTOM_NAME = new StructuredDataKey<>("custom_name", Type.TAG); - public static final StructuredDataKey ITEM_NAME = new StructuredDataKey<>("item_name", Type.TAG); - public static final StructuredDataKey LORE = new StructuredDataKey<>("lore", Type.TAG_ARRAY); - public static final StructuredDataKey RARITY = new StructuredDataKey<>("rarity", Type.VAR_INT); + public static final StructuredDataKey CUSTOM_NAME = new StructuredDataKey<>("custom_name", Types.TAG); + public static final StructuredDataKey ITEM_NAME = new StructuredDataKey<>("item_name", Types.TAG); + public static final StructuredDataKey LORE = new StructuredDataKey<>("lore", Types.TAG_ARRAY); + public static final StructuredDataKey RARITY = new StructuredDataKey<>("rarity", Types.VAR_INT); public static final StructuredDataKey ENCHANTMENTS = new StructuredDataKey<>("enchantments", Enchantments.TYPE); public static final StructuredDataKey CAN_PLACE_ON = new StructuredDataKey<>("can_place_on", AdventureModePredicate.TYPE); public static final StructuredDataKey CAN_BREAK = new StructuredDataKey<>("can_break", AdventureModePredicate.TYPE); public static final StructuredDataKey ATTRIBUTE_MODIFIERS = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers.TYPE); - public static final StructuredDataKey CUSTOM_MODEL_DATA = new StructuredDataKey<>("custom_model_data", Type.VAR_INT); - public static final StructuredDataKey HIDE_ADDITIONAL_TOOLTIP = new StructuredDataKey<>("hide_additional_tooltip", Type.EMPTY); - public static final StructuredDataKey HIDE_TOOLTIP = new StructuredDataKey<>("hide_tooltip", Type.EMPTY); - public static final StructuredDataKey REPAIR_COST = new StructuredDataKey<>("repair_cost", Type.VAR_INT); - public static final StructuredDataKey CREATIVE_SLOT_LOCK = new StructuredDataKey<>("creative_slot_lock", Type.EMPTY); - public static final StructuredDataKey ENCHANTMENT_GLINT_OVERRIDE = new StructuredDataKey<>("enchantment_glint_override", Type.BOOLEAN); - public static final StructuredDataKey INTANGIBLE_PROJECTILE = new StructuredDataKey<>("intangible_projectile", Type.TAG); // Doesn't actually hold data + public static final StructuredDataKey CUSTOM_MODEL_DATA = new StructuredDataKey<>("custom_model_data", Types.VAR_INT); + public static final StructuredDataKey HIDE_ADDITIONAL_TOOLTIP = new StructuredDataKey<>("hide_additional_tooltip", Types.EMPTY); + public static final StructuredDataKey HIDE_TOOLTIP = new StructuredDataKey<>("hide_tooltip", Types.EMPTY); + public static final StructuredDataKey REPAIR_COST = new StructuredDataKey<>("repair_cost", Types.VAR_INT); + public static final StructuredDataKey CREATIVE_SLOT_LOCK = new StructuredDataKey<>("creative_slot_lock", Types.EMPTY); + public static final StructuredDataKey ENCHANTMENT_GLINT_OVERRIDE = new StructuredDataKey<>("enchantment_glint_override", Types.BOOLEAN); + public static final StructuredDataKey INTANGIBLE_PROJECTILE = new StructuredDataKey<>("intangible_projectile", Types.TAG); // Doesn't actually hold data public static final StructuredDataKey FOOD = new StructuredDataKey<>("food", FoodProperties.TYPE); - public static final StructuredDataKey FIRE_RESISTANT = new StructuredDataKey<>("fire_resistant", Type.EMPTY); + public static final StructuredDataKey FIRE_RESISTANT = new StructuredDataKey<>("fire_resistant", Types.EMPTY); public static final StructuredDataKey TOOL = new StructuredDataKey<>("tool", ToolProperties.TYPE); public static final StructuredDataKey STORED_ENCHANTMENTS = new StructuredDataKey<>("stored_enchantments", Enchantments.TYPE); public static final StructuredDataKey DYED_COLOR = new StructuredDataKey<>("dyed_color", DyedColor.TYPE); - public static final StructuredDataKey MAP_COLOR = new StructuredDataKey<>("map_color", Type.INT); - public static final StructuredDataKey MAP_ID = new StructuredDataKey<>("map_id", Type.VAR_INT); - public static final StructuredDataKey MAP_DECORATIONS = new StructuredDataKey<>("map_decorations", Type.COMPOUND_TAG); - public static final StructuredDataKey MAP_POST_PROCESSING = new StructuredDataKey<>("map_post_processing", Type.VAR_INT); + public static final StructuredDataKey MAP_COLOR = new StructuredDataKey<>("map_color", Types.INT); + public static final StructuredDataKey MAP_ID = new StructuredDataKey<>("map_id", Types.VAR_INT); + public static final StructuredDataKey MAP_DECORATIONS = new StructuredDataKey<>("map_decorations", Types.COMPOUND_TAG); + public static final StructuredDataKey MAP_POST_PROCESSING = new StructuredDataKey<>("map_post_processing", Types.VAR_INT); public static final StructuredDataKey CHARGED_PROJECTILES = new StructuredDataKey<>("charged_projectiles", Types1_20_5.ITEM_ARRAY); public static final StructuredDataKey BUNDLE_CONTENTS = new StructuredDataKey<>("bundle_contents", Types1_20_5.ITEM_ARRAY); public static final StructuredDataKey POTION_CONTENTS = new StructuredDataKey<>("potion_contents", PotionContents.TYPE); @@ -89,26 +90,26 @@ public record StructuredDataKey(String identifier, Type type) { public static final StructuredDataKey WRITABLE_BOOK_CONTENT = new StructuredDataKey<>("writable_book_content", FilterableString.ARRAY_TYPE); public static final StructuredDataKey WRITTEN_BOOK_CONTENT = new StructuredDataKey<>("written_book_content", WrittenBook.TYPE); public static final StructuredDataKey TRIM = new StructuredDataKey<>("trim", ArmorTrim.TYPE); - public static final StructuredDataKey DEBUG_STICK_STATE = new StructuredDataKey<>("debug_stick_state", Type.COMPOUND_TAG); - public static final StructuredDataKey ENTITY_DATA = new StructuredDataKey<>("entity_data", Type.COMPOUND_TAG); - public static final StructuredDataKey BUCKET_ENTITY_DATA = new StructuredDataKey<>("bucket_entity_data", Type.COMPOUND_TAG); - public static final StructuredDataKey BLOCK_ENTITY_DATA = new StructuredDataKey<>("block_entity_data", Type.COMPOUND_TAG); + public static final StructuredDataKey DEBUG_STICK_STATE = new StructuredDataKey<>("debug_stick_state", Types.COMPOUND_TAG); + public static final StructuredDataKey ENTITY_DATA = new StructuredDataKey<>("entity_data", Types.COMPOUND_TAG); + public static final StructuredDataKey BUCKET_ENTITY_DATA = new StructuredDataKey<>("bucket_entity_data", Types.COMPOUND_TAG); + public static final StructuredDataKey BLOCK_ENTITY_DATA = new StructuredDataKey<>("block_entity_data", Types.COMPOUND_TAG); public static final StructuredDataKey> INSTRUMENT = new StructuredDataKey<>("instrument", Instrument.TYPE); - public static final StructuredDataKey OMINOUS_BOTTLE_AMPLIFIER = new StructuredDataKey<>("ominous_bottle_amplifier", Type.VAR_INT); - public static final StructuredDataKey RECIPES = new StructuredDataKey<>("recipes", Type.TAG); + public static final StructuredDataKey OMINOUS_BOTTLE_AMPLIFIER = new StructuredDataKey<>("ominous_bottle_amplifier", Types.VAR_INT); + public static final StructuredDataKey RECIPES = new StructuredDataKey<>("recipes", Types.TAG); public static final StructuredDataKey LODESTONE_TRACKER = new StructuredDataKey<>("lodestone_tracker", LodestoneTracker.TYPE); public static final StructuredDataKey FIREWORK_EXPLOSION = new StructuredDataKey<>("firework_explosion", FireworkExplosion.TYPE); public static final StructuredDataKey FIREWORKS = new StructuredDataKey<>("fireworks", Fireworks.TYPE); - public static final StructuredDataKey PROFILE = new StructuredDataKey<>("profile", Type.GAME_PROFILE); - public static final StructuredDataKey NOTE_BLOCK_SOUND = new StructuredDataKey<>("note_block_sound", Type.STRING); + public static final StructuredDataKey PROFILE = new StructuredDataKey<>("profile", Types.GAME_PROFILE); + public static final StructuredDataKey NOTE_BLOCK_SOUND = new StructuredDataKey<>("note_block_sound", Types.STRING); public static final StructuredDataKey BANNER_PATTERNS = new StructuredDataKey<>("banner_patterns", BannerPatternLayer.ARRAY_TYPE); - public static final StructuredDataKey BASE_COLOR = new StructuredDataKey<>("base_color", Type.VAR_INT); + public static final StructuredDataKey BASE_COLOR = new StructuredDataKey<>("base_color", Types.VAR_INT); public static final StructuredDataKey POT_DECORATIONS = new StructuredDataKey<>("pot_decorations", PotDecorations.TYPE); public static final StructuredDataKey CONTAINER = new StructuredDataKey<>("container", Types1_20_5.ITEM_ARRAY); public static final StructuredDataKey BLOCK_STATE = new StructuredDataKey<>("block_state", BlockStateProperties.TYPE); public static final StructuredDataKey BEES = new StructuredDataKey<>("bees", Bee.ARRAY_TYPE); - public static final StructuredDataKey LOCK = new StructuredDataKey<>("lock", Type.TAG); - public static final StructuredDataKey CONTAINER_LOOT = new StructuredDataKey<>("container_loot", Type.COMPOUND_TAG); + public static final StructuredDataKey LOCK = new StructuredDataKey<>("lock", Types.TAG); + public static final StructuredDataKey CONTAINER_LOOT = new StructuredDataKey<>("container_loot", Types.COMPOUND_TAG); @Override public String toString() { diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ArmorTrimMaterial.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ArmorTrimMaterial.java index d3f554aca..02d5dafec 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ArmorTrimMaterial.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ArmorTrimMaterial.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.nbt.tag.Tag; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.HolderType; import io.netty.buffer.ByteBuf; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; @@ -35,35 +36,35 @@ public record ArmorTrimMaterial(String assetName, int itemId, float itemModelInd public static final HolderType TYPE = new HolderType<>() { @Override public ArmorTrimMaterial readDirect(final ByteBuf buffer) { - final String assetName = Type.STRING.read(buffer); - final int item = Type.VAR_INT.readPrimitive(buffer); + final String assetName = Types.STRING.read(buffer); + final int item = Types.VAR_INT.readPrimitive(buffer); final float itemModelIndex = buffer.readFloat(); - final int overrideArmorMaterialsSize = Type.VAR_INT.readPrimitive(buffer); + final int overrideArmorMaterialsSize = Types.VAR_INT.readPrimitive(buffer); final Int2ObjectMap overrideArmorMaterials = new Int2ObjectOpenHashMap<>(overrideArmorMaterialsSize); for (int i = 0; i < overrideArmorMaterialsSize; i++) { - final int key = Type.VAR_INT.readPrimitive(buffer); - final String value = Type.STRING.read(buffer); + final int key = Types.VAR_INT.readPrimitive(buffer); + final String value = Types.STRING.read(buffer); overrideArmorMaterials.put(key, value); } - final Tag description = Type.TAG.read(buffer); + final Tag description = Types.TAG.read(buffer); return new ArmorTrimMaterial(assetName, item, itemModelIndex, overrideArmorMaterials, description); } @Override public void writeDirect(final ByteBuf buffer, final ArmorTrimMaterial value) { - Type.STRING.write(buffer, value.assetName()); - Type.VAR_INT.writePrimitive(buffer, value.itemId()); + Types.STRING.write(buffer, value.assetName()); + Types.VAR_INT.writePrimitive(buffer, value.itemId()); buffer.writeFloat(value.itemModelIndex()); - Type.VAR_INT.writePrimitive(buffer, value.overrideArmorMaterials().size()); + Types.VAR_INT.writePrimitive(buffer, value.overrideArmorMaterials().size()); for (final Int2ObjectMap.Entry entry : value.overrideArmorMaterials().int2ObjectEntrySet()) { - Type.VAR_INT.writePrimitive(buffer, entry.getIntKey()); - Type.STRING.write(buffer, entry.getValue()); + Types.VAR_INT.writePrimitive(buffer, entry.getIntKey()); + Types.STRING.write(buffer, entry.getValue()); } - Type.TAG.write(buffer, value.description()); + Types.TAG.write(buffer, value.description()); } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ArmorTrimPattern.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ArmorTrimPattern.java index f13fc1516..193b2c746 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ArmorTrimPattern.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ArmorTrimPattern.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.nbt.tag.Tag; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.HolderType; import io.netty.buffer.ByteBuf; @@ -32,18 +33,18 @@ public record ArmorTrimPattern(String assetName, int itemId, Tag description, bo public static final HolderType TYPE = new HolderType<>() { @Override public ArmorTrimPattern readDirect(final ByteBuf buffer) { - final String assetName = Type.STRING.read(buffer); - final int itemId = Type.VAR_INT.readPrimitive(buffer); - final Tag description = Type.TAG.read(buffer); + final String assetName = Types.STRING.read(buffer); + final int itemId = Types.VAR_INT.readPrimitive(buffer); + final Tag description = Types.TAG.read(buffer); final boolean decal = buffer.readBoolean(); return new ArmorTrimPattern(assetName, itemId, description, decal); } @Override public void writeDirect(final ByteBuf buffer, final ArmorTrimPattern value) { - Type.STRING.write(buffer, value.assetName()); - Type.VAR_INT.writePrimitive(buffer, value.itemId()); - Type.TAG.write(buffer, value.description()); + Types.STRING.write(buffer, value.assetName()); + Types.VAR_INT.writePrimitive(buffer, value.itemId()); + Types.TAG.write(buffer, value.description()); buffer.writeBoolean(value.decal()); } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/AttributeModifier.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/AttributeModifier.java index 53ef3ee45..b6f9dfd48 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/AttributeModifier.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/AttributeModifier.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import io.netty.buffer.ByteBuf; @@ -31,17 +32,17 @@ public record AttributeModifier(int attribute, ModifierData modifier, int slotTy public static final Type TYPE = new Type<>(AttributeModifier.class) { @Override public AttributeModifier read(final ByteBuf buffer) { - final int attribute = Type.VAR_INT.readPrimitive(buffer); + final int attribute = Types.VAR_INT.readPrimitive(buffer); final ModifierData modifier = ModifierData.TYPE.read(buffer); - final int slot = Type.VAR_INT.readPrimitive(buffer); + final int slot = Types.VAR_INT.readPrimitive(buffer); return new AttributeModifier(attribute, modifier, slot); } @Override public void write(final ByteBuf buffer, final AttributeModifier value) { - Type.VAR_INT.writePrimitive(buffer, value.attribute); + Types.VAR_INT.writePrimitive(buffer, value.attribute); ModifierData.TYPE.write(buffer, value.modifier); - Type.VAR_INT.writePrimitive(buffer, value.slotType); + Types.VAR_INT.writePrimitive(buffer, value.slotType); } }; public static final Type ARRAY_TYPE = new ArrayType<>(TYPE); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPattern.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPattern.java index b80184c93..8ffe72c58 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPattern.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPattern.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.HolderType; import io.netty.buffer.ByteBuf; @@ -31,15 +32,15 @@ public record BannerPattern(String assetId, String translationKey) { public static final HolderType TYPE = new HolderType<>() { @Override public BannerPattern readDirect(final ByteBuf buffer) { - final String assetId = Type.STRING.read(buffer); - final String translationKey = Type.STRING.read(buffer); + final String assetId = Types.STRING.read(buffer); + final String translationKey = Types.STRING.read(buffer); return new BannerPattern(assetId, translationKey); } @Override public void writeDirect(final ByteBuf buffer, final BannerPattern value) { - Type.STRING.write(buffer, value.assetId); - Type.STRING.write(buffer, value.translationKey); + Types.STRING.write(buffer, value.assetId); + Types.STRING.write(buffer, value.translationKey); } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPatternLayer.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPatternLayer.java index 2468b2c29..e2fb4f95b 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPatternLayer.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPatternLayer.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.minecraft.Holder; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import io.netty.buffer.ByteBuf; @@ -33,14 +34,14 @@ public record BannerPatternLayer(Holder pattern, int dyeColor) { @Override public BannerPatternLayer read(final ByteBuf buffer) { final Holder pattern = BannerPattern.TYPE.read(buffer); - final int color = Type.VAR_INT.readPrimitive(buffer); + final int color = Types.VAR_INT.readPrimitive(buffer); return new BannerPatternLayer(pattern, color); } @Override public void write(final ByteBuf buffer, final BannerPatternLayer value) { BannerPattern.TYPE.write(buffer, value.pattern); - Type.VAR_INT.writePrimitive(buffer, value.dyeColor); + Types.VAR_INT.writePrimitive(buffer, value.dyeColor); } }; public static final Type ARRAY_TYPE = new ArrayType<>(TYPE); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Bee.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Bee.java index a4a62fa2a..963f1fea3 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Bee.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Bee.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import io.netty.buffer.ByteBuf; @@ -32,17 +33,17 @@ public record Bee(CompoundTag entityData, int ticksInHive, int minTicksInHive) { public static final Type TYPE = new Type<>(Bee.class) { @Override public Bee read(final ByteBuf buffer) { - final CompoundTag entityData = Type.COMPOUND_TAG.read(buffer); - final int ticksInHive = Type.VAR_INT.readPrimitive(buffer); - final int minTicksInHive = Type.VAR_INT.readPrimitive(buffer); + final CompoundTag entityData = Types.COMPOUND_TAG.read(buffer); + final int ticksInHive = Types.VAR_INT.readPrimitive(buffer); + final int minTicksInHive = Types.VAR_INT.readPrimitive(buffer); return new Bee(entityData, ticksInHive, minTicksInHive); } @Override public void write(final ByteBuf buffer, final Bee value) { - Type.COMPOUND_TAG.write(buffer, value.entityData); - Type.VAR_INT.writePrimitive(buffer, value.ticksInHive); - Type.VAR_INT.writePrimitive(buffer, value.minTicksInHive); + Types.COMPOUND_TAG.write(buffer, value.entityData); + Types.VAR_INT.writePrimitive(buffer, value.ticksInHive); + Types.VAR_INT.writePrimitive(buffer, value.minTicksInHive); } }; public static final Type ARRAY_TYPE = new ArrayType<>(TYPE); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BlockPredicate.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BlockPredicate.java index 77fad4bf2..9d4a23891 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BlockPredicate.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BlockPredicate.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viaversion.api.minecraft.HolderSet; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -35,22 +36,22 @@ public record BlockPredicate(@Nullable HolderSet holderSet, StatePropertyMatcher public static final Type TYPE = new Type<>(BlockPredicate.class) { @Override public BlockPredicate read(final ByteBuf buffer) { - final HolderSet holders = Type.OPTIONAL_HOLDER_SET.read(buffer); + final HolderSet holders = Types.OPTIONAL_HOLDER_SET.read(buffer); final StatePropertyMatcher[] propertyMatchers = buffer.readBoolean() ? StatePropertyMatcher.ARRAY_TYPE.read(buffer) : null; - final CompoundTag tag = Type.OPTIONAL_COMPOUND_TAG.read(buffer); + final CompoundTag tag = Types.OPTIONAL_COMPOUND_TAG.read(buffer); return new BlockPredicate(holders, propertyMatchers, tag); } @Override public void write(final ByteBuf buffer, final BlockPredicate value) { - Type.OPTIONAL_HOLDER_SET.write(buffer, value.holderSet); + Types.OPTIONAL_HOLDER_SET.write(buffer, value.holderSet); buffer.writeBoolean(value.propertyMatchers != null); if (value.propertyMatchers != null) { StatePropertyMatcher.ARRAY_TYPE.write(buffer, value.propertyMatchers); } - Type.OPTIONAL_COMPOUND_TAG.write(buffer, value.tag); + Types.OPTIONAL_COMPOUND_TAG.write(buffer, value.tag); } }; public static final Type ARRAY_TYPE = new ArrayType<>(TYPE); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BlockStateProperties.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BlockStateProperties.java index aa02b5f88..4bbd1f757 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BlockStateProperties.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BlockStateProperties.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import java.util.Map; @@ -32,20 +33,20 @@ public record BlockStateProperties(Map properties) { public static final Type TYPE = new Type<>(BlockStateProperties.class) { @Override public BlockStateProperties read(final ByteBuf buffer) { - final int size = Type.VAR_INT.readPrimitive(buffer); + final int size = Types.VAR_INT.readPrimitive(buffer); final Map properties = new Object2ObjectOpenHashMap<>(size); for (int i = 0; i < size; i++) { - properties.put(Type.STRING.read(buffer), Type.STRING.read(buffer)); + properties.put(Types.STRING.read(buffer), Types.STRING.read(buffer)); } return new BlockStateProperties(properties); } @Override public void write(final ByteBuf buffer, final BlockStateProperties value) { - Type.VAR_INT.writePrimitive(buffer, value.properties.size()); + Types.VAR_INT.writePrimitive(buffer, value.properties.size()); for (final Map.Entry entry : value.properties.entrySet()) { - Type.STRING.write(buffer, entry.getKey()); - Type.STRING.write(buffer, entry.getValue()); + Types.STRING.write(buffer, entry.getKey()); + Types.STRING.write(buffer, entry.getValue()); } } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Enchantments.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Enchantments.java index 1a5044cb4..a0caa205c 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Enchantments.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Enchantments.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import it.unimi.dsi.fastutil.ints.Int2IntMap; import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; @@ -33,10 +34,10 @@ public record Enchantments(Int2IntMap enchantments, boolean showInTooltip) { @Override public Enchantments read(final ByteBuf buffer) { final Int2IntMap enchantments = new Int2IntOpenHashMap(); - final int size = Type.VAR_INT.readPrimitive(buffer); + final int size = Types.VAR_INT.readPrimitive(buffer); for (int i = 0; i < size; i++) { - final int id = Type.VAR_INT.readPrimitive(buffer); - final int level = Type.VAR_INT.readPrimitive(buffer); + final int id = Types.VAR_INT.readPrimitive(buffer); + final int level = Types.VAR_INT.readPrimitive(buffer); enchantments.put(id, level); } @@ -45,10 +46,10 @@ public record Enchantments(Int2IntMap enchantments, boolean showInTooltip) { @Override public void write(final ByteBuf buffer, final Enchantments value) { - Type.VAR_INT.writePrimitive(buffer, value.enchantments.size()); + Types.VAR_INT.writePrimitive(buffer, value.enchantments.size()); for (final Int2IntMap.Entry entry : value.enchantments.int2IntEntrySet()) { - Type.VAR_INT.writePrimitive(buffer, entry.getIntKey()); - Type.VAR_INT.writePrimitive(buffer, entry.getIntValue()); + Types.VAR_INT.writePrimitive(buffer, entry.getIntKey()); + Types.VAR_INT.writePrimitive(buffer, entry.getIntValue()); } buffer.writeBoolean(value.showInTooltip()); } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FilterableComponent.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FilterableComponent.java index cd89e73bc..c0b2754aa 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FilterableComponent.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FilterableComponent.java @@ -24,12 +24,13 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.nbt.tag.Tag; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import org.checkerframework.checker.nullness.qual.Nullable; public final class FilterableComponent extends Filterable { - public static final Type TYPE = new FilterableType<>(Type.TAG, Type.OPTIONAL_TAG, FilterableComponent.class) { + public static final Type TYPE = new FilterableType<>(Types.TAG, Types.OPTIONAL_TAG, FilterableComponent.class) { @Override protected FilterableComponent create(final Tag raw, final Tag filtered) { return new FilterableComponent(raw, filtered); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FilterableString.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FilterableString.java index 51e945d79..c90ee6e4a 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FilterableString.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FilterableString.java @@ -23,12 +23,13 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import org.checkerframework.checker.nullness.qual.Nullable; public final class FilterableString extends Filterable { - public static final Type TYPE = new FilterableType<>(Type.STRING, Type.OPTIONAL_STRING, FilterableString.class) { + public static final Type TYPE = new FilterableType<>(Types.STRING, Types.OPTIONAL_STRING, FilterableString.class) { @Override protected FilterableString create(final String raw, final String filtered) { return new FilterableString(raw, filtered); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FireworkExplosion.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FireworkExplosion.java index 789871c8c..926bfaaec 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FireworkExplosion.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FireworkExplosion.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import io.netty.buffer.ByteBuf; @@ -30,9 +31,9 @@ public record FireworkExplosion(int shape, int[] colors, int[] fadeColors, boole public static final Type TYPE = new Type<>(FireworkExplosion.class) { @Override public FireworkExplosion read(final ByteBuf buffer) { - final int shape = Type.VAR_INT.readPrimitive(buffer); - final int[] colors = Type.INT_ARRAY_PRIMITIVE.read(buffer); - final int[] fadeColors = Type.INT_ARRAY_PRIMITIVE.read(buffer); + final int shape = Types.VAR_INT.readPrimitive(buffer); + final int[] colors = Types.INT_ARRAY_PRIMITIVE.read(buffer); + final int[] fadeColors = Types.INT_ARRAY_PRIMITIVE.read(buffer); final boolean hasTrail = buffer.readBoolean(); final boolean hasTwinkle = buffer.readBoolean(); return new FireworkExplosion(shape, colors, fadeColors, hasTrail, hasTwinkle); @@ -40,9 +41,9 @@ public record FireworkExplosion(int shape, int[] colors, int[] fadeColors, boole @Override public void write(final ByteBuf buffer, final FireworkExplosion value) { - Type.VAR_INT.writePrimitive(buffer, value.shape); - Type.INT_ARRAY_PRIMITIVE.write(buffer, value.colors); - Type.INT_ARRAY_PRIMITIVE.write(buffer, value.fadeColors); + Types.VAR_INT.writePrimitive(buffer, value.shape); + Types.INT_ARRAY_PRIMITIVE.write(buffer, value.colors); + Types.INT_ARRAY_PRIMITIVE.write(buffer, value.fadeColors); buffer.writeBoolean(value.hasTrail); buffer.writeBoolean(value.hasTwinkle); } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Fireworks.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Fireworks.java index fba0e1c6d..b7e26e2cf 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Fireworks.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Fireworks.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public record Fireworks(int flightDuration, FireworkExplosion[] explosions) { @@ -30,14 +31,14 @@ public record Fireworks(int flightDuration, FireworkExplosion[] explosions) { public static final Type TYPE = new Type<>(Fireworks.class) { @Override public Fireworks read(final ByteBuf buffer) { - final int flightDuration = Type.VAR_INT.readPrimitive(buffer); + final int flightDuration = Types.VAR_INT.readPrimitive(buffer); final FireworkExplosion[] explosions = FireworkExplosion.ARRAY_TYPE.read(buffer); return new Fireworks(flightDuration, explosions); } @Override public void write(final ByteBuf buffer, final Fireworks value) { - Type.VAR_INT.writePrimitive(buffer, value.flightDuration); + Types.VAR_INT.writePrimitive(buffer, value.flightDuration); FireworkExplosion.ARRAY_TYPE.write(buffer, value.explosions); } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FoodProperties.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FoodProperties.java index a25cba9ea..7c582d27c 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FoodProperties.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/FoodProperties.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public record FoodProperties(int nutrition, float saturationModifier, boolean canAlwaysEat, float eatSeconds, @@ -31,7 +32,7 @@ public record FoodProperties(int nutrition, float saturationModifier, boolean ca public static final Type TYPE = new Type<>(FoodProperties.class) { @Override public FoodProperties read(final ByteBuf buffer) { - final int nutrition = Type.VAR_INT.readPrimitive(buffer); + final int nutrition = Types.VAR_INT.readPrimitive(buffer); final float saturationModifier = buffer.readFloat(); final boolean canAlwaysEat = buffer.readBoolean(); final float eatSeconds = buffer.readFloat(); @@ -41,7 +42,7 @@ public record FoodProperties(int nutrition, float saturationModifier, boolean ca @Override public void write(final ByteBuf buffer, final FoodProperties value) { - Type.VAR_INT.writePrimitive(buffer, value.nutrition); + Types.VAR_INT.writePrimitive(buffer, value.nutrition); buffer.writeFloat(value.saturationModifier); buffer.writeBoolean(value.canAlwaysEat); buffer.writeFloat(value.eatSeconds); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument.java index 065d73a6f..21384c5a2 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument.java @@ -24,7 +24,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.minecraft.Holder; import com.viaversion.viaversion.api.minecraft.SoundEvent; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.HolderType; import io.netty.buffer.ByteBuf; @@ -33,16 +33,16 @@ public record Instrument(Holder soundEvent, int useDuration, float r public static final HolderType TYPE = new HolderType<>() { @Override public Instrument readDirect(final ByteBuf buffer) { - final Holder soundEvent = Type.SOUND_EVENT.read(buffer); - final int useDuration = Type.VAR_INT.readPrimitive(buffer); + final Holder soundEvent = Types.SOUND_EVENT.read(buffer); + final int useDuration = Types.VAR_INT.readPrimitive(buffer); final float range = buffer.readFloat(); return new Instrument(soundEvent, useDuration, range); } @Override public void writeDirect(final ByteBuf buffer, final Instrument value) { - Type.SOUND_EVENT.write(buffer, value.soundEvent()); - Type.VAR_INT.writePrimitive(buffer, value.useDuration()); + Types.SOUND_EVENT.write(buffer, value.soundEvent()); + Types.VAR_INT.writePrimitive(buffer, value.useDuration()); buffer.writeFloat(value.range()); } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTracker.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTracker.java index a3e58e719..ed7cdf3c1 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTracker.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTracker.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.minecraft.GlobalPosition; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -32,14 +33,14 @@ public record LodestoneTracker(@Nullable GlobalPosition position, boolean tracke public static final Type TYPE = new Type<>(LodestoneTracker.class) { @Override public LodestoneTracker read(final ByteBuf buffer) { - final GlobalPosition position = Type.OPTIONAL_GLOBAL_POSITION.read(buffer); + final GlobalPosition position = Types.OPTIONAL_GLOBAL_POSITION.read(buffer); final boolean tracked = buffer.readBoolean(); return new LodestoneTracker(position, tracked); } @Override public void write(final ByteBuf buffer, final LodestoneTracker value) { - Type.OPTIONAL_GLOBAL_POSITION.write(buffer, value.position); + Types.OPTIONAL_GLOBAL_POSITION.write(buffer, value.position); buffer.writeBoolean(value.tracked); } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/MapDecoration.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/MapDecoration.java index 97623dde2..25d96274f 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/MapDecoration.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/MapDecoration.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public record MapDecoration(String type, double x, double z, float rotation) { @@ -30,16 +31,16 @@ public record MapDecoration(String type, double x, double z, float rotation) { public static final Type TYPE = new Type<>(MapDecoration.class) { @Override public MapDecoration read(final ByteBuf buffer) { - final String type = Type.STRING.read(buffer); - final double x = Type.DOUBLE.readPrimitive(buffer); - final double z = Type.DOUBLE.readPrimitive(buffer); - final float rotation = Type.FLOAT.readPrimitive(buffer); + final String type = Types.STRING.read(buffer); + final double x = Types.DOUBLE.readPrimitive(buffer); + final double z = Types.DOUBLE.readPrimitive(buffer); + final float rotation = Types.FLOAT.readPrimitive(buffer); return new MapDecoration(type, x, z, rotation); } @Override public void write(final ByteBuf buffer, final MapDecoration value) { - Type.STRING.write(buffer, value.type); + Types.STRING.write(buffer, value.type); buffer.writeDouble(value.x); buffer.writeDouble(value.z); buffer.writeFloat(value.rotation); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/MapDecorations.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/MapDecorations.java index c4e659440..047f4e106 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/MapDecorations.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/MapDecorations.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; @@ -34,9 +35,9 @@ public record MapDecorations(Map decorations) { @Override public MapDecorations read(final ByteBuf buffer) { final Object2ObjectMap decorations = new Object2ObjectOpenHashMap<>(); - final int size = Type.VAR_INT.readPrimitive(buffer); + final int size = Types.VAR_INT.readPrimitive(buffer); for (int i = 0; i < size; i++) { - final String id = Type.STRING.read(buffer); + final String id = Types.STRING.read(buffer); final MapDecoration decoration = MapDecoration.TYPE.read(buffer); decorations.put(id, decoration); } @@ -45,9 +46,9 @@ public record MapDecorations(Map decorations) { @Override public void write(final ByteBuf buffer, final MapDecorations value) { - Type.VAR_INT.writePrimitive(buffer, value.decorations.size()); + Types.VAR_INT.writePrimitive(buffer, value.decorations.size()); for (final Map.Entry entry : value.decorations.entrySet()) { - Type.STRING.write(buffer, entry.getKey()); + Types.STRING.write(buffer, entry.getKey()); MapDecoration.TYPE.write(buffer, entry.getValue()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ModifierData.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ModifierData.java index afb6564e7..440540c7a 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ModifierData.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ModifierData.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import java.util.UUID; @@ -31,19 +32,19 @@ public record ModifierData(UUID uuid, String name, double amount, int operation) public static final Type TYPE = new Type<>(ModifierData.class) { @Override public ModifierData read(final ByteBuf buffer) { - final UUID uuid = Type.UUID.read(buffer); - final String name = Type.STRING.read(buffer); + final UUID uuid = Types.UUID.read(buffer); + final String name = Types.STRING.read(buffer); final double amount = buffer.readDouble(); - final int operation = Type.VAR_INT.readPrimitive(buffer); + final int operation = Types.VAR_INT.readPrimitive(buffer); return new ModifierData(uuid, name, amount, operation); } @Override public void write(final ByteBuf buffer, final ModifierData value) { - Type.UUID.write(buffer, value.uuid); - Type.STRING.write(buffer, value.name); + Types.UUID.write(buffer, value.uuid); + Types.STRING.write(buffer, value.name); buffer.writeDouble(value.amount); - Type.VAR_INT.writePrimitive(buffer, value.operation); + Types.VAR_INT.writePrimitive(buffer, value.operation); } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotDecorations.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotDecorations.java index 03fd81e40..62ec39983 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotDecorations.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotDecorations.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public final class PotDecorations { @@ -30,12 +31,12 @@ public final class PotDecorations { public static final Type TYPE = new Type<>(PotDecorations.class) { @Override public PotDecorations read(final ByteBuf buffer) { - return new PotDecorations(Type.VAR_INT_ARRAY_PRIMITIVE.read(buffer)); + return new PotDecorations(Types.VAR_INT_ARRAY_PRIMITIVE.read(buffer)); } @Override public void write(final ByteBuf buffer, final PotDecorations value) { - Type.VAR_INT_ARRAY_PRIMITIVE.write(buffer, value.itemIds()); + Types.VAR_INT_ARRAY_PRIMITIVE.write(buffer, value.itemIds()); } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionContents.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionContents.java index cdfad17a7..81fdbb956 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionContents.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionContents.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -31,7 +32,7 @@ public record PotionContents(@Nullable Integer potion, @Nullable Integer customC public static final Type TYPE = new Type<>(PotionContents.class) { @Override public PotionContents read(final ByteBuf buffer) { - final Integer potion = buffer.readBoolean() ? Type.VAR_INT.readPrimitive(buffer) : null; + final Integer potion = buffer.readBoolean() ? Types.VAR_INT.readPrimitive(buffer) : null; final Integer customColor = buffer.readBoolean() ? buffer.readInt() : null; final PotionEffect[] customEffects = PotionEffect.ARRAY_TYPE.read(buffer); return new PotionContents(potion, customColor, customEffects); @@ -41,7 +42,7 @@ public record PotionContents(@Nullable Integer potion, @Nullable Integer customC public void write(final ByteBuf buffer, final PotionContents value) { buffer.writeBoolean(value.potion != null); if (value.potion != null) { - Type.VAR_INT.writePrimitive(buffer, value.potion); + Types.VAR_INT.writePrimitive(buffer, value.potion); } buffer.writeBoolean(value.customColor != null); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionEffect.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionEffect.java index 6c6b6578f..051f3dc08 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionEffect.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionEffect.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import io.netty.buffer.ByteBuf; @@ -31,14 +32,14 @@ public record PotionEffect(int effect, PotionEffectData effectData) { public static final Type TYPE = new Type<>(PotionEffect.class) { @Override public PotionEffect read(final ByteBuf buffer) { - final int effect = Type.VAR_INT.readPrimitive(buffer); + final int effect = Types.VAR_INT.readPrimitive(buffer); final PotionEffectData effectData = PotionEffectData.TYPE.read(buffer); return new PotionEffect(effect, effectData); } @Override public void write(final ByteBuf buffer, final PotionEffect value) { - Type.VAR_INT.writePrimitive(buffer, value.effect); + Types.VAR_INT.writePrimitive(buffer, value.effect); PotionEffectData.TYPE.write(buffer, value.effectData); } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionEffectData.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionEffectData.java index c0fb8b9c0..9c6f0c134 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionEffectData.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/PotionEffectData.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -33,8 +34,8 @@ public record PotionEffectData(int amplifier, int duration, boolean ambient, boo public static final Type TYPE = new Type<>(PotionEffectData.class) { @Override public PotionEffectData read(final ByteBuf buffer) { - final int amplifier = Type.VAR_INT.readPrimitive(buffer); - final int duration = Type.VAR_INT.readPrimitive(buffer); + final int amplifier = Types.VAR_INT.readPrimitive(buffer); + final int duration = Types.VAR_INT.readPrimitive(buffer); final boolean ambient = buffer.readBoolean(); final boolean showParticles = buffer.readBoolean(); final boolean showIcon = buffer.readBoolean(); @@ -44,8 +45,8 @@ public record PotionEffectData(int amplifier, int duration, boolean ambient, boo @Override public void write(final ByteBuf buffer, final PotionEffectData value) { - Type.VAR_INT.writePrimitive(buffer, value.amplifier); - Type.VAR_INT.writePrimitive(buffer, value.duration); + Types.VAR_INT.writePrimitive(buffer, value.amplifier); + Types.VAR_INT.writePrimitive(buffer, value.duration); buffer.writeBoolean(value.ambient); buffer.writeBoolean(value.showParticles); buffer.writeBoolean(value.showIcon); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/StatePropertyMatcher.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/StatePropertyMatcher.java index 479c4a1a5..cf3d0579d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/StatePropertyMatcher.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/StatePropertyMatcher.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import com.viaversion.viaversion.util.Either; import io.netty.buffer.ByteBuf; @@ -34,27 +35,27 @@ public record StatePropertyMatcher(String name, Either ma public static final Type TYPE = new Type<>(StatePropertyMatcher.class) { @Override public StatePropertyMatcher read(final ByteBuf buffer) { - final String name = Type.STRING.read(buffer); + final String name = Types.STRING.read(buffer); if (buffer.readBoolean()) { - final String value = Type.STRING.read(buffer); + final String value = Types.STRING.read(buffer); return new StatePropertyMatcher(name, Either.left(value)); } else { - final String minValue = Type.OPTIONAL_STRING.read(buffer); - final String maxValue = Type.OPTIONAL_STRING.read(buffer); + final String minValue = Types.OPTIONAL_STRING.read(buffer); + final String maxValue = Types.OPTIONAL_STRING.read(buffer); return new StatePropertyMatcher(name, Either.right(new RangedMatcher(minValue, maxValue))); } } @Override public void write(final ByteBuf buffer, final StatePropertyMatcher value) { - Type.STRING.write(buffer, value.name); + Types.STRING.write(buffer, value.name); if (value.matcher.isLeft()) { buffer.writeBoolean(true); - Type.STRING.write(buffer, value.matcher.left()); + Types.STRING.write(buffer, value.matcher.left()); } else { buffer.writeBoolean(false); - Type.OPTIONAL_STRING.write(buffer, value.matcher.right().minValue()); - Type.OPTIONAL_STRING.write(buffer, value.matcher.right().maxValue()); + Types.OPTIONAL_STRING.write(buffer, value.matcher.right().minValue()); + Types.OPTIONAL_STRING.write(buffer, value.matcher.right().maxValue()); } } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/SuspiciousStewEffect.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/SuspiciousStewEffect.java index 8f30fe37e..0e2bdf29d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/SuspiciousStewEffect.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/SuspiciousStewEffect.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import io.netty.buffer.ByteBuf; @@ -31,15 +32,15 @@ public record SuspiciousStewEffect(int mobEffect, int duration) { public static final Type TYPE = new Type<>(SuspiciousStewEffect.class) { @Override public SuspiciousStewEffect read(final ByteBuf buffer) { - final int effect = Type.VAR_INT.readPrimitive(buffer); - final int duration = Type.VAR_INT.readPrimitive(buffer); + final int effect = Types.VAR_INT.readPrimitive(buffer); + final int duration = Types.VAR_INT.readPrimitive(buffer); return new SuspiciousStewEffect(effect, duration); } @Override public void write(final ByteBuf buffer, final SuspiciousStewEffect value) { - Type.VAR_INT.writePrimitive(buffer, value.mobEffect); - Type.VAR_INT.writePrimitive(buffer, value.duration); + Types.VAR_INT.writePrimitive(buffer, value.mobEffect); + Types.VAR_INT.writePrimitive(buffer, value.duration); } }; public static final Type ARRAY_TYPE = new ArrayType<>(TYPE); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ToolProperties.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ToolProperties.java index 588c14524..265b71443 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ToolProperties.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ToolProperties.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public record ToolProperties(ToolRule[] rules, float defaultMiningSpeed, int damagePerBlock) { @@ -32,7 +33,7 @@ public record ToolProperties(ToolRule[] rules, float defaultMiningSpeed, int dam public ToolProperties read(final ByteBuf buffer) { final ToolRule[] rules = ToolRule.ARRAY_TYPE.read(buffer); final float defaultMiningSpeed = buffer.readFloat(); - final int damagePerBlock = Type.VAR_INT.readPrimitive(buffer); + final int damagePerBlock = Types.VAR_INT.readPrimitive(buffer); return new ToolProperties(rules, defaultMiningSpeed, damagePerBlock); } @@ -40,7 +41,7 @@ public record ToolProperties(ToolRule[] rules, float defaultMiningSpeed, int dam public void write(final ByteBuf buffer, final ToolProperties value) { ToolRule.ARRAY_TYPE.write(buffer, value.rules()); buffer.writeFloat(value.defaultMiningSpeed()); - Type.VAR_INT.writePrimitive(buffer, value.damagePerBlock()); + Types.VAR_INT.writePrimitive(buffer, value.damagePerBlock()); } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ToolRule.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ToolRule.java index bed7a0a5d..d7c0288df 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ToolRule.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ToolRule.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.minecraft.HolderSet; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -33,17 +34,17 @@ public record ToolRule(HolderSet blocks, @Nullable Float speed, @Nullable Boolea public static final Type TYPE = new Type<>(ToolRule.class) { @Override public ToolRule read(final ByteBuf buffer) { - final HolderSet blocks = Type.HOLDER_SET.read(buffer); - final Float speed = Type.OPTIONAL_FLOAT.read(buffer); - final Boolean correctForDrops = Type.OPTIONAL_BOOLEAN.read(buffer); + final HolderSet blocks = Types.HOLDER_SET.read(buffer); + final Float speed = Types.OPTIONAL_FLOAT.read(buffer); + final Boolean correctForDrops = Types.OPTIONAL_BOOLEAN.read(buffer); return new ToolRule(blocks, speed, correctForDrops); } @Override public void write(final ByteBuf buffer, final ToolRule value) { - Type.HOLDER_SET.write(buffer, value.blocks); - Type.OPTIONAL_FLOAT.write(buffer, value.speed); - Type.OPTIONAL_BOOLEAN.write(buffer, value.correctForDrops); + Types.HOLDER_SET.write(buffer, value.blocks); + Types.OPTIONAL_FLOAT.write(buffer, value.speed); + Types.OPTIONAL_BOOLEAN.write(buffer, value.correctForDrops); } }; public static final Type ARRAY_TYPE = new ArrayType<>(TYPE); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/WrittenBook.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/WrittenBook.java index a60df78b1..e3664a65c 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/WrittenBook.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/WrittenBook.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.minecraft.item.data; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public record WrittenBook(FilterableString title, String author, int generation, FilterableComponent[] pages, @@ -32,8 +33,8 @@ public record WrittenBook(FilterableString title, String author, int generation, @Override public WrittenBook read(final ByteBuf buffer) { final FilterableString title = FilterableString.TYPE.read(buffer); - final String author = Type.STRING.read(buffer); - final int generation = Type.VAR_INT.readPrimitive(buffer); + final String author = Types.STRING.read(buffer); + final int generation = Types.VAR_INT.readPrimitive(buffer); final FilterableComponent[] pages = FilterableComponent.ARRAY_TYPE.read(buffer); final boolean resolved = buffer.readBoolean(); return new WrittenBook(title, author, generation, pages, resolved); @@ -42,8 +43,8 @@ public record WrittenBook(FilterableString title, String author, int generation, @Override public void write(final ByteBuf buffer, final WrittenBook value) { FilterableString.TYPE.write(buffer, value.title); - Type.STRING.write(buffer, value.author); - Type.VAR_INT.writePrimitive(buffer, value.generation); + Types.STRING.write(buffer, value.author); + Types.VAR_INT.writePrimitive(buffer, value.generation); FilterableComponent.ARRAY_TYPE.write(buffer, value.pages); buffer.writeBoolean(value.resolved); } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_12.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_12.java index 1cf73b2e0..9bd2bb2f7 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_12.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_12.java @@ -24,28 +24,27 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; public enum MetaType1_12 implements MetaType { - Byte(0, Type.BYTE), - VarInt(1, Type.VAR_INT), - Float(2, Type.FLOAT), - String(3, Type.STRING), - Chat(4, Type.COMPONENT), - Slot(5, Type.ITEM1_8), - Boolean(6, Type.BOOLEAN), - Vector3F(7, Type.ROTATION), - Position(8, Type.POSITION1_8), - OptPosition(9, Type.OPTIONAL_POSITION1_8), - Direction(10, Type.VAR_INT), - OptUUID(11, Type.OPTIONAL_UUID), - BlockID(12, Type.VAR_INT), - NBTTag(13, Type.NAMED_COMPOUND_TAG); + BYTE(Types.BYTE), + VAR_INT(Types.VAR_INT), + FLOAT(Types.FLOAT), + STRING(Types.STRING), + COMPONENT(Types.COMPONENT), + ITEM(Types.ITEM1_8), + BOOLEAN(Types.BOOLEAN), + ROTATIONS(Types.ROTATIONS), + BLOCK_POSITION(Types.BLOCK_POSITION1_8), + OPTIONAL_BLOCK_POSITION(Types.OPTIONAL_POSITION1_8), + DIRECTION(Types.VAR_INT), + OPTIONAL_UUID(Types.OPTIONAL_UUID), + OPTIONAL_BLOCK_STATE(Types.VAR_INT), + COMPOUND_TAG(Types.NAMED_COMPOUND_TAG); - private final int typeID; - private final Type type; + private final Type type; - MetaType1_12(int typeID, Type type) { - this.typeID = typeID; + MetaType1_12(Type type) { this.type = type; } @@ -55,7 +54,7 @@ public enum MetaType1_12 implements MetaType { @Override public int typeId() { - return typeID; + return ordinal(); } @Override diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_8.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_8.java index 8be4aef9a..04adf3927 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_8.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_8.java @@ -24,22 +24,21 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; public enum MetaType1_8 implements MetaType { - Byte(0, Type.BYTE), - Short(1, Type.SHORT), - Int(2, Type.INT), - Float(3, Type.FLOAT), - String(4, Type.STRING), - Slot(5, Type.ITEM1_8), - Position(6, Type.VECTOR), - Rotation(7, Type.ROTATION); + BYTE(Types.BYTE), + SHORT(Types.SHORT), + INT(Types.INT), + FLOAT(Types.FLOAT), + STRING(Types.STRING), + ITEM(Types.ITEM1_8), + BLOCK_POSITION(Types.VECTOR), + ROTATIONS(Types.ROTATIONS); - private final int typeID; - private final Type type; + private final Type type; - MetaType1_8(int typeID, Type type) { - this.typeID = typeID; + MetaType1_8(Type type) { this.type = type; } @@ -49,7 +48,7 @@ public enum MetaType1_8 implements MetaType { @Override public int typeId() { - return typeID; + return ordinal(); } @Override diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_9.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_9.java index 7c4ec3227..ab1ccdbac 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_9.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_9.java @@ -24,27 +24,26 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; public enum MetaType1_9 implements MetaType { - Byte(0, Type.BYTE), - VarInt(1, Type.VAR_INT), - Float(2, Type.FLOAT), - String(3, Type.STRING), - Chat(4, Type.COMPONENT), - Slot(5, Type.ITEM1_8), - Boolean(6, Type.BOOLEAN), - Vector3F(7, Type.ROTATION), - Position(8, Type.POSITION1_8), - OptPosition(9, Type.OPTIONAL_POSITION1_8), - Direction(10, Type.VAR_INT), - OptUUID(11, Type.OPTIONAL_UUID), - BlockID(12, Type.VAR_INT); + BYTE(Types.BYTE), + VAR_INT(Types.VAR_INT), + FLOAT(Types.FLOAT), + STRING(Types.STRING), + COMPONENT(Types.COMPONENT), + ITEM(Types.ITEM1_8), + BOOLEAN(Types.BOOLEAN), + ROTATIONS(Types.ROTATIONS), + BLOCK_POSITION(Types.BLOCK_POSITION1_8), + OPTIONAL_BLOCK_POSITION(Types.OPTIONAL_POSITION1_8), + DIRECTION(Types.VAR_INT), + OPTIONAL_UUID(Types.OPTIONAL_UUID), + OPTIONAL_BLOCK_STATE(Types.VAR_INT); - private final int typeID; - private final Type type; + private final Type type; - MetaType1_9(int typeID, Type type) { - this.typeID = typeID; + MetaType1_9(Type type) { this.type = type; } @@ -54,7 +53,7 @@ public enum MetaType1_9 implements MetaType { @Override public int typeId() { - return typeID; + return ordinal(); } @Override diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13.java index 3a4bd24e8..939c0c92e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13.java @@ -24,25 +24,26 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; public final class MetaTypes1_13 extends AbstractMetaTypes { - public final MetaType byteType = add(0, Type.BYTE); - public final MetaType varIntType = add(1, Type.VAR_INT); - public final MetaType floatType = add(2, Type.FLOAT); - public final MetaType stringType = add(3, Type.STRING); - public final MetaType componentType = add(4, Type.COMPONENT); - public final MetaType optionalComponentType = add(5, Type.OPTIONAL_COMPONENT); - public final MetaType itemType = add(6, Type.ITEM1_13); - public final MetaType booleanType = add(7, Type.BOOLEAN); - public final MetaType rotationType = add(8, Type.ROTATION); - public final MetaType positionType = add(9, Type.POSITION1_8); - public final MetaType optionalPositionType = add(10, Type.OPTIONAL_POSITION1_8); - public final MetaType directionType = add(11, Type.VAR_INT); - public final MetaType optionalUUIDType = add(12, Type.OPTIONAL_UUID); - public final MetaType blockStateType = add(13, Type.VAR_INT); - public final MetaType nbtType = add(14, Type.NAMED_COMPOUND_TAG); + public final MetaType byteType = add(0, Types.BYTE); + public final MetaType varIntType = add(1, Types.VAR_INT); + public final MetaType floatType = add(2, Types.FLOAT); + public final MetaType stringType = add(3, Types.STRING); + public final MetaType componentType = add(4, Types.COMPONENT); + public final MetaType optionalComponentType = add(5, Types.OPTIONAL_COMPONENT); + public final MetaType itemType = add(6, Types.ITEM1_13); + public final MetaType booleanType = add(7, Types.BOOLEAN); + public final MetaType rotationsType = add(8, Types.ROTATIONS); + public final MetaType blockPositionType = add(9, Types.BLOCK_POSITION1_8); + public final MetaType optionalBlockPositionType = add(10, Types.OPTIONAL_POSITION1_8); + public final MetaType directionType = add(11, Types.VAR_INT); + public final MetaType optionalUUIDType = add(12, Types.OPTIONAL_UUID); + public final MetaType optionalBlockStateType = add(13, Types.VAR_INT); + public final MetaType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG); public final MetaType particleType; public MetaTypes1_13(final ParticleType particleType) { diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13_2.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13_2.java index c139e9111..c70c9ea8e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13_2.java @@ -24,25 +24,26 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; public final class MetaTypes1_13_2 extends AbstractMetaTypes { - public final MetaType byteType = add(0, Type.BYTE); - public final MetaType varIntType = add(1, Type.VAR_INT); - public final MetaType floatType = add(2, Type.FLOAT); - public final MetaType stringType = add(3, Type.STRING); - public final MetaType componentType = add(4, Type.COMPONENT); - public final MetaType optionalComponentType = add(5, Type.OPTIONAL_COMPONENT); - public final MetaType itemType = add(6, Type.ITEM1_13_2); - public final MetaType booleanType = add(7, Type.BOOLEAN); - public final MetaType rotationType = add(8, Type.ROTATION); - public final MetaType positionType = add(9, Type.POSITION1_8); - public final MetaType optionalPositionType = add(10, Type.OPTIONAL_POSITION1_8); - public final MetaType directionType = add(11, Type.VAR_INT); - public final MetaType optionalUUIDType = add(12, Type.OPTIONAL_UUID); - public final MetaType blockStateType = add(13, Type.VAR_INT); - public final MetaType nbtType = add(14, Type.NAMED_COMPOUND_TAG); + public final MetaType byteType = add(0, Types.BYTE); + public final MetaType varIntType = add(1, Types.VAR_INT); + public final MetaType floatType = add(2, Types.FLOAT); + public final MetaType stringType = add(3, Types.STRING); + public final MetaType componentType = add(4, Types.COMPONENT); + public final MetaType optionalComponentType = add(5, Types.OPTIONAL_COMPONENT); + public final MetaType itemType = add(6, Types.ITEM1_13_2); + public final MetaType booleanType = add(7, Types.BOOLEAN); + public final MetaType rotationsType = add(8, Types.ROTATIONS); + public final MetaType blockPositionType = add(9, Types.BLOCK_POSITION1_8); + public final MetaType optionalBlockPositionType = add(10, Types.OPTIONAL_POSITION1_8); + public final MetaType directionType = add(11, Types.VAR_INT); + public final MetaType optionalUUIDType = add(12, Types.OPTIONAL_UUID); + public final MetaType optionalBlockStateType = add(13, Types.VAR_INT); + public final MetaType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG); public final MetaType particleType; public MetaTypes1_13_2(final ParticleType particleType) { diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_14.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_14.java index 04364ee3c..aa2a9114f 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_14.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_14.java @@ -24,29 +24,30 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; public final class MetaTypes1_14 extends AbstractMetaTypes { - public final MetaType byteType = add(0, Type.BYTE); - public final MetaType varIntType = add(1, Type.VAR_INT); - public final MetaType floatType = add(2, Type.FLOAT); - public final MetaType stringType = add(3, Type.STRING); - public final MetaType componentType = add(4, Type.COMPONENT); - public final MetaType optionalComponentType = add(5, Type.OPTIONAL_COMPONENT); - public final MetaType itemType = add(6, Type.ITEM1_13_2); - public final MetaType booleanType = add(7, Type.BOOLEAN); - public final MetaType rotationType = add(8, Type.ROTATION); - public final MetaType positionType = add(9, Type.POSITION1_14); - public final MetaType optionalPositionType = add(10, Type.OPTIONAL_POSITION_1_14); - public final MetaType directionType = add(11, Type.VAR_INT); - public final MetaType optionalUUIDType = add(12, Type.OPTIONAL_UUID); - public final MetaType blockStateType = add(13, Type.VAR_INT); - public final MetaType nbtType = add(14, Type.NAMED_COMPOUND_TAG); + public final MetaType byteType = add(0, Types.BYTE); + public final MetaType varIntType = add(1, Types.VAR_INT); + public final MetaType floatType = add(2, Types.FLOAT); + public final MetaType stringType = add(3, Types.STRING); + public final MetaType componentType = add(4, Types.COMPONENT); + public final MetaType optionalComponentType = add(5, Types.OPTIONAL_COMPONENT); + public final MetaType itemType = add(6, Types.ITEM1_13_2); + public final MetaType booleanType = add(7, Types.BOOLEAN); + public final MetaType rotationsType = add(8, Types.ROTATIONS); + public final MetaType blockPositionType = add(9, Types.BLOCK_POSITION1_14); + public final MetaType optionalBlockPositionType = add(10, Types.OPTIONAL_POSITION_1_14); + public final MetaType directionType = add(11, Types.VAR_INT); + public final MetaType optionalUUIDType = add(12, Types.OPTIONAL_UUID); + public final MetaType optionalBlockStateType = add(13, Types.VAR_INT); + public final MetaType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG); public final MetaType particleType; - public final MetaType villagerDatatType = add(16, Type.VILLAGER_DATA); - public final MetaType optionalVarIntType = add(17, Type.OPTIONAL_VAR_INT); - public final MetaType poseType = add(18, Type.VAR_INT); + public final MetaType villagerDatatType = add(16, Types.VILLAGER_DATA); + public final MetaType optionalVarIntType = add(17, Types.OPTIONAL_VAR_INT); + public final MetaType poseType = add(18, Types.VAR_INT); public MetaTypes1_14(final ParticleType particleType) { super(19); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19.java index da35b7ca5..661bf965d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19.java @@ -24,33 +24,34 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; public final class MetaTypes1_19 extends AbstractMetaTypes { - public final MetaType byteType = add(0, Type.BYTE); - public final MetaType varIntType = add(1, Type.VAR_INT); - public final MetaType floatType = add(2, Type.FLOAT); - public final MetaType stringType = add(3, Type.STRING); - public final MetaType componentType = add(4, Type.COMPONENT); - public final MetaType optionalComponentType = add(5, Type.OPTIONAL_COMPONENT); - public final MetaType itemType = add(6, Type.ITEM1_13_2); - public final MetaType booleanType = add(7, Type.BOOLEAN); - public final MetaType rotationType = add(8, Type.ROTATION); - public final MetaType positionType = add(9, Type.POSITION1_14); - public final MetaType optionalPositionType = add(10, Type.OPTIONAL_POSITION_1_14); - public final MetaType directionType = add(11, Type.VAR_INT); - public final MetaType optionalUUIDType = add(12, Type.OPTIONAL_UUID); - public final MetaType blockStateType = add(13, Type.VAR_INT); - public final MetaType nbtType = add(14, Type.NAMED_COMPOUND_TAG); + public final MetaType byteType = add(0, Types.BYTE); + public final MetaType varIntType = add(1, Types.VAR_INT); + public final MetaType floatType = add(2, Types.FLOAT); + public final MetaType stringType = add(3, Types.STRING); + public final MetaType componentType = add(4, Types.COMPONENT); + public final MetaType optionalComponentType = add(5, Types.OPTIONAL_COMPONENT); + public final MetaType itemType = add(6, Types.ITEM1_13_2); + public final MetaType booleanType = add(7, Types.BOOLEAN); + public final MetaType rotationsType = add(8, Types.ROTATIONS); + public final MetaType blockPositionType = add(9, Types.BLOCK_POSITION1_14); + public final MetaType optionalBlockPositionType = add(10, Types.OPTIONAL_POSITION_1_14); + public final MetaType directionType = add(11, Types.VAR_INT); + public final MetaType optionalUUIDType = add(12, Types.OPTIONAL_UUID); + public final MetaType optionalBlockStateType = add(13, Types.VAR_INT); + public final MetaType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG); public final MetaType particleType; - public final MetaType villagerDatatType = add(16, Type.VILLAGER_DATA); - public final MetaType optionalVarIntType = add(17, Type.OPTIONAL_VAR_INT); - public final MetaType poseType = add(18, Type.VAR_INT); - public final MetaType catVariantType = add(19, Type.VAR_INT); - public final MetaType frogVariantType = add(20, Type.VAR_INT); - public final MetaType optionalGlobalPosition = add(21, Type.OPTIONAL_GLOBAL_POSITION); - public final MetaType paintingVariantType = add(22, Type.VAR_INT); + public final MetaType villagerDatatType = add(16, Types.VILLAGER_DATA); + public final MetaType optionalVarIntType = add(17, Types.OPTIONAL_VAR_INT); + public final MetaType poseType = add(18, Types.VAR_INT); + public final MetaType catVariantType = add(19, Types.VAR_INT); + public final MetaType frogVariantType = add(20, Types.VAR_INT); + public final MetaType optionalGlobalPosition = add(21, Types.OPTIONAL_GLOBAL_POSITION); + public final MetaType paintingVariantType = add(22, Types.VAR_INT); public MetaTypes1_19(final ParticleType particleType) { super(23); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_3.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_3.java index c4712fcfb..f88577420 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_3.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_3.java @@ -24,34 +24,35 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; public final class MetaTypes1_19_3 extends AbstractMetaTypes { - public final MetaType byteType = add(0, Type.BYTE); - public final MetaType varIntType = add(1, Type.VAR_INT); - public final MetaType longType = add(2, Type.VAR_LONG); - public final MetaType floatType = add(3, Type.FLOAT); - public final MetaType stringType = add(4, Type.STRING); - public final MetaType componentType = add(5, Type.COMPONENT); - public final MetaType optionalComponentType = add(6, Type.OPTIONAL_COMPONENT); - public final MetaType itemType = add(7, Type.ITEM1_13_2); - public final MetaType booleanType = add(8, Type.BOOLEAN); - public final MetaType rotationType = add(9, Type.ROTATION); - public final MetaType positionType = add(10, Type.POSITION1_14); - public final MetaType optionalPositionType = add(11, Type.OPTIONAL_POSITION_1_14); - public final MetaType directionType = add(12, Type.VAR_INT); - public final MetaType optionalUUIDType = add(13, Type.OPTIONAL_UUID); - public final MetaType blockStateType = add(14, Type.VAR_INT); - public final MetaType nbtType = add(15, Type.NAMED_COMPOUND_TAG); + public final MetaType byteType = add(0, Types.BYTE); + public final MetaType varIntType = add(1, Types.VAR_INT); + public final MetaType longType = add(2, Types.VAR_LONG); + public final MetaType floatType = add(3, Types.FLOAT); + public final MetaType stringType = add(4, Types.STRING); + public final MetaType componentType = add(5, Types.COMPONENT); + public final MetaType optionalComponentType = add(6, Types.OPTIONAL_COMPONENT); + public final MetaType itemType = add(7, Types.ITEM1_13_2); + public final MetaType booleanType = add(8, Types.BOOLEAN); + public final MetaType rotationsType = add(9, Types.ROTATIONS); + public final MetaType blockPositionType = add(10, Types.BLOCK_POSITION1_14); + public final MetaType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14); + public final MetaType directionType = add(12, Types.VAR_INT); + public final MetaType optionalUUIDType = add(13, Types.OPTIONAL_UUID); + public final MetaType optionalBlockStateType = add(14, Types.VAR_INT); + public final MetaType compoundTagType = add(15, Types.NAMED_COMPOUND_TAG); public final MetaType particleType; - public final MetaType villagerDatatType = add(17, Type.VILLAGER_DATA); - public final MetaType optionalVarIntType = add(18, Type.OPTIONAL_VAR_INT); - public final MetaType poseType = add(19, Type.VAR_INT); - public final MetaType catVariantType = add(20, Type.VAR_INT); - public final MetaType frogVariantType = add(21, Type.VAR_INT); - public final MetaType optionalGlobalPosition = add(22, Type.OPTIONAL_GLOBAL_POSITION); - public final MetaType paintingVariantType = add(23, Type.VAR_INT); + public final MetaType villagerDatatType = add(17, Types.VILLAGER_DATA); + public final MetaType optionalVarIntType = add(18, Types.OPTIONAL_VAR_INT); + public final MetaType poseType = add(19, Types.VAR_INT); + public final MetaType catVariantType = add(20, Types.VAR_INT); + public final MetaType frogVariantType = add(21, Types.VAR_INT); + public final MetaType optionalGlobalPosition = add(22, Types.OPTIONAL_GLOBAL_POSITION); + public final MetaType paintingVariantType = add(23, Types.VAR_INT); public MetaTypes1_19_3(final ParticleType particleType) { super(24); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_4.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_4.java index e5c6d3166..bb708129f 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_4.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_4.java @@ -24,38 +24,39 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; public final class MetaTypes1_19_4 extends AbstractMetaTypes { - public final MetaType byteType = add(0, Type.BYTE); - public final MetaType varIntType = add(1, Type.VAR_INT); - public final MetaType longType = add(2, Type.VAR_LONG); - public final MetaType floatType = add(3, Type.FLOAT); - public final MetaType stringType = add(4, Type.STRING); - public final MetaType componentType = add(5, Type.COMPONENT); - public final MetaType optionalComponentType = add(6, Type.OPTIONAL_COMPONENT); - public final MetaType itemType = add(7, Type.ITEM1_13_2); - public final MetaType booleanType = add(8, Type.BOOLEAN); - public final MetaType rotationType = add(9, Type.ROTATION); - public final MetaType positionType = add(10, Type.POSITION1_14); - public final MetaType optionalPositionType = add(11, Type.OPTIONAL_POSITION_1_14); - public final MetaType directionType = add(12, Type.VAR_INT); - public final MetaType optionalUUIDType = add(13, Type.OPTIONAL_UUID); - public final MetaType blockStateType = add(14, Type.VAR_INT); - public final MetaType optionalBlockStateType = add(15, Type.VAR_INT); - public final MetaType nbtType = add(16, Type.NAMED_COMPOUND_TAG); + public final MetaType byteType = add(0, Types.BYTE); + public final MetaType varIntType = add(1, Types.VAR_INT); + public final MetaType longType = add(2, Types.VAR_LONG); + public final MetaType floatType = add(3, Types.FLOAT); + public final MetaType stringType = add(4, Types.STRING); + public final MetaType componentType = add(5, Types.COMPONENT); + public final MetaType optionalComponentType = add(6, Types.OPTIONAL_COMPONENT); + public final MetaType itemType = add(7, Types.ITEM1_13_2); + public final MetaType booleanType = add(8, Types.BOOLEAN); + public final MetaType rotationsType = add(9, Types.ROTATIONS); + public final MetaType blockPositionType = add(10, Types.BLOCK_POSITION1_14); + public final MetaType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14); + public final MetaType directionType = add(12, Types.VAR_INT); + public final MetaType optionalUUIDType = add(13, Types.OPTIONAL_UUID); + public final MetaType blockStateType = add(14, Types.VAR_INT); + public final MetaType optionalBlockStateType = add(15, Types.VAR_INT); + public final MetaType compoundTagType = add(16, Types.NAMED_COMPOUND_TAG); public final MetaType particleType; - public final MetaType villagerDatatType = add(18, Type.VILLAGER_DATA); - public final MetaType optionalVarIntType = add(19, Type.OPTIONAL_VAR_INT); - public final MetaType poseType = add(20, Type.VAR_INT); - public final MetaType catVariantType = add(21, Type.VAR_INT); - public final MetaType frogVariantType = add(22, Type.VAR_INT); - public final MetaType optionalGlobalPosition = add(23, Type.OPTIONAL_GLOBAL_POSITION); - public final MetaType paintingVariantType = add(24, Type.VAR_INT); - public final MetaType snifferState = add(25, Type.VAR_INT); - public final MetaType vectorType = add(26, Type.VECTOR3F); - public final MetaType quaternionType = add(27, Type.QUATERNION); + public final MetaType villagerDatatType = add(18, Types.VILLAGER_DATA); + public final MetaType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT); + public final MetaType poseType = add(20, Types.VAR_INT); + public final MetaType catVariantType = add(21, Types.VAR_INT); + public final MetaType frogVariantType = add(22, Types.VAR_INT); + public final MetaType optionalGlobalPosition = add(23, Types.OPTIONAL_GLOBAL_POSITION); + public final MetaType paintingVariantType = add(24, Types.VAR_INT); + public final MetaType snifferState = add(25, Types.VAR_INT); + public final MetaType vector3FType = add(26, Types.VECTOR3F); + public final MetaType quaternionType = add(27, Types.QUATERNION); public MetaTypes1_19_4(final ParticleType particleType) { super(28); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_2.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_2.java index 34726ed84..d3a610cec 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_2.java @@ -24,38 +24,39 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; public final class MetaTypes1_20_2 extends AbstractMetaTypes { - public final MetaType byteType = add(0, Type.BYTE); - public final MetaType varIntType = add(1, Type.VAR_INT); - public final MetaType longType = add(2, Type.VAR_LONG); - public final MetaType floatType = add(3, Type.FLOAT); - public final MetaType stringType = add(4, Type.STRING); - public final MetaType componentType = add(5, Type.COMPONENT); - public final MetaType optionalComponentType = add(6, Type.OPTIONAL_COMPONENT); - public final MetaType itemType = add(7, Type.ITEM1_20_2); - public final MetaType booleanType = add(8, Type.BOOLEAN); - public final MetaType rotationType = add(9, Type.ROTATION); - public final MetaType positionType = add(10, Type.POSITION1_14); - public final MetaType optionalPositionType = add(11, Type.OPTIONAL_POSITION_1_14); - public final MetaType directionType = add(12, Type.VAR_INT); - public final MetaType optionalUUIDType = add(13, Type.OPTIONAL_UUID); - public final MetaType blockStateType = add(14, Type.VAR_INT); - public final MetaType optionalBlockStateType = add(15, Type.VAR_INT); - public final MetaType nbtType = add(16, Type.COMPOUND_TAG); + public final MetaType byteType = add(0, Types.BYTE); + public final MetaType varIntType = add(1, Types.VAR_INT); + public final MetaType longType = add(2, Types.VAR_LONG); + public final MetaType floatType = add(3, Types.FLOAT); + public final MetaType stringType = add(4, Types.STRING); + public final MetaType componentType = add(5, Types.COMPONENT); + public final MetaType optionalComponentType = add(6, Types.OPTIONAL_COMPONENT); + public final MetaType itemType = add(7, Types.ITEM1_20_2); + public final MetaType booleanType = add(8, Types.BOOLEAN); + public final MetaType rotationsType = add(9, Types.ROTATIONS); + public final MetaType blockPositionType = add(10, Types.BLOCK_POSITION1_14); + public final MetaType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14); + public final MetaType directionType = add(12, Types.VAR_INT); + public final MetaType optionalUUIDType = add(13, Types.OPTIONAL_UUID); + public final MetaType blockStateType = add(14, Types.VAR_INT); + public final MetaType optionalBlockStateType = add(15, Types.VAR_INT); + public final MetaType compoundTagType = add(16, Types.COMPOUND_TAG); public final MetaType particleType; - public final MetaType villagerDatatType = add(18, Type.VILLAGER_DATA); - public final MetaType optionalVarIntType = add(19, Type.OPTIONAL_VAR_INT); - public final MetaType poseType = add(20, Type.VAR_INT); - public final MetaType catVariantType = add(21, Type.VAR_INT); - public final MetaType frogVariantType = add(22, Type.VAR_INT); - public final MetaType optionalGlobalPosition = add(23, Type.OPTIONAL_GLOBAL_POSITION); - public final MetaType paintingVariantType = add(24, Type.VAR_INT); - public final MetaType snifferState = add(25, Type.VAR_INT); - public final MetaType vectorType = add(26, Type.VECTOR3F); - public final MetaType quaternionType = add(27, Type.QUATERNION); + public final MetaType villagerDatatType = add(18, Types.VILLAGER_DATA); + public final MetaType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT); + public final MetaType poseType = add(20, Types.VAR_INT); + public final MetaType catVariantType = add(21, Types.VAR_INT); + public final MetaType frogVariantType = add(22, Types.VAR_INT); + public final MetaType optionalGlobalPosition = add(23, Types.OPTIONAL_GLOBAL_POSITION); + public final MetaType paintingVariantType = add(24, Types.VAR_INT); + public final MetaType snifferState = add(25, Types.VAR_INT); + public final MetaType vector3FType = add(26, Types.VECTOR3F); + public final MetaType quaternionType = add(27, Types.QUATERNION); public MetaTypes1_20_2(final ParticleType particleType) { super(28); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_3.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_3.java index fee3c3bfc..8bf0e0cf2 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_3.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_3.java @@ -24,38 +24,39 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; public final class MetaTypes1_20_3 extends AbstractMetaTypes { - public final MetaType byteType = add(0, Type.BYTE); - public final MetaType varIntType = add(1, Type.VAR_INT); - public final MetaType longType = add(2, Type.VAR_LONG); - public final MetaType floatType = add(3, Type.FLOAT); - public final MetaType stringType = add(4, Type.STRING); - public final MetaType componentType = add(5, Type.TAG); - public final MetaType optionalComponentType = add(6, Type.OPTIONAL_TAG); - public final MetaType itemType = add(7, Type.ITEM1_20_2); - public final MetaType booleanType = add(8, Type.BOOLEAN); - public final MetaType rotationType = add(9, Type.ROTATION); - public final MetaType positionType = add(10, Type.POSITION1_14); - public final MetaType optionalPositionType = add(11, Type.OPTIONAL_POSITION_1_14); - public final MetaType directionType = add(12, Type.VAR_INT); - public final MetaType optionalUUIDType = add(13, Type.OPTIONAL_UUID); - public final MetaType blockStateType = add(14, Type.VAR_INT); - public final MetaType optionalBlockStateType = add(15, Type.VAR_INT); - public final MetaType nbtType = add(16, Type.COMPOUND_TAG); + public final MetaType byteType = add(0, Types.BYTE); + public final MetaType varIntType = add(1, Types.VAR_INT); + public final MetaType longType = add(2, Types.VAR_LONG); + public final MetaType floatType = add(3, Types.FLOAT); + public final MetaType stringType = add(4, Types.STRING); + public final MetaType componentType = add(5, Types.TAG); + public final MetaType optionalComponentType = add(6, Types.OPTIONAL_TAG); + public final MetaType itemType = add(7, Types.ITEM1_20_2); + public final MetaType booleanType = add(8, Types.BOOLEAN); + public final MetaType rotationsType = add(9, Types.ROTATIONS); + public final MetaType blockPositionType = add(10, Types.BLOCK_POSITION1_14); + public final MetaType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14); + public final MetaType directionType = add(12, Types.VAR_INT); + public final MetaType optionalUUIDType = add(13, Types.OPTIONAL_UUID); + public final MetaType blockStateType = add(14, Types.VAR_INT); + public final MetaType optionalBlockStateType = add(15, Types.VAR_INT); + public final MetaType compoundTagType = add(16, Types.COMPOUND_TAG); public final MetaType particleType; - public final MetaType villagerDatatType = add(18, Type.VILLAGER_DATA); - public final MetaType optionalVarIntType = add(19, Type.OPTIONAL_VAR_INT); - public final MetaType poseType = add(20, Type.VAR_INT); - public final MetaType catVariantType = add(21, Type.VAR_INT); - public final MetaType frogVariantType = add(22, Type.VAR_INT); - public final MetaType optionalGlobalPosition = add(23, Type.OPTIONAL_GLOBAL_POSITION); - public final MetaType paintingVariantType = add(24, Type.VAR_INT); - public final MetaType snifferState = add(25, Type.VAR_INT); - public final MetaType vectorType = add(26, Type.VECTOR3F); - public final MetaType quaternionType = add(27, Type.QUATERNION); + public final MetaType villagerDatatType = add(18, Types.VILLAGER_DATA); + public final MetaType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT); + public final MetaType poseType = add(20, Types.VAR_INT); + public final MetaType catVariantType = add(21, Types.VAR_INT); + public final MetaType frogVariantType = add(22, Types.VAR_INT); + public final MetaType optionalGlobalPosition = add(23, Types.OPTIONAL_GLOBAL_POSITION); + public final MetaType paintingVariantType = add(24, Types.VAR_INT); + public final MetaType snifferState = add(25, Types.VAR_INT); + public final MetaType vector3FType = add(26, Types.VECTOR3F); + public final MetaType quaternionType = add(27, Types.QUATERNION); public MetaTypes1_20_3(final ParticleType particleType) { super(28); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_5.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_5.java index 5c04cc5cc..e2e641294 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_5.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_5.java @@ -25,43 +25,44 @@ package com.viaversion.viaversion.api.minecraft.metadata.types; import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.ArrayType; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_20_5; public final class MetaTypes1_20_5 extends AbstractMetaTypes { - public final MetaType byteType = add(0, Type.BYTE); - public final MetaType varIntType = add(1, Type.VAR_INT); - public final MetaType longType = add(2, Type.VAR_LONG); - public final MetaType floatType = add(3, Type.FLOAT); - public final MetaType stringType = add(4, Type.STRING); - public final MetaType componentType = add(5, Type.TAG); - public final MetaType optionalComponentType = add(6, Type.OPTIONAL_TAG); + public final MetaType byteType = add(0, Types.BYTE); + public final MetaType varIntType = add(1, Types.VAR_INT); + public final MetaType longType = add(2, Types.VAR_LONG); + public final MetaType floatType = add(3, Types.FLOAT); + public final MetaType stringType = add(4, Types.STRING); + public final MetaType componentType = add(5, Types.TAG); + public final MetaType optionalComponentType = add(6, Types.OPTIONAL_TAG); public final MetaType itemType = add(7, Types1_20_5.ITEM); - public final MetaType booleanType = add(8, Type.BOOLEAN); - public final MetaType rotationType = add(9, Type.ROTATION); - public final MetaType positionType = add(10, Type.POSITION1_14); - public final MetaType optionalPositionType = add(11, Type.OPTIONAL_POSITION_1_14); - public final MetaType directionType = add(12, Type.VAR_INT); - public final MetaType optionalUUIDType = add(13, Type.OPTIONAL_UUID); - public final MetaType blockStateType = add(14, Type.VAR_INT); - public final MetaType optionalBlockStateType = add(15, Type.VAR_INT); - public final MetaType nbtType = add(16, Type.COMPOUND_TAG); + public final MetaType booleanType = add(8, Types.BOOLEAN); + public final MetaType rotationsType = add(9, Types.ROTATIONS); + public final MetaType blockPositionType = add(10, Types.BLOCK_POSITION1_14); + public final MetaType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14); + public final MetaType directionType = add(12, Types.VAR_INT); + public final MetaType optionalUUIDType = add(13, Types.OPTIONAL_UUID); + public final MetaType blockStateType = add(14, Types.VAR_INT); + public final MetaType optionalBlockStateType = add(15, Types.VAR_INT); + public final MetaType compoundTagType = add(16, Types.COMPOUND_TAG); public final MetaType particleType; public final MetaType particlesType; - public final MetaType villagerDatatType = add(19, Type.VILLAGER_DATA); - public final MetaType optionalVarIntType = add(20, Type.OPTIONAL_VAR_INT); - public final MetaType poseType = add(21, Type.VAR_INT); - public final MetaType catVariantType = add(22, Type.VAR_INT); - public final MetaType wolfVariantType = add(23, Type.VAR_INT); - public final MetaType frogVariantType = add(24, Type.VAR_INT); - public final MetaType optionalGlobalPosition = add(25, Type.OPTIONAL_GLOBAL_POSITION); - public final MetaType paintingVariantType = add(26, Type.VAR_INT); - public final MetaType snifferState = add(27, Type.VAR_INT); - public final MetaType armadilloState = add(28, Type.VAR_INT); - public final MetaType vectorType = add(29, Type.VECTOR3F); - public final MetaType quaternionType = add(30, Type.QUATERNION); + public final MetaType villagerDatatType = add(19, Types.VILLAGER_DATA); + public final MetaType optionalVarIntType = add(20, Types.OPTIONAL_VAR_INT); + public final MetaType poseType = add(21, Types.VAR_INT); + public final MetaType catVariantType = add(22, Types.VAR_INT); + public final MetaType wolfVariantType = add(23, Types.VAR_INT); + public final MetaType frogVariantType = add(24, Types.VAR_INT); + public final MetaType optionalGlobalPosition = add(25, Types.OPTIONAL_GLOBAL_POSITION); + public final MetaType paintingVariantType = add(26, Types.VAR_INT); + public final MetaType snifferState = add(27, Types.VAR_INT); + public final MetaType armadilloState = add(28, Types.VAR_INT); + public final MetaType vector3FType = add(29, Types.VECTOR3F); + public final MetaType quaternionType = add(30, Types.QUATERNION); public MetaTypes1_20_5(final ParticleType particleType, final ArrayType particlesType) { super(31); diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/Type.java b/api/src/main/java/com/viaversion/viaversion/api/type/Type.java index 0ed9bee90..1d0721a3d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/Type.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/Type.java @@ -22,196 +22,14 @@ */ package com.viaversion.viaversion.api.type; -import com.viaversion.nbt.tag.CompoundTag; -import com.viaversion.nbt.tag.Tag; -import com.google.gson.JsonElement; -import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; -import com.viaversion.viaversion.api.minecraft.EulerAngle; -import com.viaversion.viaversion.api.minecraft.GameProfile; -import com.viaversion.viaversion.api.minecraft.GlobalPosition; -import com.viaversion.viaversion.api.minecraft.HolderSet; -import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; -import com.viaversion.viaversion.api.minecraft.Position; -import com.viaversion.viaversion.api.minecraft.ProfileKey; -import com.viaversion.viaversion.api.minecraft.Quaternion; -import com.viaversion.viaversion.api.minecraft.RegistryEntry; -import com.viaversion.viaversion.api.minecraft.SoundEvent; -import com.viaversion.viaversion.api.minecraft.Vector; -import com.viaversion.viaversion.api.minecraft.Vector3f; -import com.viaversion.viaversion.api.minecraft.VillagerData; -import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity; -import com.viaversion.viaversion.api.minecraft.item.Item; -import com.viaversion.viaversion.api.minecraft.metadata.ChunkPosition; -import com.viaversion.viaversion.api.type.types.ArrayType; -import com.viaversion.viaversion.api.type.types.BitSetType; -import com.viaversion.viaversion.api.type.types.BooleanType; -import com.viaversion.viaversion.api.type.types.ByteArrayType; -import com.viaversion.viaversion.api.type.types.ByteType; -import com.viaversion.viaversion.api.type.types.ComponentType; -import com.viaversion.viaversion.api.type.types.DoubleType; -import com.viaversion.viaversion.api.type.types.EmptyType; -import com.viaversion.viaversion.api.type.types.FloatType; -import com.viaversion.viaversion.api.type.types.IntArrayType; -import com.viaversion.viaversion.api.type.types.IntType; -import com.viaversion.viaversion.api.type.types.LongArrayType; -import com.viaversion.viaversion.api.type.types.LongType; -import com.viaversion.viaversion.api.type.types.OptionalVarIntType; -import com.viaversion.viaversion.api.type.types.RegistryEntryType; -import com.viaversion.viaversion.api.type.types.RemainingBytesType; -import com.viaversion.viaversion.api.type.types.ShortByteArrayType; -import com.viaversion.viaversion.api.type.types.ShortType; -import com.viaversion.viaversion.api.type.types.StringType; -import com.viaversion.viaversion.api.type.types.UUIDType; -import com.viaversion.viaversion.api.type.types.UnsignedByteType; -import com.viaversion.viaversion.api.type.types.UnsignedShortType; -import com.viaversion.viaversion.api.type.types.VarIntArrayType; -import com.viaversion.viaversion.api.type.types.VarIntType; -import com.viaversion.viaversion.api.type.types.VarLongType; -import com.viaversion.viaversion.api.type.types.block.BlockChangeRecordType; -import com.viaversion.viaversion.api.type.types.block.BlockEntityType1_18; -import com.viaversion.viaversion.api.type.types.block.BlockEntityType1_20_2; -import com.viaversion.viaversion.api.type.types.block.VarLongBlockChangeRecordType; -import com.viaversion.viaversion.api.type.types.item.ItemShortArrayType1_13; -import com.viaversion.viaversion.api.type.types.item.ItemShortArrayType1_13_2; -import com.viaversion.viaversion.api.type.types.item.ItemShortArrayType1_8; -import com.viaversion.viaversion.api.type.types.item.ItemType1_13; -import com.viaversion.viaversion.api.type.types.item.ItemType1_13_2; -import com.viaversion.viaversion.api.type.types.item.ItemType1_20_2; -import com.viaversion.viaversion.api.type.types.item.ItemType1_8; -import com.viaversion.viaversion.api.type.types.math.ChunkPositionType; -import com.viaversion.viaversion.api.type.types.math.EulerAngleType; -import com.viaversion.viaversion.api.type.types.math.GlobalPositionType; -import com.viaversion.viaversion.api.type.types.math.PositionType1_14; -import com.viaversion.viaversion.api.type.types.math.PositionType1_8; -import com.viaversion.viaversion.api.type.types.math.QuaternionType; -import com.viaversion.viaversion.api.type.types.math.Vector3fType; -import com.viaversion.viaversion.api.type.types.math.VectorType; -import com.viaversion.viaversion.api.type.types.misc.CompoundTagType; -import com.viaversion.viaversion.api.type.types.misc.GameProfileType; -import com.viaversion.viaversion.api.type.types.misc.HolderSetType; -import com.viaversion.viaversion.api.type.types.misc.HolderType; -import com.viaversion.viaversion.api.type.types.misc.NamedCompoundTagType; -import com.viaversion.viaversion.api.type.types.misc.PlayerMessageSignatureType; -import com.viaversion.viaversion.api.type.types.misc.ProfileKeyType; -import com.viaversion.viaversion.api.type.types.misc.SoundEventType; -import com.viaversion.viaversion.api.type.types.misc.TagType; -import com.viaversion.viaversion.api.type.types.misc.VillagerDataType; -import com.viaversion.viaversion.util.Unit; -import java.util.UUID; - /** * Type for buffer reading and writing. * * @param read/written type + * @see Types */ public abstract class Type implements ByteBufReader, ByteBufWriter { - public static final Type EMPTY = new EmptyType(); - - public static final ByteType BYTE = new ByteType(); - public static final UnsignedByteType UNSIGNED_BYTE = new UnsignedByteType(); - public static final Type BYTE_ARRAY_PRIMITIVE = new ByteArrayType(); - public static final Type OPTIONAL_BYTE_ARRAY_PRIMITIVE = new ByteArrayType.OptionalByteArrayType(); - public static final Type SHORT_BYTE_ARRAY = new ShortByteArrayType(); - public static final Type REMAINING_BYTES = new RemainingBytesType(); - public static final Type INT_ARRAY_PRIMITIVE = new IntArrayType(); - - public static final ShortType SHORT = new ShortType(); - public static final UnsignedShortType UNSIGNED_SHORT = new UnsignedShortType(); - - public static final IntType INT = new IntType(); - public static final FloatType FLOAT = new FloatType(); - public static final FloatType.OptionalFloatType OPTIONAL_FLOAT = new FloatType.OptionalFloatType(); - public static final DoubleType DOUBLE = new DoubleType(); - - public static final LongType LONG = new LongType(); - public static final Type LONG_ARRAY_PRIMITIVE = new LongArrayType(); - - public static final BooleanType BOOLEAN = new BooleanType(); - public static final BooleanType.OptionalBooleanType OPTIONAL_BOOLEAN = new BooleanType.OptionalBooleanType(); - - /* Other Types */ - public static final Type COMPONENT = new ComponentType(); - public static final Type OPTIONAL_COMPONENT = new ComponentType.OptionalComponentType(); - - public static final Type STRING = new StringType(); - public static final Type OPTIONAL_STRING = new StringType.OptionalStringType(); - public static final Type STRING_ARRAY = new ArrayType<>(Type.STRING); - - public static final Type UUID = new UUIDType(); - public static final Type OPTIONAL_UUID = new UUIDType.OptionalUUIDType(); - public static final Type UUID_ARRAY = new ArrayType<>(Type.UUID); - - public static final VarIntType VAR_INT = new VarIntType(); - public static final OptionalVarIntType OPTIONAL_VAR_INT = new OptionalVarIntType(); - public static final Type VAR_INT_ARRAY_PRIMITIVE = new VarIntArrayType(); - public static final VarLongType VAR_LONG = new VarLongType(); - - /* MC Types */ - public static final Type POSITION1_8 = new PositionType1_8(); - public static final Type OPTIONAL_POSITION1_8 = new PositionType1_8.OptionalPositionType(); - public static final Type POSITION1_14 = new PositionType1_14(); - public static final Type OPTIONAL_POSITION_1_14 = new PositionType1_14.OptionalPosition1_14Type(); - public static final Type ROTATION = new EulerAngleType(); - public static final Type VECTOR = new VectorType(); - public static final Type VECTOR3F = new Vector3fType(); - public static final Type QUATERNION = new QuaternionType(); - - public static final Type NAMED_COMPOUND_TAG = new NamedCompoundTagType(); - public static final Type OPTIONAL_NAMED_COMPOUND_TAG = new NamedCompoundTagType.OptionalNamedCompoundTagType(); - public static final Type NAMED_COMPOUND_TAG_ARRAY = new ArrayType<>(Type.NAMED_COMPOUND_TAG); - public static final Type COMPOUND_TAG = new CompoundTagType(); - public static final Type OPTIONAL_COMPOUND_TAG = new CompoundTagType.OptionalCompoundTagType(); - public static final Type TAG = new TagType(); - public static final Type TAG_ARRAY = new ArrayType<>(TAG); - public static final Type OPTIONAL_TAG = new TagType.OptionalTagType(); - - public static final Type GLOBAL_POSITION = new GlobalPositionType(); - public static final Type OPTIONAL_GLOBAL_POSITION = new GlobalPositionType.OptionalGlobalPositionType(); - public static final Type CHUNK_POSITION = new ChunkPositionType(); - - public static final Type BLOCK_ENTITY1_18 = new BlockEntityType1_18(); - public static final Type BLOCK_ENTITY1_20_2 = new BlockEntityType1_20_2(); - - public static final Type BLOCK_CHANGE_RECORD = new BlockChangeRecordType(); - public static final Type BLOCK_CHANGE_RECORD_ARRAY = new ArrayType<>(Type.BLOCK_CHANGE_RECORD); - public static final Type VAR_LONG_BLOCK_CHANGE_RECORD = new VarLongBlockChangeRecordType(); - public static final Type VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY = new ArrayType<>(Type.VAR_LONG_BLOCK_CHANGE_RECORD); - - public static final Type VILLAGER_DATA = new VillagerDataType(); - - public static final Type GAME_PROFILE = new GameProfileType(); - public static final Type PROFILE_KEY = new ProfileKeyType(); - public static final Type OPTIONAL_PROFILE_KEY = new ProfileKeyType.OptionalProfileKeyType(); - - public static final Type PLAYER_MESSAGE_SIGNATURE = new PlayerMessageSignatureType(); - public static final Type OPTIONAL_PLAYER_MESSAGE_SIGNATURE = new PlayerMessageSignatureType.OptionalPlayerMessageSignatureType(); - public static final Type PLAYER_MESSAGE_SIGNATURE_ARRAY = new ArrayType<>(PLAYER_MESSAGE_SIGNATURE); - - public static final BitSetType PROFILE_ACTIONS_ENUM = new BitSetType(6); - public static final ByteArrayType SIGNATURE_BYTES = new ByteArrayType(256); - public static final BitSetType ACKNOWLEDGED_BIT_SET = new BitSetType(20); - public static final ByteArrayType.OptionalByteArrayType OPTIONAL_SIGNATURE_BYTES = new ByteArrayType.OptionalByteArrayType(256); - - public static final Type REGISTRY_ENTRY = new RegistryEntryType(); - public static final Type REGISTRY_ENTRY_ARRAY = new ArrayType<>(REGISTRY_ENTRY); - - public static final Type HOLDER_SET = new HolderSetType(); - public static final Type OPTIONAL_HOLDER_SET = new HolderSetType.OptionalHolderSetType(); - - public static final HolderType SOUND_EVENT = new SoundEventType(); - - public static final Type ITEM1_8 = new ItemType1_8(); - public static final Type ITEM1_13 = new ItemType1_13(); - public static final Type ITEM1_13_2 = new ItemType1_13_2(); - public static final Type ITEM1_20_2 = new ItemType1_20_2(); - public static final Type ITEM1_8_SHORT_ARRAY = new ItemShortArrayType1_8(); - public static final Type ITEM1_13_SHORT_ARRAY = new ItemShortArrayType1_13(); - public static final Type ITEM1_13_2_SHORT_ARRAY = new ItemShortArrayType1_13_2(); - public static final Type ITEM1_13_ARRAY = new ArrayType<>(ITEM1_13); - public static final Type ITEM1_13_2_ARRAY = new ArrayType<>(ITEM1_13_2); - public static final Type ITEM1_20_2_ARRAY = new ArrayType<>(ITEM1_20_2); - /* Actual Class */ private final Class outputClass; private final String typeName; diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/Types.java b/api/src/main/java/com/viaversion/viaversion/api/type/Types.java new file mode 100644 index 000000000..2cf15fa22 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/type/Types.java @@ -0,0 +1,215 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2024 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.viaversion.viaversion.api.type; + +import com.google.gson.JsonElement; +import com.viaversion.nbt.tag.CompoundTag; +import com.viaversion.nbt.tag.Tag; +import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; +import com.viaversion.viaversion.api.minecraft.EulerAngle; +import com.viaversion.viaversion.api.minecraft.GameProfile; +import com.viaversion.viaversion.api.minecraft.GlobalPosition; +import com.viaversion.viaversion.api.minecraft.HolderSet; +import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; +import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.ProfileKey; +import com.viaversion.viaversion.api.minecraft.Quaternion; +import com.viaversion.viaversion.api.minecraft.RegistryEntry; +import com.viaversion.viaversion.api.minecraft.SoundEvent; +import com.viaversion.viaversion.api.minecraft.Vector; +import com.viaversion.viaversion.api.minecraft.Vector3f; +import com.viaversion.viaversion.api.minecraft.VillagerData; +import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity; +import com.viaversion.viaversion.api.minecraft.item.Item; +import com.viaversion.viaversion.api.minecraft.item.data.Enchantments; +import com.viaversion.viaversion.api.minecraft.metadata.ChunkPosition; +import com.viaversion.viaversion.api.type.types.ArrayType; +import com.viaversion.viaversion.api.type.types.BitSetType; +import com.viaversion.viaversion.api.type.types.BooleanType; +import com.viaversion.viaversion.api.type.types.ByteArrayType; +import com.viaversion.viaversion.api.type.types.ByteType; +import com.viaversion.viaversion.api.type.types.ComponentType; +import com.viaversion.viaversion.api.type.types.DoubleType; +import com.viaversion.viaversion.api.type.types.EmptyType; +import com.viaversion.viaversion.api.type.types.FloatType; +import com.viaversion.viaversion.api.type.types.IntArrayType; +import com.viaversion.viaversion.api.type.types.IntType; +import com.viaversion.viaversion.api.type.types.LongArrayType; +import com.viaversion.viaversion.api.type.types.LongType; +import com.viaversion.viaversion.api.type.types.OptionalVarIntType; +import com.viaversion.viaversion.api.type.types.RegistryEntryType; +import com.viaversion.viaversion.api.type.types.RemainingBytesType; +import com.viaversion.viaversion.api.type.types.ShortByteArrayType; +import com.viaversion.viaversion.api.type.types.ShortType; +import com.viaversion.viaversion.api.type.types.StringType; +import com.viaversion.viaversion.api.type.types.UUIDType; +import com.viaversion.viaversion.api.type.types.UnsignedByteType; +import com.viaversion.viaversion.api.type.types.UnsignedShortType; +import com.viaversion.viaversion.api.type.types.VarIntArrayType; +import com.viaversion.viaversion.api.type.types.VarIntType; +import com.viaversion.viaversion.api.type.types.VarLongType; +import com.viaversion.viaversion.api.type.types.block.BlockChangeRecordType; +import com.viaversion.viaversion.api.type.types.block.BlockEntityType1_18; +import com.viaversion.viaversion.api.type.types.block.BlockEntityType1_20_2; +import com.viaversion.viaversion.api.type.types.block.VarLongBlockChangeRecordType; +import com.viaversion.viaversion.api.type.types.item.ItemShortArrayType1_13; +import com.viaversion.viaversion.api.type.types.item.ItemShortArrayType1_13_2; +import com.viaversion.viaversion.api.type.types.item.ItemShortArrayType1_8; +import com.viaversion.viaversion.api.type.types.item.ItemType1_13; +import com.viaversion.viaversion.api.type.types.item.ItemType1_13_2; +import com.viaversion.viaversion.api.type.types.item.ItemType1_20_2; +import com.viaversion.viaversion.api.type.types.item.ItemType1_8; +import com.viaversion.viaversion.api.type.types.math.ChunkPositionType; +import com.viaversion.viaversion.api.type.types.math.EulerAngleType; +import com.viaversion.viaversion.api.type.types.math.GlobalPositionType; +import com.viaversion.viaversion.api.type.types.math.PositionType1_14; +import com.viaversion.viaversion.api.type.types.math.PositionType1_8; +import com.viaversion.viaversion.api.type.types.math.QuaternionType; +import com.viaversion.viaversion.api.type.types.math.Vector3fType; +import com.viaversion.viaversion.api.type.types.math.VectorType; +import com.viaversion.viaversion.api.type.types.misc.CompoundTagType; +import com.viaversion.viaversion.api.type.types.misc.GameProfileType; +import com.viaversion.viaversion.api.type.types.misc.HolderSetType; +import com.viaversion.viaversion.api.type.types.misc.HolderType; +import com.viaversion.viaversion.api.type.types.misc.NamedCompoundTagType; +import com.viaversion.viaversion.api.type.types.misc.PlayerMessageSignatureType; +import com.viaversion.viaversion.api.type.types.misc.ProfileKeyType; +import com.viaversion.viaversion.api.type.types.misc.SoundEventType; +import com.viaversion.viaversion.api.type.types.misc.TagType; +import com.viaversion.viaversion.api.type.types.misc.VillagerDataType; +import com.viaversion.viaversion.api.type.types.version.Types1_20_5; +import com.viaversion.viaversion.util.Unit; +import java.util.UUID; + +/** + * Holds the mostly stable {@link Type} instances. + * Others may be held separately or object classes themselves, e.g. {@link Types1_20_5} or {@link Enchantments} + */ +public final class Types { + + public static final Type EMPTY = new EmptyType(); + + public static final ByteType BYTE = new ByteType(); + public static final UnsignedByteType UNSIGNED_BYTE = new UnsignedByteType(); + public static final Type BYTE_ARRAY_PRIMITIVE = new ByteArrayType(); + public static final Type OPTIONAL_BYTE_ARRAY_PRIMITIVE = new ByteArrayType.OptionalByteArrayType(); + public static final Type SHORT_BYTE_ARRAY = new ShortByteArrayType(); + public static final Type REMAINING_BYTES = new RemainingBytesType(); + public static final Type INT_ARRAY_PRIMITIVE = new IntArrayType(); + + public static final ShortType SHORT = new ShortType(); + public static final UnsignedShortType UNSIGNED_SHORT = new UnsignedShortType(); + + public static final IntType INT = new IntType(); + public static final FloatType FLOAT = new FloatType(); + public static final FloatType.OptionalFloatType OPTIONAL_FLOAT = new FloatType.OptionalFloatType(); + public static final DoubleType DOUBLE = new DoubleType(); + + public static final LongType LONG = new LongType(); + public static final Type LONG_ARRAY_PRIMITIVE = new LongArrayType(); + + public static final BooleanType BOOLEAN = new BooleanType(); + public static final BooleanType.OptionalBooleanType OPTIONAL_BOOLEAN = new BooleanType.OptionalBooleanType(); + + /* Other Types */ + public static final Type COMPONENT = new ComponentType(); + public static final Type OPTIONAL_COMPONENT = new ComponentType.OptionalComponentType(); + + public static final Type STRING = new StringType(); + public static final Type OPTIONAL_STRING = new StringType.OptionalStringType(); + public static final Type STRING_ARRAY = new ArrayType<>(Types.STRING); + + public static final Type UUID = new UUIDType(); + public static final Type OPTIONAL_UUID = new UUIDType.OptionalUUIDType(); + public static final Type UUID_ARRAY = new ArrayType<>(Types.UUID); + + public static final VarIntType VAR_INT = new VarIntType(); + public static final OptionalVarIntType OPTIONAL_VAR_INT = new OptionalVarIntType(); + public static final Type VAR_INT_ARRAY_PRIMITIVE = new VarIntArrayType(); + public static final VarLongType VAR_LONG = new VarLongType(); + + /* MC Types */ + public static final Type BLOCK_POSITION1_8 = new PositionType1_8(); + public static final Type OPTIONAL_POSITION1_8 = new PositionType1_8.OptionalPositionType(); + public static final Type BLOCK_POSITION1_14 = new PositionType1_14(); + public static final Type OPTIONAL_POSITION_1_14 = new PositionType1_14.OptionalPosition1_14Type(); + public static final Type ROTATIONS = new EulerAngleType(); + public static final Type VECTOR = new VectorType(); + public static final Type VECTOR3F = new Vector3fType(); + public static final Type QUATERNION = new QuaternionType(); + + public static final Type NAMED_COMPOUND_TAG = new NamedCompoundTagType(); + public static final Type OPTIONAL_NAMED_COMPOUND_TAG = new NamedCompoundTagType.OptionalNamedCompoundTagType(); + public static final Type NAMED_COMPOUND_TAG_ARRAY = new ArrayType<>(Types.NAMED_COMPOUND_TAG); + public static final Type COMPOUND_TAG = new CompoundTagType(); + public static final Type OPTIONAL_COMPOUND_TAG = new CompoundTagType.OptionalCompoundTagType(); + public static final Type TAG = new TagType(); + public static final Type TAG_ARRAY = new ArrayType<>(TAG); + public static final Type OPTIONAL_TAG = new TagType.OptionalTagType(); + + public static final Type GLOBAL_POSITION = new GlobalPositionType(); + public static final Type OPTIONAL_GLOBAL_POSITION = new GlobalPositionType.OptionalGlobalPositionType(); + public static final Type CHUNK_POSITION = new ChunkPositionType(); + + public static final Type BLOCK_ENTITY1_18 = new BlockEntityType1_18(); + public static final Type BLOCK_ENTITY1_20_2 = new BlockEntityType1_20_2(); + + public static final Type BLOCK_CHANGE = new BlockChangeRecordType(); + public static final Type BLOCK_CHANGE_ARRAY = new ArrayType<>(Types.BLOCK_CHANGE); + public static final Type VAR_LONG_BLOCK_CHANGE = new VarLongBlockChangeRecordType(); + public static final Type VAR_LONG_BLOCK_CHANGE_ARRAY = new ArrayType<>(Types.VAR_LONG_BLOCK_CHANGE); + + public static final Type VILLAGER_DATA = new VillagerDataType(); + + public static final Type GAME_PROFILE = new GameProfileType(); + public static final Type PROFILE_KEY = new ProfileKeyType(); + public static final Type OPTIONAL_PROFILE_KEY = new ProfileKeyType.OptionalProfileKeyType(); + + public static final Type PLAYER_MESSAGE_SIGNATURE = new PlayerMessageSignatureType(); + public static final Type OPTIONAL_PLAYER_MESSAGE_SIGNATURE = new PlayerMessageSignatureType.OptionalPlayerMessageSignatureType(); + public static final Type PLAYER_MESSAGE_SIGNATURE_ARRAY = new ArrayType<>(PLAYER_MESSAGE_SIGNATURE); + + public static final BitSetType PROFILE_ACTIONS_ENUM = new BitSetType(6); + public static final ByteArrayType SIGNATURE_BYTES = new ByteArrayType(256); + public static final BitSetType ACKNOWLEDGED_BIT_SET = new BitSetType(20); + public static final ByteArrayType.OptionalByteArrayType OPTIONAL_SIGNATURE_BYTES = new ByteArrayType.OptionalByteArrayType(256); + + public static final Type REGISTRY_ENTRY = new RegistryEntryType(); + public static final Type REGISTRY_ENTRY_ARRAY = new ArrayType<>(REGISTRY_ENTRY); + + public static final Type HOLDER_SET = new HolderSetType(); + public static final Type OPTIONAL_HOLDER_SET = new HolderSetType.OptionalHolderSetType(); + + public static final HolderType SOUND_EVENT = new SoundEventType(); + + public static final Type ITEM1_8 = new ItemType1_8(); + public static final Type ITEM1_13 = new ItemType1_13(); + public static final Type ITEM1_13_2 = new ItemType1_13_2(); + public static final Type ITEM1_20_2 = new ItemType1_20_2(); + public static final Type ITEM1_8_SHORT_ARRAY = new ItemShortArrayType1_8(); + public static final Type ITEM1_13_SHORT_ARRAY = new ItemShortArrayType1_13(); + public static final Type ITEM1_13_2_SHORT_ARRAY = new ItemShortArrayType1_13_2(); + public static final Type ITEM1_13_ARRAY = new ArrayType<>(ITEM1_13); + public static final Type ITEM1_13_2_ARRAY = new ArrayType<>(ITEM1_13_2); + public static final Type ITEM1_20_2_ARRAY = new ArrayType<>(ITEM1_20_2); +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/ArrayType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/ArrayType.java index 15ea76d77..6f1970e53 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/ArrayType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/ArrayType.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.type.types; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import java.lang.reflect.Array; @@ -41,7 +42,7 @@ public class ArrayType extends Type { @Override public T[] read(ByteBuf buffer) { - int amount = Type.VAR_INT.readPrimitive(buffer); + int amount = Types.VAR_INT.readPrimitive(buffer); T[] array = (T[]) Array.newInstance(elementType.getOutputClass(), amount); for (int i = 0; i < amount; i++) { @@ -52,7 +53,7 @@ public class ArrayType extends Type { @Override public void write(ByteBuf buffer, T[] object) { - Type.VAR_INT.writePrimitive(buffer, object.length); + Types.VAR_INT.writePrimitive(buffer, object.length); for (T o : object) { elementType.write(buffer, o); } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/BooleanType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/BooleanType.java index a89ad2476..99de98151 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/BooleanType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/BooleanType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.TypeConverter; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class BooleanType extends Type implements TypeConverter { @@ -55,7 +56,7 @@ public class BooleanType extends Type implements TypeConverter public static final class OptionalBooleanType extends OptionalType { public OptionalBooleanType() { - super(Type.BOOLEAN); + super(Types.BOOLEAN); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/ByteArrayType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/ByteArrayType.java index 07d318997..9a0a8b497 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/ByteArrayType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/ByteArrayType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types; import com.google.common.base.Preconditions; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class ByteArrayType extends Type { @@ -46,14 +47,14 @@ public class ByteArrayType extends Type { if (this.length != -1) { Preconditions.checkArgument(length == object.length, "Length does not match expected length"); } else { - Type.VAR_INT.writePrimitive(buffer, object.length); + Types.VAR_INT.writePrimitive(buffer, object.length); } buffer.writeBytes(object); } @Override public byte[] read(final ByteBuf buffer) { - final int length = this.length == -1 ? Type.VAR_INT.readPrimitive(buffer) : this.length; + final int length = this.length == -1 ? Types.VAR_INT.readPrimitive(buffer) : this.length; Preconditions.checkArgument(buffer.isReadable(length), "Length is fewer than readable bytes"); final byte[] array = new byte[length]; buffer.readBytes(array); @@ -63,7 +64,7 @@ public class ByteArrayType extends Type { public static final class OptionalByteArrayType extends OptionalType { public OptionalByteArrayType() { - super(Type.BYTE_ARRAY_PRIMITIVE); + super(Types.BYTE_ARRAY_PRIMITIVE); } public OptionalByteArrayType(final int length) { diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/ComponentType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/ComponentType.java index c9fdc665f..0950bde3c 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/ComponentType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/ComponentType.java @@ -28,6 +28,7 @@ import com.google.gson.JsonSyntaxException; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class ComponentType extends Type { @@ -56,7 +57,7 @@ public class ComponentType extends Type { public static final class OptionalComponentType extends OptionalType { public OptionalComponentType() { - super(Type.COMPONENT); + super(Types.COMPONENT); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/FloatType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/FloatType.java index 87569de0f..4b5b5aec6 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/FloatType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/FloatType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.TypeConverter; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class FloatType extends Type implements TypeConverter { @@ -72,7 +73,7 @@ public class FloatType extends Type implements TypeConverter { public static final class OptionalFloatType extends OptionalType { public OptionalFloatType() { - super(Type.FLOAT); + super(Types.FLOAT); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/IntArrayType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/IntArrayType.java index b44ec5a71..c0623e290 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/IntArrayType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/IntArrayType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types; import com.google.common.base.Preconditions; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class IntArrayType extends Type { @@ -46,7 +47,7 @@ public class IntArrayType extends Type { if (this.length != -1) { Preconditions.checkArgument(length == object.length, "Length does not match expected length"); } else { - Type.VAR_INT.writePrimitive(buffer, object.length); + Types.VAR_INT.writePrimitive(buffer, object.length); } for (final int i : object) { buffer.writeInt(i); @@ -55,7 +56,7 @@ public class IntArrayType extends Type { @Override public int[] read(final ByteBuf buffer) { - final int length = this.length == -1 ? Type.VAR_INT.readPrimitive(buffer) : this.length; + final int length = this.length == -1 ? Types.VAR_INT.readPrimitive(buffer) : this.length; Preconditions.checkArgument(buffer.isReadable(length), "Length is fewer than readable bytes"); final int[] array = new int[length]; for (int i = 0; i < length; i++) { diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/LongArrayType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/LongArrayType.java index 16f687876..80d2da8a7 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/LongArrayType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/LongArrayType.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.type.types; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class LongArrayType extends Type { @@ -33,7 +34,7 @@ public class LongArrayType extends Type { @Override public long[] read(ByteBuf buffer) { - int length = Type.VAR_INT.readPrimitive(buffer); + int length = Types.VAR_INT.readPrimitive(buffer); long[] array = new long[length]; for (int i = 0; i < array.length; i++) { array[i] = buffer.readLong(); @@ -43,7 +44,7 @@ public class LongArrayType extends Type { @Override public void write(ByteBuf buffer, long[] object) { - Type.VAR_INT.writePrimitive(buffer, object.length); + Types.VAR_INT.writePrimitive(buffer, object.length); for (long l : object) { buffer.writeLong(l); } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/OptionalVarIntType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/OptionalVarIntType.java index 5ba5be5b1..6638f906d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/OptionalVarIntType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/OptionalVarIntType.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.type.types; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class OptionalVarIntType extends Type { @@ -33,16 +34,16 @@ public class OptionalVarIntType extends Type { @Override public Integer read(final ByteBuf buffer) { - final int value = Type.VAR_INT.readPrimitive(buffer); + final int value = Types.VAR_INT.readPrimitive(buffer); return value == 0 ? null : value - 1; } @Override public void write(final ByteBuf buffer, final Integer object) { if (object == null) { - Type.VAR_INT.writePrimitive(buffer, 0); + Types.VAR_INT.writePrimitive(buffer, 0); } else { - Type.VAR_INT.writePrimitive(buffer, object + 1); + Types.VAR_INT.writePrimitive(buffer, object + 1); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/RegistryEntryType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/RegistryEntryType.java index 899ce0f2b..cd3cfdd42 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/RegistryEntryType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/RegistryEntryType.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types; import com.viaversion.viaversion.api.minecraft.RegistryEntry; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class RegistryEntryType extends Type { @@ -34,12 +35,12 @@ public class RegistryEntryType extends Type { @Override public RegistryEntry read(final ByteBuf buffer) { - return new RegistryEntry(Type.STRING.read(buffer), Type.OPTIONAL_TAG.read(buffer)); + return new RegistryEntry(Types.STRING.read(buffer), Types.OPTIONAL_TAG.read(buffer)); } @Override public void write(final ByteBuf buffer, final RegistryEntry entry) { - Type.STRING.write(buffer, entry.key()); - Type.OPTIONAL_TAG.write(buffer, entry.tag()); + Types.STRING.write(buffer, entry.key()); + Types.OPTIONAL_TAG.write(buffer, entry.tag()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/StringType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/StringType.java index e3cb5e735..d5360c6d6 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/StringType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/StringType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types; import com.google.common.base.Preconditions; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import java.nio.charset.StandardCharsets; @@ -45,7 +46,7 @@ public class StringType extends Type { @Override public String read(ByteBuf buffer) { - int len = Type.VAR_INT.readPrimitive(buffer); + int len = Types.VAR_INT.readPrimitive(buffer); Preconditions.checkArgument(len <= maxLength * MAX_CHAR_UTF_8_LENGTH, "Cannot receive string longer than Short.MAX_VALUE * " + MAX_CHAR_UTF_8_LENGTH + " bytes (got %s bytes)", len); @@ -66,14 +67,14 @@ public class StringType extends Type { } byte[] b = object.getBytes(StandardCharsets.UTF_8); - Type.VAR_INT.writePrimitive(buffer, b.length); + Types.VAR_INT.writePrimitive(buffer, b.length); buffer.writeBytes(b); } public static final class OptionalStringType extends OptionalType { public OptionalStringType() { - super(Type.STRING); + super(Types.STRING); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/UUIDType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/UUIDType.java index 9e2f29037..4930950c8 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/UUIDType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/UUIDType.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import java.util.UUID; @@ -47,7 +48,7 @@ public class UUIDType extends Type { public static final class OptionalUUIDType extends OptionalType { public OptionalUUIDType() { - super(Type.UUID); + super(Types.UUID); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/VarIntArrayType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/VarIntArrayType.java index 28fc86195..ac4b2388e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/VarIntArrayType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/VarIntArrayType.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types; import com.google.common.base.Preconditions; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class VarIntArrayType extends Type { @@ -33,20 +34,20 @@ public class VarIntArrayType extends Type { @Override public int[] read(ByteBuf buffer) { - int length = Type.VAR_INT.readPrimitive(buffer); + int length = Types.VAR_INT.readPrimitive(buffer); Preconditions.checkArgument(buffer.isReadable(length)); // Sanity check, at least 1 byte will be used for each varint int[] array = new int[length]; for (int i = 0; i < array.length; i++) { - array[i] = Type.VAR_INT.readPrimitive(buffer); + array[i] = Types.VAR_INT.readPrimitive(buffer); } return array; } @Override public void write(ByteBuf buffer, int[] object) { - Type.VAR_INT.writePrimitive(buffer, object.length); + Types.VAR_INT.writePrimitive(buffer, object.length); for (int i : object) { - Type.VAR_INT.writePrimitive(buffer, i); + Types.VAR_INT.writePrimitive(buffer, i); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockChangeRecordType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockChangeRecordType.java index 8024b572e..9e2ef554d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockChangeRecordType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockChangeRecordType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.block; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_8; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class BlockChangeRecordType extends Type { @@ -35,14 +36,14 @@ public class BlockChangeRecordType extends Type { @Override public BlockChangeRecord read(ByteBuf buffer) { - short position = Type.SHORT.readPrimitive(buffer); - int blockId = Type.VAR_INT.readPrimitive(buffer); + short position = Types.SHORT.readPrimitive(buffer); + int blockId = Types.VAR_INT.readPrimitive(buffer); return new BlockChangeRecord1_8(position >> 12 & 0xF, position & 0xFF, position >> 8 & 0xF, blockId); } @Override public void write(ByteBuf buffer, BlockChangeRecord object) { - Type.SHORT.writePrimitive(buffer, (short) (object.getSectionX() << 12 | object.getSectionZ() << 8 | object.getY())); - Type.VAR_INT.writePrimitive(buffer, object.getBlockId()); + Types.SHORT.writePrimitive(buffer, (short) (object.getSectionX() << 12 | object.getSectionZ() << 8 | object.getY())); + Types.VAR_INT.writePrimitive(buffer, object.getBlockId()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockEntityType1_18.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockEntityType1_18.java index d3d933310..20399e235 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockEntityType1_18.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockEntityType1_18.java @@ -26,6 +26,7 @@ import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity; import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntityImpl; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class BlockEntityType1_18 extends Type { @@ -38,8 +39,8 @@ public class BlockEntityType1_18 extends Type { public BlockEntity read(final ByteBuf buffer) { final byte xz = buffer.readByte(); final short y = buffer.readShort(); - final int typeId = Type.VAR_INT.readPrimitive(buffer); - final CompoundTag tag = Type.NAMED_COMPOUND_TAG.read(buffer); + final int typeId = Types.VAR_INT.readPrimitive(buffer); + final CompoundTag tag = Types.NAMED_COMPOUND_TAG.read(buffer); return new BlockEntityImpl(xz, y, typeId, tag); } @@ -47,7 +48,7 @@ public class BlockEntityType1_18 extends Type { public void write(final ByteBuf buffer, final BlockEntity entity) { buffer.writeByte(entity.packedXZ()); buffer.writeShort(entity.y()); - Type.VAR_INT.writePrimitive(buffer, entity.typeId()); - Type.NAMED_COMPOUND_TAG.write(buffer, entity.tag()); + Types.VAR_INT.writePrimitive(buffer, entity.typeId()); + Types.NAMED_COMPOUND_TAG.write(buffer, entity.tag()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockEntityType1_20_2.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockEntityType1_20_2.java index 6dfd56550..9ea2fd4be 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockEntityType1_20_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/block/BlockEntityType1_20_2.java @@ -26,6 +26,7 @@ import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity; import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntityImpl; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class BlockEntityType1_20_2 extends Type { @@ -38,8 +39,8 @@ public class BlockEntityType1_20_2 extends Type { public BlockEntity read(final ByteBuf buffer) { final byte xz = buffer.readByte(); final short y = buffer.readShort(); - final int typeId = Type.VAR_INT.readPrimitive(buffer); - final CompoundTag tag = Type.COMPOUND_TAG.read(buffer); + final int typeId = Types.VAR_INT.readPrimitive(buffer); + final CompoundTag tag = Types.COMPOUND_TAG.read(buffer); return new BlockEntityImpl(xz, y, typeId, tag); } @@ -47,7 +48,7 @@ public class BlockEntityType1_20_2 extends Type { public void write(final ByteBuf buffer, final BlockEntity entity) { buffer.writeByte(entity.packedXZ()); buffer.writeShort(entity.y()); - Type.VAR_INT.writePrimitive(buffer, entity.typeId()); - Type.COMPOUND_TAG.write(buffer, entity.tag()); + Types.VAR_INT.writePrimitive(buffer, entity.typeId()); + Types.COMPOUND_TAG.write(buffer, entity.tag()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/block/VarLongBlockChangeRecordType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/block/VarLongBlockChangeRecordType.java index 8bb63c129..19249953a 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/block/VarLongBlockChangeRecordType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/block/VarLongBlockChangeRecordType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.block; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_16_2; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class VarLongBlockChangeRecordType extends Type { @@ -35,7 +36,7 @@ public class VarLongBlockChangeRecordType extends Type { @Override public BlockChangeRecord read(ByteBuf buffer) { - long data = Type.VAR_LONG.readPrimitive(buffer); + long data = Types.VAR_LONG.readPrimitive(buffer); short position = (short) (data & 0xFFFL); return new BlockChangeRecord1_16_2(position >>> 8 & 0xF, position & 0xF, position >>> 4 & 0xF, (int) (data >>> 12)); } @@ -43,6 +44,6 @@ public class VarLongBlockChangeRecordType extends Type { @Override public void write(ByteBuf buffer, BlockChangeRecord object) { short position = (short) (object.getSectionX() << 8 | object.getSectionZ() << 4 | object.getSectionY()); - Type.VAR_LONG.writePrimitive(buffer, (long) object.getBlockId() << 12 | position); + Types.VAR_LONG.writePrimitive(buffer, (long) object.getBlockId() << 12 | position); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/BulkChunkType1_8.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/BulkChunkType1_8.java index 33d98f5db..84dc92be1 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/BulkChunkType1_8.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/BulkChunkType1_8.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.chunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class BulkChunkType1_8 extends Type { @@ -42,7 +43,7 @@ public class BulkChunkType1_8 extends Type { @Override public Chunk[] read(ByteBuf input) { final boolean skyLight = input.readBoolean(); - final int count = Type.VAR_INT.readPrimitive(input); + final int count = Types.VAR_INT.readPrimitive(input); final Chunk[] chunks = new Chunk[count]; final ChunkBulkSection[] chunkInfo = new ChunkBulkSection[count]; @@ -73,7 +74,7 @@ public class BulkChunkType1_8 extends Type { } } output.writeBoolean(skyLight); - Type.VAR_INT.writePrimitive(output, chunks.length); + Types.VAR_INT.writePrimitive(output, chunks.length); // Write metadata for (Chunk chunk : chunks) { diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_13.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_13.java index 6c61cf3ca..837fe2a28 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_13.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_13.java @@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionImpl; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.util.CompactArrayUtil; import io.netty.buffer.ByteBuf; @@ -50,18 +51,18 @@ public class ChunkSectionType1_13 extends Type { // Read palette ChunkSection chunkSection; if (bitsPerBlock != GLOBAL_PALETTE) { - int paletteLength = Type.VAR_INT.readPrimitive(buffer); + int paletteLength = Types.VAR_INT.readPrimitive(buffer); chunkSection = new ChunkSectionImpl(true, paletteLength); DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS); for (int i = 0; i < paletteLength; i++) { - blockPalette.addId(Type.VAR_INT.readPrimitive(buffer)); + blockPalette.addId(Types.VAR_INT.readPrimitive(buffer)); } } else { chunkSection = new ChunkSectionImpl(true); } // Read blocks - long[] blockData = Type.LONG_ARRAY_PRIMITIVE.read(buffer); + long[] blockData = Types.LONG_ARRAY_PRIMITIVE.read(buffer); if (blockData.length > 0) { int expectedLength = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0); if (blockData.length == expectedLength) { @@ -90,14 +91,14 @@ public class ChunkSectionType1_13 extends Type { // Write palette if (bitsPerBlock != GLOBAL_PALETTE) { - Type.VAR_INT.writePrimitive(buffer, blockPalette.size()); + Types.VAR_INT.writePrimitive(buffer, blockPalette.size()); for (int i = 0; i < blockPalette.size(); i++) { - Type.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i)); + Types.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i)); } } long[] data = CompactArrayUtil.createCompactArray(bitsPerBlock, ChunkSection.SIZE, bitsPerBlock == GLOBAL_PALETTE ? blockPalette::idAt : blockPalette::paletteIndexAt); - Type.LONG_ARRAY_PRIMITIVE.write(buffer, data); + Types.LONG_ARRAY_PRIMITIVE.write(buffer, data); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_16.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_16.java index bb5429b2c..02170562d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_16.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_16.java @@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionImpl; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.util.CompactArrayUtil; import io.netty.buffer.ByteBuf; @@ -50,18 +51,18 @@ public class ChunkSectionType1_16 extends Type { // Read palette ChunkSection chunkSection; if (bitsPerBlock != GLOBAL_PALETTE) { - int paletteLength = Type.VAR_INT.readPrimitive(buffer); + int paletteLength = Types.VAR_INT.readPrimitive(buffer); chunkSection = new ChunkSectionImpl(false, paletteLength); DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS); for (int i = 0; i < paletteLength; i++) { - blockPalette.addId(Type.VAR_INT.readPrimitive(buffer)); + blockPalette.addId(Types.VAR_INT.readPrimitive(buffer)); } } else { chunkSection = new ChunkSectionImpl(false); } // Read blocks - long[] blockData = Type.LONG_ARRAY_PRIMITIVE.read(buffer); + long[] blockData = Types.LONG_ARRAY_PRIMITIVE.read(buffer); if (blockData.length > 0) { char valuesPerLong = (char) (64 / bitsPerBlock); int expectedLength = (ChunkSection.SIZE + valuesPerLong - 1) / valuesPerLong; @@ -91,14 +92,14 @@ public class ChunkSectionType1_16 extends Type { // Write palette if (bitsPerBlock != GLOBAL_PALETTE) { - Type.VAR_INT.writePrimitive(buffer, blockPalette.size()); + Types.VAR_INT.writePrimitive(buffer, blockPalette.size()); for (int i = 0; i < blockPalette.size(); i++) { - Type.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i)); + Types.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i)); } } long[] data = CompactArrayUtil.createCompactArrayWithPadding(bitsPerBlock, ChunkSection.SIZE, bitsPerBlock == GLOBAL_PALETTE ? blockPalette::idAt : blockPalette::paletteIndexAt); - Type.LONG_ARRAY_PRIMITIVE.write(buffer, data); + Types.LONG_ARRAY_PRIMITIVE.write(buffer, data); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_9.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_9.java index 3532f6cde..7427cabbb 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_9.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkSectionType1_9.java @@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionImpl; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.util.CompactArrayUtil; import io.netty.buffer.ByteBuf; @@ -49,19 +50,19 @@ public class ChunkSectionType1_9 extends Type { } // Read palette - int paletteLength = Type.VAR_INT.readPrimitive(buffer); + int paletteLength = Types.VAR_INT.readPrimitive(buffer); ChunkSection chunkSection = bitsPerBlock != GLOBAL_PALETTE ? new ChunkSectionImpl(true, paletteLength) : new ChunkSectionImpl(true); DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS); for (int i = 0; i < paletteLength; i++) { if (bitsPerBlock != GLOBAL_PALETTE) { - blockPalette.addId(Type.VAR_INT.readPrimitive(buffer)); + blockPalette.addId(Types.VAR_INT.readPrimitive(buffer)); } else { - Type.VAR_INT.readPrimitive(buffer); + Types.VAR_INT.readPrimitive(buffer); } } // Read blocks - long[] blockData = Type.LONG_ARRAY_PRIMITIVE.read(buffer); + long[] blockData = Types.LONG_ARRAY_PRIMITIVE.read(buffer); if (blockData.length > 0) { int expectedLength = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0); if (blockData.length == expectedLength) { @@ -89,16 +90,16 @@ public class ChunkSectionType1_9 extends Type { // Write palette if (bitsPerBlock != GLOBAL_PALETTE) { - Type.VAR_INT.writePrimitive(buffer, blockPalette.size()); + Types.VAR_INT.writePrimitive(buffer, blockPalette.size()); for (int i = 0; i < blockPalette.size(); i++) { - Type.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i)); + Types.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i)); } } else { - Type.VAR_INT.writePrimitive(buffer, 0); + Types.VAR_INT.writePrimitive(buffer, 0); } long[] data = CompactArrayUtil.createCompactArray(bitsPerBlock, ChunkSection.SIZE, bitsPerBlock == GLOBAL_PALETTE ? blockPalette::idAt : blockPalette::paletteIndexAt); - Type.LONG_ARRAY_PRIMITIVE.write(buffer, data); + Types.LONG_ARRAY_PRIMITIVE.write(buffer, data); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_13.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_13.java index 54cf9d1cb..78b457337 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_13.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_13.java @@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_13; import io.netty.buffer.ByteBuf; import java.util.ArrayList; @@ -57,8 +58,8 @@ public class ChunkType1_13 extends Type { int chunkZ = input.readInt(); boolean fullChunk = input.readBoolean(); - int primaryBitmask = Type.VAR_INT.readPrimitive(input); - ByteBuf data = input.readSlice(Type.VAR_INT.readPrimitive(input)); + int primaryBitmask = Types.VAR_INT.readPrimitive(input); + ByteBuf data = input.readSlice(Types.VAR_INT.readPrimitive(input)); // Read sections ChunkSection[] sections = new ChunkSection[16]; @@ -84,7 +85,7 @@ public class ChunkType1_13 extends Type { } } - List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Types.NAMED_COMPOUND_TAG_ARRAY.read(input))); return new BaseChunk(chunkX, chunkZ, fullChunk, false, primaryBitmask, sections, biomeData, nbtData); } @@ -94,7 +95,7 @@ public class ChunkType1_13 extends Type { output.writeInt(chunk.getZ()); output.writeBoolean(chunk.isFullChunk()); - Type.VAR_INT.writePrimitive(output, chunk.getBitmask()); + Types.VAR_INT.writePrimitive(output, chunk.getBitmask()); ByteBuf buf = output.alloc().buffer(); try { @@ -109,7 +110,7 @@ public class ChunkType1_13 extends Type { } buf.readerIndex(0); - Type.VAR_INT.writePrimitive(output, buf.readableBytes() + (chunk.isBiomeData() ? 1024 : 0)); + Types.VAR_INT.writePrimitive(output, buf.readableBytes() + (chunk.isBiomeData() ? 1024 : 0)); output.writeBytes(buf); } finally { buf.release(); // release buffer @@ -123,6 +124,6 @@ public class ChunkType1_13 extends Type { } // Write Block Entities - Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); + Types.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_14.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_14.java index 280d0983c..f6d0ca2a5 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_14.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_14.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_13; import io.netty.buffer.ByteBuf; import java.util.ArrayList; @@ -48,9 +49,9 @@ public class ChunkType1_14 extends Type { int chunkZ = input.readInt(); boolean fullChunk = input.readBoolean(); - int primaryBitmask = Type.VAR_INT.readPrimitive(input); - CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(input); - ByteBuf data = input.readSlice(Type.VAR_INT.readPrimitive(input)); + int primaryBitmask = Types.VAR_INT.readPrimitive(input); + CompoundTag heightMap = Types.NAMED_COMPOUND_TAG.read(input); + ByteBuf data = input.readSlice(Types.VAR_INT.readPrimitive(input)); // Read sections ChunkSection[] sections = new ChunkSection[16]; @@ -70,7 +71,7 @@ public class ChunkType1_14 extends Type { } } - List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Types.NAMED_COMPOUND_TAG_ARRAY.read(input))); return new BaseChunk(chunkX, chunkZ, fullChunk, false, primaryBitmask, sections, biomeData, heightMap, nbtData); } @@ -80,8 +81,8 @@ public class ChunkType1_14 extends Type { output.writeInt(chunk.getZ()); output.writeBoolean(chunk.isFullChunk()); - Type.VAR_INT.writePrimitive(output, chunk.getBitmask()); - Type.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); + Types.VAR_INT.writePrimitive(output, chunk.getBitmask()); + Types.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); ByteBuf buf = output.alloc().buffer(); try { @@ -93,7 +94,7 @@ public class ChunkType1_14 extends Type { Types1_13.CHUNK_SECTION.write(buf, section); } buf.readerIndex(0); - Type.VAR_INT.writePrimitive(output, buf.readableBytes() + (chunk.isBiomeData() ? 1024 : 0)); // 256 * 4 + Types.VAR_INT.writePrimitive(output, buf.readableBytes() + (chunk.isBiomeData() ? 1024 : 0)); // 256 * 4 output.writeBytes(buf); } finally { buf.release(); // release buffer @@ -107,6 +108,6 @@ public class ChunkType1_14 extends Type { } // Write Block Entities - Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); + Types.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_15.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_15.java index ba5326e68..f884e62a4 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_15.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_15.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_13; import io.netty.buffer.ByteBuf; import java.util.ArrayList; @@ -48,8 +49,8 @@ public class ChunkType1_15 extends Type { int chunkZ = input.readInt(); boolean fullChunk = input.readBoolean(); - int primaryBitmask = Type.VAR_INT.readPrimitive(input); - CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(input); + int primaryBitmask = Types.VAR_INT.readPrimitive(input); + CompoundTag heightMap = Types.NAMED_COMPOUND_TAG.read(input); int[] biomeData = fullChunk ? new int[1024] : null; if (fullChunk) { @@ -58,7 +59,7 @@ public class ChunkType1_15 extends Type { } } - ByteBuf data = input.readSlice(Type.VAR_INT.readPrimitive(input)); + ByteBuf data = input.readSlice(Types.VAR_INT.readPrimitive(input)); // Read sections ChunkSection[] sections = new ChunkSection[16]; @@ -71,7 +72,7 @@ public class ChunkType1_15 extends Type { sections[i] = section; } - List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Types.NAMED_COMPOUND_TAG_ARRAY.read(input))); return new BaseChunk(chunkX, chunkZ, fullChunk, false, primaryBitmask, sections, biomeData, heightMap, nbtData); } @@ -81,8 +82,8 @@ public class ChunkType1_15 extends Type { output.writeInt(chunk.getZ()); output.writeBoolean(chunk.isFullChunk()); - Type.VAR_INT.writePrimitive(output, chunk.getBitmask()); - Type.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); + Types.VAR_INT.writePrimitive(output, chunk.getBitmask()); + Types.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); // Write biome data if (chunk.isBiomeData()) { @@ -101,13 +102,13 @@ public class ChunkType1_15 extends Type { Types1_13.CHUNK_SECTION.write(buf, section); } buf.readerIndex(0); - Type.VAR_INT.writePrimitive(output, buf.readableBytes()); + Types.VAR_INT.writePrimitive(output, buf.readableBytes()); output.writeBytes(buf); } finally { buf.release(); // release buffer } // Write Block Entities - Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); + Types.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_16.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_16.java index 23053bed4..88f9d5568 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_16.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_16.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_16; import io.netty.buffer.ByteBuf; import java.util.ArrayList; @@ -49,8 +50,8 @@ public class ChunkType1_16 extends Type { boolean fullChunk = input.readBoolean(); boolean ignoreOldLightData = input.readBoolean(); - int primaryBitmask = Type.VAR_INT.readPrimitive(input); - CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(input); + int primaryBitmask = Types.VAR_INT.readPrimitive(input); + CompoundTag heightMap = Types.NAMED_COMPOUND_TAG.read(input); int[] biomeData = fullChunk ? new int[1024] : null; if (fullChunk) { @@ -59,7 +60,7 @@ public class ChunkType1_16 extends Type { } } - ByteBuf data = input.readSlice(Type.VAR_INT.readPrimitive(input)); + ByteBuf data = input.readSlice(Types.VAR_INT.readPrimitive(input)); // Read sections ChunkSection[] sections = new ChunkSection[16]; @@ -72,7 +73,7 @@ public class ChunkType1_16 extends Type { sections[i] = section; } - List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Types.NAMED_COMPOUND_TAG_ARRAY.read(input))); return new BaseChunk(chunkX, chunkZ, fullChunk, ignoreOldLightData, primaryBitmask, sections, biomeData, heightMap, nbtData); } @@ -83,8 +84,8 @@ public class ChunkType1_16 extends Type { output.writeBoolean(chunk.isFullChunk()); output.writeBoolean(chunk.isIgnoreOldLightData()); - Type.VAR_INT.writePrimitive(output, chunk.getBitmask()); - Type.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); + Types.VAR_INT.writePrimitive(output, chunk.getBitmask()); + Types.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); // Write biome data if (chunk.isBiomeData()) { @@ -103,13 +104,13 @@ public class ChunkType1_16 extends Type { Types1_16.CHUNK_SECTION.write(buf, section); } buf.readerIndex(0); - Type.VAR_INT.writePrimitive(output, buf.readableBytes()); + Types.VAR_INT.writePrimitive(output, buf.readableBytes()); output.writeBytes(buf); } finally { buf.release(); // release buffer } // Write Block Entities - Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); + Types.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_16_2.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_16_2.java index 75cf32a2c..73046b8ae 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_16_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_16_2.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_16; import io.netty.buffer.ByteBuf; import java.util.ArrayList; @@ -48,15 +49,15 @@ public class ChunkType1_16_2 extends Type { int chunkZ = input.readInt(); boolean fullChunk = input.readBoolean(); - int primaryBitmask = Type.VAR_INT.readPrimitive(input); - CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(input); + int primaryBitmask = Types.VAR_INT.readPrimitive(input); + CompoundTag heightMap = Types.NAMED_COMPOUND_TAG.read(input); int[] biomeData = null; if (fullChunk) { - biomeData = Type.VAR_INT_ARRAY_PRIMITIVE.read(input); + biomeData = Types.VAR_INT_ARRAY_PRIMITIVE.read(input); } - ByteBuf data = input.readSlice(Type.VAR_INT.readPrimitive(input)); + ByteBuf data = input.readSlice(Types.VAR_INT.readPrimitive(input)); // Read sections ChunkSection[] sections = new ChunkSection[16]; @@ -69,7 +70,7 @@ public class ChunkType1_16_2 extends Type { sections[i] = section; } - List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Types.NAMED_COMPOUND_TAG_ARRAY.read(input))); return new BaseChunk(chunkX, chunkZ, fullChunk, false, primaryBitmask, sections, biomeData, heightMap, nbtData); } @@ -79,12 +80,12 @@ public class ChunkType1_16_2 extends Type { output.writeInt(chunk.getZ()); output.writeBoolean(chunk.isFullChunk()); - Type.VAR_INT.writePrimitive(output, chunk.getBitmask()); - Type.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); + Types.VAR_INT.writePrimitive(output, chunk.getBitmask()); + Types.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); // Write biome data if (chunk.isBiomeData()) { - Type.VAR_INT_ARRAY_PRIMITIVE.write(output, chunk.getBiomeData()); + Types.VAR_INT_ARRAY_PRIMITIVE.write(output, chunk.getBiomeData()); } ByteBuf buf = output.alloc().buffer(); @@ -97,13 +98,13 @@ public class ChunkType1_16_2 extends Type { Types1_16.CHUNK_SECTION.write(buf, section); } buf.readerIndex(0); - Type.VAR_INT.writePrimitive(output, buf.readableBytes()); + Types.VAR_INT.writePrimitive(output, buf.readableBytes()); output.writeBytes(buf); } finally { buf.release(); // release buffer } // Write Block Entities - Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); + Types.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_17.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_17.java index b55f15467..d00fbc084 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_17.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_17.java @@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_16; import io.netty.buffer.ByteBuf; import java.util.ArrayList; @@ -51,12 +52,12 @@ public final class ChunkType1_17 extends Type { int chunkX = input.readInt(); int chunkZ = input.readInt(); - BitSet sectionsMask = BitSet.valueOf(Type.LONG_ARRAY_PRIMITIVE.read(input)); - CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(input); + BitSet sectionsMask = BitSet.valueOf(Types.LONG_ARRAY_PRIMITIVE.read(input)); + CompoundTag heightMap = Types.NAMED_COMPOUND_TAG.read(input); - int[] biomeData = Type.VAR_INT_ARRAY_PRIMITIVE.read(input); + int[] biomeData = Types.VAR_INT_ARRAY_PRIMITIVE.read(input); - ByteBuf data = input.readSlice(Type.VAR_INT.readPrimitive(input)); + ByteBuf data = input.readSlice(Types.VAR_INT.readPrimitive(input)); // Read sections ChunkSection[] sections = new ChunkSection[ySectionCount]; @@ -69,7 +70,7 @@ public final class ChunkType1_17 extends Type { sections[i] = section; } - List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Types.NAMED_COMPOUND_TAG_ARRAY.read(input))); return new BaseChunk(chunkX, chunkZ, true, false, sectionsMask, sections, biomeData, heightMap, nbtData); } @@ -78,11 +79,11 @@ public final class ChunkType1_17 extends Type { output.writeInt(chunk.getX()); output.writeInt(chunk.getZ()); - Type.LONG_ARRAY_PRIMITIVE.write(output, chunk.getChunkMask().toLongArray()); - Type.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); + Types.LONG_ARRAY_PRIMITIVE.write(output, chunk.getChunkMask().toLongArray()); + Types.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); // Write biome data - Type.VAR_INT_ARRAY_PRIMITIVE.write(output, chunk.getBiomeData()); + Types.VAR_INT_ARRAY_PRIMITIVE.write(output, chunk.getBiomeData()); ByteBuf buf = output.alloc().buffer(); try { @@ -94,13 +95,13 @@ public final class ChunkType1_17 extends Type { Types1_16.CHUNK_SECTION.write(buf, section); } buf.readerIndex(0); - Type.VAR_INT.writePrimitive(output, buf.readableBytes()); + Types.VAR_INT.writePrimitive(output, buf.readableBytes()); output.writeBytes(buf); } finally { buf.release(); // release buffer } // Write Block Entities - Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); + Types.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_18.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_18.java index d2c81898c..1c13f845d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_18.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_18.java @@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk1_18; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; @@ -48,10 +49,10 @@ public final class ChunkType1_18 extends Type { public Chunk read(final ByteBuf buffer) { final int chunkX = buffer.readInt(); final int chunkZ = buffer.readInt(); - final CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(buffer); + final CompoundTag heightMap = Types.NAMED_COMPOUND_TAG.read(buffer); // Read sections - final ByteBuf sectionsBuf = buffer.readBytes(Type.VAR_INT.readPrimitive(buffer)); + final ByteBuf sectionsBuf = buffer.readBytes(Types.VAR_INT.readPrimitive(buffer)); final ChunkSection[] sections = new ChunkSection[ySectionCount]; try { for (int i = 0; i < ySectionCount; i++) { @@ -61,10 +62,10 @@ public final class ChunkType1_18 extends Type { sectionsBuf.release(); } - final int blockEntitiesLength = Type.VAR_INT.readPrimitive(buffer); + final int blockEntitiesLength = Types.VAR_INT.readPrimitive(buffer); final List blockEntities = new ArrayList<>(blockEntitiesLength); for (int i = 0; i < blockEntitiesLength; i++) { - blockEntities.add(Type.BLOCK_ENTITY1_18.read(buffer)); + blockEntities.add(Types.BLOCK_ENTITY1_18.read(buffer)); } return new Chunk1_18(chunkX, chunkZ, sections, heightMap, blockEntities); @@ -75,7 +76,7 @@ public final class ChunkType1_18 extends Type { buffer.writeInt(chunk.getX()); buffer.writeInt(chunk.getZ()); - Type.NAMED_COMPOUND_TAG.write(buffer, chunk.getHeightMap()); + Types.NAMED_COMPOUND_TAG.write(buffer, chunk.getHeightMap()); final ByteBuf sectionBuffer = buffer.alloc().buffer(); try { @@ -83,15 +84,15 @@ public final class ChunkType1_18 extends Type { sectionType.write(sectionBuffer, section); } sectionBuffer.readerIndex(0); - Type.VAR_INT.writePrimitive(buffer, sectionBuffer.readableBytes()); + Types.VAR_INT.writePrimitive(buffer, sectionBuffer.readableBytes()); buffer.writeBytes(sectionBuffer); } finally { sectionBuffer.release(); // release buffer } - Type.VAR_INT.writePrimitive(buffer, chunk.blockEntities().size()); + Types.VAR_INT.writePrimitive(buffer, chunk.blockEntities().size()); for (final BlockEntity blockEntity : chunk.blockEntities()) { - Type.BLOCK_ENTITY1_18.write(buffer, blockEntity); + Types.BLOCK_ENTITY1_18.write(buffer, blockEntity); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_20_2.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_20_2.java index 26dfe556b..c679cd5a1 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_20_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_20_2.java @@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk1_18; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; @@ -48,10 +49,10 @@ public final class ChunkType1_20_2 extends Type { public Chunk read(final ByteBuf buffer) { final int chunkX = buffer.readInt(); final int chunkZ = buffer.readInt(); - final CompoundTag heightMap = Type.COMPOUND_TAG.read(buffer); + final CompoundTag heightMap = Types.COMPOUND_TAG.read(buffer); // Read sections - final ByteBuf sectionsBuf = buffer.readBytes(Type.VAR_INT.readPrimitive(buffer)); + final ByteBuf sectionsBuf = buffer.readBytes(Types.VAR_INT.readPrimitive(buffer)); final ChunkSection[] sections = new ChunkSection[ySectionCount]; try { for (int i = 0; i < ySectionCount; i++) { @@ -61,10 +62,10 @@ public final class ChunkType1_20_2 extends Type { sectionsBuf.release(); } - final int blockEntitiesLength = Type.VAR_INT.readPrimitive(buffer); + final int blockEntitiesLength = Types.VAR_INT.readPrimitive(buffer); final List blockEntities = new ArrayList<>(blockEntitiesLength); for (int i = 0; i < blockEntitiesLength; i++) { - blockEntities.add(Type.BLOCK_ENTITY1_20_2.read(buffer)); + blockEntities.add(Types.BLOCK_ENTITY1_20_2.read(buffer)); } return new Chunk1_18(chunkX, chunkZ, sections, heightMap, blockEntities); @@ -75,7 +76,7 @@ public final class ChunkType1_20_2 extends Type { buffer.writeInt(chunk.getX()); buffer.writeInt(chunk.getZ()); - Type.COMPOUND_TAG.write(buffer, chunk.getHeightMap()); + Types.COMPOUND_TAG.write(buffer, chunk.getHeightMap()); final ByteBuf sectionBuffer = buffer.alloc().buffer(); try { @@ -83,15 +84,15 @@ public final class ChunkType1_20_2 extends Type { sectionType.write(sectionBuffer, section); } sectionBuffer.readerIndex(0); - Type.VAR_INT.writePrimitive(buffer, sectionBuffer.readableBytes()); + Types.VAR_INT.writePrimitive(buffer, sectionBuffer.readableBytes()); buffer.writeBytes(sectionBuffer); } finally { sectionBuffer.release(); // release buffer } - Type.VAR_INT.writePrimitive(buffer, chunk.blockEntities().size()); + Types.VAR_INT.writePrimitive(buffer, chunk.blockEntities().size()); for (final BlockEntity blockEntity : chunk.blockEntities()) { - Type.BLOCK_ENTITY1_20_2.write(buffer, blockEntity); + Types.BLOCK_ENTITY1_20_2.write(buffer, blockEntity); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_8.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_8.java index c0817604d..e86373b84 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_8.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_8.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_8; import com.viaversion.viaversion.util.ChunkUtil; import io.netty.buffer.ByteBuf; @@ -57,7 +58,7 @@ public class ChunkType1_8 extends Type { final int chunkZ = input.readInt(); final boolean fullChunk = input.readBoolean(); final int bitmask = input.readUnsignedShort(); - final int dataLength = Type.VAR_INT.readPrimitive(input); + final int dataLength = Types.VAR_INT.readPrimitive(input); final byte[] data = new byte[dataLength]; input.readBytes(data); @@ -81,7 +82,7 @@ public class ChunkType1_8 extends Type { output.writeBoolean(chunk.isFullChunk()); output.writeShort(chunk.getBitmask()); final byte[] data = serialize(chunk); - Type.VAR_INT.writePrimitive(output, data.length); + Types.VAR_INT.writePrimitive(output, data.length); output.writeBytes(data); } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_9_1.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_9_1.java index 3ab0f6b12..80f422c10 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_9_1.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_9_1.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_9; import com.viaversion.viaversion.util.ChunkUtil; import io.netty.buffer.ByteBuf; @@ -57,8 +58,8 @@ public class ChunkType1_9_1 extends Type { int chunkZ = input.readInt(); boolean groundUp = input.readBoolean(); - int primaryBitmask = Type.VAR_INT.readPrimitive(input); - ByteBuf data = input.readSlice(Type.VAR_INT.readPrimitive(input)); + int primaryBitmask = Types.VAR_INT.readPrimitive(input); + ByteBuf data = input.readSlice(Types.VAR_INT.readPrimitive(input)); ChunkSection[] sections = new ChunkSection[16]; int[] biomeData = groundUp ? new int[256] : null; @@ -101,7 +102,7 @@ public class ChunkType1_9_1 extends Type { output.writeInt(chunk.getZ()); output.writeBoolean(chunk.isFullChunk()); - Type.VAR_INT.writePrimitive(output, chunk.getBitmask()); + Types.VAR_INT.writePrimitive(output, chunk.getBitmask()); ByteBuf buf = output.alloc().buffer(); try { @@ -116,7 +117,7 @@ public class ChunkType1_9_1 extends Type { } buf.readerIndex(0); - Type.VAR_INT.writePrimitive(output, buf.readableBytes() + (chunk.isBiomeData() ? 256 : 0)); + Types.VAR_INT.writePrimitive(output, buf.readableBytes() + (chunk.isBiomeData() ? 256 : 0)); output.writeBytes(buf); } finally { buf.release(); // release buffer diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_9_3.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_9_3.java index 94d2ad4ba..3e05e20a6 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_9_3.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/ChunkType1_9_3.java @@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_9; import com.viaversion.viaversion.util.ChunkUtil; import io.netty.buffer.ByteBuf; @@ -59,8 +60,8 @@ public class ChunkType1_9_3 extends Type { int chunkZ = input.readInt(); boolean fullChunk = input.readBoolean(); - int primaryBitmask = Type.VAR_INT.readPrimitive(input); - ByteBuf data = input.readSlice(Type.VAR_INT.readPrimitive(input)); + int primaryBitmask = Types.VAR_INT.readPrimitive(input); + ByteBuf data = input.readSlice(Types.VAR_INT.readPrimitive(input)); ChunkSection[] sections = new ChunkSection[16]; int[] biomeData = fullChunk ? new int[256] : null; @@ -87,7 +88,7 @@ public class ChunkType1_9_3 extends Type { return ChunkUtil.createEmptyChunk(chunkX, chunkZ); } - List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Types.NAMED_COMPOUND_TAG_ARRAY.read(input))); return new BaseChunk(chunkX, chunkZ, fullChunk, false, primaryBitmask, sections, biomeData, nbtData); } @@ -97,7 +98,7 @@ public class ChunkType1_9_3 extends Type { output.writeInt(chunk.getZ()); output.writeBoolean(chunk.isFullChunk()); - Type.VAR_INT.writePrimitive(output, chunk.getBitmask()); + Types.VAR_INT.writePrimitive(output, chunk.getBitmask()); ByteBuf buf = output.alloc().buffer(); try { @@ -111,7 +112,7 @@ public class ChunkType1_9_3 extends Type { section.getLight().writeSkyLight(buf); } buf.readerIndex(0); - Type.VAR_INT.writePrimitive(output, buf.readableBytes() + (chunk.isBiomeData() ? 256 : 0)); + Types.VAR_INT.writePrimitive(output, buf.readableBytes() + (chunk.isBiomeData() ? 256 : 0)); output.writeBytes(buf); } finally { buf.release(); // release buffer @@ -125,6 +126,6 @@ public class ChunkType1_9_3 extends Type { } // Write Block Entities - Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); + Types.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/PaletteType1_18.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/PaletteType1_18.java index f84fa63dc..01fa1fb9d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/PaletteType1_18.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/chunk/PaletteType1_18.java @@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.DataPaletteImpl; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.util.CompactArrayUtil; import com.viaversion.viaversion.util.MathUtil; import io.netty.buffer.ByteBuf; @@ -47,8 +48,8 @@ public final class PaletteType1_18 extends Type { if (bitsPerValue == 0) { // Single value storage palette = new DataPaletteImpl(type.size(), 1); - palette.addId(Type.VAR_INT.readPrimitive(buffer)); - Type.LONG_ARRAY_PRIMITIVE.read(buffer); // Just eat it if not empty - thanks, Hypixel + palette.addId(Types.VAR_INT.readPrimitive(buffer)); + Types.LONG_ARRAY_PRIMITIVE.read(buffer); // Just eat it if not empty - thanks, Hypixel return palette; } @@ -60,17 +61,17 @@ public final class PaletteType1_18 extends Type { // Read palette if (bitsPerValue != globalPaletteBits) { - final int paletteLength = Type.VAR_INT.readPrimitive(buffer); + final int paletteLength = Types.VAR_INT.readPrimitive(buffer); palette = new DataPaletteImpl(type.size(), paletteLength); for (int i = 0; i < paletteLength; i++) { - palette.addId(Type.VAR_INT.readPrimitive(buffer)); + palette.addId(Types.VAR_INT.readPrimitive(buffer)); } } else { palette = new DataPaletteImpl(type.size()); } // Read values - final long[] values = Type.LONG_ARRAY_PRIMITIVE.read(buffer); + final long[] values = Types.LONG_ARRAY_PRIMITIVE.read(buffer); if (values.length > 0) { final int valuesPerLong = (char) (64 / bitsPerValue); final int expectedLength = (type.size() + valuesPerLong - 1) / valuesPerLong; @@ -88,8 +89,8 @@ public final class PaletteType1_18 extends Type { if (size == 1) { // Single value palette buffer.writeByte(0); // 0 bit storage - Type.VAR_INT.writePrimitive(buffer, palette.idByIndex(0)); - Type.VAR_INT.writePrimitive(buffer, 0); // Empty values length + Types.VAR_INT.writePrimitive(buffer, palette.idByIndex(0)); + Types.VAR_INT.writePrimitive(buffer, 0); // Empty values length return; } @@ -104,12 +105,12 @@ public final class PaletteType1_18 extends Type { if (bitsPerValue != globalPaletteBits) { // Write palette - Type.VAR_INT.writePrimitive(buffer, size); + Types.VAR_INT.writePrimitive(buffer, size); for (int i = 0; i < size; i++) { - Type.VAR_INT.writePrimitive(buffer, palette.idByIndex(i)); + Types.VAR_INT.writePrimitive(buffer, palette.idByIndex(i)); } } - Type.LONG_ARRAY_PRIMITIVE.write(buffer, CompactArrayUtil.createCompactArrayWithPadding(bitsPerValue, type.size(), bitsPerValue == globalPaletteBits ? palette::idAt : palette::paletteIndexAt)); + Types.LONG_ARRAY_PRIMITIVE.write(buffer, CompactArrayUtil.createCompactArrayWithPadding(bitsPerValue, type.size(), bitsPerValue == globalPaletteBits ? palette::idAt : palette::paletteIndexAt)); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemCostType1_20_5.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemCostType1_20_5.java index c5e2f3cd3..3da160294 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemCostType1_20_5.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemCostType1_20_5.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.StructuredItem; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; // Very similar to normal items (and just results in an item), except it allows non-positive amounts and has id/amount swapped because ??? @@ -43,16 +44,16 @@ public final class ItemCostType1_20_5 extends Type { @Override public Item read(final ByteBuf buffer) { - final int id = Type.VAR_INT.readPrimitive(buffer); - final int amount = Type.VAR_INT.readPrimitive(buffer); + final int id = Types.VAR_INT.readPrimitive(buffer); + final int amount = Types.VAR_INT.readPrimitive(buffer); final StructuredData[] dataArray = dataArrayType.read(buffer); return new StructuredItem(id, amount, new StructuredDataContainer(dataArray)); } @Override public void write(final ByteBuf buffer, final Item object) { - Type.VAR_INT.writePrimitive(buffer, object.identifier()); - Type.VAR_INT.writePrimitive(buffer, object.amount()); + Types.VAR_INT.writePrimitive(buffer, object.identifier()); + Types.VAR_INT.writePrimitive(buffer, object.amount()); dataArrayType.write(buffer, object.structuredData().data().values().toArray(EMPTY_DATA_ARRAY)); } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_13.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_13.java index 9e6e35130..accbebe15 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_13.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_13.java @@ -24,25 +24,26 @@ package com.viaversion.viaversion.api.type.types.item; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class ItemShortArrayType1_13 extends BaseItemArrayType { @Override public Item[] read(ByteBuf buffer) { - int amount = Type.SHORT.readPrimitive(buffer); + int amount = Types.SHORT.readPrimitive(buffer); Item[] array = new Item[amount]; for (int i = 0; i < amount; i++) { - array[i] = Type.ITEM1_13.read(buffer); + array[i] = Types.ITEM1_13.read(buffer); } return array; } @Override public void write(ByteBuf buffer, Item[] object) { - Type.SHORT.writePrimitive(buffer, (short) object.length); + Types.SHORT.writePrimitive(buffer, (short) object.length); for (Item o : object) { - Type.ITEM1_13.write(buffer, o); + Types.ITEM1_13.write(buffer, o); } } } \ No newline at end of file diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_13_2.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_13_2.java index 68b199344..c5477d850 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_13_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_13_2.java @@ -24,25 +24,26 @@ package com.viaversion.viaversion.api.type.types.item; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class ItemShortArrayType1_13_2 extends BaseItemArrayType { @Override public Item[] read(ByteBuf buffer) { - int amount = Type.SHORT.readPrimitive(buffer); + int amount = Types.SHORT.readPrimitive(buffer); Item[] array = new Item[amount]; for (int i = 0; i < amount; i++) { - array[i] = Type.ITEM1_13_2.read(buffer); + array[i] = Types.ITEM1_13_2.read(buffer); } return array; } @Override public void write(ByteBuf buffer, Item[] object) { - Type.SHORT.writePrimitive(buffer, (short) object.length); + Types.SHORT.writePrimitive(buffer, (short) object.length); for (Item o : object) { - Type.ITEM1_13_2.write(buffer, o); + Types.ITEM1_13_2.write(buffer, o); } } } \ No newline at end of file diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_8.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_8.java index be24179f1..0e5ff7b6a 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_8.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemShortArrayType1_8.java @@ -24,25 +24,26 @@ package com.viaversion.viaversion.api.type.types.item; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class ItemShortArrayType1_8 extends BaseItemArrayType { @Override public Item[] read(ByteBuf buffer) { - int amount = Type.SHORT.readPrimitive(buffer); + int amount = Types.SHORT.readPrimitive(buffer); Item[] array = new Item[amount]; for (int i = 0; i < amount; i++) { - array[i] = Type.ITEM1_8.read(buffer); + array[i] = Types.ITEM1_8.read(buffer); } return array; } @Override public void write(ByteBuf buffer, Item[] object) { - Type.SHORT.writePrimitive(buffer, (short) object.length); + Types.SHORT.writePrimitive(buffer, (short) object.length); for (Item o : object) { - Type.ITEM1_8.write(buffer, o); + Types.ITEM1_8.write(buffer, o); } } } \ No newline at end of file diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_13.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_13.java index 2f747ae1e..66787cab1 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_13.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_13.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.item; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -42,7 +43,7 @@ public class ItemType1_13 extends Type { Item item = new DataItem(); item.setIdentifier(id); item.setAmount(buffer.readByte()); - item.setTag(Type.NAMED_COMPOUND_TAG.read(buffer)); + item.setTag(Types.NAMED_COMPOUND_TAG.read(buffer)); return item; } } @@ -54,7 +55,7 @@ public class ItemType1_13 extends Type { } else { buffer.writeShort(object.identifier()); buffer.writeByte(object.amount()); - Type.NAMED_COMPOUND_TAG.write(buffer, object.tag()); + Types.NAMED_COMPOUND_TAG.write(buffer, object.tag()); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_13_2.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_13_2.java index 5497effc3..9be1c23e8 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_13_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_13_2.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.item; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -40,9 +41,9 @@ public class ItemType1_13_2 extends Type { return null; } else { Item item = new DataItem(); - item.setIdentifier(Type.VAR_INT.readPrimitive(buffer)); + item.setIdentifier(Types.VAR_INT.readPrimitive(buffer)); item.setAmount(buffer.readByte()); - item.setTag(Type.NAMED_COMPOUND_TAG.read(buffer)); + item.setTag(Types.NAMED_COMPOUND_TAG.read(buffer)); return item; } } @@ -53,9 +54,9 @@ public class ItemType1_13_2 extends Type { buffer.writeBoolean(false); } else { buffer.writeBoolean(true); - Type.VAR_INT.writePrimitive(buffer, object.identifier()); + Types.VAR_INT.writePrimitive(buffer, object.identifier()); buffer.writeByte(object.amount()); - Type.NAMED_COMPOUND_TAG.write(buffer, object.tag()); + Types.NAMED_COMPOUND_TAG.write(buffer, object.tag()); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_20_2.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_20_2.java index 8c8aa3277..725038d81 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_20_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_20_2.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.item; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -41,9 +42,9 @@ public class ItemType1_20_2 extends Type { } final Item item = new DataItem(); - item.setIdentifier(Type.VAR_INT.readPrimitive(buffer)); + item.setIdentifier(Types.VAR_INT.readPrimitive(buffer)); item.setAmount(buffer.readByte()); - item.setTag(Type.COMPOUND_TAG.read(buffer)); + item.setTag(Types.COMPOUND_TAG.read(buffer)); return item; } @@ -53,9 +54,9 @@ public class ItemType1_20_2 extends Type { buffer.writeBoolean(false); } else { buffer.writeBoolean(true); - Type.VAR_INT.writePrimitive(buffer, object.identifier()); + Types.VAR_INT.writePrimitive(buffer, object.identifier()); buffer.writeByte(object.amount()); - Type.COMPOUND_TAG.write(buffer, object.tag()); + Types.COMPOUND_TAG.write(buffer, object.tag()); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_20_5.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_20_5.java index 01b55074a..021de65d4 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_20_5.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_20_5.java @@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.StructuredItem; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; import java.util.Map; @@ -45,19 +46,19 @@ public class ItemType1_20_5 extends Type { @Override public @Nullable Item read(final ByteBuf buffer) { - final int amount = Type.VAR_INT.readPrimitive(buffer); + final int amount = Types.VAR_INT.readPrimitive(buffer); if (amount <= 0) { return null; } - final int id = Type.VAR_INT.readPrimitive(buffer); + final int id = Types.VAR_INT.readPrimitive(buffer); final Map, StructuredData> data = readData(buffer); return new StructuredItem(id, amount, new StructuredDataContainer(data)); } private Map, StructuredData> readData(final ByteBuf buffer) { - final int valuesSize = Type.VAR_INT.readPrimitive(buffer); - final int markersSize = Type.VAR_INT.readPrimitive(buffer); + final int valuesSize = Types.VAR_INT.readPrimitive(buffer); + final int markersSize = Types.VAR_INT.readPrimitive(buffer); if (valuesSize == 0 && markersSize == 0) { return new Reference2ObjectOpenHashMap<>(); } @@ -71,7 +72,7 @@ public class ItemType1_20_5 extends Type { } for (int i = 0; i < markersSize; i++) { - final int id = Type.VAR_INT.readPrimitive(buffer); + final int id = Types.VAR_INT.readPrimitive(buffer); final StructuredDataKey key = dataType.key(id); Preconditions.checkNotNull(key, "No data component serializer found for empty id %s", id); map.put(key, StructuredData.empty(key, id)); @@ -82,12 +83,12 @@ public class ItemType1_20_5 extends Type { @Override public void write(final ByteBuf buffer, @Nullable final Item object) { if (object == null) { - Type.VAR_INT.writePrimitive(buffer, 0); + Types.VAR_INT.writePrimitive(buffer, 0); return; } - Type.VAR_INT.writePrimitive(buffer, object.amount()); - Type.VAR_INT.writePrimitive(buffer, object.identifier()); + Types.VAR_INT.writePrimitive(buffer, object.amount()); + Types.VAR_INT.writePrimitive(buffer, object.identifier()); final Map, StructuredData> data = object.structuredData().data(); int valuesSize = 0; @@ -100,8 +101,8 @@ public class ItemType1_20_5 extends Type { } } - Type.VAR_INT.writePrimitive(buffer, valuesSize); - Type.VAR_INT.writePrimitive(buffer, markersSize); + Types.VAR_INT.writePrimitive(buffer, valuesSize); + Types.VAR_INT.writePrimitive(buffer, markersSize); for (final StructuredData value : data.values()) { if (value.isPresent()) { @@ -110,7 +111,7 @@ public class ItemType1_20_5 extends Type { } for (final StructuredData value : data.values()) { if (value.isEmpty()) { - Type.VAR_INT.writePrimitive(buffer, value.id()); + Types.VAR_INT.writePrimitive(buffer, value.id()); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_8.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_8.java index 877f235b0..899d044ed 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_8.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_8.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.item; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -44,7 +45,7 @@ public class ItemType1_8 extends Type { item.setIdentifier(id); item.setAmount(buffer.readByte()); item.setData(buffer.readShort()); - item.setTag(Type.NAMED_COMPOUND_TAG.read(buffer)); + item.setTag(Types.NAMED_COMPOUND_TAG.read(buffer)); return item; } } @@ -57,7 +58,7 @@ public class ItemType1_8 extends Type { buffer.writeShort(object.identifier()); buffer.writeByte(object.amount()); buffer.writeShort(object.data()); - Type.NAMED_COMPOUND_TAG.write(buffer, object.tag()); + Types.NAMED_COMPOUND_TAG.write(buffer, object.tag()); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/StructuredDataType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/StructuredDataType.java index 8269b474f..8b51ff967 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/StructuredDataType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/StructuredDataType.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.data.StructuredData; import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -41,14 +42,14 @@ public class StructuredDataType extends Type> { @Override public void write(final ByteBuf buffer, final StructuredData object) { - Type.VAR_INT.writePrimitive(buffer, object.id()); + Types.VAR_INT.writePrimitive(buffer, object.id()); object.write(buffer); } @Override public StructuredData read(final ByteBuf buffer) { Preconditions.checkNotNull(types, "StructuredDataType has not been initialized"); - final int id = Type.VAR_INT.readPrimitive(buffer); + final int id = Types.VAR_INT.readPrimitive(buffer); final StructuredDataKey key = this.types[id]; if (key == null) { throw new IllegalArgumentException("No data component serializer found for id " + id); diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/ChunkPositionType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/ChunkPositionType.java index bc08262c4..09f11d7fb 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/ChunkPositionType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/ChunkPositionType.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types.math; import com.viaversion.viaversion.api.minecraft.metadata.ChunkPosition; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class ChunkPositionType extends Type { @@ -34,12 +35,12 @@ public class ChunkPositionType extends Type { @Override public ChunkPosition read(ByteBuf buffer) { - final long chunkKey = Type.LONG.readPrimitive(buffer); + final long chunkKey = Types.LONG.readPrimitive(buffer); return new ChunkPosition(chunkKey); } @Override public void write(ByteBuf buffer, ChunkPosition chunkPosition) { - Type.LONG.writePrimitive(buffer, chunkPosition.chunkKey()); + Types.LONG.writePrimitive(buffer, chunkPosition.chunkKey()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/EulerAngleType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/EulerAngleType.java index 3200e3b32..c0b2c0d4d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/EulerAngleType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/EulerAngleType.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types.math; import com.viaversion.viaversion.api.minecraft.EulerAngle; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class EulerAngleType extends Type { @@ -33,17 +34,17 @@ public class EulerAngleType extends Type { @Override public EulerAngle read(ByteBuf buffer) { - float x = Type.FLOAT.readPrimitive(buffer); - float y = Type.FLOAT.readPrimitive(buffer); - float z = Type.FLOAT.readPrimitive(buffer); + float x = Types.FLOAT.readPrimitive(buffer); + float y = Types.FLOAT.readPrimitive(buffer); + float z = Types.FLOAT.readPrimitive(buffer); return new EulerAngle(x, y, z); } @Override public void write(ByteBuf buffer, EulerAngle object) { - Type.FLOAT.writePrimitive(buffer, object.x()); - Type.FLOAT.writePrimitive(buffer, object.y()); - Type.FLOAT.writePrimitive(buffer, object.z()); + Types.FLOAT.writePrimitive(buffer, object.x()); + Types.FLOAT.writePrimitive(buffer, object.y()); + Types.FLOAT.writePrimitive(buffer, object.z()); } } \ No newline at end of file diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/GlobalPositionType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/GlobalPositionType.java index 5019a7334..84695dbf5 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/GlobalPositionType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/GlobalPositionType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.math; import com.viaversion.viaversion.api.minecraft.GlobalPosition; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class GlobalPositionType extends Type { @@ -35,20 +36,20 @@ public class GlobalPositionType extends Type { @Override public GlobalPosition read(ByteBuf buffer) { - final String dimension = Type.STRING.read(buffer); - return Type.POSITION1_14.read(buffer).withDimension(dimension); + final String dimension = Types.STRING.read(buffer); + return Types.BLOCK_POSITION1_14.read(buffer).withDimension(dimension); } @Override public void write(ByteBuf buffer, GlobalPosition object) { - Type.STRING.write(buffer, object.dimension()); - Type.POSITION1_14.write(buffer, object); + Types.STRING.write(buffer, object.dimension()); + Types.BLOCK_POSITION1_14.write(buffer, object); } public static final class OptionalGlobalPositionType extends OptionalType { public OptionalGlobalPositionType() { - super(Type.GLOBAL_POSITION); + super(Types.GLOBAL_POSITION); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_14.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_14.java index 0aa1c816b..a022c8e39 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_14.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_14.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.math; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class PositionType1_14 extends Type { @@ -53,7 +54,7 @@ public class PositionType1_14 extends Type { public static final class OptionalPosition1_14Type extends OptionalType { public OptionalPosition1_14Type() { - super(Type.POSITION1_14); + super(Types.BLOCK_POSITION1_14); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_8.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_8.java index fd3ec4360..c401ff550 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_8.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_8.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.math; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class PositionType1_8 extends Type { @@ -51,7 +52,7 @@ public class PositionType1_8 extends Type { public static final class OptionalPositionType extends OptionalType { public OptionalPositionType() { - super(Type.POSITION1_8); + super(Types.BLOCK_POSITION1_8); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/VectorType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/VectorType.java index 4f6ea5790..262222bb1 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/VectorType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/VectorType.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types.math; import com.viaversion.viaversion.api.minecraft.Vector; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class VectorType extends Type { @@ -33,17 +34,17 @@ public class VectorType extends Type { @Override public Vector read(ByteBuf buffer) { - int x = Type.INT.read(buffer); - int y = Type.INT.read(buffer); - int z = Type.INT.read(buffer); + int x = Types.INT.read(buffer); + int y = Types.INT.read(buffer); + int z = Types.INT.read(buffer); return new Vector(x, y, z); } @Override public void write(ByteBuf buffer, Vector object) { - Type.INT.write(buffer, object.blockX()); - Type.INT.write(buffer, object.blockY()); - Type.INT.write(buffer, object.blockZ()); + Types.INT.write(buffer, object.blockX()); + Types.INT.write(buffer, object.blockY()); + Types.INT.write(buffer, object.blockZ()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/metadata/ModernMetaType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/metadata/ModernMetaType.java index d2a58da89..d813073a0 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/metadata/ModernMetaType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/metadata/ModernMetaType.java @@ -24,7 +24,7 @@ package com.viaversion.viaversion.api.type.types.metadata; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public abstract class ModernMetaType extends MetaTypeTemplate { @@ -34,7 +34,7 @@ public abstract class ModernMetaType extends MetaTypeTemplate { public Metadata read(final ByteBuf buffer) { final short index = buffer.readUnsignedByte(); if (index == END) return null; // End of metadata - final MetaType type = this.getType(Type.VAR_INT.readPrimitive(buffer)); + final MetaType type = this.getType(Types.VAR_INT.readPrimitive(buffer)); return new Metadata(index, type, type.type().read(buffer)); } @@ -47,7 +47,7 @@ public abstract class ModernMetaType extends MetaTypeTemplate { } else { buffer.writeByte(object.id()); final MetaType type = object.metaType(); - Type.VAR_INT.writePrimitive(buffer, type.typeId()); + Types.VAR_INT.writePrimitive(buffer, type.typeId()); type.type().write(buffer, object.getValue()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/CompoundTagType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/CompoundTagType.java index 27b3a1b58..48eff6910 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/CompoundTagType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/CompoundTagType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.misc; import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import java.io.IOException; @@ -62,7 +63,7 @@ public class CompoundTagType extends Type { public static final class OptionalCompoundTagType extends OptionalType { public OptionalCompoundTagType() { - super(Type.COMPOUND_TAG); + super(Types.COMPOUND_TAG); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/GameProfileType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/GameProfileType.java index 0458a5df4..e4e9216ba 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/GameProfileType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/GameProfileType.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types.misc; import com.viaversion.viaversion.api.minecraft.GameProfile; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public final class GameProfileType extends Type { @@ -34,14 +35,14 @@ public final class GameProfileType extends Type { @Override public GameProfile read(final ByteBuf buffer) { - final String name = Type.OPTIONAL_STRING.read(buffer); - final java.util.UUID id = Type.OPTIONAL_UUID.read(buffer); - final int propertyCount = Type.VAR_INT.readPrimitive(buffer); + final String name = Types.OPTIONAL_STRING.read(buffer); + final java.util.UUID id = Types.OPTIONAL_UUID.read(buffer); + final int propertyCount = Types.VAR_INT.readPrimitive(buffer); final GameProfile.Property[] properties = new GameProfile.Property[propertyCount]; for (int i = 0; i < propertyCount; i++) { - final String propertyName = Type.STRING.read(buffer); - final String propertyValue = Type.STRING.read(buffer); - final String propertySignature = Type.OPTIONAL_STRING.read(buffer); + final String propertyName = Types.STRING.read(buffer); + final String propertyValue = Types.STRING.read(buffer); + final String propertySignature = Types.OPTIONAL_STRING.read(buffer); properties[i] = new GameProfile.Property(propertyName, propertyValue, propertySignature); } return new GameProfile(name, id, properties); @@ -49,13 +50,13 @@ public final class GameProfileType extends Type { @Override public void write(final ByteBuf buffer, final GameProfile value) { - Type.OPTIONAL_STRING.write(buffer, value.name()); - Type.OPTIONAL_UUID.write(buffer, value.id()); - Type.VAR_INT.writePrimitive(buffer, value.properties().length); + Types.OPTIONAL_STRING.write(buffer, value.name()); + Types.OPTIONAL_UUID.write(buffer, value.id()); + Types.VAR_INT.writePrimitive(buffer, value.properties().length); for (final GameProfile.Property property : value.properties()) { - Type.STRING.write(buffer, property.name()); - Type.STRING.write(buffer, property.value()); - Type.OPTIONAL_STRING.write(buffer, property.signature()); + Types.STRING.write(buffer, property.name()); + Types.STRING.write(buffer, property.value()); + Types.OPTIONAL_STRING.write(buffer, property.signature()); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/HolderSetType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/HolderSetType.java index bc83ac3db..c668647c2 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/HolderSetType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/HolderSetType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.misc; import com.viaversion.viaversion.api.minecraft.HolderSet; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class HolderSetType extends Type { @@ -35,15 +36,15 @@ public class HolderSetType extends Type { @Override public HolderSet read(final ByteBuf buffer) { - final int size = Type.VAR_INT.readPrimitive(buffer) - 1; + final int size = Types.VAR_INT.readPrimitive(buffer) - 1; if (size == -1) { - final String tag = Type.STRING.read(buffer); + final String tag = Types.STRING.read(buffer); return HolderSet.of(tag); } final int[] values = new int[size]; for (int i = 0; i < size; i++) { - values[i] = Type.VAR_INT.readPrimitive(buffer); + values[i] = Types.VAR_INT.readPrimitive(buffer); } return HolderSet.of(values); } @@ -51,13 +52,13 @@ public class HolderSetType extends Type { @Override public void write(final ByteBuf buffer, final HolderSet object) { if (object.hasTagKey()) { - Type.VAR_INT.writePrimitive(buffer, 0); - Type.STRING.write(buffer, object.tagKey()); + Types.VAR_INT.writePrimitive(buffer, 0); + Types.STRING.write(buffer, object.tagKey()); } else { final int[] values = object.ids(); - Type.VAR_INT.writePrimitive(buffer, values.length + 1); + Types.VAR_INT.writePrimitive(buffer, values.length + 1); for (final int value : values) { - Type.VAR_INT.writePrimitive(buffer, value); + Types.VAR_INT.writePrimitive(buffer, value); } } } @@ -65,7 +66,7 @@ public class HolderSetType extends Type { public static final class OptionalHolderSetType extends OptionalType { public OptionalHolderSetType() { - super(Type.HOLDER_SET); + super(Types.HOLDER_SET); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/HolderType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/HolderType.java index 88d645021..c0da76653 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/HolderType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/HolderType.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types.misc; import com.viaversion.viaversion.api.minecraft.Holder; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public abstract class HolderType extends Type> { @@ -34,7 +35,7 @@ public abstract class HolderType extends Type> { @Override public Holder read(final ByteBuf buffer) { - final int id = Type.VAR_INT.readPrimitive(buffer) - 1; // Normalize id + final int id = Types.VAR_INT.readPrimitive(buffer) - 1; // Normalize id if (id == -1) { return Holder.of(readDirect(buffer)); } @@ -44,9 +45,9 @@ public abstract class HolderType extends Type> { @Override public void write(final ByteBuf buffer, final Holder object) { if (object.hasId()) { - Type.VAR_INT.writePrimitive(buffer, object.id() + 1); // Normalize id + Types.VAR_INT.writePrimitive(buffer, object.id() + 1); // Normalize id } else { - Type.VAR_INT.writePrimitive(buffer, 0); + Types.VAR_INT.writePrimitive(buffer, 0); writeDirect(buffer, object.value()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/NamedCompoundTagType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/NamedCompoundTagType.java index 7bbbfa000..7f8fb14ee 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/NamedCompoundTagType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/NamedCompoundTagType.java @@ -27,6 +27,7 @@ import com.viaversion.nbt.tag.Tag; import com.viaversion.nbt.limiter.TagLimiter; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufOutputStream; @@ -94,7 +95,7 @@ public class NamedCompoundTagType extends Type { public static final class OptionalNamedCompoundTagType extends OptionalType { public OptionalNamedCompoundTagType() { - super(Type.NAMED_COMPOUND_TAG); + super(Types.NAMED_COMPOUND_TAG); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/ParticleType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/ParticleType.java index f993b0fba..b3485b581 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/ParticleType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/ParticleType.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.util.Key; import io.netty.buffer.ByteBuf; @@ -40,7 +41,7 @@ public class ParticleType extends DynamicType { @Override public void write(final ByteBuf buffer, final Particle object) { - Type.VAR_INT.writePrimitive(buffer, object.id()); + Types.VAR_INT.writePrimitive(buffer, object.id()); for (final Particle.ParticleData data : object.getArguments()) { data.write(buffer); } @@ -48,7 +49,7 @@ public class ParticleType extends DynamicType { @Override public Particle read(final ByteBuf buffer) { - final int type = Type.VAR_INT.readPrimitive(buffer); + final int type = Types.VAR_INT.readPrimitive(buffer); final Particle particle = new Particle(type); readData(buffer, particle); return particle; @@ -66,77 +67,77 @@ public class ParticleType extends DynamicType { public static final class Readers { public static final DataReader BLOCK = (buf, particle) -> { - particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Flat Block + particle.add(Types.VAR_INT, Types.VAR_INT.readPrimitive(buf)); // Flat Block }; - public static final DataReader ITEM1_13 = itemHandler(Type.ITEM1_13); - public static final DataReader ITEM1_13_2 = itemHandler(Type.ITEM1_13_2); - public static final DataReader ITEM1_20_2 = itemHandler(Type.ITEM1_20_2); + public static final DataReader ITEM1_13 = itemHandler(Types.ITEM1_13); + public static final DataReader ITEM1_13_2 = itemHandler(Types.ITEM1_13_2); + public static final DataReader ITEM1_20_2 = itemHandler(Types.ITEM1_20_2); public static final DataReader ITEM1_20_5 = itemHandler(Types1_20_5.ITEM); public static final DataReader DUST = (buf, particle) -> { - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Red 0-1 - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Green 0-1 - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Blue 0-1 - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Scale 0.01-4 + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Red 0-1 + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Green 0-1 + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Blue 0-1 + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Scale 0.01-4 }; public static final DataReader DUST_TRANSITION = (buf, particle) -> { - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Red 0-1 - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Green 0-1 - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Blue 0-1 - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Scale 0.01-4 (moved to the end as of 24w03a / 1.20.5) - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Red - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Green - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Blue + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Red 0-1 + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Green 0-1 + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Blue 0-1 + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Scale 0.01-4 (moved to the end as of 24w03a / 1.20.5) + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Red + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Green + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Blue }; public static final DataReader VIBRATION = (buf, particle) -> { - particle.add(Type.POSITION1_14, Type.POSITION1_14.read(buf)); // From block pos + particle.add(Types.BLOCK_POSITION1_14, Types.BLOCK_POSITION1_14.read(buf)); // From block pos - String resourceLocation = Type.STRING.read(buf); - particle.add(Type.STRING, resourceLocation); + String resourceLocation = Types.STRING.read(buf); + particle.add(Types.STRING, resourceLocation); resourceLocation = Key.stripMinecraftNamespace(resourceLocation); if (resourceLocation.equals("block")) { - particle.add(Type.POSITION1_14, Type.POSITION1_14.read(buf)); // Target block pos + particle.add(Types.BLOCK_POSITION1_14, Types.BLOCK_POSITION1_14.read(buf)); // Target block pos } else if (resourceLocation.equals("entity")) { - particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Target entity + particle.add(Types.VAR_INT, Types.VAR_INT.readPrimitive(buf)); // Target entity } else { Via.getPlatform().getLogger().warning("Unknown vibration path position source type: " + resourceLocation); } - particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Arrival in ticks + particle.add(Types.VAR_INT, Types.VAR_INT.readPrimitive(buf)); // Arrival in ticks }; public static final DataReader VIBRATION1_19 = (buf, particle) -> { - String resourceLocation = Type.STRING.read(buf); - particle.add(Type.STRING, resourceLocation); + String resourceLocation = Types.STRING.read(buf); + particle.add(Types.STRING, resourceLocation); resourceLocation = Key.stripMinecraftNamespace(resourceLocation); if (resourceLocation.equals("block")) { - particle.add(Type.POSITION1_14, Type.POSITION1_14.read(buf)); // Target block pos + particle.add(Types.BLOCK_POSITION1_14, Types.BLOCK_POSITION1_14.read(buf)); // Target block pos } else if (resourceLocation.equals("entity")) { - particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Target entity - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Y offset + particle.add(Types.VAR_INT, Types.VAR_INT.readPrimitive(buf)); // Target entity + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Y offset } else { Via.getPlatform().getLogger().warning("Unknown vibration path position source type: " + resourceLocation); } - particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Arrival in ticks + particle.add(Types.VAR_INT, Types.VAR_INT.readPrimitive(buf)); // Arrival in ticks }; public static final DataReader VIBRATION1_20_3 = (buf, particle) -> { - final int sourceTypeId = Type.VAR_INT.readPrimitive(buf); - particle.add(Type.VAR_INT, sourceTypeId); + final int sourceTypeId = Types.VAR_INT.readPrimitive(buf); + particle.add(Types.VAR_INT, sourceTypeId); if (sourceTypeId == 0) { // Block - particle.add(Type.POSITION1_14, Type.POSITION1_14.read(buf)); // Target block pos + particle.add(Types.BLOCK_POSITION1_14, Types.BLOCK_POSITION1_14.read(buf)); // Target block pos } else if (sourceTypeId == 1) { // Entity - particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Target entity - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Y offset + particle.add(Types.VAR_INT, Types.VAR_INT.readPrimitive(buf)); // Target entity + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Y offset } else { Via.getPlatform().getLogger().warning("Unknown vibration path position source type: " + sourceTypeId); } - particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Arrival in ticks + particle.add(Types.VAR_INT, Types.VAR_INT.readPrimitive(buf)); // Arrival in ticks }; public static final DataReader SCULK_CHARGE = (buf, particle) -> { - particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Roll + particle.add(Types.FLOAT, Types.FLOAT.readPrimitive(buf)); // Roll }; public static final DataReader SHRIEK = (buf, particle) -> { - particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Delay + particle.add(Types.VAR_INT, Types.VAR_INT.readPrimitive(buf)); // Delay }; - public static final DataReader COLOR = (buf, particle) -> particle.add(Type.INT, buf.readInt()); + public static final DataReader COLOR = (buf, particle) -> particle.add(Types.INT, buf.readInt()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/PlayerMessageSignatureType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/PlayerMessageSignatureType.java index ef7173b28..e97053971 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/PlayerMessageSignatureType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/PlayerMessageSignatureType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.misc; import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class PlayerMessageSignatureType extends Type { @@ -35,19 +36,19 @@ public class PlayerMessageSignatureType extends Type { @Override public PlayerMessageSignature read(final ByteBuf buffer) { - return new PlayerMessageSignature(Type.UUID.read(buffer), Type.BYTE_ARRAY_PRIMITIVE.read(buffer)); + return new PlayerMessageSignature(Types.UUID.read(buffer), Types.BYTE_ARRAY_PRIMITIVE.read(buffer)); } @Override public void write(final ByteBuf buffer, final PlayerMessageSignature value) { - Type.UUID.write(buffer, value.uuid()); - Type.BYTE_ARRAY_PRIMITIVE.write(buffer, value.signatureBytes()); + Types.UUID.write(buffer, value.uuid()); + Types.BYTE_ARRAY_PRIMITIVE.write(buffer, value.signatureBytes()); } public static final class OptionalPlayerMessageSignatureType extends OptionalType { public OptionalPlayerMessageSignatureType() { - super(Type.PLAYER_MESSAGE_SIGNATURE); + super(Types.PLAYER_MESSAGE_SIGNATURE); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/ProfileKeyType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/ProfileKeyType.java index b61db8c1e..249610092 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/ProfileKeyType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/ProfileKeyType.java @@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.type.types.misc; import com.viaversion.viaversion.api.minecraft.ProfileKey; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class ProfileKeyType extends Type { @@ -35,20 +36,20 @@ public class ProfileKeyType extends Type { @Override public ProfileKey read(final ByteBuf buffer) { - return new ProfileKey(buffer.readLong(), Type.BYTE_ARRAY_PRIMITIVE.read(buffer), Type.BYTE_ARRAY_PRIMITIVE.read(buffer)); + return new ProfileKey(buffer.readLong(), Types.BYTE_ARRAY_PRIMITIVE.read(buffer), Types.BYTE_ARRAY_PRIMITIVE.read(buffer)); } @Override public void write(final ByteBuf buffer, final ProfileKey object) { buffer.writeLong(object.expiresAt()); - Type.BYTE_ARRAY_PRIMITIVE.write(buffer, object.publicKey()); - Type.BYTE_ARRAY_PRIMITIVE.write(buffer, object.keySignature()); + Types.BYTE_ARRAY_PRIMITIVE.write(buffer, object.publicKey()); + Types.BYTE_ARRAY_PRIMITIVE.write(buffer, object.keySignature()); } public static final class OptionalProfileKeyType extends OptionalType { public OptionalProfileKeyType() { - super(Type.PROFILE_KEY); + super(Types.PROFILE_KEY); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/SoundEventType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/SoundEventType.java index 38f64f93f..81b343765 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/SoundEventType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/SoundEventType.java @@ -24,20 +24,21 @@ package com.viaversion.viaversion.api.type.types.misc; import com.viaversion.viaversion.api.minecraft.SoundEvent; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public final class SoundEventType extends HolderType { @Override public SoundEvent readDirect(final ByteBuf buffer) { - final String resourceLocation = Type.STRING.read(buffer); - final Float fixedRange = Type.OPTIONAL_FLOAT.read(buffer); + final String resourceLocation = Types.STRING.read(buffer); + final Float fixedRange = Types.OPTIONAL_FLOAT.read(buffer); return new SoundEvent(resourceLocation, fixedRange); } @Override public void writeDirect(final ByteBuf buffer, final SoundEvent value) { - Type.STRING.write(buffer, value.identifier()); - Type.OPTIONAL_FLOAT.write(buffer, value.fixedRange()); + Types.STRING.write(buffer, value.identifier()); + Types.OPTIONAL_FLOAT.write(buffer, value.fixedRange()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/TagType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/TagType.java index ab799f1be..a99232803 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/TagType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/TagType.java @@ -27,6 +27,7 @@ import com.viaversion.nbt.tag.Tag; import com.viaversion.nbt.limiter.TagLimiter; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufInputStream; import java.io.IOException; @@ -64,7 +65,7 @@ public class TagType extends Type { public static final class OptionalTagType extends OptionalType { public OptionalTagType() { - super(Type.TAG); + super(Types.TAG); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/VillagerDataType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/VillagerDataType.java index 979bdd9f4..23feb062f 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/VillagerDataType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/VillagerDataType.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types.misc; import com.viaversion.viaversion.api.minecraft.VillagerData; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; public class VillagerDataType extends Type { @@ -33,13 +34,13 @@ public class VillagerDataType extends Type { @Override public VillagerData read(ByteBuf buffer) { - return new VillagerData(Type.VAR_INT.readPrimitive(buffer), Type.VAR_INT.readPrimitive(buffer), Type.VAR_INT.readPrimitive(buffer)); + return new VillagerData(Types.VAR_INT.readPrimitive(buffer), Types.VAR_INT.readPrimitive(buffer), Types.VAR_INT.readPrimitive(buffer)); } @Override public void write(ByteBuf buffer, VillagerData object) { - Type.VAR_INT.writePrimitive(buffer, object.type()); - Type.VAR_INT.writePrimitive(buffer, object.profession()); - Type.VAR_INT.writePrimitive(buffer, object.level()); + Types.VAR_INT.writePrimitive(buffer, object.type()); + Types.VAR_INT.writePrimitive(buffer, object.profession()); + Types.VAR_INT.writePrimitive(buffer, object.level()); } } diff --git a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java index adb4219fa..962fc98ae 100644 --- a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java +++ b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.bukkit.listeners.protocol1_9to1_8; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener; import com.viaversion.viaversion.protocols.v1_8to1_9.data.ArmorType; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; @@ -59,14 +60,14 @@ public class ArmorListener extends ViaBukkitListener { } PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.UPDATE_ATTRIBUTES, null, getUserConnection(player)); - wrapper.write(Type.VAR_INT, player.getEntityId()); // Player ID - wrapper.write(Type.INT, 1); // only 1 property - wrapper.write(Type.STRING, "generic.armor"); - wrapper.write(Type.DOUBLE, 0D); //default 0 armor - wrapper.write(Type.VAR_INT, 1); // 1 modifier - wrapper.write(Type.UUID, ARMOR_ATTRIBUTE); // armor modifier uuid - wrapper.write(Type.DOUBLE, (double) armor); // the modifier value - wrapper.write(Type.BYTE, (byte) 0);// the modifier operation, 0 = add number + wrapper.write(Types.VAR_INT, player.getEntityId()); // Player ID + wrapper.write(Types.INT, 1); // only 1 property + wrapper.write(Types.STRING, "generic.armor"); + wrapper.write(Types.DOUBLE, 0D); //default 0 armor + wrapper.write(Types.VAR_INT, 1); // 1 modifier + wrapper.write(Types.UUID, ARMOR_ATTRIBUTE); // armor modifier uuid + wrapper.write(Types.DOUBLE, (double) armor); // the modifier value + wrapper.write(Types.BYTE, (byte) 0);// the modifier operation, 0 = add number wrapper.scheduleSend(Protocol1_8To1_9.class); } diff --git a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/DeathListener.java b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/DeathListener.java index cbc7320c0..dbd353db6 100644 --- a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/DeathListener.java +++ b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/DeathListener.java @@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9; @@ -61,10 +62,10 @@ public class DeathListener extends ViaBukkitListener { if (userConnection != null) { PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.PLAYER_COMBAT, userConnection); try { - wrapper.write(Type.VAR_INT, 2); // Event - Entity dead - wrapper.write(Type.VAR_INT, p.getEntityId()); // Player ID - wrapper.write(Type.INT, p.getEntityId()); // Entity ID - wrapper.write(Type.COMPONENT, ComponentUtil.plainToJson(msg)); // Message + wrapper.write(Types.VAR_INT, 2); // Event - Entity dead + wrapper.write(Types.VAR_INT, p.getEntityId()); // Player ID + wrapper.write(Types.INT, p.getEntityId()); // Entity ID + wrapper.write(Types.COMPONENT, ComponentUtil.plainToJson(msg)); // Message wrapper.scheduleSend(Protocol1_8To1_9.class); } catch (Exception e) { diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java index d17e3f9da..c35fd8f8d 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java @@ -22,6 +22,7 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener; import com.viaversion.viaversion.protocols.v1_14_4to1_15.Protocol1_14_4To1_15; @@ -56,7 +57,7 @@ public class EntityToggleGlideListener extends ViaBukkitListener { // Cancelling can only be done by updating the player's metadata if (event.isGliding() && event.isCancelled()) { PacketWrapper packet = PacketWrapper.create(ClientboundPackets1_15.SET_ENTITY_DATA, null, getUserConnection(player)); - packet.write(Type.VAR_INT, player.getEntityId()); + packet.write(Types.VAR_INT, player.getEntityId()); byte bitmask = 0; // Collect other metadata for the mitmask diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/tasks/protocol1_19to1_18_2/AckSequenceTask.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/tasks/protocol1_19to1_18_2/AckSequenceTask.java index b4baefc01..e69603a55 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/tasks/protocol1_19to1_18_2/AckSequenceTask.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/tasks/protocol1_19to1_18_2/AckSequenceTask.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.bukkit.tasks.protocol1_19to1_18_2; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_18_2to1_19.Protocol1_18_2To1_19; import com.viaversion.viaversion.protocols.v1_18_2to1_19.packet.ClientboundPackets1_19; import com.viaversion.viaversion.protocols.v1_18_2to1_19.storage.SequenceStorage; @@ -41,7 +41,7 @@ public final class AckSequenceTask implements Runnable { final int sequence = sequenceStorage.setSequenceId(-1); try { final PacketWrapper ackPacket = PacketWrapper.create(ClientboundPackets1_19.BLOCK_CHANGED_ACK, connection); - ackPacket.write(Type.VAR_INT, sequence); + ackPacket.write(Types.VAR_INT, sequence); ackPacket.scheduleSend(Protocol1_18_2To1_19.class); } catch (final Exception e) { Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send block changed ack packet", e); diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java index 56ad8d147..8cf20eaae 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java @@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.protocol.ProtocolPipeline; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.bungee.storage.BungeeStorage; import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.ItemPacketRewriter1_13; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; @@ -186,8 +187,8 @@ public class BungeeServerHandler implements Listener { if (user.getProtocolInfo().getPipeline().contains(Protocol1_8To1_9.class)) { for (UUID uuid : storage.getBossbar()) { PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.BOSS_EVENT, null, user); - wrapper.write(Type.UUID, uuid); - wrapper.write(Type.VAR_INT, 1); // remove + wrapper.write(Types.UUID, uuid); + wrapper.write(Types.VAR_INT, 1); // remove wrapper.send(Protocol1_8To1_9.class); } } diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java index 82678bd3c..6e4d03c83 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java @@ -23,12 +23,12 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.storage.EntityTracker1_9; import java.util.Collections; -import java.util.logging.Level; import net.md_5.bungee.api.event.ServerConnectedEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.event.EventHandler; @@ -50,8 +50,8 @@ public class ElytraPatch implements Listener { PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.SET_ENTITY_DATA, null, user); - wrapper.write(Type.VAR_INT, entityId); - wrapper.write(Types1_9.METADATA_LIST, Collections.singletonList(new Metadata(0, MetaType1_9.Byte, (byte) 0))); + wrapper.write(Types.VAR_INT, entityId); + wrapper.write(Types1_9.METADATA_LIST, Collections.singletonList(new Metadata(0, MetaType1_9.BYTE, (byte) 0))); wrapper.scheduleSend(Protocol1_8To1_9.class); } diff --git a/common/src/main/java/com/viaversion/viaversion/connection/UserConnectionImpl.java b/common/src/main/java/com/viaversion/viaversion/connection/UserConnectionImpl.java index 9bd964a71..95df9f6d0 100644 --- a/common/src/main/java/com/viaversion/viaversion/connection/UserConnectionImpl.java +++ b/common/src/main/java/com/viaversion/viaversion/connection/UserConnectionImpl.java @@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketTracker; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.exception.CancelException; import com.viaversion.viaversion.exception.InformativeException; import com.viaversion.viaversion.protocol.packet.PacketWrapperImpl; @@ -237,8 +238,8 @@ public class UserConnectionImpl implements UserConnection { if (shouldTransformPacket()) { // Bypass serverbound packet decoder transforming - Type.VAR_INT.writePrimitive(buf, PacketWrapper.PASSTHROUGH_ID); - Type.UUID.write(buf, generatePassthroughToken()); + Types.VAR_INT.writePrimitive(buf, PacketWrapper.PASSTHROUGH_ID); + Types.UUID.write(buf, generatePassthroughToken()); } buf.writeBytes(packet); @@ -315,9 +316,9 @@ public class UserConnectionImpl implements UserConnection { return; } - int id = Type.VAR_INT.readPrimitive(buf); + int id = Types.VAR_INT.readPrimitive(buf); if (id == PacketWrapper.PASSTHROUGH_ID) { - if (!passthroughTokens.remove(Type.UUID.read(buf))) { + if (!passthroughTokens.remove(Types.UUID.read(buf))) { throw new IllegalArgumentException("Invalid token"); } return; diff --git a/common/src/main/java/com/viaversion/viaversion/legacy/bossbar/CommonBoss.java b/common/src/main/java/com/viaversion/viaversion/legacy/bossbar/CommonBoss.java index 3219afc93..ea4f6abbd 100644 --- a/common/src/main/java/com/viaversion/viaversion/legacy/bossbar/CommonBoss.java +++ b/common/src/main/java/com/viaversion/viaversion/legacy/bossbar/CommonBoss.java @@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.legacy.bossbar.BossFlag; import com.viaversion.viaversion.api.legacy.bossbar.BossStyle; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9; import com.viaversion.viaversion.util.ComponentUtil; @@ -242,30 +243,30 @@ public class CommonBoss implements BossBar { private PacketWrapper getPacket(UpdateAction action, UserConnection connection) { try { PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.BOSS_EVENT, null, connection); - wrapper.write(Type.UUID, uuid); - wrapper.write(Type.VAR_INT, action.getId()); + wrapper.write(Types.UUID, uuid); + wrapper.write(Types.VAR_INT, action.getId()); switch (action) { case ADD: - wrapper.write(Type.COMPONENT, ComponentUtil.plainToJson(title)); - wrapper.write(Type.FLOAT, health); - wrapper.write(Type.VAR_INT, color.getId()); - wrapper.write(Type.VAR_INT, style.getId()); - wrapper.write(Type.BYTE, (byte) flagToBytes()); + wrapper.write(Types.COMPONENT, ComponentUtil.plainToJson(title)); + wrapper.write(Types.FLOAT, health); + wrapper.write(Types.VAR_INT, color.getId()); + wrapper.write(Types.VAR_INT, style.getId()); + wrapper.write(Types.BYTE, (byte) flagToBytes()); break; case REMOVE: break; case UPDATE_HEALTH: - wrapper.write(Type.FLOAT, health); + wrapper.write(Types.FLOAT, health); break; case UPDATE_TITLE: - wrapper.write(Type.COMPONENT, ComponentUtil.plainToJson(title)); + wrapper.write(Types.COMPONENT, ComponentUtil.plainToJson(title)); break; case UPDATE_STYLE: - wrapper.write(Type.VAR_INT, color.getId()); - wrapper.write(Type.VAR_INT, style.getId()); + wrapper.write(Types.VAR_INT, color.getId()); + wrapper.write(Types.VAR_INT, style.getId()); break; case UPDATE_FLAGS: - wrapper.write(Type.BYTE, (byte) flagToBytes()); + wrapper.write(Types.BYTE, (byte) flagToBytes()); break; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocol/packet/PacketWrapperImpl.java b/common/src/main/java/com/viaversion/viaversion/protocol/packet/PacketWrapperImpl.java index 315c328be..9f2523775 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocol/packet/PacketWrapperImpl.java +++ b/common/src/main/java/com/viaversion/viaversion/protocol/packet/PacketWrapperImpl.java @@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.TypeConverter; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.exception.CancelException; import com.viaversion.viaversion.exception.InformativeException; import com.viaversion.viaversion.util.PipelineUtil; @@ -193,14 +194,14 @@ public class PacketWrapperImpl implements PacketWrapper { readableObjects.clear(); // If the buffer has readable bytes, copy them. if (inputBuffer.isReadable()) { - passthrough(Type.REMAINING_BYTES); + passthrough(Types.REMAINING_BYTES); } } @Override public void writeToBuffer(ByteBuf buffer) throws InformativeException { if (id != -1) { - Type.VAR_INT.writePrimitive(buffer, id); + Types.VAR_INT.writePrimitive(buffer, id); } if (!readableObjects.isEmpty()) { packetValues.addAll(readableObjects); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java index fac997e17..b36f2a405 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java @@ -33,6 +33,7 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.VersionProvider; import com.viaversion.viaversion.api.protocol.version.VersionType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.exception.CancelException; import com.viaversion.viaversion.exception.InformativeException; import com.viaversion.viaversion.protocol.version.BaseVersionProvider; @@ -56,10 +57,10 @@ public class BaseProtocol extends AbstractProtocol { - int protocolVersion = wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.STRING); // Server Address - wrapper.passthrough(Type.UNSIGNED_SHORT); // Server Port - int state = wrapper.passthrough(Type.VAR_INT); + int protocolVersion = wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.STRING); // Server Address + wrapper.passthrough(Types.UNSIGNED_SHORT); // Server Port + int state = wrapper.passthrough(Types.VAR_INT); ProtocolInfo info = wrapper.user().getProtocolInfo(); info.setProtocolVersion(ProtocolVersion.getProtocol(protocolVersion)); @@ -113,7 +114,7 @@ public class BaseProtocol extends AbstractProtocol { ProtocolInfo info = wrapper.user().getProtocolInfo(); - String originalStatus = wrapper.get(Type.STRING, 0); + String originalStatus = wrapper.get(Types.STRING, 0); try { JsonElement json = GsonUtil.getGson().fromJson(originalStatus, JsonElement.class); JsonObject version; @@ -125,7 +126,7 @@ public class BaseProtocol1_7 extends AbstractProtocol { - private static final ValueTransformer toOldByte = new ValueTransformer<>(Type.UNSIGNED_BYTE) { + private static final ValueTransformer toOldByte = new ValueTransformer<>(Types.UNSIGNED_BYTE) { @Override public Short transform(PacketWrapper wrapper, Float inputValue) { return (short) (inputValue * 16); @@ -64,9 +65,9 @@ public class Protocol1_10To1_11 extends AbstractProtocol { - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); // Change Type :) - int type = wrapper.get(Type.VAR_INT, 1); + int type = wrapper.get(Types.VAR_INT, 1); EntityTypes1_11.EntityType entType = MetadataRewriter1_11To1_10.rewriteEntityType(type, wrapper.get(Types1_9.METADATA_LIST, 0)); if (entType != null) { - wrapper.set(Type.VAR_INT, 1, entType.getId()); + wrapper.set(Types.VAR_INT, 1, entType.getId()); // Register Type ID wrapper.user().getEntityTracker(Protocol1_10To1_11.class).addEntity(entityId, entType); @@ -112,11 +113,11 @@ public class Protocol1_10To1_11 extends AbstractProtocol { - wrapper.write(Type.VAR_INT, 1); // 2 - Pickup Count + wrapper.write(Types.VAR_INT, 1); // 2 - Pickup Count }); } }); @@ -126,22 +127,22 @@ public class Protocol1_10To1_11 extends AbstractProtocol { - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); if (Via.getConfig().isHologramPatch()) { EntityTracker1_11 tracker = wrapper.user().getEntityTracker(Protocol1_10To1_11.class); if (tracker.isHologram(entityID)) { - Double newValue = wrapper.get(Type.DOUBLE, 1); + Double newValue = wrapper.get(Types.DOUBLE, 1); newValue -= (Via.getConfig().getHologramYOffset()); - wrapper.set(Type.DOUBLE, 1, newValue); + wrapper.set(Types.DOUBLE, 1, newValue); } } }); @@ -153,14 +154,14 @@ public class Protocol1_10To1_11 extends AbstractProtocol { - int action = wrapper.get(Type.VAR_INT, 0); + int action = wrapper.get(Types.VAR_INT, 0); // Handle the new ActionBar if (action >= 2) { - wrapper.set(Type.VAR_INT, 0, action + 1); + wrapper.set(Types.VAR_INT, 0, action + 1); } }); } @@ -169,15 +170,15 @@ public class Protocol1_10To1_11 extends AbstractProtocol { if (Via.getConfig().isPistonAnimationPatch()) { - int id = actionWrapper.get(Type.VAR_INT, 0); + int id = actionWrapper.get(Types.VAR_INT, 0); if (id == 33 || id == 29) { actionWrapper.cancel(); } @@ -189,13 +190,13 @@ public class Protocol1_10To1_11 extends AbstractProtocol { - CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); - if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 1) { + CompoundTag tag = wrapper.get(Types.NAMED_COMPOUND_TAG, 0); + if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 1) { EntityIdRewriter.toClientSpawner(tag); } @@ -233,12 +234,12 @@ public class Protocol1_10To1_11 extends AbstractProtocol { ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 1); + int dimensionId = wrapper.get(Types.INT, 1); clientChunks.setEnvironment(dimensionId); }); } @@ -246,10 +247,10 @@ public class Protocol1_10To1_11 extends AbstractProtocol { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 0); + int dimensionId = wrapper.get(Types.INT, 0); clientWorld.setEnvironment(dimensionId); }); } @@ -258,14 +259,14 @@ public class Protocol1_10To1_11 extends AbstractProtocol { - int effectID = packetWrapper.get(Type.INT, 0); + int effectID = packetWrapper.get(Types.INT, 0); if (effectID == 2002) { - int data = packetWrapper.get(Type.INT, 1); + int data = packetWrapper.get(Types.INT, 1); boolean isInstant = false; Pair newData = PotionColorMapping.getNewData(data); if (newData == null) { @@ -276,9 +277,9 @@ public class Protocol1_10To1_11 extends AbstractProtocol { // 100-character limit on older servers - String msg = wrapper.get(Type.STRING, 0); + String msg = wrapper.get(Types.STRING, 0); if (msg.length() > 100) { - wrapper.set(Type.STRING, 0, msg.substring(0, 100)); + wrapper.set(Types.STRING, 0, msg.substring(0, 100)); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/metadata/MetadataRewriter1_11To1_10.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/metadata/MetadataRewriter1_11To1_10.java index a047ac2ab..56530aa18 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/metadata/MetadataRewriter1_11To1_10.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/metadata/MetadataRewriter1_11To1_10.java @@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_10to1_11.Protocol1_10To1_11; import com.viaversion.viaversion.protocols.v1_10to1_11.rewriter.EntityIdRewriter; import com.viaversion.viaversion.protocols.v1_10to1_11.storage.EntityTracker1_11; @@ -51,7 +51,7 @@ public class MetadataRewriter1_11To1_10 extends EntityRewriter { boolean value = (((byte) meta.getValue()) & 0x02) == 0x02; - meta.setTypeAndValue(MetaType1_9.Boolean, value); + meta.setTypeAndValue(MetaType1_9.BOOLEAN, value); }); filter().type(EntityType.ABSTRACT_SKELETON).removeIndex(12); @@ -86,9 +86,9 @@ public class MetadataRewriter1_11To1_10 extends EntityRewriter 0 && value < 6) { - metadata.add(new Metadata(16, MetaType1_9.VarInt, value - 1)); // Add profession type to new metadata + metadata.add(new Metadata(16, MetaType1_9.VAR_INT, value - 1)); // Add profession type to new metadata return EntityType.ZOMBIE_VILLAGER; } if (value == 6) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/ItemPacketRewriter1_11.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/ItemPacketRewriter1_11.java index e7e0f49fe..5e422ac79 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/ItemPacketRewriter1_11.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/ItemPacketRewriter1_11.java @@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_10to1_11.Protocol1_10To1_11; import com.viaversion.viaversion.protocols.v1_10to1_11.rewriter.EntityIdRewriter; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3; @@ -30,7 +31,7 @@ import com.viaversion.viaversion.rewriter.ItemRewriter; public class ItemPacketRewriter1_11 extends ItemRewriter { public ItemPacketRewriter1_11(Protocol1_10To1_11 protocol) { - super(protocol, Type.ITEM1_8, Type.ITEM1_8_SHORT_ARRAY); + super(protocol, Types.ITEM1_8, Types.ITEM1_8_SHORT_ARRAY); } @Override @@ -43,24 +44,24 @@ public class ItemPacketRewriter1_11 extends ItemRewriter { - if (wrapper.get(Type.STRING, 0).equals("MC|TrList")) { - wrapper.passthrough(Type.INT); // Passthrough Window ID + if (wrapper.get(Types.STRING, 0).equals("MC|TrList")) { + wrapper.passthrough(Types.INT); // Passthrough Window ID - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + int size = wrapper.passthrough(Types.UNSIGNED_BYTE); for (int i = 0; i < size; i++) { - EntityIdRewriter.toClientItem(wrapper.passthrough(Type.ITEM1_8)); // Input Item - EntityIdRewriter.toClientItem(wrapper.passthrough(Type.ITEM1_8)); // Output Item + EntityIdRewriter.toClientItem(wrapper.passthrough(Types.ITEM1_8)); // Input Item + EntityIdRewriter.toClientItem(wrapper.passthrough(Types.ITEM1_8)); // Output Item - boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item + boolean secondItem = wrapper.passthrough(Types.BOOLEAN); // Has second item if (secondItem) - EntityIdRewriter.toClientItem(wrapper.passthrough(Type.ITEM1_8)); // Second Item + EntityIdRewriter.toClientItem(wrapper.passthrough(Types.ITEM1_8)); // Second Item - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses + wrapper.passthrough(Types.BOOLEAN); // Trade disabled + wrapper.passthrough(Types.INT); // Number of tools uses + wrapper.passthrough(Types.INT); // Maximum number of trade uses } } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_11_1to1_12/Protocol1_11_1To1_12.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_11_1to1_12/Protocol1_11_1To1_12.java index fab1256df..6686194d4 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_11_1to1_12/Protocol1_11_1To1_12.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_11_1to1_12/Protocol1_11_1To1_12.java @@ -34,6 +34,7 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3; import com.viaversion.viaversion.api.type.types.version.Types1_12; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -67,9 +68,9 @@ public class Protocol1_11_1To1_12 extends AbstractProtocol { if (!Via.getConfig().is1_12NBTArrayFix()) return; - final JsonElement element = wrapper.passthrough(Type.COMPONENT); + final JsonElement element = wrapper.passthrough(Types.COMPONENT); TranslateRewriter.toClient(wrapper.user(), element); ChatItemRewriter.toClient(element); - wrapper.set(Type.COMPONENT, 0, element); + wrapper.set(Types.COMPONENT, 0, element); }); registerClientbound(ClientboundPackets1_9_3.LEVEL_CHUNK, wrapper -> { @@ -143,18 +144,18 @@ public class Protocol1_11_1To1_12 extends AbstractProtocol { UserConnection user = wrapper.user(); ClientWorld clientChunks = user.get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 1); + int dimensionId = wrapper.get(Types.INT, 1); clientChunks.setEnvironment(dimensionId); // Reset recipes if (user.getProtocolInfo().protocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_13)) { - wrapper.create(ClientboundPackets1_13.UPDATE_RECIPES, packetWrapper -> packetWrapper.write(Type.VAR_INT, 0)) + wrapper.create(ClientboundPackets1_13.UPDATE_RECIPES, packetWrapper -> packetWrapper.write(Types.VAR_INT, 0)) .scheduleSend(Protocol1_12_2To1_13.class); } }); @@ -163,10 +164,10 @@ public class Protocol1_11_1To1_12 extends AbstractProtocol { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 0); + int dimensionId = wrapper.get(Types.INT, 0); clientWorld.setEnvironment(dimensionId); }); } @@ -182,12 +183,12 @@ public class Protocol1_11_1To1_12 extends AbstractProtocol { // As part of the fix for MC-111054, the max length of // the locale was raised to 16 (from 7), and the client @@ -198,9 +199,9 @@ public class Protocol1_11_1To1_12 extends AbstractProtocol 7) { - wrapper.set(Type.STRING, 0, locale.substring(0, 7)); + wrapper.set(Types.STRING, 0, locale.substring(0, 7)); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_11_1to1_12/rewriter/ItemPacketRewriter1_12.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_11_1to1_12/rewriter/ItemPacketRewriter1_12.java index 57e6dba71..f6cc447d0 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_11_1to1_12/rewriter/ItemPacketRewriter1_12.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_11_1to1_12/rewriter/ItemPacketRewriter1_12.java @@ -22,6 +22,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_11_1to1_12.Protocol1_11_1To1_12; import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ServerboundPackets1_12; import com.viaversion.viaversion.protocols.v1_11_1to1_12.providers.InventoryQuickMoveProvider; @@ -32,7 +33,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; public class ItemPacketRewriter1_12 extends ItemRewriter { public ItemPacketRewriter1_12(Protocol1_11_1To1_12 protocol) { - super(protocol, Type.ITEM1_8, Type.ITEM1_8_SHORT_ARRAY); + super(protocol, Types.ITEM1_8, Types.ITEM1_8_SHORT_ARRAY); } @Override @@ -45,25 +46,25 @@ public class ItemPacketRewriter1_12 extends ItemRewriter { - if (wrapper.get(Type.STRING, 0).equals("MC|TrList")) { - wrapper.passthrough(Type.INT); // Passthrough Window ID + if (wrapper.get(Types.STRING, 0).equals("MC|TrList")) { + wrapper.passthrough(Types.INT); // Passthrough Window ID - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + int size = wrapper.passthrough(Types.UNSIGNED_BYTE); for (int i = 0; i < size; i++) { - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_8)); // Input Item - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_8)); // Output Item + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_8)); // Input Item + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_8)); // Output Item - boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item + boolean secondItem = wrapper.passthrough(Types.BOOLEAN); // Has second item if (secondItem) { - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_8)); // Second Item + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_8)); // Second Item } - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses + wrapper.passthrough(Types.BOOLEAN); // Trade disabled + wrapper.passthrough(Types.INT); // Number of tools uses + wrapper.passthrough(Types.INT); // Maximum number of trade uses } } }); @@ -74,26 +75,26 @@ public class ItemPacketRewriter1_12 extends ItemRewriter { - Item item = wrapper.get(Type.ITEM1_8, 0); + Item item = wrapper.get(Types.ITEM1_8, 0); if (!Via.getConfig().is1_12QuickMoveActionFix()) { handleItemToServer(wrapper.user(), item); return; } - byte button = wrapper.get(Type.BYTE, 0); - int mode = wrapper.get(Type.VAR_INT, 0); + byte button = wrapper.get(Types.BYTE, 0); + int mode = wrapper.get(Types.VAR_INT, 0); // QUICK_MOVE PATCH (Shift + (click/double click)) if (mode == 1 && button == 0 && item == null) { - short windowId = wrapper.get(Type.UNSIGNED_BYTE, 0); - short slotId = wrapper.get(Type.SHORT, 0); - short actionId = wrapper.get(Type.SHORT, 1); + short windowId = wrapper.get(Types.UNSIGNED_BYTE, 0); + short slotId = wrapper.get(Types.SHORT, 0); + short actionId = wrapper.get(Types.SHORT, 1); InventoryQuickMoveProvider provider = Via.getManager().getProviders().get(InventoryQuickMoveProvider.class); boolean succeed = provider.registerQuickMoveAction(windowId, slotId, actionId, wrapper.user()); if (succeed) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_11to1_11_1/rewriter/ItemPacketRewriter1_11_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_11to1_11_1/rewriter/ItemPacketRewriter1_11_1.java index ecc069076..aa2b855fb 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_11to1_11_1/rewriter/ItemPacketRewriter1_11_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_11to1_11_1/rewriter/ItemPacketRewriter1_11_1.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.v1_11to1_11_1.rewriter; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_11to1_11_1.Protocol1_11To1_11_1; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3; @@ -28,7 +29,7 @@ import com.viaversion.viaversion.rewriter.ItemRewriter; public class ItemPacketRewriter1_11_1 extends ItemRewriter { public ItemPacketRewriter1_11_1(Protocol1_11To1_11_1 protocol) { - super(protocol, Type.ITEM1_8, null); + super(protocol, Types.ITEM1_8, null); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_1to1_12_2/Protocol1_12_1To1_12_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_1to1_12_2/Protocol1_12_1To1_12_2.java index 5cb094eee..be2d45c79 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_1to1_12_2/Protocol1_12_1To1_12_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_1to1_12_2/Protocol1_12_1To1_12_2.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_1to1_12_2; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ClientboundPackets1_12_1; import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ServerboundPackets1_12_1; @@ -34,14 +34,14 @@ public class Protocol1_12_1To1_12_2 extends AbstractProtocol { - Position position = wrapper.read(Type.POSITION1_8); - wrapper.write(Type.INT, position.x()); - wrapper.write(Type.INT, position.y()); - wrapper.write(Type.INT, position.z()); + Position position = wrapper.read(Types.BLOCK_POSITION1_8); + wrapper.write(Types.INT, position.x()); + wrapper.write(Types.INT, position.y()); + wrapper.write(Types.INT, position.z()); }; public static final PacketHandler SEND_DECLARE_COMMANDS_AND_TAGS = w -> { // Send fake declare commands w.create(ClientboundPackets1_13.COMMANDS, wrapper -> { - wrapper.write(Type.VAR_INT, 2); // Size + wrapper.write(Types.VAR_INT, 2); // Size // Write root node - wrapper.write(Type.BYTE, (byte) 0); // Mark as command - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{1}); // 1 child at index 1 + wrapper.write(Types.BYTE, (byte) 0); // Mark as command + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{1}); // 1 child at index 1 // Write arg node - wrapper.write(Type.BYTE, (byte) (0x02 | 0x04 | 0x10)); // Mark as command - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[0]); // No children + wrapper.write(Types.BYTE, (byte) (0x02 | 0x04 | 0x10)); // Mark as command + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[0]); // No children // Extra data - wrapper.write(Type.STRING, "args"); // Arg name - wrapper.write(Type.STRING, "brigadier:string"); - wrapper.write(Type.VAR_INT, 2); // Greedy - wrapper.write(Type.STRING, "minecraft:ask_server"); // Ask server + wrapper.write(Types.STRING, "args"); // Arg name + wrapper.write(Types.STRING, "brigadier:string"); + wrapper.write(Types.VAR_INT, 2); // Greedy + wrapper.write(Types.STRING, "minecraft:ask_server"); // Ask server - wrapper.write(Type.VAR_INT, 0); // Root node index + wrapper.write(Types.VAR_INT, 0); // Root node index }).scheduleSend(Protocol1_12_2To1_13.class); // Send tags packet w.create(ClientboundPackets1_13.UPDATE_TAGS, wrapper -> { - wrapper.write(Type.VAR_INT, MAPPINGS.getBlockTags().size()); // block tags + wrapper.write(Types.VAR_INT, MAPPINGS.getBlockTags().size()); // block tags for (Map.Entry tag : MAPPINGS.getBlockTags().entrySet()) { - wrapper.write(Type.STRING, tag.getKey()); + wrapper.write(Types.STRING, tag.getKey()); // Needs copy as other protocols may modify it - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, tag.getValue()); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, tag.getValue()); } - wrapper.write(Type.VAR_INT, MAPPINGS.getItemTags().size()); // item tags + wrapper.write(Types.VAR_INT, MAPPINGS.getItemTags().size()); // item tags for (Map.Entry tag : MAPPINGS.getItemTags().entrySet()) { - wrapper.write(Type.STRING, tag.getKey()); + wrapper.write(Types.STRING, tag.getKey()); // Needs copy as other protocols may modify it - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, tag.getValue()); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, tag.getValue()); } - wrapper.write(Type.VAR_INT, MAPPINGS.getFluidTags().size()); // fluid tags + wrapper.write(Types.VAR_INT, MAPPINGS.getFluidTags().size()); // fluid tags for (Map.Entry tag : MAPPINGS.getFluidTags().entrySet()) { - wrapper.write(Type.STRING, tag.getKey()); + wrapper.write(Types.STRING, tag.getKey()); // Needs copy as other protocols may modify it - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, tag.getValue()); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, tag.getValue()); } }).scheduleSend(Protocol1_12_2To1_13.class); }; @@ -175,21 +176,21 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT)); + componentRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); }); registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), new PacketHandlers() { @Override public void register() { - map(Type.STRING); + map(Types.STRING); handler(wrapper -> { - String response = wrapper.get(Type.STRING, 0); + String response = wrapper.get(Types.STRING, 0); try { JsonObject json = GsonUtil.getGson().fromJson(response, JsonObject.class); if (json.has("favicon")) { json.addProperty("favicon", json.get("favicon").getAsString().replace("\n", "")); } - wrapper.set(Type.STRING, 0, GsonUtil.getGson().toJson(json)); + wrapper.set(Types.STRING, 0, GsonUtil.getGson().toJson(json)); } catch (JsonParseException e) { Via.getPlatform().getLogger().log(Level.SEVERE, "Error transforming status response", e); } @@ -201,14 +202,14 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - int size = wrapper.read(Type.VAR_INT); + int size = wrapper.read(Types.VAR_INT); List remappedStats = new ArrayList<>(); for (int i = 0; i < size; i++) { - String name = wrapper.read(Type.STRING); + String name = wrapper.read(Types.STRING); String[] split = name.split("\\."); int categoryId = 0; int newId = -1; - int value = wrapper.read(Type.VAR_INT); + int value = wrapper.read(Types.VAR_INT); if (split.length == 2) { // Custom types categoryId = 8; @@ -237,11 +238,11 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - wrapper.write(Type.VAR_INT, wrapper.user().get(TabCompleteTracker.class).getTransactionId()); + wrapper.write(Types.VAR_INT, wrapper.user().get(TabCompleteTracker.class).getTransactionId()); String input = wrapper.user().get(TabCompleteTracker.class).getInput(); // Start & End @@ -267,41 +268,41 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT))); // Title + map(Types.UNSIGNED_BYTE); // Id + map(Types.STRING); // Window type + handler(wrapper -> componentRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT))); // Title } }); registerClientbound(ClientboundPackets1_12_1.COOLDOWN, wrapper -> { - int item = wrapper.read(Type.VAR_INT); - int ticks = wrapper.read(Type.VAR_INT); + int item = wrapper.read(Types.VAR_INT); + int ticks = wrapper.read(Types.VAR_INT); wrapper.cancel(); if (item == 383) { // Spawn egg for (int i = 0; i < 44; i++) { int newItem = MAPPINGS.getItemMappings().getNewId(item << 16 | i); if (newItem != -1) { PacketWrapper packet = wrapper.create(ClientboundPackets1_13.COOLDOWN); - packet.write(Type.VAR_INT, newItem); - packet.write(Type.VAR_INT, ticks); + packet.write(Types.VAR_INT, newItem); + packet.write(Types.VAR_INT, ticks); packet.send(Protocol1_12_2To1_13.class); } else { break; @@ -312,8 +313,8 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - int id = wrapper.get(Type.INT, 0); - int data = wrapper.get(Type.INT, 1); + int id = wrapper.get(Types.INT, 0); + int data = wrapper.get(Types.INT, 1); if (id == 1010) { // Play record - wrapper.set(Type.INT, 1, getMappingData().getItemMappings().getNewId(IdAndData.toRawData(data))); + wrapper.set(Types.INT, 1, getMappingData().getItemMappings().getNewId(IdAndData.toRawData(data))); } else if (id == 2001) { // Block break + block break sound int blockId = data & 0xFFF; int blockData = data >> 12; - wrapper.set(Type.INT, 1, WorldPacketRewriter1_13.toNewId(IdAndData.toRawData(blockId, blockData))); + wrapper.set(Types.INT, 1, WorldPacketRewriter1_13.toNewId(IdAndData.toRawData(blockId, blockData))); } }); } @@ -347,8 +348,8 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol wrapper.write(Type.STRING, "viaversion:legacy/" + wrapper.read(Type.VAR_INT))); + map(Types.BYTE); + handler(wrapper -> wrapper.write(Types.STRING, "viaversion:legacy/" + wrapper.read(Types.VAR_INT))); } }); @@ -357,20 +358,20 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - int iconCount = wrapper.passthrough(Type.VAR_INT); + int iconCount = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < iconCount; i++) { - byte directionAndType = wrapper.read(Type.BYTE); + byte directionAndType = wrapper.read(Types.BYTE); int type = (directionAndType & 0xF0) >> 4; - wrapper.write(Type.VAR_INT, type); - wrapper.passthrough(Type.BYTE); // Icon X - wrapper.passthrough(Type.BYTE); // Icon Z + wrapper.write(Types.VAR_INT, type); + wrapper.passthrough(Types.BYTE); // Icon X + wrapper.passthrough(Types.BYTE); // Icon Z byte direction = (byte) (directionAndType & 0x0F); - wrapper.write(Type.BYTE, direction); - wrapper.write(Type.OPTIONAL_COMPONENT, null); // Display Name + wrapper.write(Types.BYTE, direction); + wrapper.write(Types.OPTIONAL_COMPONENT, null); // Display Name } }); } @@ -378,22 +379,22 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - wrapper.write(Type.BOOLEAN, false); // smelting book open - wrapper.write(Type.BOOLEAN, false); // smelting filter active + wrapper.write(Types.BOOLEAN, false); // smelting book open + wrapper.write(Types.BOOLEAN, false); // smelting filter active }); handler(wrapper -> { - int action = wrapper.get(Type.VAR_INT, 0); + int action = wrapper.get(Types.VAR_INT, 0); for (int i = 0; i < (action == 0 ? 2 : 1); i++) { - int[] ids = wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE); + int[] ids = wrapper.read(Types.VAR_INT_ARRAY_PRIMITIVE); String[] stringIds = new String[ids.length]; for (int j = 0; j < ids.length; j++) { stringIds[j] = "viaversion:legacy/" + ids[j]; } - wrapper.write(Type.STRING_ARRAY, stringIds); + wrapper.write(Types.STRING_ARRAY, stringIds); } if (action == 0) { wrapper.create(ClientboundPackets1_13.UPDATE_RECIPES, w -> writeDeclareRecipes(w)).send(Protocol1_12_2To1_13.class); @@ -405,10 +406,10 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 0); + int dimensionId = wrapper.get(Types.INT, 0); clientWorld.setEnvironment(dimensionId); if (Via.getConfig().isServersideBlockConnections()) { @@ -422,18 +423,18 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - byte mode = wrapper.get(Type.BYTE, 0); + byte mode = wrapper.get(Types.BYTE, 0); // On create or update if (mode == 0 || mode == 2) { - String value = wrapper.read(Type.STRING); // Value - wrapper.write(Type.COMPONENT, ComponentUtil.legacyToJson(value)); + String value = wrapper.read(Types.STRING); // Value + wrapper.write(Types.COMPONENT, ComponentUtil.legacyToJson(value)); - String type = wrapper.read(Type.STRING); + String type = wrapper.read(Types.STRING); // integer or hearts - wrapper.write(Type.VAR_INT, type.equals("integer") ? 0 : 1); + wrapper.write(Types.VAR_INT, type.equals("integer") ? 0 : 1); } }); } @@ -442,26 +443,26 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - byte action = wrapper.get(Type.BYTE, 0); + byte action = wrapper.get(Types.BYTE, 0); if (action == 0 || action == 2) { - String displayName = wrapper.read(Type.STRING); // Display Name - wrapper.write(Type.COMPONENT, ComponentUtil.legacyToJson(displayName)); + String displayName = wrapper.read(Types.STRING); // Display Name + wrapper.write(Types.COMPONENT, ComponentUtil.legacyToJson(displayName)); - String prefix = wrapper.read(Type.STRING); // Prefix moved - String suffix = wrapper.read(Type.STRING); // Suffix moved + String prefix = wrapper.read(Types.STRING); // Prefix moved + String suffix = wrapper.read(Types.STRING); // Suffix moved - wrapper.passthrough(Type.BYTE); // Flags + wrapper.passthrough(Types.BYTE); // Flags - wrapper.passthrough(Type.STRING); // Name Tag Visibility - wrapper.passthrough(Type.STRING); // Collision rule + wrapper.passthrough(Types.STRING); // Name Tag Visibility + wrapper.passthrough(Types.STRING); // Collision rule // Handle new colors - int colour = wrapper.read(Type.BYTE).intValue(); + int colour = wrapper.read(Types.BYTE).intValue(); if (colour == -1) { colour = 21; // -1 changed to 21 } @@ -472,27 +473,27 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - String displayName = wrapper.read(Type.STRING); // Display Name + String displayName = wrapper.read(Types.STRING); // Display Name displayName = rewriteTeamMemberName(displayName); - wrapper.write(Type.STRING, displayName); + wrapper.write(Types.STRING, displayName); }); componentRewriter.registerTitle(ClientboundPackets1_12_1.SET_TITLES); @@ -502,39 +503,39 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol(this).registerSound(ClientboundPackets1_12_1.SOUND); registerClientbound(ClientboundPackets1_12_1.TAB_LIST, wrapper -> { - componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT)); - componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT)); + componentRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); + componentRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); }); registerClientbound(ClientboundPackets1_12_1.UPDATE_ADVANCEMENTS, wrapper -> { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - int size = wrapper.passthrough(Type.VAR_INT); // Mapping size + wrapper.passthrough(Types.BOOLEAN); // Reset/clear + int size = wrapper.passthrough(Types.VAR_INT); // Mapping size for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier - wrapper.passthrough(Type.OPTIONAL_STRING); // Parent + wrapper.passthrough(Types.STRING); // Identifier + wrapper.passthrough(Types.OPTIONAL_STRING); // Parent // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { - componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT)); // Title - componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT)); // Description - Item icon = wrapper.read(Type.ITEM1_8); + if (wrapper.passthrough(Types.BOOLEAN)) { + componentRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); // Title + componentRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); // Description + Item icon = wrapper.read(Types.ITEM1_8); itemRewriter.handleItemToClient(wrapper.user(), icon); - wrapper.write(Type.ITEM1_13, icon); // Translate item to flat item - wrapper.passthrough(Type.VAR_INT); // Frame type - int flags = wrapper.passthrough(Type.INT); // Flags + wrapper.write(Types.ITEM1_13, icon); // Translate item to flat item + wrapper.passthrough(Types.VAR_INT); // Frame type + int flags = wrapper.passthrough(Types.INT); // Flags if ((flags & 1) != 0) { - wrapper.passthrough(Type.STRING); // Background texture + wrapper.passthrough(Types.STRING); // Background texture } - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y + wrapper.passthrough(Types.FLOAT); // X + wrapper.passthrough(Types.FLOAT); // Y } - wrapper.passthrough(Type.STRING_ARRAY); // Criteria + wrapper.passthrough(Types.STRING_ARRAY); // Criteria - int arrayLength = wrapper.passthrough(Type.VAR_INT); + int arrayLength = wrapper.passthrough(Types.VAR_INT); for (int array = 0; array < arrayLength; array++) { - wrapper.passthrough(Type.STRING_ARRAY); // String array + wrapper.passthrough(Types.STRING_ARRAY); // String array } } }); @@ -556,12 +557,12 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol(Type.STRING) { + map(Types.STRING, new ValueTransformer<>(Types.STRING) { @Override public String transform(PacketWrapper wrapper, String inputValue) { wrapper.user().get(TabCompleteTracker.class).setInput(inputValue); @@ -570,14 +571,14 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - wrapper.write(Type.BOOLEAN, false); + wrapper.write(Types.BOOLEAN, false); final Position playerLookTarget = Via.getManager().getProviders().get(PlayerLookTargetProvider.class).getPlayerLookTarget(wrapper.user()); - wrapper.write(Type.OPTIONAL_POSITION1_8, playerLookTarget); + wrapper.write(Types.OPTIONAL_POSITION1_8, playerLookTarget); if (!wrapper.isCancelled() && Via.getConfig().get1_13TabCompleteDelay() > 0) { TabCompleteTracker tracker = wrapper.user().get(TabCompleteTracker.class); wrapper.cancel(); tracker.setTimeToSend(System.currentTimeMillis() + Via.getConfig().get1_13TabCompleteDelay() * 50L); - tracker.setLastTabComplete(wrapper.get(Type.STRING, 0)); + tracker.setLastTabComplete(wrapper.get(Types.STRING, 0)); } }); } @@ -585,13 +586,13 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol Plugin Message registerServerbound(ServerboundPackets1_13.EDIT_BOOK, ServerboundPackets1_12_1.CUSTOM_PAYLOAD, wrapper -> { - Item item = wrapper.read(Type.ITEM1_13); - boolean isSigning = wrapper.read(Type.BOOLEAN); + Item item = wrapper.read(Types.ITEM1_13); + boolean isSigning = wrapper.read(Types.BOOLEAN); itemRewriter.handleItemToServer(wrapper.user(), item); - wrapper.write(Type.STRING, isSigning ? "MC|BSign" : "MC|BEdit"); // Channel - wrapper.write(Type.ITEM1_8, item); + wrapper.write(Types.STRING, isSigning ? "MC|BSign" : "MC|BEdit"); // Channel + wrapper.write(Types.ITEM1_8, item); }); // New 0x0C - Query Entity NBT @@ -599,23 +600,23 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol Plugin Message registerServerbound(ServerboundPackets1_13.PICK_ITEM, ServerboundPackets1_12_1.CUSTOM_PAYLOAD, wrapper -> { - wrapper.write(Type.STRING, "MC|PickItem"); // Channel + wrapper.write(Types.STRING, "MC|PickItem"); // Channel }); registerServerbound(ServerboundPackets1_13.PLACE_RECIPE, new PacketHandlers() { @Override public void register() { - map(Type.BYTE); // Window id + map(Types.BYTE); // Window id handler(wrapper -> { - String s = wrapper.read(Type.STRING); + String s = wrapper.read(Types.STRING); Integer id; if (s.length() < 19 || (id = Ints.tryParse(s.substring(18))) == null) { wrapper.cancel(); return; } - wrapper.write(Type.VAR_INT, id); + wrapper.write(Types.VAR_INT, id); }); } }); @@ -623,13 +624,13 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - int type = wrapper.get(Type.VAR_INT, 0); + int type = wrapper.get(Types.VAR_INT, 0); if (type == 0) { - String s = wrapper.read(Type.STRING); + String s = wrapper.read(Types.STRING); Integer id; // Custom recipes if (s.length() < 19 || (id = Ints.tryParse(s.substring(18))) == null) { @@ -637,13 +638,13 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol Plugin Message registerServerbound(ServerboundPackets1_13.RENAME_ITEM, ServerboundPackets1_12_1.CUSTOM_PAYLOAD, wrapper -> { - wrapper.write(Type.STRING, "MC|ItemName"); // Channel + wrapper.write(Types.STRING, "MC|ItemName"); // Channel }); // New 0x1F - Select Trade -> Plugin Message registerServerbound(ServerboundPackets1_13.SELECT_TRADE, ServerboundPackets1_12_1.CUSTOM_PAYLOAD, new PacketHandlers() { @Override public void register() { - create(Type.STRING, "MC|TrSel"); // Channel - map(Type.VAR_INT, Type.INT); // Slot + create(Types.STRING, "MC|TrSel"); // Channel + map(Types.VAR_INT, Types.INT); // Slot } }); @@ -667,9 +668,9 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - int mode = wrapper.read(Type.VAR_INT); - byte flags = wrapper.read(Type.BYTE); + int mode = wrapper.read(Types.VAR_INT); + byte flags = wrapper.read(Types.BYTE); String stringMode = mode == 0 ? "SEQUENCE" : mode == 1 ? "AUTO" : "REDSTONE"; - wrapper.write(Type.BOOLEAN, (flags & 0x1) != 0); // Track output - wrapper.write(Type.STRING, stringMode); - wrapper.write(Type.BOOLEAN, (flags & 0x2) != 0); // Is conditional - wrapper.write(Type.BOOLEAN, (flags & 0x4) != 0); // Automatic + wrapper.write(Types.BOOLEAN, (flags & 0x1) != 0); // Track output + wrapper.write(Types.STRING, stringMode); + wrapper.write(Types.BOOLEAN, (flags & 0x2) != 0); // Is conditional + wrapper.write(Types.BOOLEAN, (flags & 0x4) != 0); // Automatic }); } }); @@ -701,10 +702,10 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - wrapper.write(Type.STRING, "MC|AdvCmd"); - wrapper.write(Type.BYTE, (byte) 1); // Type 1 for Entity + wrapper.write(Types.STRING, "MC|AdvCmd"); + wrapper.write(Types.BYTE, (byte) 1); // Type 1 for Entity }); - map(Type.VAR_INT, Type.INT); // Entity id + map(Types.VAR_INT, Types.INT); // Entity id } }); @@ -714,15 +715,15 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol(Type.BYTE) { // Action + map(Types.VAR_INT, new ValueTransformer<>(Types.BYTE) { // Action @Override public Byte transform(PacketWrapper wrapper, Integer action) { return (byte) (action + 1); } }); // Action - map(Type.VAR_INT, new ValueTransformer<>(Type.STRING) { + map(Types.VAR_INT, new ValueTransformer<>(Types.STRING) { @Override public String transform(PacketWrapper wrapper, Integer mode) { return mode == 0 ? "SAVE" @@ -731,14 +732,14 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol(Type.STRING) { // Mirror + map(Types.STRING); // Name + map(Types.BYTE, Types.INT); // Offset X + map(Types.BYTE, Types.INT); // Offset Y + map(Types.BYTE, Types.INT); // Offset Z + map(Types.BYTE, Types.INT); // Size X + map(Types.BYTE, Types.INT); // Size Y + map(Types.BYTE, Types.INT); // Size Z + map(Types.VAR_INT, new ValueTransformer<>(Types.STRING) { // Mirror @Override public String transform(PacketWrapper wrapper, Integer mirror) { return mirror == 0 ? "NONE" @@ -746,7 +747,7 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol(Type.STRING) { // Rotation + map(Types.VAR_INT, new ValueTransformer<>(Types.STRING) { // Rotation @Override public String transform(PacketWrapper wrapper, Integer rotation) { return rotation == 0 ? "NONE" @@ -755,68 +756,68 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - float integrity = wrapper.read(Type.FLOAT); - long seed = wrapper.read(Type.VAR_LONG); - byte flags = wrapper.read(Type.BYTE); + float integrity = wrapper.read(Types.FLOAT); + long seed = wrapper.read(Types.VAR_LONG); + byte flags = wrapper.read(Types.BYTE); - wrapper.write(Type.BOOLEAN, (flags & 0x1) != 0); // Ignore Entities - wrapper.write(Type.BOOLEAN, (flags & 0x2) != 0); // Show air - wrapper.write(Type.BOOLEAN, (flags & 0x4) != 0); // Show bounding box - wrapper.write(Type.FLOAT, integrity); - wrapper.write(Type.VAR_LONG, seed); + wrapper.write(Types.BOOLEAN, (flags & 0x1) != 0); // Ignore Entities + wrapper.write(Types.BOOLEAN, (flags & 0x2) != 0); // Show air + wrapper.write(Types.BOOLEAN, (flags & 0x4) != 0); // Show bounding box + wrapper.write(Types.FLOAT, integrity); + wrapper.write(Types.VAR_LONG, seed); }); } }); } private void writeDeclareRecipes(PacketWrapper recipesPacket) { - recipesPacket.write(Type.VAR_INT, RecipeData.recipes.size()); + recipesPacket.write(Types.VAR_INT, RecipeData.recipes.size()); for (Map.Entry entry : RecipeData.recipes.entrySet()) { - recipesPacket.write(Type.STRING, entry.getKey()); // Id - recipesPacket.write(Type.STRING, entry.getValue().getType()); + recipesPacket.write(Types.STRING, entry.getKey()); // Id + recipesPacket.write(Types.STRING, entry.getValue().getType()); switch (entry.getValue().getType()) { case "crafting_shapeless": { - recipesPacket.write(Type.STRING, entry.getValue().getGroup()); - recipesPacket.write(Type.VAR_INT, entry.getValue().getIngredients().length); + recipesPacket.write(Types.STRING, entry.getValue().getGroup()); + recipesPacket.write(Types.VAR_INT, entry.getValue().getIngredients().length); for (Item[] ingredient : entry.getValue().getIngredients()) { Item[] clone = ingredient.clone(); // Clone because array and item is mutable for (int i = 0; i < clone.length; i++) { if (clone[i] == null) continue; clone[i] = new DataItem(clone[i]); } - recipesPacket.write(Type.ITEM1_13_ARRAY, clone); + recipesPacket.write(Types.ITEM1_13_ARRAY, clone); } - recipesPacket.write(Type.ITEM1_13, new DataItem(entry.getValue().getResult())); + recipesPacket.write(Types.ITEM1_13, new DataItem(entry.getValue().getResult())); break; } case "crafting_shaped": { - recipesPacket.write(Type.VAR_INT, entry.getValue().getWidth()); - recipesPacket.write(Type.VAR_INT, entry.getValue().getHeight()); - recipesPacket.write(Type.STRING, entry.getValue().getGroup()); + recipesPacket.write(Types.VAR_INT, entry.getValue().getWidth()); + recipesPacket.write(Types.VAR_INT, entry.getValue().getHeight()); + recipesPacket.write(Types.STRING, entry.getValue().getGroup()); for (Item[] ingredient : entry.getValue().getIngredients()) { Item[] clone = ingredient.clone(); // Clone because array and item is mutable for (int i = 0; i < clone.length; i++) { if (clone[i] == null) continue; clone[i] = new DataItem(clone[i]); } - recipesPacket.write(Type.ITEM1_13_ARRAY, clone); + recipesPacket.write(Types.ITEM1_13_ARRAY, clone); } - recipesPacket.write(Type.ITEM1_13, new DataItem(entry.getValue().getResult())); + recipesPacket.write(Types.ITEM1_13, new DataItem(entry.getValue().getResult())); break; } case "smelting": { - recipesPacket.write(Type.STRING, entry.getValue().getGroup()); + recipesPacket.write(Types.STRING, entry.getValue().getGroup()); Item[] clone = entry.getValue().getIngredient().clone(); // Clone because array and item is mutable for (int i = 0; i < clone.length; i++) { if (clone[i] == null) continue; clone[i] = new DataItem(clone[i]); } - recipesPacket.write(Type.ITEM1_13_ARRAY, clone); - recipesPacket.write(Type.ITEM1_13, new DataItem(entry.getValue().getResult())); - recipesPacket.write(Type.FLOAT, entry.getValue().getExperience()); - recipesPacket.write(Type.VAR_INT, entry.getValue().getCookingTime()); + recipesPacket.write(Types.ITEM1_13_ARRAY, clone); + recipesPacket.write(Types.ITEM1_13, new DataItem(entry.getValue().getResult())); + recipesPacket.write(Types.FLOAT, entry.getValue().getExperience()); + recipesPacket.write(Types.VAR_INT, entry.getValue().getCookingTime()); break; } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionData.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionData.java index 23b6d17c0..f787c1cab 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionData.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionData.java @@ -36,6 +36,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.providers.BlockConnectionProvider; import com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.providers.PacketBlockConnectionProvider; @@ -89,8 +90,8 @@ public final class ConnectionData { updateBlockStorage(user, pos.x(), pos.y(), pos.z(), newBlockState); PacketWrapper blockUpdatePacket = PacketWrapper.create(ClientboundPackets1_13.BLOCK_UPDATE, null, user); - blockUpdatePacket.write(Type.POSITION1_8, pos); - blockUpdatePacket.write(Type.VAR_INT, newBlockState); + blockUpdatePacket.write(Types.BLOCK_POSITION1_8, pos); + blockUpdatePacket.write(Types.VAR_INT, newBlockState); blockUpdatePacket.send(Protocol1_12_2To1_13.class); } } @@ -720,9 +721,9 @@ public final class ConnectionData { if (!updates.isEmpty()) { PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_13.CHUNK_BLOCKS_UPDATE, null, user); - wrapper.write(Type.INT, chunkX + chunkDeltaX); - wrapper.write(Type.INT, chunkZ + chunkDeltaZ); - wrapper.write(Type.BLOCK_CHANGE_RECORD_ARRAY, updates.toArray(EMPTY_RECORDS)); + wrapper.write(Types.INT, chunkX + chunkDeltaX); + wrapper.write(Types.INT, chunkZ + chunkDeltaZ); + wrapper.write(Types.BLOCK_CHANGE_ARRAY, updates.toArray(EMPTY_RECORDS)); wrapper.send(Protocol1_12_2To1_13.class); updates.clear(); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/data/ParticleRewriter.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/data/ParticleRewriter.java index c8061cf83..4f9ed4d64 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/data/ParticleRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/data/ParticleRewriter.java @@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.WorldPacketRewriter1_13; import com.viaversion.viaversion.api.minecraft.Particle; @@ -114,10 +115,10 @@ public class ParticleRewriter { // Randomized because the previous one was a lot of different colors at once! :) private static ParticleDataHandler reddustHandler() { return (particle, data) -> { - particle.add(Type.FLOAT, randomBool() ? 1f : 0f); // Red 0 - 1 - particle.add(Type.FLOAT, 0f); // Green 0 - 1 - particle.add(Type.FLOAT, randomBool() ? 1f : 0f); // Blue 0 - 1 - particle.add(Type.FLOAT, 1f);// Scale 0.01 - 4 + particle.add(Types.FLOAT, randomBool() ? 1f : 0f); // Red 0 - 1 + particle.add(Types.FLOAT, 0f); // Green 0 - 1 + particle.add(Types.FLOAT, randomBool() ? 1f : 0f); // Blue 0 - 1 + particle.add(Types.FLOAT, 1f);// Scale 0.01 - 4 return particle; }; } @@ -141,7 +142,7 @@ public class ParticleRewriter { // Transform to new Item Via.getManager().getProtocolManager().getProtocol(Protocol1_12_2To1_13.class).getItemRewriter().handleItemToClient(null, item); - particle.add(Type.ITEM1_13, item); // Item Slot The item that will be used. + particle.add(Types.ITEM1_13, item); // Item Slot The item that will be used. return particle; }; } @@ -153,7 +154,7 @@ public class ParticleRewriter { int combined = (((value & 4095) << 4) | (value >> 12 & 15)); int newId = WorldPacketRewriter1_13.toNewId(combined); - particle.add(Type.VAR_INT, newId); // BlockState VarInt The ID of the block state. + particle.add(Types.VAR_INT, newId); // BlockState VarInt The ID of the block state. return particle; }; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/metadata/MetadataRewriter1_13To1_12_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/metadata/MetadataRewriter1_13To1_12_2.java index d5eaa12e3..ed414928e 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/metadata/MetadataRewriter1_13To1_12_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/metadata/MetadataRewriter1_13To1_12_2.java @@ -40,7 +40,7 @@ public class MetadataRewriter1_13To1_12_2 extends EntityRewriter Types1_13.META_TYPES.byId(typeId > 4 ? typeId + 1 : typeId)); filter().metaType(Types1_13.META_TYPES.itemType).handler(((event, meta) -> protocol.getItemRewriter().handleItemToClient(event.user(), meta.value()))); - filter().metaType(Types1_13.META_TYPES.blockStateType).handler(((event, meta) -> { + filter().metaType(Types1_13.META_TYPES.optionalBlockStateType).handler(((event, meta) -> { final int oldId = meta.value(); if (oldId != 0) { final int combined = (((oldId & 4095) << 4) | (oldId >> 12 & 15)); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/providers/BlockEntityProvider.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/providers/BlockEntityProvider.java index 64b4d3046..c42cf0ffd 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/providers/BlockEntityProvider.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/providers/BlockEntityProvider.java @@ -25,6 +25,7 @@ import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.platform.providers.Provider; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.providers.blockentities.BannerHandler; @@ -80,8 +81,8 @@ public class BlockEntityProvider implements Provider { private void sendBlockChange(UserConnection user, Position position, int blockId) { PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_13.BLOCK_UPDATE, null, user); - wrapper.write(Type.POSITION1_8, position); - wrapper.write(Type.VAR_INT, blockId); + wrapper.write(Types.BLOCK_POSITION1_8, position); + wrapper.write(Types.VAR_INT, blockId); wrapper.send(Protocol1_12_2To1_13.class); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/EntityPacketRewriter1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/EntityPacketRewriter1_13.java index ca39fc17c..64c35c8de 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/EntityPacketRewriter1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/EntityPacketRewriter1_13.java @@ -22,6 +22,7 @@ import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_12; import com.viaversion.viaversion.api.type.types.version.Types1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; @@ -36,20 +37,20 @@ public class EntityPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.ADD_ENTITY, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity id - map(Type.UUID); // 1 - UUID - map(Type.BYTE); // 2 - Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Pitch - map(Type.BYTE); // 7 - Yaw - map(Type.INT); // 8 - Data + map(Types.VAR_INT); // 0 - Entity id + map(Types.UUID); // 1 - UUID + map(Types.BYTE); // 2 - Type + map(Types.DOUBLE); // 3 - X + map(Types.DOUBLE); // 4 - Y + map(Types.DOUBLE); // 5 - Z + map(Types.BYTE); // 6 - Pitch + map(Types.BYTE); // 7 - Yaw + map(Types.INT); // 8 - Data // Track Entity handler(wrapper -> { - int entityId = wrapper.get(Type.VAR_INT, 0); - byte type = wrapper.get(Type.BYTE, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); + byte type = wrapper.get(Types.BYTE, 0); EntityTypes1_13.EntityType entType = EntityTypes1_13.getTypeFromId(type, true); if (entType == null) return; @@ -57,14 +58,14 @@ public class EntityPacketRewriter1_13 { wrapper.user().getEntityTracker(Protocol1_12_2To1_13.class).addEntity(entityId, entType); if (entType.is(EntityTypes1_13.EntityType.FALLING_BLOCK)) { - int oldId = wrapper.get(Type.INT, 0); + int oldId = wrapper.get(Types.INT, 0); int combined = (((oldId & 4095) << 4) | (oldId >> 12 & 15)); - wrapper.set(Type.INT, 0, WorldPacketRewriter1_13.toNewId(combined)); + wrapper.set(Types.INT, 0, WorldPacketRewriter1_13.toNewId(combined)); } // Fix ItemFrame hitbox if (entType.is(EntityTypes1_13.EntityType.ITEM_FRAME)) { - int data = wrapper.get(Type.INT, 0); + int data = wrapper.get(Types.INT, 0); switch (data) { case 0 -> data = 3; // South case 1 -> data = 4; // West @@ -72,7 +73,7 @@ public class EntityPacketRewriter1_13 { case 3 -> data = 5; // East } - wrapper.set(Type.INT, 0, data); + wrapper.set(Types.INT, 0, data); } }); } @@ -81,18 +82,18 @@ public class EntityPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.ADD_MOB, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Entity UUID - map(Type.VAR_INT); // 2 - Entity Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Yaw - map(Type.BYTE); // 7 - Pitch - map(Type.BYTE); // 8 - Head Pitch - map(Type.SHORT); // 9 - Velocity X - map(Type.SHORT); // 10 - Velocity Y - map(Type.SHORT); // 11 - Velocity Z + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Entity UUID + map(Types.VAR_INT); // 2 - Entity Type + map(Types.DOUBLE); // 3 - X + map(Types.DOUBLE); // 4 - Y + map(Types.DOUBLE); // 5 - Z + map(Types.BYTE); // 6 - Yaw + map(Types.BYTE); // 7 - Pitch + map(Types.BYTE); // 8 - Head Pitch + map(Types.SHORT); // 9 - Velocity X + map(Types.SHORT); // 10 - Velocity Y + map(Types.SHORT); // 11 - Velocity Z map(Types1_12.METADATA_LIST, Types1_13.METADATA_LIST); // 12 - Metadata handler(metadataRewriter.trackerAndRewriterHandler(Types1_13.METADATA_LIST)); @@ -102,13 +103,13 @@ public class EntityPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.ADD_PLAYER, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Player UUID - map(Type.DOUBLE); // 2 - X - map(Type.DOUBLE); // 3 - Y - map(Type.DOUBLE); // 4 - Z - map(Type.BYTE); // 5 - Yaw - map(Type.BYTE); // 6 - Pitch + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Player UUID + map(Types.DOUBLE); // 2 - X + map(Types.DOUBLE); // 3 - Y + map(Types.DOUBLE); // 4 - Z + map(Types.BYTE); // 5 - Yaw + map(Types.BYTE); // 6 - Pitch map(Types1_12.METADATA_LIST, Types1_13.METADATA_LIST); // 7 - Metadata handler(metadataRewriter.trackerAndRewriterHandler(Types1_13.METADATA_LIST, EntityTypes1_13.EntityType.PLAYER)); @@ -118,13 +119,13 @@ public class EntityPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.LOGIN, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Entity ID - map(Type.UNSIGNED_BYTE); // 1 - Gamemode - map(Type.INT); // 2 - Dimension + map(Types.INT); // 0 - Entity ID + map(Types.UNSIGNED_BYTE); // 1 - Gamemode + map(Types.INT); // 2 - Dimension handler(wrapper -> { ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 1); + int dimensionId = wrapper.get(Types.INT, 1); clientChunks.setEnvironment(dimensionId); }); handler(metadataRewriter.playerTrackerHandler()); @@ -135,18 +136,18 @@ public class EntityPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.UPDATE_MOB_EFFECT, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // Entity id - map(Type.BYTE); // Effect id - map(Type.BYTE); // Amplifier - map(Type.VAR_INT); // Duration + map(Types.VAR_INT); // Entity id + map(Types.BYTE); // Effect id + map(Types.BYTE); // Amplifier + map(Types.VAR_INT); // Duration handler(packetWrapper -> { - byte flags = packetWrapper.read(Type.BYTE); // Input Flags + byte flags = packetWrapper.read(Types.BYTE); // Input Flags if (Via.getConfig().isNewEffectIndicator()) flags |= 0x04; - packetWrapper.write(Type.BYTE, flags); + packetWrapper.write(Types.BYTE, flags); }); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java index cc50540a9..e07e71299 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java @@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13; import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ClientboundPackets1_12_1; @@ -59,21 +60,21 @@ public class ItemPacketRewriter1_13 extends ItemRewriter handleItemToClient(wrapper.user(), wrapper.get(Type.ITEM1_13, 0))); + handler(wrapper -> handleItemToClient(wrapper.user(), wrapper.get(Types.ITEM1_13, 0))); } }); protocol.registerClientbound(ClientboundPackets1_12_1.CONTAINER_SET_CONTENT, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.ITEM1_8_SHORT_ARRAY, Type.ITEM1_13_SHORT_ARRAY); // 1 - Window Values + map(Types.UNSIGNED_BYTE); // 0 - Window ID + map(Types.ITEM1_8_SHORT_ARRAY, Types.ITEM1_13_SHORT_ARRAY); // 1 - Window Values handler(wrapper -> { - Item[] items = wrapper.get(Type.ITEM1_13_SHORT_ARRAY, 0); + Item[] items = wrapper.get(Types.ITEM1_13_SHORT_ARRAY, 0); for (Item item : items) { handleItemToClient(wrapper.user(), item); } @@ -83,14 +84,14 @@ public class ItemPacketRewriter1_13 extends ItemRewriter { - short property = wrapper.get(Type.SHORT, 0); + short property = wrapper.get(Types.SHORT, 0); if (property >= 4 && property <= 6) { // Enchantment id - wrapper.set(Type.SHORT, 1, (short) protocol.getMappingData().getEnchantmentMappings().getNewId(wrapper.get(Type.SHORT, 1))); + wrapper.set(Types.SHORT, 1, (short) protocol.getMappingData().getEnchantmentMappings().getNewId(wrapper.get(Types.SHORT, 1))); } }); } @@ -100,21 +101,21 @@ public class ItemPacketRewriter1_13 extends ItemRewriter { - String channel = wrapper.get(Type.STRING, 0); + String channel = wrapper.get(Types.STRING, 0); // Handle stopsound change if (channel.equals("MC|StopSound")) { - String originalSource = wrapper.read(Type.STRING); - String originalSound = wrapper.read(Type.STRING); + String originalSource = wrapper.read(Types.STRING); + String originalSound = wrapper.read(Types.STRING); // Reset the packet wrapper.clearPacket(); wrapper.setPacketType(ClientboundPackets1_13.STOP_SOUND); byte flags = 0; - wrapper.write(Type.BYTE, flags); // Placeholder + wrapper.write(Types.BYTE, flags); // Placeholder if (!originalSource.isEmpty()) { flags |= 1; Optional finalSource = SoundSource.findBySource(originalSource); @@ -126,41 +127,41 @@ public class ItemPacketRewriter1_13 extends ItemRewriter rewrittenChannels = new ArrayList<>(); for (String s : channels) { String rewritten = getNewPluginChannelId(s); @@ -183,14 +184,14 @@ public class ItemPacketRewriter1_13 extends ItemRewriter handleItemToClient(wrapper.user(), wrapper.get(Type.ITEM1_13, 0))); + handler(wrapper -> handleItemToClient(wrapper.user(), wrapper.get(Types.ITEM1_13, 0))); } }); @@ -210,23 +211,23 @@ public class ItemPacketRewriter1_13 extends ItemRewriter handleItemToServer(wrapper.user(), wrapper.get(Type.ITEM1_8, 0))); + handler(wrapper -> handleItemToServer(wrapper.user(), wrapper.get(Types.ITEM1_8, 0))); } }); protocol.registerServerbound(ServerboundPackets1_13.CUSTOM_PAYLOAD, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // Channel + map(Types.STRING); // Channel handlerSoftFail(wrapper -> { - String channel = wrapper.get(Type.STRING, 0); + String channel = wrapper.get(Types.STRING, 0); String old = channel; channel = getOldPluginChannelId(channel); if (channel == null) { @@ -236,7 +237,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter rewrittenChannels = new ArrayList<>(); for (String s : channels) { String rewritten = getOldPluginChannelId(s); @@ -246,9 +247,9 @@ public class ItemPacketRewriter1_13 extends ItemRewriter handleItemToServer(wrapper.user(), wrapper.get(Type.ITEM1_8, 0))); + handler(wrapper -> handleItemToServer(wrapper.user(), wrapper.get(Types.ITEM1_8, 0))); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/WorldPacketRewriter1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/WorldPacketRewriter1_13.java index dc50acb3e..62b7acfe3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/WorldPacketRewriter1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/WorldPacketRewriter1_13.java @@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; @@ -80,19 +81,19 @@ public class WorldPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.ADD_PAINTING, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Entity UUID + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Entity UUID handler(wrapper -> { PaintingProvider provider = Via.getManager().getProviders().get(PaintingProvider.class); - String motive = wrapper.read(Type.STRING); + String motive = wrapper.read(Types.STRING); Optional id = provider.getIntByIdentifier(motive); if (id.isEmpty() && (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug())) { Via.getPlatform().getLogger().warning("Could not find painting motive: " + motive + " falling back to default (0)"); } - wrapper.write(Type.VAR_INT, id.orElse(0)); + wrapper.write(Types.VAR_INT, id.orElse(0)); }); } }); @@ -100,14 +101,14 @@ public class WorldPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.BLOCK_ENTITY_DATA, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_8); // 0 - Location - map(Type.UNSIGNED_BYTE); // 1 - Action - map(Type.NAMED_COMPOUND_TAG); // 2 - NBT data + map(Types.BLOCK_POSITION1_8); // 0 - Location + map(Types.UNSIGNED_BYTE); // 1 - Action + map(Types.NAMED_COMPOUND_TAG); // 2 - NBT data handler(wrapper -> { - Position position = wrapper.get(Type.POSITION1_8, 0); - short action = wrapper.get(Type.UNSIGNED_BYTE, 0); - CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); + Position position = wrapper.get(Types.BLOCK_POSITION1_8, 0); + short action = wrapper.get(Types.UNSIGNED_BYTE, 0); + CompoundTag tag = wrapper.get(Types.NAMED_COMPOUND_TAG, 0); BlockEntityProvider provider = Via.getManager().getProviders().get(BlockEntityProvider.class); int newId = provider.transform(wrapper.user(), position, tag, true); @@ -130,15 +131,15 @@ public class WorldPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.BLOCK_EVENT, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_8); // Location - map(Type.UNSIGNED_BYTE); // Action Id - map(Type.UNSIGNED_BYTE); // Action param - map(Type.VAR_INT); // Block Id - /!\ NOT BLOCK STATE ID + map(Types.BLOCK_POSITION1_8); // Location + map(Types.UNSIGNED_BYTE); // Action Id + map(Types.UNSIGNED_BYTE); // Action param + map(Types.VAR_INT); // Block Id - /!\ NOT BLOCK STATE ID handler(wrapper -> { - Position pos = wrapper.get(Type.POSITION1_8, 0); - short action = wrapper.get(Type.UNSIGNED_BYTE, 0); - short param = wrapper.get(Type.UNSIGNED_BYTE, 1); - int blockId = wrapper.get(Type.VAR_INT, 0); + Position pos = wrapper.get(Types.BLOCK_POSITION1_8, 0); + short action = wrapper.get(Types.UNSIGNED_BYTE, 0); + short param = wrapper.get(Types.UNSIGNED_BYTE, 1); + int blockId = wrapper.get(Types.VAR_INT, 0); if (blockId == 25) blockId = 73; @@ -163,11 +164,11 @@ public class WorldPacketRewriter1_13 { if (blockId == 73) { // Note block PacketWrapper blockChange = wrapper.create(ClientboundPackets1_13.BLOCK_UPDATE); - blockChange.write(Type.POSITION1_8, pos); - blockChange.write(Type.VAR_INT, 249 + (action * 24 * 2) + (param * 2)); + blockChange.write(Types.BLOCK_POSITION1_8, pos); + blockChange.write(Types.VAR_INT, 249 + (action * 24 * 2) + (param * 2)); blockChange.send(Protocol1_12_2To1_13.class); } - wrapper.set(Type.VAR_INT, 0, blockId); + wrapper.set(Types.VAR_INT, 0, blockId); }); } }); @@ -175,11 +176,11 @@ public class WorldPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.BLOCK_UPDATE, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_8); - map(Type.VAR_INT); + map(Types.BLOCK_POSITION1_8); + map(Types.VAR_INT); handler(wrapper -> { - Position position = wrapper.get(Type.POSITION1_8, 0); - int newId = toNewId(wrapper.get(Type.VAR_INT, 0)); + Position position = wrapper.get(Types.BLOCK_POSITION1_8, 0); + int newId = toNewId(wrapper.get(Types.VAR_INT, 0)); UserConnection userConnection = wrapper.user(); if (Via.getConfig().isServersideBlockConnections()) { @@ -187,7 +188,7 @@ public class WorldPacketRewriter1_13 { ConnectionData.updateBlockStorage(userConnection, position.x(), position.y(), position.z(), newId); } - wrapper.set(Type.VAR_INT, 0, checkStorage(wrapper.user(), position, newId)); + wrapper.set(Types.VAR_INT, 0, checkStorage(wrapper.user(), position, newId)); if (Via.getConfig().isServersideBlockConnections()) { // Workaround for packet order issue @@ -202,14 +203,14 @@ public class WorldPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.CHUNK_BLOCKS_UPDATE, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Chunk X - map(Type.INT); // 1 - Chunk Z - map(Type.BLOCK_CHANGE_RECORD_ARRAY); // 2 - Records + map(Types.INT); // 0 - Chunk X + map(Types.INT); // 1 - Chunk Z + map(Types.BLOCK_CHANGE_ARRAY); // 2 - Records handler(wrapper -> { - int chunkX = wrapper.get(Type.INT, 0); - int chunkZ = wrapper.get(Type.INT, 1); + int chunkX = wrapper.get(Types.INT, 0); + int chunkZ = wrapper.get(Types.INT, 1); UserConnection userConnection = wrapper.user(); - BlockChangeRecord[] records = wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0); + BlockChangeRecord[] records = wrapper.get(Types.BLOCK_CHANGE_ARRAY, 0); // Convert ids for (BlockChangeRecord record : records) { int newBlock = toNewId(record.getBlockId()); @@ -264,25 +265,25 @@ public class WorldPacketRewriter1_13 { return; } - map(Type.FLOAT); // X - map(Type.FLOAT); // Y - map(Type.FLOAT); // Z - map(Type.FLOAT); // Radius - map(Type.INT); // Record Count + map(Types.FLOAT); // X + map(Types.FLOAT); // Y + map(Types.FLOAT); // Z + map(Types.FLOAT); // Radius + map(Types.INT); // Record Count handler(wrapper -> { UserConnection userConnection = wrapper.user(); - int x = (int) Math.floor(wrapper.get(Type.FLOAT, 0)); - int y = (int) Math.floor(wrapper.get(Type.FLOAT, 1)); - int z = (int) Math.floor(wrapper.get(Type.FLOAT, 2)); - int recordCount = wrapper.get(Type.INT, 0); + int x = (int) Math.floor(wrapper.get(Types.FLOAT, 0)); + int y = (int) Math.floor(wrapper.get(Types.FLOAT, 1)); + int z = (int) Math.floor(wrapper.get(Types.FLOAT, 2)); + int recordCount = wrapper.get(Types.INT, 0); Position[] records = new Position[recordCount]; for (int i = 0; i < recordCount; i++) { Position position = new Position( - x + wrapper.passthrough(Type.BYTE), - (short) (y + wrapper.passthrough(Type.BYTE)), - z + wrapper.passthrough(Type.BYTE)); + x + wrapper.passthrough(Types.BYTE), + (short) (y + wrapper.passthrough(Types.BYTE)), + z + wrapper.passthrough(Types.BYTE)); records[i] = position; // Set to air @@ -305,8 +306,8 @@ public class WorldPacketRewriter1_13 { public void register() { if (Via.getConfig().isServersideBlockConnections()) { handler(wrapper -> { - int x = wrapper.passthrough(Type.INT); - int z = wrapper.passthrough(Type.INT); + int x = wrapper.passthrough(Types.INT); + int z = wrapper.passthrough(Types.INT); ConnectionData.blockConnectionProvider.unloadChunk(wrapper.user(), x, z); }); } @@ -316,11 +317,11 @@ public class WorldPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.CUSTOM_SOUND, new PacketHandlers() { @Override public void register() { - map(Type.STRING); + map(Types.STRING); handler(wrapper -> { - String sound = Key.stripMinecraftNamespace(wrapper.get(Type.STRING, 0)); + String sound = Key.stripMinecraftNamespace(wrapper.get(Types.STRING, 0)); String newSoundId = NamedSoundRewriter.getNewId(sound); - wrapper.set(Type.STRING, 0, newSoundId); + wrapper.set(Types.STRING, 0, newSoundId); }); } }); @@ -470,19 +471,19 @@ public class WorldPacketRewriter1_13 { protocol.registerClientbound(ClientboundPackets1_12_1.LEVEL_PARTICLES, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Particle ID - map(Type.BOOLEAN); // 1 - Long Distance - map(Type.FLOAT); // 2 - X - map(Type.FLOAT); // 3 - Y - map(Type.FLOAT); // 4 - Z - map(Type.FLOAT); // 5 - Offset X - map(Type.FLOAT); // 6 - Offset Y - map(Type.FLOAT); // 7 - Offset Z - map(Type.FLOAT); // 8 - Particle Data - map(Type.INT); // 9 - Particle Count + map(Types.INT); // 0 - Particle ID + map(Types.BOOLEAN); // 1 - Long Distance + map(Types.FLOAT); // 2 - X + map(Types.FLOAT); // 3 - Y + map(Types.FLOAT); // 4 - Z + map(Types.FLOAT); // 5 - Offset X + map(Types.FLOAT); // 6 - Offset Y + map(Types.FLOAT); // 7 - Offset Z + map(Types.FLOAT); // 8 - Particle Data + map(Types.INT); // 9 - Particle Count handler(wrapper -> { - int particleId = wrapper.get(Type.INT, 0); + int particleId = wrapper.get(Types.INT, 0); // Get the data (Arrays are overrated) int dataCount = 0; @@ -495,7 +496,7 @@ public class WorldPacketRewriter1_13 { Integer[] data = new Integer[dataCount]; for (int i = 0; i < data.length; i++) - data[i] = wrapper.read(Type.VAR_INT); + data[i] = wrapper.read(Types.VAR_INT); Particle particle = ParticleRewriter.rewriteParticle(particleId, data); @@ -507,27 +508,27 @@ public class WorldPacketRewriter1_13 { // Handle reddust particle color if (particle.id() == 11) { - int count = wrapper.get(Type.INT, 1); - float speed = wrapper.get(Type.FLOAT, 6); + int count = wrapper.get(Types.INT, 1); + float speed = wrapper.get(Types.FLOAT, 6); // Only handle for count = 0 if (count == 0) { - wrapper.set(Type.INT, 1, 1); - wrapper.set(Type.FLOAT, 6, 0f); + wrapper.set(Types.INT, 1, 1); + wrapper.set(Types.FLOAT, 6, 0f); for (int i = 0; i < 3; i++) { //RGB values are represented by the X/Y/Z offset - float colorValue = wrapper.get(Type.FLOAT, i + 3) * speed; + float colorValue = wrapper.get(Types.FLOAT, i + 3) * speed; if (colorValue == 0 && i == 0) { // https://minecraft.gamepedia.com/User:Alphappy/reddust colorValue = 1; } particle.getArgument(i).setValue(colorValue); - wrapper.set(Type.FLOAT, i + 3, 0f); + wrapper.set(Types.FLOAT, i + 3, 0f); } } } - wrapper.set(Type.INT, 0, particle.id()); + wrapper.set(Types.INT, 0, particle.id()); for (Particle.ParticleData particleData : particle.getArguments()) particleData.write(wrapper); @@ -537,21 +538,21 @@ public class WorldPacketRewriter1_13 { // Incoming Packets protocol.registerServerbound(ServerboundPackets1_13.USE_ITEM_ON, wrapper -> { - Position pos = wrapper.passthrough(Type.POSITION1_8); - wrapper.passthrough(Type.VAR_INT); // block face - wrapper.passthrough(Type.VAR_INT); // hand - wrapper.passthrough(Type.FLOAT); // cursor x - wrapper.passthrough(Type.FLOAT); // cursor y - wrapper.passthrough(Type.FLOAT); // cursor z + Position pos = wrapper.passthrough(Types.BLOCK_POSITION1_8); + wrapper.passthrough(Types.VAR_INT); // block face + wrapper.passthrough(Types.VAR_INT); // hand + wrapper.passthrough(Types.FLOAT); // cursor x + wrapper.passthrough(Types.FLOAT); // cursor y + wrapper.passthrough(Types.FLOAT); // cursor z if (Via.getConfig().isServersideBlockConnections() && ConnectionData.needStoreBlocks()) { ConnectionData.markModified(wrapper.user(), pos); } }); protocol.registerServerbound(ServerboundPackets1_13.PLAYER_ACTION, wrapper -> { - int status = wrapper.passthrough(Type.VAR_INT); // Status - Position pos = wrapper.passthrough(Type.POSITION1_8); // Location - wrapper.passthrough(Type.UNSIGNED_BYTE); // block face + int status = wrapper.passthrough(Types.VAR_INT); // Status + Position pos = wrapper.passthrough(Types.BLOCK_POSITION1_8); // Location + wrapper.passthrough(Types.UNSIGNED_BYTE); // block face // 0 = Started digging: if in creative this causes the block to break directly // There's no point in storing the finished digging as it may never show-up (creative) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/TabCompleteTracker.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/TabCompleteTracker.java index b786f632d..21ad6265c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/TabCompleteTracker.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/TabCompleteTracker.java @@ -23,6 +23,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.providers.PlayerLookTargetProvider; import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ServerboundPackets1_12_1; @@ -37,10 +38,10 @@ public class TabCompleteTracker implements StorableObject { public void sendPacketToServer(UserConnection connection) { if (lastTabComplete == null || timeToSend > System.currentTimeMillis()) return; PacketWrapper wrapper = PacketWrapper.create(ServerboundPackets1_12_1.COMMAND_SUGGESTION, null, connection); - wrapper.write(Type.STRING, lastTabComplete); - wrapper.write(Type.BOOLEAN, false); + wrapper.write(Types.STRING, lastTabComplete); + wrapper.write(Types.BOOLEAN, false); final Position playerLookTarget = Via.getManager().getProviders().get(PlayerLookTargetProvider.class).getPlayerLookTarget(connection); - wrapper.write(Type.OPTIONAL_POSITION1_8, playerLookTarget); + wrapper.write(Types.OPTIONAL_POSITION1_8, playerLookTarget); wrapper.scheduleSendToServer(Protocol1_12_2To1_13.class); lastTabComplete = null; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/Protocol1_13_1To1_13_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/Protocol1_13_1To1_13_2.java index 98042a0b5..182d9fc3d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/Protocol1_13_1To1_13_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/Protocol1_13_1To1_13_2.java @@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13; import com.viaversion.viaversion.protocols.v1_13_1to1_13_2.rewriter.EntityPacketRewriter1_13_2; @@ -42,38 +43,38 @@ public class Protocol1_13_1To1_13_2 extends AbstractProtocol { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - int size = wrapper.passthrough(Type.VAR_INT); // Mapping size + wrapper.passthrough(Types.BOOLEAN); // Reset/clear + int size = wrapper.passthrough(Types.VAR_INT); // Mapping size for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier - wrapper.passthrough(Type.OPTIONAL_STRING); // Parent + wrapper.passthrough(Types.STRING); // Identifier + wrapper.passthrough(Types.OPTIONAL_STRING); // Parent // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.COMPONENT); // Title - wrapper.passthrough(Type.COMPONENT); // Description - Item icon = wrapper.read(Type.ITEM1_13); - wrapper.write(Type.ITEM1_13_2, icon); - wrapper.passthrough(Type.VAR_INT); // Frame type - int flags = wrapper.passthrough(Type.INT); // Flags + if (wrapper.passthrough(Types.BOOLEAN)) { + wrapper.passthrough(Types.COMPONENT); // Title + wrapper.passthrough(Types.COMPONENT); // Description + Item icon = wrapper.read(Types.ITEM1_13); + wrapper.write(Types.ITEM1_13_2, icon); + wrapper.passthrough(Types.VAR_INT); // Frame type + int flags = wrapper.passthrough(Types.INT); // Flags if ((flags & 1) != 0) { - wrapper.passthrough(Type.STRING); // Background texture + wrapper.passthrough(Types.STRING); // Background texture } - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y + wrapper.passthrough(Types.FLOAT); // X + wrapper.passthrough(Types.FLOAT); // Y } - wrapper.passthrough(Type.STRING_ARRAY); // Criteria + wrapper.passthrough(Types.STRING_ARRAY); // Criteria - int arrayLength = wrapper.passthrough(Type.VAR_INT); + int arrayLength = wrapper.passthrough(Types.VAR_INT); for (int array = 0; array < arrayLength; array++) { - wrapper.passthrough(Type.STRING_ARRAY); // String array + wrapper.passthrough(Types.STRING_ARRAY); // String array } } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/EntityPacketRewriter1_13_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/EntityPacketRewriter1_13_2.java index 7fd9edf07..91173f434 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/EntityPacketRewriter1_13_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/EntityPacketRewriter1_13_2.java @@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; 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.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; @@ -38,18 +39,18 @@ public class EntityPacketRewriter1_13_2 { protocol.registerClientbound(ClientboundPackets1_13.ADD_MOB, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Entity UUID - map(Type.VAR_INT); // 2 - Entity Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Yaw - map(Type.BYTE); // 7 - Pitch - map(Type.BYTE); // 8 - Head Pitch - map(Type.SHORT); // 9 - Velocity X - map(Type.SHORT); // 10 - Velocity Y - map(Type.SHORT); // 11 - Velocity Z + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Entity UUID + map(Types.VAR_INT); // 2 - Entity Type + map(Types.DOUBLE); // 3 - X + map(Types.DOUBLE); // 4 - Y + map(Types.DOUBLE); // 5 - Z + map(Types.BYTE); // 6 - Yaw + map(Types.BYTE); // 7 - Pitch + map(Types.BYTE); // 8 - Head Pitch + map(Types.SHORT); // 9 - Velocity X + map(Types.SHORT); // 10 - Velocity Y + map(Types.SHORT); // 11 - Velocity Z map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 12 - Metadata handler(metaTypeHandler); @@ -59,13 +60,13 @@ public class EntityPacketRewriter1_13_2 { protocol.registerClientbound(ClientboundPackets1_13.ADD_PLAYER, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Player UUID - map(Type.DOUBLE); // 2 - X - map(Type.DOUBLE); // 3 - Y - map(Type.DOUBLE); // 4 - Z - map(Type.BYTE); // 5 - Yaw - map(Type.BYTE); // 6 - Pitch + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Player UUID + map(Types.DOUBLE); // 2 - X + map(Types.DOUBLE); // 3 - Y + map(Types.DOUBLE); // 4 - Z + map(Types.BYTE); // 5 - Yaw + map(Types.BYTE); // 6 - Pitch map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata handler(metaTypeHandler); @@ -75,7 +76,7 @@ public class EntityPacketRewriter1_13_2 { protocol.registerClientbound(ClientboundPackets1_13.SET_ENTITY_DATA, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID + map(Types.VAR_INT); // 0 - Entity ID map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 1 - Metadata list handler(metaTypeHandler); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/ItemPacketRewriter1_13_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/ItemPacketRewriter1_13_2.java index 3f5a0e124..12bafb901 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/ItemPacketRewriter1_13_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/ItemPacketRewriter1_13_2.java @@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.v1_13_1to1_13_2.rewriter; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13; import com.viaversion.viaversion.protocols.v1_13_1to1_13_2.Protocol1_13_1To1_13_2; @@ -30,43 +31,43 @@ public class ItemPacketRewriter1_13_2 { protocol.registerClientbound(ClientboundPackets1_13.CONTAINER_SET_SLOT, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot ID - map(Type.ITEM1_13, Type.ITEM1_13_2); // 2 - Slot Value + map(Types.UNSIGNED_BYTE); // 0 - Window ID + map(Types.SHORT); // 1 - Slot ID + map(Types.ITEM1_13, Types.ITEM1_13_2); // 2 - Slot Value } }); protocol.registerClientbound(ClientboundPackets1_13.CONTAINER_SET_CONTENT, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.ITEM1_13_SHORT_ARRAY, Type.ITEM1_13_2_SHORT_ARRAY); // 1 - Window Values + map(Types.UNSIGNED_BYTE); // 0 - Window ID + map(Types.ITEM1_13_SHORT_ARRAY, Types.ITEM1_13_2_SHORT_ARRAY); // 1 - Window Values } }); protocol.registerClientbound(ClientboundPackets1_13.CUSTOM_PAYLOAD, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // Channel + map(Types.STRING); // Channel handlerSoftFail(wrapper -> { - String channel = Key.namespaced(wrapper.get(Type.STRING, 0)); + String channel = Key.namespaced(wrapper.get(Types.STRING, 0)); if (channel.equals("minecraft:trader_list")) { - wrapper.passthrough(Type.INT); // Passthrough Window ID + wrapper.passthrough(Types.INT); // Passthrough Window ID - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + int size = wrapper.passthrough(Types.UNSIGNED_BYTE); for (int i = 0; i < size; i++) { // Input Item - wrapper.write(Type.ITEM1_13_2, wrapper.read(Type.ITEM1_13)); + wrapper.write(Types.ITEM1_13_2, wrapper.read(Types.ITEM1_13)); // Output Item - wrapper.write(Type.ITEM1_13_2, wrapper.read(Type.ITEM1_13)); + wrapper.write(Types.ITEM1_13_2, wrapper.read(Types.ITEM1_13)); - boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item + boolean secondItem = wrapper.passthrough(Types.BOOLEAN); // Has second item if (secondItem) { - wrapper.write(Type.ITEM1_13_2, wrapper.read(Type.ITEM1_13)); + wrapper.write(Types.ITEM1_13_2, wrapper.read(Types.ITEM1_13)); } - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses + wrapper.passthrough(Types.BOOLEAN); // Trade disabled + wrapper.passthrough(Types.INT); // Number of tools uses + wrapper.passthrough(Types.INT); // Maximum number of trade uses } } }); @@ -76,39 +77,39 @@ public class ItemPacketRewriter1_13_2 { protocol.registerClientbound(ClientboundPackets1_13.SET_EQUIPPED_ITEM, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.VAR_INT); // 1 - Slot ID - map(Type.ITEM1_13, Type.ITEM1_13_2); // 2 - Item + map(Types.VAR_INT); // 0 - Entity ID + map(Types.VAR_INT); // 1 - Slot ID + map(Types.ITEM1_13, Types.ITEM1_13_2); // 2 - Item } }); protocol.registerClientbound(ClientboundPackets1_13.UPDATE_RECIPES, wrapper -> { - int recipesNo = wrapper.passthrough(Type.VAR_INT); + int recipesNo = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < recipesNo; i++) { - wrapper.passthrough(Type.STRING); // Id - String type = wrapper.passthrough(Type.STRING); + wrapper.passthrough(Types.STRING); // Id + String type = wrapper.passthrough(Types.STRING); if (type.equals("crafting_shapeless")) { - wrapper.passthrough(Type.STRING); // Group - int ingredientsNo = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.STRING); // Group + int ingredientsNo = wrapper.passthrough(Types.VAR_INT); for (int i1 = 0; i1 < ingredientsNo; i1++) { - wrapper.write(Type.ITEM1_13_2_ARRAY, wrapper.read(Type.ITEM1_13_ARRAY)); + wrapper.write(Types.ITEM1_13_2_ARRAY, wrapper.read(Types.ITEM1_13_ARRAY)); } - wrapper.write(Type.ITEM1_13_2, wrapper.read(Type.ITEM1_13)); + wrapper.write(Types.ITEM1_13_2, wrapper.read(Types.ITEM1_13)); } else if (type.equals("crafting_shaped")) { - int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.STRING); // Group + int ingredientsNo = wrapper.passthrough(Types.VAR_INT) * wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.STRING); // Group for (int i1 = 0; i1 < ingredientsNo; i1++) { - wrapper.write(Type.ITEM1_13_2_ARRAY, wrapper.read(Type.ITEM1_13_ARRAY)); + wrapper.write(Types.ITEM1_13_2_ARRAY, wrapper.read(Types.ITEM1_13_ARRAY)); } - wrapper.write(Type.ITEM1_13_2, wrapper.read(Type.ITEM1_13)); + wrapper.write(Types.ITEM1_13_2, wrapper.read(Types.ITEM1_13)); } else if (type.equals("smelting")) { - wrapper.passthrough(Type.STRING); // Group + wrapper.passthrough(Types.STRING); // Group // Ingredient start - wrapper.write(Type.ITEM1_13_2_ARRAY, wrapper.read(Type.ITEM1_13_ARRAY)); + wrapper.write(Types.ITEM1_13_2_ARRAY, wrapper.read(Types.ITEM1_13_ARRAY)); // Ingredient end - wrapper.write(Type.ITEM1_13_2, wrapper.read(Type.ITEM1_13)); - wrapper.passthrough(Type.FLOAT); // EXP - wrapper.passthrough(Type.VAR_INT); // Cooking time + wrapper.write(Types.ITEM1_13_2, wrapper.read(Types.ITEM1_13)); + wrapper.passthrough(Types.FLOAT); // EXP + wrapper.passthrough(Types.VAR_INT); // Cooking time } } }); @@ -116,19 +117,19 @@ public class ItemPacketRewriter1_13_2 { protocol.registerServerbound(ServerboundPackets1_13.CONTAINER_CLICK, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot - map(Type.BYTE); // 2 - Button - map(Type.SHORT); // 3 - Action number - map(Type.VAR_INT); // 4 - Mode - map(Type.ITEM1_13_2, Type.ITEM1_13); // 5 - Clicked Item + map(Types.UNSIGNED_BYTE); // 0 - Window ID + map(Types.SHORT); // 1 - Slot + map(Types.BYTE); // 2 - Button + map(Types.SHORT); // 3 - Action number + map(Types.VAR_INT); // 4 - Mode + map(Types.ITEM1_13_2, Types.ITEM1_13); // 5 - Clicked Item } }); protocol.registerServerbound(ServerboundPackets1_13.SET_CREATIVE_MODE_SLOT, new PacketHandlers() { @Override public void register() { - map(Type.SHORT); // 0 - Slot - map(Type.ITEM1_13_2, Type.ITEM1_13); // 1 - Clicked Item + map(Types.SHORT); // 0 - Slot + map(Types.ITEM1_13_2, Types.ITEM1_13); // 1 - Clicked Item } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/WorldPacketRewriter1_13_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/WorldPacketRewriter1_13_2.java index 9857cef08..801fb8b87 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/WorldPacketRewriter1_13_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_1to1_13_2/rewriter/WorldPacketRewriter1_13_2.java @@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.v1_13_1to1_13_2.rewriter; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_13_1to1_13_2.Protocol1_13_1To1_13_2; @@ -28,20 +29,20 @@ public class WorldPacketRewriter1_13_2 { protocol.registerClientbound(ClientboundPackets1_13.LEVEL_PARTICLES, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Particle ID - map(Type.BOOLEAN); // 1 - Long Distance - map(Type.FLOAT); // 2 - X - map(Type.FLOAT); // 3 - Y - map(Type.FLOAT); // 4 - Z - map(Type.FLOAT); // 5 - Offset X - map(Type.FLOAT); // 6 - Offset Y - map(Type.FLOAT); // 7 - Offset Z - map(Type.FLOAT); // 8 - Particle Data - map(Type.INT); // 9 - Particle Count + map(Types.INT); // 0 - Particle ID + map(Types.BOOLEAN); // 1 - Long Distance + map(Types.FLOAT); // 2 - X + map(Types.FLOAT); // 3 - Y + map(Types.FLOAT); // 4 - Z + map(Types.FLOAT); // 5 - Offset X + map(Types.FLOAT); // 6 - Offset Y + map(Types.FLOAT); // 7 - Offset Z + map(Types.FLOAT); // 8 - Particle Data + map(Types.INT); // 9 - Particle Count handler(wrapper -> { - int id = wrapper.get(Type.INT, 0); + int id = wrapper.get(Types.INT, 0); if (id == 27) { - wrapper.write(Type.ITEM1_13_2, wrapper.read(Type.ITEM1_13)); + wrapper.write(Types.ITEM1_13_2, wrapper.read(Types.ITEM1_13)); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java index 4c11ea005..5b6ed2dcf 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java @@ -22,6 +22,7 @@ import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_13_2; import com.viaversion.viaversion.api.type.types.version.Types1_14; @@ -79,58 +80,58 @@ public class Protocol1_13_2To1_14 extends AbstractProtocol { - int blockTagsSize = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT, blockTagsSize + 6); // block tags + int blockTagsSize = wrapper.read(Types.VAR_INT); + wrapper.write(Types.VAR_INT, blockTagsSize + 6); // block tags for (int i = 0; i < blockTagsSize; i++) { - wrapper.passthrough(Type.STRING); - int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); + wrapper.passthrough(Types.STRING); + int[] blockIds = wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE); for (int j = 0; j < blockIds.length; j++) { blockIds[j] = MAPPINGS.getNewBlockId(blockIds[j]); } } // Minecraft crashes if we not send signs tags - wrapper.write(Type.STRING, "minecraft:signs"); - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{ + wrapper.write(Types.STRING, "minecraft:signs"); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{ MAPPINGS.getNewBlockId(150), MAPPINGS.getNewBlockId(155) }); - wrapper.write(Type.STRING, "minecraft:wall_signs"); - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{ + wrapper.write(Types.STRING, "minecraft:wall_signs"); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{ MAPPINGS.getNewBlockId(155) }); - wrapper.write(Type.STRING, "minecraft:standing_signs"); - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{ + wrapper.write(Types.STRING, "minecraft:standing_signs"); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{ MAPPINGS.getNewBlockId(150) }); // Fences and walls tags - used for block connections - wrapper.write(Type.STRING, "minecraft:fences"); - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{189, 248, 472, 473, 474, 475}); - wrapper.write(Type.STRING, "minecraft:walls"); - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{271, 272}); - wrapper.write(Type.STRING, "minecraft:wooden_fences"); - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{189, 472, 473, 474, 475}); - int itemTagsSize = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT, itemTagsSize + 2); // item tags + wrapper.write(Types.STRING, "minecraft:fences"); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{189, 248, 472, 473, 474, 475}); + wrapper.write(Types.STRING, "minecraft:walls"); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{271, 272}); + wrapper.write(Types.STRING, "minecraft:wooden_fences"); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{189, 472, 473, 474, 475}); + int itemTagsSize = wrapper.read(Types.VAR_INT); + wrapper.write(Types.VAR_INT, itemTagsSize + 2); // item tags for (int i = 0; i < itemTagsSize; i++) { - wrapper.passthrough(Type.STRING); - int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); + wrapper.passthrough(Types.STRING); + int[] itemIds = wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE); for (int j = 0; j < itemIds.length; j++) { itemIds[j] = MAPPINGS.getNewItemId(itemIds[j]); } } // Should fix fuel shift clicking - wrapper.write(Type.STRING, "minecraft:signs"); - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{ + wrapper.write(Types.STRING, "minecraft:signs"); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{ MAPPINGS.getNewItemId(541) }); // Arrows tag (used by bow) - wrapper.write(Type.STRING, "minecraft:arrows"); - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{526, 825, 826}); - int fluidTagsSize = wrapper.passthrough(Type.VAR_INT); // fluid tags + wrapper.write(Types.STRING, "minecraft:arrows"); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{526, 825, 826}); + int fluidTagsSize = wrapper.passthrough(Types.VAR_INT); // fluid tags for (int i = 0; i < fluidTagsSize; i++) { - wrapper.passthrough(Type.STRING); - wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); + wrapper.passthrough(Types.STRING); + wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE); } - wrapper.write(Type.VAR_INT, 0); // new entity tags - do we need to send this? + wrapper.write(Types.VAR_INT, 0); // new entity tags - do we need to send this? }); // Set Difficulty packet added in 19w11a diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/metadata/MetadataRewriter1_14To1_13_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/metadata/MetadataRewriter1_14To1_13_2.java index e9280f35d..84e66a1a9 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/metadata/MetadataRewriter1_14To1_13_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/metadata/MetadataRewriter1_14To1_13_2.java @@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_13_2to1_14.Protocol1_13_2To1_14; @@ -43,7 +44,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter { - int entityId = wrapper.passthrough(Type.VAR_INT); + int entityId = wrapper.passthrough(Types.VAR_INT); metadataRewriter.tracker(wrapper.user()).addEntity(entityId, EntityTypes1_14.EXPERIENCE_ORB); }); protocol.registerClientbound(ClientboundPackets1_13.ADD_GLOBAL_ENTITY, wrapper -> { - int entityId = wrapper.passthrough(Type.VAR_INT); - if (wrapper.passthrough(Type.BYTE) == 1) { + int entityId = wrapper.passthrough(Types.VAR_INT); + if (wrapper.passthrough(Types.BYTE) == 1) { metadataRewriter.tracker(wrapper.user()).addEntity(entityId, EntityTypes1_14.LIGHTNING_BOLT); } }); @@ -56,32 +57,32 @@ public class EntityPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.ADD_ENTITY, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity id - map(Type.UUID); // 1 - UUID - map(Type.BYTE, Type.VAR_INT); // 2 - Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Pitch - map(Type.BYTE); // 7 - Yaw - map(Type.INT); // 8 - Data - map(Type.SHORT); // 9 - Velocity X - map(Type.SHORT); // 10 - Velocity Y - map(Type.SHORT); // 11 - Velocity Z + map(Types.VAR_INT); // 0 - Entity id + map(Types.UUID); // 1 - UUID + map(Types.BYTE, Types.VAR_INT); // 2 - Type + map(Types.DOUBLE); // 3 - X + map(Types.DOUBLE); // 4 - Y + map(Types.DOUBLE); // 5 - Z + map(Types.BYTE); // 6 - Pitch + map(Types.BYTE); // 7 - Yaw + map(Types.INT); // 8 - Data + map(Types.SHORT); // 9 - Velocity X + map(Types.SHORT); // 10 - Velocity Y + map(Types.SHORT); // 11 - Velocity Z // Track Entity handler(wrapper -> { - int entityId = wrapper.get(Type.VAR_INT, 0); - int typeId = wrapper.get(Type.VAR_INT, 1); + int entityId = wrapper.get(Types.VAR_INT, 0); + int typeId = wrapper.get(Types.VAR_INT, 1); EntityTypes1_13.EntityType type1_13 = EntityTypes1_13.getTypeFromId(typeId, true); typeId = metadataRewriter.newEntityId(type1_13.getId()); EntityType type1_14 = EntityTypes1_14.getTypeFromId(typeId); if (type1_14 != null) { - int data = wrapper.get(Type.INT, 0); + int data = wrapper.get(Types.INT, 0); if (type1_14.is(EntityTypes1_14.FALLING_BLOCK)) { - wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(data)); + wrapper.set(Types.INT, 0, protocol.getMappingData().getNewBlockStateId(data)); } else if (type1_14.is(EntityTypes1_14.MINECART)) { typeId = switch (data) { case 1 -> EntityTypes1_14.CHEST_MINECART.getId(); @@ -95,14 +96,14 @@ public class EntityPacketRewriter1_14 { } else if ((type1_14.is(EntityTypes1_14.ITEM) && data > 0) || type1_14.isOrHasParent(EntityTypes1_14.ABSTRACT_ARROW)) { if (type1_14.isOrHasParent(EntityTypes1_14.ABSTRACT_ARROW)) { - wrapper.set(Type.INT, 0, data - 1); + wrapper.set(Types.INT, 0, data - 1); } // send velocity in separate packet, 1.14 is now ignoring the velocity PacketWrapper velocity = wrapper.create(0x45); - velocity.write(Type.VAR_INT, entityId); - velocity.write(Type.SHORT, wrapper.get(Type.SHORT, 0)); - velocity.write(Type.SHORT, wrapper.get(Type.SHORT, 1)); - velocity.write(Type.SHORT, wrapper.get(Type.SHORT, 2)); + velocity.write(Types.VAR_INT, entityId); + velocity.write(Types.SHORT, wrapper.get(Types.SHORT, 0)); + velocity.write(Types.SHORT, wrapper.get(Types.SHORT, 1)); + velocity.write(Types.SHORT, wrapper.get(Types.SHORT, 2)); velocity.scheduleSend(Protocol1_13_2To1_14.class); } @@ -110,7 +111,7 @@ public class EntityPacketRewriter1_14 { wrapper.user().getEntityTracker(Protocol1_13_2To1_14.class).addEntity(entityId, type1_14); } - wrapper.set(Type.VAR_INT, 1, typeId); + wrapper.set(Types.VAR_INT, 1, typeId); }); } }); @@ -118,18 +119,18 @@ public class EntityPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.ADD_MOB, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Entity UUID - map(Type.VAR_INT); // 2 - Entity Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Yaw - map(Type.BYTE); // 7 - Pitch - map(Type.BYTE); // 8 - Head Pitch - map(Type.SHORT); // 9 - Velocity X - map(Type.SHORT); // 10 - Velocity Y - map(Type.SHORT); // 11 - Velocity Z + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Entity UUID + map(Types.VAR_INT); // 2 - Entity Type + map(Types.DOUBLE); // 3 - X + map(Types.DOUBLE); // 4 - Y + map(Types.DOUBLE); // 5 - Z + map(Types.BYTE); // 6 - Yaw + map(Types.BYTE); // 7 - Pitch + map(Types.BYTE); // 8 - Head Pitch + map(Types.SHORT); // 9 - Velocity X + map(Types.SHORT); // 10 - Velocity Y + map(Types.SHORT); // 11 - Velocity Z map(Types1_13_2.METADATA_LIST, Types1_14.METADATA_LIST); // 12 - Metadata handler(metadataRewriter.trackerAndRewriterHandler(Types1_14.METADATA_LIST)); @@ -139,25 +140,25 @@ public class EntityPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.ADD_PAINTING, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); - map(Type.UUID); - map(Type.VAR_INT); - map(Type.POSITION1_8, Type.POSITION1_14); - map(Type.BYTE); - handler(wrapper -> metadataRewriter.tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), EntityTypes1_14.PAINTING)); + map(Types.VAR_INT); + map(Types.UUID); + map(Types.VAR_INT); + map(Types.BLOCK_POSITION1_8, Types.BLOCK_POSITION1_14); + map(Types.BYTE); + handler(wrapper -> metadataRewriter.tracker(wrapper.user()).addEntity(wrapper.get(Types.VAR_INT, 0), EntityTypes1_14.PAINTING)); } }); protocol.registerClientbound(ClientboundPackets1_13.ADD_PLAYER, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Player UUID - map(Type.DOUBLE); // 2 - X - map(Type.DOUBLE); // 3 - Y - map(Type.DOUBLE); // 4 - Z - map(Type.BYTE); // 5 - Yaw - map(Type.BYTE); // 6 - Pitch + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Player UUID + map(Types.DOUBLE); // 2 - X + map(Types.DOUBLE); // 3 - Y + map(Types.DOUBLE); // 4 - Z + map(Types.BYTE); // 5 - Yaw + map(Types.BYTE); // 6 - Pitch map(Types1_13_2.METADATA_LIST, Types1_14.METADATA_LIST); // 7 - Metadata handler(metadataRewriter.trackerAndRewriterHandler(Types1_14.METADATA_LIST, EntityTypes1_14.PLAYER)); @@ -167,21 +168,21 @@ public class EntityPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.ANIMATE, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); + map(Types.VAR_INT); handler(wrapper -> { - short animation = wrapper.passthrough(Type.UNSIGNED_BYTE); + short animation = wrapper.passthrough(Types.UNSIGNED_BYTE); if (animation == 2) { //Leave bed EntityTracker1_14 tracker = wrapper.user().getEntityTracker(Protocol1_13_2To1_14.class); - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); tracker.setSleeping(entityId, false); PacketWrapper metadataPacket = wrapper.create(ClientboundPackets1_14.SET_ENTITY_DATA); - metadataPacket.write(Type.VAR_INT, entityId); + metadataPacket.write(Types.VAR_INT, entityId); List metadataList = new LinkedList<>(); if (tracker.clientEntityId() != entityId) { metadataList.add(new Metadata(6, Types1_14.META_TYPES.poseType, MetadataRewriter1_14To1_13_2.recalculatePlayerPose(entityId, tracker))); } - metadataList.add(new Metadata(12, Types1_14.META_TYPES.optionalPositionType, null)); + metadataList.add(new Metadata(12, Types1_14.META_TYPES.optionalBlockPositionType, null)); metadataPacket.write(Types1_14.METADATA_LIST, metadataList); metadataPacket.scheduleSend(Protocol1_13_2To1_14.class); } @@ -192,27 +193,27 @@ public class EntityPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.LOGIN, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Entity ID - map(Type.UNSIGNED_BYTE); // 1 - Gamemode - map(Type.INT); // 2 - Dimension + map(Types.INT); // 0 - Entity ID + map(Types.UNSIGNED_BYTE); // 1 - Gamemode + map(Types.INT); // 2 - Dimension handler(wrapper -> { // Store the player ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 1); + int dimensionId = wrapper.get(Types.INT, 1); clientChunks.setEnvironment(dimensionId); }); handler(metadataRewriter.playerTrackerHandler()); handler(wrapper -> { - short difficulty = wrapper.read(Type.UNSIGNED_BYTE); // 19w11a removed difficulty from join game + short difficulty = wrapper.read(Types.UNSIGNED_BYTE); // 19w11a removed difficulty from join game PacketWrapper difficultyPacket = wrapper.create(ClientboundPackets1_14.CHANGE_DIFFICULTY); - difficultyPacket.write(Type.UNSIGNED_BYTE, difficulty); - difficultyPacket.write(Type.BOOLEAN, false); // Unknown value added in 19w11a + difficultyPacket.write(Types.UNSIGNED_BYTE, difficulty); + difficultyPacket.write(Types.BOOLEAN, false); // Unknown value added in 19w11a difficultyPacket.scheduleSend(protocol.getClass()); - wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players - wrapper.passthrough(Type.STRING); // Level Type + wrapper.passthrough(Types.UNSIGNED_BYTE); // Max Players + wrapper.passthrough(Types.STRING); // Level Type - wrapper.write(Type.VAR_INT, WorldPacketRewriter1_14.SERVERSIDE_VIEW_DISTANCE); // Serverside view distance, added in 19w13a + wrapper.write(Types.VAR_INT, WorldPacketRewriter1_14.SERVERSIDE_VIEW_DISTANCE); // Serverside view distance, added in 19w13a }); handler(wrapper -> { // Manually send the packet @@ -228,15 +229,15 @@ public class EntityPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.PLAYER_SLEEP, ClientboundPackets1_14.SET_ENTITY_DATA, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); + map(Types.VAR_INT); handler(wrapper -> { EntityTracker1_14 tracker = wrapper.user().getEntityTracker(Protocol1_13_2To1_14.class); - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); tracker.setSleeping(entityId, true); - Position position = wrapper.read(Type.POSITION1_8); + Position position = wrapper.read(Types.BLOCK_POSITION1_8); List metadataList = new LinkedList<>(); - metadataList.add(new Metadata(12, Types1_14.META_TYPES.optionalPositionType, position)); + metadataList.add(new Metadata(12, Types1_14.META_TYPES.optionalBlockPositionType, position)); if (tracker.clientEntityId() != entityId) { metadataList.add(new Metadata(6, Types1_14.META_TYPES.poseType, MetadataRewriter1_14To1_13_2.recalculatePlayerPose(entityId, tracker))); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java index 328d5707e..ca54d12ce 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java @@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13; import com.viaversion.viaversion.protocols.v1_13_2to1_14.Protocol1_13_2To1_14; @@ -60,7 +61,7 @@ public class ItemPacketRewriter1_14 extends ItemRewriter { - Short windowId = wrapper.read(Type.UNSIGNED_BYTE); - String type = wrapper.read(Type.STRING); - JsonElement title = wrapper.read(Type.COMPONENT); + Short windowId = wrapper.read(Types.UNSIGNED_BYTE); + String type = wrapper.read(Types.STRING); + JsonElement title = wrapper.read(Types.COMPONENT); COMPONENT_REWRITER.processText(wrapper.user(), title); - Short slots = wrapper.read(Type.UNSIGNED_BYTE); + Short slots = wrapper.read(Types.UNSIGNED_BYTE); if (type.equals("EntityHorse")) { wrapper.setPacketType(ClientboundPackets1_14.HORSE_SCREEN_OPEN); - int entityId = wrapper.read(Type.INT); - wrapper.write(Type.UNSIGNED_BYTE, windowId); - wrapper.write(Type.VAR_INT, slots.intValue()); - wrapper.write(Type.INT, entityId); + int entityId = wrapper.read(Types.INT); + wrapper.write(Types.UNSIGNED_BYTE, windowId); + wrapper.write(Types.VAR_INT, slots.intValue()); + wrapper.write(Types.INT, entityId); } else { wrapper.setPacketType(ClientboundPackets1_14.OPEN_SCREEN); - wrapper.write(Type.VAR_INT, windowId.intValue()); + wrapper.write(Types.VAR_INT, windowId.intValue()); int typeId = -1; switch (type) { @@ -129,8 +130,8 @@ public class ItemPacketRewriter1_14 extends ItemRewriter { - String channel = Key.namespaced(wrapper.get(Type.STRING, 0)); + String channel = Key.namespaced(wrapper.get(Types.STRING, 0)); if (channel.equals("minecraft:trader_list")) { wrapper.setPacketType(ClientboundPackets1_14.MERCHANT_OFFERS); wrapper.resetReader(); - wrapper.read(Type.STRING); // Remove channel + wrapper.read(Types.STRING); // Remove channel - int windowId = wrapper.read(Type.INT); + int windowId = wrapper.read(Types.INT); EntityTracker1_14 tracker = wrapper.user().getEntityTracker(Protocol1_13_2To1_14.class); tracker.setLatestTradeWindowId(windowId); - wrapper.write(Type.VAR_INT, windowId); + wrapper.write(Types.VAR_INT, windowId); - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + int size = wrapper.passthrough(Types.UNSIGNED_BYTE); for (int i = 0; i < size; i++) { // Input Item - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Output Item - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); - boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item + boolean secondItem = wrapper.passthrough(Types.BOOLEAN); // Has second item if (secondItem) { // Second Item - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); } - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses + wrapper.passthrough(Types.BOOLEAN); // Trade disabled + wrapper.passthrough(Types.INT); // Number of tools uses + wrapper.passthrough(Types.INT); // Maximum number of trade uses - wrapper.write(Type.INT, 0); - wrapper.write(Type.INT, 0); - wrapper.write(Type.FLOAT, 0f); + wrapper.write(Types.INT, 0); + wrapper.write(Types.INT, 0); + wrapper.write(Types.FLOAT, 0f); } - wrapper.write(Type.VAR_INT, 0); - wrapper.write(Type.VAR_INT, 0); - wrapper.write(Type.BOOLEAN, false); + wrapper.write(Types.VAR_INT, 0); + wrapper.write(Types.VAR_INT, 0); + wrapper.write(Types.BOOLEAN, false); wrapper.clearInputBuffer(); } else if (channel.equals("minecraft:book_open")) { - int hand = wrapper.read(Type.VAR_INT); + int hand = wrapper.read(Types.VAR_INT); wrapper.clearPacket(); wrapper.setPacketType(ClientboundPackets1_14.OPEN_BOOK); - wrapper.write(Type.VAR_INT, hand); + wrapper.write(Types.VAR_INT, hand); } }); } @@ -192,21 +193,21 @@ public class ItemPacketRewriter1_14 extends ItemRewriter recipeRewriter = new RecipeRewriter<>(protocol); protocol.registerClientbound(ClientboundPackets1_13.UPDATE_RECIPES, wrapper -> { - int size = wrapper.passthrough(Type.VAR_INT); + int size = wrapper.passthrough(Types.VAR_INT); int deleted = 0; for (int i = 0; i < size; i++) { - String id = wrapper.read(Type.STRING); // Recipe Identifier - String type = wrapper.read(Type.STRING); + String id = wrapper.read(Types.STRING); // Recipe Identifier + String type = wrapper.read(Types.STRING); if (REMOVED_RECIPE_TYPES.contains(type)) { deleted++; continue; } - wrapper.write(Type.STRING, type); - wrapper.write(Type.STRING, id); + wrapper.write(Types.STRING, type); + wrapper.write(Types.STRING, id); recipeRewriter.handleRecipeType(wrapper, type); } - wrapper.set(Type.VAR_INT, 0, size - deleted); + wrapper.set(Types.VAR_INT, 0, size - deleted); }); @@ -216,20 +217,20 @@ public class ItemPacketRewriter1_14 extends ItemRewriter { - Item item = wrapper.passthrough(Type.ITEM1_13_2); + Item item = wrapper.passthrough(Types.ITEM1_13_2); protocol.getItemRewriter().handleItemToServer(wrapper.user(), item); if (item == null) return; @@ -78,30 +79,30 @@ public class PlayerPackets1_14 { protocol.registerServerbound(ServerboundPackets1_14.PLAYER_ACTION, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // Action - map(Type.POSITION1_14, Type.POSITION1_8); // Position + map(Types.VAR_INT); // Action + map(Types.BLOCK_POSITION1_14, Types.BLOCK_POSITION1_8); // Position } }); protocol.registerServerbound(ServerboundPackets1_14.RECIPE_BOOK_UPDATE, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); + map(Types.VAR_INT); handler(wrapper -> { - int type = wrapper.get(Type.VAR_INT, 0); + int type = wrapper.get(Types.VAR_INT, 0); if (type == 0) { - wrapper.passthrough(Type.STRING); + wrapper.passthrough(Types.STRING); } else if (type == 1) { - wrapper.passthrough(Type.BOOLEAN); // Crafting Recipe Book Open - wrapper.passthrough(Type.BOOLEAN); // Crafting Recipe Filter Active - wrapper.passthrough(Type.BOOLEAN); // Smelting Recipe Book Open - wrapper.passthrough(Type.BOOLEAN); // Smelting Recipe Filter Active + wrapper.passthrough(Types.BOOLEAN); // Crafting Recipe Book Open + wrapper.passthrough(Types.BOOLEAN); // Crafting Recipe Filter Active + wrapper.passthrough(Types.BOOLEAN); // Smelting Recipe Book Open + wrapper.passthrough(Types.BOOLEAN); // Smelting Recipe Filter Active // Unknown new booleans - wrapper.read(Type.BOOLEAN); - wrapper.read(Type.BOOLEAN); - wrapper.read(Type.BOOLEAN); - wrapper.read(Type.BOOLEAN); + wrapper.read(Types.BOOLEAN); + wrapper.read(Types.BOOLEAN); + wrapper.read(Types.BOOLEAN); + wrapper.read(Types.BOOLEAN); } }); } @@ -110,37 +111,37 @@ public class PlayerPackets1_14 { protocol.registerServerbound(ServerboundPackets1_14.SET_COMMAND_BLOCK, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_14, Type.POSITION1_8); + map(Types.BLOCK_POSITION1_14, Types.BLOCK_POSITION1_8); } }); protocol.registerServerbound(ServerboundPackets1_14.SET_STRUCTURE_BLOCK, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_14, Type.POSITION1_8); + map(Types.BLOCK_POSITION1_14, Types.BLOCK_POSITION1_8); } }); protocol.registerServerbound(ServerboundPackets1_14.SIGN_UPDATE, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_14, Type.POSITION1_8); + map(Types.BLOCK_POSITION1_14, Types.BLOCK_POSITION1_8); } }); protocol.registerServerbound(ServerboundPackets1_14.USE_ITEM_ON, wrapper -> { - int hand = wrapper.read(Type.VAR_INT); - Position position = wrapper.read(Type.POSITION1_14); - int face = wrapper.read(Type.VAR_INT); - float x = wrapper.read(Type.FLOAT); - float y = wrapper.read(Type.FLOAT); - float z = wrapper.read(Type.FLOAT); - wrapper.read(Type.BOOLEAN); // new unknown boolean + int hand = wrapper.read(Types.VAR_INT); + Position position = wrapper.read(Types.BLOCK_POSITION1_14); + int face = wrapper.read(Types.VAR_INT); + float x = wrapper.read(Types.FLOAT); + float y = wrapper.read(Types.FLOAT); + float z = wrapper.read(Types.FLOAT); + wrapper.read(Types.BOOLEAN); // new unknown boolean - wrapper.write(Type.POSITION1_8, position); - wrapper.write(Type.VAR_INT, face); - wrapper.write(Type.VAR_INT, hand); - wrapper.write(Type.FLOAT, x); - wrapper.write(Type.FLOAT, y); - wrapper.write(Type.FLOAT, z); + wrapper.write(Types.BLOCK_POSITION1_8, position); + wrapper.write(Types.VAR_INT, face); + wrapper.write(Types.VAR_INT, hand); + wrapper.write(Types.FLOAT, x); + wrapper.write(Types.FLOAT, y); + wrapper.write(Types.FLOAT, z); }); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/WorldPacketRewriter1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/WorldPacketRewriter1_14.java index cf323a020..fa8b2a5ba 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/WorldPacketRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/WorldPacketRewriter1_14.java @@ -31,6 +31,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_14; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; @@ -58,36 +59,36 @@ public class WorldPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.BLOCK_DESTRUCTION, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); - map(Type.POSITION1_8, Type.POSITION1_14); - map(Type.BYTE); + map(Types.VAR_INT); + map(Types.BLOCK_POSITION1_8, Types.BLOCK_POSITION1_14); + map(Types.BYTE); } }); protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_8, Type.POSITION1_14); + map(Types.BLOCK_POSITION1_8, Types.BLOCK_POSITION1_14); } }); protocol.registerClientbound(ClientboundPackets1_13.BLOCK_EVENT, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_8, Type.POSITION1_14); // Location - map(Type.UNSIGNED_BYTE); // Action id - map(Type.UNSIGNED_BYTE); // Action param - map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE - handler(wrapper -> wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockId(wrapper.get(Type.VAR_INT, 0)))); + map(Types.BLOCK_POSITION1_8, Types.BLOCK_POSITION1_14); // Location + map(Types.UNSIGNED_BYTE); // Action id + map(Types.UNSIGNED_BYTE); // Action param + map(Types.VAR_INT); // Block id - /!\ NOT BLOCK STATE + handler(wrapper -> wrapper.set(Types.VAR_INT, 0, protocol.getMappingData().getNewBlockId(wrapper.get(Types.VAR_INT, 0)))); } }); protocol.registerClientbound(ClientboundPackets1_13.BLOCK_UPDATE, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_8, Type.POSITION1_14); - map(Type.VAR_INT); + map(Types.BLOCK_POSITION1_8, Types.BLOCK_POSITION1_14); + map(Types.VAR_INT); handler(wrapper -> { - int id = wrapper.get(Type.VAR_INT, 0); + int id = wrapper.get(Types.VAR_INT, 0); - wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(id)); + wrapper.set(Types.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(id)); }); } }); @@ -95,9 +96,9 @@ public class WorldPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.CHANGE_DIFFICULTY, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); + map(Types.UNSIGNED_BYTE); handler(wrapper -> { - wrapper.write(Type.BOOLEAN, false); // Added in 19w11a. Maybe https://bugs.mojang.com/browse/MC-44471 ? + wrapper.write(Types.BOOLEAN, false); // Added in 19w11a. Maybe https://bugs.mojang.com/browse/MC-44471 ? }); } }); @@ -107,17 +108,17 @@ public class WorldPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.EXPLODE, new PacketHandlers() { @Override public void register() { - map(Type.FLOAT); // X - map(Type.FLOAT); // Y - map(Type.FLOAT); // Z - map(Type.FLOAT); // Radius + map(Types.FLOAT); // X + map(Types.FLOAT); // Y + map(Types.FLOAT); // Z + map(Types.FLOAT); // Radius handler(wrapper -> { for (int i = 0; i < 3; i++) { - float coord = wrapper.get(Type.FLOAT, i); + float coord = wrapper.get(Types.FLOAT, i); if (coord < 0f) { coord = (int) coord; - wrapper.set(Type.FLOAT, i, coord); + wrapper.set(Types.FLOAT, i, coord); } } }); @@ -183,8 +184,8 @@ public class WorldPacketRewriter1_14 { chunk.setHeightMap(heightMap); PacketWrapper lightPacket = wrapper.create(ClientboundPackets1_14.LIGHT_UPDATE); - lightPacket.write(Type.VAR_INT, chunk.getX()); - lightPacket.write(Type.VAR_INT, chunk.getZ()); + lightPacket.write(Types.VAR_INT, chunk.getX()); + lightPacket.write(Types.VAR_INT, chunk.getZ()); int skyLightMask = chunk.isFullChunk() ? 0x3ffff : 0; // all 18 bits set if ground up int blockLightMask = 0; @@ -197,30 +198,30 @@ public class WorldPacketRewriter1_14 { blockLightMask |= (1 << (i + 1)); } - lightPacket.write(Type.VAR_INT, skyLightMask); - lightPacket.write(Type.VAR_INT, blockLightMask); - lightPacket.write(Type.VAR_INT, 0); // empty sky light mask - lightPacket.write(Type.VAR_INT, 0); // empty block light mask + lightPacket.write(Types.VAR_INT, skyLightMask); + lightPacket.write(Types.VAR_INT, blockLightMask); + lightPacket.write(Types.VAR_INT, 0); // empty sky light mask + lightPacket.write(Types.VAR_INT, 0); // empty block light mask // not sending skylight/setting empty skylight causes client lag due to some weird calculations // only do this on the initial chunk send (not when chunk.isGroundUp() is false) if (chunk.isFullChunk()) - lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT); // chunk below 0 + lightPacket.write(Types.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT); // chunk below 0 for (ChunkSection section : chunk.getSections()) { if (section == null || !section.getLight().hasSkyLight()) { if (chunk.isFullChunk()) { - lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT); + lightPacket.write(Types.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT); } continue; } - lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, section.getLight().getSkyLight()); + lightPacket.write(Types.BYTE_ARRAY_PRIMITIVE, section.getLight().getSkyLight()); } if (chunk.isFullChunk()) - lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT); // chunk above 255 + lightPacket.write(Types.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT); // chunk above 255 for (ChunkSection section : chunk.getSections()) { if (section == null) continue; - lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, section.getLight().getBlockLight()); + lightPacket.write(Types.BYTE_ARRAY_PRIMITIVE, section.getLight().getBlockLight()); } EntityTracker1_14 entityTracker = wrapper.user().getEntityTracker(Protocol1_13_2To1_14.class); @@ -230,8 +231,8 @@ public class WorldPacketRewriter1_14 { || diffX >= SERVERSIDE_VIEW_DISTANCE || diffZ >= SERVERSIDE_VIEW_DISTANCE) { PacketWrapper fakePosLook = wrapper.create(ClientboundPackets1_14.SET_CHUNK_CACHE_CENTER); // Set center chunk - fakePosLook.write(Type.VAR_INT, chunk.getX()); - fakePosLook.write(Type.VAR_INT, chunk.getZ()); + fakePosLook.write(Types.VAR_INT, chunk.getX()); + fakePosLook.write(Types.VAR_INT, chunk.getZ()); fakePosLook.send(Protocol1_13_2To1_14.class); entityTracker.setChunkCenterX(chunk.getX()); entityTracker.setChunkCenterZ(chunk.getZ()); @@ -250,16 +251,16 @@ public class WorldPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.LEVEL_EVENT, new PacketHandlers() { @Override public void register() { - map(Type.INT); // Effect Id - map(Type.POSITION1_8, Type.POSITION1_14); // Location - map(Type.INT); // Data + map(Types.INT); // Effect Id + map(Types.BLOCK_POSITION1_8, Types.BLOCK_POSITION1_14); // Location + map(Types.INT); // Data handler(wrapper -> { - int id = wrapper.get(Type.INT, 0); - int data = wrapper.get(Type.INT, 1); + int id = wrapper.get(Types.INT, 0); + int data = wrapper.get(Types.INT, 1); if (id == 1010) { // Play record - wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(data)); + wrapper.set(Types.INT, 1, protocol.getMappingData().getNewItemId(data)); } else if (id == 2001) { // Block break + block break sound - wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(data)); + wrapper.set(Types.INT, 1, protocol.getMappingData().getNewBlockStateId(data)); } }); } @@ -268,11 +269,11 @@ public class WorldPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.MAP_ITEM_DATA, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); - map(Type.BYTE); - map(Type.BOOLEAN); + map(Types.VAR_INT); + map(Types.BYTE); + map(Types.BOOLEAN); handler(wrapper -> { - wrapper.write(Type.BOOLEAN, false); // new value, probably if the map is locked (added in 19w02a), old maps are not locked + wrapper.write(Types.BOOLEAN, false); // new value, probably if the map is locked (added in 19w02a), old maps are not locked }); } }); @@ -280,20 +281,20 @@ public class WorldPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Dimension ID + map(Types.INT); // 0 - Dimension ID handler(wrapper -> { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 0); + int dimensionId = wrapper.get(Types.INT, 0); clientWorld.setEnvironment(dimensionId); EntityTracker1_14 entityTracker = wrapper.user().getEntityTracker(Protocol1_13_2To1_14.class); // The client may reset the center chunk if dimension is changed entityTracker.setForceSendCenterChunk(true); }); handler(wrapper -> { - short difficulty = wrapper.read(Type.UNSIGNED_BYTE); // 19w11a removed difficulty from respawn + short difficulty = wrapper.read(Types.UNSIGNED_BYTE); // 19w11a removed difficulty from respawn PacketWrapper difficultyPacket = wrapper.create(ClientboundPackets1_14.CHANGE_DIFFICULTY); - difficultyPacket.write(Type.UNSIGNED_BYTE, difficulty); - difficultyPacket.write(Type.BOOLEAN, false); // Unknown value added in 19w11a + difficultyPacket.write(Types.UNSIGNED_BYTE, difficulty); + difficultyPacket.write(Types.BOOLEAN, false); // Unknown value added in 19w11a difficultyPacket.scheduleSend(protocol.getClass()); }); handler(wrapper -> { @@ -308,14 +309,14 @@ public class WorldPacketRewriter1_14 { protocol.registerClientbound(ClientboundPackets1_13.SET_DEFAULT_SPAWN_POSITION, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_8, Type.POSITION1_14); + map(Types.BLOCK_POSITION1_8, Types.BLOCK_POSITION1_14); } }); } static void sendViewDistancePacket(UserConnection connection) { PacketWrapper setViewDistance = PacketWrapper.create(ClientboundPackets1_14.SET_CHUNK_CACHE_RADIUS, connection); - setViewDistance.write(Type.VAR_INT, WorldPacketRewriter1_14.SERVERSIDE_VIEW_DISTANCE); + setViewDistance.write(Types.VAR_INT, WorldPacketRewriter1_14.SERVERSIDE_VIEW_DISTANCE); setViewDistance.send(Protocol1_13_2To1_14.class); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/Protocol1_13To1_13_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/Protocol1_13To1_13_1.java index efec1c653..94d6ee10a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/Protocol1_13To1_13_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/Protocol1_13To1_13_1.java @@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13; @@ -60,8 +61,8 @@ public class Protocol1_13To1_13_1 extends AbstractProtocol(Type.STRING) { + map(Types.VAR_INT); + map(Types.STRING, new ValueTransformer<>(Types.STRING) { @Override public String transform(PacketWrapper wrapper, String inputValue) { // 1.13 starts sending slash at start, so we remove it for compatibility @@ -74,14 +75,14 @@ public class Protocol1_13To1_13_1 extends AbstractProtocol { - Item item = wrapper.get(Type.ITEM1_13, 0); + Item item = wrapper.get(Types.ITEM1_13, 0); itemRewriter.handleItemToServer(wrapper.user(), item); }); handler(wrapper -> { - int hand = wrapper.read(Type.VAR_INT); + int hand = wrapper.read(Types.VAR_INT); if (hand == 1) { wrapper.cancel(); } @@ -92,18 +93,18 @@ public class Protocol1_13To1_13_1 extends AbstractProtocol { - int start = wrapper.get(Type.VAR_INT, 1); - wrapper.set(Type.VAR_INT, 1, start + 1); // Offset by +1 to take into account / at beginning + int start = wrapper.get(Types.VAR_INT, 1); + wrapper.set(Types.VAR_INT, 1, start + 1); // Offset by +1 to take into account / at beginning // Passthrough suggestions - int count = wrapper.get(Type.VAR_INT, 3); + int count = wrapper.get(Types.VAR_INT, 3); for (int i = 0; i < count; i++) { - wrapper.passthrough(Type.STRING); - wrapper.passthrough(Type.OPTIONAL_COMPONENT); // Tooltip + wrapper.passthrough(Types.STRING); + wrapper.passthrough(Types.OPTIONAL_COMPONENT); // Tooltip } }); } @@ -112,18 +113,18 @@ public class Protocol1_13To1_13_1 extends AbstractProtocol { - int action = wrapper.get(Type.VAR_INT, 0); + int action = wrapper.get(Types.VAR_INT, 0); if (action == 0) { - wrapper.passthrough(Type.COMPONENT); - wrapper.passthrough(Type.FLOAT); - wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.VAR_INT); - short flags = wrapper.read(Type.BYTE); + wrapper.passthrough(Types.COMPONENT); + wrapper.passthrough(Types.FLOAT); + wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.VAR_INT); + short flags = wrapper.read(Types.BYTE); if ((flags & 0x02) != 0) flags |= 0x04; - wrapper.write(Type.UNSIGNED_BYTE, flags); + wrapper.write(Types.UNSIGNED_BYTE, flags); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/metadata/MetadataRewriter1_13_1To1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/metadata/MetadataRewriter1_13_1To1_13.java index ff1389302..46cb8478b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/metadata/MetadataRewriter1_13_1To1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/metadata/MetadataRewriter1_13_1To1_13.java @@ -32,7 +32,7 @@ public class MetadataRewriter1_13_1To1_13 extends EntityRewriter { int data = meta.value(); meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/EntityPacketRewriter1_13_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/EntityPacketRewriter1_13_1.java index f105f7a95..e1d78057e 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/EntityPacketRewriter1_13_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/EntityPacketRewriter1_13_1.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.v1_13to1_13_1.rewriter; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_13to1_13_1.Protocol1_13To1_13_1; @@ -33,26 +34,26 @@ public class EntityPacketRewriter1_13_1 { protocol.registerClientbound(ClientboundPackets1_13.ADD_ENTITY, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity id - map(Type.UUID); // 1 - UUID - map(Type.BYTE); // 2 - Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Pitch - map(Type.BYTE); // 7 - Yaw - map(Type.INT); // 8 - Data + map(Types.VAR_INT); // 0 - Entity id + map(Types.UUID); // 1 - UUID + map(Types.BYTE); // 2 - Type + map(Types.DOUBLE); // 3 - X + map(Types.DOUBLE); // 4 - Y + map(Types.DOUBLE); // 5 - Z + map(Types.BYTE); // 6 - Pitch + map(Types.BYTE); // 7 - Yaw + map(Types.INT); // 8 - Data // Track Entity handler(wrapper -> { - int entityId = wrapper.get(Type.VAR_INT, 0); - byte type = wrapper.get(Type.BYTE, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); + byte type = wrapper.get(Types.BYTE, 0); EntityTypes1_13.EntityType entType = EntityTypes1_13.getTypeFromId(type, true); if (entType != null) { if (entType.is(EntityTypes1_13.EntityType.FALLING_BLOCK)) { - int data = wrapper.get(Type.INT, 0); - wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(data)); + int data = wrapper.get(Types.INT, 0); + wrapper.set(Types.INT, 0, protocol.getMappingData().getNewBlockStateId(data)); } // Register Type ID wrapper.user().getEntityTracker(Protocol1_13To1_13_1.class).addEntity(entityId, entType); @@ -64,18 +65,18 @@ public class EntityPacketRewriter1_13_1 { protocol.registerClientbound(ClientboundPackets1_13.ADD_MOB, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Entity UUID - map(Type.VAR_INT); // 2 - Entity Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Yaw - map(Type.BYTE); // 7 - Pitch - map(Type.BYTE); // 8 - Head Pitch - map(Type.SHORT); // 9 - Velocity X - map(Type.SHORT); // 10 - Velocity Y - map(Type.SHORT); // 11 - Velocity Z + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Entity UUID + map(Types.VAR_INT); // 2 - Entity Type + map(Types.DOUBLE); // 3 - X + map(Types.DOUBLE); // 4 - Y + map(Types.DOUBLE); // 5 - Z + map(Types.BYTE); // 6 - Yaw + map(Types.BYTE); // 7 - Pitch + map(Types.BYTE); // 8 - Head Pitch + map(Types.SHORT); // 9 - Velocity X + map(Types.SHORT); // 10 - Velocity Y + map(Types.SHORT); // 11 - Velocity Z map(Types1_13.METADATA_LIST); // 12 - Metadata handler(metadataRewriter.trackerAndRewriterHandler(Types1_13.METADATA_LIST)); @@ -85,13 +86,13 @@ public class EntityPacketRewriter1_13_1 { protocol.registerClientbound(ClientboundPackets1_13.ADD_PLAYER, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Player UUID - map(Type.DOUBLE); // 2 - X - map(Type.DOUBLE); // 3 - Y - map(Type.DOUBLE); // 4 - Z - map(Type.BYTE); // 5 - Yaw - map(Type.BYTE); // 6 - Pitch + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Player UUID + map(Types.DOUBLE); // 2 - X + map(Types.DOUBLE); // 3 - Y + map(Types.DOUBLE); // 4 - Z + map(Types.BYTE); // 5 - Yaw + map(Types.BYTE); // 6 - Pitch map(Types1_13.METADATA_LIST); // 7 - Metadata handler(metadataRewriter.trackerAndRewriterHandler(Types1_13.METADATA_LIST, EntityTypes1_13.EntityType.PLAYER)); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/ItemPacketRewriter1_13_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/ItemPacketRewriter1_13_1.java index 919a15052..0b520e980 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/ItemPacketRewriter1_13_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/ItemPacketRewriter1_13_1.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.v1_13to1_13_1.rewriter; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13; import com.viaversion.viaversion.protocols.v1_13to1_13_1.Protocol1_13To1_13_1; @@ -30,7 +31,7 @@ import com.viaversion.viaversion.util.Key; public class ItemPacketRewriter1_13_1 extends ItemRewriter { public ItemPacketRewriter1_13_1(Protocol1_13To1_13_1 protocol) { - super(protocol, Type.ITEM1_13, Type.ITEM1_13_SHORT_ARRAY); + super(protocol, Types.ITEM1_13, Types.ITEM1_13_SHORT_ARRAY); } @Override @@ -43,28 +44,28 @@ public class ItemPacketRewriter1_13_1 extends ItemRewriter { - String channel = Key.namespaced(wrapper.get(Type.STRING, 0)); + String channel = Key.namespaced(wrapper.get(Types.STRING, 0)); if (channel.equals("minecraft:trader_list")) { - wrapper.passthrough(Type.INT); // Passthrough Window ID + wrapper.passthrough(Types.INT); // Passthrough Window ID - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + int size = wrapper.passthrough(Types.UNSIGNED_BYTE); for (int i = 0; i < size; i++) { // Input Item - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13)); + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13)); // Output Item - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13)); + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13)); - boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item + boolean secondItem = wrapper.passthrough(Types.BOOLEAN); // Has second item if (secondItem) { // Second Item - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13)); + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13)); } - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses + wrapper.passthrough(Types.BOOLEAN); // Trade disabled + wrapper.passthrough(Types.INT); // Number of tools uses + wrapper.passthrough(Types.INT); // Maximum number of trade uses } } }); @@ -76,20 +77,20 @@ public class ItemPacketRewriter1_13_1 extends ItemRewriter recipeRewriter = new RecipeRewriter<>(protocol) { @Override protected Type itemType() { - return Type.ITEM1_13; + return Types.ITEM1_13; } @Override protected Type itemArrayType() { - return Type.ITEM1_13_ARRAY; + return Types.ITEM1_13_ARRAY; } }; protocol.registerClientbound(ClientboundPackets1_13.UPDATE_RECIPES, wrapper -> { - int size = wrapper.passthrough(Type.VAR_INT); + int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { // First id, then type - wrapper.passthrough(Type.STRING); // Id - String type = Key.stripMinecraftNamespace(wrapper.passthrough(Type.STRING)); + wrapper.passthrough(Types.STRING); // Id + String type = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING)); recipeRewriter.handleRecipeType(wrapper, type); } }); @@ -97,6 +98,6 @@ public class ItemPacketRewriter1_13_1 extends ItemRewriter { - int id = wrapper.get(Type.INT, 0); + int id = wrapper.get(Types.INT, 0); if (id == 2000) { // Smoke - int data = wrapper.get(Type.INT, 1); + int data = wrapper.get(Types.INT, 1); switch (data) { case 1: // North - wrapper.set(Type.INT, 1, 2); // North + wrapper.set(Types.INT, 1, 2); // North break; case 0: // North-West case 3: // West case 6: // South-West - wrapper.set(Type.INT, 1, 4); // West + wrapper.set(Types.INT, 1, 4); // West break; case 2: // North-East case 5: // East case 8: // South-East - wrapper.set(Type.INT, 1, 5); // East + wrapper.set(Types.INT, 1, 5); // East break; case 7: // South - wrapper.set(Type.INT, 1, 3); // South + wrapper.set(Types.INT, 1, 3); // South break; default: // Self and other directions - wrapper.set(Type.INT, 1, 0); // Down + wrapper.set(Types.INT, 1, 0); // Down break; } } else if (id == 1010) { // Play record - wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(wrapper.get(Type.INT, 1))); + wrapper.set(Types.INT, 1, protocol.getMappingData().getNewItemId(wrapper.get(Types.INT, 1))); } else if (id == 2001) { // Block break + block break sound - wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.INT, 1))); + wrapper.set(Types.INT, 1, protocol.getMappingData().getNewBlockStateId(wrapper.get(Types.INT, 1))); } }); } @@ -98,14 +99,14 @@ public class WorldPacketRewriter1_13_1 { protocol.registerClientbound(ClientboundPackets1_13.LOGIN, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Entity ID - map(Type.UNSIGNED_BYTE); // 1 - Gamemode - map(Type.INT); // 2 - Dimension + map(Types.INT); // 0 - Entity ID + map(Types.UNSIGNED_BYTE); // 1 - Gamemode + map(Types.INT); // 2 - Dimension handler(wrapper -> { // Store the player ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 1); + int dimensionId = wrapper.get(Types.INT, 1); clientChunks.setEnvironment(dimensionId); }); } @@ -114,10 +115,10 @@ public class WorldPacketRewriter1_13_1 { protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Dimension ID + map(Types.INT); // 0 - Dimension ID handler(wrapper -> { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 0); + int dimensionId = wrapper.get(Types.INT, 0); clientWorld.setEnvironment(dimensionId); }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_2to1_14_3/Protocol1_14_2To1_14_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_2to1_14_3/Protocol1_14_2To1_14_3.java index edc05aa51..cf33318e8 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_2to1_14_3/Protocol1_14_2To1_14_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_2to1_14_3/Protocol1_14_2To1_14_3.java @@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.v1_14_2to1_14_3; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ServerboundPackets1_14; @@ -31,25 +32,25 @@ public class Protocol1_14_2To1_14_3 extends AbstractProtocol { - wrapper.passthrough(Type.VAR_INT); - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + wrapper.passthrough(Types.VAR_INT); + int size = wrapper.passthrough(Types.UNSIGNED_BYTE); for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.ITEM1_13_2); - wrapper.passthrough(Type.ITEM1_13_2); - if (wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.ITEM1_13_2); + wrapper.passthrough(Types.ITEM1_13_2); + wrapper.passthrough(Types.ITEM1_13_2); + if (wrapper.passthrough(Types.BOOLEAN)) { + wrapper.passthrough(Types.ITEM1_13_2); } - wrapper.passthrough(Type.BOOLEAN); - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.FLOAT); + wrapper.passthrough(Types.BOOLEAN); + wrapper.passthrough(Types.INT); + wrapper.passthrough(Types.INT); + wrapper.passthrough(Types.INT); + wrapper.passthrough(Types.INT); + wrapper.passthrough(Types.FLOAT); } - wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.VAR_INT); - boolean regularVillager = wrapper.passthrough(Type.BOOLEAN); - wrapper.write(Type.BOOLEAN, regularVillager); // new boolean added in pre-1 + wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.VAR_INT); + boolean regularVillager = wrapper.passthrough(Types.BOOLEAN); + wrapper.write(Types.BOOLEAN, regularVillager); // new boolean added in pre-1 }); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_3to1_14_4/Protocol1_14_3To1_14_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_3to1_14_4/Protocol1_14_3To1_14_4.java index afe043a31..0e9ff1a57 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_3to1_14_4/Protocol1_14_3To1_14_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_3to1_14_4/Protocol1_14_3To1_14_4.java @@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.v1_14_3to1_14_4; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ServerboundPackets1_14; import com.viaversion.viaversion.protocols.v1_14_3to1_14_4.packet.ClientboundPackets1_14_4; @@ -32,21 +33,21 @@ public class Protocol1_14_3To1_14_4 extends AbstractProtocol { - wrapper.passthrough(Type.VAR_INT); - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + wrapper.passthrough(Types.VAR_INT); + int size = wrapper.passthrough(Types.UNSIGNED_BYTE); for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.ITEM1_13_2); - wrapper.passthrough(Type.ITEM1_13_2); - if (wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.ITEM1_13_2); + wrapper.passthrough(Types.ITEM1_13_2); + wrapper.passthrough(Types.ITEM1_13_2); + if (wrapper.passthrough(Types.BOOLEAN)) { + wrapper.passthrough(Types.ITEM1_13_2); } - wrapper.passthrough(Type.BOOLEAN); - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.FLOAT); - wrapper.write(Type.INT, 0); // demand value added in pre5 + wrapper.passthrough(Types.BOOLEAN); + wrapper.passthrough(Types.INT); + wrapper.passthrough(Types.INT); + wrapper.passthrough(Types.INT); + wrapper.passthrough(Types.INT); + wrapper.passthrough(Types.FLOAT); + wrapper.write(Types.INT, 0); // demand value added in pre5 } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/Protocol1_14_4To1_15.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/Protocol1_14_4To1_15.java index 5b05610cb..8afe6d95a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/Protocol1_14_4To1_15.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/Protocol1_14_4To1_15.java @@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ServerboundPackets1_14; import com.viaversion.viaversion.protocols.v1_14_3to1_14_4.packet.ClientboundPackets1_14_4; @@ -60,7 +61,7 @@ public class Protocol1_14_4To1_15 extends AbstractProtocol(this).register(ClientboundPackets1_14_4.AWARD_STATS); - registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> itemRewriter.handleItemToServer(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2))); + registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> itemRewriter.handleItemToServer(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2))); tagRewriter.register(ClientboundPackets1_14_4.UPDATE_TAGS, RegistryType.ENTITY); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/metadata/MetadataRewriter1_15To1_14_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/metadata/MetadataRewriter1_15To1_14_4.java index 02bd507bc..78639f3d6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/metadata/MetadataRewriter1_15To1_14_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/metadata/MetadataRewriter1_15To1_14_4.java @@ -33,7 +33,7 @@ public class MetadataRewriter1_15To1_14_4 extends EntityRewriter { int data = meta.value(); meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/EntityPacketRewriter1_15.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/EntityPacketRewriter1_15.java index 83e1e34b7..2c791d5cf 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/EntityPacketRewriter1_15.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/EntityPacketRewriter1_15.java @@ -23,6 +23,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.protocols.v1_14_3to1_14_4.packet.ClientboundPackets1_14_4; import com.viaversion.viaversion.protocols.v1_14_4to1_15.Protocol1_14_4To1_15; @@ -41,37 +42,37 @@ public final class EntityPacketRewriter1_15 { protocol.registerClientbound(ClientboundPackets1_14_4.ADD_MOB, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Entity UUID - map(Type.VAR_INT); // 2 - Entity Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Yaw - map(Type.BYTE); // 7 - Pitch - map(Type.BYTE); // 8 - Head Pitch - map(Type.SHORT); // 9 - Velocity X - map(Type.SHORT); // 10 - Velocity Y - map(Type.SHORT); // 11 - Velocity Z + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Entity UUID + map(Types.VAR_INT); // 2 - Entity Type + map(Types.DOUBLE); // 3 - X + map(Types.DOUBLE); // 4 - Y + map(Types.DOUBLE); // 5 - Z + map(Types.BYTE); // 6 - Yaw + map(Types.BYTE); // 7 - Pitch + map(Types.BYTE); // 8 - Head Pitch + map(Types.SHORT); // 9 - Velocity X + map(Types.SHORT); // 10 - Velocity Y + map(Types.SHORT); // 11 - Velocity Z handler(metadataRewriter.trackerHandler()); - handler(wrapper -> sendMetadataPacket(wrapper, wrapper.get(Type.VAR_INT, 0), metadataRewriter)); + handler(wrapper -> sendMetadataPacket(wrapper, wrapper.get(Types.VAR_INT, 0), metadataRewriter)); } }); protocol.registerClientbound(ClientboundPackets1_14_4.ADD_PLAYER, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Player UUID - map(Type.DOUBLE); // 2 - X - map(Type.DOUBLE); // 3 - Y - map(Type.DOUBLE); // 4 - Z - map(Type.BYTE); // 5 - Yaw - map(Type.BYTE); // 6 - Pitch + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Player UUID + map(Types.DOUBLE); // 2 - X + map(Types.DOUBLE); // 3 - Y + map(Types.DOUBLE); // 4 - Z + map(Types.BYTE); // 5 - Yaw + map(Types.BYTE); // 6 - Pitch handler(wrapper -> { - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); wrapper.user().getEntityTracker(Protocol1_14_4To1_15.class).addEntity(entityId, EntityTypes1_15.PLAYER); sendMetadataPacket(wrapper, entityId, metadataRewriter); @@ -82,26 +83,26 @@ public final class EntityPacketRewriter1_15 { protocol.registerClientbound(ClientboundPackets1_14_4.RESPAWN, new PacketHandlers() { @Override public void register() { - map(Type.INT); - handler(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed + map(Types.INT); + handler(wrapper -> wrapper.write(Types.LONG, 0L)); // Level Seed } }); protocol.registerClientbound(ClientboundPackets1_14_4.LOGIN, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Entity ID - map(Type.UNSIGNED_BYTE); // 1 - Gamemode - map(Type.INT); // 2 - Dimension + map(Types.INT); // 0 - Entity ID + map(Types.UNSIGNED_BYTE); // 1 - Gamemode + map(Types.INT); // 2 - Dimension handler(metadataRewriter.playerTrackerHandler()); - handler(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed + handler(wrapper -> wrapper.write(Types.LONG, 0L)); // Level Seed - map(Type.UNSIGNED_BYTE); // 3 - Max Players - map(Type.STRING); // 4 - Level Type - map(Type.VAR_INT); // 5 - View Distance - map(Type.BOOLEAN); // 6 - Reduce Debug Info + map(Types.UNSIGNED_BYTE); // 3 - Max Players + map(Types.STRING); // 4 - Level Type + map(Types.VAR_INT); // 5 - View Distance + map(Types.BOOLEAN); // 6 - Reduce Debug Info - handler(wrapper -> wrapper.write(Type.BOOLEAN, !Via.getConfig().is1_15InstantRespawn())); // Show Death Screen + handler(wrapper -> wrapper.write(Types.BOOLEAN, !Via.getConfig().is1_15InstantRespawn())); // Show Death Screen } }); @@ -124,7 +125,7 @@ public final class EntityPacketRewriter1_15 { rewriter.handleMetadata(entityId, metadata, wrapper.user()); PacketWrapper metadataPacket = PacketWrapper.create(ClientboundPackets1_15.SET_ENTITY_DATA, wrapper.user()); - metadataPacket.write(Type.VAR_INT, entityId); + metadataPacket.write(Types.VAR_INT, entityId); metadataPacket.write(Types1_14.METADATA_LIST, metadata); metadataPacket.send(Protocol1_14_4To1_15.class); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/ItemPacketRewriter1_15.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/ItemPacketRewriter1_15.java index be466d274..7d1199bf0 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/ItemPacketRewriter1_15.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/ItemPacketRewriter1_15.java @@ -18,6 +18,7 @@ package com.viaversion.viaversion.protocols.v1_14_4to1_15.rewriter; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ServerboundPackets1_14; import com.viaversion.viaversion.protocols.v1_14_3to1_14_4.packet.ClientboundPackets1_14_4; import com.viaversion.viaversion.protocols.v1_14_4to1_15.Protocol1_14_4To1_15; @@ -27,7 +28,7 @@ import com.viaversion.viaversion.rewriter.RecipeRewriter; public class ItemPacketRewriter1_15 extends ItemRewriter { public ItemPacketRewriter1_15(Protocol1_14_4To1_15 protocol) { - super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_SHORT_ARRAY); + super(protocol, Types.ITEM1_13_2, Types.ITEM1_13_2_SHORT_ARRAY); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/WorldPacketRewriter1_15.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/WorldPacketRewriter1_15.java index 712eba740..b085ff6f6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/WorldPacketRewriter1_15.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14_4to1_15/rewriter/WorldPacketRewriter1_15.java @@ -23,6 +23,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_14; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_15; import com.viaversion.viaversion.protocols.v1_14_3to1_14_4.packet.ClientboundPackets1_14_4; @@ -83,23 +84,23 @@ public final class WorldPacketRewriter1_15 { protocol.registerClientbound(ClientboundPackets1_14_4.LEVEL_PARTICLES, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Particle ID - map(Type.BOOLEAN); // 1 - Long Distance - map(Type.FLOAT, Type.DOUBLE); // 2 - X - map(Type.FLOAT, Type.DOUBLE); // 3 - Y - map(Type.FLOAT, Type.DOUBLE); // 4 - Z - map(Type.FLOAT); // 5 - Offset X - map(Type.FLOAT); // 6 - Offset Y - map(Type.FLOAT); // 7 - Offset Z - map(Type.FLOAT); // 8 - Particle Data - map(Type.INT); // 9 - Particle Count + map(Types.INT); // 0 - Particle ID + map(Types.BOOLEAN); // 1 - Long Distance + map(Types.FLOAT, Types.DOUBLE); // 2 - X + map(Types.FLOAT, Types.DOUBLE); // 3 - Y + map(Types.FLOAT, Types.DOUBLE); // 4 - Z + map(Types.FLOAT); // 5 - Offset X + map(Types.FLOAT); // 6 - Offset Y + map(Types.FLOAT); // 7 - Offset Z + map(Types.FLOAT); // 8 - Particle Data + map(Types.INT); // 9 - Particle Count handler(wrapper -> { - int id = wrapper.get(Type.INT, 0); + int id = wrapper.get(Types.INT, 0); if (id == 3 || id == 23) { - int data = wrapper.passthrough(Type.VAR_INT); - wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data)); + int data = wrapper.passthrough(Types.VAR_INT); + wrapper.set(Types.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data)); } else if (id == 32) { - protocol.getItemRewriter().handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); + protocol.getItemRewriter().handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14to1_14_1/rewriter/EntityPacketRewriter1_14_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14to1_14_1/rewriter/EntityPacketRewriter1_14_1.java index 4ade1a8aa..10a55134c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_14to1_14_1/rewriter/EntityPacketRewriter1_14_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_14to1_14_1/rewriter/EntityPacketRewriter1_14_1.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.v1_14to1_14_1.rewriter; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.v1_14to1_14_1.Protocol1_14To1_14_1; @@ -33,18 +34,18 @@ public class EntityPacketRewriter1_14_1 { protocol.registerClientbound(ClientboundPackets1_14.ADD_MOB, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Entity UUID - map(Type.VAR_INT); // 2 - Entity Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Yaw - map(Type.BYTE); // 7 - Pitch - map(Type.BYTE); // 8 - Head Pitch - map(Type.SHORT); // 9 - Velocity X - map(Type.SHORT); // 10 - Velocity Y - map(Type.SHORT); // 11 - Velocity Z + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Entity UUID + map(Types.VAR_INT); // 2 - Entity Type + map(Types.DOUBLE); // 3 - X + map(Types.DOUBLE); // 4 - Y + map(Types.DOUBLE); // 5 - Z + map(Types.BYTE); // 6 - Yaw + map(Types.BYTE); // 7 - Pitch + map(Types.BYTE); // 8 - Head Pitch + map(Types.SHORT); // 9 - Velocity X + map(Types.SHORT); // 10 - Velocity Y + map(Types.SHORT); // 11 - Velocity Z map(Types1_14.METADATA_LIST); // 12 - Metadata handler(metadataRewriter.trackerAndRewriterHandler(Types1_14.METADATA_LIST)); @@ -56,13 +57,13 @@ public class EntityPacketRewriter1_14_1 { protocol.registerClientbound(ClientboundPackets1_14.ADD_PLAYER, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Player UUID - map(Type.DOUBLE); // 2 - X - map(Type.DOUBLE); // 3 - Y - map(Type.DOUBLE); // 4 - Z - map(Type.BYTE); // 5 - Yaw - map(Type.BYTE); // 6 - Pitch + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Player UUID + map(Types.DOUBLE); // 2 - X + map(Types.DOUBLE); // 3 - Y + map(Types.DOUBLE); // 4 - Z + map(Types.BYTE); // 5 - Yaw + map(Types.BYTE); // 6 - Pitch map(Types1_14.METADATA_LIST); // 7 - Metadata handler(metadataRewriter.trackerAndRewriterHandler(Types1_14.METADATA_LIST, EntityTypes1_14.PLAYER)); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java index a26049bf1..c0ff9f3e1 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java @@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol; 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; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_16; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -85,13 +86,13 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol { // Transform string to a uuid - UUID uuid = UUID.fromString(wrapper.read(Type.STRING)); - wrapper.write(Type.UUID, uuid); + UUID uuid = UUID.fromString(wrapper.read(Types.STRING)); + wrapper.write(Types.UUID, uuid); }); // Motd Status - line breaks are no longer allowed for player samples registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), wrapper -> { - String original = wrapper.passthrough(Type.STRING); + String original = wrapper.passthrough(Types.STRING); JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class); JsonObject players = object.getAsJsonObject("players"); if (players == null) return; @@ -120,7 +121,7 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol { - componentRewriter.processText(wrapper.user(), wrapper.get(Type.COMPONENT, 0)); - wrapper.write(Type.UUID, ZERO_UUID); // Sender uuid - always send as 'system' + componentRewriter.processText(wrapper.user(), wrapper.get(Types.COMPONENT, 0)); + wrapper.write(Types.UUID, ZERO_UUID); // Sender uuid - always send as 'system' }); } }); @@ -145,30 +146,30 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol { - wrapper.passthrough(Type.VAR_INT); // Entity Id - int action = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.VAR_INT); // Entity Id + int action = wrapper.passthrough(Types.VAR_INT); if (action == 0 || action == 2) { if (action == 2) { // Location - wrapper.passthrough(Type.FLOAT); - wrapper.passthrough(Type.FLOAT); - wrapper.passthrough(Type.FLOAT); + wrapper.passthrough(Types.FLOAT); + wrapper.passthrough(Types.FLOAT); + wrapper.passthrough(Types.FLOAT); } - wrapper.passthrough(Type.VAR_INT); // Hand + wrapper.passthrough(Types.VAR_INT); // Hand } // New boolean: Whether the client is sneaking/pressing shift - wrapper.read(Type.BOOLEAN); + wrapper.read(Types.BOOLEAN); }); if (Via.getConfig().isIgnoreLong1_16ChannelNames()) { registerServerbound(ServerboundPackets1_16.CUSTOM_PAYLOAD, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // Channel + map(Types.STRING); // Channel handlerSoftFail(wrapper -> { - final String channel = wrapper.get(Type.STRING, 0); + final String channel = wrapper.get(Types.STRING, 0); final String namespacedChannel = Key.namespaced(channel); if (channel.length() > 32) { if (!Via.getConfig().isSuppressConversionWarnings()) { @@ -176,7 +177,7 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol checkedChannels = new ArrayList<>(channels.length); for (String registeredChannel : channels) { if (registeredChannel.length() > 32) { @@ -195,7 +196,7 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol { - wrapper.passthrough(Type.BYTE); // Flags + wrapper.passthrough(Types.BYTE); // Flags final PlayerAbilitiesProvider playerAbilities = Via.getManager().getProviders().get(PlayerAbilitiesProvider.class); - wrapper.write(Type.FLOAT, playerAbilities.getFlyingSpeed(wrapper.user())); - wrapper.write(Type.FLOAT, playerAbilities.getWalkingSpeed(wrapper.user())); + wrapper.write(Types.FLOAT, playerAbilities.getFlyingSpeed(wrapper.user())); + wrapper.write(Types.FLOAT, playerAbilities.getWalkingSpeed(wrapper.user())); }); cancelServerbound(ServerboundPackets1_16.JIGSAW_GENERATE); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/metadata/MetadataRewriter1_16To1_15_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/metadata/MetadataRewriter1_16To1_15_2.java index 0ca0f1ff9..715d43649 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/metadata/MetadataRewriter1_16To1_15_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/metadata/MetadataRewriter1_16To1_15_2.java @@ -34,7 +34,7 @@ public class MetadataRewriter1_16To1_15_2 extends EntityRewriter { int data = meta.value(); meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/EntityPacketRewriter1_16.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/EntityPacketRewriter1_16.java index cdc444ec1..2421c4e72 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/EntityPacketRewriter1_16.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/EntityPacketRewriter1_16.java @@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.api.type.types.version.Types1_16; import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPackets1_15; @@ -51,7 +52,7 @@ public class EntityPacketRewriter1_16 { if (userMap != null) { map = userMap; } - int dimension = wrapper.read(Type.INT); + int dimension = wrapper.read(Types.INT); String dimensionName; String outputName; switch (dimension) { @@ -73,8 +74,8 @@ public class EntityPacketRewriter1_16 { outputName = map.overworld(); } - wrapper.write(Type.STRING, dimensionName); // dimension - wrapper.write(Type.STRING, outputName); // world + wrapper.write(Types.STRING, dimensionName); // dimension + wrapper.write(Types.STRING, outputName); // world }; public static final CompoundTag DIMENSIONS_TAG = new CompoundTag(); private static final String[] WORLD_NAMES = {"minecraft:overworld", "minecraft:the_nether", "minecraft:the_end"}; @@ -161,8 +162,8 @@ public class EntityPacketRewriter1_16 { // Spawn lightning -> Spawn entity protocol.registerClientbound(ClientboundPackets1_15.ADD_GLOBAL_ENTITY, ClientboundPackets1_16.ADD_ENTITY, wrapper -> { - int entityId = wrapper.passthrough(Type.VAR_INT); - byte type = wrapper.read(Type.BYTE); + int entityId = wrapper.passthrough(Types.VAR_INT); + byte type = wrapper.read(Types.BYTE); if (type != 1) { // Cancel if not lightning/invalid id wrapper.cancel(); @@ -171,18 +172,18 @@ public class EntityPacketRewriter1_16 { wrapper.user().getEntityTracker(Protocol1_15_2To1_16.class).addEntity(entityId, EntityTypes1_16.LIGHTNING_BOLT); - wrapper.write(Type.UUID, UUID.randomUUID()); // uuid - wrapper.write(Type.VAR_INT, EntityTypes1_16.LIGHTNING_BOLT.getId()); // entity type + wrapper.write(Types.UUID, UUID.randomUUID()); // uuid + wrapper.write(Types.VAR_INT, EntityTypes1_16.LIGHTNING_BOLT.getId()); // entity type - wrapper.passthrough(Type.DOUBLE); // x - wrapper.passthrough(Type.DOUBLE); // y - wrapper.passthrough(Type.DOUBLE); // z - wrapper.write(Type.BYTE, (byte) 0); // yaw - wrapper.write(Type.BYTE, (byte) 0); // pitch - wrapper.write(Type.INT, 0); // data - wrapper.write(Type.SHORT, (short) 0); // velocity - wrapper.write(Type.SHORT, (short) 0); // velocity - wrapper.write(Type.SHORT, (short) 0); // velocity + wrapper.passthrough(Types.DOUBLE); // x + wrapper.passthrough(Types.DOUBLE); // y + wrapper.passthrough(Types.DOUBLE); // z + wrapper.write(Types.BYTE, (byte) 0); // yaw + wrapper.write(Types.BYTE, (byte) 0); // pitch + wrapper.write(Types.INT, 0); // data + wrapper.write(Types.SHORT, (short) 0); // velocity + wrapper.write(Types.SHORT, (short) 0); // velocity + wrapper.write(Types.SHORT, (short) 0); // velocity }); metadataRewriter.registerTrackerWithData(ClientboundPackets1_15.ADD_ENTITY, EntityTypes1_16.FALLING_BLOCK); @@ -195,15 +196,15 @@ public class EntityPacketRewriter1_16 { @Override public void register() { handler(DIMENSION_HANDLER); - map(Type.LONG); // Seed - map(Type.UNSIGNED_BYTE); // Gamemode + map(Types.LONG); // Seed + map(Types.UNSIGNED_BYTE); // Gamemode handler(wrapper -> { - wrapper.write(Type.BYTE, (byte) -1); // Previous gamemode, set to none + wrapper.write(Types.BYTE, (byte) -1); // Previous gamemode, set to none - String levelType = wrapper.read(Type.STRING); - wrapper.write(Type.BOOLEAN, false); // debug - wrapper.write(Type.BOOLEAN, levelType.equals("flat")); - wrapper.write(Type.BOOLEAN, true); // keep all playerdata + String levelType = wrapper.read(Types.STRING); + wrapper.write(Types.BOOLEAN, false); // debug + wrapper.write(Types.BOOLEAN, levelType.equals("flat")); + wrapper.write(Types.BOOLEAN, true); // keep all playerdata }); } }); @@ -211,37 +212,37 @@ public class EntityPacketRewriter1_16 { protocol.registerClientbound(ClientboundPackets1_15.LOGIN, new PacketHandlers() { @Override public void register() { - map(Type.INT); // Entity ID - map(Type.UNSIGNED_BYTE); // Gamemode + map(Types.INT); // Entity ID + map(Types.UNSIGNED_BYTE); // Gamemode handler(wrapper -> { - wrapper.write(Type.BYTE, (byte) -1); // Previous gamemode, set to none - wrapper.write(Type.STRING_ARRAY, Arrays.copyOf(WORLD_NAMES, WORLD_NAMES.length)); // World list - only used for command completion - wrapper.write(Type.NAMED_COMPOUND_TAG, DIMENSIONS_TAG.copy()); // Dimension registry + wrapper.write(Types.BYTE, (byte) -1); // Previous gamemode, set to none + wrapper.write(Types.STRING_ARRAY, Arrays.copyOf(WORLD_NAMES, WORLD_NAMES.length)); // World list - only used for command completion + wrapper.write(Types.NAMED_COMPOUND_TAG, DIMENSIONS_TAG.copy()); // Dimension registry }); handler(DIMENSION_HANDLER); // Dimension - map(Type.LONG); // Seed - map(Type.UNSIGNED_BYTE); // Max players + map(Types.LONG); // Seed + map(Types.UNSIGNED_BYTE); // Max players handler(wrapper -> { - wrapper.user().getEntityTracker(Protocol1_15_2To1_16.class).addEntity(wrapper.get(Type.INT, 0), EntityTypes1_16.PLAYER); + wrapper.user().getEntityTracker(Protocol1_15_2To1_16.class).addEntity(wrapper.get(Types.INT, 0), EntityTypes1_16.PLAYER); - final String type = wrapper.read(Type.STRING);// level type - wrapper.passthrough(Type.VAR_INT); // View distance - wrapper.passthrough(Type.BOOLEAN); // Reduced debug info - wrapper.passthrough(Type.BOOLEAN); // Show death screen + final String type = wrapper.read(Types.STRING);// level type + wrapper.passthrough(Types.VAR_INT); // View distance + wrapper.passthrough(Types.BOOLEAN); // Reduced debug info + wrapper.passthrough(Types.BOOLEAN); // Show death screen - wrapper.write(Type.BOOLEAN, false); // Debug - wrapper.write(Type.BOOLEAN, type.equals("flat")); + wrapper.write(Types.BOOLEAN, false); // Debug + wrapper.write(Types.BOOLEAN, type.equals("flat")); }); } }); protocol.registerClientbound(ClientboundPackets1_15.UPDATE_ATTRIBUTES, wrapper -> { - wrapper.passthrough(Type.VAR_INT); - int size = wrapper.passthrough(Type.INT); + wrapper.passthrough(Types.VAR_INT); + int size = wrapper.passthrough(Types.INT); int actualSize = size; for (int i = 0; i < size; i++) { // Attributes have been renamed and are now namespaced identifiers - String key = wrapper.read(Type.STRING); + String key = wrapper.read(Types.STRING); String attributeIdentifier = AttributeMappings.attributeIdentifierMappings().get(key); if (attributeIdentifier == null) { attributeIdentifier = Key.namespaced(key); @@ -250,29 +251,29 @@ public class EntityPacketRewriter1_16 { Via.getPlatform().getLogger().warning("Invalid attribute: " + key); } actualSize--; - wrapper.read(Type.DOUBLE); - int modifierSize = wrapper.read(Type.VAR_INT); + wrapper.read(Types.DOUBLE); + int modifierSize = wrapper.read(Types.VAR_INT); for (int j = 0; j < modifierSize; j++) { - wrapper.read(Type.UUID); - wrapper.read(Type.DOUBLE); - wrapper.read(Type.BYTE); + wrapper.read(Types.UUID); + wrapper.read(Types.DOUBLE); + wrapper.read(Types.BYTE); } continue; } } - wrapper.write(Type.STRING, attributeIdentifier); + wrapper.write(Types.STRING, attributeIdentifier); - wrapper.passthrough(Type.DOUBLE); - int modifierSize = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.DOUBLE); + int modifierSize = wrapper.passthrough(Types.VAR_INT); for (int j = 0; j < modifierSize; j++) { - wrapper.passthrough(Type.UUID); - wrapper.passthrough(Type.DOUBLE); - wrapper.passthrough(Type.BYTE); + wrapper.passthrough(Types.UUID); + wrapper.passthrough(Types.DOUBLE); + wrapper.passthrough(Types.BYTE); } } if (size != actualSize) { - wrapper.set(Type.INT, 0, actualSize); + wrapper.set(Types.INT, 0, actualSize); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/ItemPacketRewriter1_16.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/ItemPacketRewriter1_16.java index a398d5505..a210dee9b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/ItemPacketRewriter1_16.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/ItemPacketRewriter1_16.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.v1_15_2to1_16.Protocol1_15_2To1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.data.AttributeMappings; @@ -43,7 +44,7 @@ import java.util.UUID; public class ItemPacketRewriter1_16 extends ItemRewriter { public ItemPacketRewriter1_16(Protocol1_15_2To1_16 protocol) { - super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_SHORT_ARRAY); + super(protocol, Types.ITEM1_13_2, Types.ITEM1_13_2_SHORT_ARRAY); } @Override @@ -51,25 +52,25 @@ public class ItemPacketRewriter1_16 extends ItemRewriter { PacketWrapper clearPacket = wrapper.create(ClientboundPackets1_16.CONTAINER_SET_SLOT); - clearPacket.write(Type.UNSIGNED_BYTE, (short) -1); - clearPacket.write(Type.SHORT, (short) -1); - clearPacket.write(Type.ITEM1_13_2, null); + clearPacket.write(Types.UNSIGNED_BYTE, (short) -1); + clearPacket.write(Types.SHORT, (short) -1); + clearPacket.write(Types.ITEM1_13_2, null); clearPacket.send(Protocol1_15_2To1_16.class); }; protocol.registerClientbound(ClientboundPackets1_15.OPEN_SCREEN, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // Window Id - map(Type.VAR_INT); // Window Type - map(Type.COMPONENT); // Window Title + map(Types.VAR_INT); // Window Id + map(Types.VAR_INT); // Window Type + map(Types.COMPONENT); // Window Title handler(cursorRemapper); handler(wrapper -> { InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class); - int windowType = wrapper.get(Type.VAR_INT, 1); + int windowType = wrapper.get(Types.VAR_INT, 1); if (windowType >= 20) { // smithing added with id 20 - wrapper.set(Type.VAR_INT, 1, ++windowType); + wrapper.set(Types.VAR_INT, 1, ++windowType); } inventoryTracker.setInventoryOpen(true); }); @@ -90,16 +91,16 @@ public class ItemPacketRewriter1_16 extends ItemRewriter { - short property = wrapper.get(Type.SHORT, 0); + short property = wrapper.get(Types.SHORT, 0); if (property >= 4 && property <= 6) { // Enchantment id - short enchantmentId = wrapper.get(Type.SHORT, 1); + short enchantmentId = wrapper.get(Types.SHORT, 1); if (enchantmentId >= 11) { // soul_speed added with id 11 - wrapper.set(Type.SHORT, 1, ++enchantmentId); + wrapper.set(Types.SHORT, 1, ++enchantmentId); } } }); @@ -115,12 +116,12 @@ public class ItemPacketRewriter1_16 extends ItemRewriter { - int slot = wrapper.read(Type.VAR_INT); - wrapper.write(Type.BYTE, (byte) slot); - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); + int slot = wrapper.read(Types.VAR_INT); + wrapper.write(Types.BYTE, (byte) slot); + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); }); } }); @@ -135,9 +136,9 @@ public class ItemPacketRewriter1_16 extends ItemRewriter handleItemToServer(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2))); + protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2))); - registerSpawnParticle(ClientboundPackets1_15.LEVEL_PARTICLES, Type.DOUBLE); + registerSpawnParticle(ClientboundPackets1_15.LEVEL_PARTICLES, Types.DOUBLE); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/WorldPacketRewriter1_16.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/WorldPacketRewriter1_16.java index b0bcea4d5..53f784d83 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/WorldPacketRewriter1_16.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/WorldPacketRewriter1_16.java @@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_15; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16; import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPackets1_15; @@ -54,9 +55,9 @@ public class WorldPacketRewriter1_16 { protocol.registerClientbound(ClientboundPackets1_15.LIGHT_UPDATE, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // x - map(Type.VAR_INT); // y - handler(wrapper -> wrapper.write(Type.BOOLEAN, true)); // Take neighbour's light into account as well + map(Types.VAR_INT); // x + map(Types.VAR_INT); // y + handler(wrapper -> wrapper.write(Types.BOOLEAN, true)); // Take neighbour's light into account as well } }); @@ -94,9 +95,9 @@ public class WorldPacketRewriter1_16 { }); protocol.registerClientbound(ClientboundPackets1_15.BLOCK_ENTITY_DATA, wrapper -> { - wrapper.passthrough(Type.POSITION1_14); // Position - wrapper.passthrough(Type.UNSIGNED_BYTE); // Action - CompoundTag tag = wrapper.passthrough(Type.NAMED_COMPOUND_TAG); + wrapper.passthrough(Types.BLOCK_POSITION1_14); // Position + wrapper.passthrough(Types.UNSIGNED_BYTE); // Action + CompoundTag tag = wrapper.passthrough(Types.NAMED_COMPOUND_TAG); handleBlockEntity(protocol, wrapper.user(), tag); }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/Protocol1_16_1To1_16_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/Protocol1_16_1To1_16_2.java index a3c29c168..83e725acb 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/Protocol1_16_1To1_16_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/Protocol1_16_1To1_16_2.java @@ -22,6 +22,7 @@ import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ServerboundPackets1_16; @@ -64,23 +65,23 @@ public class Protocol1_16_1To1_16_2 extends AbstractProtocol { - int recipeType = wrapper.read(Type.VAR_INT); - boolean open = wrapper.read(Type.BOOLEAN); - boolean filter = wrapper.read(Type.BOOLEAN); - wrapper.write(Type.VAR_INT, 1); // Settings - wrapper.write(Type.BOOLEAN, recipeType == 0 && open); // Crafting - wrapper.write(Type.BOOLEAN, filter); - wrapper.write(Type.BOOLEAN, recipeType == 1 && open); // Furnace - wrapper.write(Type.BOOLEAN, filter); - wrapper.write(Type.BOOLEAN, recipeType == 2 && open); // Blast Furnace - wrapper.write(Type.BOOLEAN, filter); - wrapper.write(Type.BOOLEAN, recipeType == 3 && open); // Smoker - wrapper.write(Type.BOOLEAN, filter); + int recipeType = wrapper.read(Types.VAR_INT); + boolean open = wrapper.read(Types.BOOLEAN); + boolean filter = wrapper.read(Types.BOOLEAN); + wrapper.write(Types.VAR_INT, 1); // Settings + wrapper.write(Types.BOOLEAN, recipeType == 0 && open); // Crafting + wrapper.write(Types.BOOLEAN, filter); + wrapper.write(Types.BOOLEAN, recipeType == 1 && open); // Furnace + wrapper.write(Types.BOOLEAN, filter); + wrapper.write(Types.BOOLEAN, recipeType == 2 && open); // Blast Furnace + wrapper.write(Types.BOOLEAN, filter); + wrapper.write(Types.BOOLEAN, recipeType == 3 && open); // Smoker + wrapper.write(Types.BOOLEAN, filter); }); registerServerbound(ServerboundPackets1_16_2.RECIPE_BOOK_SEEN_RECIPE, ServerboundPackets1_16.RECIPE_BOOK_UPDATE, wrapper -> { - String recipe = wrapper.read(Type.STRING); - wrapper.write(Type.VAR_INT, 0); // Shown - wrapper.write(Type.STRING, recipe); + String recipe = wrapper.read(Types.STRING); + wrapper.write(Types.VAR_INT, 0); // Shown + wrapper.write(Types.STRING, recipe); }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/metadata/MetadataRewriter1_16_2To1_16_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/metadata/MetadataRewriter1_16_2To1_16_1.java index c5b897e5e..cd2c99db3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/metadata/MetadataRewriter1_16_2To1_16_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/metadata/MetadataRewriter1_16_2To1_16_1.java @@ -32,7 +32,7 @@ public class MetadataRewriter1_16_2To1_16_1 extends EntityRewriter { int data = meta.value(); meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/EntityPacketRewriter1_16_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/EntityPacketRewriter1_16_2.java index 985283fc0..223fca082 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/EntityPacketRewriter1_16_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/EntityPacketRewriter1_16_2.java @@ -22,6 +22,7 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.Protocol1_16_1To1_16_2; @@ -40,34 +41,34 @@ public class EntityPacketRewriter1_16_2 { protocol.registerClientbound(ClientboundPackets1_16.LOGIN, new PacketHandlers() { @Override public void register() { - map(Type.INT); // Entity ID + map(Types.INT); // Entity ID handler(wrapper -> { - short gamemode = wrapper.read(Type.UNSIGNED_BYTE); - wrapper.write(Type.BOOLEAN, (gamemode & 0x08) != 0); // Hardcore - wrapper.write(Type.BYTE, (byte) (gamemode & ~0x08)); // Gamemode + short gamemode = wrapper.read(Types.UNSIGNED_BYTE); + wrapper.write(Types.BOOLEAN, (gamemode & 0x08) != 0); // Hardcore + wrapper.write(Types.BYTE, (byte) (gamemode & ~0x08)); // Gamemode }); - map(Type.BYTE); // Previous Gamemode - map(Type.STRING_ARRAY); // World List + map(Types.BYTE); // Previous Gamemode + map(Types.STRING_ARRAY); // World List handler(wrapper -> { // Throw away the old dimension registry, extra conversion would be too hard of a hit - wrapper.read(Type.NAMED_COMPOUND_TAG); - wrapper.write(Type.NAMED_COMPOUND_TAG, protocol.getMappingData().getDimensionRegistry()); + wrapper.read(Types.NAMED_COMPOUND_TAG); + wrapper.write(Types.NAMED_COMPOUND_TAG, protocol.getMappingData().getDimensionRegistry()); // Instead of the dimension's resource key, it now just wants the data directly - String dimensionType = wrapper.read(Type.STRING); - wrapper.write(Type.NAMED_COMPOUND_TAG, getDimensionData(dimensionType)); + String dimensionType = wrapper.read(Types.STRING); + wrapper.write(Types.NAMED_COMPOUND_TAG, getDimensionData(dimensionType)); }); - map(Type.STRING); // Dimension - map(Type.LONG); // Seed - map(Type.UNSIGNED_BYTE, Type.VAR_INT); // Max players + map(Types.STRING); // Dimension + map(Types.LONG); // Seed + map(Types.UNSIGNED_BYTE, Types.VAR_INT); // Max players // ... handler(metadataRewriter.playerTrackerHandler()); } }); protocol.registerClientbound(ClientboundPackets1_16.RESPAWN, wrapper -> { - String dimensionType = wrapper.read(Type.STRING); - wrapper.write(Type.NAMED_COMPOUND_TAG, getDimensionData(dimensionType)); + String dimensionType = wrapper.read(Types.STRING); + wrapper.write(Types.NAMED_COMPOUND_TAG, getDimensionData(dimensionType)); }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/ItemPacketRewriter1_16_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/ItemPacketRewriter1_16_2.java index 46641e2ff..bf1a4e243 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/ItemPacketRewriter1_16_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/ItemPacketRewriter1_16_2.java @@ -18,6 +18,7 @@ package com.viaversion.viaversion.protocols.v1_16_1to1_16_2.rewriter; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.Protocol1_16_1To1_16_2; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ServerboundPackets1_16_2; @@ -27,7 +28,7 @@ import com.viaversion.viaversion.rewriter.RecipeRewriter; public class ItemPacketRewriter1_16_2 extends ItemRewriter { public ItemPacketRewriter1_16_2(Protocol1_16_1To1_16_2 protocol) { - super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_SHORT_ARRAY); + super(protocol, Types.ITEM1_13_2, Types.ITEM1_13_2_SHORT_ARRAY); } @Override @@ -40,24 +41,24 @@ public class ItemPacketRewriter1_16_2 extends ItemRewriter { - wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.BOOLEAN); // Open - wrapper.passthrough(Type.BOOLEAN); // Filter - wrapper.passthrough(Type.BOOLEAN); // Furnace - wrapper.passthrough(Type.BOOLEAN); // Filter furnace + wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.BOOLEAN); // Open + wrapper.passthrough(Types.BOOLEAN); // Filter + wrapper.passthrough(Types.BOOLEAN); // Furnace + wrapper.passthrough(Types.BOOLEAN); // Filter furnace // Blast furnace / smoker - wrapper.write(Type.BOOLEAN, false); - wrapper.write(Type.BOOLEAN, false); - wrapper.write(Type.BOOLEAN, false); - wrapper.write(Type.BOOLEAN, false); + wrapper.write(Types.BOOLEAN, false); + wrapper.write(Types.BOOLEAN, false); + wrapper.write(Types.BOOLEAN, false); + wrapper.write(Types.BOOLEAN, false); }); new RecipeRewriter<>(protocol).register(ClientboundPackets1_16.UPDATE_RECIPES); registerClickWindow(ServerboundPackets1_16_2.CONTAINER_CLICK); registerCreativeInvAction(ServerboundPackets1_16_2.SET_CREATIVE_MODE_SLOT); - protocol.registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2))); + protocol.registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2))); - registerSpawnParticle(ClientboundPackets1_16.LEVEL_PARTICLES, Type.DOUBLE); + registerSpawnParticle(ClientboundPackets1_16.LEVEL_PARTICLES, Types.DOUBLE); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/WorldPacketRewriter1_16_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/WorldPacketRewriter1_16_2.java index 46aa10319..a4f6bcfef 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/WorldPacketRewriter1_16_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/WorldPacketRewriter1_16_2.java @@ -25,6 +25,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2; import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ClientboundPackets1_16; @@ -66,15 +67,15 @@ public class WorldPacketRewriter1_16_2 { protocol.registerClientbound(ClientboundPackets1_16.CHUNK_BLOCKS_UPDATE, ClientboundPackets1_16_2.SECTION_BLOCKS_UPDATE, wrapper -> { wrapper.cancel(); - int chunkX = wrapper.read(Type.INT); - int chunkZ = wrapper.read(Type.INT); + int chunkX = wrapper.read(Types.INT); + int chunkZ = wrapper.read(Types.INT); long chunkPosition = 0; chunkPosition |= (chunkX & 0x3FFFFFL) << 42; chunkPosition |= (chunkZ & 0x3FFFFFL) << 20; List[] sectionRecords = new List[16]; - BlockChangeRecord[] blockChangeRecord = wrapper.read(Type.BLOCK_CHANGE_RECORD_ARRAY); + BlockChangeRecord[] blockChangeRecord = wrapper.read(Types.BLOCK_CHANGE_ARRAY); for (BlockChangeRecord record : blockChangeRecord) { int chunkY = record.getY() >> 4; List list = sectionRecords[chunkY]; @@ -93,9 +94,9 @@ public class WorldPacketRewriter1_16_2 { if (sectionRecord == null) continue; PacketWrapper newPacket = wrapper.create(ClientboundPackets1_16_2.SECTION_BLOCKS_UPDATE); - newPacket.write(Type.LONG, chunkPosition | (chunkY & 0xFFFFFL)); - newPacket.write(Type.BOOLEAN, false); // Ignore light updates - newPacket.write(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY, sectionRecord.toArray(EMPTY_RECORDS)); + newPacket.write(Types.LONG, chunkPosition | (chunkY & 0xFFFFFL)); + newPacket.write(Types.BOOLEAN, false); // Ignore light updates + newPacket.write(Types.VAR_LONG_BLOCK_CHANGE_ARRAY, sectionRecord.toArray(EMPTY_RECORDS)); newPacket.send(Protocol1_16_1To1_16_2.class); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_3to1_16_4/Protocol1_16_3To1_16_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_3to1_16_4/Protocol1_16_3To1_16_4.java index 3d2f4a977..a6e8b77e3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_3to1_16_4/Protocol1_16_3To1_16_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_3to1_16_4/Protocol1_16_3To1_16_4.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.v1_16_3to1_16_4; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ClientboundPackets1_16_2; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ServerboundPackets1_16_2; @@ -34,11 +35,11 @@ public class Protocol1_16_3To1_16_4 extends AbstractProtocol { - int slot = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT, slot == 40 ? 1 : 0); // 40 = offhand, everything else assumed as mainhand + int slot = wrapper.read(Types.VAR_INT); + wrapper.write(Types.VAR_INT, slot == 40 ? 1 : 0); // 40 = offhand, everything else assumed as mainhand }); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17.java index afeb0192b..c9d3d392d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17.java @@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_17; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -64,10 +65,10 @@ public final class Protocol1_16_4To1_17 extends AbstractProtocol { // Tags are now generically written with resource location - 5 different Vanilla types - wrapper.write(Type.VAR_INT, 5); + wrapper.write(Types.VAR_INT, 5); for (RegistryType type : RegistryType.getValues()) { // Prefix with resource location - wrapper.write(Type.STRING, type.resourceLocation()); + wrapper.write(Types.STRING, type.resourceLocation()); // Id conversion tagRewriter.handle(wrapper, tagRewriter.getRewriter(type), tagRewriter.getNewTags(type)); @@ -79,11 +80,11 @@ public final class Protocol1_16_4To1_17 extends AbstractProtocol { - wrapper.passthrough(Type.STRING); - wrapper.passthrough(Type.STRING); - wrapper.write(Type.BOOLEAN, Via.getConfig().isForcedUse1_17ResourcePack()); // Required - wrapper.write(Type.OPTIONAL_COMPONENT, Via.getConfig().get1_17ResourcePackPrompt()); // Prompt message + wrapper.passthrough(Types.STRING); + wrapper.passthrough(Types.STRING); + wrapper.write(Types.BOOLEAN, Via.getConfig().isForcedUse1_17ResourcePack()); // Required + wrapper.write(Types.OPTIONAL_COMPONENT, Via.getConfig().get1_17ResourcePackPrompt()); // Prompt message }); registerClientbound(ClientboundPackets1_16_2.MAP_ITEM_DATA, wrapper -> { - wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.BYTE); - wrapper.read(Type.BOOLEAN); // Tracking position removed - wrapper.passthrough(Type.BOOLEAN); + wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.BYTE); + wrapper.read(Types.BOOLEAN); // Tracking position removed + wrapper.passthrough(Types.BOOLEAN); - int size = wrapper.read(Type.VAR_INT); + int size = wrapper.read(Types.VAR_INT); // Write whether markers exist or not if (size != 0) { - wrapper.write(Type.BOOLEAN, true); - wrapper.write(Type.VAR_INT, size); + wrapper.write(Types.BOOLEAN, true); + wrapper.write(Types.VAR_INT, size); } else { - wrapper.write(Type.BOOLEAN, false); + wrapper.write(Types.BOOLEAN, false); } }); registerClientbound(ClientboundPackets1_16_2.SET_TITLES, null, wrapper -> { // Title packet actions have been split into individual packets (the content hasn't changed) - int type = wrapper.read(Type.VAR_INT); + int type = wrapper.read(Types.VAR_INT); ClientboundPacketType packetType; switch (type) { case 0 -> packetType = ClientboundPackets1_17.SET_TITLE_TEXT; @@ -127,11 +128,11 @@ public final class Protocol1_16_4To1_17 extends AbstractProtocol packetType = ClientboundPackets1_17.SET_TITLES_ANIMATION; case 4 -> { packetType = ClientboundPackets1_17.CLEAR_TITLES; - wrapper.write(Type.BOOLEAN, false); // Reset times + wrapper.write(Types.BOOLEAN, false); // Reset times } case 5 -> { packetType = ClientboundPackets1_17.CLEAR_TITLES; - wrapper.write(Type.BOOLEAN, true); // Reset times + wrapper.write(Types.BOOLEAN, true); // Reset times } default -> throw new IllegalArgumentException("Invalid title type received: " + type); } @@ -142,32 +143,32 @@ public final class Protocol1_16_4To1_17 extends AbstractProtocol wrapper.write(Type.VAR_INT, wrapper.read(Type.INT))); // Collection length is now a var int + map(Types.FLOAT); // X + map(Types.FLOAT); // Y + map(Types.FLOAT); // Z + map(Types.FLOAT); // Strength + handler(wrapper -> wrapper.write(Types.VAR_INT, wrapper.read(Types.INT))); // Collection length is now a var int } }); registerClientbound(ClientboundPackets1_16_2.SET_DEFAULT_SPAWN_POSITION, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_14); - handler(wrapper -> wrapper.write(Type.FLOAT, 0f)); // Angle (which Mojang just forgot to write to the buffer, lol) + map(Types.BLOCK_POSITION1_14); + handler(wrapper -> wrapper.write(Types.FLOAT, 0f)); // Angle (which Mojang just forgot to write to the buffer, lol) } }); registerServerbound(ServerboundPackets1_17.CLIENT_INFORMATION, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // Locale - map(Type.BYTE); // View distance - map(Type.VAR_INT); // Chat mode - map(Type.BOOLEAN); // Chat colors - map(Type.UNSIGNED_BYTE); // Chat flags - map(Type.VAR_INT); // Main hand - read(Type.BOOLEAN); // Text filtering + map(Types.STRING); // Locale + map(Types.BYTE); // View distance + map(Types.VAR_INT); // Chat mode + map(Types.BOOLEAN); // Chat colors + map(Types.UNSIGNED_BYTE); // Chat flags + map(Types.VAR_INT); // Main hand + read(Types.BOOLEAN); // Text filtering } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/EntityPacketRewriter1_17.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/EntityPacketRewriter1_17.java index 5415cf0d5..fb3328e9f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/EntityPacketRewriter1_17.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/EntityPacketRewriter1_17.java @@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_16; import com.viaversion.viaversion.api.type.types.version.Types1_17; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ClientboundPackets1_16_2; @@ -49,7 +50,7 @@ public final class EntityPacketRewriter1_17 extends EntityRewriter { - int[] entityIds = wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE); + int[] entityIds = wrapper.read(Types.VAR_INT_ARRAY_PRIMITIVE); wrapper.cancel(); EntityTracker entityTracker = wrapper.user().getEntityTracker(Protocol1_16_4To1_17.class); @@ -58,7 +59,7 @@ public final class EntityPacketRewriter1_17 extends EntityRewriter { // Add new dimension fields - CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); + CompoundTag registry = wrapper.get(Types.NAMED_COMPOUND_TAG, 0); ListTag dimensions = TagUtil.getRegistryEntries(registry, "dimension_type"); for (CompoundTag dimension : dimensions) { CompoundTag dimensionCompound = dimension.getCompoundTag("element"); addNewDimensionData(dimensionCompound); } - CompoundTag currentDimensionTag = wrapper.get(Type.NAMED_COMPOUND_TAG, 1); + CompoundTag currentDimensionTag = wrapper.get(Types.NAMED_COMPOUND_TAG, 1); addNewDimensionData(currentDimensionTag); }); handler(playerTrackerHandler()); @@ -90,35 +91,35 @@ public final class EntityPacketRewriter1_17 extends EntityRewriter { - CompoundTag dimensionData = wrapper.passthrough(Type.NAMED_COMPOUND_TAG); + CompoundTag dimensionData = wrapper.passthrough(Types.NAMED_COMPOUND_TAG); addNewDimensionData(dimensionData); }); protocol.registerClientbound(ClientboundPackets1_16_2.UPDATE_ATTRIBUTES, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // Entity id - handler(wrapper -> wrapper.write(Type.VAR_INT, wrapper.read(Type.INT))); // Collection length is now a var int + map(Types.VAR_INT); // Entity id + handler(wrapper -> wrapper.write(Types.VAR_INT, wrapper.read(Types.INT))); // Collection length is now a var int } }); protocol.registerClientbound(ClientboundPackets1_16_2.PLAYER_POSITION, new PacketHandlers() { @Override public void register() { - map(Type.DOUBLE); - map(Type.DOUBLE); - map(Type.DOUBLE); - map(Type.FLOAT); - map(Type.FLOAT); - map(Type.BYTE); - map(Type.VAR_INT); - create(Type.BOOLEAN, false); // Dismount vehicle + map(Types.DOUBLE); + map(Types.DOUBLE); + map(Types.DOUBLE); + map(Types.FLOAT); + map(Types.FLOAT); + map(Types.BYTE); + map(Types.VAR_INT); + create(Types.BOOLEAN, false); // Dismount vehicle } }); protocol.registerClientbound(ClientboundPackets1_16_2.PLAYER_COMBAT, null, wrapper -> { // Combat packet actions have been split into individual packets (the content hasn't changed) - int type = wrapper.read(Type.VAR_INT); + int type = wrapper.read(Types.VAR_INT); ClientboundPacketType packetType = switch (type) { case 0 -> ClientboundPackets1_17.PLAYER_COMBAT_ENTER; case 1 -> ClientboundPackets1_17.PLAYER_COMBAT_END; @@ -143,7 +144,7 @@ public final class EntityPacketRewriter1_17 extends EntityRewriter { public ItemPacketRewriter1_17(Protocol1_16_4To1_17 protocol) { - super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_SHORT_ARRAY); + super(protocol, Types.ITEM1_13_2, Types.ITEM1_13_2_SHORT_ARRAY); } @Override @@ -47,34 +48,34 @@ public final class ItemPacketRewriter1_17 extends ItemRewriter(protocol).register(ClientboundPackets1_16_2.UPDATE_RECIPES); registerCreativeInvAction(ServerboundPackets1_17.SET_CREATIVE_MODE_SLOT); - protocol.registerServerbound(ServerboundPackets1_17.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2))); + protocol.registerServerbound(ServerboundPackets1_17.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2))); protocol.registerServerbound(ServerboundPackets1_17.CONTAINER_CLICK, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); // Window Id - map(Type.SHORT); // Slot - map(Type.BYTE); // Button - handler(wrapper -> wrapper.write(Type.SHORT, (short) 0)); // Action id - doesn't matter, as the sent out confirmation packet will be cancelled - map(Type.VAR_INT); // Action + map(Types.UNSIGNED_BYTE); // Window Id + map(Types.SHORT); // Slot + map(Types.BYTE); // Button + handler(wrapper -> wrapper.write(Types.SHORT, (short) 0)); // Action id - doesn't matter, as the sent out confirmation packet will be cancelled + map(Types.VAR_INT); // Action handler(wrapper -> { // Affected items - throw them away! - int length = wrapper.read(Type.VAR_INT); + int length = wrapper.read(Types.VAR_INT); for (int i = 0; i < length; i++) { - wrapper.read(Type.SHORT); // Slot - wrapper.read(Type.ITEM1_13_2); + wrapper.read(Types.SHORT); // Slot + wrapper.read(Types.ITEM1_13_2); } // 1.17 clients send the then carried item, but 1.16 expects the clicked one - Item item = wrapper.read(Type.ITEM1_13_2); - int action = wrapper.get(Type.VAR_INT, 0); + Item item = wrapper.read(Types.ITEM1_13_2); + int action = wrapper.get(Types.VAR_INT, 0); if (action == 5 || action == 1) { // Quick craft (= dragging / mouse movement while clicking on an empty slot) // OR Quick move (= shift click to move a whole stack to the other inventory) @@ -85,22 +86,22 @@ public final class ItemPacketRewriter1_17 extends ItemRewriter { - short inventoryId = wrapper.read(Type.UNSIGNED_BYTE); - short confirmationId = wrapper.read(Type.SHORT); - boolean accepted = wrapper.read(Type.BOOLEAN); + short inventoryId = wrapper.read(Types.UNSIGNED_BYTE); + short confirmationId = wrapper.read(Types.SHORT); + boolean accepted = wrapper.read(Types.BOOLEAN); if (!accepted) { // Use the new ping packet to replace the removed acknowledgement, extra bit for fast dismissal int id = (1 << 30) | (inventoryId << 16) | (confirmationId & 0xFFFF); wrapper.user().get(InventoryAcknowledgements.class).addId(id); PacketWrapper pingPacket = wrapper.create(ClientboundPackets1_17.PING); - pingPacket.write(Type.INT, id); + pingPacket.write(Types.INT, id); pingPacket.send(Protocol1_16_4To1_17.class); } @@ -109,16 +110,16 @@ public final class ItemPacketRewriter1_17 extends ItemRewriter { - int id = wrapper.read(Type.INT); + int id = wrapper.read(Types.INT); // Check extra bit for fast dismissal if ((id & (1 << 30)) != 0 && wrapper.user().get(InventoryAcknowledgements.class).removeId(id)) { // Decode our requested inventory acknowledgement short inventoryId = (short) ((id >> 16) & 0xFF); short confirmationId = (short) (id & 0xFFFF); PacketWrapper packet = wrapper.create(ServerboundPackets1_16_2.CONTAINER_ACK); - packet.write(Type.UNSIGNED_BYTE, inventoryId); - packet.write(Type.SHORT, confirmationId); - packet.write(Type.BOOLEAN, true); // Accept + packet.write(Types.UNSIGNED_BYTE, inventoryId); + packet.write(Types.SHORT, confirmationId); + packet.write(Types.BOOLEAN, true); // Accept packet.sendToServer(Protocol1_16_4To1_17.class); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/WorldPacketRewriter1_17.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/WorldPacketRewriter1_17.java index eb513000a..d1566e396 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/WorldPacketRewriter1_17.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/WorldPacketRewriter1_17.java @@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ClientboundPackets1_16_2; @@ -49,7 +50,7 @@ public final class WorldPacketRewriter1_17 { protocol.registerClientbound(ClientboundPackets1_16_2.SET_BORDER, null, wrapper -> { // Border packet actions have been split into individual packets (the content hasn't changed) - int type = wrapper.read(Type.VAR_INT); + int type = wrapper.read(Types.VAR_INT); ClientboundPacketType packetType = switch (type) { case 0 -> ClientboundPackets1_17.SET_BORDER_SIZE; case 1 -> ClientboundPackets1_17.SET_BORDER_LERP_SIZE; @@ -66,17 +67,17 @@ public final class WorldPacketRewriter1_17 { protocol.registerClientbound(ClientboundPackets1_16_2.LIGHT_UPDATE, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // x - map(Type.VAR_INT); // y - map(Type.BOOLEAN); // trust edges + map(Types.VAR_INT); // x + map(Types.VAR_INT); // y + map(Types.BOOLEAN); // trust edges handler(wrapper -> { - int skyLightMask = wrapper.read(Type.VAR_INT); - int blockLightMask = wrapper.read(Type.VAR_INT); + int skyLightMask = wrapper.read(Types.VAR_INT); + int blockLightMask = wrapper.read(Types.VAR_INT); // Now all written as a representation of BitSets - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(skyLightMask)); // Sky light mask - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(blockLightMask)); // Block light mask - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(wrapper.read(Type.VAR_INT))); // Empty sky light mask - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(wrapper.read(Type.VAR_INT))); // Empty block light mask + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(skyLightMask)); // Sky light mask + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(blockLightMask)); // Block light mask + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(wrapper.read(Types.VAR_INT))); // Empty sky light mask + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(wrapper.read(Types.VAR_INT))); // Empty block light mask writeLightArrays(wrapper, skyLightMask); writeLightArrays(wrapper, blockLightMask); @@ -87,14 +88,14 @@ public final class WorldPacketRewriter1_17 { List light = new ArrayList<>(); for (int i = 0; i < 18; i++) { if (isSet(bitMask, i)) { - light.add(wrapper.read(Type.BYTE_ARRAY_PRIMITIVE)); + light.add(wrapper.read(Types.BYTE_ARRAY_PRIMITIVE)); } } // Now needs the length of the bytearray-array - wrapper.write(Type.VAR_INT, light.size()); + wrapper.write(Types.VAR_INT, light.size()); for (byte[] bytes : light) { - wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, bytes); + wrapper.write(Types.BYTE_ARRAY_PRIMITIVE, bytes); } } @@ -152,8 +153,8 @@ public final class WorldPacketRewriter1_17 { if (section == null) continue; PacketWrapper blockChangePacket = wrapper.create(ClientboundPackets1_17.SECTION_BLOCKS_UPDATE); - blockChangePacket.write(Type.LONG, chunkPosition | (chunkY & 0xFFFFFL)); - blockChangePacket.write(Type.BOOLEAN, true); // Suppress light updates + blockChangePacket.write(Types.LONG, chunkPosition | (chunkY & 0xFFFFFL)); + blockChangePacket.write(Types.BOOLEAN, true); // Suppress light updates //TODO this can be optimized BlockChangeRecord[] blockChangeRecords = new BlockChangeRecord[4096]; @@ -168,7 +169,7 @@ public final class WorldPacketRewriter1_17 { } } - blockChangePacket.write(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY, blockChangeRecords); + blockChangePacket.write(Types.VAR_LONG_BLOCK_CHANGE_ARRAY, blockChangeRecords); blockChangePacket.send(Protocol1_16_4To1_17.class); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/Protocol1_17_1To1_18.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/Protocol1_17_1To1_18.java index 2233765b8..21d4418db 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/Protocol1_17_1To1_18.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/Protocol1_17_1To1_18.java @@ -25,6 +25,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_18; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -72,14 +73,14 @@ public final class Protocol1_17_1To1_18 extends AbstractProtocol { - int chunkRadius = wrapper.passthrough(Type.VAR_INT); - wrapper.write(Type.VAR_INT, chunkRadius); // Simulation distance + int chunkRadius = wrapper.passthrough(Types.VAR_INT); + wrapper.write(Types.VAR_INT, chunkRadius); // Simulation distance }); handler(worldDataTrackerHandler(1)); handler(biomeSizeTracker()); @@ -65,10 +66,10 @@ public final class EntityPacketRewriter1_18 extends EntityRewriter { - final String world = wrapper.get(Type.STRING, 0); + final String world = wrapper.get(Types.STRING, 0); final EntityTracker tracker = tracker(wrapper.user()); if (!world.equals(tracker.currentWorld())) { wrapper.user().get(ChunkLightStorage.class).clear(); @@ -86,9 +87,9 @@ public final class EntityPacketRewriter1_18 extends EntityRewriter { public ItemPacketRewriter1_18(Protocol1_17_1To1_18 protocol) { - super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_ARRAY); + super(protocol, Types.ITEM1_13_2, Types.ITEM1_13_2_ARRAY); } @Override @@ -44,14 +45,14 @@ public final class ItemPacketRewriter1_18 extends ItemRewriter { - int id = wrapper.get(Type.INT, 0); - int data = wrapper.get(Type.INT, 1); + int id = wrapper.get(Types.INT, 0); + int data = wrapper.get(Types.INT, 1); if (id == 1010) { // Play record - wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(data)); + wrapper.set(Types.INT, 1, protocol.getMappingData().getNewItemId(data)); } }); } @@ -60,38 +61,38 @@ public final class ItemPacketRewriter1_18 extends ItemRewriter { - int id = wrapper.get(Type.INT, 0); + int id = wrapper.get(Types.INT, 0); if (id == 2) { // Barrier - wrapper.set(Type.INT, 0, 3); // Block marker - wrapper.write(Type.VAR_INT, 7754); + wrapper.set(Types.INT, 0, 3); // Block marker + wrapper.write(Types.VAR_INT, 7754); return; } else if (id == 3) { // Light block - wrapper.write(Type.VAR_INT, 7786); + wrapper.write(Types.VAR_INT, 7786); return; } ParticleMappings mappings = protocol.getMappingData().getParticleMappings(); if (mappings.isBlockParticle(id)) { - int data = wrapper.passthrough(Type.VAR_INT); - wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data)); + int data = wrapper.passthrough(Types.VAR_INT); + wrapper.set(Types.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data)); } else if (mappings.isItemParticle(id)) { - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); } int newId = protocol.getMappingData().getNewParticleId(id); if (newId != id) { - wrapper.set(Type.INT, 0, newId); + wrapper.set(Types.INT, 0, newId); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/rewriter/WorldPacketRewriter1_18.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/rewriter/WorldPacketRewriter1_18.java index 9dfc6953b..9c21f9903 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/rewriter/WorldPacketRewriter1_18.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/rewriter/WorldPacketRewriter1_18.java @@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPaletteImpl; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18; import com.viaversion.viaversion.protocols.v1_17_1to1_18.Protocol1_17_1To1_18; @@ -52,20 +53,20 @@ public final class WorldPacketRewriter1_18 { protocol.registerClientbound(ClientboundPackets1_17_1.BLOCK_ENTITY_DATA, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_14); + map(Types.BLOCK_POSITION1_14); handler(wrapper -> { - final short id = wrapper.read(Type.UNSIGNED_BYTE); + final short id = wrapper.read(Types.UNSIGNED_BYTE); final int newId = BlockEntityIds.newId(id); - wrapper.write(Type.VAR_INT, newId); + wrapper.write(Types.VAR_INT, newId); - handleSpawners(newId, wrapper.passthrough(Type.NAMED_COMPOUND_TAG)); + handleSpawners(newId, wrapper.passthrough(Types.NAMED_COMPOUND_TAG)); }); } }); protocol.registerClientbound(ClientboundPackets1_17_1.LIGHT_UPDATE, wrapper -> { - final int chunkX = wrapper.passthrough(Type.VAR_INT); - final int chunkZ = wrapper.passthrough(Type.VAR_INT); + final int chunkX = wrapper.passthrough(Types.VAR_INT); + final int chunkZ = wrapper.passthrough(Types.VAR_INT); if (wrapper.user().get(ChunkLightStorage.class).isLoaded(chunkX, chunkZ)) { if (!Via.getConfig().cache1_17Light()) { @@ -78,22 +79,22 @@ public final class WorldPacketRewriter1_18 { wrapper.cancel(); } - final boolean trustEdges = wrapper.passthrough(Type.BOOLEAN); - final long[] skyLightMask = wrapper.passthrough(Type.LONG_ARRAY_PRIMITIVE); - final long[] blockLightMask = wrapper.passthrough(Type.LONG_ARRAY_PRIMITIVE); - final long[] emptySkyLightMask = wrapper.passthrough(Type.LONG_ARRAY_PRIMITIVE); - final long[] emptyBlockLightMask = wrapper.passthrough(Type.LONG_ARRAY_PRIMITIVE); + final boolean trustEdges = wrapper.passthrough(Types.BOOLEAN); + final long[] skyLightMask = wrapper.passthrough(Types.LONG_ARRAY_PRIMITIVE); + final long[] blockLightMask = wrapper.passthrough(Types.LONG_ARRAY_PRIMITIVE); + final long[] emptySkyLightMask = wrapper.passthrough(Types.LONG_ARRAY_PRIMITIVE); + final long[] emptyBlockLightMask = wrapper.passthrough(Types.LONG_ARRAY_PRIMITIVE); - final int skyLightLenght = wrapper.passthrough(Type.VAR_INT); + final int skyLightLenght = wrapper.passthrough(Types.VAR_INT); final byte[][] skyLight = new byte[skyLightLenght][]; for (int i = 0; i < skyLightLenght; i++) { - skyLight[i] = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); + skyLight[i] = wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE); } - final int blockLightLength = wrapper.passthrough(Type.VAR_INT); + final int blockLightLength = wrapper.passthrough(Types.VAR_INT); final byte[][] blockLight = new byte[blockLightLength][]; for (int i = 0; i < blockLightLength; i++) { - blockLight[i] = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); + blockLight[i] = wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE); } final ChunkLightStorage lightStorage = wrapper.user().get(ChunkLightStorage.class); @@ -171,33 +172,33 @@ public final class WorldPacketRewriter1_18 { final BitSet emptyLightMask = new BitSet(); emptyLightMask.set(0, tracker.currentWorldSectionHeight() + 2); - wrapper.write(Type.BOOLEAN, false); - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, new long[0]); - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, new long[0]); - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, emptyLightMask.toLongArray()); - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, emptyLightMask.toLongArray()); - wrapper.write(Type.VAR_INT, 0); - wrapper.write(Type.VAR_INT, 0); + wrapper.write(Types.BOOLEAN, false); + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, new long[0]); + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, new long[0]); + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, emptyLightMask.toLongArray()); + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, emptyLightMask.toLongArray()); + wrapper.write(Types.VAR_INT, 0); + wrapper.write(Types.VAR_INT, 0); } else { - wrapper.write(Type.BOOLEAN, light.trustEdges()); - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, light.skyLightMask()); - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, light.blockLightMask()); - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, light.emptySkyLightMask()); - wrapper.write(Type.LONG_ARRAY_PRIMITIVE, light.emptyBlockLightMask()); - wrapper.write(Type.VAR_INT, light.skyLight().length); + wrapper.write(Types.BOOLEAN, light.trustEdges()); + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, light.skyLightMask()); + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, light.blockLightMask()); + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, light.emptySkyLightMask()); + wrapper.write(Types.LONG_ARRAY_PRIMITIVE, light.emptyBlockLightMask()); + wrapper.write(Types.VAR_INT, light.skyLight().length); for (final byte[] skyLight : light.skyLight()) { - wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, skyLight); + wrapper.write(Types.BYTE_ARRAY_PRIMITIVE, skyLight); } - wrapper.write(Type.VAR_INT, light.blockLight().length); + wrapper.write(Types.VAR_INT, light.blockLight().length); for (final byte[] blockLight : light.blockLight()) { - wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, blockLight); + wrapper.write(Types.BYTE_ARRAY_PRIMITIVE, blockLight); } } }); protocol.registerClientbound(ClientboundPackets1_17_1.FORGET_LEVEL_CHUNK, wrapper -> { - final int chunkX = wrapper.passthrough(Type.INT); - final int chunkZ = wrapper.passthrough(Type.INT); + final int chunkX = wrapper.passthrough(Types.INT); + final int chunkZ = wrapper.passthrough(Types.INT); wrapper.user().get(ChunkLightStorage.class).clear(chunkX, chunkZ); }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_17to1_17_1/Protocol1_17To1_17_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_17to1_17_1/Protocol1_17To1_17_1.java index c5e46bb80..6ef8063cb 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_17to1_17_1/Protocol1_17To1_17_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_17to1_17_1/Protocol1_17To1_17_1.java @@ -25,6 +25,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.StringType; import com.viaversion.viaversion.protocols.v1_16_4to1_17.packet.ClientboundPackets1_17; import com.viaversion.viaversion.protocols.v1_16_4to1_17.packet.ServerboundPackets1_17; @@ -43,29 +44,29 @@ public final class Protocol1_17To1_17_1 extends AbstractProtocol { // Aaaaand back to an array again! - int entityId = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{entityId}); + int entityId = wrapper.read(Types.VAR_INT); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{entityId}); }); registerClientbound(ClientboundPackets1_17.CONTAINER_SET_SLOT, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); // Container id - create(Type.VAR_INT, 0); // Add arbitrary state id + map(Types.UNSIGNED_BYTE); // Container id + create(Types.VAR_INT, 0); // Add arbitrary state id } }); registerClientbound(ClientboundPackets1_17.CONTAINER_SET_CONTENT, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); // Container id - create(Type.VAR_INT, 0); // Add arbitrary state id + map(Types.UNSIGNED_BYTE); // Container id + create(Types.VAR_INT, 0); // Add arbitrary state id handler(wrapper -> { // Length encoded as var int now - wrapper.write(Type.ITEM1_13_2_ARRAY, wrapper.read(Type.ITEM1_13_2_SHORT_ARRAY)); + wrapper.write(Types.ITEM1_13_2_ARRAY, wrapper.read(Types.ITEM1_13_2_SHORT_ARRAY)); // Carried item - should work like this - wrapper.write(Type.ITEM1_13_2, null); + wrapper.write(Types.ITEM1_13_2, null); }); } }); @@ -73,8 +74,8 @@ public final class Protocol1_17To1_17_1 extends AbstractProtocol pagesTag = new ListTag<>(StringTag.class); for (int i = 0; i < pages; i++) { String page = wrapper.read(PAGE_STRING_TYPE); @@ -102,7 +103,7 @@ public final class Protocol1_17To1_17_1 extends AbstractProtocol wrapper.write(Type.LONG, randomLong())); // Seed + map(Types.VAR_INT); // Sound id + map(Types.VAR_INT); // Source + map(Types.INT); // X + map(Types.INT); // Y + map(Types.INT); // Z + map(Types.FLOAT); // Volume + map(Types.FLOAT); // Pitch + handler(wrapper -> wrapper.write(Types.LONG, randomLong())); // Seed handler(soundRewriter.getSoundHandler()); } }); registerClientbound(ClientboundPackets1_18.SOUND_ENTITY, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // Sound id - map(Type.VAR_INT); // Source - map(Type.VAR_INT); // Entity id - map(Type.FLOAT); // Volume - map(Type.FLOAT); // Pitch - handler(wrapper -> wrapper.write(Type.LONG, randomLong())); // Seed + map(Types.VAR_INT); // Sound id + map(Types.VAR_INT); // Source + map(Types.VAR_INT); // Entity id + map(Types.FLOAT); // Volume + map(Types.FLOAT); // Pitch + handler(wrapper -> wrapper.write(Types.LONG, randomLong())); // Seed handler(soundRewriter.getSoundHandler()); } }); registerClientbound(ClientboundPackets1_18.CUSTOM_SOUND, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // Sound name - map(Type.VAR_INT); // Source - map(Type.INT); // X - map(Type.INT); // Y - map(Type.INT); // Z - map(Type.FLOAT); // Volume - map(Type.FLOAT); // Pitch - handler(wrapper -> wrapper.write(Type.LONG, randomLong())); // Seed + map(Types.STRING); // Sound name + map(Types.VAR_INT); // Source + map(Types.INT); // X + map(Types.INT); // Y + map(Types.INT); // Z + map(Types.FLOAT); // Volume + map(Types.FLOAT); // Pitch + handler(wrapper -> wrapper.write(Types.LONG, randomLong())); // Seed } }); new StatisticsRewriter<>(this).register(ClientboundPackets1_18.AWARD_STATS); - final PacketHandler singleNullTextComponentMapper = wrapper -> wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT))); + final PacketHandler singleNullTextComponentMapper = wrapper -> wrapper.write(Types.COMPONENT, mapTextComponentIfNull(wrapper.read(Types.COMPONENT))); registerClientbound(ClientboundPackets1_18.SET_TITLE_TEXT, singleNullTextComponentMapper); registerClientbound(ClientboundPackets1_18.SET_SUBTITLE_TEXT, singleNullTextComponentMapper); registerClientbound(ClientboundPackets1_18.SET_ACTION_BAR_TEXT, singleNullTextComponentMapper); registerClientbound(ClientboundPackets1_18.SET_OBJECTIVE, wrapper -> { - wrapper.passthrough(Type.STRING); // Objective Name - byte action = wrapper.passthrough(Type.BYTE); // Mode + wrapper.passthrough(Types.STRING); // Objective Name + byte action = wrapper.passthrough(Types.BYTE); // Mode if (action == 0 || action == 2) { - wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT))); // Display Name + wrapper.write(Types.COMPONENT, mapTextComponentIfNull(wrapper.read(Types.COMPONENT))); // Display Name } }); registerClientbound(ClientboundPackets1_18.SET_PLAYER_TEAM, wrapper -> { - wrapper.passthrough(Type.STRING); // Team Name - byte action = wrapper.passthrough(Type.BYTE); // Mode + wrapper.passthrough(Types.STRING); // Team Name + byte action = wrapper.passthrough(Types.BYTE); // Mode if (action == 0 || action == 2) { - wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT))); // Display Name - wrapper.passthrough(Type.BYTE); // Flags - wrapper.passthrough(Type.STRING); // Name Tag Visibility - wrapper.passthrough(Type.STRING); // Collision rule - wrapper.passthrough(Type.VAR_INT); // Color - wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT))); // Prefix - wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT))); // Suffix + wrapper.write(Types.COMPONENT, mapTextComponentIfNull(wrapper.read(Types.COMPONENT))); // Display Name + wrapper.passthrough(Types.BYTE); // Flags + wrapper.passthrough(Types.STRING); // Name Tag Visibility + wrapper.passthrough(Types.STRING); // Collision rule + wrapper.passthrough(Types.VAR_INT); // Color + wrapper.write(Types.COMPONENT, mapTextComponentIfNull(wrapper.read(Types.COMPONENT))); // Prefix + wrapper.write(Types.COMPONENT, mapTextComponentIfNull(wrapper.read(Types.COMPONENT))); // Suffix } }); final CommandRewriter commandRewriter = new CommandRewriter<>(this); registerClientbound(ClientboundPackets1_18.COMMANDS, wrapper -> { - final int size = wrapper.passthrough(Type.VAR_INT); + final int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { - final byte flags = wrapper.passthrough(Type.BYTE); - wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); // Children indices + final byte flags = wrapper.passthrough(Types.BYTE); + wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE); // Children indices if ((flags & 0x08) != 0) { - wrapper.passthrough(Type.VAR_INT); // Redirect node index + wrapper.passthrough(Types.VAR_INT); // Redirect node index } final int nodeType = flags & 0x03; if (nodeType == 1 || nodeType == 2) { // Literal/argument node - wrapper.passthrough(Type.STRING); // Name + wrapper.passthrough(Types.STRING); // Name } if (nodeType == 2) { // Argument node - final String argumentType = wrapper.read(Type.STRING); + final String argumentType = wrapper.read(Types.STRING); final int argumentTypeId = MAPPINGS.getArgumentTypeMappings().mappedId(argumentType); if (argumentTypeId == -1) { Via.getPlatform().getLogger().warning("Unknown command argument type: " + argumentType); } - wrapper.write(Type.VAR_INT, argumentTypeId); + wrapper.write(Types.VAR_INT, argumentTypeId); commandRewriter.handleArgument(wrapper, argumentType); if ((flags & 0x10) != 0) { - wrapper.passthrough(Type.STRING); // Suggestion type + wrapper.passthrough(Types.STRING); // Suggestion type } } } - wrapper.passthrough(Type.VAR_INT); // Root node index + wrapper.passthrough(Types.VAR_INT); // Root node index }); // Make every message a system message, including player ones; we don't want to analyze and remove player names from the original component registerClientbound(ClientboundPackets1_18.CHAT, ClientboundPackets1_19.SYSTEM_CHAT, new PacketHandlers() { @Override public void register() { - map(Type.COMPONENT); // Message + map(Types.COMPONENT); // Message handler(wrapper -> { - final int type = wrapper.read(Type.BYTE); - wrapper.write(Type.VAR_INT, type == 0 ? 1 : type); + final int type = wrapper.read(Types.BYTE); + wrapper.write(Types.VAR_INT, type == 0 ? 1 : type); }); - read(Type.UUID); // Sender + read(Types.UUID); // Sender } }); registerServerbound(ServerboundPackets1_19.CHAT, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // Message - read(Type.LONG); // Timestamp - read(Type.LONG); // Salt - read(Type.BYTE_ARRAY_PRIMITIVE); // Signature - read(Type.BOOLEAN); // Signed preview + map(Types.STRING); // Message + read(Types.LONG); // Timestamp + read(Types.LONG); // Salt + read(Types.BYTE_ARRAY_PRIMITIVE); // Signature + read(Types.BOOLEAN); // Signed preview } }); registerServerbound(ServerboundPackets1_19.CHAT_COMMAND, ServerboundPackets1_17.CHAT, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // Command - read(Type.LONG); // Timestamp - read(Type.LONG); // Salt + map(Types.STRING); // Command + read(Types.LONG); // Timestamp + read(Types.LONG); // Salt handler(wrapper -> { - final String command = wrapper.get(Type.STRING, 0); - wrapper.set(Type.STRING, 0, "/" + command); + final String command = wrapper.get(Types.STRING, 0); + wrapper.set(Types.STRING, 0, "/" + command); - final int signatures = wrapper.read(Type.VAR_INT); + final int signatures = wrapper.read(Types.VAR_INT); for (int i = 0; i < signatures; i++) { - wrapper.read(Type.STRING); // Argument name - wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); // Signature + wrapper.read(Types.STRING); // Argument name + wrapper.read(Types.BYTE_ARRAY_PRIMITIVE); // Signature } }); - read(Type.BOOLEAN); // Signed preview + read(Types.BOOLEAN); // Signed preview } }); cancelServerbound(ServerboundPackets1_19.CHAT_PREVIEW); @@ -235,19 +236,19 @@ public final class Protocol1_18_2To1_19 extends AbstractProtocol { - final byte[] publicKey = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); - final byte[] nonce = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); + final byte[] publicKey = wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE); + final byte[] nonce = wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE); wrapper.user().put(new NonceStorage(CipherUtil.encryptNonce(publicKey, nonce))); }); } @@ -256,19 +257,19 @@ public final class Protocol1_18_2To1_19 extends AbstractProtocol { - if (wrapper.read(Type.BOOLEAN)) { + if (wrapper.read(Types.BOOLEAN)) { // Nonce, just pass it through - wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); + wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE); } else { // 🧂 final NonceStorage nonceStorage = wrapper.user().remove(NonceStorage.class); @@ -276,9 +277,9 @@ public final class Protocol1_18_2To1_19 extends AbstractProtocol { - final byte yaw = wrapper.get(Type.BYTE, 1); - wrapper.write(Type.BYTE, yaw); // Head yaw + final byte yaw = wrapper.get(Types.BYTE, 1); + wrapper.write(Types.BYTE, yaw); // Head yaw }); - map(Type.INT, Type.VAR_INT); // Data + map(Types.INT, Types.VAR_INT); // Data handler(trackerHandler()); handler(wrapper -> { - final int entityId = wrapper.get(Type.VAR_INT, 0); + final int entityId = wrapper.get(Types.VAR_INT, 0); final EntityType entityType = tracker(wrapper.user()).entityType(entityId); if (entityType == EntityTypes1_19.FALLING_BLOCK) { - wrapper.set(Type.VAR_INT, 2, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.VAR_INT, 2))); + wrapper.set(Types.VAR_INT, 2, protocol.getMappingData().getNewBlockStateId(wrapper.get(Types.VAR_INT, 2))); } }); } @@ -93,31 +94,31 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter { - wrapper.write(Type.VAR_INT, EntityTypes1_19.PAINTING.getId()); + wrapper.write(Types.VAR_INT, EntityTypes1_19.PAINTING.getId()); - final int motive = wrapper.read(Type.VAR_INT); - final Position blockPosition = wrapper.read(Type.POSITION1_14); - final byte direction = wrapper.read(Type.BYTE); - wrapper.write(Type.DOUBLE, blockPosition.x() + 0.5d); - wrapper.write(Type.DOUBLE, blockPosition.y() + 0.5d); - wrapper.write(Type.DOUBLE, blockPosition.z() + 0.5d); - wrapper.write(Type.BYTE, (byte) 0); // Pitch - wrapper.write(Type.BYTE, (byte) 0); // Yaw - wrapper.write(Type.BYTE, (byte) 0); // Head yaw - wrapper.write(Type.VAR_INT, to3dId(direction)); // Data - wrapper.write(Type.SHORT, (short) 0); // Velocity x - wrapper.write(Type.SHORT, (short) 0); // Velocity y - wrapper.write(Type.SHORT, (short) 0); // Velocity z + final int motive = wrapper.read(Types.VAR_INT); + final Position blockPosition = wrapper.read(Types.BLOCK_POSITION1_14); + final byte direction = wrapper.read(Types.BYTE); + wrapper.write(Types.DOUBLE, blockPosition.x() + 0.5d); + wrapper.write(Types.DOUBLE, blockPosition.y() + 0.5d); + wrapper.write(Types.DOUBLE, blockPosition.z() + 0.5d); + wrapper.write(Types.BYTE, (byte) 0); // Pitch + wrapper.write(Types.BYTE, (byte) 0); // Yaw + wrapper.write(Types.BYTE, (byte) 0); // Head yaw + wrapper.write(Types.VAR_INT, to3dId(direction)); // Data + wrapper.write(Types.SHORT, (short) 0); // Velocity x + wrapper.write(Types.SHORT, (short) 0); // Velocity y + wrapper.write(Types.SHORT, (short) 0); // Velocity z wrapper.send(Protocol1_18_2To1_19.class); wrapper.cancel(); // Send motive in metadata final PacketWrapper metaPacket = wrapper.create(ClientboundPackets1_19.SET_ENTITY_DATA); - metaPacket.write(Type.VAR_INT, wrapper.get(Type.VAR_INT, 0)); // Entity id + metaPacket.write(Types.VAR_INT, wrapper.get(Types.VAR_INT, 0)); // Entity id final List metadata = new ArrayList<>(); metadata.add(new Metadata(8, Types1_19.META_TYPES.paintingVariantType, protocol.getMappingData().getPaintingMappings().getNewIdOrDefault(motive, 0))); metaPacket.write(Types1_19.METADATA_LIST, metadata); @@ -129,24 +130,24 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter { // Change order - final byte yaw = wrapper.read(Type.BYTE); - final byte pitch = wrapper.read(Type.BYTE); - wrapper.write(Type.BYTE, pitch); - wrapper.write(Type.BYTE, yaw); + final byte yaw = wrapper.read(Types.BYTE); + final byte pitch = wrapper.read(Types.BYTE); + wrapper.write(Types.BYTE, pitch); + wrapper.write(Types.BYTE, yaw); }); - map(Type.BYTE); // Head yaw - create(Type.VAR_INT, 0); // Data - map(Type.SHORT); // Velocity x - map(Type.SHORT); // Velocity y - map(Type.SHORT); // Velocity z + map(Types.BYTE); // Head yaw + create(Types.VAR_INT, 0); // Data + map(Types.SHORT); // Velocity x + map(Types.SHORT); // Velocity y + map(Types.SHORT); // Velocity z handler(trackerHandler()); } }); @@ -154,26 +155,26 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter { - final CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); + final CompoundTag tag = wrapper.get(Types.NAMED_COMPOUND_TAG, 0); // Add necessary chat types tag.put("minecraft:chat_type", protocol.getMappingData().chatRegistry()); @@ -196,23 +197,23 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter { // Disable the chat preview final PacketWrapper displayPreviewPacket = wrapper.create(ClientboundPackets1_19.SET_DISPLAY_CHAT_PREVIEW); - displayPreviewPacket.write(Type.BOOLEAN, false); + displayPreviewPacket.write(Types.BOOLEAN, false); displayPreviewPacket.scheduleSend(Protocol1_18_2To1_19.class); }); } @@ -221,52 +222,52 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter writeDimensionKey(wrapper, wrapper.user().get(DimensionRegistryStorage.class))); - map(Type.STRING); // World - map(Type.LONG); // Seed - map(Type.UNSIGNED_BYTE); // Gamemode - map(Type.BYTE); // Previous gamemode - map(Type.BOOLEAN); // Debug - map(Type.BOOLEAN); // Flat - map(Type.BOOLEAN); // Keep player data - create(Type.OPTIONAL_GLOBAL_POSITION, null); // Last death location + map(Types.STRING); // World + map(Types.LONG); // Seed + map(Types.UNSIGNED_BYTE); // Gamemode + map(Types.BYTE); // Previous gamemode + map(Types.BOOLEAN); // Debug + map(Types.BOOLEAN); // Flat + map(Types.BOOLEAN); // Keep player data + create(Types.OPTIONAL_GLOBAL_POSITION, null); // Last death location handler(worldDataTrackerHandlerByKey()); } }); protocol.registerClientbound(ClientboundPackets1_18.PLAYER_INFO, wrapper -> { - final int action = wrapper.passthrough(Type.VAR_INT); - final int entries = wrapper.passthrough(Type.VAR_INT); + final int action = wrapper.passthrough(Types.VAR_INT); + final int entries = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < entries; i++) { - wrapper.passthrough(Type.UUID); // UUID + wrapper.passthrough(Types.UUID); // UUID if (action == 0) { // Add player - wrapper.passthrough(Type.STRING); // Player Name + wrapper.passthrough(Types.STRING); // Player Name - final int properties = wrapper.passthrough(Type.VAR_INT); + final int properties = wrapper.passthrough(Types.VAR_INT); for (int j = 0; j < properties; j++) { - wrapper.passthrough(Type.STRING); // Name - wrapper.passthrough(Type.STRING); // Value - wrapper.passthrough(Type.OPTIONAL_STRING); // Signature + wrapper.passthrough(Types.STRING); // Name + wrapper.passthrough(Types.STRING); // Value + wrapper.passthrough(Types.OPTIONAL_STRING); // Signature } - wrapper.passthrough(Type.VAR_INT); // Gamemode - wrapper.passthrough(Type.VAR_INT); // Ping - final JsonElement displayName = wrapper.read(Type.OPTIONAL_COMPONENT); // Display name + wrapper.passthrough(Types.VAR_INT); // Gamemode + wrapper.passthrough(Types.VAR_INT); // Ping + final JsonElement displayName = wrapper.read(Types.OPTIONAL_COMPONENT); // Display name if (!Protocol1_18_2To1_19.isTextComponentNull(displayName)) { - wrapper.write(Type.OPTIONAL_COMPONENT, displayName); + wrapper.write(Types.OPTIONAL_COMPONENT, displayName); } else { - wrapper.write(Type.OPTIONAL_COMPONENT, null); + wrapper.write(Types.OPTIONAL_COMPONENT, null); } // No public profile signature - wrapper.write(Type.OPTIONAL_PROFILE_KEY, null); + wrapper.write(Types.OPTIONAL_PROFILE_KEY, null); } else if (action == 1 || action == 2) { // Update gamemode/update latency - wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.VAR_INT); } else if (action == 3) { // Update display name - final JsonElement displayName = wrapper.read(Type.OPTIONAL_COMPONENT); // Display name + final JsonElement displayName = wrapper.read(Types.OPTIONAL_COMPONENT); // Display name if (!Protocol1_18_2To1_19.isTextComponentNull(displayName)) { - wrapper.write(Type.OPTIONAL_COMPONENT, displayName); + wrapper.write(Types.OPTIONAL_COMPONENT, displayName); } else { - wrapper.write(Type.OPTIONAL_COMPONENT, null); + wrapper.write(Types.OPTIONAL_COMPONENT, null); } } } @@ -275,7 +276,7 @@ public final class EntityPacketRewriter1_19 extends EntityRewritergetArgument(0).getValue()); if (resourceLocation.equals("entity")) { // Add Y offset - particle.getArguments().add(2, new Particle.ParticleData<>(Type.FLOAT, 0F)); + particle.getArguments().add(2, new Particle.ParticleData<>(Types.FLOAT, 0F)); } } rewriteParticle(event.user(), particle); }); - registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.blockStateType, null); + registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.optionalBlockStateType, null); filter().type(EntityTypes1_19.ABSTRACT_MINECART).index(11).handler((event, meta) -> { // Convert to new block id diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/ItemPacketRewriter1_19.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/ItemPacketRewriter1_19.java index dfa1e4b00..8b0ef010e 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/ItemPacketRewriter1_19.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/ItemPacketRewriter1_19.java @@ -22,6 +22,7 @@ import com.viaversion.viaversion.api.data.ParticleMappings; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_17_1to1_18.packet.ClientboundPackets1_18; import com.viaversion.viaversion.protocols.v1_18_2to1_19.Protocol1_18_2To1_19; import com.viaversion.viaversion.protocols.v1_18_2to1_19.packet.ServerboundPackets1_19; @@ -33,7 +34,7 @@ import com.viaversion.viaversion.util.Key; public final class ItemPacketRewriter1_19 extends ItemRewriter { public ItemPacketRewriter1_19(Protocol1_18_2To1_19 protocol) { - super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_ARRAY); + super(protocol, Types.ITEM1_13_2, Types.ITEM1_13_2_ARRAY); } @Override @@ -46,30 +47,30 @@ public final class ItemPacketRewriter1_19 extends ItemRewriter { - final int id = wrapper.get(Type.VAR_INT, 0); + final int id = wrapper.get(Types.VAR_INT, 0); final ParticleMappings particleMappings = protocol.getMappingData().getParticleMappings(); if (id == particleMappings.id("vibration")) { - wrapper.read(Type.POSITION1_14); // Remove position + wrapper.read(Types.BLOCK_POSITION1_14); // Remove position - final String resourceLocation = Key.stripMinecraftNamespace(wrapper.passthrough(Type.STRING)); + final String resourceLocation = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING)); if (resourceLocation.equals("entity")) { - wrapper.passthrough(Type.VAR_INT); // Target entity - wrapper.write(Type.FLOAT, 0F); // Y offset + wrapper.passthrough(Types.VAR_INT); // Target entity + wrapper.write(Types.FLOAT, 0F); // Y offset } } }); - handler(getSpawnParticleHandler(Type.VAR_INT)); + handler(getSpawnParticleHandler(Types.VAR_INT)); } }); @@ -81,27 +82,27 @@ public final class ItemPacketRewriter1_19 extends ItemRewriter { - final int size = wrapper.read(Type.UNSIGNED_BYTE); - wrapper.write(Type.VAR_INT, size); + final int size = wrapper.read(Types.UNSIGNED_BYTE); + wrapper.write(Types.VAR_INT, size); for (int i = 0; i < size; i++) { - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); // First item - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); // Result + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // First item + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Result - if (wrapper.read(Type.BOOLEAN)) { - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); + if (wrapper.read(Types.BOOLEAN)) { + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); } else { - wrapper.write(Type.ITEM1_13_2, null); + wrapper.write(Types.ITEM1_13_2, null); } - wrapper.passthrough(Type.BOOLEAN); // Out of stock - wrapper.passthrough(Type.INT); // Uses - wrapper.passthrough(Type.INT); // Max uses - wrapper.passthrough(Type.INT); // Xp - wrapper.passthrough(Type.INT); // Special price diff - wrapper.passthrough(Type.FLOAT); // Price multiplier - wrapper.passthrough(Type.INT); //Demand + wrapper.passthrough(Types.BOOLEAN); // Out of stock + wrapper.passthrough(Types.INT); // Uses + wrapper.passthrough(Types.INT); // Max uses + wrapper.passthrough(Types.INT); // Xp + wrapper.passthrough(Types.INT); // Special price diff + wrapper.passthrough(Types.FLOAT); // Price multiplier + wrapper.passthrough(Types.INT); //Demand } }); } @@ -110,29 +111,29 @@ public final class ItemPacketRewriter1_19 extends ItemRewriter { - final int sequence = wrapper.read(Type.VAR_INT); + final int sequence = wrapper.read(Types.VAR_INT); final AckSequenceProvider provider = Via.getManager().getProviders().get(AckSequenceProvider.class); provider.handleSequence(wrapper.user(), sequence); }; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/WorldPacketRewriter1_19.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/WorldPacketRewriter1_19.java index c1304f9e4..a1bdab074 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/WorldPacketRewriter1_19.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/WorldPacketRewriter1_19.java @@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18; import com.viaversion.viaversion.protocols.v1_17_1to1_18.packet.ClientboundPackets1_18; import com.viaversion.viaversion.protocols.v1_18_2to1_19.Protocol1_18_2To1_19; @@ -61,17 +61,17 @@ public final class WorldPacketRewriter1_19 { protocol.registerServerbound(ServerboundPackets1_19.SET_BEACON, wrapper -> { // Primary effect - if (wrapper.read(Type.BOOLEAN)) { - wrapper.passthrough(Type.VAR_INT); + if (wrapper.read(Types.BOOLEAN)) { + wrapper.passthrough(Types.VAR_INT); } else { - wrapper.write(Type.VAR_INT, -1); + wrapper.write(Types.VAR_INT, -1); } // Secondary effect - if (wrapper.read(Type.BOOLEAN)) { - wrapper.passthrough(Type.VAR_INT); + if (wrapper.read(Types.BOOLEAN)) { + wrapper.passthrough(Types.VAR_INT); } else { - wrapper.write(Type.VAR_INT, -1); + wrapper.write(Types.VAR_INT, -1); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_18to1_18_2/Protocol1_18To1_18_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_18to1_18_2/Protocol1_18To1_18_2.java index f02f9ccde..5b53f3f28 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_18to1_18_2/Protocol1_18To1_18_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_18to1_18_2/Protocol1_18To1_18_2.java @@ -25,6 +25,7 @@ import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_16_4to1_17.packet.ServerboundPackets1_17; import com.viaversion.viaversion.protocols.v1_17_1to1_18.packet.ClientboundPackets1_18; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -45,42 +46,42 @@ public final class Protocol1_18To1_18_2 extends AbstractProtocol { - final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); + final CompoundTag registry = wrapper.get(Types.NAMED_COMPOUND_TAG, 0); final ListTag dimensions = TagUtil.getRegistryEntries(registry, "dimension_type"); for (final CompoundTag dimension : dimensions) { addTagPrefix(dimension.getCompoundTag("element")); } - addTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1)); + addTagPrefix(wrapper.get(Types.NAMED_COMPOUND_TAG, 1)); }); } }); - registerClientbound(ClientboundPackets1_18.RESPAWN, wrapper -> addTagPrefix(wrapper.passthrough(Type.NAMED_COMPOUND_TAG))); + registerClientbound(ClientboundPackets1_18.RESPAWN, wrapper -> addTagPrefix(wrapper.passthrough(Types.NAMED_COMPOUND_TAG))); } private void addTagPrefix(CompoundTag tag) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/Protocol1_19_1To1_19_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/Protocol1_19_1To1_19_3.java index edc69a8ba..f9069ec19 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/Protocol1_19_1To1_19_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/Protocol1_19_1To1_19_3.java @@ -38,6 +38,7 @@ import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.BitSetType; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_19_3; @@ -90,20 +91,20 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol { - int soundId = wrapper.read(Type.VAR_INT); + int soundId = wrapper.read(Types.VAR_INT); soundId = MAPPINGS.getSoundMappings().getNewId(soundId); if (soundId == -1) { wrapper.cancel(); return; } - wrapper.write(Type.SOUND_EVENT, Holder.of(soundId)); + wrapper.write(Types.SOUND_EVENT, Holder.of(soundId)); }; registerClientbound(ClientboundPackets1_19_1.SOUND_ENTITY, soundHandler); registerClientbound(ClientboundPackets1_19_1.SOUND, soundHandler); registerClientbound(ClientboundPackets1_19_1.CUSTOM_SOUND, ClientboundPackets1_19_3.SOUND, wrapper -> { - final String soundIdentifier = wrapper.read(Type.STRING); - wrapper.write(Type.SOUND_EVENT, Holder.of(new SoundEvent(soundIdentifier, null))); + final String soundIdentifier = wrapper.read(Types.STRING); + wrapper.write(Types.SOUND_EVENT, Holder.of(new SoundEvent(soundIdentifier, null))); }); new StatisticsRewriter<>(this).register(ClientboundPackets1_19_1.AWARD_STATS); @@ -112,9 +113,9 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol wrapper.write(Type.STRING, "minecraft:enchantment"); - case "minecraft:mob_effect" -> wrapper.write(Type.STRING, "minecraft:mob_effect"); - case "minecraft:entity_summon" -> wrapper.write(Type.STRING, "minecraft:entity_type"); + case "minecraft:item_enchantment" -> wrapper.write(Types.STRING, "minecraft:enchantment"); + case "minecraft:mob_effect" -> wrapper.write(Types.STRING, "minecraft:mob_effect"); + case "minecraft:entity_summon" -> wrapper.write(Types.STRING, "minecraft:entity_type"); default -> super.handleArgument(wrapper, argumentType); } } @@ -135,9 +136,9 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol { - final PlayerMessageSignature signature = wrapper.read(Type.PLAYER_MESSAGE_SIGNATURE); + final PlayerMessageSignature signature = wrapper.read(Types.PLAYER_MESSAGE_SIGNATURE); // Store message signature for last seen if (!signature.uuid().equals(ZERO_UUID) && signature.signatureBytes().length != 0) { @@ -158,20 +159,20 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol { final ChatSession1_19_1 chatSession = wrapper.user().get(ChatSession1_19_1.class); final ReceivedMessagesStorage messagesStorage = wrapper.user().get(ReceivedMessagesStorage.class); - final int signatures = wrapper.read(Type.VAR_INT); + final int signatures = wrapper.read(Types.VAR_INT); for (int i = 0; i < signatures; i++) { - wrapper.read(Type.STRING); // Argument name - wrapper.read(Type.SIGNATURE_BYTES); // Signature + wrapper.read(Types.STRING); // Argument name + wrapper.read(Types.SIGNATURE_BYTES); // Signature } final SignableCommandArgumentsProvider argumentsProvider = Via.getManager().getProviders().get(SignableCommandArgumentsProvider.class); if (chatSession != null && argumentsProvider != null) { final UUID sender = wrapper.user().getProtocolInfo().getUuid(); - final String message = wrapper.get(Type.STRING, 0); - final long timestamp = wrapper.get(Type.LONG, 0); - final long salt = wrapper.get(Type.LONG, 1); + final String message = wrapper.get(Types.STRING, 0); + final long timestamp = wrapper.get(Types.LONG, 0); + final long salt = wrapper.get(Types.LONG, 1); final List> arguments = argumentsProvider.getSignableArguments(message); - wrapper.write(Type.VAR_INT, arguments.size()); // Signature count + wrapper.write(Types.VAR_INT, arguments.size()); // Signature count for (Pair argument : arguments) { final MessageMetadata metadata = new MessageMetadata(sender, timestamp, salt); @@ -227,39 +228,39 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol { final ChatSession1_19_1 chatSession = wrapper.user().get(ChatSession1_19_1.class); final ReceivedMessagesStorage messagesStorage = wrapper.user().get(ReceivedMessagesStorage.class); if (chatSession != null) { final UUID sender = wrapper.user().getProtocolInfo().getUuid(); - final String message = wrapper.get(Type.STRING, 0); - final long timestamp = wrapper.get(Type.LONG, 0); - final long salt = wrapper.get(Type.LONG, 1); + final String message = wrapper.get(Types.STRING, 0); + final long timestamp = wrapper.get(Types.LONG, 0); + final long salt = wrapper.get(Types.LONG, 1); final MessageMetadata metadata = new MessageMetadata(sender, timestamp, salt); final DecoratableMessage decoratableMessage = new DecoratableMessage(message); @@ -270,30 +271,30 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol { if (wrapper.user().has(ChatSession1_19_1.class)) { - wrapper.user().put(new NonceStorage(wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE))); // Nonce + wrapper.user().put(new NonceStorage(wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE))); // Nonce } }); } @@ -301,23 +302,23 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol { final ChatSession1_19_1 chatSession = wrapper.user().get(ChatSession1_19_1.class); - wrapper.write(Type.OPTIONAL_PROFILE_KEY, chatSession == null ? null : chatSession.getProfileKey()); // Profile Key + wrapper.write(Types.OPTIONAL_PROFILE_KEY, chatSession == null ? null : chatSession.getProfileKey()); // Profile Key }); - map(Type.OPTIONAL_UUID); // Profile uuid + map(Types.OPTIONAL_UUID); // Profile uuid } }); registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() { @Override public void register() { - map(Type.BYTE_ARRAY_PRIMITIVE); // Public key + map(Types.BYTE_ARRAY_PRIMITIVE); // Public key handler(wrapper -> { final ChatSession1_19_1 chatSession = wrapper.user().get(ChatSession1_19_1.class); - final byte[] verifyToken = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); // Verify token - wrapper.write(Type.BOOLEAN, chatSession == null); // Is nonce + final byte[] verifyToken = wrapper.read(Types.BYTE_ARRAY_PRIMITIVE); // Verify token + wrapper.write(Types.BOOLEAN, chatSession == null); // Is nonce if (chatSession != null) { final long salt = ThreadLocalRandom.current().nextLong(); final byte[] signature; @@ -329,10 +330,10 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol { // Also enable vanilla features final PacketWrapper enableFeaturesPacket = wrapper.create(ClientboundPackets1_19_3.UPDATE_ENABLED_FEATURES); - enableFeaturesPacket.write(Type.VAR_INT, 1); - enableFeaturesPacket.write(Type.STRING, "minecraft:vanilla"); + enableFeaturesPacket.write(Types.VAR_INT, 1); + enableFeaturesPacket.write(Types.STRING, "minecraft:vanilla"); enableFeaturesPacket.scheduleSend(Protocol1_19_1To1_19_3.class); }); } @@ -74,35 +75,35 @@ public final class EntityPacketRewriter1_19_3 extends EntityRewriter { - final boolean keepAttributes = wrapper.read(Type.BOOLEAN); + final boolean keepAttributes = wrapper.read(Types.BOOLEAN); byte keepDataMask = 0x02; // Always keep entity data if (keepAttributes) { keepDataMask |= 0x01; } - wrapper.write(Type.BYTE, keepDataMask); + wrapper.write(Types.BYTE, keepDataMask); }); } }); protocol.registerClientbound(ClientboundPackets1_19_1.PLAYER_INFO, ClientboundPackets1_19_3.PLAYER_INFO_UPDATE, wrapper -> { - final int action = wrapper.read(Type.VAR_INT); + final int action = wrapper.read(Types.VAR_INT); if (action == 4) { // Remove player // Write into new packet type - final int entries = wrapper.read(Type.VAR_INT); + final int entries = wrapper.read(Types.VAR_INT); final UUID[] uuidsToRemove = new UUID[entries]; for (int i = 0; i < entries; i++) { - uuidsToRemove[i] = wrapper.read(Type.UUID); + uuidsToRemove[i] = wrapper.read(Types.UUID); } - wrapper.write(Type.UUID_ARRAY, uuidsToRemove); + wrapper.write(Types.UUID_ARRAY, uuidsToRemove); wrapper.setPacketType(ClientboundPackets1_19_3.PLAYER_INFO_REMOVE); return; } @@ -116,34 +117,34 @@ public final class EntityPacketRewriter1_19_3 extends EntityRewriter Types1_19_3.META_TYPES.byId(typeId >= 2 ? typeId + 1 : typeId)); // Long added - registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, Types1_19_3.META_TYPES.particleType); + registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.optionalBlockStateType, Types1_19_3.META_TYPES.particleType); filter().type(EntityTypes1_19_3.ENTITY).index(6).handler((event, meta) -> { // Sitting pose added diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/rewriter/ItemPacketRewriter1_19_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/rewriter/ItemPacketRewriter1_19_3.java index f629eb8da..4737b5e68 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/rewriter/ItemPacketRewriter1_19_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/rewriter/ItemPacketRewriter1_19_3.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.v1_19_1to1_19_3.rewriter; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18; import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.Protocol1_19_1To1_19_3; import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.packet.ServerboundPackets1_19_3; @@ -34,7 +35,7 @@ public final class ItemPacketRewriter1_19_3 extends ItemRewriter recipeRewriter = new RecipeRewriter<>(protocol); protocol.registerClientbound(ClientboundPackets1_19_1.UPDATE_RECIPES, wrapper -> { - final int size = wrapper.passthrough(Type.VAR_INT); + final int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { - final String type = Key.stripMinecraftNamespace(wrapper.passthrough(Type.STRING)); - wrapper.passthrough(Type.STRING); // Recipe Identifier + final String type = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING)); + wrapper.passthrough(Types.STRING); // Recipe Identifier switch (type) { case "crafting_shapeless": { - wrapper.passthrough(Type.STRING); // Group - wrapper.write(Type.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY); - final int ingredients = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.STRING); // Group + wrapper.write(Types.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY); + final int ingredients = wrapper.passthrough(Types.VAR_INT); for (int j = 0; j < ingredients; j++) { - final Item[] items = wrapper.passthrough(Type.ITEM1_13_2_ARRAY); // Ingredients + final Item[] items = wrapper.passthrough(Types.ITEM1_13_2_ARRAY); // Ingredients for (final Item item : items) { handleItemToClient(wrapper.user(), item); } } - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); // Result + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Result break; } case "crafting_shaped": { - final int ingredients = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.STRING); // Group - wrapper.write(Type.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY); + final int ingredients = wrapper.passthrough(Types.VAR_INT) * wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.STRING); // Group + wrapper.write(Types.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY); for (int j = 0; j < ingredients; j++) { - final Item[] items = wrapper.passthrough(Type.ITEM1_13_2_ARRAY); // Ingredients + final Item[] items = wrapper.passthrough(Types.ITEM1_13_2_ARRAY); // Ingredients for (final Item item : items) { handleItemToClient(wrapper.user(), item); } } - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); // Result + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Result break; } case "smelting": case "campfire_cooking": case "blasting": case "smoking": - wrapper.passthrough(Type.STRING); // Group - wrapper.write(Type.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY); - final Item[] items = wrapper.passthrough(Type.ITEM1_13_2_ARRAY); // Ingredients + wrapper.passthrough(Types.STRING); // Group + wrapper.write(Types.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY); + final Item[] items = wrapper.passthrough(Types.ITEM1_13_2_ARRAY); // Ingredients for (final Item item : items) { handleItemToClient(wrapper.user(), item); } - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); // Result - wrapper.passthrough(Type.FLOAT); // EXP - wrapper.passthrough(Type.VAR_INT); // Cooking time + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Result + wrapper.passthrough(Types.FLOAT); // EXP + wrapper.passthrough(Types.VAR_INT); // Cooking time break; case "crafting_special_armordye": case "crafting_special_bookcloning": @@ -118,7 +119,7 @@ public final class ItemPacketRewriter1_19_3 extends ItemRewriter extends RecipeRewriter { @@ -46,8 +47,8 @@ public class RecipeRewriter1_19_3 extends Recip @Override public void handleCraftingShapeless(final PacketWrapper wrapper) { - wrapper.passthrough(Type.STRING); // Group - wrapper.passthrough(Type.VAR_INT); // Crafting book category + wrapper.passthrough(Types.STRING); // Group + wrapper.passthrough(Types.VAR_INT); // Crafting book category handleIngredients(wrapper); final Item result = rewrite(wrapper.user(), wrapper.read(itemType())); wrapper.write(mappedItemType(), result); @@ -55,9 +56,9 @@ public class RecipeRewriter1_19_3 extends Recip @Override public void handleCraftingShaped(final PacketWrapper wrapper) { - final int ingredients = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.STRING); // Group - wrapper.passthrough(Type.VAR_INT); // Crafting book category + final int ingredients = wrapper.passthrough(Types.VAR_INT) * wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.STRING); // Group + wrapper.passthrough(Types.VAR_INT); // Crafting book category for (int i = 0; i < ingredients; i++) { handleIngredient(wrapper); } @@ -67,12 +68,12 @@ public class RecipeRewriter1_19_3 extends Recip @Override public void handleSmelting(final PacketWrapper wrapper) { - wrapper.passthrough(Type.STRING); // Group - wrapper.passthrough(Type.VAR_INT); // Crafting book category + wrapper.passthrough(Types.STRING); // Group + wrapper.passthrough(Types.VAR_INT); // Crafting book category handleIngredient(wrapper); final Item result = rewrite(wrapper.user(), wrapper.read(itemType())); wrapper.write(mappedItemType(), result); - wrapper.passthrough(Type.FLOAT); // EXP - wrapper.passthrough(Type.VAR_INT); // Cooking time + wrapper.passthrough(Types.FLOAT); // EXP + wrapper.passthrough(Types.VAR_INT); // Cooking time } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/Protocol1_19_3To1_19_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/Protocol1_19_3To1_19_4.java index 50b5660cb..dc47b7466 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/Protocol1_19_3To1_19_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/Protocol1_19_3To1_19_4.java @@ -23,6 +23,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_19_4; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -69,7 +70,7 @@ public final class Protocol1_19_3To1_19_4 extends AbstractProtocol { - JsonElement element = wrapper.read(Type.OPTIONAL_COMPONENT); + JsonElement element = wrapper.read(Types.OPTIONAL_COMPONENT); if (element != null) { - wrapper.write(Type.COMPONENT, element); + wrapper.write(Types.COMPONENT, element); } else { - wrapper.write(Type.COMPONENT, ComponentUtil.emptyJsonComponent()); + wrapper.write(Types.COMPONENT, ComponentUtil.emptyJsonComponent()); } - final String iconBase64 = wrapper.read(Type.OPTIONAL_STRING); + final String iconBase64 = wrapper.read(Types.OPTIONAL_STRING); byte[] iconBytes = null; if (iconBase64 != null && iconBase64.startsWith("data:image/png;base64,")) { iconBytes = Base64.getDecoder().decode(iconBase64.substring("data:image/png;base64,".length()).getBytes(StandardCharsets.UTF_8)); } - wrapper.write(Type.OPTIONAL_BYTE_ARRAY_PRIMITIVE, iconBytes); + wrapper.write(Types.OPTIONAL_BYTE_ARRAY_PRIMITIVE, iconBytes); }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/CommandRewriter1_19_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/CommandRewriter1_19_4.java index 339e6a2b8..276569995 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/CommandRewriter1_19_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/CommandRewriter1_19_4.java @@ -19,13 +19,13 @@ package com.viaversion.viaversion.protocols.v1_19_3to1_19_4.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.api.type.Types; import com.viaversion.viaversion.rewriter.CommandRewriter; public class CommandRewriter1_19_4 extends CommandRewriter { public CommandRewriter1_19_4(Protocol protocol) { super(protocol); - this.parserHandlers.put("minecraft:time", wrapper -> wrapper.passthrough(Type.INT)); // Minimum + this.parserHandlers.put("minecraft:time", wrapper -> wrapper.passthrough(Types.INT)); // Minimum } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/EntityPacketRewriter1_19_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/EntityPacketRewriter1_19_4.java index 9f8d7eea4..a1378b1e7 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/EntityPacketRewriter1_19_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/EntityPacketRewriter1_19_4.java @@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_19_3; import com.viaversion.viaversion.api.type.types.version.Types1_19_4; import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.packet.ClientboundPackets1_19_3; @@ -46,20 +47,20 @@ public final class EntityPacketRewriter1_19_4 extends EntityRewriter { - final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); + final CompoundTag registry = wrapper.get(Types.NAMED_COMPOUND_TAG, 0); final CompoundTag damageTypeRegistry = protocol.getMappingData().damageTypesRegistry(); registry.put("minecraft:damage_type", damageTypeRegistry); @@ -77,22 +78,22 @@ public final class EntityPacketRewriter1_19_4 extends EntityRewriter { - if (wrapper.read(Type.BOOLEAN)) { // Dismount vehicle + if (wrapper.read(Types.BOOLEAN)) { // Dismount vehicle final PlayerVehicleTracker playerVehicleTracker = wrapper.user().get(PlayerVehicleTracker.class); if (playerVehicleTracker.getVehicleId() != -1) { final PacketWrapper bundleStart = wrapper.create(ClientboundPackets1_19_4.BUNDLE_DELIMITER); bundleStart.send(Protocol1_19_3To1_19_4.class); final PacketWrapper setPassengers = wrapper.create(ClientboundPackets1_19_4.SET_PASSENGERS); - setPassengers.write(Type.VAR_INT, playerVehicleTracker.getVehicleId()); // vehicle id - setPassengers.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[0]); // passenger ids + setPassengers.write(Types.VAR_INT, playerVehicleTracker.getVehicleId()); // vehicle id + setPassengers.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[0]); // passenger ids setPassengers.send(Protocol1_19_3To1_19_4.class); wrapper.send(Protocol1_19_3To1_19_4.class); wrapper.cancel(); @@ -109,18 +110,18 @@ public final class EntityPacketRewriter1_19_4 extends EntityRewriter { final PlayerVehicleTracker playerVehicleTracker = wrapper.user().get(PlayerVehicleTracker.class); final int clientEntityId = wrapper.user().getEntityTracker(Protocol1_19_3To1_19_4.class).clientEntityId(); - final int vehicleId = wrapper.get(Type.VAR_INT, 0); + final int vehicleId = wrapper.get(Types.VAR_INT, 0); if (playerVehicleTracker.getVehicleId() == vehicleId) { playerVehicleTracker.setVehicleId(-1); } - final int[] passengerIds = wrapper.get(Type.VAR_INT_ARRAY_PRIMITIVE, 0); + final int[] passengerIds = wrapper.get(Types.VAR_INT_ARRAY_PRIMITIVE, 0); for (int passengerId : passengerIds) { if (passengerId == clientEntityId) { playerVehicleTracker.setVehicleId(vehicleId); @@ -135,22 +136,22 @@ public final class EntityPacketRewriter1_19_4 extends EntityRewriter { - final int entityId = wrapper.read(Type.VAR_INT); // entity id + final int entityId = wrapper.read(Types.VAR_INT); // entity id final int clientEntityId = wrapper.user().getEntityTracker(Protocol1_19_3To1_19_4.class).clientEntityId(); if (entityId != clientEntityId) { - wrapper.write(Type.VAR_INT, entityId); // entity id + wrapper.write(Types.VAR_INT, entityId); // entity id return; } wrapper.setPacketType(ClientboundPackets1_19_4.PLAYER_POSITION); - wrapper.passthrough(Type.DOUBLE); // x - wrapper.passthrough(Type.DOUBLE); // y - wrapper.passthrough(Type.DOUBLE); // z - wrapper.write(Type.FLOAT, wrapper.read(Type.BYTE) * 360F / 256F); // yaw - wrapper.write(Type.FLOAT, wrapper.read(Type.BYTE) * 360F / 256F); // pitch - wrapper.read(Type.BOOLEAN); // on ground - wrapper.write(Type.BYTE, (byte) 0); // flags - wrapper.write(Type.VAR_INT, -1); // teleport id + wrapper.passthrough(Types.DOUBLE); // x + wrapper.passthrough(Types.DOUBLE); // y + wrapper.passthrough(Types.DOUBLE); // z + wrapper.write(Types.FLOAT, wrapper.read(Types.BYTE) * 360F / 256F); // yaw + wrapper.write(Types.FLOAT, wrapper.read(Types.BYTE) * 360F / 256F); // pitch + wrapper.read(Types.BOOLEAN); // on ground + wrapper.write(Types.BYTE, (byte) 0); // flags + wrapper.write(Types.VAR_INT, -1); // teleport id }); } }); @@ -158,16 +159,16 @@ public final class EntityPacketRewriter1_19_4 extends EntityRewriter { - final short action = wrapper.read(Type.UNSIGNED_BYTE); + final short action = wrapper.read(Types.UNSIGNED_BYTE); if (action != 1) { - wrapper.write(Type.UNSIGNED_BYTE, action); + wrapper.write(Types.UNSIGNED_BYTE, action); return; } wrapper.setPacketType(ClientboundPackets1_19_4.HURT_ANIMATION); - wrapper.write(Type.FLOAT, 0F); + wrapper.write(Types.FLOAT, 0F); }); } }); @@ -175,30 +176,30 @@ public final class EntityPacketRewriter1_19_4 extends EntityRewriter wrapper.user().put(new PlayerVehicleTracker())); } }); protocol.registerClientbound(ClientboundPackets1_19_3.ENTITY_EVENT, wrapper -> { - final int entityId = wrapper.read(Type.INT); - final byte event = wrapper.read(Type.BYTE); + final int entityId = wrapper.read(Types.INT); + final byte event = wrapper.read(Types.BYTE); final int damageType = damageTypeFromEntityEvent(event); if (damageType != -1) { wrapper.setPacketType(ClientboundPackets1_19_4.DAMAGE_EVENT); - wrapper.write(Type.VAR_INT, entityId); - wrapper.write(Type.VAR_INT, damageType); - wrapper.write(Type.VAR_INT, 0); // No source entity - wrapper.write(Type.VAR_INT, 0); // No direct source entity - wrapper.write(Type.BOOLEAN, false); // No source position + wrapper.write(Types.VAR_INT, entityId); + wrapper.write(Types.VAR_INT, damageType); + wrapper.write(Types.VAR_INT, 0); // No source entity + wrapper.write(Types.VAR_INT, 0); // No direct source entity + wrapper.write(Types.BOOLEAN, false); // No source position return; } - wrapper.write(Type.INT, entityId); - wrapper.write(Type.BYTE, event); + wrapper.write(Types.INT, entityId); + wrapper.write(Types.BYTE, event); }); registerTrackerWithData1_19(ClientboundPackets1_19_3.ADD_ENTITY, EntityTypes1_19_4.FALLING_BLOCK); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/ItemPacketRewriter1_19_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/ItemPacketRewriter1_19_4.java index f4c905dac..28a69984f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/ItemPacketRewriter1_19_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/ItemPacketRewriter1_19_4.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.v1_19_3to1_19_4.rewriter; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18; import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.packet.ClientboundPackets1_19_3; import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.rewriter.RecipeRewriter1_19_3; @@ -31,7 +32,7 @@ import com.viaversion.viaversion.rewriter.ItemRewriter; public final class ItemPacketRewriter1_19_4 extends ItemRewriter { public ItemPacketRewriter1_19_4(final Protocol1_19_3To1_19_4 protocol) { - super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_ARRAY); + super(protocol, Types.ITEM1_13_2, Types.ITEM1_13_2_ARRAY); } @Override @@ -46,23 +47,23 @@ public final class ItemPacketRewriter1_19_4 extends ItemRewriter { - int id = wrapper.get(Type.INT, 0); - int data = wrapper.get(Type.INT, 1); + int id = wrapper.get(Types.INT, 0); + int data = wrapper.get(Types.INT, 1); if (id == 1010) { // Play record if (data >= 1092 && data <= 1106) { // These IDs are valid records - wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(data)); + wrapper.set(Types.INT, 1, protocol.getMappingData().getNewItemId(data)); } else { // Send stop record instead - wrapper.set(Type.INT, 0, 1011); - wrapper.set(Type.INT, 1, 0); + wrapper.set(Types.INT, 0, 1011); + wrapper.set(Types.INT, 1, 0); } } else if (id == 2001) { // Block break + block break sound - wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(data)); + wrapper.set(Types.INT, 1, protocol.getMappingData().getNewBlockStateId(data)); } }); } @@ -71,13 +72,13 @@ public final class ItemPacketRewriter1_19_4 extends ItemRewriter { - final int windowType = wrapper.get(Type.VAR_INT, 1); + final int windowType = wrapper.get(Types.VAR_INT, 1); if (windowType >= 21) { // New smithing menu - wrapper.set(Type.VAR_INT, 1, windowType + 1); + wrapper.set(Types.VAR_INT, 1, windowType + 1); } }); } @@ -98,7 +99,7 @@ public final class ItemPacketRewriter1_19_4 extends ItemRewriter extends RecipeRewriter1_19_3 { @@ -32,6 +32,6 @@ public class RecipeRewriter1_19_4 extends Recip @Override public void handleCraftingShaped(final PacketWrapper wrapper) { super.handleCraftingShaped(wrapper); - wrapper.passthrough(Type.BOOLEAN); // Show notification + wrapper.passthrough(Types.BOOLEAN); // Show notification } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/Protocol1_19_4To1_20.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/Protocol1_19_4To1_20.java index 567f03974..930f041a0 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/Protocol1_19_4To1_20.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/Protocol1_19_4To1_20.java @@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.data.MappingData; import com.viaversion.viaversion.api.data.MappingDataBase; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4; import com.viaversion.viaversion.api.protocol.AbstractProtocol; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_20; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -58,12 +58,12 @@ public final class Protocol1_19_4To1_20 extends AbstractProtocol(this).register(ClientboundPackets1_19_4.AWARD_STATS); registerClientbound(ClientboundPackets1_19_4.PLAYER_COMBAT_END, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Duration - wrapper.read(Type.INT); // Killer ID + wrapper.passthrough(Types.VAR_INT); // Duration + wrapper.read(Types.INT); // Killer ID }); registerClientbound(ClientboundPackets1_19_4.PLAYER_COMBAT_KILL, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Duration - wrapper.read(Type.INT); // Killer ID + wrapper.passthrough(Types.VAR_INT); // Duration + wrapper.read(Types.INT); // Killer ID }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/rewriter/EntityPacketRewriter1_20.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/rewriter/EntityPacketRewriter1_20.java index 6bb31f156..7430cce02 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/rewriter/EntityPacketRewriter1_20.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/rewriter/EntityPacketRewriter1_20.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_19_4; import com.viaversion.viaversion.api.type.types.version.Types1_20; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPackets1_19_4; @@ -52,30 +53,30 @@ public final class EntityPacketRewriter1_20 extends EntityRewriter { - final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); + final CompoundTag registry = wrapper.get(Types.NAMED_COMPOUND_TAG, 0); final ListTag damageTypes = TagUtil.getRegistryEntries(registry, "damage_type"); int highestId = -1; for (final CompoundTag damageType : damageTypes) { @@ -110,16 +111,16 @@ public final class EntityPacketRewriter1_20 extends EntityRewriter { public ItemPacketRewriter1_20(final Protocol1_19_4To1_20 protocol) { - super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_ARRAY); + super(protocol, Types.ITEM1_13_2, Types.ITEM1_13_2_ARRAY); } @Override @@ -62,44 +63,44 @@ public final class ItemPacketRewriter1_20 extends ItemRewriter { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - int size = wrapper.passthrough(Type.VAR_INT); // Mapping size + wrapper.passthrough(Types.BOOLEAN); // Reset/clear + int size = wrapper.passthrough(Types.VAR_INT); // Mapping size for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier - wrapper.passthrough(Type.OPTIONAL_STRING); // Parent + wrapper.passthrough(Types.STRING); // Identifier + wrapper.passthrough(Types.OPTIONAL_STRING); // Parent // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.COMPONENT); // Title - wrapper.passthrough(Type.COMPONENT); // Description - handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)); // Icon - wrapper.passthrough(Type.VAR_INT); // Frame type - int flags = wrapper.passthrough(Type.INT); // Flags + if (wrapper.passthrough(Types.BOOLEAN)) { + wrapper.passthrough(Types.COMPONENT); // Title + wrapper.passthrough(Types.COMPONENT); // Description + handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Icon + wrapper.passthrough(Types.VAR_INT); // Frame type + int flags = wrapper.passthrough(Types.INT); // Flags if ((flags & 1) != 0) { - wrapper.passthrough(Type.STRING); // Background texture + wrapper.passthrough(Types.STRING); // Background texture } - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y + wrapper.passthrough(Types.FLOAT); // X + wrapper.passthrough(Types.FLOAT); // Y } - wrapper.passthrough(Type.STRING_ARRAY); // Critereon triggers + wrapper.passthrough(Types.STRING_ARRAY); // Critereon triggers - int requirements = wrapper.passthrough(Type.VAR_INT); + int requirements = wrapper.passthrough(Types.VAR_INT); for (int array = 0; array < requirements; array++) { - wrapper.passthrough(Type.STRING_ARRAY); + wrapper.passthrough(Types.STRING_ARRAY); } - wrapper.write(Type.BOOLEAN, false); // Sends telemetry + wrapper.write(Types.BOOLEAN, false); // Sends telemetry } }); protocol.registerClientbound(ClientboundPackets1_19_4.OPEN_SIGN_EDITOR, wrapper -> { - wrapper.passthrough(Type.POSITION1_14); - wrapper.write(Type.BOOLEAN, true); // Front text + wrapper.passthrough(Types.BLOCK_POSITION1_14); + wrapper.write(Types.BOOLEAN, true); // Front text }); protocol.registerServerbound(ServerboundPackets1_19_4.SIGN_UPDATE, wrapper -> { - wrapper.passthrough(Type.POSITION1_14); - final boolean frontText = wrapper.read(Type.BOOLEAN); + wrapper.passthrough(Types.BLOCK_POSITION1_14); + final boolean frontText = wrapper.read(Types.BOOLEAN); if (!frontText) { wrapper.cancel(); } @@ -109,23 +110,23 @@ public final class ItemPacketRewriter1_20 extends ItemRewriter handleBlockEntity(blockEntity))); - read(Type.BOOLEAN); // Trust edges + read(Types.BOOLEAN); // Trust edges } }); protocol.registerClientbound(ClientboundPackets1_19_4.LIGHT_UPDATE, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // X - wrapper.passthrough(Type.VAR_INT); // Y - wrapper.read(Type.BOOLEAN); // Trust edges + wrapper.passthrough(Types.VAR_INT); // X + wrapper.passthrough(Types.VAR_INT); // Y + wrapper.read(Types.BOOLEAN); // Trust edges }); protocol.registerClientbound(ClientboundPackets1_19_4.SECTION_BLOCKS_UPDATE, new PacketHandlers() { @Override public void register() { - map(Type.LONG); // Chunk position - read(Type.BOOLEAN); // Suppress light updates + map(Types.LONG); // Chunk position + read(Types.BOOLEAN); // Suppress light updates handler(wrapper -> { - for (final BlockChangeRecord record : wrapper.passthrough(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY)) { + for (final BlockChangeRecord record : wrapper.passthrough(Types.VAR_LONG_BLOCK_CHANGE_ARRAY)) { record.setBlockId(protocol.getMappingData().getNewBlockStateId(record.getBlockId())); } }); @@ -134,26 +135,26 @@ public final class ItemPacketRewriter1_20 extends ItemRewriter recipeRewriter = new RecipeRewriter1_19_4<>(protocol); protocol.registerClientbound(ClientboundPackets1_19_4.UPDATE_RECIPES, wrapper -> { - final int size = wrapper.passthrough(Type.VAR_INT); + final int size = wrapper.passthrough(Types.VAR_INT); int newSize = size; for (int i = 0; i < size; i++) { - final String type = wrapper.read(Type.STRING); + final String type = wrapper.read(Types.STRING); final String cutType = Key.stripMinecraftNamespace(type); if (cutType.equals("smithing")) { newSize--; - wrapper.read(Type.STRING); // Recipe identifier - wrapper.read(Type.ITEM1_13_2_ARRAY); // Base - wrapper.read(Type.ITEM1_13_2_ARRAY); // Additions - wrapper.read(Type.ITEM1_13_2); // Result + wrapper.read(Types.STRING); // Recipe identifier + wrapper.read(Types.ITEM1_13_2_ARRAY); // Base + wrapper.read(Types.ITEM1_13_2_ARRAY); // Additions + wrapper.read(Types.ITEM1_13_2); // Result continue; } - wrapper.write(Type.STRING, type); - wrapper.passthrough(Type.STRING); // Recipe Identifier + wrapper.write(Types.STRING, type); + wrapper.passthrough(Types.STRING); // Recipe Identifier recipeRewriter.handleRecipeType(wrapper, cutType); } - wrapper.set(Type.VAR_INT, 0, newSize); + wrapper.set(Types.VAR_INT, 0, newSize); }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19to1_19_1/Protocol1_19To1_19_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19to1_19_1/Protocol1_19To1_19_1.java index dc2b8b881..311860d9a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19to1_19_1/Protocol1_19To1_19_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19to1_19_1/Protocol1_19To1_19_1.java @@ -35,6 +35,7 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol; 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; import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets; import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets; import com.viaversion.viaversion.protocols.v1_18_2to1_19.packet.ClientboundPackets1_19; @@ -71,11 +72,11 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol { - final int type = wrapper.read(Type.VAR_INT); + final int type = wrapper.read(Types.VAR_INT); final boolean overlay = type == 2; - wrapper.write(Type.BOOLEAN, overlay); + wrapper.write(Types.BOOLEAN, overlay); }); } }); @@ -84,12 +85,12 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol { // Back to system chat - final JsonElement signedContent = wrapper.read(Type.COMPONENT); - final JsonElement unsignedContent = wrapper.read(Type.OPTIONAL_COMPONENT); - final int chatTypeId = wrapper.read(Type.VAR_INT); - wrapper.read(Type.UUID); // Sender UUID - final JsonElement senderName = wrapper.read(Type.COMPONENT); - final JsonElement teamName = wrapper.read(Type.OPTIONAL_COMPONENT); + final JsonElement signedContent = wrapper.read(Types.COMPONENT); + final JsonElement unsignedContent = wrapper.read(Types.OPTIONAL_COMPONENT); + final int chatTypeId = wrapper.read(Types.VAR_INT); + wrapper.read(Types.UUID); // Sender UUID + final JsonElement senderName = wrapper.read(Types.COMPONENT); + final JsonElement teamName = wrapper.read(Types.OPTIONAL_COMPONENT); final CompoundTag chatType = wrapper.user().get(ChatTypeStorage.class).chatType(chatTypeId); final ChatDecorationResult decorationResult = decorateChatMessage(chatType, chatTypeId, senderName, teamName, unsignedContent != null ? unsignedContent : signedContent); @@ -98,30 +99,30 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol { final ChatSession1_19_0 chatSession = wrapper.user().get(ChatSession1_19_0.class); if (chatSession != null) { final UUID sender = wrapper.user().getProtocolInfo().getUuid(); - final String message = wrapper.get(Type.STRING, 0); - final long timestamp = wrapper.get(Type.LONG, 0); - final long salt = wrapper.get(Type.LONG, 1); + final String message = wrapper.get(Types.STRING, 0); + final long timestamp = wrapper.get(Types.LONG, 0); + final long salt = wrapper.get(Types.LONG, 1); final MessageMetadata metadata = new MessageMetadata(sender, timestamp, salt); final DecoratableMessage decoratableMessage = new DecoratableMessage(message); @@ -132,39 +133,39 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol { final ChatSession1_19_0 chatSession = wrapper.user().get(ChatSession1_19_0.class); final SignableCommandArgumentsProvider argumentsProvider = Via.getManager().getProviders().get(SignableCommandArgumentsProvider.class); - final int signatures = wrapper.read(Type.VAR_INT); + final int signatures = wrapper.read(Types.VAR_INT); for (int i = 0; i < signatures; i++) { - wrapper.read(Type.STRING); // Argument name - wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); // Signature + wrapper.read(Types.STRING); // Argument name + wrapper.read(Types.BYTE_ARRAY_PRIMITIVE); // Signature } if (chatSession != null && argumentsProvider != null) { final UUID sender = wrapper.user().getProtocolInfo().getUuid(); - final String message = wrapper.get(Type.STRING, 0); - final long timestamp = wrapper.get(Type.LONG, 0); - final long salt = wrapper.get(Type.LONG, 1); + final String message = wrapper.get(Types.STRING, 0); + final long timestamp = wrapper.get(Types.LONG, 0); + final long salt = wrapper.get(Types.LONG, 1); final List> arguments = argumentsProvider.getSignableArguments(message); - wrapper.write(Type.VAR_INT, arguments.size()); // Signature count + wrapper.write(Types.VAR_INT, arguments.size()); // Signature count for (Pair argument : arguments) { final MessageMetadata metadata = new MessageMetadata(sender, timestamp, salt); final DecoratableMessage decoratableMessage = new DecoratableMessage(argument.value()); @@ -176,16 +177,16 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol { final ChatTypeStorage chatTypeStorage = wrapper.user().get(ChatTypeStorage.class); chatTypeStorage.clear(); - final CompoundTag registry = wrapper.passthrough(Type.NAMED_COMPOUND_TAG); + final CompoundTag registry = wrapper.passthrough(Types.NAMED_COMPOUND_TAG); final ListTag chatTypes = TagUtil.removeRegistryEntries(registry, "chat_type"); for (final CompoundTag chatType : chatTypes) { final NumberTag idTag = chatType.getNumberTag("id"); @@ -218,42 +219,42 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol { - final ProfileKey profileKey = wrapper.read(Type.OPTIONAL_PROFILE_KEY); // Profile Key + final ProfileKey profileKey = wrapper.read(Types.OPTIONAL_PROFILE_KEY); // Profile Key final ChatSession1_19_0 chatSession = wrapper.user().get(ChatSession1_19_0.class); - wrapper.write(Type.OPTIONAL_PROFILE_KEY, chatSession == null ? null : chatSession.getProfileKey()); // Profile Key + wrapper.write(Types.OPTIONAL_PROFILE_KEY, chatSession == null ? null : chatSession.getProfileKey()); // Profile Key if (profileKey == null || chatSession != null) { // Modified client that doesn't include the profile key, or already done in 1.18->1.19 protocol; no need to map it wrapper.user().put(new NonceStorage(null)); } }); - read(Type.OPTIONAL_UUID); // Profile uuid + read(Types.OPTIONAL_UUID); // Profile uuid } }); registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() { @Override public void register() { - map(Type.STRING); // Server id + map(Types.STRING); // Server id handler(wrapper -> { if (wrapper.user().has(NonceStorage.class)) { return; } - final byte[] publicKey = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); - final byte[] nonce = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); + final byte[] publicKey = wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE); + final byte[] nonce = wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE); wrapper.user().put(new NonceStorage(CipherUtil.encryptNonce(publicKey, nonce))); }); } @@ -261,19 +262,19 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol { final NonceStorage nonceStorage = wrapper.user().remove(NonceStorage.class); if (nonceStorage.nonce() == null) { return; } - final boolean isNonce = wrapper.read(Type.BOOLEAN); - wrapper.write(Type.BOOLEAN, true); + final boolean isNonce = wrapper.read(Types.BOOLEAN); + wrapper.write(Types.BOOLEAN, true); if (!isNonce) { // Should never be true at this point, but /shrug otherwise - wrapper.read(Type.LONG); // Salt - wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); // Signature - wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, nonceStorage.nonce()); + wrapper.read(Types.LONG); // Salt + wrapper.read(Types.BYTE_ARRAY_PRIMITIVE); // Signature + wrapper.write(Types.BYTE_ARRAY_PRIMITIVE, nonceStorage.nonce()); } }); } @@ -281,12 +282,12 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol { - String identifier = wrapper.get(Type.STRING, 0); + String identifier = wrapper.get(Types.STRING, 0); if (identifier.equals("velocity:player_info")) { - byte[] data = wrapper.passthrough(Type.REMAINING_BYTES); + byte[] data = wrapper.passthrough(Types.REMAINING_BYTES); // Velocity modern forwarding version above 1 includes the players public key. // This is an issue because the server will expect a 1.19 key and receive a 1.19.1 key. // Velocity modern forwarding versions: https://github.com/PaperMC/Velocity/blob/1a3fba4250553702d9dcd05731d04347bfc24c9f/proxy/src/main/java/com/velocitypowered/proxy/connection/VelocityConstants.java#L27-L29 @@ -295,7 +296,7 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol(this).registerDeclareCommands1_19(ClientboundPackets1_20_2.COMMANDS); registerClientbound(ClientboundPackets1_20_2.SET_SCORE, wrapper -> { - wrapper.passthrough(Type.STRING); // Owner + wrapper.passthrough(Types.STRING); // Owner - final int action = wrapper.read(Type.VAR_INT); - final String objectiveName = wrapper.read(Type.STRING); + final int action = wrapper.read(Types.VAR_INT); + final String objectiveName = wrapper.read(Types.STRING); if (action == 1) { // Reset score - wrapper.write(Type.OPTIONAL_STRING, objectiveName.isEmpty() ? null : objectiveName); + wrapper.write(Types.OPTIONAL_STRING, objectiveName.isEmpty() ? null : objectiveName); wrapper.setPacketType(ClientboundPackets1_20_3.RESET_SCORE); return; } - wrapper.write(Type.STRING, objectiveName); - wrapper.passthrough(Type.VAR_INT); // Score + wrapper.write(Types.STRING, objectiveName); + wrapper.passthrough(Types.VAR_INT); // Score // Null display and number format - wrapper.write(Type.OPTIONAL_TAG, null); - wrapper.write(Type.BOOLEAN, false); + wrapper.write(Types.OPTIONAL_TAG, null); + wrapper.write(Types.BOOLEAN, false); }); registerClientbound(ClientboundPackets1_20_2.SET_OBJECTIVE, wrapper -> { - wrapper.passthrough(Type.STRING); // Objective Name - final byte action = wrapper.passthrough(Type.BYTE); // Method + wrapper.passthrough(Types.STRING); // Objective Name + final byte action = wrapper.passthrough(Types.BYTE); // Method if (action == 0 || action == 2) { convertComponent(wrapper); // Display Name - wrapper.passthrough(Type.VAR_INT); // Render type - wrapper.write(Type.BOOLEAN, false); // Null number format + wrapper.passthrough(Types.VAR_INT); // Render type + wrapper.write(Types.BOOLEAN, false); // Null number format } }); registerServerbound(ServerboundPackets1_20_3.SET_JIGSAW_BLOCK, wrapper -> { - wrapper.passthrough(Type.POSITION1_14); // Position - wrapper.passthrough(Type.STRING); // Name - wrapper.passthrough(Type.STRING); // Target - wrapper.passthrough(Type.STRING); // Pool - wrapper.passthrough(Type.STRING); // Final state - wrapper.passthrough(Type.STRING); // Joint type - wrapper.read(Type.VAR_INT); // Selection priority - wrapper.read(Type.VAR_INT); // Placement priority + wrapper.passthrough(Types.BLOCK_POSITION1_14); // Position + wrapper.passthrough(Types.STRING); // Name + wrapper.passthrough(Types.STRING); // Target + wrapper.passthrough(Types.STRING); // Pool + wrapper.passthrough(Types.STRING); // Final state + wrapper.passthrough(Types.STRING); // Joint type + wrapper.read(Types.VAR_INT); // Selection priority + wrapper.read(Types.VAR_INT); // Placement priority }); // Components are now (mostly) written as nbt instead of json strings registerClientbound(ClientboundPackets1_20_2.UPDATE_ADVANCEMENTS, wrapper -> { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - final int size = wrapper.passthrough(Type.VAR_INT); // Mapping size + wrapper.passthrough(Types.BOOLEAN); // Reset/clear + final int size = wrapper.passthrough(Types.VAR_INT); // Mapping size for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier - wrapper.passthrough(Type.OPTIONAL_STRING); // Parent + wrapper.passthrough(Types.STRING); // Identifier + wrapper.passthrough(Types.OPTIONAL_STRING); // Parent // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { + if (wrapper.passthrough(Types.BOOLEAN)) { convertComponent(wrapper); // Title convertComponent(wrapper); // Description - itemRewriter.handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_20_2)); // Icon - wrapper.passthrough(Type.VAR_INT); // Frame type - final int flags = wrapper.passthrough(Type.INT); + itemRewriter.handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_20_2)); // Icon + wrapper.passthrough(Types.VAR_INT); // Frame type + final int flags = wrapper.passthrough(Types.INT); if ((flags & 1) != 0) { - wrapper.passthrough(Type.STRING); // Background texture + wrapper.passthrough(Types.STRING); // Background texture } - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y + wrapper.passthrough(Types.FLOAT); // X + wrapper.passthrough(Types.FLOAT); // Y } - final int requirements = wrapper.passthrough(Type.VAR_INT); + final int requirements = wrapper.passthrough(Types.VAR_INT); for (int array = 0; array < requirements; array++) { - wrapper.passthrough(Type.STRING_ARRAY); + wrapper.passthrough(Types.STRING_ARRAY); } - wrapper.passthrough(Type.BOOLEAN); // Send telemetry + wrapper.passthrough(Types.BOOLEAN); // Send telemetry } }); registerClientbound(ClientboundPackets1_20_2.COMMAND_SUGGESTIONS, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Transaction id - wrapper.passthrough(Type.VAR_INT); // Start - wrapper.passthrough(Type.VAR_INT); // Length + wrapper.passthrough(Types.VAR_INT); // Transaction id + wrapper.passthrough(Types.VAR_INT); // Start + wrapper.passthrough(Types.VAR_INT); // Length - final int suggestions = wrapper.passthrough(Type.VAR_INT); + final int suggestions = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < suggestions; i++) { - wrapper.passthrough(Type.STRING); // Suggestion + wrapper.passthrough(Types.STRING); // Suggestion convertOptionalComponent(wrapper); // Tooltip } }); registerClientbound(ClientboundPackets1_20_2.MAP_ITEM_DATA, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Map id - wrapper.passthrough(Type.BYTE); // Scale - wrapper.passthrough(Type.BOOLEAN); // Locked - if (wrapper.passthrough(Type.BOOLEAN)) { - final int icons = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.VAR_INT); // Map id + wrapper.passthrough(Types.BYTE); // Scale + wrapper.passthrough(Types.BOOLEAN); // Locked + if (wrapper.passthrough(Types.BOOLEAN)) { + final int icons = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < icons; i++) { - wrapper.passthrough(Type.VAR_INT); // Type - wrapper.passthrough(Type.BYTE); // X - wrapper.passthrough(Type.BYTE); // Y - wrapper.passthrough(Type.BYTE); // Rotation + wrapper.passthrough(Types.VAR_INT); // Type + wrapper.passthrough(Types.BYTE); // X + wrapper.passthrough(Types.BYTE); // Y + wrapper.passthrough(Types.BYTE); // Rotation convertOptionalComponent(wrapper); // Display name } } }); registerClientbound(ClientboundPackets1_20_2.BOSS_EVENT, wrapper -> { - wrapper.passthrough(Type.UUID); // Id + wrapper.passthrough(Types.UUID); // Id - final int action = wrapper.passthrough(Type.VAR_INT); + final int action = wrapper.passthrough(Types.VAR_INT); if (action == 0 || action == 3) { convertComponent(wrapper); } }); registerClientbound(ClientboundPackets1_20_2.PLAYER_CHAT, wrapper -> { - wrapper.passthrough(Type.UUID); // Sender - wrapper.passthrough(Type.VAR_INT); // Index - wrapper.passthrough(Type.OPTIONAL_SIGNATURE_BYTES); // Signature - wrapper.passthrough(Type.STRING); // Plain content - wrapper.passthrough(Type.LONG); // Timestamp - wrapper.passthrough(Type.LONG); // Salt + wrapper.passthrough(Types.UUID); // Sender + wrapper.passthrough(Types.VAR_INT); // Index + wrapper.passthrough(Types.OPTIONAL_SIGNATURE_BYTES); // Signature + wrapper.passthrough(Types.STRING); // Plain content + wrapper.passthrough(Types.LONG); // Timestamp + wrapper.passthrough(Types.LONG); // Salt - final int lastSeen = wrapper.passthrough(Type.VAR_INT); + final int lastSeen = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < lastSeen; i++) { - final int index = wrapper.passthrough(Type.VAR_INT); + final int index = wrapper.passthrough(Types.VAR_INT); if (index == 0) { - wrapper.passthrough(Type.SIGNATURE_BYTES); + wrapper.passthrough(Types.SIGNATURE_BYTES); } } convertOptionalComponent(wrapper); // Unsigned content - final int filterMaskType = wrapper.passthrough(Type.VAR_INT); + final int filterMaskType = wrapper.passthrough(Types.VAR_INT); if (filterMaskType == 2) { - wrapper.passthrough(Type.LONG_ARRAY_PRIMITIVE); // Mask + wrapper.passthrough(Types.LONG_ARRAY_PRIMITIVE); // Mask } - wrapper.passthrough(Type.VAR_INT); // Chat type + wrapper.passthrough(Types.VAR_INT); // Chat type convertComponent(wrapper); // Sender convertOptionalComponent(wrapper); // Target }); registerClientbound(ClientboundPackets1_20_2.SET_PLAYER_TEAM, wrapper -> { - wrapper.passthrough(Type.STRING); // Team Name - final byte action = wrapper.passthrough(Type.BYTE); // Mode + wrapper.passthrough(Types.STRING); // Team Name + final byte action = wrapper.passthrough(Types.BYTE); // Mode if (action == 0 || action == 2) { convertComponent(wrapper); // Display Name - wrapper.passthrough(Type.BYTE); // Flags - wrapper.passthrough(Type.STRING); // Name Tag Visibility - wrapper.passthrough(Type.STRING); // Collision rule - wrapper.passthrough(Type.VAR_INT); // Color + wrapper.passthrough(Types.BYTE); // Flags + wrapper.passthrough(Types.STRING); // Name Tag Visibility + wrapper.passthrough(Types.STRING); // Collision rule + wrapper.passthrough(Types.VAR_INT); // Color convertComponent(wrapper); // Prefix convertComponent(wrapper); // Suffix } @@ -236,16 +237,16 @@ public final class Protocol1_20_2To1_20_3 extends AbstractProtocol { convertComponent(wrapper); - wrapper.passthrough(Type.VAR_INT); // Chat type + wrapper.passthrough(Types.VAR_INT); // Chat type convertComponent(wrapper); // Name convertOptionalComponent(wrapper); // Target name }); registerClientbound(ClientboundPackets1_20_2.SYSTEM_CHAT, this::convertComponent); registerClientbound(ClientboundPackets1_20_2.OPEN_SCREEN, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Container id + wrapper.passthrough(Types.VAR_INT); // Container id - final int containerTypeId = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT, MAPPINGS.getMenuMappings().getNewId(containerTypeId)); + final int containerTypeId = wrapper.read(Types.VAR_INT); + wrapper.write(Types.VAR_INT, MAPPINGS.getMenuMappings().getNewId(containerTypeId)); convertComponent(wrapper); }); @@ -257,37 +258,37 @@ public final class Protocol1_20_2To1_20_3 extends AbstractProtocol convertComponent(wrapper)); } }); registerClientbound(ClientboundPackets1_20_2.PLAYER_INFO_UPDATE, wrapper -> { - final BitSet actions = wrapper.passthrough(Type.PROFILE_ACTIONS_ENUM); - final int entries = wrapper.passthrough(Type.VAR_INT); + final BitSet actions = wrapper.passthrough(Types.PROFILE_ACTIONS_ENUM); + final int entries = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < entries; i++) { - wrapper.passthrough(Type.UUID); + wrapper.passthrough(Types.UUID); if (actions.get(0)) { - wrapper.passthrough(Type.STRING); // Player Name + wrapper.passthrough(Types.STRING); // Player Name - final int properties = wrapper.passthrough(Type.VAR_INT); + final int properties = wrapper.passthrough(Types.VAR_INT); for (int j = 0; j < properties; j++) { - wrapper.passthrough(Type.STRING); // Name - wrapper.passthrough(Type.STRING); // Value - wrapper.passthrough(Type.OPTIONAL_STRING); // Signature + wrapper.passthrough(Types.STRING); // Name + wrapper.passthrough(Types.STRING); // Value + wrapper.passthrough(Types.OPTIONAL_STRING); // Signature } } - if (actions.get(1) && wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.UUID); // Session UUID - wrapper.passthrough(Type.PROFILE_KEY); + if (actions.get(1) && wrapper.passthrough(Types.BOOLEAN)) { + wrapper.passthrough(Types.UUID); // Session UUID + wrapper.passthrough(Types.PROFILE_KEY); } if (actions.get(2)) { - wrapper.passthrough(Type.VAR_INT); // Gamemode + wrapper.passthrough(Types.VAR_INT); // Gamemode } if (actions.get(3)) { - wrapper.passthrough(Type.BOOLEAN); // Listed + wrapper.passthrough(Types.BOOLEAN); // Listed } if (actions.get(4)) { - wrapper.passthrough(Type.VAR_INT); // Latency + wrapper.passthrough(Types.VAR_INT); // Latency } if (actions.get(5)) { convertOptionalComponent(wrapper); // Display name @@ -304,15 +305,15 @@ public final class Protocol1_20_2To1_20_3 extends AbstractProtocol { - wrapper.read(Type.UUID); // Pack UUID + wrapper.read(Types.UUID); // Pack UUID - final int action = wrapper.read(Type.VAR_INT); + final int action = wrapper.read(Types.VAR_INT); if (action == 4) { // Downloaded wrapper.cancel(); } else if (action > 4) { // Invalid url, failed reload, and discarded - wrapper.write(Type.VAR_INT, 2); // Failed download + wrapper.write(Types.VAR_INT, 2); // Failed download } else { - wrapper.write(Type.VAR_INT, action); + wrapper.write(Types.VAR_INT, action); } }; } @@ -321,26 +322,26 @@ public final class Protocol1_20_2To1_20_3 extends AbstractProtocol { // Drop old resource packs first final PacketWrapper dropPacksPacket = wrapper.create(popType); - dropPacksPacket.write(Type.OPTIONAL_UUID, null); + dropPacksPacket.write(Types.OPTIONAL_UUID, null); dropPacksPacket.send(Protocol1_20_2To1_20_3.class); // Use the hash to write a pack uuid - final String url = wrapper.read(Type.STRING); - final String hash = wrapper.read(Type.STRING); - wrapper.write(Type.UUID, UUID.nameUUIDFromBytes(url.getBytes(StandardCharsets.UTF_8))); - wrapper.write(Type.STRING, url); - wrapper.write(Type.STRING, hash); - wrapper.passthrough(Type.BOOLEAN); // Required + final String url = wrapper.read(Types.STRING); + final String hash = wrapper.read(Types.STRING); + wrapper.write(Types.UUID, UUID.nameUUIDFromBytes(url.getBytes(StandardCharsets.UTF_8))); + wrapper.write(Types.STRING, url); + wrapper.write(Types.STRING, hash); + wrapper.passthrough(Types.BOOLEAN); // Required convertOptionalComponent(wrapper); }; } private void convertComponent(final PacketWrapper wrapper) { - wrapper.write(Type.TAG, ComponentUtil.jsonToTag(wrapper.read(Type.COMPONENT))); + wrapper.write(Types.TAG, ComponentUtil.jsonToTag(wrapper.read(Types.COMPONENT))); } private void convertOptionalComponent(final PacketWrapper wrapper) { - wrapper.write(Type.OPTIONAL_TAG, ComponentUtil.jsonToTag(wrapper.read(Type.OPTIONAL_COMPONENT))); + wrapper.write(Types.OPTIONAL_TAG, ComponentUtil.jsonToTag(wrapper.read(Types.OPTIONAL_COMPONENT))); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java index 3140af77d..b549968ef 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java @@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; import com.viaversion.viaversion.api.type.types.version.Types1_20_3; import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundPacket1_20_2; @@ -48,7 +49,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; 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); + super(protocol, Types.ITEM1_20_2, Types.ITEM1_20_2_ARRAY); } @Override @@ -73,25 +74,25 @@ public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter { - final int id = wrapper.get(Type.VAR_INT, 0); + final int id = wrapper.get(Types.VAR_INT, 0); final ParticleMappings particleMappings = protocol.getMappingData().getParticleMappings(); if (id == particleMappings.id("vibration")) { - final String resourceLocation = Key.stripMinecraftNamespace(wrapper.read(Type.STRING)); - wrapper.write(Type.VAR_INT, resourceLocation.equals("block") ? 0 : 1); + final String resourceLocation = Key.stripMinecraftNamespace(wrapper.read(Types.STRING)); + wrapper.write(Types.VAR_INT, resourceLocation.equals("block") ? 0 : 1); } }); - handler(getSpawnParticleHandler(Type.VAR_INT)); + handler(getSpawnParticleHandler(Types.VAR_INT)); } }); @@ -99,43 +100,43 @@ public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter { - wrapper.passthrough(Type.DOUBLE); // X - wrapper.passthrough(Type.DOUBLE); // Y - wrapper.passthrough(Type.DOUBLE); // Z - wrapper.passthrough(Type.FLOAT); // Power - final int blocks = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.DOUBLE); // X + wrapper.passthrough(Types.DOUBLE); // Y + wrapper.passthrough(Types.DOUBLE); // Z + wrapper.passthrough(Types.FLOAT); // Power + final int blocks = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < blocks; i++) { - wrapper.passthrough(Type.BYTE); // Relative X - wrapper.passthrough(Type.BYTE); // Relative Y - wrapper.passthrough(Type.BYTE); // Relative Z + wrapper.passthrough(Types.BYTE); // Relative X + wrapper.passthrough(Types.BYTE); // Relative Y + wrapper.passthrough(Types.BYTE); // Relative Z } - wrapper.passthrough(Type.FLOAT); // Knockback X - wrapper.passthrough(Type.FLOAT); // Knockback Y - wrapper.passthrough(Type.FLOAT); // Knockback Z + wrapper.passthrough(Types.FLOAT); // Knockback X + wrapper.passthrough(Types.FLOAT); // Knockback Y + wrapper.passthrough(Types.FLOAT); // Knockback Z - wrapper.write(Type.VAR_INT, 1); // Block interaction type - Destroy + wrapper.write(Types.VAR_INT, 1); // Block interaction type - Destroy wrapper.write(Types1_20_3.PARTICLE, new Particle(protocol.getMappingData().getParticleMappings().mappedId("explosion"))); // Small explosion particle wrapper.write(Types1_20_3.PARTICLE, new Particle(protocol.getMappingData().getParticleMappings().mappedId("explosion_emitter"))); // Large explosion particle - wrapper.write(Type.STRING, "minecraft:entity.generic.explode"); // Explosion sound - wrapper.write(Type.OPTIONAL_FLOAT, null); // Sound range + wrapper.write(Types.STRING, "minecraft:entity.generic.explode"); // Explosion sound + wrapper.write(Types.OPTIONAL_FLOAT, null); // Sound range }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/EntityPacketRewriter1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/EntityPacketRewriter1_20_3.java index 3c1aee2d3..ad3ba1bd1 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/EntityPacketRewriter1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/EntityPacketRewriter1_20_3.java @@ -25,6 +25,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; 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.v1_20to1_20_2.packet.ClientboundConfigurationPackets1_20_2; @@ -51,7 +52,7 @@ public final class EntityPacketRewriter1_20_3 extends EntityRewriter sendChunksSentGameEvent(wrapper)); } @@ -79,8 +80,8 @@ public final class EntityPacketRewriter1_20_3 extends EntityRewriter sendChunksSentGameEvent(wrapper)); } @@ -96,8 +97,8 @@ public final class EntityPacketRewriter1_20_3 extends EntityRewriterremoveArgument(0).getValue(); if (Key.stripMinecraftNamespace(resourceLocation).equals("block")) { - particle.add(0, Type.VAR_INT, 0); + particle.add(0, Types.VAR_INT, 0); } else { // Entity - particle.add(0, Type.VAR_INT, 1); + particle.add(0, Types.VAR_INT, 1); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/RecipeRewriter1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/RecipeRewriter1_20_3.java index e4bc0625a..85ac0e454 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/RecipeRewriter1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/RecipeRewriter1_20_3.java @@ -22,6 +22,7 @@ import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.rewriter.RecipeRewriter1_19_4; public class RecipeRewriter1_20_3 extends RecipeRewriter1_19_4 { @@ -32,16 +33,16 @@ public class RecipeRewriter1_20_3 extends Recip @Override public void handleCraftingShaped(final PacketWrapper wrapper) { - wrapper.passthrough(Type.STRING); // Group - wrapper.passthrough(Type.VAR_INT); // Crafting book category - final int ingredients = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.STRING); // Group + wrapper.passthrough(Types.VAR_INT); // Crafting book category + final int ingredients = wrapper.passthrough(Types.VAR_INT) * wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < ingredients; i++) { handleIngredient(wrapper); } final Item item = rewrite(wrapper.user(), wrapper.read(itemType())); // Result wrapper.write(mappedItemType(), item); - wrapper.passthrough(Type.BOOLEAN); // Show notification + wrapper.passthrough(Types.BOOLEAN); // Show notification } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/Protocol1_20_3To1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/Protocol1_20_3To1_20_5.java index 9e51582df..82225b346 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/Protocol1_20_3To1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/Protocol1_20_3To1_20_5.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider; import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -92,18 +93,18 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol { - wrapper.passthrough(Type.STRING); // Server ID - wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); // Public key - wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); // Challenge - wrapper.write(Type.BOOLEAN, true); // Authenticate + wrapper.passthrough(Types.STRING); // Server ID + wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE); // Public key + wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE); // Challenge + wrapper.write(Types.BOOLEAN, true); // Authenticate }); registerClientbound(ClientboundPackets1_20_3.SERVER_DATA, wrapper -> { - wrapper.passthrough(Type.TAG); // MOTD - wrapper.passthrough(Type.OPTIONAL_BYTE_ARRAY_PRIMITIVE); // Icon + wrapper.passthrough(Types.TAG); // MOTD + wrapper.passthrough(Types.OPTIONAL_BYTE_ARRAY_PRIMITIVE); // Icon // Moved to join game - final boolean enforcesSecureChat = wrapper.read(Type.BOOLEAN); + final boolean enforcesSecureChat = wrapper.read(Types.BOOLEAN); final AcknowledgedMessagesStorage storage = wrapper.user().get(AcknowledgedMessagesStorage.class); storage.setSecureChatEnforced(enforcesSecureChat); if (enforcesSecureChat) { @@ -115,9 +116,9 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol { - wrapper.passthrough(Type.UUID); // Sender - wrapper.passthrough(Type.VAR_INT); // Index - final byte[] signature = wrapper.passthrough(Type.OPTIONAL_SIGNATURE_BYTES); + wrapper.passthrough(Types.UUID); // Sender + wrapper.passthrough(Types.VAR_INT); // Index + final byte[] signature = wrapper.passthrough(Types.OPTIONAL_SIGNATURE_BYTES); if (signature == null) { return; } @@ -126,64 +127,64 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol 64) { final PacketWrapper chatAck = wrapper.create(ServerboundPackets1_20_3.CHAT_ACK); - chatAck.write(Type.VAR_INT, storage.offset()); + chatAck.write(Types.VAR_INT, storage.offset()); chatAck.sendToServer(Protocol1_20_3To1_20_5.class); storage.clearOffset(); } }); registerServerbound(ServerboundPackets1_20_5.CHAT, wrapper -> { - wrapper.passthrough(Type.STRING); // Message - wrapper.passthrough(Type.LONG); // Timestamp + wrapper.passthrough(Types.STRING); // Message + wrapper.passthrough(Types.LONG); // Timestamp final AcknowledgedMessagesStorage storage = wrapper.user().get(AcknowledgedMessagesStorage.class); - final long salt = wrapper.read(Type.LONG); - final byte[] signature = wrapper.read(Type.OPTIONAL_SIGNATURE_BYTES); + final long salt = wrapper.read(Types.LONG); + final byte[] signature = wrapper.read(Types.OPTIONAL_SIGNATURE_BYTES); if (storage.isSecureChatEnforced()) { // Fake it till you make it - wrapper.write(Type.LONG, salt); - wrapper.write(Type.OPTIONAL_SIGNATURE_BYTES, signature); + wrapper.write(Types.LONG, salt); + wrapper.write(Types.OPTIONAL_SIGNATURE_BYTES, signature); } else { // Go the safer route and strip the signature. No signature means no verification - wrapper.write(Type.LONG, 0L); - wrapper.write(Type.OPTIONAL_SIGNATURE_BYTES, null); + wrapper.write(Types.LONG, 0L); + wrapper.write(Types.OPTIONAL_SIGNATURE_BYTES, null); } replaceChatAck(wrapper, storage); }); registerServerbound(ServerboundPackets1_20_5.CHAT_COMMAND_SIGNED, ServerboundPackets1_20_3.CHAT_COMMAND, wrapper -> { - wrapper.passthrough(Type.STRING); // Command - wrapper.passthrough(Type.LONG); // Timestamp + wrapper.passthrough(Types.STRING); // Command + wrapper.passthrough(Types.LONG); // Timestamp // See above, strip signatures if we can to prevent verification of possibly bad signatures final AcknowledgedMessagesStorage storage = wrapper.user().get(AcknowledgedMessagesStorage.class); - final long salt = wrapper.read(Type.LONG); - final int signatures = wrapper.read(Type.VAR_INT); + final long salt = wrapper.read(Types.LONG); + final int signatures = wrapper.read(Types.VAR_INT); if (storage.isSecureChatEnforced()) { - wrapper.write(Type.LONG, salt); - wrapper.write(Type.VAR_INT, signatures); + wrapper.write(Types.LONG, salt); + wrapper.write(Types.VAR_INT, signatures); for (int i = 0; i < signatures; i++) { - wrapper.passthrough(Type.STRING); // Argument name - wrapper.passthrough(Type.SIGNATURE_BYTES); // Signature + wrapper.passthrough(Types.STRING); // Argument name + wrapper.passthrough(Types.SIGNATURE_BYTES); // Signature } } else { // Remove signatures - wrapper.write(Type.LONG, 0L); - wrapper.write(Type.VAR_INT, 0); // No signatures + wrapper.write(Types.LONG, 0L); + wrapper.write(Types.VAR_INT, 0); // No signatures for (int i = 0; i < signatures; i++) { - wrapper.read(Type.STRING); // Argument name - wrapper.read(Type.SIGNATURE_BYTES); // Signature + wrapper.read(Types.STRING); // Argument name + wrapper.read(Types.SIGNATURE_BYTES); // Signature } } replaceChatAck(wrapper, storage); }); registerServerbound(ServerboundPackets1_20_5.CHAT_COMMAND, wrapper -> { - wrapper.passthrough(Type.STRING); // Command + wrapper.passthrough(Types.STRING); // Command - wrapper.write(Type.LONG, System.currentTimeMillis()); // Timestamp - wrapper.write(Type.LONG, 0L); // Salt - wrapper.write(Type.VAR_INT, 0); // No signatures + wrapper.write(Types.LONG, System.currentTimeMillis()); // Timestamp + wrapper.write(Types.LONG, 0L); // Salt + wrapper.write(Types.VAR_INT, 0); // No signatures writeChatAck(wrapper, wrapper.user().get(AcknowledgedMessagesStorage.class)); }); @@ -196,8 +197,8 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol(this).registerDeclareCommands1_19(ClientboundPackets1_20_3.COMMANDS); registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE, wrapper -> { - wrapper.passthrough(Type.UUID); // UUID - wrapper.passthrough(Type.STRING); // Name + wrapper.passthrough(Types.UUID); // UUID + wrapper.passthrough(Types.STRING); // Name - final int properties = wrapper.passthrough(Type.VAR_INT); + final int properties = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < properties; i++) { - wrapper.passthrough(Type.STRING); // Name - wrapper.passthrough(Type.STRING); // Value - wrapper.passthrough(Type.OPTIONAL_STRING); // Signature + wrapper.passthrough(Types.STRING); // Name + wrapper.passthrough(Types.STRING); // Value + wrapper.passthrough(Types.OPTIONAL_STRING); // Signature } - wrapper.write(Type.BOOLEAN, strictErrorHandling); + wrapper.write(Types.BOOLEAN, strictErrorHandling); }); cancelServerbound(State.LOGIN, ServerboundLoginPackets.COOKIE_RESPONSE.getId()); @@ -230,14 +231,14 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol { - wrapper.passthrough(Type.POSITION1_14); // Position + wrapper.passthrough(Types.BLOCK_POSITION1_14); // Position - final int typeId = wrapper.passthrough(Type.VAR_INT); + final int typeId = wrapper.passthrough(Types.VAR_INT); if (isUnknownBlockEntity(typeId)) { wrapper.cancel(); return; } - CompoundTag tag = wrapper.read(Type.COMPOUND_TAG); + CompoundTag tag = wrapper.read(Types.COMPOUND_TAG); if (tag != null) { updateBlockEntityTag(wrapper.user(), null, tag); } else { // No longer nullable tag = new CompoundTag(); } - wrapper.write(Type.COMPOUND_TAG, tag); + wrapper.write(Types.COMPOUND_TAG, tag); }); registerSetCooldown(ClientboundPackets1_20_3.COOLDOWN); @@ -179,144 +180,144 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter { - final byte containerId = wrapper.read(Type.VAR_INT).byteValue(); - final byte buttonId = wrapper.read(Type.VAR_INT).byteValue(); - wrapper.write(Type.BYTE, containerId); - wrapper.write(Type.BYTE, buttonId); + final byte containerId = wrapper.read(Types.VAR_INT).byteValue(); + final byte buttonId = wrapper.read(Types.VAR_INT).byteValue(); + wrapper.write(Types.BYTE, containerId); + wrapper.write(Types.BYTE, buttonId); }); protocol.registerClientbound(ClientboundPackets1_20_3.UPDATE_ADVANCEMENTS, wrapper -> { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - int size = wrapper.passthrough(Type.VAR_INT); // Mapping size + wrapper.passthrough(Types.BOOLEAN); // Reset/clear + int size = wrapper.passthrough(Types.VAR_INT); // Mapping size for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier - wrapper.passthrough(Type.OPTIONAL_STRING); // Parent + wrapper.passthrough(Types.STRING); // Identifier + wrapper.passthrough(Types.OPTIONAL_STRING); // Parent // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.TAG); // Title - wrapper.passthrough(Type.TAG); // Description + if (wrapper.passthrough(Types.BOOLEAN)) { + wrapper.passthrough(Types.TAG); // Title + wrapper.passthrough(Types.TAG); // Description Item item = handleNonNullItemToClient(wrapper.user(), wrapper.read(itemType())); wrapper.write(mappedItemType(), item); - wrapper.passthrough(Type.VAR_INT); // Frame type - int flags = wrapper.passthrough(Type.INT); // Flags + wrapper.passthrough(Types.VAR_INT); // Frame type + int flags = wrapper.passthrough(Types.INT); // Flags if ((flags & 1) != 0) { - wrapper.passthrough(Type.STRING); // Background texture + wrapper.passthrough(Types.STRING); // Background texture } - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y + wrapper.passthrough(Types.FLOAT); // X + wrapper.passthrough(Types.FLOAT); // Y } - int requirements = wrapper.passthrough(Type.VAR_INT); + int requirements = wrapper.passthrough(Types.VAR_INT); for (int array = 0; array < requirements; array++) { - wrapper.passthrough(Type.STRING_ARRAY); + wrapper.passthrough(Types.STRING_ARRAY); } - wrapper.passthrough(Type.BOOLEAN); // Send telemetry + wrapper.passthrough(Types.BOOLEAN); // Send telemetry } }); protocol.registerClientbound(ClientboundPackets1_20_3.LEVEL_PARTICLES, wrapper -> { - final int particleId = wrapper.read(Type.VAR_INT); + final int particleId = wrapper.read(Types.VAR_INT); - wrapper.passthrough(Type.BOOLEAN); // Long Distance - wrapper.passthrough(Type.DOUBLE); // X - wrapper.passthrough(Type.DOUBLE); // Y - wrapper.passthrough(Type.DOUBLE); // Z - wrapper.passthrough(Type.FLOAT); // Offset X - wrapper.passthrough(Type.FLOAT); // Offset Y - wrapper.passthrough(Type.FLOAT); // Offset Z - final float data = wrapper.passthrough(Type.FLOAT); - wrapper.passthrough(Type.INT); // Particle Count + wrapper.passthrough(Types.BOOLEAN); // Long Distance + wrapper.passthrough(Types.DOUBLE); // X + wrapper.passthrough(Types.DOUBLE); // Y + wrapper.passthrough(Types.DOUBLE); // Z + wrapper.passthrough(Types.FLOAT); // Offset X + wrapper.passthrough(Types.FLOAT); // Offset Y + wrapper.passthrough(Types.FLOAT); // Offset Z + final float data = wrapper.passthrough(Types.FLOAT); + wrapper.passthrough(Types.INT); // Particle Count // Read data and add it to Particle final ParticleMappings mappings = protocol.getMappingData().getParticleMappings(); final int mappedId = mappings.getNewId(particleId); final Particle particle = new Particle(mappedId); if (mappedId == mappings.mappedId("entity_effect")) { - particle.add(Type.INT, data != 0 ? ThreadLocalRandom.current().nextInt() : 0); // rgb + particle.add(Types.INT, data != 0 ? ThreadLocalRandom.current().nextInt() : 0); // rgb } else if (particleId == mappings.id("dust_color_transition")) { for (int i = 0; i < 7; i++) { - particle.add(Type.FLOAT, wrapper.read(Type.FLOAT)); + particle.add(Types.FLOAT, wrapper.read(Types.FLOAT)); } // fromColor, scale, toColor -> fromColor, toColor, scale - particle.add(Type.FLOAT, particle.removeArgument(3).getValue()); + particle.add(Types.FLOAT, particle.removeArgument(3).getValue()); } else if (mappings.isBlockParticle(particleId)) { - final int blockStateId = wrapper.read(Type.VAR_INT); - particle.add(Type.VAR_INT, protocol.getMappingData().getNewBlockStateId(blockStateId)); + final int blockStateId = wrapper.read(Types.VAR_INT); + particle.add(Types.VAR_INT, protocol.getMappingData().getNewBlockStateId(blockStateId)); } else if (mappings.isItemParticle(particleId)) { - final Item item = handleNonNullItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_20_2)); + final Item item = handleNonNullItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_20_2)); particle.add(Types1_20_5.ITEM, item); } else if (particleId == mappings.id("dust")) { // R, g, b, scale for (int i = 0; i < 4; i++) { - particle.add(Type.FLOAT, wrapper.read(Type.FLOAT)); + particle.add(Types.FLOAT, wrapper.read(Types.FLOAT)); } } else if (particleId == mappings.id("vibration")) { - final int sourceTypeId = wrapper.read(Type.VAR_INT); - particle.add(Type.VAR_INT, sourceTypeId); + final int sourceTypeId = wrapper.read(Types.VAR_INT); + particle.add(Types.VAR_INT, sourceTypeId); if (sourceTypeId == 0) { // Block - particle.add(Type.POSITION1_14, wrapper.read(Type.POSITION1_14)); // Target block pos + particle.add(Types.BLOCK_POSITION1_14, wrapper.read(Types.BLOCK_POSITION1_14)); // Target block pos } else if (sourceTypeId == 1) { // Entity - particle.add(Type.VAR_INT, wrapper.read(Type.VAR_INT)); // Target entity - particle.add(Type.FLOAT, wrapper.read(Type.FLOAT)); // Y offset + particle.add(Types.VAR_INT, wrapper.read(Types.VAR_INT)); // Target entity + particle.add(Types.FLOAT, wrapper.read(Types.FLOAT)); // Y offset } else { Via.getPlatform().getLogger().warning("Unknown vibration path position source type: " + sourceTypeId); } - particle.add(Type.VAR_INT, wrapper.read(Type.VAR_INT)); // Arrival in ticks + particle.add(Types.VAR_INT, wrapper.read(Types.VAR_INT)); // Arrival in ticks } else if (particleId == mappings.id("sculk_charge")) { - particle.add(Type.FLOAT, wrapper.read(Type.FLOAT)); // Roll + particle.add(Types.FLOAT, wrapper.read(Types.FLOAT)); // Roll } else if (particleId == mappings.id("shriek")) { - particle.add(Type.VAR_INT, wrapper.read(Type.VAR_INT)); // Delay + particle.add(Types.VAR_INT, wrapper.read(Types.VAR_INT)); // Delay } wrapper.write(Types1_20_5.PARTICLE, particle); }); protocol.registerClientbound(ClientboundPackets1_20_3.EXPLODE, wrapper -> { - wrapper.passthrough(Type.DOUBLE); // X - wrapper.passthrough(Type.DOUBLE); // Y - wrapper.passthrough(Type.DOUBLE); // Z - wrapper.passthrough(Type.FLOAT); // Power - final int blocks = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.DOUBLE); // X + wrapper.passthrough(Types.DOUBLE); // Y + wrapper.passthrough(Types.DOUBLE); // Z + wrapper.passthrough(Types.FLOAT); // Power + final int blocks = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < blocks; i++) { - wrapper.passthrough(Type.BYTE); // Relative X - wrapper.passthrough(Type.BYTE); // Relative Y - wrapper.passthrough(Type.BYTE); // Relative Z + wrapper.passthrough(Types.BYTE); // Relative X + wrapper.passthrough(Types.BYTE); // Relative Y + wrapper.passthrough(Types.BYTE); // Relative Z } - wrapper.passthrough(Type.FLOAT); // Knockback X - wrapper.passthrough(Type.FLOAT); // Knockback Y - wrapper.passthrough(Type.FLOAT); // Knockback Z - wrapper.passthrough(Type.VAR_INT); // Block interaction type + wrapper.passthrough(Types.FLOAT); // Knockback X + wrapper.passthrough(Types.FLOAT); // Knockback Y + wrapper.passthrough(Types.FLOAT); // Knockback Z + wrapper.passthrough(Types.VAR_INT); // Block interaction type protocol.getEntityRewriter().rewriteParticle(wrapper, Types1_20_3.PARTICLE, Types1_20_5.PARTICLE); // Small explosion particle protocol.getEntityRewriter().rewriteParticle(wrapper, Types1_20_3.PARTICLE, Types1_20_5.PARTICLE); // Large explosion particle - wrapper.write(Type.VAR_INT, 0); // "Empty" registry id to instead use the resource location that follows after + wrapper.write(Types.VAR_INT, 0); // "Empty" registry id to instead use the resource location that follows after }); protocol.registerClientbound(ClientboundPackets1_20_3.MERCHANT_OFFERS, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Container id - final int size = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.VAR_INT); // Container id + final int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { - final Item input = handleItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_20_2)); + final Item input = handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_20_2)); wrapper.write(Types1_20_5.ITEM_COST, input); - final Item output = handleNonNullItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_20_2)); + final Item output = handleNonNullItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_20_2)); wrapper.write(Types1_20_5.ITEM, output); - final Item secondInput = handleItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_20_2)); + final Item secondInput = handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_20_2)); wrapper.write(Types1_20_5.OPTIONAL_ITEM_COST, secondInput); - wrapper.passthrough(Type.BOOLEAN); // Out of stock - wrapper.passthrough(Type.INT); // Number of trade uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses - wrapper.passthrough(Type.INT); // XP - wrapper.passthrough(Type.INT); // Special price - wrapper.passthrough(Type.FLOAT); // Price multiplier - wrapper.passthrough(Type.INT); // Demand + wrapper.passthrough(Types.BOOLEAN); // Out of stock + wrapper.passthrough(Types.INT); // Number of trade uses + wrapper.passthrough(Types.INT); // Maximum number of trade uses + wrapper.passthrough(Types.INT); // XP + wrapper.passthrough(Types.INT); // Special price + wrapper.passthrough(Types.FLOAT); // Price multiplier + wrapper.passthrough(Types.INT); // Demand } }); @@ -332,13 +333,13 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter { - final int size = wrapper.passthrough(Type.VAR_INT); + final int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { // Change order and write the type as an int - final String type = wrapper.read(Type.STRING); - wrapper.passthrough(Type.STRING); // Recipe Identifier + final String type = wrapper.read(Types.STRING); + wrapper.passthrough(Types.STRING); // Recipe Identifier - wrapper.write(Type.VAR_INT, protocol.getMappingData().getRecipeSerializerMappings().mappedId(type)); + wrapper.write(Types.VAR_INT, protocol.getMappingData().getRecipeSerializerMappings().mappedId(type)); recipeRewriter.handleRecipeType(wrapper, Key.stripMinecraftNamespace(type)); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java index 9b4ee46fb..84ebf3144 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java @@ -33,6 +33,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_20_3; import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundConfigurationPackets1_20_3; @@ -75,10 +76,10 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter { final PacketWrapper knownPacksPacket = wrapper.create(ClientboundConfigurationPackets1_20_5.SELECT_KNOWN_PACKS); - knownPacksPacket.write(Type.VAR_INT, 0); // No known packs, everything is sent here + knownPacksPacket.write(Types.VAR_INT, 0); // No known packs, everything is sent here knownPacksPacket.send(Protocol1_20_3To1_20_5.class); - final CompoundTag registryData = wrapper.read(Type.COMPOUND_TAG); + final CompoundTag registryData = wrapper.read(Types.COMPOUND_TAG); cacheDimensionData(wrapper.user(), registryData); trackBiomeSize(wrapper.user(), registryData); @@ -172,8 +173,8 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter(StringTag.class)); - wolfVariantsPacket.write(Type.REGISTRY_ENTRY_ARRAY, new RegistryEntry[]{new RegistryEntry("minecraft:pale", paleWolf)}); + wolfVariantsPacket.write(Types.REGISTRY_ENTRY_ARRAY, new RegistryEntry[]{new RegistryEntry("minecraft:pale", paleWolf)}); wolfVariantsPacket.send(Protocol1_20_3To1_20_5.class); final PacketWrapper bannerPatternsPacket = wrapper.create(ClientboundConfigurationPackets1_20_5.REGISTRY_DATA); - bannerPatternsPacket.write(Type.STRING, "minecraft:banner_pattern"); + bannerPatternsPacket.write(Types.STRING, "minecraft:banner_pattern"); final RegistryEntry[] patternEntries = new RegistryEntry[BannerPatterns1_20_5.keys().length]; final String[] keys = BannerPatterns1_20_5.keys(); for (int i = 0; i < keys.length; i++) { @@ -202,35 +203,35 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter { - final String dimensionKey = wrapper.read(Type.STRING); + final String dimensionKey = wrapper.read(Types.STRING); final DimensionData data = tracker(wrapper.user()).dimensionData(dimensionKey); - wrapper.write(Type.VAR_INT, data.id()); + wrapper.write(Types.VAR_INT, data.id()); }); - map(Type.STRING); // World - map(Type.LONG); // Seed - map(Type.BYTE); // Gamemode - map(Type.BYTE); // Previous gamemode - map(Type.BOOLEAN); // Debug - map(Type.BOOLEAN); // Flat - map(Type.OPTIONAL_GLOBAL_POSITION); // Last death location - map(Type.VAR_INT); // Portal cooldown + map(Types.STRING); // World + map(Types.LONG); // Seed + map(Types.BYTE); // Gamemode + map(Types.BYTE); // Previous gamemode + map(Types.BOOLEAN); // Debug + map(Types.BOOLEAN); // Flat + map(Types.OPTIONAL_GLOBAL_POSITION); // Last death location + map(Types.VAR_INT); // Portal cooldown handler(worldDataTrackerHandlerByKey1_20_5(3)); // Tracks world height and name for chunk data and entity (un)tracking handler(playerTrackerHandler()); handler(wrapper -> { @@ -238,15 +239,15 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter { - final String dimensionKey = wrapper.read(Type.STRING); + final String dimensionKey = wrapper.read(Types.STRING); final DimensionData data = tracker(wrapper.user()).dimensionData(dimensionKey); - wrapper.write(Type.VAR_INT, data.id()); + wrapper.write(Types.VAR_INT, data.id()); - wrapper.passthrough(Type.STRING); // World + wrapper.passthrough(Types.STRING); // World worldDataTrackerHandlerByKey1_20_5(0).handle(wrapper); // Tracks world height and name for chunk data and entity (un)tracking - wrapper.passthrough(Type.LONG); // Seed + wrapper.passthrough(Types.LONG); // Seed - final byte gamemode = wrapper.passthrough(Type.BYTE); + final byte gamemode = wrapper.passthrough(Types.BYTE); sendRangeAttributes(wrapper.user(), gamemode == CREATIVE_MODE_ID); }); protocol.registerClientbound(ClientboundPackets1_20_3.UPDATE_MOB_EFFECT, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Entity ID - wrapper.passthrough(Type.VAR_INT); // Effect ID + wrapper.passthrough(Types.VAR_INT); // Entity ID + wrapper.passthrough(Types.VAR_INT); // Effect ID - final byte amplifier = wrapper.read(Type.BYTE); - wrapper.write(Type.VAR_INT, (int) amplifier); + final byte amplifier = wrapper.read(Types.BYTE); + wrapper.write(Types.VAR_INT, (int) amplifier); - wrapper.passthrough(Type.VAR_INT); // Duration - wrapper.passthrough(Type.BYTE); // Flags - wrapper.read(Type.OPTIONAL_COMPOUND_TAG); // Remove factor data + wrapper.passthrough(Types.VAR_INT); // Duration + wrapper.passthrough(Types.BYTE); // Flags + wrapper.read(Types.OPTIONAL_COMPOUND_TAG); // Remove factor data }); protocol.registerClientbound(ClientboundPackets1_20_3.UPDATE_ATTRIBUTES, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Entity ID - final int size = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.VAR_INT); // Entity ID + final int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { // From a string to a registry int ID - final String attributeIdentifier = wrapper.read(Type.STRING); + final String attributeIdentifier = wrapper.read(Types.STRING); final int mappedId = Attributes1_20_5.keyToId(attributeIdentifier); - wrapper.write(Type.VAR_INT, mappedId != -1 ? mappedId : 0); + wrapper.write(Types.VAR_INT, mappedId != -1 ? mappedId : 0); - wrapper.passthrough(Type.DOUBLE); // Base - final int modifierSize = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.DOUBLE); // Base + final int modifierSize = wrapper.passthrough(Types.VAR_INT); for (int j = 0; j < modifierSize; j++) { - wrapper.passthrough(Type.UUID); // ID - wrapper.passthrough(Type.DOUBLE); // Amount - wrapper.passthrough(Type.BYTE); // Operation + wrapper.passthrough(Types.UUID); // ID + wrapper.passthrough(Types.DOUBLE); // Amount + wrapper.passthrough(Types.BYTE); // Operation } } }); protocol.registerClientbound(ClientboundPackets1_20_3.GAME_EVENT, wrapper -> { // If the gamemode changed to/from creative, update the range attribute - final short event = wrapper.passthrough(Type.UNSIGNED_BYTE); + final short event = wrapper.passthrough(Types.UNSIGNED_BYTE); if (event != 3) { return; } // Resend attributes either with their original list or with the creative range modifier added - final float value = wrapper.passthrough(Type.FLOAT); + final float value = wrapper.passthrough(Types.FLOAT); sendRangeAttributes(wrapper.user(), value == CREATIVE_MODE_ID); }); } @@ -364,25 +365,25 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter { - final String channel = Key.namespaced(wrapper.get(Type.STRING, 0)); + final String channel = Key.namespaced(wrapper.get(Types.STRING, 0)); if (channel.equals("minecraft:brand")) { - wrapper.passthrough(Type.STRING); + wrapper.passthrough(Types.STRING); wrapper.clearInputBuffer(); } }); @@ -95,10 +96,10 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol { - final String url = wrapper.passthrough(Type.STRING); - final String hash = wrapper.passthrough(Type.STRING); - final boolean required = wrapper.passthrough(Type.BOOLEAN); - final JsonElement prompt = wrapper.passthrough(Type.OPTIONAL_COMPONENT); + final String url = wrapper.passthrough(Types.STRING); + final String hash = wrapper.passthrough(Types.STRING); + final boolean required = wrapper.passthrough(Types.BOOLEAN); + final JsonElement prompt = wrapper.passthrough(Types.OPTIONAL_COMPONENT); wrapper.user().put(new LastResourcePack(url, hash, required, prompt)); }); @@ -114,15 +115,15 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol { - final byte slot = wrapper.read(Type.BYTE); - wrapper.write(Type.VAR_INT, (int) slot); + final byte slot = wrapper.read(Types.BYTE); + wrapper.write(Types.VAR_INT, (int) slot); }); registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), wrapper -> { - wrapper.passthrough(Type.STRING); // Name + wrapper.passthrough(Types.STRING); // Name - final UUID uuid = wrapper.read(Type.UUID); - wrapper.write(Type.OPTIONAL_UUID, uuid); + final UUID uuid = wrapper.read(Types.UUID); + wrapper.write(Types.OPTIONAL_UUID, uuid); }); // Deal with the new CONFIGURATION protocol state the client expects @@ -159,14 +160,14 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol { final ConfigurationState.ClientInformation clientInformation = new ConfigurationState.ClientInformation( - wrapper.read(Type.STRING), // Language - wrapper.read(Type.BYTE), // View distance - wrapper.read(Type.VAR_INT), // Chat visibility - wrapper.read(Type.BOOLEAN), // Chat colors - wrapper.read(Type.UNSIGNED_BYTE), // Model customization - wrapper.read(Type.VAR_INT), // Main hand - wrapper.read(Type.BOOLEAN), // Text filtering enabled - wrapper.read(Type.BOOLEAN) // Allow listing in server list preview + wrapper.read(Types.STRING), // Language + wrapper.read(Types.BYTE), // View distance + wrapper.read(Types.VAR_INT), // Chat visibility + wrapper.read(Types.BOOLEAN), // Chat colors + wrapper.read(Types.UNSIGNED_BYTE), // Model customization + wrapper.read(Types.VAR_INT), // Main hand + wrapper.read(Types.BOOLEAN), // Text filtering enabled + wrapper.read(Types.BOOLEAN) // Allow listing in server list preview ); // Store it to re-send it when another ClientboundLoginPacket is sent, since the client will only send it @@ -204,10 +205,10 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol { wrapper.cancel(); - final long time = wrapper.read(Type.LONG); + final long time = wrapper.read(Types.LONG); final PacketWrapper responsePacket = wrapper.create(ClientboundPackets1_20_2.PONG_RESPONSE); - responsePacket.write(Type.LONG, time); + responsePacket.write(Types.LONG, time); responsePacket.sendFuture(Protocol1_20To1_20_2.class); }); } @@ -294,7 +295,7 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol { public BlockItemPacketRewriter1_20_2(final Protocol1_20To1_20_2 protocol) { - super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_ARRAY); + super(protocol, Types.ITEM1_13_2, Types.ITEM1_13_2_ARRAY); } @Override @@ -64,29 +65,29 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter { // Effects start at 1 before 1.20.2 - if (wrapper.passthrough(Type.BOOLEAN)) { // Primary effect - wrapper.write(Type.VAR_INT, wrapper.read(Type.VAR_INT) + 1); + if (wrapper.passthrough(Types.BOOLEAN)) { // Primary effect + wrapper.write(Types.VAR_INT, wrapper.read(Types.VAR_INT) + 1); } - if (wrapper.passthrough(Type.BOOLEAN)) { // Secondary effect - wrapper.write(Type.VAR_INT, wrapper.read(Type.VAR_INT) + 1); + if (wrapper.passthrough(Types.BOOLEAN)) { // Secondary effect + wrapper.write(Types.VAR_INT, wrapper.read(Types.VAR_INT) + 1); } }); protocol.registerClientbound(ClientboundPackets1_19_4.FORGET_LEVEL_CHUNK, wrapper -> { - final int x = wrapper.read(Type.INT); - final int z = wrapper.read(Type.INT); - wrapper.write(Type.CHUNK_POSITION, new ChunkPosition(x, z)); + final int x = wrapper.read(Types.INT); + final int z = wrapper.read(Types.INT); + wrapper.write(Types.CHUNK_POSITION, new ChunkPosition(x, z)); }); protocol.registerClientbound(ClientboundPackets1_19_4.TAG_QUERY, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Transaction id - wrapper.write(Type.COMPOUND_TAG, wrapper.read(Type.NAMED_COMPOUND_TAG)); + wrapper.passthrough(Types.VAR_INT); // Transaction id + wrapper.write(Types.COMPOUND_TAG, wrapper.read(Types.NAMED_COMPOUND_TAG)); }); protocol.registerClientbound(ClientboundPackets1_19_4.BLOCK_ENTITY_DATA, wrapper -> { - wrapper.passthrough(Type.POSITION1_14); // Position - wrapper.passthrough(Type.VAR_INT); // Type - wrapper.write(Type.COMPOUND_TAG, handleBlockEntity(wrapper.read(Type.NAMED_COMPOUND_TAG))); + wrapper.passthrough(Types.BLOCK_POSITION1_14); // Position + wrapper.passthrough(Types.VAR_INT); // Type + wrapper.write(Types.COMPOUND_TAG, handleBlockEntity(wrapper.read(Types.NAMED_COMPOUND_TAG))); }); protocol.registerClientbound(ClientboundPackets1_19_4.LEVEL_CHUNK_WITH_LIGHT, wrapper -> { @@ -118,68 +119,68 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter { - final Item[] items = wrapper.read(Type.ITEM1_13_2_ARRAY); + final Item[] items = wrapper.read(Types.ITEM1_13_2_ARRAY); for (final Item item : items) { handleItemToClient(wrapper.user(), item); } - wrapper.write(Type.ITEM1_20_2_ARRAY, items); - wrapper.write(Type.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_13_2))); // Carried item + wrapper.write(Types.ITEM1_20_2_ARRAY, items); + wrapper.write(Types.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_13_2))); // Carried item }); } }); protocol.registerClientbound(ClientboundPackets1_19_4.CONTAINER_SET_SLOT, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); // Window id - map(Type.VAR_INT); // State id - map(Type.SHORT); // Slot id - handler(wrapper -> wrapper.write(Type.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_13_2)))); + map(Types.UNSIGNED_BYTE); // Window id + map(Types.VAR_INT); // State id + map(Types.SHORT); // Slot id + handler(wrapper -> wrapper.write(Types.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_13_2)))); } }); protocol.registerClientbound(ClientboundPackets1_19_4.UPDATE_ADVANCEMENTS, wrapper -> { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - final int size = wrapper.passthrough(Type.VAR_INT); // Mapping size + wrapper.passthrough(Types.BOOLEAN); // Reset/clear + final int size = wrapper.passthrough(Types.VAR_INT); // Mapping size for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier - wrapper.passthrough(Type.OPTIONAL_STRING); // Parent + wrapper.passthrough(Types.STRING); // Identifier + wrapper.passthrough(Types.OPTIONAL_STRING); // Parent // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.COMPONENT); // Title - wrapper.passthrough(Type.COMPONENT); // Description - wrapper.write(Type.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_13_2))); // Icon - wrapper.passthrough(Type.VAR_INT); // Frame type - final int flags = wrapper.passthrough(Type.INT); // Flags + if (wrapper.passthrough(Types.BOOLEAN)) { + wrapper.passthrough(Types.COMPONENT); // Title + wrapper.passthrough(Types.COMPONENT); // Description + wrapper.write(Types.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_13_2))); // Icon + wrapper.passthrough(Types.VAR_INT); // Frame type + final int flags = wrapper.passthrough(Types.INT); // Flags if ((flags & 1) != 0) { - wrapper.passthrough(Type.STRING); // Background texture + wrapper.passthrough(Types.STRING); // Background texture } - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y + wrapper.passthrough(Types.FLOAT); // X + wrapper.passthrough(Types.FLOAT); // Y } // Remove criterion triggers - wrapper.read(Type.STRING_ARRAY); // Criteria + wrapper.read(Types.STRING_ARRAY); // Criteria - final int requirements = wrapper.passthrough(Type.VAR_INT); + final int requirements = wrapper.passthrough(Types.VAR_INT); for (int array = 0; array < requirements; array++) { - wrapper.passthrough(Type.STRING_ARRAY); + wrapper.passthrough(Types.STRING_ARRAY); } - wrapper.passthrough(Type.BOOLEAN); // Send telemetry + wrapper.passthrough(Types.BOOLEAN); // Send telemetry } }); protocol.registerClientbound(ClientboundPackets1_19_4.SET_EQUIPMENT, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID + map(Types.VAR_INT); // 0 - Entity ID handler(wrapper -> { byte slot; do { - slot = wrapper.passthrough(Type.BYTE); - wrapper.write(Type.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_13_2))); + slot = wrapper.passthrough(Types.BYTE); + wrapper.write(Types.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_13_2))); } while ((slot & 0xFFFFFF80) != 0); }); } @@ -187,71 +188,71 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter { // Affected items - final int length = wrapper.passthrough(Type.VAR_INT); + final int length = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < length; i++) { - wrapper.passthrough(Type.SHORT); // Slot - wrapper.write(Type.ITEM1_13_2, handleItemToServer(wrapper.user(), wrapper.read(Type.ITEM1_20_2))); + wrapper.passthrough(Types.SHORT); // Slot + wrapper.write(Types.ITEM1_13_2, handleItemToServer(wrapper.user(), wrapper.read(Types.ITEM1_20_2))); } // Carried item - wrapper.write(Type.ITEM1_13_2, handleItemToServer(wrapper.user(), wrapper.read(Type.ITEM1_20_2))); + wrapper.write(Types.ITEM1_13_2, handleItemToServer(wrapper.user(), wrapper.read(Types.ITEM1_20_2))); }); } }); protocol.registerClientbound(ClientboundPackets1_19_4.MERCHANT_OFFERS, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Container id - final int size = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.VAR_INT); // Container id + final int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { - wrapper.write(Type.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_13_2))); // Input - wrapper.write(Type.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_13_2))); // Output - wrapper.write(Type.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_13_2))); // Second Item + wrapper.write(Types.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_13_2))); // Input + wrapper.write(Types.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_13_2))); // Output + wrapper.write(Types.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_13_2))); // Second Item - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses + wrapper.passthrough(Types.BOOLEAN); // Trade disabled + wrapper.passthrough(Types.INT); // Number of tools uses + wrapper.passthrough(Types.INT); // Maximum number of trade uses - wrapper.passthrough(Type.INT); // XP - wrapper.passthrough(Type.INT); // Special price - wrapper.passthrough(Type.FLOAT); // Price multiplier - wrapper.passthrough(Type.INT); // Demand + wrapper.passthrough(Types.INT); // XP + wrapper.passthrough(Types.INT); // Special price + wrapper.passthrough(Types.FLOAT); // Price multiplier + wrapper.passthrough(Types.INT); // Demand } }); protocol.registerServerbound(ServerboundPackets1_20_2.SET_CREATIVE_MODE_SLOT, new PacketHandlers() { @Override public void register() { - map(Type.SHORT); // 0 - Slot - handler(wrapper -> wrapper.write(Type.ITEM1_13_2, handleItemToServer(wrapper.user(), wrapper.read(Type.ITEM1_20_2)))); // 1 - Clicked Item + map(Types.SHORT); // 0 - Slot + handler(wrapper -> wrapper.write(Types.ITEM1_13_2, handleItemToServer(wrapper.user(), wrapper.read(Types.ITEM1_20_2)))); // 1 - Clicked Item } }); protocol.registerClientbound(ClientboundPackets1_19_4.LEVEL_PARTICLES, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Particle ID - map(Type.BOOLEAN); // 1 - Long Distance - map(Type.DOUBLE); // 2 - X - map(Type.DOUBLE); // 3 - Y - map(Type.DOUBLE); // 4 - Z - map(Type.FLOAT); // 5 - Offset X - map(Type.FLOAT); // 6 - Offset Y - map(Type.FLOAT); // 7 - Offset Z - map(Type.FLOAT); // 8 - Particle Data - map(Type.INT); // 9 - Particle Count + map(Types.VAR_INT); // 0 - Particle ID + map(Types.BOOLEAN); // 1 - Long Distance + map(Types.DOUBLE); // 2 - X + map(Types.DOUBLE); // 3 - Y + map(Types.DOUBLE); // 4 - Z + map(Types.FLOAT); // 5 - Offset X + map(Types.FLOAT); // 6 - Offset Y + map(Types.FLOAT); // 7 - Offset Z + map(Types.FLOAT); // 8 - Particle Data + map(Types.INT); // 9 - Particle Count handler(wrapper -> { - final int id = wrapper.get(Type.VAR_INT, 0); + final int id = wrapper.get(Types.VAR_INT, 0); final ParticleMappings mappings = Protocol1_20To1_20_2.MAPPINGS.getParticleMappings(); if (mappings.isBlockParticle(id)) { - final int data = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewBlockStateId(data)); + final int data = wrapper.read(Types.VAR_INT); + wrapper.write(Types.VAR_INT, protocol.getMappingData().getNewBlockStateId(data)); } else if (mappings.isItemParticle(id)) { - wrapper.write(Type.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Type.ITEM1_13_2))); + wrapper.write(Types.ITEM1_20_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_13_2))); } }); } @@ -260,53 +261,53 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter(protocol) { @Override public void handleCraftingShapeless(final PacketWrapper wrapper) { - wrapper.passthrough(Type.STRING); // Group - wrapper.passthrough(Type.VAR_INT); // Crafting book category + wrapper.passthrough(Types.STRING); // Group + wrapper.passthrough(Types.VAR_INT); // Crafting book category handleIngredients(wrapper); final Item result = wrapper.read(itemType()); rewrite(wrapper.user(), result); - wrapper.write(Type.ITEM1_20_2, result); + wrapper.write(Types.ITEM1_20_2, result); } @Override public void handleSmelting(final PacketWrapper wrapper) { - wrapper.passthrough(Type.STRING); // Group - wrapper.passthrough(Type.VAR_INT); // Crafting book category + wrapper.passthrough(Types.STRING); // Group + wrapper.passthrough(Types.VAR_INT); // Crafting book category handleIngredient(wrapper); final Item result = wrapper.read(itemType()); rewrite(wrapper.user(), result); - wrapper.write(Type.ITEM1_20_2, result); + wrapper.write(Types.ITEM1_20_2, result); - wrapper.passthrough(Type.FLOAT); // EXP - wrapper.passthrough(Type.VAR_INT); // Cooking time + wrapper.passthrough(Types.FLOAT); // EXP + wrapper.passthrough(Types.VAR_INT); // Cooking time } @Override public void handleCraftingShaped(final PacketWrapper wrapper) { - final int ingredients = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.STRING); // Group - wrapper.passthrough(Type.VAR_INT); // Crafting book category + final int ingredients = wrapper.passthrough(Types.VAR_INT) * wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.STRING); // Group + wrapper.passthrough(Types.VAR_INT); // Crafting book category for (int i = 0; i < ingredients; i++) { handleIngredient(wrapper); } final Item result = wrapper.read(itemType()); rewrite(wrapper.user(), result); - wrapper.write(Type.ITEM1_20_2, result); + wrapper.write(Types.ITEM1_20_2, result); - wrapper.passthrough(Type.BOOLEAN); // Show notification + wrapper.passthrough(Types.BOOLEAN); // Show notification } @Override public void handleStonecutting(final PacketWrapper wrapper) { - wrapper.passthrough(Type.STRING); // Group + wrapper.passthrough(Types.STRING); // Group handleIngredient(wrapper); final Item result = wrapper.read(itemType()); rewrite(wrapper.user(), result); - wrapper.write(Type.ITEM1_20_2, result); + wrapper.write(Types.ITEM1_20_2, result); } @Override @@ -316,7 +317,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter { - wrapper.passthrough(Type.VAR_INT); // Entity id - wrapper.passthrough(Type.UUID); // UUID + wrapper.passthrough(Types.VAR_INT); // Entity id + wrapper.passthrough(Types.UUID); // UUID - wrapper.write(Type.VAR_INT, EntityTypes1_19_4.PLAYER.getId()); // Entity type id + wrapper.write(Types.VAR_INT, EntityTypes1_19_4.PLAYER.getId()); // Entity type id - wrapper.passthrough(Type.DOUBLE); // X - wrapper.passthrough(Type.DOUBLE); // Y - wrapper.passthrough(Type.DOUBLE); // Z + wrapper.passthrough(Types.DOUBLE); // X + wrapper.passthrough(Types.DOUBLE); // Y + wrapper.passthrough(Types.DOUBLE); // Z - final byte yaw = wrapper.read(Type.BYTE); // Yaw - wrapper.passthrough(Type.BYTE); // Pitch - wrapper.write(Type.BYTE, yaw); - wrapper.write(Type.BYTE, yaw); // Head yaw - wrapper.write(Type.VAR_INT, 0); // Data - wrapper.write(Type.SHORT, (short) 0); // Velocity X - wrapper.write(Type.SHORT, (short) 0); // Velocity Y - wrapper.write(Type.SHORT, (short) 0); // Velocity Z + final byte yaw = wrapper.read(Types.BYTE); // Yaw + wrapper.passthrough(Types.BYTE); // Pitch + wrapper.write(Types.BYTE, yaw); + wrapper.write(Types.BYTE, yaw); // Head yaw + wrapper.write(Types.VAR_INT, 0); // Data + wrapper.write(Types.SHORT, (short) 0); // Velocity X + wrapper.write(Types.SHORT, (short) 0); // Velocity Y + wrapper.write(Types.SHORT, (short) 0); // Velocity Z }); protocol.registerClientbound(ClientboundPackets1_19_4.LOGIN, new PacketHandlers() { @@ -68,33 +69,33 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter { // Just reorder written data, move dimension data to configuration phase - wrapper.passthrough(Type.INT); // Entity id - wrapper.passthrough(Type.BOOLEAN); // Hardcore + wrapper.passthrough(Types.INT); // Entity id + wrapper.passthrough(Types.BOOLEAN); // Hardcore - final byte gamemode = wrapper.read(Type.BYTE); - final byte previousGamemode = wrapper.read(Type.BYTE); + final byte gamemode = wrapper.read(Types.BYTE); + final byte previousGamemode = wrapper.read(Types.BYTE); - wrapper.passthrough(Type.STRING_ARRAY); // World List + wrapper.passthrough(Types.STRING_ARRAY); // World List - final CompoundTag dimensionRegistry = wrapper.read(Type.NAMED_COMPOUND_TAG); - final String dimensionType = wrapper.read(Type.STRING); - final String world = wrapper.read(Type.STRING); - final long seed = wrapper.read(Type.LONG); + final CompoundTag dimensionRegistry = wrapper.read(Types.NAMED_COMPOUND_TAG); + final String dimensionType = wrapper.read(Types.STRING); + final String world = wrapper.read(Types.STRING); + final long seed = wrapper.read(Types.LONG); trackBiomeSize(wrapper.user(), dimensionRegistry); // Caches dimensions to access data like height later cacheDimensionData(wrapper.user(), dimensionRegistry); // Tracks the amount of biomes sent for chunk data - wrapper.passthrough(Type.VAR_INT); // Max players - wrapper.passthrough(Type.VAR_INT); // View distance - wrapper.passthrough(Type.VAR_INT); // Simulation distance - wrapper.passthrough(Type.BOOLEAN); // Reduced debug info - wrapper.passthrough(Type.BOOLEAN); // Show death screen + wrapper.passthrough(Types.VAR_INT); // Max players + wrapper.passthrough(Types.VAR_INT); // View distance + wrapper.passthrough(Types.VAR_INT); // Simulation distance + wrapper.passthrough(Types.BOOLEAN); // Reduced debug info + wrapper.passthrough(Types.BOOLEAN); // Show death screen - wrapper.write(Type.BOOLEAN, false); // Limited crafting - wrapper.write(Type.STRING, dimensionType); - wrapper.write(Type.STRING, world); - wrapper.write(Type.LONG, seed); - wrapper.write(Type.BYTE, gamemode); - wrapper.write(Type.BYTE, previousGamemode); + wrapper.write(Types.BOOLEAN, false); // Limited crafting + wrapper.write(Types.STRING, dimensionType); + wrapper.write(Types.STRING, world); + wrapper.write(Types.LONG, seed); + wrapper.write(Types.BYTE, gamemode); + wrapper.write(Types.BYTE, previousGamemode); // Debug, flat, last death pos, and portal cooldown at the end unchanged @@ -135,38 +136,38 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter { - wrapper.passthrough(Type.STRING); // Dimension type - wrapper.passthrough(Type.STRING); // World - wrapper.passthrough(Type.LONG); // Seed - wrapper.write(Type.BYTE, wrapper.read(Type.UNSIGNED_BYTE).byteValue()); // Gamemode - wrapper.passthrough(Type.BYTE); // Previous gamemode - wrapper.passthrough(Type.BOOLEAN); // Debug - wrapper.passthrough(Type.BOOLEAN); // Flat + wrapper.passthrough(Types.STRING); // Dimension type + wrapper.passthrough(Types.STRING); // World + wrapper.passthrough(Types.LONG); // Seed + wrapper.write(Types.BYTE, wrapper.read(Types.UNSIGNED_BYTE).byteValue()); // Gamemode + wrapper.passthrough(Types.BYTE); // Previous gamemode + wrapper.passthrough(Types.BOOLEAN); // Debug + wrapper.passthrough(Types.BOOLEAN); // Flat // Move this to the end - final byte dataToKeep = wrapper.read(Type.BYTE); + final byte dataToKeep = wrapper.read(Types.BYTE); - wrapper.passthrough(Type.OPTIONAL_GLOBAL_POSITION); // Last death position - wrapper.passthrough(Type.VAR_INT); // Portal cooldown + wrapper.passthrough(Types.OPTIONAL_GLOBAL_POSITION); // Last death position + wrapper.passthrough(Types.VAR_INT); // Portal cooldown - wrapper.write(Type.BYTE, dataToKeep); + wrapper.write(Types.BYTE, dataToKeep); }); handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking } }); protocol.registerClientbound(ClientboundPackets1_19_4.UPDATE_MOB_EFFECT, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Entity id - wrapper.write(Type.VAR_INT, wrapper.read(Type.VAR_INT) - 1); // Effect id - wrapper.passthrough(Type.BYTE); // Amplifier - wrapper.passthrough(Type.VAR_INT); // Duration - wrapper.passthrough(Type.BYTE); // Flags - wrapper.write(Type.OPTIONAL_COMPOUND_TAG, wrapper.read(Type.OPTIONAL_NAMED_COMPOUND_TAG)); // Factor data + wrapper.passthrough(Types.VAR_INT); // Entity id + wrapper.write(Types.VAR_INT, wrapper.read(Types.VAR_INT) - 1); // Effect id + wrapper.passthrough(Types.BYTE); // Amplifier + wrapper.passthrough(Types.VAR_INT); // Duration + wrapper.passthrough(Types.BYTE); // Flags + wrapper.write(Types.OPTIONAL_COMPOUND_TAG, wrapper.read(Types.OPTIONAL_NAMED_COMPOUND_TAG)); // Factor data }); protocol.registerClientbound(ClientboundPackets1_19_4.REMOVE_MOB_EFFECT, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Entity id - wrapper.write(Type.VAR_INT, wrapper.read(Type.VAR_INT) - 1); // Effect id + wrapper.passthrough(Types.VAR_INT); // Entity id + wrapper.write(Types.VAR_INT, wrapper.read(Types.VAR_INT) - 1); // Effect id }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/rewriter/RecipeRewriter1_20_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/rewriter/RecipeRewriter1_20_2.java index 54c919ba3..d106c3a38 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/rewriter/RecipeRewriter1_20_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/rewriter/RecipeRewriter1_20_2.java @@ -21,6 +21,7 @@ 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.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.rewriter.RecipeRewriter1_19_4; public class RecipeRewriter1_20_2 extends RecipeRewriter1_19_4 { @@ -31,11 +32,11 @@ public class RecipeRewriter1_20_2 extends Recip @Override protected Type itemType() { - return Type.ITEM1_20_2; + return Types.ITEM1_20_2; } @Override protected Type itemArrayType() { - return Type.ITEM1_20_2_ARRAY; + return Types.ITEM1_20_2_ARRAY; } } \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/storage/ConfigurationState.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/storage/ConfigurationState.java index d339b06bf..47dd51e7f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/storage/ConfigurationState.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/storage/ConfigurationState.java @@ -23,6 +23,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.PacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ServerboundPackets1_19_4; import com.viaversion.viaversion.protocols.v1_20to1_20_2.Protocol1_20To1_20_2; import io.netty.buffer.ByteBuf; @@ -163,14 +164,14 @@ public class ConfigurationState implements StorableObject { } final PacketWrapper settingsPacket = PacketWrapper.create(ServerboundPackets1_19_4.CLIENT_INFORMATION, connection); - settingsPacket.write(Type.STRING, clientInformation.language); - settingsPacket.write(Type.BYTE, clientInformation.viewDistance); - settingsPacket.write(Type.VAR_INT, clientInformation.chatVisibility); - settingsPacket.write(Type.BOOLEAN, clientInformation.showChatColors); - settingsPacket.write(Type.UNSIGNED_BYTE, clientInformation.modelCustomization); - settingsPacket.write(Type.VAR_INT, clientInformation.mainHand); - settingsPacket.write(Type.BOOLEAN, clientInformation.textFiltering); - settingsPacket.write(Type.BOOLEAN, clientInformation.allowListing); + settingsPacket.write(Types.STRING, clientInformation.language); + settingsPacket.write(Types.BYTE, clientInformation.viewDistance); + settingsPacket.write(Types.VAR_INT, clientInformation.chatVisibility); + settingsPacket.write(Types.BOOLEAN, clientInformation.showChatColors); + settingsPacket.write(Types.UNSIGNED_BYTE, clientInformation.modelCustomization); + settingsPacket.write(Types.VAR_INT, clientInformation.mainHand); + settingsPacket.write(Types.BOOLEAN, clientInformation.textFiltering); + settingsPacket.write(Types.BOOLEAN, clientInformation.allowListing); return settingsPacket; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/storage/LastTags.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/storage/LastTags.java index 34cc5afc8..0a339c5f3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/storage/LastTags.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/storage/LastTags.java @@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_20to1_20_2.Protocol1_20To1_20_2; import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundConfigurationPackets1_20_2; import java.util.ArrayList; @@ -32,14 +33,14 @@ public class LastTags implements StorableObject { private final List registryTags = new ArrayList<>(); public LastTags(final PacketWrapper wrapper) { - final int length = wrapper.passthrough(Type.VAR_INT); + final int length = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < length; i++) { final List tags = new ArrayList<>(); - final String registryKey = wrapper.passthrough(Type.STRING); - final int tagsSize = wrapper.passthrough(Type.VAR_INT); + final String registryKey = wrapper.passthrough(Types.STRING); + final int tagsSize = wrapper.passthrough(Types.VAR_INT); for (int j = 0; j < tagsSize; j++) { - final String key = wrapper.passthrough(Type.STRING); - final int[] ids = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); + final String key = wrapper.passthrough(Types.STRING); + final int[] ids = wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE); tags.add(new Tag(key, ids)); } @@ -53,13 +54,13 @@ public class LastTags implements StorableObject { } final PacketWrapper packet = PacketWrapper.create(ClientboundConfigurationPackets1_20_2.UPDATE_TAGS, connection); - packet.write(Type.VAR_INT, registryTags.size()); + packet.write(Types.VAR_INT, registryTags.size()); for (final RegistryTags registryTag : registryTags) { - packet.write(Type.STRING, registryTag.registryKey); - packet.write(Type.VAR_INT, registryTag.tags.size()); + packet.write(Types.STRING, registryTag.registryKey); + packet.write(Types.VAR_INT, registryTag.tags.size()); for (final Tag tag : registryTag.tags) { - packet.write(Type.STRING, tag.key); - packet.write(Type.VAR_INT_ARRAY_PRIMITIVE, Arrays.copyOf(tag.ids, tag.ids.length)); + packet.write(Types.STRING, tag.key); + packet.write(Types.VAR_INT_ARRAY_PRIMITIVE, Arrays.copyOf(tag.ids, tag.ids.length)); } } packet.send(Protocol1_20To1_20_2.class); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/Protocol1_8To1_9.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/Protocol1_8To1_9.java index b2a82225b..56c94fdd0 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/Protocol1_8To1_9.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/Protocol1_8To1_9.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets; import com.viaversion.viaversion.protocols.v1_8.packet.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.v1_8.packet.ServerboundPackets1_8; @@ -56,7 +57,7 @@ import com.viaversion.viaversion.util.SerializerVersion; public class Protocol1_8To1_9 extends AbstractProtocol { - public static final ValueTransformer STRING_TO_JSON = new ValueTransformer<>(Type.COMPONENT) { + public static final ValueTransformer STRING_TO_JSON = new ValueTransformer<>(Types.COMPONENT) { @Override public JsonElement transform(PacketWrapper wrapper, String line) { return ComponentUtil.convertJsonOrEmpty(line, SerializerVersion.V1_8, SerializerVersion.V1_9); @@ -89,12 +90,12 @@ public class Protocol1_8To1_9 extends AbstractProtocol { - if (wrapper.isReadable(Type.COMPONENT, 0)) { + if (wrapper.isReadable(Types.COMPONENT, 0)) { // Already written as component in the base protocol return; } - STRING_TO_JSON.write(wrapper, wrapper.read(Type.STRING)); + STRING_TO_JSON.write(wrapper, wrapper.read(Types.STRING)); }); // Other Handlers diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/metadata/MetaIndex.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/metadata/MetaIndex.java index e2bd88f49..e40b5e151 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/metadata/MetaIndex.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/metadata/MetaIndex.java @@ -31,163 +31,163 @@ import static com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10.E public enum MetaIndex { // Entity - ENTITY_STATUS(ENTITY, 0, MetaType1_8.Byte, MetaType1_9.Byte), - ENTITY_AIR(ENTITY, 1, MetaType1_8.Short, MetaType1_9.VarInt), - ENTITY_NAMETAG(ENTITY, 2, MetaType1_8.String, MetaType1_9.String), - ENTITY_ALWAYS_SHOW_NAMETAG(ENTITY, 3, MetaType1_8.Byte, MetaType1_9.Boolean), - ENTITY_SILENT(ENTITY, 4, MetaType1_8.Byte, MetaType1_9.Boolean), + ENTITY_STATUS(ENTITY, 0, MetaType1_8.BYTE, MetaType1_9.BYTE), + ENTITY_AIR(ENTITY, 1, MetaType1_8.SHORT, MetaType1_9.VAR_INT), + ENTITY_NAMETAG(ENTITY, 2, MetaType1_8.STRING, MetaType1_9.STRING), + ENTITY_ALWAYS_SHOW_NAMETAG(ENTITY, 3, MetaType1_8.BYTE, MetaType1_9.BOOLEAN), + ENTITY_SILENT(ENTITY, 4, MetaType1_8.BYTE, MetaType1_9.BOOLEAN), // Living entity // hand state added in 1.9 (5/byte) - LIVING_ENTITY_HEALTH(ENTITY_LIVING, 6, MetaType1_8.Float, MetaType1_9.Float), - LIVING_ENTITY_POTION_EFFECT_COLOR(ENTITY_LIVING, 7, MetaType1_8.Int, MetaType1_9.VarInt), - LIVING_ENTITY_IS_POTION_AMBIENT(ENTITY_LIVING, 8, MetaType1_8.Byte, MetaType1_9.Boolean), - LIVING_ENTITY_NUMBER_OF_ARROWS_IN(ENTITY_LIVING, 9, MetaType1_8.Byte, MetaType1_9.VarInt), + LIVING_ENTITY_HEALTH(ENTITY_LIVING, 6, MetaType1_8.FLOAT, MetaType1_9.FLOAT), + LIVING_ENTITY_POTION_EFFECT_COLOR(ENTITY_LIVING, 7, MetaType1_8.INT, MetaType1_9.VAR_INT), + LIVING_ENTITY_IS_POTION_AMBIENT(ENTITY_LIVING, 8, MetaType1_8.BYTE, MetaType1_9.BOOLEAN), + LIVING_ENTITY_NUMBER_OF_ARROWS_IN(ENTITY_LIVING, 9, MetaType1_8.BYTE, MetaType1_9.VAR_INT), - LIVING_ENTITY_NO_AI(ENTITY_LIVING, 15, MetaType1_8.Byte, 10, MetaType1_9.Byte), + LIVING_ENTITY_NO_AI(ENTITY_LIVING, 15, MetaType1_8.BYTE, 10, MetaType1_9.BYTE), // Ageable entity - AGEABLE_CREATURE_AGE(ENTITY_AGEABLE, 12, MetaType1_8.Byte, 11, MetaType1_9.Boolean), + AGEABLE_CREATURE_AGE(ENTITY_AGEABLE, 12, MetaType1_8.BYTE, 11, MetaType1_9.BOOLEAN), // Armor stand - ARMOR_STAND_INFO(ARMOR_STAND, 10, MetaType1_8.Byte, MetaType1_9.Byte), - ARMOR_STAND_HEAD_POS(ARMOR_STAND, 11, MetaType1_8.Rotation, MetaType1_9.Vector3F), - ARMOR_STAND_BODY_POS(ARMOR_STAND, 12, MetaType1_8.Rotation, MetaType1_9.Vector3F), - ARMOR_STAND_LA_POS(ARMOR_STAND, 13, MetaType1_8.Rotation, MetaType1_9.Vector3F), - ARMOR_STAND_RA_POS(ARMOR_STAND, 14, MetaType1_8.Rotation, MetaType1_9.Vector3F), - ARMOR_STAND_LL_POS(ARMOR_STAND, 15, MetaType1_8.Rotation, MetaType1_9.Vector3F), - ARMOR_STAND_RL_POS(ARMOR_STAND, 16, MetaType1_8.Rotation, MetaType1_9.Vector3F), + ARMOR_STAND_INFO(ARMOR_STAND, 10, MetaType1_8.BYTE, MetaType1_9.BYTE), + ARMOR_STAND_HEAD_POS(ARMOR_STAND, 11, MetaType1_8.ROTATIONS, MetaType1_9.ROTATIONS), + ARMOR_STAND_BODY_POS(ARMOR_STAND, 12, MetaType1_8.ROTATIONS, MetaType1_9.ROTATIONS), + ARMOR_STAND_LA_POS(ARMOR_STAND, 13, MetaType1_8.ROTATIONS, MetaType1_9.ROTATIONS), + ARMOR_STAND_RA_POS(ARMOR_STAND, 14, MetaType1_8.ROTATIONS, MetaType1_9.ROTATIONS), + ARMOR_STAND_LL_POS(ARMOR_STAND, 15, MetaType1_8.ROTATIONS, MetaType1_9.ROTATIONS), + ARMOR_STAND_RL_POS(ARMOR_STAND, 16, MetaType1_8.ROTATIONS, MetaType1_9.ROTATIONS), // Human (player) - PLAYER_SKIN_FLAGS(ENTITY_HUMAN, 10, MetaType1_8.Byte, 12, MetaType1_9.Byte), // unsigned on 1.8 - PLAYER_BYTE(ENTITY_HUMAN, 16, MetaType1_8.Byte, null), // unused on 1.8 - PLAYER_ADDITIONAL_HEARTS(ENTITY_HUMAN, 17, MetaType1_8.Float, 10, MetaType1_9.Float), - PLAYER_SCORE(ENTITY_HUMAN, 18, MetaType1_8.Int, 11, MetaType1_9.VarInt), - PLAYER_HAND(ENTITY_HUMAN, 5, MetaType1_9.Byte), // new in 1.9 + PLAYER_SKIN_FLAGS(ENTITY_HUMAN, 10, MetaType1_8.BYTE, 12, MetaType1_9.BYTE), // unsigned on 1.8 + PLAYER_BYTE(ENTITY_HUMAN, 16, MetaType1_8.BYTE, null), // unused on 1.8 + PLAYER_ADDITIONAL_HEARTS(ENTITY_HUMAN, 17, MetaType1_8.FLOAT, 10, MetaType1_9.FLOAT), + PLAYER_SCORE(ENTITY_HUMAN, 18, MetaType1_8.INT, 11, MetaType1_9.VAR_INT), + PLAYER_HAND(ENTITY_HUMAN, 5, MetaType1_9.BYTE), // new in 1.9 // Horse - HORSE_INFO(HORSE, 16, MetaType1_8.Int, 12, MetaType1_9.Byte), - HORSE_TYPE(HORSE, 19, MetaType1_8.Byte, 13, MetaType1_9.VarInt), - HORSE_SUBTYPE(HORSE, 20, MetaType1_8.Int, 14, MetaType1_9.VarInt), - HORSE_OWNER(HORSE, 21, MetaType1_8.String, 15, MetaType1_9.OptUUID), - HORSE_ARMOR(HORSE, 22, MetaType1_8.Int, 16, MetaType1_9.VarInt), + HORSE_INFO(HORSE, 16, MetaType1_8.INT, 12, MetaType1_9.BYTE), + HORSE_TYPE(HORSE, 19, MetaType1_8.BYTE, 13, MetaType1_9.VAR_INT), + HORSE_SUBTYPE(HORSE, 20, MetaType1_8.INT, 14, MetaType1_9.VAR_INT), + HORSE_OWNER(HORSE, 21, MetaType1_8.STRING, 15, MetaType1_9.OPTIONAL_UUID), + HORSE_ARMOR(HORSE, 22, MetaType1_8.INT, 16, MetaType1_9.VAR_INT), // Bat - BAT_IS_HANGING(BAT, 16, MetaType1_8.Byte, 11, MetaType1_9.Byte), + BAT_IS_HANGING(BAT, 16, MetaType1_8.BYTE, 11, MetaType1_9.BYTE), // Tamable entity - TAMABLE_ANIMAL_ANIMAL_INFO(ENTITY_TAMEABLE_ANIMAL, 16, MetaType1_8.Byte, 12, MetaType1_9.Byte), - TAMABLE_ANIMAL_ANIMAL_OWNER(ENTITY_TAMEABLE_ANIMAL, 17, MetaType1_8.String, 13, MetaType1_9.OptUUID), + TAMABLE_ANIMAL_ANIMAL_INFO(ENTITY_TAMEABLE_ANIMAL, 16, MetaType1_8.BYTE, 12, MetaType1_9.BYTE), + TAMABLE_ANIMAL_ANIMAL_OWNER(ENTITY_TAMEABLE_ANIMAL, 17, MetaType1_8.STRING, 13, MetaType1_9.OPTIONAL_UUID), // Ocelot - OCELOT_TYPE(OCELOT, 18, MetaType1_8.Byte, 14, MetaType1_9.VarInt), + OCELOT_TYPE(OCELOT, 18, MetaType1_8.BYTE, 14, MetaType1_9.VAR_INT), // Wolf - WOLF_HEALTH(WOLF, 18, MetaType1_8.Float, 14, MetaType1_9.Float), - WOLF_BEGGING(WOLF, 19, MetaType1_8.Byte, 15, MetaType1_9.Boolean), - WOLF_COLLAR(WOLF, 20, MetaType1_8.Byte, 16, MetaType1_9.VarInt), + WOLF_HEALTH(WOLF, 18, MetaType1_8.FLOAT, 14, MetaType1_9.FLOAT), + WOLF_BEGGING(WOLF, 19, MetaType1_8.BYTE, 15, MetaType1_9.BOOLEAN), + WOLF_COLLAR(WOLF, 20, MetaType1_8.BYTE, 16, MetaType1_9.VAR_INT), // Pig - PIG_SADDLE(PIG, 16, MetaType1_8.Byte, 12, MetaType1_9.Boolean), + PIG_SADDLE(PIG, 16, MetaType1_8.BYTE, 12, MetaType1_9.BOOLEAN), // Rabbit - RABBIT_TYPE(RABBIT, 18, MetaType1_8.Byte, 12, MetaType1_9.VarInt), + RABBIT_TYPE(RABBIT, 18, MetaType1_8.BYTE, 12, MetaType1_9.VAR_INT), // Sheep - SHEEP_COLOR(SHEEP, 16, MetaType1_8.Byte, 12, MetaType1_9.Byte), + SHEEP_COLOR(SHEEP, 16, MetaType1_8.BYTE, 12, MetaType1_9.BYTE), // Villager - VILLAGER_PROFESSION(VILLAGER, 16, MetaType1_8.Int, 12, MetaType1_9.VarInt), + VILLAGER_PROFESSION(VILLAGER, 16, MetaType1_8.INT, 12, MetaType1_9.VAR_INT), // Enderman - ENDERMAN_BLOCK_STATE(ENDERMAN, 16, MetaType1_8.Short, 11, MetaType1_9.BlockID), - ENDERMAN_BLOCK_DATA(ENDERMAN, 17, MetaType1_8.Byte, null), // always 0 when sent, never read by the client - ENDERMAN_IS_SCREAMING(ENDERMAN, 18, MetaType1_8.Byte, 12, MetaType1_9.Boolean), + ENDERMAN_BLOCK_STATE(ENDERMAN, 16, MetaType1_8.SHORT, 11, MetaType1_9.OPTIONAL_BLOCK_STATE), + ENDERMAN_BLOCK_DATA(ENDERMAN, 17, MetaType1_8.BYTE, null), // always 0 when sent, never read by the client + ENDERMAN_IS_SCREAMING(ENDERMAN, 18, MetaType1_8.BYTE, 12, MetaType1_9.BOOLEAN), // Zombie - ZOMBIE_IS_CHILD(ZOMBIE, 12, MetaType1_8.Byte, 11, MetaType1_9.Boolean), - ZOMBIE_IS_VILLAGER(ZOMBIE, 13, MetaType1_8.Byte, 12, MetaType1_9.VarInt), // now indicates villager type - ZOMBIE_IS_CONVERTING(ZOMBIE, 14, MetaType1_8.Byte, 13, MetaType1_9.Boolean), + ZOMBIE_IS_CHILD(ZOMBIE, 12, MetaType1_8.BYTE, 11, MetaType1_9.BOOLEAN), + ZOMBIE_IS_VILLAGER(ZOMBIE, 13, MetaType1_8.BYTE, 12, MetaType1_9.VAR_INT), // now indicates villager type + ZOMBIE_IS_CONVERTING(ZOMBIE, 14, MetaType1_8.BYTE, 13, MetaType1_9.BOOLEAN), // arms raised added in 1.9 (14/boolean) // Blaze - BLAZE_ON_FIRE(BLAZE, 16, MetaType1_8.Byte, 11, MetaType1_9.Byte), + BLAZE_ON_FIRE(BLAZE, 16, MetaType1_8.BYTE, 11, MetaType1_9.BYTE), // Spider - SPIDER_CLIMBING(SPIDER, 16, MetaType1_8.Byte, 11, MetaType1_9.Byte), + SPIDER_CLIMBING(SPIDER, 16, MetaType1_8.BYTE, 11, MetaType1_9.BYTE), // Creeper - CREEPER_FUSE(CREEPER, 16, MetaType1_8.Byte, 11, MetaType1_9.VarInt), - CREEPER_IS_POWERED(CREEPER, 17, MetaType1_8.Byte, 12, MetaType1_9.Boolean), - CREEPER_IS_IGNITED(CREEPER, 18, MetaType1_8.Byte, 13, MetaType1_9.Boolean), + CREEPER_FUSE(CREEPER, 16, MetaType1_8.BYTE, 11, MetaType1_9.VAR_INT), + CREEPER_IS_POWERED(CREEPER, 17, MetaType1_8.BYTE, 12, MetaType1_9.BOOLEAN), + CREEPER_IS_IGNITED(CREEPER, 18, MetaType1_8.BYTE, 13, MetaType1_9.BOOLEAN), // Ghast - GHAST_IS_ATTACKING(GHAST, 16, MetaType1_8.Byte, 11, MetaType1_9.Boolean), + GHAST_IS_ATTACKING(GHAST, 16, MetaType1_8.BYTE, 11, MetaType1_9.BOOLEAN), // Slime - SLIME_SIZE(SLIME, 16, MetaType1_8.Byte, 11, MetaType1_9.VarInt), + SLIME_SIZE(SLIME, 16, MetaType1_8.BYTE, 11, MetaType1_9.VAR_INT), // Skeleton - SKELETON_TYPE(SKELETON, 13, MetaType1_8.Byte, 11, MetaType1_9.VarInt), + SKELETON_TYPE(SKELETON, 13, MetaType1_8.BYTE, 11, MetaType1_9.VAR_INT), // Witch - WITCH_AGGRESSIVE(WITCH, 21, MetaType1_8.Byte, 11, MetaType1_9.Boolean), + WITCH_AGGRESSIVE(WITCH, 21, MetaType1_8.BYTE, 11, MetaType1_9.BOOLEAN), // Iron golem - IRON_GOLEM_PLAYER_MADE(IRON_GOLEM, 16, MetaType1_8.Byte, 11, MetaType1_9.Byte), + IRON_GOLEM_PLAYER_MADE(IRON_GOLEM, 16, MetaType1_8.BYTE, 11, MetaType1_9.BYTE), // Wither - WITHER_TARGET1(WITHER, 17, MetaType1_8.Int, 11, MetaType1_9.VarInt), - WITHER_TARGET2(WITHER, 18, MetaType1_8.Int, 12, MetaType1_9.VarInt), - WITHER_TARGET3(WITHER, 19, MetaType1_8.Int, 13, MetaType1_9.VarInt), - WITHER_INVULNERABILITY_TIME(WITHER, 20, MetaType1_8.Int, 14, MetaType1_9.VarInt), + WITHER_TARGET1(WITHER, 17, MetaType1_8.INT, 11, MetaType1_9.VAR_INT), + WITHER_TARGET2(WITHER, 18, MetaType1_8.INT, 12, MetaType1_9.VAR_INT), + WITHER_TARGET3(WITHER, 19, MetaType1_8.INT, 13, MetaType1_9.VAR_INT), + WITHER_INVULNERABILITY_TIME(WITHER, 20, MetaType1_8.INT, 14, MetaType1_9.VAR_INT), // Wither skull - WITHER_SKULL_INVULNERABILITY(WITHER_SKULL, 10, MetaType1_8.Byte, 5, MetaType1_9.Boolean), + WITHER_SKULL_INVULNERABILITY(WITHER_SKULL, 10, MetaType1_8.BYTE, 5, MetaType1_9.BOOLEAN), // Guardian - GUARDIAN_INFO(GUARDIAN, 16, MetaType1_8.Int, 11, MetaType1_9.Byte), - GUARDIAN_TARGET(GUARDIAN, 17, MetaType1_8.Int, 12, MetaType1_9.VarInt), + GUARDIAN_INFO(GUARDIAN, 16, MetaType1_8.INT, 11, MetaType1_9.BYTE), + GUARDIAN_TARGET(GUARDIAN, 17, MetaType1_8.INT, 12, MetaType1_9.VAR_INT), // Boat - BOAT_SINCE_HIT(BOAT, 17, MetaType1_8.Int, 5, MetaType1_9.VarInt), - BOAT_FORWARD_DIRECTION(BOAT, 18, MetaType1_8.Int, 6, MetaType1_9.VarInt), - BOAT_DAMAGE_TAKEN(BOAT, 19, MetaType1_8.Float, 7, MetaType1_9.Float), + BOAT_SINCE_HIT(BOAT, 17, MetaType1_8.INT, 5, MetaType1_9.VAR_INT), + BOAT_FORWARD_DIRECTION(BOAT, 18, MetaType1_8.INT, 6, MetaType1_9.VAR_INT), + BOAT_DAMAGE_TAKEN(BOAT, 19, MetaType1_8.FLOAT, 7, MetaType1_9.FLOAT), // boat type added in 1.9 (20/varint) // Minecart - ABSTRACT_MINECART_SHAKING_POWER(MINECART_ABSTRACT, 17, MetaType1_8.Int, 5, MetaType1_9.VarInt), - ABSTRACT_MINECART_SHAKING_DIRECTION(MINECART_ABSTRACT, 18, MetaType1_8.Int, 6, MetaType1_9.VarInt), - ABSTRACT_MINECART_DAMAGE_TAKEN(MINECART_ABSTRACT, 19, MetaType1_8.Float, 7, MetaType1_9.Float), - ABSTRACT_MINECART_BLOCK(MINECART_ABSTRACT, 20, MetaType1_8.Int, 8, MetaType1_9.VarInt), - ABSTRACT_MINECART_BLOCK_Y(MINECART_ABSTRACT, 21, MetaType1_8.Int, 9, MetaType1_9.VarInt), - ABSTRACT_MINECART_SHOW_BLOCK(MINECART_ABSTRACT, 22, MetaType1_8.Byte, 10, MetaType1_9.Boolean), + ABSTRACT_MINECART_SHAKING_POWER(MINECART_ABSTRACT, 17, MetaType1_8.INT, 5, MetaType1_9.VAR_INT), + ABSTRACT_MINECART_SHAKING_DIRECTION(MINECART_ABSTRACT, 18, MetaType1_8.INT, 6, MetaType1_9.VAR_INT), + ABSTRACT_MINECART_DAMAGE_TAKEN(MINECART_ABSTRACT, 19, MetaType1_8.FLOAT, 7, MetaType1_9.FLOAT), + ABSTRACT_MINECART_BLOCK(MINECART_ABSTRACT, 20, MetaType1_8.INT, 8, MetaType1_9.VAR_INT), + ABSTRACT_MINECART_BLOCK_Y(MINECART_ABSTRACT, 21, MetaType1_8.INT, 9, MetaType1_9.VAR_INT), + ABSTRACT_MINECART_SHOW_BLOCK(MINECART_ABSTRACT, 22, MetaType1_8.BYTE, 10, MetaType1_9.BOOLEAN), // Command minecart - MINECART_COMMAND_BLOCK_COMMAND(MINECART_ABSTRACT, 23, MetaType1_8.String, 11, MetaType1_9.String), - MINECART_COMMAND_BLOCK_OUTPUT(MINECART_ABSTRACT, 24, MetaType1_8.String, 12, MetaType1_9.Chat), + MINECART_COMMAND_BLOCK_COMMAND(MINECART_ABSTRACT, 23, MetaType1_8.STRING, 11, MetaType1_9.STRING), + MINECART_COMMAND_BLOCK_OUTPUT(MINECART_ABSTRACT, 24, MetaType1_8.STRING, 12, MetaType1_9.COMPONENT), // Furnace minecart - MINECART_FURNACE_IS_POWERED(MINECART_ABSTRACT, 16, MetaType1_8.Byte, 11, MetaType1_9.Boolean), + MINECART_FURNACE_IS_POWERED(MINECART_ABSTRACT, 16, MetaType1_8.BYTE, 11, MetaType1_9.BOOLEAN), // Item drop - DROPPED_ITEM_ITEM(DROPPED_ITEM, 10, MetaType1_8.Slot, 5, MetaType1_9.Slot), + DROPPED_ITEM_ITEM(DROPPED_ITEM, 10, MetaType1_8.ITEM, 5, MetaType1_9.ITEM), // Arrow - ARROW_IS_CRIT(ARROW, 16, MetaType1_8.Byte, 5, MetaType1_9.Byte), + ARROW_IS_CRIT(ARROW, 16, MetaType1_8.BYTE, 5, MetaType1_9.BYTE), // Firework - FIREWORK_INFO(FIREWORK, 8, MetaType1_8.Slot, 5, MetaType1_9.Slot), + FIREWORK_INFO(FIREWORK, 8, MetaType1_8.ITEM, 5, MetaType1_9.ITEM), // Item frame - ITEM_FRAME_ITEM(ITEM_FRAME, 8, MetaType1_8.Slot, 5, MetaType1_9.Slot), - ITEM_FRAME_ROTATION(ITEM_FRAME, 9, MetaType1_8.Byte, 6, MetaType1_9.VarInt), + ITEM_FRAME_ITEM(ITEM_FRAME, 8, MetaType1_8.ITEM, 5, MetaType1_9.ITEM), + ITEM_FRAME_ROTATION(ITEM_FRAME, 9, MetaType1_8.BYTE, 6, MetaType1_9.VAR_INT), // Ender crystal - ENDER_CRYSTAL_HEALTH(ENDER_CRYSTAL, 8, MetaType1_8.Int, null), + ENDER_CRYSTAL_HEALTH(ENDER_CRYSTAL, 8, MetaType1_8.INT, null), // Ender dragon - ENDER_DRAGON_PHASE(ENDER_DRAGON, 11, MetaType1_9.VarInt); + ENDER_DRAGON_PHASE(ENDER_DRAGON, 11, MetaType1_9.VAR_INT); private static final HashMap, MetaIndex> metadataRewrites = new HashMap<>(); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/metadata/MetadataRewriter1_9To1_8.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/metadata/MetadataRewriter1_9To1_8.java index e36f8eae5..9ef91342e 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/metadata/MetadataRewriter1_9To1_8.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/metadata/MetadataRewriter1_9To1_8.java @@ -64,12 +64,12 @@ public class MetadataRewriter1_9To1_8 extends EntityRewriter out) throws Exception { if (!in.isReadable()) return; - int outLength = Type.VAR_INT.readPrimitive(in); + int outLength = Types.VAR_INT.readPrimitive(in); if (outLength == 0) { out.add(in.readBytes(in.readableBytes())); return; @@ -135,7 +135,7 @@ public class CompressionProvider implements Provider { return; } - Type.VAR_INT.writePrimitive(out, frameLength); + Types.VAR_INT.writePrimitive(out, frameLength); ByteBuf temp = in; if (!in.hasArray()) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/providers/MovementTransmitterProvider.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/providers/MovementTransmitterProvider.java index bb4ceead0..56c619f72 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/providers/MovementTransmitterProvider.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/providers/MovementTransmitterProvider.java @@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.platform.providers.Provider; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_8.packet.ServerboundPackets1_8; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.storage.MovementTracker; @@ -40,7 +40,7 @@ public class MovementTransmitterProvider implements Provider { try { final PacketWrapper playerMovement = PacketWrapper.create(ServerboundPackets1_8.MOVE_PLAYER_STATUS_ONLY, userConnection); - playerMovement.write(Type.BOOLEAN, movementTracker.isGround()); // on ground + playerMovement.write(Types.BOOLEAN, movementTracker.isGround()); // on ground playerMovement.scheduleSendToServer(Protocol1_8To1_9.class); } catch (Throwable e) { Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send player movement packet", e); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/EntityPacketRewriter1_9.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/EntityPacketRewriter1_9.java index a87ce23e8..a85956f8b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/EntityPacketRewriter1_9.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/EntityPacketRewriter1_9.java @@ -25,6 +25,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_8; import com.viaversion.viaversion.api.type.types.version.Types1_9; import com.viaversion.viaversion.protocols.v1_8.packet.ClientboundPackets1_8; @@ -43,7 +44,7 @@ import java.util.Map; import java.util.UUID; public class EntityPacketRewriter1_9 { - public static final ValueTransformer toNewShort = new ValueTransformer<>(Type.SHORT) { + public static final ValueTransformer toNewShort = new ValueTransformer<>(Types.SHORT) { @Override public Short transform(PacketWrapper wrapper, Byte inputValue) { return (short) (inputValue * 128); @@ -56,15 +57,15 @@ public class EntityPacketRewriter1_9 { @Override public void register() { - map(Type.INT); // 0 - Entity ID - map(Type.INT); // 1 - Vehicle + map(Types.INT); // 0 - Entity ID + map(Types.INT); // 1 - Vehicle handler(wrapper -> { - final short leashState = wrapper.read(Type.UNSIGNED_BYTE); + final short leashState = wrapper.read(Types.UNSIGNED_BYTE); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); if (leashState == 0) { - int passenger = wrapper.get(Type.INT, 0); - int vehicle = wrapper.get(Type.INT, 1); + int passenger = wrapper.get(Types.INT, 0); + int vehicle = wrapper.get(Types.INT, 1); wrapper.cancel(); // Don't send current packet @@ -74,11 +75,11 @@ public class EntityPacketRewriter1_9 { return; // Cancel } - passengerPacket.write(Type.VAR_INT, tracker.getVehicleMap().remove(passenger)); - passengerPacket.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{}); + passengerPacket.write(Types.VAR_INT, tracker.getVehicleMap().remove(passenger)); + passengerPacket.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{}); } else { - passengerPacket.write(Type.VAR_INT, vehicle); - passengerPacket.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{passenger}); + passengerPacket.write(Types.VAR_INT, vehicle); + passengerPacket.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{passenger}); tracker.getVehicleMap().put(passenger, vehicle); } passengerPacket.send(Protocol1_8To1_9.class); // Send the packet @@ -90,24 +91,24 @@ public class EntityPacketRewriter1_9 { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.INT, SpawnPackets1_9.toNewDouble); // 1 - X - Needs to be divided by 32 - map(Type.INT, SpawnPackets1_9.toNewDouble); // 2 - Y - Needs to be divided by 32 - map(Type.INT, SpawnPackets1_9.toNewDouble); // 3 - Z - Needs to be divided by 32 + map(Types.VAR_INT); // 0 - Entity ID + map(Types.INT, SpawnPackets1_9.toNewDouble); // 1 - X - Needs to be divided by 32 + map(Types.INT, SpawnPackets1_9.toNewDouble); // 2 - Y - Needs to be divided by 32 + map(Types.INT, SpawnPackets1_9.toNewDouble); // 3 - Z - Needs to be divided by 32 - map(Type.BYTE); // 4 - Pitch - map(Type.BYTE); // 5 - Yaw + map(Types.BYTE); // 4 - Pitch + map(Types.BYTE); // 5 - Yaw - map(Type.BOOLEAN); // 6 - On Ground + map(Types.BOOLEAN); // 6 - On Ground handler(wrapper -> { - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); if (Via.getConfig().isHologramPatch()) { EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); if (tracker.getKnownHolograms().contains(entityID)) { - Double newValue = wrapper.get(Type.DOUBLE, 1); + Double newValue = wrapper.get(Types.DOUBLE, 1); newValue += (Via.getConfig().getHologramYOffset()); - wrapper.set(Type.DOUBLE, 1, newValue); + wrapper.set(Types.DOUBLE, 1, newValue); } } }); @@ -119,39 +120,39 @@ public class EntityPacketRewriter1_9 { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.BYTE, toNewShort); // 1 - X - map(Type.BYTE, toNewShort); // 2 - Y - map(Type.BYTE, toNewShort); // 3 - Z + map(Types.VAR_INT); // 0 - Entity ID + map(Types.BYTE, toNewShort); // 1 - X + map(Types.BYTE, toNewShort); // 2 - Y + map(Types.BYTE, toNewShort); // 3 - Z - map(Type.BYTE); // 4 - Yaw - map(Type.BYTE); // 5 - Pitch + map(Types.BYTE); // 4 - Yaw + map(Types.BYTE); // 5 - Pitch - map(Type.BOOLEAN); // 6 - On Ground + map(Types.BOOLEAN); // 6 - On Ground } }); protocol.registerClientbound(ClientboundPackets1_8.MOVE_ENTITY_POS, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.BYTE, toNewShort); // 1 - X - map(Type.BYTE, toNewShort); // 2 - Y - map(Type.BYTE, toNewShort); // 3 - Z + map(Types.VAR_INT); // 0 - Entity ID + map(Types.BYTE, toNewShort); // 1 - X + map(Types.BYTE, toNewShort); // 2 - Y + map(Types.BYTE, toNewShort); // 3 - Z - map(Type.BOOLEAN); // 4 - On Ground + map(Types.BOOLEAN); // 4 - On Ground } }); protocol.registerClientbound(ClientboundPackets1_8.SET_EQUIPPED_ITEM, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID + map(Types.VAR_INT); // 0 - Entity ID // 1 - Slot ID - map(Type.SHORT, new ValueTransformer<>(Type.VAR_INT) { + map(Types.SHORT, new ValueTransformer<>(Types.VAR_INT) { @Override public Integer transform(PacketWrapper wrapper, Short slot) { - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); int receiverId = wrapper.user().getEntityTracker(Protocol1_8To1_9.class).clientEntityId(); // Cancel invalid slots as they would cause a packet read error in 1.9 @@ -170,17 +171,17 @@ public class EntityPacketRewriter1_9 { return slot > 0 ? slot.intValue() + 1 : slot.intValue(); } }); - map(Type.ITEM1_8); // 2 - Item + map(Types.ITEM1_8); // 2 - Item // Item Rewriter handler(wrapper -> { - Item stack = wrapper.get(Type.ITEM1_8, 0); + Item stack = wrapper.get(Types.ITEM1_8, 0); ItemRewriter.toClient(stack); }); // Blocking handler(wrapper -> { EntityTracker1_9 entityTracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); - int entityID = wrapper.get(Type.VAR_INT, 0); - Item stack = wrapper.get(Type.ITEM1_8, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); + Item stack = wrapper.get(Types.ITEM1_8, 0); if (stack != null && Protocol1_8To1_9.isSword(stack.identifier())) { entityTracker.getValidBlocking().add(entityID); @@ -195,11 +196,11 @@ public class EntityPacketRewriter1_9 { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID + map(Types.VAR_INT); // 0 - Entity ID map(Types1_8.METADATA_LIST, Types1_9.METADATA_LIST); // 1 - Metadata List handler(wrapper -> { List metadataList = wrapper.get(Types1_9.METADATA_LIST, 0); - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); if (tracker.hasEntity(entityId)) { protocol.get(MetadataRewriter1_9To1_8.class).handleMetadata(entityId, metadataList, wrapper.user()); @@ -211,7 +212,7 @@ public class EntityPacketRewriter1_9 { // Handler for meta data handler(wrapper -> { List metadataList = wrapper.get(Types1_9.METADATA_LIST, 0); - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.handleMetadata(entityID, metadataList); }); @@ -229,16 +230,16 @@ public class EntityPacketRewriter1_9 { protocol.registerClientbound(ClientboundPackets1_8.UPDATE_MOB_EFFECT, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.BYTE); // 1 - Effect ID - map(Type.BYTE); // 2 - Amplifier - map(Type.VAR_INT); // 3 - Duration + map(Types.VAR_INT); // 0 - Entity ID + map(Types.BYTE); // 1 - Effect ID + map(Types.BYTE); // 2 - Amplifier + map(Types.VAR_INT); // 3 - Duration //Handle effect indicator handler(wrapper -> { - boolean showParticles = wrapper.read(Type.BOOLEAN); //In 1.8 = true->Show particles : false->Hide particles + boolean showParticles = wrapper.read(Types.BOOLEAN); //In 1.8 = true->Show particles : false->Hide particles boolean newEffect = Via.getConfig().isNewEffectIndicator(); //0: hide, 1: shown without indictator, 2: shown with indicator, 3: hide with beacon indicator, but we don't use it. - wrapper.write(Type.BYTE, (byte) (showParticles ? newEffect ? 2 : 1 : 0)); + wrapper.write(Types.BYTE, (byte) (showParticles ? newEffect ? 2 : 1 : 0)); }); } }); @@ -248,12 +249,12 @@ public class EntityPacketRewriter1_9 { protocol.registerClientbound(ClientboundPackets1_8.PLAYER_COMBAT, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); //Event id + map(Types.VAR_INT); //Event id handler(wrapper -> { - if (wrapper.get(Type.VAR_INT, 0) == 2) { // entity dead - wrapper.passthrough(Type.VAR_INT); //Player id - wrapper.passthrough(Type.INT); //Entity id - Protocol1_8To1_9.STRING_TO_JSON.write(wrapper, wrapper.read(Type.STRING)); + if (wrapper.get(Types.VAR_INT, 0) == 2) { // entity dead + wrapper.passthrough(Types.VAR_INT); //Player id + wrapper.passthrough(Types.INT); //Entity id + Protocol1_8To1_9.STRING_TO_JSON.write(wrapper, wrapper.read(Types.STRING)); } }); } @@ -262,27 +263,27 @@ public class EntityPacketRewriter1_9 { protocol.registerClientbound(ClientboundPackets1_8.UPDATE_ATTRIBUTES, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); + map(Types.VAR_INT); handler(wrapper -> { if (!Via.getConfig().isMinimizeCooldown()) return; EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); - if (wrapper.get(Type.VAR_INT, 0) != tracker.getProvidedEntityId()) { + if (wrapper.get(Types.VAR_INT, 0) != tracker.getProvidedEntityId()) { return; } - int propertiesToRead = wrapper.read(Type.INT); + int propertiesToRead = wrapper.read(Types.INT); Map>>> properties = new HashMap<>(propertiesToRead); for (int i = 0; i < propertiesToRead; i++) { - String key = wrapper.read(Type.STRING); - Double value = wrapper.read(Type.DOUBLE); - int modifiersToRead = wrapper.read(Type.VAR_INT); + String key = wrapper.read(Types.STRING); + Double value = wrapper.read(Types.DOUBLE); + int modifiersToRead = wrapper.read(Types.VAR_INT); List> modifiers = new ArrayList<>(modifiersToRead); for (int j = 0; j < modifiersToRead; j++) { modifiers.add( new Triple<>( - wrapper.read(Type.UUID), - wrapper.read(Type.DOUBLE), // Amount - wrapper.read(Type.BYTE) // Operation + wrapper.read(Types.UUID), + wrapper.read(Types.DOUBLE), // Amount + wrapper.read(Types.BYTE) // Operation ) ); } @@ -298,15 +299,15 @@ public class EntityPacketRewriter1_9 { new Triple<>(UUID.fromString("55FCED67-E92A-486E-9800-B47F202C4386"), 0.0, (byte) 2) // Dig slow down ))); - wrapper.write(Type.INT, properties.size()); + wrapper.write(Types.INT, properties.size()); for (Map.Entry>>> entry : properties.entrySet()) { - wrapper.write(Type.STRING, entry.getKey()); // Key - wrapper.write(Type.DOUBLE, entry.getValue().key()); // Value - wrapper.write(Type.VAR_INT, entry.getValue().value().size()); + wrapper.write(Types.STRING, entry.getKey()); // Key + wrapper.write(Types.DOUBLE, entry.getValue().key()); // Value + wrapper.write(Types.VAR_INT, entry.getValue().value().size()); for (Triple modifier : entry.getValue().value()) { - wrapper.write(Type.UUID, modifier.first()); - wrapper.write(Type.DOUBLE, modifier.second()); // Amount - wrapper.write(Type.BYTE, modifier.third()); // Operation + wrapper.write(Types.UUID, modifier.first()); + wrapper.write(Types.DOUBLE, modifier.second()); // Amount + wrapper.write(Types.BYTE, modifier.third()); // Operation } } }); @@ -316,10 +317,10 @@ public class EntityPacketRewriter1_9 { protocol.registerClientbound(ClientboundPackets1_8.ANIMATE, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UNSIGNED_BYTE); // 1 - Animation + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UNSIGNED_BYTE); // 1 - Animation handler(wrapper -> { - if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 3) { + if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 3) { wrapper.cancel(); } }); @@ -332,15 +333,15 @@ public class EntityPacketRewriter1_9 { @Override public void register() { - map(Type.VAR_INT); // 0 - Player ID - map(Type.VAR_INT); // 1 - Action - map(Type.VAR_INT); // 2 - Jump + map(Types.VAR_INT); // 0 - Player ID + map(Types.VAR_INT); // 1 - Action + map(Types.VAR_INT); // 2 - Jump handler(wrapper -> { - int action = wrapper.get(Type.VAR_INT, 1); + int action = wrapper.get(Types.VAR_INT, 1); if (action == 6 || action == 8) wrapper.cancel(); if (action == 7) { - wrapper.set(Type.VAR_INT, 1, 6); + wrapper.set(Types.VAR_INT, 1, 6); } }); } @@ -350,19 +351,19 @@ public class EntityPacketRewriter1_9 { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID (Target) - map(Type.VAR_INT); // 1 - Action Type + map(Types.VAR_INT); // 0 - Entity ID (Target) + map(Types.VAR_INT); // 1 - Action Type // Cancel second hand to prevent double interact handler(wrapper -> { - int type = wrapper.get(Type.VAR_INT, 1); + int type = wrapper.get(Types.VAR_INT, 1); if (type == 2) { - wrapper.passthrough(Type.FLOAT); // 2 - X - wrapper.passthrough(Type.FLOAT); // 3 - Y - wrapper.passthrough(Type.FLOAT); // 4 - Z + wrapper.passthrough(Types.FLOAT); // 2 - X + wrapper.passthrough(Types.FLOAT); // 3 - Y + wrapper.passthrough(Types.FLOAT); // 4 - Z } if (type == 0 || type == 2) { - int hand = wrapper.read(Type.VAR_INT); // 2/5 - Hand + int hand = wrapper.read(Types.VAR_INT); // 2/5 - Hand if (hand == 1) wrapper.cancel(); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/ItemPacketRewriter1_9.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/ItemPacketRewriter1_9.java index ed7ddeb9b..5c997d77c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/ItemPacketRewriter1_9.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/ItemPacketRewriter1_9.java @@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_8.packet.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.v1_8to1_9.rewriter.ItemRewriter; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; @@ -36,14 +37,14 @@ public class ItemPacketRewriter1_9 { @Override public void register() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Property Key - map(Type.SHORT); // 2 - Property Value + map(Types.UNSIGNED_BYTE); // 0 - Window ID + map(Types.SHORT); // 1 - Property Key + map(Types.SHORT); // 2 - Property Value handler(wrapper -> { - final short windowId = wrapper.get(Type.UNSIGNED_BYTE, 0); - final short property = wrapper.get(Type.SHORT, 0); - short value = wrapper.get(Type.SHORT, 1); + final short windowId = wrapper.get(Types.UNSIGNED_BYTE, 0); + final short property = wrapper.get(Types.SHORT, 0); + short value = wrapper.get(Types.SHORT, 1); InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class); if (inventoryTracker.getInventory() != null && inventoryTracker.getInventory().equalsIgnoreCase("minecraft:enchanting_table")) { if (property > 3 && property < 7) { @@ -51,13 +52,13 @@ public class ItemPacketRewriter1_9 { final short level = (short) (value >> 8); final short enchantID = (short) (value & 0xFF); wrapper.create(wrapper.getId(), propertyPacket -> { - propertyPacket.write(Type.UNSIGNED_BYTE, windowId); - propertyPacket.write(Type.SHORT, property); - propertyPacket.write(Type.SHORT, enchantID); + propertyPacket.write(Types.UNSIGNED_BYTE, windowId); + propertyPacket.write(Types.SHORT, property); + propertyPacket.write(Types.SHORT, enchantID); }).scheduleSend(Protocol1_8To1_9.class); - wrapper.set(Type.SHORT, 0, (short) (property + 3)); - wrapper.set(Type.SHORT, 1, level); + wrapper.set(Types.SHORT, 0, (short) (property + 3)); + wrapper.set(Types.SHORT, 1, level); } } }); @@ -67,22 +68,22 @@ public class ItemPacketRewriter1_9 { @Override public void register() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.STRING); // 1 - Window Type - map(Type.STRING, Protocol1_8To1_9.STRING_TO_JSON); // 2 - Window Title - map(Type.UNSIGNED_BYTE); // 3 - Slot Count + map(Types.UNSIGNED_BYTE); // 0 - Window ID + map(Types.STRING); // 1 - Window Type + map(Types.STRING, Protocol1_8To1_9.STRING_TO_JSON); // 2 - Window Title + map(Types.UNSIGNED_BYTE); // 3 - Slot Count // There is a horse parameter after this, we don't handle it and let it passthrough // Inventory tracking handler(wrapper -> { - String inventory = wrapper.get(Type.STRING, 0); + String inventory = wrapper.get(Types.STRING, 0); InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class); inventoryTracker.setInventory(inventory); }); // Brewing patch handler(wrapper -> { - String inventory = wrapper.get(Type.STRING, 0); + String inventory = wrapper.get(Types.STRING, 0); if (inventory.equals("minecraft:brewing_stand")) { - wrapper.set(Type.UNSIGNED_BYTE, 1, (short) (wrapper.get(Type.UNSIGNED_BYTE, 1) + 1)); + wrapper.set(Types.UNSIGNED_BYTE, 1, (short) (wrapper.get(Types.UNSIGNED_BYTE, 1) + 1)); } }); } @@ -90,11 +91,11 @@ public class ItemPacketRewriter1_9 { protocol.registerClientbound(ClientboundPackets1_8.CONTAINER_SET_SLOT, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot ID - map(Type.ITEM1_8); // 2 - Slot Value + map(Types.UNSIGNED_BYTE); // 0 - Window ID + map(Types.SHORT); // 1 - Slot ID + map(Types.ITEM1_8); // 2 - Slot Value handler(wrapper -> { - Item stack = wrapper.get(Type.ITEM1_8, 0); + Item stack = wrapper.get(Types.ITEM1_8, 0); boolean showShieldWhenSwordInHand = Via.getConfig().isShowShieldWhenSwordInHand() && Via.getConfig().isShieldBlocking(); @@ -104,8 +105,8 @@ public class ItemPacketRewriter1_9 { InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class); EntityTracker1_9 entityTracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); - short slotID = wrapper.get(Type.SHORT, 0); - byte windowId = wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue(); + short slotID = wrapper.get(Types.SHORT, 0); + byte windowId = wrapper.get(Types.UNSIGNED_BYTE, 0).byteValue(); // Store item in slot inventoryTracker.setItemId(windowId, slotID, stack == null ? 0 : stack.identifier()); @@ -120,10 +121,10 @@ public class ItemPacketRewriter1_9 { handler(wrapper -> { InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class); - short slotID = wrapper.get(Type.SHORT, 0); + short slotID = wrapper.get(Types.SHORT, 0); if (inventoryTracker.getInventory() != null && inventoryTracker.getInventory().equals("minecraft:brewing_stand")) { if (slotID >= 4) { - wrapper.set(Type.SHORT, 0, (short) (slotID + 1)); + wrapper.set(Types.SHORT, 0, (short) (slotID + 1)); } } }); @@ -133,12 +134,12 @@ public class ItemPacketRewriter1_9 { @Override public void register() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.ITEM1_8_SHORT_ARRAY); // 1 - Window Values + map(Types.UNSIGNED_BYTE); // 0 - Window ID + map(Types.ITEM1_8_SHORT_ARRAY); // 1 - Window Values handler(wrapper -> { - Item[] stacks = wrapper.get(Type.ITEM1_8_SHORT_ARRAY, 0); - Short windowId = wrapper.get(Type.UNSIGNED_BYTE, 0); + Item[] stacks = wrapper.get(Types.ITEM1_8_SHORT_ARRAY, 0); + Short windowId = wrapper.get(Types.UNSIGNED_BYTE, 0); InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class); EntityTracker1_9 entityTracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); @@ -166,7 +167,7 @@ public class ItemPacketRewriter1_9 { handler(wrapper -> { InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class); if (inventoryTracker.getInventory() != null && inventoryTracker.getInventory().equals("minecraft:brewing_stand")) { - Item[] oldStack = wrapper.get(Type.ITEM1_8_SHORT_ARRAY, 0); + Item[] oldStack = wrapper.get(Types.ITEM1_8_SHORT_ARRAY, 0); Item[] newStack = new Item[oldStack.length + 1]; for (int i = 0; i < newStack.length; i++) { if (i > 4) { @@ -177,7 +178,7 @@ public class ItemPacketRewriter1_9 { } } } - wrapper.set(Type.ITEM1_8_SHORT_ARRAY, 0, newStack); + wrapper.set(Types.ITEM1_8_SHORT_ARRAY, 0, newStack); } }); } @@ -186,12 +187,12 @@ public class ItemPacketRewriter1_9 { @Override public void register() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID + map(Types.UNSIGNED_BYTE); // 0 - Window ID // Inventory tracking handler(wrapper -> { InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class); inventoryTracker.setInventory(null); - inventoryTracker.resetInventory(wrapper.get(Type.UNSIGNED_BYTE, 0)); + inventoryTracker.resetInventory(wrapper.get(Types.UNSIGNED_BYTE, 0)); }); } }); @@ -200,10 +201,10 @@ public class ItemPacketRewriter1_9 { @Override public void register() { - map(Type.VAR_INT); // 0 - Map ID - map(Type.BYTE); // 1 - Map Scale + map(Types.VAR_INT); // 0 - Map ID + map(Types.BYTE); // 1 - Map Scale handler(wrapper -> { - wrapper.write(Type.BOOLEAN, true); // 2 - Show marker + wrapper.write(Types.BOOLEAN, true); // 2 - Show marker }); // Everything else is passed through } @@ -215,10 +216,10 @@ public class ItemPacketRewriter1_9 { @Override public void register() { - map(Type.SHORT); // 0 - Slot ID - map(Type.ITEM1_8); // 1 - Item + map(Types.SHORT); // 0 - Slot ID + map(Types.ITEM1_8); // 1 - Item handler(wrapper -> { - Item stack = wrapper.get(Type.ITEM1_8, 0); + Item stack = wrapper.get(Types.ITEM1_8, 0); boolean showShieldWhenSwordInHand = Via.getConfig().isShowShieldWhenSwordInHand() && Via.getConfig().isShieldBlocking(); @@ -226,7 +227,7 @@ public class ItemPacketRewriter1_9 { if (showShieldWhenSwordInHand) { InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class); EntityTracker1_9 entityTracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); - short slotID = wrapper.get(Type.SHORT, 0); + short slotID = wrapper.get(Types.SHORT, 0); // Update item in slot inventoryTracker.setItemId((short) 0, slotID, stack == null ? 0 : stack.identifier()); @@ -239,17 +240,17 @@ public class ItemPacketRewriter1_9 { }); // Elytra throw patch handler(wrapper -> { - final short slot = wrapper.get(Type.SHORT, 0); + final short slot = wrapper.get(Types.SHORT, 0); boolean throwItem = (slot == 45); if (throwItem) { // Send a packet wiping the slot wrapper.create(ClientboundPackets1_9.CONTAINER_SET_SLOT, w -> { - w.write(Type.UNSIGNED_BYTE, (short) 0); - w.write(Type.SHORT, slot); - w.write(Type.ITEM1_8, null); + w.write(Types.UNSIGNED_BYTE, (short) 0); + w.write(Types.SHORT, slot); + w.write(Types.ITEM1_8, null); }).send(Protocol1_8To1_9.class); // Finally reset to simulate throwing item - wrapper.set(Type.SHORT, 0, (short) -999); // Set slot to -999 + wrapper.set(Types.SHORT, 0, (short) -999); // Set slot to -999 } }); } @@ -259,20 +260,20 @@ public class ItemPacketRewriter1_9 { @Override public void register() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot ID - map(Type.BYTE); // 2 - Button - map(Type.SHORT); // 3 - Action - map(Type.VAR_INT, Type.BYTE); // 4 - Mode - map(Type.ITEM1_8); // 5 - Clicked Item + map(Types.UNSIGNED_BYTE); // 0 - Window ID + map(Types.SHORT); // 1 - Slot ID + map(Types.BYTE); // 2 - Button + map(Types.SHORT); // 3 - Action + map(Types.VAR_INT, Types.BYTE); // 4 - Mode + map(Types.ITEM1_8); // 5 - Clicked Item handler(wrapper -> { - Item stack = wrapper.get(Type.ITEM1_8, 0); + Item stack = wrapper.get(Types.ITEM1_8, 0); if (Via.getConfig().isShowShieldWhenSwordInHand()) { - Short windowId = wrapper.get(Type.UNSIGNED_BYTE, 0); - byte mode = wrapper.get(Type.BYTE, 1); - short hoverSlot = wrapper.get(Type.SHORT, 0); - byte button = wrapper.get(Type.BYTE, 0); + Short windowId = wrapper.get(Types.UNSIGNED_BYTE, 0); + byte mode = wrapper.get(Types.BYTE, 1); + short hoverSlot = wrapper.get(Types.SHORT, 0); + byte button = wrapper.get(Types.BYTE, 0); // Move items in inventory to track the sword location InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class); @@ -283,8 +284,8 @@ public class ItemPacketRewriter1_9 { }); // Brewing patch and elytra throw patch handler(wrapper -> { - final short windowID = wrapper.get(Type.UNSIGNED_BYTE, 0); - final short slot = wrapper.get(Type.SHORT, 0); + final short windowID = wrapper.get(Types.UNSIGNED_BYTE, 0); + final short slot = wrapper.get(Types.SHORT, 0); boolean throwItem = (slot == 45 && windowID == 0); InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class); if (inventoryTracker.getInventory() != null && inventoryTracker.getInventory().equals("minecraft:brewing_stand")) { @@ -292,21 +293,21 @@ public class ItemPacketRewriter1_9 { throwItem = true; } if (slot > 4) { - wrapper.set(Type.SHORT, 0, (short) (slot - 1)); + wrapper.set(Types.SHORT, 0, (short) (slot - 1)); } } if (throwItem) { // Send a packet wiping the slot wrapper.create(ClientboundPackets1_9.CONTAINER_SET_SLOT, w -> { - w.write(Type.UNSIGNED_BYTE, windowID); - w.write(Type.SHORT, slot); - w.write(Type.ITEM1_8, null); + w.write(Types.UNSIGNED_BYTE, windowID); + w.write(Types.SHORT, slot); + w.write(Types.ITEM1_8, null); }).scheduleSend(Protocol1_8To1_9.class); // Finally reset to simulate throwing item - wrapper.set(Type.BYTE, 0, (byte) 0); // Set button to 0 - wrapper.set(Type.BYTE, 1, (byte) 0); // Set mode to 0 - wrapper.set(Type.SHORT, 0, (short) -999); // Set slot to -999 + wrapper.set(Types.BYTE, 0, (byte) 0); // Set button to 0 + wrapper.set(Types.BYTE, 1, (byte) 0); // Set mode to 0 + wrapper.set(Types.SHORT, 0, (short) -999); // Set slot to -999 } }); } @@ -318,13 +319,13 @@ public class ItemPacketRewriter1_9 { @Override public void register() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID + map(Types.UNSIGNED_BYTE); // 0 - Window ID // Inventory tracking handler(wrapper -> { InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class); inventoryTracker.setInventory(null); - inventoryTracker.resetInventory(wrapper.get(Type.UNSIGNED_BYTE, 0)); + inventoryTracker.resetInventory(wrapper.get(Types.UNSIGNED_BYTE, 0)); }); } }); @@ -334,7 +335,7 @@ public class ItemPacketRewriter1_9 { PacketHandlers() { @Override public void register() { - map(Type.SHORT); // 0 - Slot id + map(Types.SHORT); // 0 - Slot id // Blocking patch handler(wrapper -> { @@ -352,7 +353,7 @@ public class ItemPacketRewriter1_9 { if (showShieldWhenSwordInHand) { // Update current held item slot index - entityTracker.setHeldItemSlot(wrapper.get(Type.SHORT, 0)); + entityTracker.setHeldItemSlot(wrapper.get(Types.SHORT, 0)); // Sync shield item in offhand with main hand entityTracker.syncShieldWithSword(); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/PlayerPackets1_9.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/PlayerPackets1_9.java index 9237031f0..f4baf65a8 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/PlayerPackets1_9.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/PlayerPackets1_9.java @@ -25,6 +25,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_8.packet.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.v1_8to1_9.rewriter.ItemRewriter; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; @@ -43,11 +44,11 @@ public class PlayerPackets1_9 { protocol.registerClientbound(ClientboundPackets1_8.CHAT, new PacketHandlers() { @Override public void register() { - map(Type.STRING, Protocol1_8To1_9.STRING_TO_JSON); // 0 - Chat Message (json) - map(Type.BYTE); // 1 - Chat Position + map(Types.STRING, Protocol1_8To1_9.STRING_TO_JSON); // 0 - Chat Message (json) + map(Types.BYTE); // 1 - Chat Position handler(wrapper -> { - JsonObject obj = (JsonObject) wrapper.get(Type.COMPONENT, 0); + JsonObject obj = (JsonObject) wrapper.get(Types.COMPONENT, 0); ChatRewriter.toClient(obj, wrapper.user()); }); } @@ -56,27 +57,27 @@ public class PlayerPackets1_9 { protocol.registerClientbound(ClientboundPackets1_8.TAB_LIST, new PacketHandlers() { @Override public void register() { - map(Type.STRING, Protocol1_8To1_9.STRING_TO_JSON); // 0 - Header - map(Type.STRING, Protocol1_8To1_9.STRING_TO_JSON); // 1 - Footer + map(Types.STRING, Protocol1_8To1_9.STRING_TO_JSON); // 0 - Header + map(Types.STRING, Protocol1_8To1_9.STRING_TO_JSON); // 1 - Footer } }); protocol.registerClientbound(ClientboundPackets1_8.DISCONNECT, new PacketHandlers() { @Override public void register() { - map(Type.STRING, Protocol1_8To1_9.STRING_TO_JSON); // 0 - Reason + map(Types.STRING, Protocol1_8To1_9.STRING_TO_JSON); // 0 - Reason } }); protocol.registerClientbound(ClientboundPackets1_8.SET_TITLES, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Action + map(Types.VAR_INT); // 0 - Action // We only handle if the title or subtitle is set then just write through. handler(wrapper -> { - int action = wrapper.get(Type.VAR_INT, 0); + int action = wrapper.get(Types.VAR_INT, 0); if (action == 0 || action == 1) { - Protocol1_8To1_9.STRING_TO_JSON.write(wrapper, wrapper.read(Type.STRING)); + Protocol1_8To1_9.STRING_TO_JSON.write(wrapper, wrapper.read(Types.STRING)); } }); // Everything else is handled. @@ -86,45 +87,45 @@ public class PlayerPackets1_9 { protocol.registerClientbound(ClientboundPackets1_8.PLAYER_POSITION, new PacketHandlers() { @Override public void register() { - map(Type.DOUBLE); // 0 - Player X - map(Type.DOUBLE); // 1 - Player Y - map(Type.DOUBLE); // 2 - Player Z + map(Types.DOUBLE); // 0 - Player X + map(Types.DOUBLE); // 1 - Player Y + map(Types.DOUBLE); // 2 - Player Z - map(Type.FLOAT); // 3 - Player Yaw - map(Type.FLOAT); // 4 - Player Pitch + map(Types.FLOAT); // 3 - Player Yaw + map(Types.FLOAT); // 4 - Player Pitch - map(Type.BYTE); // 5 - Player Flags + map(Types.BYTE); // 5 - Player Flags - create(Type.VAR_INT, 0); // 6 - Teleport ID was added + create(Types.VAR_INT, 0); // 6 - Teleport ID was added } }); protocol.registerClientbound(ClientboundPackets1_8.SET_PLAYER_TEAM, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // 0 - Team Name - map(Type.BYTE); // 1 - Mode + map(Types.STRING); // 0 - Team Name + map(Types.BYTE); // 1 - Mode handler(wrapper -> { - byte mode = wrapper.get(Type.BYTE, 0); // Mode + byte mode = wrapper.get(Types.BYTE, 0); // Mode if (mode == 0 || mode == 2) { - wrapper.passthrough(Type.STRING); // Display Name - wrapper.passthrough(Type.STRING); // Prefix - wrapper.passthrough(Type.STRING); // Suffix + wrapper.passthrough(Types.STRING); // Display Name + wrapper.passthrough(Types.STRING); // Prefix + wrapper.passthrough(Types.STRING); // Suffix - wrapper.passthrough(Type.BYTE); // Friendly Fire + wrapper.passthrough(Types.BYTE); // Friendly Fire - wrapper.passthrough(Type.STRING); // Name tag visibility + wrapper.passthrough(Types.STRING); // Name tag visibility - wrapper.write(Type.STRING, Via.getConfig().isPreventCollision() ? "never" : ""); + wrapper.write(Types.STRING, Via.getConfig().isPreventCollision() ? "never" : ""); - wrapper.passthrough(Type.BYTE); // Colour + wrapper.passthrough(Types.BYTE); // Colour } if (mode == 0 || mode == 3 || mode == 4) { - String[] players = wrapper.passthrough(Type.STRING_ARRAY); // Players + String[] players = wrapper.passthrough(Types.STRING_ARRAY); // Players final EntityTracker1_9 entityTracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); String myName = wrapper.user().getProtocolInfo().getUsername(); - String teamName = wrapper.get(Type.STRING, 0); + String teamName = wrapper.get(Types.STRING, 0); for (String player : players) { if (entityTracker.isAutoTeam() && player.equalsIgnoreCase(myName)) { if (mode == 4) { @@ -145,7 +146,7 @@ public class PlayerPackets1_9 { if (mode == 1) { // Remove team final EntityTracker1_9 entityTracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); - String teamName = wrapper.get(Type.STRING, 0); + String teamName = wrapper.get(Types.STRING, 0); if (entityTracker.isAutoTeam() && teamName.equals(entityTracker.getCurrentTeam())) { // team was removed @@ -163,30 +164,30 @@ public class PlayerPackets1_9 { protocol.registerClientbound(ClientboundPackets1_8.LOGIN, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Player ID + map(Types.INT); // 0 - Player ID // Parse this info handler(wrapper -> { - int entityId = wrapper.get(Type.INT, 0); + int entityId = wrapper.get(Types.INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.addEntity(entityId, EntityTypes1_10.EntityType.PLAYER); tracker.setClientEntityId(entityId); }); - map(Type.UNSIGNED_BYTE); // 1 - Player Gamemode - map(Type.BYTE); // 2 - Player Dimension - map(Type.UNSIGNED_BYTE); // 3 - World Difficulty - map(Type.UNSIGNED_BYTE); // 4 - Max Players (Tab) - map(Type.STRING); // 5 - Level Type - map(Type.BOOLEAN); // 6 - Reduced Debug info + map(Types.UNSIGNED_BYTE); // 1 - Player Gamemode + map(Types.BYTE); // 2 - Player Dimension + map(Types.UNSIGNED_BYTE); // 3 - World Difficulty + map(Types.UNSIGNED_BYTE); // 4 - Max Players (Tab) + map(Types.STRING); // 5 - Level Type + map(Types.BOOLEAN); // 6 - Reduced Debug info handler(wrapper -> { EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); - tracker.setGameMode(GameMode.getById(wrapper.get(Type.UNSIGNED_BYTE, 0))); //Set player gamemode + tracker.setGameMode(GameMode.getById(wrapper.get(Types.UNSIGNED_BYTE, 0))); //Set player gamemode }); // Track player's dimension handler(wrapper -> { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.BYTE, 0); + int dimensionId = wrapper.get(Types.BYTE, 0); clientWorld.setEnvironment(dimensionId); }); @@ -216,37 +217,37 @@ public class PlayerPackets1_9 { protocol.registerClientbound(ClientboundPackets1_8.PLAYER_INFO, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Action - map(Type.VAR_INT); // 1 - Player Count + map(Types.VAR_INT); // 0 - Action + map(Types.VAR_INT); // 1 - Player Count // Due to this being a complex data structure we just use a handler. handler(wrapper -> { - int action = wrapper.get(Type.VAR_INT, 0); - int count = wrapper.get(Type.VAR_INT, 1); + int action = wrapper.get(Types.VAR_INT, 0); + int count = wrapper.get(Types.VAR_INT, 1); for (int i = 0; i < count; i++) { - wrapper.passthrough(Type.UUID); // Player UUID + wrapper.passthrough(Types.UUID); // Player UUID if (action == 0) { // add player - wrapper.passthrough(Type.STRING); // Player Name + wrapper.passthrough(Types.STRING); // Player Name - int properties = wrapper.passthrough(Type.VAR_INT); + int properties = wrapper.passthrough(Types.VAR_INT); // loop through properties for (int j = 0; j < properties; j++) { - wrapper.passthrough(Type.STRING); // name - wrapper.passthrough(Type.STRING); // value - wrapper.passthrough(Type.OPTIONAL_STRING); // signature + wrapper.passthrough(Types.STRING); // name + wrapper.passthrough(Types.STRING); // value + wrapper.passthrough(Types.OPTIONAL_STRING); // signature } - wrapper.passthrough(Type.VAR_INT); // gamemode - wrapper.passthrough(Type.VAR_INT); // ping - String displayName = wrapper.read(Type.OPTIONAL_STRING); - wrapper.write(Type.OPTIONAL_COMPONENT, displayName != null ? + wrapper.passthrough(Types.VAR_INT); // gamemode + wrapper.passthrough(Types.VAR_INT); // ping + String displayName = wrapper.read(Types.OPTIONAL_STRING); + wrapper.write(Types.OPTIONAL_COMPONENT, displayName != null ? Protocol1_8To1_9.STRING_TO_JSON.transform(wrapper, displayName) : null); } else if ((action == 1) || (action == 2)) { // update gamemode || update latency - wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.VAR_INT); } else if (action == 3) { // update display name - String displayName = wrapper.read(Type.OPTIONAL_STRING); - wrapper.write(Type.OPTIONAL_COMPONENT, displayName != null ? + String displayName = wrapper.read(Types.OPTIONAL_STRING); + wrapper.write(Types.OPTIONAL_COMPONENT, displayName != null ? Protocol1_8To1_9.STRING_TO_JSON.transform(wrapper, displayName) : null); } } @@ -257,34 +258,34 @@ public class PlayerPackets1_9 { protocol.registerClientbound(ClientboundPackets1_8.CUSTOM_PAYLOAD, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // 0 - Channel Name + map(Types.STRING); // 0 - Channel Name handlerSoftFail(wrapper -> { - String name = wrapper.get(Type.STRING, 0); + String name = wrapper.get(Types.STRING, 0); if (name.equals("MC|BOpen")) { - wrapper.write(Type.VAR_INT, 0); + wrapper.write(Types.VAR_INT, 0); } else if (name.equals("MC|TrList")) { - wrapper.passthrough(Type.INT); // ID + wrapper.passthrough(Types.INT); // ID - Short size = wrapper.passthrough(Type.UNSIGNED_BYTE); + Short size = wrapper.passthrough(Types.UNSIGNED_BYTE); for (int i = 0; i < size; ++i) { - Item item1 = wrapper.passthrough(Type.ITEM1_8); + Item item1 = wrapper.passthrough(Types.ITEM1_8); ItemRewriter.toClient(item1); - Item item2 = wrapper.passthrough(Type.ITEM1_8); + Item item2 = wrapper.passthrough(Types.ITEM1_8); ItemRewriter.toClient(item2); - boolean present = wrapper.passthrough(Type.BOOLEAN); + boolean present = wrapper.passthrough(Types.BOOLEAN); if (present) { - Item item3 = wrapper.passthrough(Type.ITEM1_8); + Item item3 = wrapper.passthrough(Types.ITEM1_8); ItemRewriter.toClient(item3); } - wrapper.passthrough(Type.BOOLEAN); + wrapper.passthrough(Types.BOOLEAN); - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.INT); + wrapper.passthrough(Types.INT); + wrapper.passthrough(Types.INT); } } }); @@ -294,15 +295,15 @@ public class PlayerPackets1_9 { protocol.registerClientbound(ClientboundPackets1_8.RESPAWN, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Dimension - map(Type.UNSIGNED_BYTE); // 1 - Difficulty - map(Type.UNSIGNED_BYTE); // 2 - GameMode - map(Type.STRING); // 3 - Level Type + map(Types.INT); // 0 - Dimension + map(Types.UNSIGNED_BYTE); // 1 - Difficulty + map(Types.UNSIGNED_BYTE); // 2 - GameMode + map(Types.STRING); // 3 - Level Type // Track player's dimension handler(wrapper -> { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 0); + int dimensionId = wrapper.get(Types.INT, 0); clientWorld.setEnvironment(dimensionId); }); @@ -310,7 +311,7 @@ public class PlayerPackets1_9 { // Client unloads chunks on respawn wrapper.user().get(ClientChunks.class).getLoadedChunks().clear(); - int gamemode = wrapper.get(Type.UNSIGNED_BYTE, 0); + int gamemode = wrapper.get(Types.UNSIGNED_BYTE, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.setGameMode(GameMode.getById(gamemode)); }); @@ -327,17 +328,17 @@ public class PlayerPackets1_9 { protocol.registerClientbound(ClientboundPackets1_8.GAME_EVENT, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); //0 - Reason - map(Type.FLOAT); //1 - Value + map(Types.UNSIGNED_BYTE); //0 - Reason + map(Types.FLOAT); //1 - Value handler(wrapper -> { - short reason = wrapper.get(Type.UNSIGNED_BYTE, 0); + short reason = wrapper.get(Types.UNSIGNED_BYTE, 0); if (reason == 3) { //Change gamemode - int gamemode = wrapper.get(Type.FLOAT, 0).intValue(); + int gamemode = wrapper.get(Types.FLOAT, 0).intValue(); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.setGameMode(GameMode.getById(gamemode)); } else if (reason == 4) { //Open credits screen - wrapper.set(Type.FLOAT, 0, 1F); + wrapper.set(Types.FLOAT, 0, 1F); } }); } @@ -348,7 +349,7 @@ public class PlayerPackets1_9 { wrapper.cancel(); CompressionProvider provider = Via.getManager().getProviders().get(CompressionProvider.class); - provider.handlePlayCompression(wrapper.user(), wrapper.read(Type.VAR_INT)); + provider.handlePlayCompression(wrapper.user(), wrapper.read(Types.VAR_INT)); }); @@ -356,26 +357,26 @@ public class PlayerPackets1_9 { protocol.registerServerbound(ServerboundPackets1_9.COMMAND_SUGGESTION, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // 0 - Requested Command - read(Type.BOOLEAN); // 1 - Is Command Block + map(Types.STRING); // 0 - Requested Command + read(Types.BOOLEAN); // 1 - Is Command Block } }); protocol.registerServerbound(ServerboundPackets1_9.CLIENT_INFORMATION, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // 0 - locale - map(Type.BYTE); // 1 - View Distance - map(Type.VAR_INT, Type.BYTE); // 2 - Chat Mode - map(Type.BOOLEAN); // 3 - If Chat Colours on - map(Type.UNSIGNED_BYTE); // 4 - Skin Parts + map(Types.STRING); // 0 - locale + map(Types.BYTE); // 1 - View Distance + map(Types.VAR_INT, Types.BYTE); // 2 - Chat Mode + map(Types.BOOLEAN); // 3 - If Chat Colours on + map(Types.UNSIGNED_BYTE); // 4 - Skin Parts handler(wrapper -> { - int hand = wrapper.read(Type.VAR_INT); + int hand = wrapper.read(Types.VAR_INT); // Add 0x80 if left-handed if (Via.getConfig().isLeftHandedHandling() && hand == 0) { - wrapper.set(Type.UNSIGNED_BYTE, 0, (short) (wrapper.get(Type.UNSIGNED_BYTE, 0).intValue() | 0x80)); + wrapper.set(Types.UNSIGNED_BYTE, 0, (short) (wrapper.get(Types.UNSIGNED_BYTE, 0).intValue() | 0x80)); } wrapper.sendToServer(Protocol1_8To1_9.class); wrapper.cancel(); @@ -387,7 +388,7 @@ public class PlayerPackets1_9 { protocol.registerServerbound(ServerboundPackets1_9.SWING, new PacketHandlers() { @Override public void register() { - read(Type.VAR_INT); // 0 - Hand + read(Types.VAR_INT); // 0 - Hand } }); @@ -398,28 +399,28 @@ public class PlayerPackets1_9 { protocol.registerServerbound(ServerboundPackets1_9.CUSTOM_PAYLOAD, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // 0 - Channel Name + map(Types.STRING); // 0 - Channel Name handlerSoftFail(wrapper -> { - String name = wrapper.get(Type.STRING, 0); + String name = wrapper.get(Types.STRING, 0); if (name.equals("MC|BSign")) { - Item item = wrapper.passthrough(Type.ITEM1_8); + Item item = wrapper.passthrough(Types.ITEM1_8); if (item != null) { item.setIdentifier(387); // Written Book ItemRewriter.rewriteBookToServer(item); } } if (name.equals("MC|AutoCmd")) { - wrapper.set(Type.STRING, 0, "MC|AdvCdm"); - wrapper.write(Type.BYTE, (byte) 0); - wrapper.passthrough(Type.INT); // X - wrapper.passthrough(Type.INT); // Y - wrapper.passthrough(Type.INT); // Z - wrapper.passthrough(Type.STRING); // Command - wrapper.passthrough(Type.BOOLEAN); // Flag + wrapper.set(Types.STRING, 0, "MC|AdvCdm"); + wrapper.write(Types.BYTE, (byte) 0); + wrapper.passthrough(Types.INT); // X + wrapper.passthrough(Types.INT); // Y + wrapper.passthrough(Types.INT); // Z + wrapper.passthrough(Types.STRING); // Command + wrapper.passthrough(Types.BOOLEAN); // Flag wrapper.clearInputBuffer(); } if (name.equals("MC|AdvCmd")) { - wrapper.set(Type.STRING, 0, "MC|AdvCdm"); + wrapper.set(Types.STRING, 0, "MC|AdvCdm"); } }); } @@ -428,9 +429,9 @@ public class PlayerPackets1_9 { protocol.registerServerbound(ServerboundPackets1_9.CLIENT_COMMAND, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Action ID + map(Types.VAR_INT); // 0 - Action ID handler(wrapper -> { - int action = wrapper.get(Type.VAR_INT, 0); + int action = wrapper.get(Types.VAR_INT, 0); if (action == 2) { // cancel any blocking >.> EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); @@ -448,43 +449,43 @@ public class PlayerPackets1_9 { final PacketHandler onGroundHandler = wrapper -> { final MovementTracker tracker = wrapper.user().get(MovementTracker.class); tracker.incrementIdlePacket(); - tracker.setGround(wrapper.get(Type.BOOLEAN, 0)); + tracker.setGround(wrapper.get(Types.BOOLEAN, 0)); }; protocol.registerServerbound(ServerboundPackets1_9.MOVE_PLAYER_POS, new PacketHandlers() { @Override public void register() { - map(Type.DOUBLE); // 0 - X - map(Type.DOUBLE); // 1 - Y - map(Type.DOUBLE); // 2 - Z - map(Type.BOOLEAN); // 3 - Ground + map(Types.DOUBLE); // 0 - X + map(Types.DOUBLE); // 1 - Y + map(Types.DOUBLE); // 2 - Z + map(Types.BOOLEAN); // 3 - Ground handler(onGroundHandler); } }); protocol.registerServerbound(ServerboundPackets1_9.MOVE_PLAYER_POS_ROT, new PacketHandlers() { @Override public void register() { - map(Type.DOUBLE); // 0 - X - map(Type.DOUBLE); // 1 - Y - map(Type.DOUBLE); // 2 - Z - map(Type.FLOAT); // 3 - Yaw - map(Type.FLOAT); // 4 - Pitch - map(Type.BOOLEAN); // 5 - Ground + map(Types.DOUBLE); // 0 - X + map(Types.DOUBLE); // 1 - Y + map(Types.DOUBLE); // 2 - Z + map(Types.FLOAT); // 3 - Yaw + map(Types.FLOAT); // 4 - Pitch + map(Types.BOOLEAN); // 5 - Ground handler(onGroundHandler); } }); protocol.registerServerbound(ServerboundPackets1_9.MOVE_PLAYER_ROT, new PacketHandlers() { @Override public void register() { - map(Type.FLOAT); // 0 - Yaw - map(Type.FLOAT); // 1 - Pitch - map(Type.BOOLEAN); // 2 - Ground + map(Types.FLOAT); // 0 - Yaw + map(Types.FLOAT); // 1 - Pitch + map(Types.BOOLEAN); // 2 - Ground handler(onGroundHandler); } }); protocol.registerServerbound(ServerboundPackets1_9.MOVE_PLAYER_STATUS_ONLY, new PacketHandlers() { @Override public void register() { - map(Type.BOOLEAN); // 0 - Ground + map(Types.BOOLEAN); // 0 - Ground handler(onGroundHandler); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/SpawnPackets1_9.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/SpawnPackets1_9.java index 8db3f8aa4..1bca713bd 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/SpawnPackets1_9.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/SpawnPackets1_9.java @@ -28,10 +28,10 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_8; import com.viaversion.viaversion.api.type.types.version.Types1_9; import com.viaversion.viaversion.protocols.v1_8.packet.ClientboundPackets1_8; -import com.viaversion.viaversion.protocols.v1_8to1_9.rewriter.ItemRewriter; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.metadata.MetadataRewriter1_9To1_8; import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9; @@ -40,7 +40,7 @@ import java.util.ArrayList; import java.util.List; public class SpawnPackets1_9 { - public static final ValueTransformer toNewDouble = new ValueTransformer<>(Type.DOUBLE) { + public static final ValueTransformer toNewDouble = new ValueTransformer<>(Types.DOUBLE) { @Override public Double transform(PacketWrapper wrapper, Integer inputValue) { return inputValue / 32D; @@ -51,65 +51,65 @@ public class SpawnPackets1_9 { protocol.registerClientbound(ClientboundPackets1_8.ADD_ENTITY, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID + map(Types.VAR_INT); // 0 - Entity ID handler(wrapper -> { - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); - wrapper.write(Type.UUID, tracker.getEntityUUID(entityID)); // 1 - UUID + wrapper.write(Types.UUID, tracker.getEntityUUID(entityID)); // 1 - UUID }); - map(Type.BYTE); // 2 - Type + map(Types.BYTE); // 2 - Type // Parse this info handler(wrapper -> { - int entityID = wrapper.get(Type.VAR_INT, 0); - int typeID = wrapper.get(Type.BYTE, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); + int typeID = wrapper.get(Types.BYTE, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.addEntity(entityID, EntityTypes1_10.getTypeFromId(typeID, true)); }); - map(Type.INT, toNewDouble); // 3 - X - Needs to be divided by 32 - map(Type.INT, toNewDouble); // 4 - Y - Needs to be divided by 32 - map(Type.INT, toNewDouble); // 5 - Z - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 3 - X - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 4 - Y - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 5 - Z - Needs to be divided by 32 - map(Type.BYTE); // 6 - Pitch - map(Type.BYTE); // 7 - Yaw + map(Types.BYTE); // 6 - Pitch + map(Types.BYTE); // 7 - Yaw - map(Type.INT); // 8 - Data + map(Types.INT); // 8 - Data // Create last 3 shorts handler(wrapper -> { - int data = wrapper.get(Type.INT, 0); // Data (1st Integer) + int data = wrapper.get(Types.INT, 0); // Data (1st Integer) short vX = 0; short vY = 0; short vZ = 0; if (data > 0) { - vX = wrapper.read(Type.SHORT); - vY = wrapper.read(Type.SHORT); - vZ = wrapper.read(Type.SHORT); + vX = wrapper.read(Types.SHORT); + vY = wrapper.read(Types.SHORT); + vZ = wrapper.read(Types.SHORT); } - wrapper.write(Type.SHORT, vX); - wrapper.write(Type.SHORT, vY); - wrapper.write(Type.SHORT, vZ); + wrapper.write(Types.SHORT, vX); + wrapper.write(Types.SHORT, vY); + wrapper.write(Types.SHORT, vZ); }); // Handle potions handler(wrapper -> { - final int entityID = wrapper.get(Type.VAR_INT, 0); - final int data = wrapper.get(Type.INT, 0); // Data + final int entityID = wrapper.get(Types.VAR_INT, 0); + final int data = wrapper.get(Types.INT, 0); // Data - int typeID = wrapper.get(Type.BYTE, 0); + int typeID = wrapper.get(Types.BYTE, 0); if (EntityTypes1_10.getTypeFromId(typeID, true) == EntityTypes1_10.EntityType.SPLASH_POTION) { // Convert this to meta data, woo! PacketWrapper metaPacket = wrapper.create(ClientboundPackets1_9.SET_ENTITY_DATA, wrapper1 -> { - wrapper1.write(Type.VAR_INT, entityID); + wrapper1.write(Types.VAR_INT, entityID); List meta = new ArrayList<>(); Item item = new DataItem(373, (byte) 1, (short) data, null); // Potion ItemRewriter.toClient(item); // Rewrite so that it gets the right nbt // TEMP FIX FOR POTIONS UNTIL WE FIGURE OUT HOW TO TRANSFORM SENT PACKETS - Metadata potion = new Metadata(5, MetaType1_9.Slot, item); + Metadata potion = new Metadata(5, MetaType1_9.ITEM, item); meta.add(potion); wrapper1.write(Types1_9.METADATA_LIST, meta); }); @@ -125,78 +125,78 @@ public class SpawnPackets1_9 { protocol.registerClientbound(ClientboundPackets1_8.ADD_EXPERIENCE_ORB, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID + map(Types.VAR_INT); // 0 - Entity ID // Parse this info handler(wrapper -> { - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.addEntity(entityID, EntityTypes1_10.EntityType.EXPERIENCE_ORB); }); - map(Type.INT, toNewDouble); // 1 - X - Needs to be divided by 32 - map(Type.INT, toNewDouble); // 2 - Y - Needs to be divided by 32 - map(Type.INT, toNewDouble); // 3 - Z - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 1 - X - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 2 - Y - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 3 - Z - Needs to be divided by 32 - map(Type.SHORT); // 4 - Amount to spawn + map(Types.SHORT); // 4 - Amount to spawn } }); protocol.registerClientbound(ClientboundPackets1_8.ADD_GLOBAL_ENTITY, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.BYTE); // 1 - Type + map(Types.VAR_INT); // 0 - Entity ID + map(Types.BYTE); // 1 - Type // Parse this info handler(wrapper -> { // Currently only lightning uses this - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.addEntity(entityID, EntityTypes1_10.EntityType.LIGHTNING); }); - map(Type.INT, toNewDouble); // 2 - X - Needs to be divided by 32 - map(Type.INT, toNewDouble); // 3 - Y - Needs to be divided by 32 - map(Type.INT, toNewDouble); // 4 - Z - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 2 - X - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 3 - Y - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 4 - Z - Needs to be divided by 32 } }); protocol.registerClientbound(ClientboundPackets1_8.ADD_MOB, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID + map(Types.VAR_INT); // 0 - Entity ID handler(wrapper -> { - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); - wrapper.write(Type.UUID, tracker.getEntityUUID(entityID)); // 1 - UUID + wrapper.write(Types.UUID, tracker.getEntityUUID(entityID)); // 1 - UUID }); - map(Type.UNSIGNED_BYTE); // 2 - Type + map(Types.UNSIGNED_BYTE); // 2 - Type // Parse this info handler(wrapper -> { - int entityID = wrapper.get(Type.VAR_INT, 0); - int typeID = wrapper.get(Type.UNSIGNED_BYTE, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); + int typeID = wrapper.get(Types.UNSIGNED_BYTE, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.addEntity(entityID, EntityTypes1_10.getTypeFromId(typeID, false)); }); - map(Type.INT, toNewDouble); // 3 - X - Needs to be divided by 32 - map(Type.INT, toNewDouble); // 4 - Y - Needs to be divided by 32 - map(Type.INT, toNewDouble); // 5 - Z - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 3 - X - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 4 - Y - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 5 - Z - Needs to be divided by 32 - map(Type.BYTE); // 6 - Yaw - map(Type.BYTE); // 7 - Pitch - map(Type.BYTE); // 8 - Head Pitch + map(Types.BYTE); // 6 - Yaw + map(Types.BYTE); // 7 - Pitch + map(Types.BYTE); // 8 - Head Pitch - map(Type.SHORT); // 9 - Velocity X - map(Type.SHORT); // 10 - Velocity Y - map(Type.SHORT); // 11 - Velocity Z + map(Types.SHORT); // 9 - Velocity X + map(Types.SHORT); // 10 - Velocity Y + map(Types.SHORT); // 11 - Velocity Z map(Types1_8.METADATA_LIST, Types1_9.METADATA_LIST); handler(wrapper -> { List metadataList = wrapper.get(Types1_9.METADATA_LIST, 0); - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); if (tracker.hasEntity(entityId)) { protocol.get(MetadataRewriter1_9To1_8.class).handleMetadata(entityId, metadataList, wrapper.user()); @@ -208,7 +208,7 @@ public class SpawnPackets1_9 { // Handler for meta data handler(wrapper -> { List metadataList = wrapper.get(Types1_9.METADATA_LIST, 0); - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.handleMetadata(entityID, metadataList); }); @@ -218,54 +218,54 @@ public class SpawnPackets1_9 { protocol.registerClientbound(ClientboundPackets1_8.ADD_PAINTING, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID + map(Types.VAR_INT); // 0 - Entity ID // Parse this info handler(wrapper -> { - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.addEntity(entityID, EntityTypes1_10.EntityType.PAINTING); }); handler(wrapper -> { - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); - wrapper.write(Type.UUID, tracker.getEntityUUID(entityID)); // 1 - UUID + wrapper.write(Types.UUID, tracker.getEntityUUID(entityID)); // 1 - UUID }); - map(Type.STRING); // 2 - Title - map(Type.POSITION1_8); // 3 - Position - map(Type.BYTE); // 4 - Direction + map(Types.STRING); // 2 - Title + map(Types.BLOCK_POSITION1_8); // 3 - Position + map(Types.BYTE); // 4 - Direction } }); protocol.registerClientbound(ClientboundPackets1_8.ADD_PLAYER, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Player UUID + map(Types.VAR_INT); // 0 - Entity ID + map(Types.UUID); // 1 - Player UUID // Parse this info handler(wrapper -> { - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.addEntity(entityID, EntityTypes1_10.EntityType.PLAYER); }); - map(Type.INT, toNewDouble); // 2 - X - Needs to be divided by 32 - map(Type.INT, toNewDouble); // 3 - Y - Needs to be divided by 32 - map(Type.INT, toNewDouble); // 4 - Z - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 2 - X - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 3 - Y - Needs to be divided by 32 + map(Types.INT, toNewDouble); // 4 - Z - Needs to be divided by 32 - map(Type.BYTE); // 5 - Yaw - map(Type.BYTE); // 6 - Pitch + map(Types.BYTE); // 5 - Yaw + map(Types.BYTE); // 6 - Pitch //Handle discontinued player hand item handler(wrapper -> { - short item = wrapper.read(Type.SHORT); + short item = wrapper.read(Types.SHORT); if (item != 0) { PacketWrapper packet = PacketWrapper.create(ClientboundPackets1_9.SET_EQUIPPED_ITEM, null, wrapper.user()); - packet.write(Type.VAR_INT, wrapper.get(Type.VAR_INT, 0)); - packet.write(Type.VAR_INT, 0); - packet.write(Type.ITEM1_8, new DataItem(item, (byte) 1, (short) 0, null)); + packet.write(Types.VAR_INT, wrapper.get(Types.VAR_INT, 0)); + packet.write(Types.VAR_INT, 0); + packet.write(Types.ITEM1_8, new DataItem(item, (byte) 1, (short) 0, null)); packet.send(Protocol1_8To1_9.class); } }); @@ -274,7 +274,7 @@ public class SpawnPackets1_9 { handler(wrapper -> { List metadataList = wrapper.get(Types1_9.METADATA_LIST, 0); - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); if (tracker.hasEntity(entityId)) { protocol.get(MetadataRewriter1_9To1_8.class).handleMetadata(entityId, metadataList, wrapper.user()); @@ -287,7 +287,7 @@ public class SpawnPackets1_9 { // Handler for meta data handler(wrapper -> { List metadataList = wrapper.get(Types1_9.METADATA_LIST, 0); - int entityID = wrapper.get(Type.VAR_INT, 0); + int entityID = wrapper.get(Types.VAR_INT, 0); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); tracker.handleMetadata(entityID, metadataList); }); @@ -298,10 +298,10 @@ public class SpawnPackets1_9 { @Override public void register() { - map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entities to destroy + map(Types.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entities to destroy handler(wrapper -> { - int[] entities = wrapper.get(Type.VAR_INT_ARRAY_PRIMITIVE, 0); + int[] entities = wrapper.get(Types.VAR_INT_ARRAY_PRIMITIVE, 0); EntityTracker tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); for (int entity : entities) { // EntityTracker diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/WorldPacketRewriter1_9.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/WorldPacketRewriter1_9.java index 3b94f41f3..0b98fded8 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/WorldPacketRewriter1_9.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/WorldPacketRewriter1_9.java @@ -31,6 +31,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.BulkChunkType1_8; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_8; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_1; @@ -55,10 +56,10 @@ public class WorldPacketRewriter1_9 { protocol.registerClientbound(ClientboundPackets1_8.UPDATE_SIGN, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_8); // 0 - Sign Position + map(Types.BLOCK_POSITION1_8); // 0 - Sign Position handler(wrapper -> { for (int i = 0; i < 4; i++) { - final String line = wrapper.read(Type.STRING); // Should be Type.COMPONENT but would break in some cases + final String line = wrapper.read(Types.STRING); // Should be Type.COMPONENT but would break in some cases Protocol1_8To1_9.STRING_TO_JSON.write(wrapper, line); } }); @@ -68,24 +69,24 @@ public class WorldPacketRewriter1_9 { protocol.registerClientbound(ClientboundPackets1_8.LEVEL_EVENT, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Effect ID - map(Type.POSITION1_8); // 1 - Position - map(Type.INT); // 2 - Data - map(Type.BOOLEAN); // 3 - Disable relative volume + map(Types.INT); // 0 - Effect ID + map(Types.BLOCK_POSITION1_8); // 1 - Position + map(Types.INT); // 2 - Data + map(Types.BOOLEAN); // 3 - Disable relative volume handler(wrapper -> { - int id = wrapper.get(Type.INT, 0); + int id = wrapper.get(Types.INT, 0); id = Effect.getNewId(id); - wrapper.set(Type.INT, 0, id); + wrapper.set(Types.INT, 0, id); }); // Rewrite potion effect as it changed to use a dynamic registry handler(wrapper -> { - int id = wrapper.get(Type.INT, 0); + int id = wrapper.get(Types.INT, 0); if (id == 2002) { - int data = wrapper.get(Type.INT, 1); + int data = wrapper.get(Types.INT, 1); int newData = ItemRewriter.getNewEffectID(data); - wrapper.set(Type.INT, 1, newData); + wrapper.set(Types.INT, 1, newData); } }); } @@ -94,12 +95,12 @@ public class WorldPacketRewriter1_9 { protocol.registerClientbound(ClientboundPackets1_8.CUSTOM_SOUND, new PacketHandlers() { @Override public void register() { - map(Type.STRING); // 0 - Sound Name + map(Types.STRING); // 0 - Sound Name // 1 - Sound Category ID // Everything else gets written through handler(wrapper -> { - String name = Key.stripMinecraftNamespace(wrapper.get(Type.STRING, 0)); + String name = Key.stripMinecraftNamespace(wrapper.get(Types.STRING, 0)); SoundEffect effect = SoundEffect.getByName(name); int catid = 0; @@ -108,13 +109,13 @@ public class WorldPacketRewriter1_9 { catid = effect.getCategory().getId(); newname = effect.getNewName(); } - wrapper.set(Type.STRING, 0, newname); - wrapper.write(Type.VAR_INT, catid); // Write Category ID + wrapper.set(Types.STRING, 0, newname); + wrapper.write(Types.VAR_INT, catid); // Write Category ID if (effect != null && effect.isBreakSound()) { EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); - int x = wrapper.passthrough(Type.INT); //Position X - int y = wrapper.passthrough(Type.INT); //Position Y - int z = wrapper.passthrough(Type.INT); //Position Z + int x = wrapper.passthrough(Types.INT); //Position X + int y = wrapper.passthrough(Types.INT); //Position Y + int z = wrapper.passthrough(Types.INT); //Position Z if (tracker.interactedBlockRecently((int) Math.floor(x / 8.0), (int) Math.floor(y / 8.0), (int) Math.floor(z / 8.0))) { wrapper.cancel(); } @@ -133,8 +134,8 @@ public class WorldPacketRewriter1_9 { // Check if the chunk should be handled as an unload packet if (chunk.isFullChunk() && chunk.getBitmask() == 0) { wrapper.setPacketType(ClientboundPackets1_9.FORGET_LEVEL_CHUNK); - wrapper.write(Type.INT, chunk.getX()); - wrapper.write(Type.INT, chunk.getZ()); + wrapper.write(Types.INT, chunk.getX()); + wrapper.write(Types.INT, chunk.getZ()); // Remove commandBlocks on chunk unload CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class); @@ -149,8 +150,8 @@ public class WorldPacketRewriter1_9 { int chunkZ = chunk.getZ() + face.modZ(); if (!clientChunks.getLoadedChunks().contains(ClientChunks.toLong(chunkX, chunkZ))) { PacketWrapper unloadChunk = wrapper.create(ClientboundPackets1_9.FORGET_LEVEL_CHUNK); - unloadChunk.write(Type.INT, chunkX); - unloadChunk.write(Type.INT, chunkZ); + unloadChunk.write(Types.INT, chunkX); + unloadChunk.write(Types.INT, chunkZ); unloadChunk.send(Protocol1_8To1_9.class); } } @@ -211,13 +212,13 @@ public class WorldPacketRewriter1_9 { protocol.registerClientbound(ClientboundPackets1_8.BLOCK_ENTITY_DATA, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_8); // 0 - Block Position - map(Type.UNSIGNED_BYTE); // 1 - Action - map(Type.NAMED_COMPOUND_TAG); // 2 - NBT (Might not be present) + map(Types.BLOCK_POSITION1_8); // 0 - Block Position + map(Types.UNSIGNED_BYTE); // 1 - Action + map(Types.NAMED_COMPOUND_TAG); // 2 - NBT (Might not be present) handler(wrapper -> { - int action = wrapper.get(Type.UNSIGNED_BYTE, 0); + int action = wrapper.get(Types.UNSIGNED_BYTE, 0); if (action == 1) { // Update Spawner - CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); + CompoundTag tag = wrapper.get(Types.NAMED_COMPOUND_TAG, 0); if (tag != null) { StringTag entityId = tag.getStringTag("EntityId"); if (entityId != null) { @@ -234,7 +235,7 @@ public class WorldPacketRewriter1_9 { } if (action == 2) { // Update Command Block CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class); - provider.addOrUpdateBlock(wrapper.user(), wrapper.get(Type.POSITION1_8, 0), wrapper.get(Type.NAMED_COMPOUND_TAG, 0)); + provider.addOrUpdateBlock(wrapper.user(), wrapper.get(Types.BLOCK_POSITION1_8, 0), wrapper.get(Types.NAMED_COMPOUND_TAG, 0)); // To prevent window issues don't send updates wrapper.cancel(); @@ -248,11 +249,11 @@ public class WorldPacketRewriter1_9 { protocol.registerServerbound(ServerboundPackets1_9.SIGN_UPDATE, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_8); // 0 - Sign Position + map(Types.BLOCK_POSITION1_8); // 0 - Sign Position handler(wrapper -> { for (int i = 0; i < 4; i++) { - final String line = wrapper.read(Type.STRING); - wrapper.write(Type.COMPONENT, ComponentUtil.plainToJson(line)); + final String line = wrapper.read(Types.STRING); + wrapper.write(Types.COMPONENT, ComponentUtil.plainToJson(line)); } }); } @@ -261,16 +262,16 @@ public class WorldPacketRewriter1_9 { protocol.registerServerbound(ServerboundPackets1_9.PLAYER_ACTION, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // Action - map(Type.POSITION1_8); // Position + map(Types.VAR_INT); // Action + map(Types.BLOCK_POSITION1_8); // Position handler(wrapper -> { - int status = wrapper.get(Type.VAR_INT, 0); + int status = wrapper.get(Types.VAR_INT, 0); if (status == 6) wrapper.cancel(); }); // Blocking handler(wrapper -> { - int status = wrapper.get(Type.VAR_INT, 0); + int status = wrapper.get(Types.VAR_INT, 0); if (status == 5 || status == 4 || status == 3) { EntityTracker1_9 entityTracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); if (entityTracker.isBlocking()) { @@ -285,12 +286,12 @@ public class WorldPacketRewriter1_9 { }); protocol.registerServerbound(ServerboundPackets1_9.USE_ITEM, null, wrapper -> { - int hand = wrapper.read(Type.VAR_INT); + int hand = wrapper.read(Types.VAR_INT); // Wipe the input buffer wrapper.clearInputBuffer(); wrapper.setPacketType(ServerboundPackets1_8.USE_ITEM_ON); - wrapper.write(Type.POSITION1_8, new Position(-1, (short) -1, -1)); - wrapper.write(Type.UNSIGNED_BYTE, (short) 255); + wrapper.write(Types.BLOCK_POSITION1_8, new Position(-1, (short) -1, -1)); + wrapper.write(Types.UNSIGNED_BYTE, (short) 255); // Write item in hand Item item = Protocol1_8To1_9.getHandItem(wrapper.user()); // Blocking patch @@ -332,36 +333,36 @@ public class WorldPacketRewriter1_9 { tracker.setBlocking(false); } } - wrapper.write(Type.ITEM1_8, item); + wrapper.write(Types.ITEM1_8, item); - wrapper.write(Type.UNSIGNED_BYTE, (short) 0); - wrapper.write(Type.UNSIGNED_BYTE, (short) 0); - wrapper.write(Type.UNSIGNED_BYTE, (short) 0); + wrapper.write(Types.UNSIGNED_BYTE, (short) 0); + wrapper.write(Types.UNSIGNED_BYTE, (short) 0); + wrapper.write(Types.UNSIGNED_BYTE, (short) 0); }); protocol.registerServerbound(ServerboundPackets1_9.USE_ITEM_ON, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_8); // 0 - Position - map(Type.VAR_INT, Type.UNSIGNED_BYTE); // 1 - Block Face + map(Types.BLOCK_POSITION1_8); // 0 - Position + map(Types.VAR_INT, Types.UNSIGNED_BYTE); // 1 - Block Face handler(wrapper -> { - final int hand = wrapper.read(Type.VAR_INT); // 2 - Hand + final int hand = wrapper.read(Types.VAR_INT); // 2 - Hand if (hand != 0) wrapper.cancel(); }); handler(wrapper -> { Item item = Protocol1_8To1_9.getHandItem(wrapper.user()); - wrapper.write(Type.ITEM1_8, item); // 3 - Item + wrapper.write(Types.ITEM1_8, item); // 3 - Item }); - map(Type.UNSIGNED_BYTE); // 4 - X - map(Type.UNSIGNED_BYTE); // 5 - Y - map(Type.UNSIGNED_BYTE); // 6 - Z + map(Types.UNSIGNED_BYTE); // 4 - X + map(Types.UNSIGNED_BYTE); // 5 - Y + map(Types.UNSIGNED_BYTE); // 6 - Z //Register block place to fix sounds handler(wrapper -> { - int face = wrapper.get(Type.UNSIGNED_BYTE, 0); + int face = wrapper.get(Types.UNSIGNED_BYTE, 0); if (face == 255) return; - Position p = wrapper.get(Type.POSITION1_8, 0); + Position p = wrapper.get(Types.BLOCK_POSITION1_8, 0); int x = p.x(); int y = p.y(); int z = p.z(); @@ -381,15 +382,15 @@ public class WorldPacketRewriter1_9 { handler(wrapper -> { CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class); - Position pos = wrapper.get(Type.POSITION1_8, 0); + Position pos = wrapper.get(Types.BLOCK_POSITION1_8, 0); Optional tag = provider.get(wrapper.user(), pos); // Send the Update Block Entity packet if present if (tag.isPresent()) { PacketWrapper updateBlockEntity = PacketWrapper.create(ClientboundPackets1_9.BLOCK_ENTITY_DATA, null, wrapper.user()); - updateBlockEntity.write(Type.POSITION1_8, pos); - updateBlockEntity.write(Type.UNSIGNED_BYTE, (short) 2); - updateBlockEntity.write(Type.NAMED_COMPOUND_TAG, tag.get()); + updateBlockEntity.write(Types.BLOCK_POSITION1_8, pos); + updateBlockEntity.write(Types.UNSIGNED_BYTE, (short) 2); + updateBlockEntity.write(Types.NAMED_COMPOUND_TAG, tag.get()); updateBlockEntity.scheduleSend(Protocol1_8To1_9.class); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/EntityTracker1_9.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/EntityTracker1_9.java index e412c326a..20ad1151b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/EntityTracker1_9.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/EntityTracker1_9.java @@ -31,6 +31,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.data.GameMode; @@ -86,9 +87,9 @@ public class EntityTracker1_9 extends EntityTrackerBase { public void setSecondHand(int entityID, Item item) { PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.SET_EQUIPPED_ITEM, null, user()); - wrapper.write(Type.VAR_INT, entityID); - wrapper.write(Type.VAR_INT, 1); // slot - wrapper.write(Type.ITEM1_8, this.itemInSecondHand = item); + wrapper.write(Types.VAR_INT, entityID); + wrapper.write(Types.VAR_INT, 1); // slot + wrapper.write(Types.ITEM1_8, this.itemInSecondHand = item); wrapper.scheduleSend(Protocol1_8To1_9.class); } @@ -160,7 +161,7 @@ public class EntityTracker1_9 extends EntityTrackerBase { for (Metadata metadata : new ArrayList<>(metadataList)) { if (type == EntityType.SKELETON) { if ((getMetaByIndex(metadataList, 12)) == null) { - metadataList.add(new Metadata(12, MetaType1_9.Boolean, true)); + metadataList.add(new Metadata(12, MetaType1_9.BOOLEAN, true)); } } @@ -193,7 +194,7 @@ public class EntityTracker1_9 extends EntityTrackerBase { if (metadata.id() == 12 && Via.getConfig().isLeftHandedHandling()) { // Player model metadataList.add(new Metadata( 13, // Main hand - MetaType1_9.Byte, + MetaType1_9.BYTE, (byte) (((((byte) metadata.getValue()) & 0x80) != 0) ? 0 : 1) )); } @@ -212,11 +213,11 @@ public class EntityTracker1_9 extends EntityTrackerBase { knownHolograms.add(entityId); // Send movement PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.MOVE_ENTITY_POS, null, user()); - wrapper.write(Type.VAR_INT, entityId); - wrapper.write(Type.SHORT, (short) 0); - wrapper.write(Type.SHORT, (short) (128D * (Via.getConfig().getHologramYOffset() * 32D))); - wrapper.write(Type.SHORT, (short) 0); - wrapper.write(Type.BOOLEAN, true); + wrapper.write(Types.VAR_INT, entityId); + wrapper.write(Types.SHORT, (short) 0); + wrapper.write(Types.SHORT, (short) (128D * (Via.getConfig().getHologramYOffset() * 32D))); + wrapper.write(Types.SHORT, (short) 0); + wrapper.write(Types.BOOLEAN, true); wrapper.scheduleSend(Protocol1_8To1_9.class); } } @@ -272,24 +273,24 @@ public class EntityTracker1_9 extends EntityTrackerBase { public void sendTeamPacket(boolean add, boolean now) { PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.SET_PLAYER_TEAM, null, user()); - wrapper.write(Type.STRING, "viaversion"); // Use viaversion as name + wrapper.write(Types.STRING, "viaversion"); // Use viaversion as name if (add) { // add if (!teamExists) { - wrapper.write(Type.BYTE, (byte) 0); // make team - wrapper.write(Type.STRING, "viaversion"); - wrapper.write(Type.STRING, "§f"); // prefix - wrapper.write(Type.STRING, ""); // suffix - wrapper.write(Type.BYTE, (byte) 0); // friendly fire - wrapper.write(Type.STRING, ""); // nametags - wrapper.write(Type.STRING, "never"); // collision rule :) - wrapper.write(Type.BYTE, (byte) 15); // color + wrapper.write(Types.BYTE, (byte) 0); // make team + wrapper.write(Types.STRING, "viaversion"); + wrapper.write(Types.STRING, "§f"); // prefix + wrapper.write(Types.STRING, ""); // suffix + wrapper.write(Types.BYTE, (byte) 0); // friendly fire + wrapper.write(Types.STRING, ""); // nametags + wrapper.write(Types.STRING, "never"); // collision rule :) + wrapper.write(Types.BYTE, (byte) 15); // color } else { - wrapper.write(Type.BYTE, (byte) 3); + wrapper.write(Types.BYTE, (byte) 3); } - wrapper.write(Type.STRING_ARRAY, new String[]{user().getProtocolInfo().getUsername()}); + wrapper.write(Types.STRING_ARRAY, new String[]{user().getProtocolInfo().getUsername()}); } else { - wrapper.write(Type.BYTE, (byte) 1); // remove team + wrapper.write(Types.BYTE, (byte) 1); // remove team } teamExists = add; if (now) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_1to1_9_3/Protocol1_9_1To1_9_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_1to1_9_3/Protocol1_9_1To1_9_3.java index 0ba5083ca..b9b730f82 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_1to1_9_3/Protocol1_9_1To1_9_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_1to1_9_3/Protocol1_9_1To1_9_3.java @@ -33,6 +33,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_1; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3; import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9; @@ -44,7 +45,7 @@ import java.util.List; public class Protocol1_9_1To1_9_3 extends AbstractProtocol { - public static final ValueTransformer ADJUST_PITCH = new ValueTransformer<>(Type.UNSIGNED_BYTE, Type.UNSIGNED_BYTE) { + public static final ValueTransformer ADJUST_PITCH = new ValueTransformer<>(Types.UNSIGNED_BYTE, Types.UNSIGNED_BYTE) { @Override public Short transform(PacketWrapper wrapper, Short inputValue) { return (short) Math.round(inputValue / 63.5F * 63.0F); @@ -60,18 +61,18 @@ public class Protocol1_9_1To1_9_3 extends AbstractProtocol { //read data - Position position = wrapper.read(Type.POSITION1_8); + Position position = wrapper.read(Types.BLOCK_POSITION1_8); JsonElement[] lines = new JsonElement[4]; for (int i = 0; i < 4; i++) { - lines[i] = wrapper.read(Type.COMPONENT); + lines[i] = wrapper.read(Types.COMPONENT); } wrapper.clearInputBuffer(); //write data wrapper.setPacketType(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA); - wrapper.write(Type.POSITION1_8, position); //Block location - wrapper.write(Type.UNSIGNED_BYTE, (short) 9); //Action type (9 update sign) + wrapper.write(Types.BLOCK_POSITION1_8, position); //Block location + wrapper.write(Types.UNSIGNED_BYTE, (short) 9); //Action type (9 update sign) //Create nbt CompoundTag tag = new CompoundTag(); @@ -83,7 +84,7 @@ public class Protocol1_9_1To1_9_3 extends AbstractProtocol { @@ -115,13 +116,13 @@ public class Protocol1_9_1To1_9_3 extends AbstractProtocol { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 1); + int dimensionId = wrapper.get(Types.INT, 1); clientWorld.setEnvironment(dimensionId); }); } @@ -130,10 +131,10 @@ public class Protocol1_9_1To1_9_3 extends AbstractProtocol { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 0); + int dimensionId = wrapper.get(Types.INT, 0); clientWorld.setEnvironment(dimensionId); }); } @@ -143,12 +144,12 @@ public class Protocol1_9_1To1_9_3 extends AbstractProtocol { - public static final ValueTransformer TO_NEW_PITCH = new ValueTransformer<>(Type.FLOAT) { + public static final ValueTransformer TO_NEW_PITCH = new ValueTransformer<>(Types.FLOAT) { @Override public Float transform(PacketWrapper wrapper, Short inputValue) { return inputValue / 63.0F; @@ -71,13 +72,13 @@ public class Protocol1_9_3To1_10 extends AbstractProtocol { - int id = wrapper.get(Type.VAR_INT, 0); - wrapper.set(Type.VAR_INT, 0, getNewSoundId(id)); + int id = wrapper.get(Types.VAR_INT, 0); + wrapper.set(Types.VAR_INT, 0, getNewSoundId(id)); }); } }); @@ -104,7 +105,7 @@ public class Protocol1_9_3To1_10 extends AbstractProtocol { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 1); + int dimensionId = wrapper.get(Types.INT, 1); clientWorld.setEnvironment(dimensionId); }); } @@ -165,12 +166,12 @@ public class Protocol1_9_3To1_10 extends AbstractProtocol { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 0); + int dimensionId = wrapper.get(Types.INT, 0); clientWorld.setEnvironment(dimensionId); }); } @@ -194,12 +195,12 @@ public class Protocol1_9_3To1_10 extends AbstractProtocol { ResourcePackTracker tracker = wrapper.user().get(ResourcePackTracker.class); - tracker.setLastHash(wrapper.get(Type.STRING, 1)); // Store the hash for resourcepack status + tracker.setLastHash(wrapper.get(Types.STRING, 1)); // Store the hash for resourcepack status }); } }); @@ -210,8 +211,8 @@ public class Protocol1_9_3To1_10 extends AbstractProtocol { ResourcePackTracker tracker = wrapper.user().get(ResourcePackTracker.class); - wrapper.write(Type.STRING, tracker.getLastHash()); - wrapper.write(Type.VAR_INT, wrapper.read(Type.VAR_INT)); + wrapper.write(Types.STRING, tracker.getLastHash()); + wrapper.write(Types.VAR_INT, wrapper.read(Types.VAR_INT)); }); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_3to1_10/rewriter/ItemPacketRewriter1_10.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_3to1_10/rewriter/ItemPacketRewriter1_10.java index 1dcfd704e..0a661c22c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_3to1_10/rewriter/ItemPacketRewriter1_10.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_3to1_10/rewriter/ItemPacketRewriter1_10.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.v1_9_3to1_10.rewriter; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3; import com.viaversion.viaversion.protocols.v1_9_3to1_10.Protocol1_9_3To1_10; @@ -28,7 +29,7 @@ import com.viaversion.viaversion.rewriter.ItemRewriter; public class ItemPacketRewriter1_10 extends ItemRewriter { public ItemPacketRewriter1_10(Protocol1_9_3To1_10 protocol) { - super(protocol, Type.ITEM1_8, null); + super(protocol, Types.ITEM1_8, null); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_9to1_9_1/Protocol1_9To1_9_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_9to1_9_1/Protocol1_9To1_9_1.java index 9666a3072..d9f6fbcca 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_9to1_9_1/Protocol1_9To1_9_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_9to1_9_1/Protocol1_9To1_9_1.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.v1_9to1_9_1; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ServerboundPackets1_9; @@ -36,27 +37,27 @@ public class Protocol1_9To1_9_1 extends AbstractProtocol { - int sound = wrapper.get(Type.VAR_INT, 0); + int sound = wrapper.get(Types.VAR_INT, 0); if (sound >= 415) // Add 1 to every sound id since there is no Elytra sound on a 1.9 server - wrapper.set(Type.VAR_INT, 0, sound + 1); + wrapper.set(Types.VAR_INT, 0, sound + 1); }); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/AttributeRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/AttributeRewriter.java index c4fbe3bf8..7818562a0 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/AttributeRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/AttributeRewriter.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.rewriter; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; public class AttributeRewriter { private final Protocol protocol; @@ -30,19 +31,19 @@ public class AttributeRewriter { public void register1_20_5(C packetType) { protocol.registerClientbound(packetType, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Entity ID + wrapper.passthrough(Types.VAR_INT); // Entity ID - final int size = wrapper.passthrough(Type.VAR_INT); + final int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { - final int attributeId = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewAttributeId(attributeId)); + final int attributeId = wrapper.read(Types.VAR_INT); + wrapper.write(Types.VAR_INT, protocol.getMappingData().getNewAttributeId(attributeId)); - wrapper.passthrough(Type.DOUBLE); // Base - final int modifierSize = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.DOUBLE); // Base + final int modifierSize = wrapper.passthrough(Types.VAR_INT); for (int j = 0; j < modifierSize; j++) { - wrapper.passthrough(Type.UUID); // ID - wrapper.passthrough(Type.DOUBLE); // Amount - wrapper.passthrough(Type.BYTE); // Operation + wrapper.passthrough(Types.UUID); // ID + wrapper.passthrough(Types.DOUBLE); // Amount + wrapper.passthrough(Types.BYTE); // Operation } } }); 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 6bfeec003..a8e1fead1 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java @@ -36,6 +36,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.util.MathUtil; import java.util.List; import java.util.function.BiConsumer; @@ -54,15 +55,15 @@ public class BlockRewriter { } public static BlockRewriter legacy(final Protocol protocol) { - return new BlockRewriter<>(protocol, Type.POSITION1_8, Type.NAMED_COMPOUND_TAG); + return new BlockRewriter<>(protocol, Types.BLOCK_POSITION1_8, Types.NAMED_COMPOUND_TAG); } public static BlockRewriter for1_14(final Protocol protocol) { - return new BlockRewriter<>(protocol, Type.POSITION1_14, Type.NAMED_COMPOUND_TAG); + return new BlockRewriter<>(protocol, Types.BLOCK_POSITION1_14, Types.NAMED_COMPOUND_TAG); } public static BlockRewriter for1_20_2(final Protocol protocol) { - return new BlockRewriter<>(protocol, Type.POSITION1_14, Type.COMPOUND_TAG); + return new BlockRewriter<>(protocol, Types.BLOCK_POSITION1_14, Types.COMPOUND_TAG); } public void registerBlockAction(C packetType) { @@ -70,15 +71,15 @@ public class BlockRewriter { @Override public void register() { map(positionType); // Location - map(Type.UNSIGNED_BYTE); // Action id - map(Type.UNSIGNED_BYTE); // Action param - map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE + map(Types.UNSIGNED_BYTE); // Action id + map(Types.UNSIGNED_BYTE); // Action param + map(Types.VAR_INT); // Block id - /!\ NOT BLOCK STATE handler(wrapper -> { if (protocol.getMappingData().getBlockMappings() == null) { return; } - int id = wrapper.get(Type.VAR_INT, 0); + int id = wrapper.get(Types.VAR_INT, 0); int mappedId = protocol.getMappingData().getNewBlockId(id); if (mappedId == -1) { // Block (action) has been removed @@ -86,7 +87,7 @@ public class BlockRewriter { return; } - wrapper.set(Type.VAR_INT, 0, mappedId); + wrapper.set(Types.VAR_INT, 0, mappedId); }); } }); @@ -97,8 +98,8 @@ public class BlockRewriter { @Override public void register() { map(positionType); - map(Type.VAR_INT); - handler(wrapper -> wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.VAR_INT, 0)))); + map(Types.VAR_INT); + handler(wrapper -> wrapper.set(Types.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(wrapper.get(Types.VAR_INT, 0)))); } }); } @@ -107,10 +108,10 @@ public class BlockRewriter { protocol.registerClientbound(packetType, new PacketHandlers() { @Override public void register() { - map(Type.INT); // 0 - Chunk X - map(Type.INT); // 1 - Chunk Z + map(Types.INT); // 0 - Chunk X + map(Types.INT); // 1 - Chunk Z handler(wrapper -> { - for (BlockChangeRecord record : wrapper.passthrough(Type.BLOCK_CHANGE_RECORD_ARRAY)) { + for (BlockChangeRecord record : wrapper.passthrough(Types.BLOCK_CHANGE_ARRAY)) { record.setBlockId(protocol.getMappingData().getNewBlockStateId(record.getBlockId())); } }); @@ -122,10 +123,10 @@ public class BlockRewriter { protocol.registerClientbound(packetType, new PacketHandlers() { @Override public void register() { - map(Type.LONG); // Chunk position - map(Type.BOOLEAN); // Suppress light updates + map(Types.LONG); // Chunk position + map(Types.BOOLEAN); // Suppress light updates handler(wrapper -> { - for (BlockChangeRecord record : wrapper.passthrough(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY)) { + for (BlockChangeRecord record : wrapper.passthrough(Types.VAR_LONG_BLOCK_CHANGE_ARRAY)) { record.setBlockId(protocol.getMappingData().getNewBlockStateId(record.getBlockId())); } }); @@ -137,9 +138,9 @@ public class BlockRewriter { protocol.registerClientbound(packetType, new PacketHandlers() { @Override public void register() { - map(Type.LONG); // Chunk position + map(Types.LONG); // Chunk position handler(wrapper -> { - for (BlockChangeRecord record : wrapper.passthrough(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY)) { + for (BlockChangeRecord record : wrapper.passthrough(Types.VAR_LONG_BLOCK_CHANGE_ARRAY)) { record.setBlockId(protocol.getMappingData().getNewBlockStateId(record.getBlockId())); } }); @@ -156,16 +157,16 @@ public class BlockRewriter { protocol.registerClientbound(packetType, new PacketHandlers() { @Override public void register() { - map(Type.INT); // Effect Id + map(Types.INT); // Effect Id map(positionType); // Location - map(Type.INT); // Data + map(Types.INT); // Data handler(wrapper -> { - int id = wrapper.get(Type.INT, 0); - int data = wrapper.get(Type.INT, 1); + int id = wrapper.get(Types.INT, 0); + int data = wrapper.get(Types.INT, 1); if (id == playRecordId && protocol.getMappingData().getItemMappings() != null) { - wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(data)); + wrapper.set(Types.INT, 1, protocol.getMappingData().getNewItemId(data)); } else if (id == blockBreakId && protocol.getMappingData().getBlockStateMappings() != null) { - wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(data)); + wrapper.set(Types.INT, 1, protocol.getMappingData().getNewBlockStateId(data)); } }); } @@ -230,12 +231,12 @@ public class BlockRewriter { protocol.registerClientbound(packetType, wrapper -> { final Position position = wrapper.passthrough(positionType); - final int blockEntityId = wrapper.read(Type.VAR_INT); + final int blockEntityId = wrapper.read(Types.VAR_INT); final Mappings mappings = protocol.getMappingData().getBlockEntityMappings(); if (mappings != null) { - wrapper.write(Type.VAR_INT, mappings.getNewIdOrDefault(blockEntityId, blockEntityId)); + wrapper.write(Types.VAR_INT, mappings.getNewIdOrDefault(blockEntityId, blockEntityId)); } else { - wrapper.write(Type.VAR_INT, blockEntityId); + wrapper.write(Types.VAR_INT, blockEntityId); } final CompoundTag tag; 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 a0ac6bfac..a5af04e41 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/CommandRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/CommandRewriter.java @@ -23,6 +23,7 @@ import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import java.util.HashMap; import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; @@ -39,54 +40,54 @@ public class CommandRewriter { // Register default parsers this.parserHandlers.put("brigadier:double", wrapper -> { - byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags - if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.DOUBLE); // Min Value - if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.DOUBLE); // Max Value + byte propertyFlags = wrapper.passthrough(Types.BYTE); // Flags + if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Types.DOUBLE); // Min Value + if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Types.DOUBLE); // Max Value }); this.parserHandlers.put("brigadier:float", wrapper -> { - byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags - if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.FLOAT); // Min Value - if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.FLOAT); // Max Value + byte propertyFlags = wrapper.passthrough(Types.BYTE); // Flags + if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Types.FLOAT); // Min Value + if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Types.FLOAT); // Max Value }); this.parserHandlers.put("brigadier:integer", wrapper -> { - byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags - if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.INT); // Min Value - if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.INT); // Max Value + byte propertyFlags = wrapper.passthrough(Types.BYTE); // Flags + if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Types.INT); // Min Value + if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Types.INT); // Max Value }); this.parserHandlers.put("brigadier:long", wrapper -> { - byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags - if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.LONG); // Min Value - if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.LONG); // Max Value + byte propertyFlags = wrapper.passthrough(Types.BYTE); // Flags + if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Types.LONG); // Min Value + if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Types.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(Types.VAR_INT)); // Flags + this.parserHandlers.put("minecraft:entity", wrapper -> wrapper.passthrough(Types.BYTE)); // Flags + this.parserHandlers.put("minecraft:score_holder", wrapper -> wrapper.passthrough(Types.BYTE)); // Flags + this.parserHandlers.put("minecraft:resource", wrapper -> wrapper.passthrough(Types.STRING)); // Resource location + this.parserHandlers.put("minecraft:resource_or_tag", wrapper -> wrapper.passthrough(Types.STRING)); // Resource location/tag + this.parserHandlers.put("minecraft:resource_or_tag_key", wrapper -> wrapper.passthrough(Types.STRING)); // Resource location + this.parserHandlers.put("minecraft:resource_key", wrapper -> wrapper.passthrough(Types.STRING)); // Resource location/tag } public void registerDeclareCommands(C packetType) { protocol.registerClientbound(packetType, wrapper -> { - int size = wrapper.passthrough(Type.VAR_INT); + int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { - byte flags = wrapper.passthrough(Type.BYTE); - wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); // Children indices + byte flags = wrapper.passthrough(Types.BYTE); + wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE); // Children indices if ((flags & 0x08) != 0) { - wrapper.passthrough(Type.VAR_INT); // Redirect node index + wrapper.passthrough(Types.VAR_INT); // Redirect node index } byte nodeType = (byte) (flags & 0x03); if (nodeType == 1 || nodeType == 2) { // Literal/argument node - wrapper.passthrough(Type.STRING); // Name + wrapper.passthrough(Types.STRING); // Name } if (nodeType == 2) { // Argument node - String argumentType = wrapper.read(Type.STRING); + String argumentType = wrapper.read(Types.STRING); String newArgumentType = handleArgumentType(argumentType); if (newArgumentType != null) { - wrapper.write(Type.STRING, newArgumentType); + wrapper.write(Types.STRING, newArgumentType); } // Always call the handler using the previous name @@ -94,53 +95,53 @@ public class CommandRewriter { } if ((flags & 0x10) != 0) { - wrapper.passthrough(Type.STRING); // Suggestion type + wrapper.passthrough(Types.STRING); // Suggestion type } } - wrapper.passthrough(Type.VAR_INT); // Root node index + wrapper.passthrough(Types.VAR_INT); // Root node index }); } public void registerDeclareCommands1_19(C packetType) { protocol.registerClientbound(packetType, wrapper -> { - int size = wrapper.passthrough(Type.VAR_INT); + int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { - byte flags = wrapper.passthrough(Type.BYTE); - wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); // Children indices + byte flags = wrapper.passthrough(Types.BYTE); + wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE); // Children indices if ((flags & 0x08) != 0) { - wrapper.passthrough(Type.VAR_INT); // Redirect node index + wrapper.passthrough(Types.VAR_INT); // Redirect node index } byte nodeType = (byte) (flags & 0x03); if (nodeType == 1 || nodeType == 2) { // Literal/argument node - wrapper.passthrough(Type.STRING); // Name + wrapper.passthrough(Types.STRING); // Name } if (nodeType == 2) { // Argument node - int argumentTypeId = wrapper.read(Type.VAR_INT); + int argumentTypeId = wrapper.read(Types.VAR_INT); String argumentType = argumentType(argumentTypeId); if (argumentType == null) { // Modded servers may send unknown argument types that are ignored by the client // Adjust the id to the hopefully still assumed out-of-bounds pos... - wrapper.write(Type.VAR_INT, mapInvalidArgumentType(argumentTypeId)); + wrapper.write(Types.VAR_INT, mapInvalidArgumentType(argumentTypeId)); continue; } String newArgumentType = handleArgumentType(argumentType); Preconditions.checkNotNull(newArgumentType, "No mapping for argument type %s", argumentType); - wrapper.write(Type.VAR_INT, mappedArgumentTypeId(newArgumentType)); + wrapper.write(Types.VAR_INT, mappedArgumentTypeId(newArgumentType)); // Always call the handler using the previous name handleArgument(wrapper, argumentType); if ((flags & 0x10) != 0) { - wrapper.passthrough(Type.STRING); // Suggestion type + wrapper.passthrough(Types.STRING); // Suggestion type } } } - wrapper.passthrough(Type.VAR_INT); // Root node index + wrapper.passthrough(Types.VAR_INT); // Root node index }); } 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 f9e241144..21d2a3465 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/ComponentRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/ComponentRewriter.java @@ -35,6 +35,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; 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; import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets; import org.checkerframework.checker.nullness.qual.Nullable; @@ -65,10 +66,10 @@ public class ComponentRewriter { protocol.registerClientbound(packetType, new PacketHandlers() { @Override public void register() { - map(Type.UUID); - map(Type.VAR_INT); + map(Types.UUID); + map(Types.VAR_INT); handler(wrapper -> { - final int action = wrapper.get(Type.VAR_INT, 0); + final int action = wrapper.get(Types.VAR_INT, 0); if (action == 0 || action == 3) { passthroughAndProcess(wrapper); } @@ -82,10 +83,10 @@ public class ComponentRewriter { */ public void registerCombatEvent(final C packetType) { protocol.registerClientbound(packetType, wrapper -> { - if (wrapper.passthrough(Type.VAR_INT) == 2) { - wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.INT); - processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT)); + if (wrapper.passthrough(Types.VAR_INT) == 2) { + wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.INT); + processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); } }); } @@ -95,25 +96,25 @@ public class ComponentRewriter { */ public void registerTitle(final C packetType) { protocol.registerClientbound(packetType, wrapper -> { - final int action = wrapper.passthrough(Type.VAR_INT); + final int action = wrapper.passthrough(Types.VAR_INT); if (action >= 0 && action <= 2) { - processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT)); + processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); } }); } public void registerPing() { // Always json - protocol.registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT, wrapper -> processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT))); + protocol.registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT, wrapper -> processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT))); } public void registerLegacyOpenWindow(final C packetType) { protocol.registerClientbound(packetType, new PacketHandlers() { @Override public void register() { - map(Type.UNSIGNED_BYTE); // Id - map(Type.STRING); // Window Type - handler(wrapper -> processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT))); + map(Types.UNSIGNED_BYTE); // Id + map(Types.STRING); // Window Type + handler(wrapper -> processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT))); } }); } @@ -122,8 +123,8 @@ public class ComponentRewriter { protocol.registerClientbound(packetType, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // Id - map(Type.VAR_INT); // Window Type + map(Types.VAR_INT); // Id + map(Types.VAR_INT); // Window Type handler(wrapper -> passthroughAndProcess(wrapper)); } }); @@ -140,9 +141,9 @@ public class ComponentRewriter { protocol.registerClientbound(packetType, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); - map(Type.INT); - handler(wrapper -> processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT))); + map(Types.VAR_INT); + map(Types.INT); + handler(wrapper -> processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT))); } }); } @@ -151,7 +152,7 @@ public class ComponentRewriter { protocol.registerClientbound(packetType, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // Duration + map(Types.VAR_INT); // Duration handler(wrapper -> passthroughAndProcess(wrapper)); } }); @@ -160,10 +161,10 @@ public class ComponentRewriter { public void passthroughAndProcess(final PacketWrapper wrapper) { switch (type) { case JSON: - processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT)); + processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); break; case NBT: - processTag(wrapper.user(), wrapper.passthrough(Type.TAG)); + processTag(wrapper.user(), wrapper.passthrough(Types.TAG)); break; } } 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 d132e9223..0d057ce67 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java @@ -43,6 +43,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.rewriter.ItemRewriter; import com.viaversion.viaversion.api.rewriter.RewriterBase; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.data.entity.DimensionDataImpl; import com.viaversion.viaversion.rewriter.meta.MetaFilter; import com.viaversion.viaversion.rewriter.meta.MetaHandlerEvent; @@ -227,9 +228,9 @@ public abstract class EntityRewriter { - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); EntityType entityType = tracker(wrapper.user()).entityType(entityId); if (entityType == fallingBlockType) { - wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.INT, 0))); + wrapper.set(Types.INT, 0, protocol.getMappingData().getNewBlockStateId(wrapper.get(Types.INT, 0))); } }); } @@ -264,26 +265,26 @@ public abstract class EntityRewriter { if (protocol.getMappingData() == null) { return; } - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); EntityType entityType = tracker(wrapper.user()).entityType(entityId); if (entityType == fallingBlockType) { - wrapper.set(Type.VAR_INT, 2, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.VAR_INT, 2))); + wrapper.set(Types.VAR_INT, 2, protocol.getMappingData().getNewBlockStateId(wrapper.get(Types.VAR_INT, 2))); } }); } @@ -311,7 +312,7 @@ public abstract class EntityRewriter { - int[] entityIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); + int[] entityIds = wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE); EntityTracker entityTracker = tracker(wrapper.user()); for (int entity : entityIds) { entityTracker.removeEntity(entity); @@ -336,7 +337,7 @@ public abstract class EntityRewriter { - int entityId = wrapper.passthrough(Type.VAR_INT); + int entityId = wrapper.passthrough(Types.VAR_INT); tracker(wrapper.user()).removeEntity(entityId); }); } @@ -345,14 +346,14 @@ public abstract class EntityRewriter { - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); List metadata = wrapper.get(newMetaType, 0); handleMetadata(entityId, metadata, wrapper.user()); }); @@ -371,7 +372,7 @@ public abstract class EntityRewriter { final EntityTracker tracker = tracker(wrapper.user()); - final int entityId = wrapper.get(Type.INT, 0); + final int entityId = wrapper.get(Types.INT, 0); tracker.setClientEntityId(entityId); tracker.addEntity(entityId, tracker.playerType()); }; @@ -388,7 +389,7 @@ public abstract class EntityRewriter { EntityTracker tracker = tracker(wrapper.user()); - CompoundTag registryData = wrapper.get(Type.NAMED_COMPOUND_TAG, nbtIndex); + CompoundTag registryData = wrapper.get(Types.NAMED_COMPOUND_TAG, nbtIndex); NumberTag height = registryData.getNumberTag("height"); if (height != null) { int blockHeight = height.asInt(); @@ -404,7 +405,7 @@ public abstract class EntityRewriter { EntityTracker tracker = tracker(wrapper.user()); - String dimensionKey = wrapper.get(Type.STRING, 0); + String dimensionKey = wrapper.get(Types.STRING, 0); DimensionData dimensionData = tracker.dimensionData(dimensionKey); if (dimensionData == null) { Via.getPlatform().getLogger().severe("Dimension data missing for dimension: " + dimensionKey + ", falling back to overworld"); @@ -427,7 +428,7 @@ public abstract class EntityRewriter> 4); tracker.setCurrentMinY(dimensionData.minY()); - String world = wrapper.get(Type.STRING, 1); + String world = wrapper.get(Types.STRING, 1); if (tracker.currentWorld() != null && !tracker.currentWorld().equals(world)) { tracker.clearEntities(); tracker.trackClientEntity(); @@ -439,7 +440,7 @@ public abstract class EntityRewriter { EntityTracker tracker = tracker(wrapper.user()); - int dimensionId = wrapper.get(Type.VAR_INT, dimensionIdIndex); + int dimensionId = wrapper.get(Types.VAR_INT, dimensionIdIndex); DimensionData dimensionData = tracker.dimensionData(dimensionId); if (dimensionData == null) { Via.getPlatform().getLogger().severe("Dimension data missing for dimension: " + dimensionId + ", falling back to overworld"); @@ -450,7 +451,7 @@ public abstract class EntityRewriter> 4); tracker.setCurrentMinY(dimensionData.minY()); - String world = wrapper.get(Type.STRING, 0); + String world = wrapper.get(Types.STRING, 0); if (tracker.currentWorld() != null && !tracker.currentWorld().equals(world)) { tracker.clearEntities(); tracker.trackClientEntity(); @@ -460,11 +461,11 @@ public abstract class EntityRewriter trackBiomeSize(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0)); + return wrapper -> trackBiomeSize(wrapper.user(), wrapper.get(Types.NAMED_COMPOUND_TAG, 0)); } public PacketHandler configurationBiomeSizeTracker() { - return wrapper -> trackBiomeSize(wrapper.user(), wrapper.get(Type.COMPOUND_TAG, 0)); + return wrapper -> trackBiomeSize(wrapper.user(), wrapper.get(Types.COMPOUND_TAG, 0)); } public void trackBiomeSize(final UserConnection connection, final CompoundTag registry) { @@ -473,11 +474,11 @@ public abstract class EntityRewriter cacheDimensionData(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0)); + return wrapper -> cacheDimensionData(wrapper.user(), wrapper.get(Types.NAMED_COMPOUND_TAG, 0)); } public PacketHandler configurationDimensionDataHandler() { - return wrapper -> cacheDimensionData(wrapper.user(), wrapper.get(Type.COMPOUND_TAG, 0)); + return wrapper -> cacheDimensionData(wrapper.user(), wrapper.get(Types.COMPOUND_TAG, 0)); } /** @@ -497,12 +498,12 @@ public abstract class EntityRewriter { - final String registryKey = Key.stripMinecraftNamespace(wrapper.get(Type.STRING, 0)); + final String registryKey = Key.stripMinecraftNamespace(wrapper.get(Types.STRING, 0)); if (registryKey.equals("worldgen/biome")) { - final RegistryEntry[] entries = wrapper.get(Type.REGISTRY_ENTRY_ARRAY, 0); + final RegistryEntry[] entries = wrapper.get(Types.REGISTRY_ENTRY_ARRAY, 0); tracker(wrapper.user()).setBiomesSent(entries.length); } else if (registryKey.equals("dimension_type")) { - final RegistryEntry[] entries = wrapper.get(Type.REGISTRY_ENTRY_ARRAY, 0); + final RegistryEntry[] entries = wrapper.get(Types.REGISTRY_ENTRY_ARRAY, 0); final Map dimensionDataMap = new HashMap<>(entries.length); for (int i = 0; i < entries.length; i++) { final RegistryEntry entry = entries[i]; @@ -524,12 +525,12 @@ public abstract class EntityRewriter> metaType) { return wrapper -> { - int entityId = wrapper.get(Type.VAR_INT, 0); - int type = wrapper.get(Type.VAR_INT, 1); + int entityId = wrapper.get(Types.VAR_INT, 0); + int type = wrapper.get(Types.VAR_INT, 1); int newType = newEntityId(type); if (newType != type) { - wrapper.set(Type.VAR_INT, 1, newType); + wrapper.set(Types.VAR_INT, 1, newType); } EntityType entType = typeFromId(trackMappedType ? newType : type); @@ -544,7 +545,7 @@ public abstract class EntityRewriter> metaType, EntityType entityType) { return wrapper -> { - int entityId = wrapper.get(Type.VAR_INT, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); // Register Type ID tracker(wrapper.user()).addEntity(entityId, entityType); @@ -561,8 +562,8 @@ public abstract class EntityRewriter { - int entityId = wrapper.get(Type.VAR_INT, 0); - byte type = wrapper.get(Type.BYTE, 0); + int entityId = wrapper.get(Types.VAR_INT, 0); + byte type = wrapper.get(Types.BYTE, 0); EntityType entType = objectTypeFromId(type); // Register Type ID 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 26c62e1be..9e818096a 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java @@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.rewriter.RewriterBase; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import org.checkerframework.checker.nullness.qual.Nullable; public class ItemRewriter { Item[] items = wrapper.read(itemArrayType); wrapper.write(mappedItemArrayType, items); @@ -89,8 +90,8 @@ public class ItemRewriter { Item[] items = wrapper.read(itemArrayType); wrapper.write(mappedItemArrayType, items); @@ -108,16 +109,16 @@ public class ItemRewriter { - final int windowType = wrapper.read(Type.VAR_INT); + final int windowType = wrapper.read(Types.VAR_INT); final int mappedId = protocol.getMappingData().getMenuMappings().getNewId(windowType); if (mappedId == -1) { wrapper.cancel(); return; } - wrapper.write(Type.VAR_INT, mappedId); + wrapper.write(Types.VAR_INT, mappedId); }); } }); @@ -127,8 +128,8 @@ public class ItemRewriter handleClientboundItem(wrapper)); } }); @@ -138,9 +139,9 @@ public class ItemRewriter handleClientboundItem(wrapper)); } }); @@ -151,8 +152,8 @@ public class ItemRewriter handleClientboundItem(wrapper)); } }); @@ -163,12 +164,12 @@ public class ItemRewriter { byte slot; do { - slot = wrapper.passthrough(Type.BYTE); + slot = wrapper.passthrough(Types.BYTE); // & 0x7F into an extra variable if slot is needed handleClientboundItem(wrapper); } while (slot < 0); @@ -181,7 +182,7 @@ public class ItemRewriter handleServerboundItem(wrapper)); } }); @@ -191,11 +192,11 @@ public class ItemRewriter handleServerboundItem(wrapper)); } }); @@ -205,17 +206,17 @@ public class ItemRewriter { // Affected items - int length = wrapper.passthrough(Type.VAR_INT); + int length = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < length; i++) { - wrapper.passthrough(Type.SHORT); // Slot + wrapper.passthrough(Types.SHORT); // Slot handleServerboundItem(wrapper); } @@ -228,32 +229,32 @@ public class ItemRewriter { - int itemId = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewItemId(itemId)); + int itemId = wrapper.read(Types.VAR_INT); + wrapper.write(Types.VAR_INT, protocol.getMappingData().getNewItemId(itemId)); }); } // 1.14.4+ public void registerTradeList(C packetType) { protocol.registerClientbound(packetType, wrapper -> { - wrapper.passthrough(Type.VAR_INT); - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + wrapper.passthrough(Types.VAR_INT); + int size = wrapper.passthrough(Types.UNSIGNED_BYTE); for (int i = 0; i < size; i++) { handleClientboundItem(wrapper); // Input handleClientboundItem(wrapper); // Output - if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item + if (wrapper.passthrough(Types.BOOLEAN)) { // Has second item handleClientboundItem(wrapper); // Second item } - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses + wrapper.passthrough(Types.BOOLEAN); // Trade disabled + wrapper.passthrough(Types.INT); // Number of tools uses + wrapper.passthrough(Types.INT); // Maximum number of trade uses - wrapper.passthrough(Type.INT); // XP - wrapper.passthrough(Type.INT); // Special price - wrapper.passthrough(Type.FLOAT); // Price multiplier - wrapper.passthrough(Type.INT); // Demand + wrapper.passthrough(Types.INT); // XP + wrapper.passthrough(Types.INT); // Special price + wrapper.passthrough(Types.FLOAT); // Price multiplier + wrapper.passthrough(Types.INT); // Demand } //... }); @@ -261,21 +262,21 @@ public class ItemRewriter { - wrapper.passthrough(Type.VAR_INT); // Container id - int size = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.VAR_INT); // Container id + int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { handleClientboundItem(wrapper); // Input handleClientboundItem(wrapper); // Output handleClientboundItem(wrapper); // Second item - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses + wrapper.passthrough(Types.BOOLEAN); // Trade disabled + wrapper.passthrough(Types.INT); // Number of tools uses + wrapper.passthrough(Types.INT); // Maximum number of trade uses - wrapper.passthrough(Type.INT); // XP - wrapper.passthrough(Type.INT); // Special price - wrapper.passthrough(Type.FLOAT); // Price multiplier - wrapper.passthrough(Type.INT); // Demand + wrapper.passthrough(Types.INT); // XP + wrapper.passthrough(Types.INT); // Special price + wrapper.passthrough(Types.FLOAT); // Price multiplier + wrapper.passthrough(Types.INT); // Demand } }); } @@ -287,8 +288,8 @@ public class ItemRewriter optionalCostType, final Type mappedOptionalCostType ) { protocol.registerClientbound(packetType, wrapper -> { - wrapper.passthrough(Type.VAR_INT); // Container id - int size = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.VAR_INT); // Container id + int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { final Item input = wrapper.read(costType); wrapper.write(mappedCostType, handleItemToClient(wrapper.user(), input)); @@ -298,86 +299,86 @@ public class ItemRewriter { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - int size = wrapper.passthrough(Type.VAR_INT); // Mapping size + wrapper.passthrough(Types.BOOLEAN); // Reset/clear + int size = wrapper.passthrough(Types.VAR_INT); // Mapping size for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier - wrapper.passthrough(Type.OPTIONAL_STRING); // Parent + wrapper.passthrough(Types.STRING); // Identifier + wrapper.passthrough(Types.OPTIONAL_STRING); // Parent // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.COMPONENT); // Title - wrapper.passthrough(Type.COMPONENT); // Description + if (wrapper.passthrough(Types.BOOLEAN)) { + wrapper.passthrough(Types.COMPONENT); // Title + wrapper.passthrough(Types.COMPONENT); // Description handleClientboundItem(wrapper); // Icon - wrapper.passthrough(Type.VAR_INT); // Frame type - int flags = wrapper.passthrough(Type.INT); // Flags + wrapper.passthrough(Types.VAR_INT); // Frame type + int flags = wrapper.passthrough(Types.INT); // Flags if ((flags & 1) != 0) { - wrapper.passthrough(Type.STRING); // Background texture + wrapper.passthrough(Types.STRING); // Background texture } - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y + wrapper.passthrough(Types.FLOAT); // X + wrapper.passthrough(Types.FLOAT); // Y } - wrapper.passthrough(Type.STRING_ARRAY); // Criteria + wrapper.passthrough(Types.STRING_ARRAY); // Criteria - int arrayLength = wrapper.passthrough(Type.VAR_INT); + int arrayLength = wrapper.passthrough(Types.VAR_INT); for (int array = 0; array < arrayLength; array++) { - wrapper.passthrough(Type.STRING_ARRAY); // String array + wrapper.passthrough(Types.STRING_ARRAY); // String array } } }); } public void registerAdvancements1_20_2(C packetType) { - registerAdvancements1_20_2(packetType, Type.COMPONENT); + registerAdvancements1_20_2(packetType, Types.COMPONENT); } public void registerAdvancements1_20_3(C packetType) { - registerAdvancements1_20_2(packetType, Type.TAG); + registerAdvancements1_20_2(packetType, Types.TAG); } private void registerAdvancements1_20_2(C packetType, Type componentType) { protocol.registerClientbound(packetType, wrapper -> { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - int size = wrapper.passthrough(Type.VAR_INT); // Mapping size + wrapper.passthrough(Types.BOOLEAN); // Reset/clear + int size = wrapper.passthrough(Types.VAR_INT); // Mapping size for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier - wrapper.passthrough(Type.OPTIONAL_STRING); // Parent + wrapper.passthrough(Types.STRING); // Identifier + wrapper.passthrough(Types.OPTIONAL_STRING); // Parent // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { + if (wrapper.passthrough(Types.BOOLEAN)) { wrapper.passthrough(componentType); // Title wrapper.passthrough(componentType); // Description handleClientboundItem(wrapper); // Icon - wrapper.passthrough(Type.VAR_INT); // Frame type - int flags = wrapper.passthrough(Type.INT); // Flags + wrapper.passthrough(Types.VAR_INT); // Frame type + int flags = wrapper.passthrough(Types.INT); // Flags if ((flags & 1) != 0) { - wrapper.passthrough(Type.STRING); // Background texture + wrapper.passthrough(Types.STRING); // Background texture } - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y + wrapper.passthrough(Types.FLOAT); // X + wrapper.passthrough(Types.FLOAT); // Y } - int requirements = wrapper.passthrough(Type.VAR_INT); + int requirements = wrapper.passthrough(Types.VAR_INT); for (int array = 0; array < requirements; array++) { - wrapper.passthrough(Type.STRING_ARRAY); + wrapper.passthrough(Types.STRING_ARRAY); } - wrapper.passthrough(Type.BOOLEAN); // Send telemetry + wrapper.passthrough(Types.BOOLEAN); // Send telemetry } }); } @@ -386,17 +387,17 @@ public class ItemRewriter { Mappings mappings = protocol.getMappingData().getEnchantmentMappings(); if (mappings == null) { return; } - short property = wrapper.passthrough(Type.SHORT); + short property = wrapper.passthrough(Types.SHORT); if (property >= 4 && property <= 6) { // Enchantment id - short enchantmentId = (short) mappings.getNewId(wrapper.read(Type.SHORT)); - wrapper.write(Type.SHORT, enchantmentId); + short enchantmentId = (short) mappings.getNewId(wrapper.read(Types.SHORT)); + wrapper.write(Types.SHORT, enchantmentId); } }); } @@ -408,16 +409,16 @@ public class ItemRewriter { final Particle particle = wrapper.read(unmappedParticleType); rewriteParticle(wrapper.user(), particle); @@ -467,20 +468,20 @@ public class ItemRewriter unmappedParticleType, Type mappedParticleType) { final SoundRewriter cSoundRewriter = new SoundRewriter<>(protocol); protocol.registerClientbound(packetType, wrapper -> { - wrapper.passthrough(Type.DOUBLE); // X - wrapper.passthrough(Type.DOUBLE); // Y - wrapper.passthrough(Type.DOUBLE); // Z - wrapper.passthrough(Type.FLOAT); // Power - final int blocks = wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Types.DOUBLE); // X + wrapper.passthrough(Types.DOUBLE); // Y + wrapper.passthrough(Types.DOUBLE); // Z + wrapper.passthrough(Types.FLOAT); // Power + final int blocks = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < blocks; i++) { - wrapper.passthrough(Type.BYTE); // Relative X - wrapper.passthrough(Type.BYTE); // Relative Y - wrapper.passthrough(Type.BYTE); // Relative Z + wrapper.passthrough(Types.BYTE); // Relative X + wrapper.passthrough(Types.BYTE); // Relative Y + wrapper.passthrough(Types.BYTE); // Relative Z } - wrapper.passthrough(Type.FLOAT); // Knockback X - wrapper.passthrough(Type.FLOAT); // Knockback Y - wrapper.passthrough(Type.FLOAT); // Knockback Z - wrapper.passthrough(Type.VAR_INT); // Block interaction type + wrapper.passthrough(Types.FLOAT); // Knockback X + wrapper.passthrough(Types.FLOAT); // Knockback Y + wrapper.passthrough(Types.FLOAT); // Knockback Z + wrapper.passthrough(Types.VAR_INT); // Block interaction type final Particle smallExplosionParticle = wrapper.read(unmappedParticleType); final Particle largeExplosionParticle = wrapper.read(unmappedParticleType); @@ -494,7 +495,7 @@ public class ItemRewriter idType) { @@ -506,8 +507,8 @@ public class ItemRewriter { */ public void register(C packetType) { protocol.registerClientbound(packetType, wrapper -> { - int size = wrapper.passthrough(Type.VAR_INT); + int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { - String type = wrapper.passthrough(Type.STRING); - wrapper.passthrough(Type.STRING); // Recipe Identifier + String type = wrapper.passthrough(Types.STRING); + wrapper.passthrough(Types.STRING); // Recipe Identifier handleRecipeType(wrapper, Key.stripMinecraftNamespace(type)); } }); @@ -79,11 +80,11 @@ public class RecipeRewriter { public void register1_20_5(C packetType) { protocol.registerClientbound(packetType, wrapper -> { - int size = wrapper.passthrough(Type.VAR_INT); + int size = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING);// Recipe Identifier + wrapper.passthrough(Types.STRING);// Recipe Identifier - final int typeId = wrapper.passthrough(Type.VAR_INT); + final int typeId = wrapper.passthrough(Types.VAR_INT); final String type = protocol.getMappingData().getRecipeSerializerMappings().identifier(typeId); handleRecipeType(wrapper, type); } @@ -91,8 +92,8 @@ public class RecipeRewriter { } public void handleCraftingShaped(PacketWrapper wrapper) { - int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.STRING); // Group + int ingredientsNo = wrapper.passthrough(Types.VAR_INT) * wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.STRING); // Group for (int i = 0; i < ingredientsNo; i++) { handleIngredient(wrapper); } @@ -102,23 +103,23 @@ public class RecipeRewriter { } public void handleCraftingShapeless(PacketWrapper wrapper) { - wrapper.passthrough(Type.STRING); // Group + wrapper.passthrough(Types.STRING); // Group handleIngredients(wrapper); final Item result = rewrite(wrapper.user(), wrapper.read(itemType())); wrapper.write(mappedItemType(), result); } public void handleSmelting(PacketWrapper wrapper) { - wrapper.passthrough(Type.STRING); // Group + wrapper.passthrough(Types.STRING); // Group handleIngredient(wrapper); final Item result = rewrite(wrapper.user(), wrapper.read(itemType())); wrapper.write(mappedItemType(), result); - wrapper.passthrough(Type.FLOAT); // EXP - wrapper.passthrough(Type.VAR_INT); // Cooking time + wrapper.passthrough(Types.FLOAT); // EXP + wrapper.passthrough(Types.VAR_INT); // Cooking time } public void handleStonecutting(PacketWrapper wrapper) { - wrapper.passthrough(Type.STRING); // Group + wrapper.passthrough(Types.STRING); // Group handleIngredient(wrapper); final Item result = rewrite(wrapper.user(), wrapper.read(itemType())); wrapper.write(mappedItemType(), result); @@ -132,7 +133,7 @@ public class RecipeRewriter { } public void handleSimpleRecipe(final PacketWrapper wrapper) { - wrapper.passthrough(Type.VAR_INT); // Crafting book category + wrapper.passthrough(Types.VAR_INT); // Crafting book category } public void handleSmithingTransform(final PacketWrapper wrapper) { @@ -166,7 +167,7 @@ public class RecipeRewriter { } protected void handleIngredients(final PacketWrapper wrapper) { - final int ingredients = wrapper.passthrough(Type.VAR_INT); + final int ingredients = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < ingredients; i++) { handleIngredient(wrapper); } @@ -179,11 +180,11 @@ public class RecipeRewriter { } protected Type itemType() { - return Type.ITEM1_13_2; + return Types.ITEM1_13_2; } protected Type itemArrayType() { - return Type.ITEM1_13_2_ARRAY; + return Types.ITEM1_13_2_ARRAY; } protected Type mappedItemType() { 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 ed94a710b..fb5e26ae6 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/SoundRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/SoundRewriter.java @@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; public class SoundRewriter { protected final Protocol protocol; @@ -43,7 +43,7 @@ public class SoundRewriter { protocol.registerClientbound(packetType, new PacketHandlers() { @Override public void register() { - map(Type.VAR_INT); // Sound id + map(Types.VAR_INT); // Sound id handler(getSoundHandler()); } }); @@ -55,10 +55,10 @@ public class SoundRewriter { public PacketHandler soundHolderHandler() { return wrapper -> { - Holder soundEventHolder = wrapper.read(Type.SOUND_EVENT); + Holder soundEventHolder = wrapper.read(Types.SOUND_EVENT); if (soundEventHolder.isDirect()) { // Is followed by the resource loation - wrapper.write(Type.SOUND_EVENT, soundEventHolder); + wrapper.write(Types.SOUND_EVENT, soundEventHolder); return; } @@ -72,18 +72,18 @@ public class SoundRewriter { soundEventHolder = Holder.of(mappedId); } - wrapper.write(Type.SOUND_EVENT, soundEventHolder); + wrapper.write(Types.SOUND_EVENT, soundEventHolder); }; } public PacketHandler getSoundHandler() { return wrapper -> { - int soundId = wrapper.get(Type.VAR_INT, 0); + int soundId = wrapper.get(Types.VAR_INT, 0); int mappedId = idRewriter.rewrite(soundId); if (mappedId == -1) { wrapper.cancel(); } else if (soundId != mappedId) { - wrapper.set(Type.VAR_INT, 0, mappedId); + wrapper.set(Types.VAR_INT, 0, mappedId); } }; } 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 ff888c869..4ec185473 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/StatisticsRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/StatisticsRewriter.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.rewriter; import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import org.checkerframework.checker.nullness.qual.Nullable; public class StatisticsRewriter { @@ -33,12 +33,12 @@ public class StatisticsRewriter { public void register(C packetType) { protocol.registerClientbound(packetType, wrapper -> { - int size = wrapper.passthrough(Type.VAR_INT); + int size = wrapper.passthrough(Types.VAR_INT); int newSize = size; for (int i = 0; i < size; i++) { - int categoryId = wrapper.read(Type.VAR_INT); - int statisticId = wrapper.read(Type.VAR_INT); - int value = wrapper.read(Type.VAR_INT); + int categoryId = wrapper.read(Types.VAR_INT); + int statisticId = wrapper.read(Types.VAR_INT); + int value = wrapper.read(Types.VAR_INT); if (categoryId == CUSTOM_STATS_CATEGORY && protocol.getMappingData().getStatisticsMappings() != null) { // Rewrite custom statistics id statisticId = protocol.getMappingData().getStatisticsMappings().getNewId(statisticId); @@ -56,13 +56,13 @@ public class StatisticsRewriter { } } - wrapper.write(Type.VAR_INT, categoryId); - wrapper.write(Type.VAR_INT, statisticId); - wrapper.write(Type.VAR_INT, value); + wrapper.write(Types.VAR_INT, categoryId); + wrapper.write(Types.VAR_INT, statisticId); + wrapper.write(Types.VAR_INT, value); } if (newSize != size) { - wrapper.set(Type.VAR_INT, 0, newSize); + wrapper.set(Types.VAR_INT, 0, newSize); } }); } 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 c07032987..0725cf337 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java @@ -26,6 +26,7 @@ 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.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.util.Key; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; @@ -136,21 +137,21 @@ public class TagRewriter implements com.viavers public PacketHandler getGenericHandler() { return wrapper -> { - final int length = wrapper.passthrough(Type.VAR_INT); + final int length = wrapper.passthrough(Types.VAR_INT); int editedLength = length; for (int i = 0; i < length; i++) { - String registryKey = wrapper.read(Type.STRING); + String registryKey = wrapper.read(Types.STRING); if (toRemove.contains(registryKey)) { - wrapper.set(Type.VAR_INT, 0, --editedLength); - int tagsSize = wrapper.read(Type.VAR_INT); + wrapper.set(Types.VAR_INT, 0, --editedLength); + int tagsSize = wrapper.read(Types.VAR_INT); for (int j = 0; j < tagsSize; j++) { - wrapper.read(Type.STRING); - wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE); + wrapper.read(Types.STRING); + wrapper.read(Types.VAR_INT_ARRAY_PRIMITIVE); } continue; } - wrapper.write(Type.STRING, registryKey); + wrapper.write(Types.STRING, registryKey); registryKey = Key.stripMinecraftNamespace(registryKey); RegistryType type = RegistryType.getByKey(registryKey); @@ -168,20 +169,20 @@ public class TagRewriter implements com.viavers } public void handle(PacketWrapper wrapper, @Nullable IdRewriteFunction rewriteFunction, @Nullable List newTags, @Nullable Map tagsToRename) { - int tagsSize = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT, newTags != null ? tagsSize + newTags.size() : tagsSize); // add new tags count + int tagsSize = wrapper.read(Types.VAR_INT); + wrapper.write(Types.VAR_INT, newTags != null ? tagsSize + newTags.size() : tagsSize); // add new tags count for (int i = 0; i < tagsSize; i++) { - String key = wrapper.read(Type.STRING); + String key = wrapper.read(Types.STRING); if (tagsToRename != null) { String renamedKey = tagsToRename.get(key); if (renamedKey != null) { key = renamedKey; } } - wrapper.write(Type.STRING, key); + wrapper.write(Types.STRING, key); - int[] ids = wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE); + int[] ids = wrapper.read(Types.VAR_INT_ARRAY_PRIMITIVE); if (rewriteFunction != null) { // Map ids and filter out new blocks IntList idList = new IntArrayList(ids.length); @@ -192,18 +193,18 @@ public class TagRewriter implements com.viavers } } - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, idList.toArray(EMPTY_ARRAY)); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, idList.toArray(EMPTY_ARRAY)); } else { // Write the original array - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, ids); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, ids); } } // Send new tags if present if (newTags != null) { for (TagData tag : newTags) { - wrapper.write(Type.STRING, tag.identifier()); - wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, tag.entries()); + wrapper.write(Types.STRING, tag.identifier()); + wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, tag.entries()); } } } diff --git a/common/src/test/java/com/viaversion/viaversion/common/type/ItemTypeTest.java b/common/src/test/java/com/viaversion/viaversion/common/type/ItemTypeTest.java index eca2eac36..23b5d29b6 100644 --- a/common/src/test/java/com/viaversion/viaversion/common/type/ItemTypeTest.java +++ b/common/src/test/java/com/viaversion/viaversion/common/type/ItemTypeTest.java @@ -19,6 +19,7 @@ package com.viaversion.viaversion.common.type; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.junit.jupiter.api.Assertions; @@ -29,9 +30,9 @@ class ItemTypeTest { @Test void testEmptyItemRead() { // Test empty item read - Assertions.assertNull(Type.ITEM1_8.read(Unpooled.wrappedBuffer(new byte[]{-1, -1}))); - Assertions.assertNull(Type.ITEM1_13.read(Unpooled.wrappedBuffer(new byte[]{-1, -1}))); - Assertions.assertNull(Type.ITEM1_13_2.read(Unpooled.wrappedBuffer(new byte[]{0}))); + Assertions.assertNull(Types.ITEM1_8.read(Unpooled.wrappedBuffer(new byte[]{-1, -1}))); + Assertions.assertNull(Types.ITEM1_13.read(Unpooled.wrappedBuffer(new byte[]{-1, -1}))); + Assertions.assertNull(Types.ITEM1_13_2.read(Unpooled.wrappedBuffer(new byte[]{0}))); } @Test @@ -39,7 +40,7 @@ class ItemTypeTest { // Test item read Assertions.assertEquals( new DataItem(Short.MAX_VALUE, (byte) -128, (short) 257, null), - Type.ITEM1_8.read(Unpooled.wrappedBuffer(new byte[]{ + Types.ITEM1_8.read(Unpooled.wrappedBuffer(new byte[]{ 127, -1, -128, 1, 1, @@ -48,7 +49,7 @@ class ItemTypeTest { ); Assertions.assertEquals( new DataItem(420, (byte) 53, (short) 0, null), - Type.ITEM1_13.read(Unpooled.wrappedBuffer(new byte[]{ + Types.ITEM1_13.read(Unpooled.wrappedBuffer(new byte[]{ 1, (byte) 164, 53, 0 @@ -56,7 +57,7 @@ class ItemTypeTest { ); Assertions.assertEquals( new DataItem(268435456, (byte) 127, (short) 0, null), - Type.ITEM1_13_2.read(Unpooled.wrappedBuffer(new byte[]{ + Types.ITEM1_13_2.read(Unpooled.wrappedBuffer(new byte[]{ 1, -128, -128, -128, -128, 1, 127, @@ -70,11 +71,11 @@ class ItemTypeTest { ByteBuf buf = Unpooled.buffer(); // Test item empty write - Type.ITEM1_8.write(buf, null); + Types.ITEM1_8.write(buf, null); Assertions.assertArrayEquals(toBytes(buf), new byte[]{-1, -1}); - Type.ITEM1_13.write(buf, null); + Types.ITEM1_13.write(buf, null); Assertions.assertArrayEquals(toBytes(buf), new byte[]{-1, -1}); - Type.ITEM1_13_2.write(buf, null); + Types.ITEM1_13_2.write(buf, null); Assertions.assertArrayEquals(toBytes(buf), new byte[]{0}); } @@ -83,20 +84,20 @@ class ItemTypeTest { ByteBuf buf = Unpooled.buffer(); // Test item write - Type.ITEM1_8.write(buf, new DataItem(Short.MAX_VALUE, (byte) -128, (short) 257, null)); + Types.ITEM1_8.write(buf, new DataItem(Short.MAX_VALUE, (byte) -128, (short) 257, null)); Assertions.assertArrayEquals(toBytes(buf), new byte[]{ 127, -1, -128, 1, 1, 0 }); - Type.ITEM1_13.write(buf, new DataItem(420, (byte) 53, (short) 0, null)); + Types.ITEM1_13.write(buf, new DataItem(420, (byte) 53, (short) 0, null)); Assertions.assertArrayEquals(toBytes(buf), new byte[]{ 1, (byte) 164, 53, 0 }); - Type.ITEM1_13_2.write(buf, new DataItem(268435456, (byte) 127, (short) 0, null)); + Types.ITEM1_13_2.write(buf, new DataItem(268435456, (byte) 127, (short) 0, null)); Assertions.assertArrayEquals(toBytes(buf), new byte[]{ 1, -128, -128, -128, -128, 1, diff --git a/common/src/test/java/com/viaversion/viaversion/common/type/StringTypeTest.java b/common/src/test/java/com/viaversion/viaversion/common/type/StringTypeTest.java index 580658025..608a3fe72 100644 --- a/common/src/test/java/com/viaversion/viaversion/common/type/StringTypeTest.java +++ b/common/src/test/java/com/viaversion/viaversion/common/type/StringTypeTest.java @@ -18,6 +18,7 @@ package com.viaversion.viaversion.common.type; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; @@ -29,7 +30,7 @@ class StringTypeTest { void testStringWrite() { // Write final ByteBuf buf = Unpooled.buffer(); - Type.STRING.write(buf, "\uD83E\uDDFD"); // Sponge Emoji + Types.STRING.write(buf, "\uD83E\uDDFD"); // Sponge Emoji Assertions.assertEquals(ByteBufUtil.hexDump(buf), "04f09fa7bd"); } @@ -37,32 +38,32 @@ class StringTypeTest { void testStringRead() throws Exception { // Write final ByteBuf buf = Unpooled.buffer(); - Type.STRING.write(buf, new String(new char[Short.MAX_VALUE])); - Assertions.assertEquals(Type.STRING.read(buf), new String(new char[Short.MAX_VALUE])); + Types.STRING.write(buf, new String(new char[Short.MAX_VALUE])); + Assertions.assertEquals(Types.STRING.read(buf), new String(new char[Short.MAX_VALUE])); - Type.STRING.write(buf, new String(new char[Short.MAX_VALUE]).replace("\0", "a")); - Assertions.assertEquals(Type.STRING.read(buf), new String(new char[Short.MAX_VALUE]).replace("\0", "a")); + Types.STRING.write(buf, new String(new char[Short.MAX_VALUE]).replace("\0", "a")); + Assertions.assertEquals(Types.STRING.read(buf), new String(new char[Short.MAX_VALUE]).replace("\0", "a")); - Type.STRING.write(buf, new String(new char[Short.MAX_VALUE / 2]).replace("\0", "\uD83E\uDDFD")); - Assertions.assertEquals(Type.STRING.read(buf), new String(new char[Short.MAX_VALUE / 2]).replace("\0", "\uD83E\uDDFD")); + Types.STRING.write(buf, new String(new char[Short.MAX_VALUE / 2]).replace("\0", "\uD83E\uDDFD")); + Assertions.assertEquals(Types.STRING.read(buf), new String(new char[Short.MAX_VALUE / 2]).replace("\0", "\uD83E\uDDFD")); } @Test void testStringReadOverflowException() { // Read exception final ByteBuf buf = Unpooled.buffer(); - Type.VAR_INT.writePrimitive(buf, (Short.MAX_VALUE + 1) * 4); + Types.VAR_INT.writePrimitive(buf, (Short.MAX_VALUE + 1) * 4); for (int i = 0; i < Short.MAX_VALUE / 2 + 1; i++) { buf.writeBytes(new byte[]{0x04, (byte) 0xf0, (byte) 0x9f, (byte) 0xa7, (byte) 0xbd}); // Sponge emoji } - Assertions.assertThrows(IllegalArgumentException.class, () -> Type.STRING.read(buf)); + Assertions.assertThrows(IllegalArgumentException.class, () -> Types.STRING.read(buf)); } @Test void testStringWriteOverflowException() { // Write exceptions final ByteBuf buf = Unpooled.buffer(); - Assertions.assertThrows(IllegalArgumentException.class, () -> Type.STRING.write(buf, new String(new char[Short.MAX_VALUE / 2 + 1]).replace("\0", "\uD83E\uDDFD"))); - Assertions.assertThrows(IllegalArgumentException.class, () -> Type.STRING.write(buf, new String(new char[Short.MAX_VALUE + 1]))); + Assertions.assertThrows(IllegalArgumentException.class, () -> Types.STRING.write(buf, new String(new char[Short.MAX_VALUE / 2 + 1]).replace("\0", "\uD83E\uDDFD"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> Types.STRING.write(buf, new String(new char[Short.MAX_VALUE + 1]))); } } diff --git a/template/src/main/java/com/viaversion/viaversion/template/protocols/rewriter/EntityPacketRewriter1_99.java b/template/src/main/java/com/viaversion/viaversion/template/protocols/rewriter/EntityPacketRewriter1_99.java index d027b9b29..ceedde77e 100644 --- a/template/src/main/java/com/viaversion/viaversion/template/protocols/rewriter/EntityPacketRewriter1_99.java +++ b/template/src/main/java/com/viaversion/viaversion/template/protocols/rewriter/EntityPacketRewriter1_99.java @@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundConfigurationPackets1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5; @@ -47,8 +48,8 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter