From 2480eb6a7fe4a0690fa28c6e98cfb6fc25b530b8 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 28 Feb 2024 22:15:31 +0100 Subject: [PATCH] Start working on 24w09a --- .../viaversion/api/data/MappingData.java | 2 + .../viaversion/api/data/MappingDataBase.java | 7 ++ .../viaversion/api/minecraft/Particle.java | 9 +- .../api/minecraft/item/DataItem.java | 18 ++- .../api/minecraft/item/DynamicItem.java | 114 ++++++++++++++++++ .../viaversion/api/minecraft/item/Item.java | 4 + .../api/minecraft/item/ItemData.java | 78 ++++++++++++ .../minecraft/item/data/BannerPattern.java | 62 ++++++++++ .../api/minecraft/item/data/Bee.java | 71 +++++++++++ .../item/data/BlockStateProperties.java | 62 ++++++++++ .../api/minecraft/item/data/DyedColor.java | 60 +++++++++ .../api/minecraft/item/data/Enchantments.java | 72 +++++++++++ .../api/minecraft/item/data/GameProfile.java | 106 ++++++++++++++++ .../minecraft/item/data/LodestoneTarget.java | 61 ++++++++++ .../api/minecraft/item/data/WrittenBook.java | 84 +++++++++++++ .../api/minecraft/metadata/MetaType.java | 2 + .../metadata/types/MetaTypes1_20_5.java | 3 +- .../api/protocol/version/ProtocolVersion.java | 2 +- .../viaversion/viaversion/api/type/Type.java | 5 + .../viaversion/api/type/types/UnitType.java | 43 +++++++ .../api/type/types/item/ItemDataType.java | 89 ++++++++++++++ .../api/type/types/item/ItemType1_20_5.java | 111 +++++++++++++++++ .../api/type/types/misc/DynamicType.java | 96 +++++++++++++++ .../api/type/types/misc/ParticleType.java | 91 +++----------- .../api/type/types/version/Types1_20_5.java | 11 +- .../viaversion/viaversion/util/IdHolder.java | 28 +++++ .../com/viaversion/viaversion/util/Key.java | 16 ++- .../com/viaversion/viaversion/util/Unit.java | 28 +++++ .../data/entity/StoredEntityDataImpl.java | 4 +- .../rewriter/RecipeRewriter1_19_3.java | 10 +- .../rewriter/RecipeRewriter1_20_3.java | 4 +- .../Protocol1_20_5To1_20_3.java | 76 ++++++++++-- .../BlockItemPacketRewriter1_20_5.java | 82 ++++++++++++- .../viaversion/rewriter/ItemRewriter.java | 88 ++++++++------ .../viaversion/rewriter/RecipeRewriter.java | 40 ++++-- .../viaversion/data/identifiers-1.20.3.nbt | Bin 3967 -> 4719 bytes .../viaversion/data/identifiers-1.20.5.nbt | Bin 4039 -> 4791 bytes .../data/mappings-1.20.3to1.20.5.nbt | Bin 574 -> 606 bytes gradle.properties | 2 +- 39 files changed, 1484 insertions(+), 157 deletions(-) create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DynamicItem.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/item/ItemData.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPattern.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Bee.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BlockStateProperties.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/DyedColor.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Enchantments.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/GameProfile.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTarget.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/WrittenBook.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/UnitType.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemDataType.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_20_5.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/misc/DynamicType.java create mode 100644 api/src/main/java/com/viaversion/viaversion/util/IdHolder.java create mode 100644 api/src/main/java/com/viaversion/viaversion/util/Unit.java diff --git a/api/src/main/java/com/viaversion/viaversion/api/data/MappingData.java b/api/src/main/java/com/viaversion/viaversion/api/data/MappingData.java index 5877576fd..015233e80 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/data/MappingData.java +++ b/api/src/main/java/com/viaversion/viaversion/api/data/MappingData.java @@ -115,5 +115,7 @@ public interface MappingData { @Nullable FullMappings getRecipeSerializerMappings(); + FullMappings getItemDataSerializerMappings(); + @Nullable Mappings getPaintingMappings(); } diff --git a/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataBase.java b/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataBase.java index 2aa09a6ea..c605e2d24 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataBase.java +++ b/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataBase.java @@ -45,6 +45,7 @@ public class MappingDataBase implements MappingData { protected FullMappings argumentTypeMappings; protected FullMappings entityMappings; protected FullMappings recipeSerializerMappings; + protected FullMappings itemDataSerializerMappings; protected ParticleMappings particleMappings; protected Mappings blockMappings; protected Mappings blockStateMappings; @@ -86,6 +87,7 @@ public class MappingDataBase implements MappingData { entityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "entities"); argumentTypeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "argumenttypes"); recipeSerializerMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "recipe_serializers"); + itemDataSerializerMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "item_serializers"); final ListTag unmappedParticles = unmappedIdentifierData.get("particles"); final ListTag mappedParticles = mappedIdentifierData.get("particles"); @@ -238,6 +240,11 @@ public class MappingDataBase implements MappingData { return argumentTypeMappings; } + @Override + public @Nullable FullMappings getItemDataSerializerMappings() { + return itemDataSerializerMappings; + } + @Override public @Nullable Mappings getPaintingMappings() { return paintingMappings; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/Particle.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/Particle.java index 9ef8681ca..6d1e5ab38 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/Particle.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/Particle.java @@ -24,11 +24,12 @@ package com.viaversion.viaversion.api.minecraft; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.util.IdHolder; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; -public final class Particle { +public final class Particle implements IdHolder { private final List> arguments = new ArrayList<>(4); private int id; @@ -36,10 +37,16 @@ public final class Particle { this.id = id; } + @Deprecated public int getId() { return id; } + @Override + public int id() { + return id; + } + public void setId(final int id) { this.id = id; } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DataItem.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DataItem.java index 2d1d2f90f..c0e11fbdd 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DataItem.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DataItem.java @@ -24,7 +24,10 @@ package com.viaversion.viaversion.api.minecraft.item; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.google.gson.annotations.SerializedName; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.util.Objects; +import java.util.Optional; import org.checkerframework.checker.nullness.qual.Nullable; public class DataItem implements Item { @@ -91,6 +94,11 @@ public class DataItem implements Item { this.tag = tag; } + @Override + public Int2ObjectMap>> itemData() { + return new Int2ObjectOpenHashMap<>(); + } + @Override public Item copy() { return new DataItem(identifier, amount, data, tag); @@ -119,10 +127,10 @@ public class DataItem implements Item { @Override public String toString() { return "Item{" + - "identifier=" + identifier + - ", amount=" + amount + - ", data=" + data + - ", tag=" + tag + - '}'; + "identifier=" + identifier + + ", amount=" + amount + + ", data=" + data + + ", tag=" + tag + + '}'; } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DynamicItem.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DynamicItem.java new file mode 100644 index 000000000..fe0c9a011 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DynamicItem.java @@ -0,0 +1,114 @@ +/* + * 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.minecraft.item; + +import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import java.util.Optional; +import org.checkerframework.checker.nullness.qual.Nullable; + +public class DynamicItem implements Item { + private final Int2ObjectMap>> data; + private int identifier; + private byte amount; + + public DynamicItem() { + this(0, (byte) 0, new Int2ObjectOpenHashMap<>()); + } + + public DynamicItem(int identifier, byte amount, Int2ObjectMap>> data) { + this.identifier = identifier; + this.amount = amount; + this.data = data; + } + + @Override + public int identifier() { + return identifier; + } + + @Override + public void setIdentifier(int identifier) { + this.identifier = identifier; + } + + @Override + public int amount() { + return amount; + } + + @Override + public void setAmount(int amount) { + if (amount > Byte.MAX_VALUE || amount < Byte.MIN_VALUE) { + throw new IllegalArgumentException("Invalid item amount: " + amount); + } + this.amount = (byte) amount; + } + + @Override + public @Nullable CompoundTag tag() { + return null; + } + + @Override + public void setTag(@Nullable CompoundTag tag) { + throw new UnsupportedOperationException(); + } + + @Override + public Int2ObjectMap>> itemData() { + return data; + } + + public void addData(ItemData data) { + this.data.put(data.id(), Optional.of(data)); + } + + public void addMarkerData(int id) { + this.data.put(id, Optional.empty()); + } + + @Override + public Item copy() { + return new DynamicItem(identifier, amount, data); + } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final DynamicItem that = (DynamicItem) o; + if (identifier != that.identifier) return false; + if (amount != that.amount) return false; + return data.equals(that.data); + } + + @Override + public int hashCode() { + int result = data.hashCode(); + result = 31 * result + identifier; + result = 31 * result + amount; + return result; + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/Item.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/Item.java index 7b75e2c13..5684647b4 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/Item.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/Item.java @@ -23,6 +23,8 @@ package com.viaversion.viaversion.api.minecraft.item; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import java.util.Optional; import org.checkerframework.checker.nullness.qual.Nullable; public interface Item { @@ -88,6 +90,8 @@ public interface Item { */ void setTag(@Nullable CompoundTag tag); + Int2ObjectMap>> itemData(); + /** * Returns a copy of the item. * diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/ItemData.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/ItemData.java new file mode 100644 index 000000000..b9d01736d --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/ItemData.java @@ -0,0 +1,78 @@ +/* + * 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.minecraft.item; + +import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.util.IdHolder; +import com.viaversion.viaversion.util.Unit; +import io.netty.buffer.ByteBuf; + +public final class ItemData implements IdHolder { + + private final Type type; + private T value; + private int id; + + public ItemData(final Type type, final T value, final int id) { + this.type = type; + this.value = value; + this.id = id; + } + + public static ItemData empty(final int id) { + return new ItemData<>(Type.UNIT, Unit.INSTANCE, id); + } + + public boolean isEmpty() { + return type == Type.UNIT; + } + + public void setValue(final T value) { + if (value != null && !type.getOutputClass().isAssignableFrom(value.getClass())) { + throw new IllegalArgumentException("Item data type and value are incompatible. Type=" + type + + ", value=" + value + " (" + value.getClass().getSimpleName() + ")"); + } + this.value = value; + } + + public void write(final ByteBuf buffer) throws Exception { + type.write(buffer, value); + } + + public void setId(final int id) { + this.id = id; + } + + public Type type() { + return type; + } + + public T value() { + return value; + } + + @Override + public int id() { + return id; + } +} 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 new file mode 100644 index 000000000..6e75c2d6b --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPattern.java @@ -0,0 +1,62 @@ +/* + * 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.minecraft.item.data; + +import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.ArrayType; +import io.netty.buffer.ByteBuf; + +public final class BannerPattern { + + public static final Type TYPE = new Type(BannerPattern.class) { + @Override + public BannerPattern read(final ByteBuf buffer) throws Exception { + final int pattern = Type.VAR_INT.readPrimitive(buffer); + final int color = Type.VAR_INT.readPrimitive(buffer); + return new BannerPattern(pattern, color); + } + + @Override + public void write(final ByteBuf buffer, final BannerPattern value) throws Exception { + Type.VAR_INT.writePrimitive(buffer, value.pattern); + Type.VAR_INT.writePrimitive(buffer, value.color); + } + }; + public static final Type ARRAY_TYPE = new ArrayType<>(TYPE); + + private final int pattern; + private final int color; + + public BannerPattern(final int pattern, final int color) { + this.pattern = pattern; + this.color = color; + } + + public int pattern() { + return this.pattern; + } + + public int color() { + return this.color; + } +} 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 new file mode 100644 index 000000000..cccc45444 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Bee.java @@ -0,0 +1,71 @@ +/* + * 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.minecraft.item.data; + +import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.ArrayType; +import io.netty.buffer.ByteBuf; + +public final class Bee { + + public static final Type TYPE = new Type(Bee.class) { + @Override + public Bee read(final ByteBuf buffer) throws Exception { + final CompoundTag entityData = Type.COMPOUND_TAG.read(buffer); + final int ticksInHive = Type.VAR_INT.readPrimitive(buffer); + final int minTicksInHive = Type.VAR_INT.readPrimitive(buffer); + return new Bee(entityData, ticksInHive, minTicksInHive); + } + + @Override + public void write(final ByteBuf buffer, final Bee value) throws Exception { + Type.COMPOUND_TAG.write(buffer, value.entityData); + Type.VAR_INT.writePrimitive(buffer, value.ticksInHive); + Type.VAR_INT.writePrimitive(buffer, value.minTicksInHive); + } + }; + public static final Type ARRAY_TYPE = new ArrayType<>(TYPE); + + private final CompoundTag entityData; + private final int ticksInHive; + private final int minTicksInHive; + + public Bee(CompoundTag entityData, int ticksInHive, int minTicksInHive) { + this.entityData = entityData; + this.ticksInHive = ticksInHive; + this.minTicksInHive = minTicksInHive; + } + + public CompoundTag entityData() { + return entityData; + } + + public int ticksInHive() { + return ticksInHive; + } + + public int minTicksInHive() { + return minTicksInHive; + } +} 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 new file mode 100644 index 000000000..b13305928 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BlockStateProperties.java @@ -0,0 +1,62 @@ +/* + * 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.minecraft.item.data; + +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import java.util.Map; + +public final class BlockStateProperties { + + public static final Type TYPE = new Type(BlockStateProperties.class) { + @Override + public BlockStateProperties read(final ByteBuf buffer) throws Exception { + final int size = Type.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)); + } + return new BlockStateProperties(properties); + } + + @Override + public void write(final ByteBuf buffer, final BlockStateProperties value) throws Exception { + Type.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()); + } + } + }; + + private final Map properties; + + public BlockStateProperties(final Map properties) { + this.properties = properties; + } + + public Map properties() { + return properties; + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/DyedColor.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/DyedColor.java new file mode 100644 index 000000000..dcc29fce7 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/DyedColor.java @@ -0,0 +1,60 @@ +/* + * 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.minecraft.item.data; + +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; + +public final class DyedColor { + + public static final Type TYPE = new Type(DyedColor.class) { + @Override + public DyedColor read(final ByteBuf buffer) { + final int rgb = buffer.readInt(); + final boolean showInTooltip = buffer.readBoolean(); + return new DyedColor(rgb, showInTooltip); + } + + @Override + public void write(final ByteBuf buffer, final DyedColor value) { + buffer.writeInt(value.rgb); + buffer.writeBoolean(value.showInTooltip); + } + }; + + private final int rgb; + private final boolean showInTooltip; + + public DyedColor(final int rgb, final boolean showInTooltip) { + this.rgb = rgb; + this.showInTooltip = showInTooltip; + } + + public int rgb() { + return this.rgb; + } + + public boolean showInTooltip() { + return this.showInTooltip; + } +} 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 new file mode 100644 index 000000000..f0bce4ed5 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Enchantments.java @@ -0,0 +1,72 @@ +/* + * 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.minecraft.item.data; + +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; +import it.unimi.dsi.fastutil.ints.Int2IntMap; +import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; + +public final class Enchantments { + + public static final Type TYPE = new Type(Enchantments.class) { + @Override + public Enchantments read(final ByteBuf buffer) { + final Int2IntMap enchantments = new Int2IntOpenHashMap(); + final int size = Type.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); + enchantments.put(id, level); + } + + return new Enchantments(enchantments, buffer.readBoolean()); + } + + @Override + public void write(final ByteBuf buffer, final Enchantments value) { + Type.VAR_INT.writePrimitive(buffer, value.enchantments.size()); + for (final Int2IntMap.Entry entry : value.enchantments.int2IntEntrySet()) { + Type.VAR_INT.writePrimitive(buffer, entry.getIntValue()); + Type.VAR_INT.writePrimitive(buffer, entry.getIntValue()); + } + buffer.writeBoolean(value.showInTooltip()); + } + }; + + private final Int2IntMap enchantments; + private final boolean showInTooltip; + + public Enchantments(final Int2IntMap enchantments, final boolean showInTooltip) { + this.enchantments = enchantments; + this.showInTooltip = showInTooltip; + } + + public Int2IntMap enchantments() { + return enchantments; + } + + public boolean showInTooltip() { + return showInTooltip; + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/GameProfile.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/GameProfile.java new file mode 100644 index 000000000..4f61b1941 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/GameProfile.java @@ -0,0 +1,106 @@ +/* + * 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.minecraft.item.data; + +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; +import java.util.UUID; +import org.checkerframework.checker.nullness.qual.Nullable; + +public final class GameProfile { + + public static final Type TYPE = new Type(GameProfile.class) { + @Override + public GameProfile read(final ByteBuf buffer) throws Exception { + final String name = Type.STRING.read(buffer); + final UUID id = Type.OPTIONAL_UUID.read(buffer); + final int propertyCount = Type.VAR_INT.readPrimitive(buffer); + final Property[] properties = new 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); + properties[i] = new Property(propertyName, propertyValue, propertySignature); + } + return new GameProfile(name, id, properties); + } + + @Override + public void write(final ByteBuf buffer, final GameProfile value) throws Exception { + Type.STRING.write(buffer, value.name); + Type.OPTIONAL_UUID.write(buffer, value.id); + Type.VAR_INT.writePrimitive(buffer, value.properties.length); + for (final Property property : value.properties) { + Type.STRING.write(buffer, property.name); + Type.STRING.write(buffer, property.value); + Type.OPTIONAL_STRING.write(buffer, property.signature); + } + } + }; + + private final String name; + private final UUID id; + private final Property[] properties; + + public GameProfile(final String name, @Nullable final UUID id, final Property[] properties) { + this.name = name; + this.id = id; + this.properties = properties; + } + + public String name() { + return name; + } + + public @Nullable UUID id() { + return id; + } + + public Property[] properties() { + return properties; + } + + public static final class Property { + private final String name; + private final String value; + private final String signature; + + public Property(final String name, final String value, @Nullable final String signature) { + this.name = name; + this.value = value; + this.signature = signature; + } + + public String name() { + return name; + } + + public String value() { + return value; + } + + public @Nullable String signature() { + return signature; + } + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTarget.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTarget.java new file mode 100644 index 000000000..476f96ac4 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTarget.java @@ -0,0 +1,61 @@ +/* + * 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.minecraft.item.data; + +import com.viaversion.viaversion.api.minecraft.GlobalPosition; +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; + +public final class LodestoneTarget { + + public static final Type TYPE = new Type(LodestoneTarget.class) { + @Override + public LodestoneTarget read(final ByteBuf buffer) throws Exception { + final GlobalPosition position = Type.GLOBAL_POSITION.read(buffer); + final boolean tracked = buffer.readBoolean(); + return new LodestoneTarget(position, tracked); + } + + @Override + public void write(final ByteBuf buffer, final LodestoneTarget value) throws Exception { + Type.GLOBAL_POSITION.write(buffer, value.position); + buffer.writeBoolean(value.tracked); + } + }; + + private final GlobalPosition position; + private final boolean tracked; + + public LodestoneTarget(final GlobalPosition position, final boolean tracked) { + this.position = position; + this.tracked = tracked; + } + + public GlobalPosition pos() { + return this.position; + } + + public boolean tracked() { + return this.tracked; + } +} 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 new file mode 100644 index 000000000..87cecd848 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/WrittenBook.java @@ -0,0 +1,84 @@ +/* + * 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.minecraft.item.data; + +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; + +public final class WrittenBook { + + public static final Type TYPE = new Type(WrittenBook.class) { + @Override + public WrittenBook read(final ByteBuf buffer) throws Exception { + final String title = Type.STRING.read(buffer); + final String author = Type.STRING.read(buffer); + final int generation = Type.VAR_INT.readPrimitive(buffer); + final String[] pages = Type.STRING_ARRAY.read(buffer); + final boolean resolved = buffer.readBoolean(); + return new WrittenBook(title, author, generation, pages, resolved); + } + + @Override + public void write(final ByteBuf buffer, final WrittenBook value) throws Exception { + Type.STRING.write(buffer, value.title); + Type.STRING.write(buffer, value.author); + Type.VAR_INT.writePrimitive(buffer, value.generation); + Type.STRING_ARRAY.write(buffer, value.pages); + buffer.writeBoolean(value.resolved); + } + }; + + private final String title; + private final String author; + private final int generation; + private final String[] pages; + private final boolean resolved; + + public WrittenBook(final String title, final String author, final int generation, final String[] pages, final boolean resolved) { + this.title = title; + this.author = author; + this.generation = generation; + this.pages = pages; + this.resolved = resolved; + } + + public String title() { + return title; + } + + public String author() { + return author; + } + + public int generation() { + return generation; + } + + public String[] pages() { + return pages; + } + + public boolean resolved() { + return resolved; + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/MetaType.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/MetaType.java index d7986e9a3..e93f043ca 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/MetaType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/MetaType.java @@ -22,6 +22,7 @@ */ package com.viaversion.viaversion.api.minecraft.metadata; +import com.google.common.base.Preconditions; import com.viaversion.viaversion.api.type.Type; public interface MetaType { @@ -49,6 +50,7 @@ public interface MetaType { private final Type type; MetaTypeImpl(final int typeId, final Type type) { + Preconditions.checkNotNull(type); this.typeId = typeId; this.type = type; } 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 f56899da5..83d492044 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,6 +25,7 @@ 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.misc.ParticleType; +import com.viaversion.viaversion.api.type.types.version.Types1_20_5; public final class MetaTypes1_20_5 extends AbstractMetaTypes { @@ -35,7 +36,7 @@ public final class MetaTypes1_20_5 extends AbstractMetaTypes { 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 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); diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java index aa0beb754..9d66c6814 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java @@ -83,7 +83,7 @@ public class ProtocolVersion implements Comparable { public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new SubVersionRange("1.20", 0, 1)); public static final ProtocolVersion v1_20_2 = register(764, "1.20.2"); public static final ProtocolVersion v1_20_3 = register(765, "1.20.3/1.20.4", new SubVersionRange("1.20", 3, 4)); - public static final ProtocolVersion v1_20_5 = register(766, 177, "1.20.5"); + public static final ProtocolVersion v1_20_5 = register(766, 178, "1.20.5"); public static final ProtocolVersion unknown = new ProtocolVersion(VersionType.SPECIAL, -1, -1, "UNKNOWN", null); public static ProtocolVersion register(int version, String name) { 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 e0baf6979..b42566ec0 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 @@ -56,6 +56,7 @@ 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.UnitType; import com.viaversion.viaversion.api.type.types.UnsignedByteType; import com.viaversion.viaversion.api.type.types.UnsignedShortType; import com.viaversion.viaversion.api.type.types.VarIntArrayType; @@ -87,6 +88,7 @@ import com.viaversion.viaversion.api.type.types.block.VarLongBlockChangeRecordTy 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.VillagerDataType; +import com.viaversion.viaversion.util.Unit; import java.util.UUID; /** @@ -96,6 +98,8 @@ import java.util.UUID; */ public abstract class Type implements ByteBufReader, ByteBufWriter { + public static final Type UNIT = new UnitType(); + public static final ByteType BYTE = new ByteType(); public static final UnsignedByteType UNSIGNED_BYTE = new UnsignedByteType(); public static final Type BYTE_ARRAY_PRIMITIVE = new ByteArrayType(); @@ -149,6 +153,7 @@ public abstract class Type implements ByteBufReader, ByteBufWriter { 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(); @Deprecated/*(forRemoval=true)*/ public static final Type NBT = NAMED_COMPOUND_TAG; diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/UnitType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/UnitType.java new file mode 100644 index 000000000..0e9de32a2 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/UnitType.java @@ -0,0 +1,43 @@ +/* + * 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.types; + +import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.util.Unit; +import io.netty.buffer.ByteBuf; + +public final class UnitType extends Type { + + public UnitType() { + super(Unit.class); + } + + @Override + public Unit read(final ByteBuf buffer) throws Exception { + return Unit.INSTANCE; + } + + @Override + public void write(final ByteBuf buffer, final Unit value) throws Exception { + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemDataType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemDataType.java new file mode 100644 index 000000000..6548dffa5 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemDataType.java @@ -0,0 +1,89 @@ +/* + * 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.types.item; + +import com.viaversion.viaversion.api.data.FullMappings; +import com.viaversion.viaversion.api.minecraft.item.ItemData; +import com.viaversion.viaversion.api.protocol.Protocol; +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; + +public class ItemDataType extends Type> { + + private final Int2ObjectMap> types = new Int2ObjectOpenHashMap<>(); + + public ItemDataType() { + super(ItemData.class); + } + + @Override + public void write(final ByteBuf buffer, final ItemData object) throws Exception { + Type.VAR_INT.writePrimitive(buffer, object.id()); + object.write(buffer); + } + + @Override + public ItemData read(final ByteBuf buffer) throws Exception { + final int id = Type.VAR_INT.readPrimitive(buffer); + final Type type = this.types.get(id); + if (type != null) { + return readItemData(buffer, type, id); + } + throw new IllegalArgumentException("Unknown item data type id: " + id); + } + + private ItemData readItemData(final ByteBuf buffer, final Type type, final int id) throws Exception { + return new ItemData<>(type, type.read(buffer), id); + } + + public DataFiller filler(final Protocol protocol) { + return filler(protocol, true); + } + + public DataFiller filler(final Protocol protocol, final boolean useMappedNames) { + return new DataFiller(protocol, useMappedNames); + } + + public final class DataFiller { + + private final FullMappings mappings; + private final boolean useMappedNames; + + private DataFiller(final Protocol protocol, final boolean useMappedNames) { + this.mappings = protocol.getMappingData().getItemDataSerializerMappings(); + this.useMappedNames = useMappedNames; + } + + public DataFiller reader(final String identifier, final Type reader) { + types.put(useMappedNames ? mappings.mappedId(identifier) : mappings.id(identifier), reader); + return this; + } + + public DataFiller reader(final int id, final Type type) { + types.put(id, type); + return this; + } + } +} 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 new file mode 100644 index 000000000..8e3fce433 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/item/ItemType1_20_5.java @@ -0,0 +1,111 @@ +/* + * 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.types.item; + +import com.viaversion.viaversion.api.minecraft.item.DynamicItem; +import com.viaversion.viaversion.api.minecraft.item.Item; +import com.viaversion.viaversion.api.minecraft.item.ItemData; +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import java.util.Optional; +import org.checkerframework.checker.nullness.qual.Nullable; + +public class ItemType1_20_5 extends Type { + + private final Type> dataType; + + public ItemType1_20_5(final Type> itemDataType) { + super(Item.class); + this.dataType = itemDataType; + } + + @Override + public @Nullable Item read(final ByteBuf buffer) throws Exception { + final byte amount = buffer.readByte(); + if (amount <= 0) { + return null; + } + + final int id = Type.VAR_INT.readPrimitive(buffer); + final Int2ObjectMap>> data = readData(buffer); + return new DynamicItem(id, amount, data); + } + + private Int2ObjectMap>> readData(final ByteBuf buffer) throws Exception { + final int valuesSize = Type.VAR_INT.readPrimitive(buffer); + final int markersSize = Type.VAR_INT.readPrimitive(buffer); + if (valuesSize == 0 && markersSize == 0) { + return new Int2ObjectOpenHashMap<>(); + } + + final Int2ObjectMap>> map = new Int2ObjectOpenHashMap<>(valuesSize + markersSize); + for (int i = 0; i < valuesSize; i++) { + final ItemData value = dataType.read(buffer); + map.put(value.id(), Optional.of(value)); + } + + for (int i = 0; i < markersSize; i++) { + final int key = Type.VAR_INT.readPrimitive(buffer); + map.put(key, Optional.empty()); + } + return map; + } + + @Override + public void write(final ByteBuf buffer, @Nullable final Item object) throws Exception { + if (object == null) { + buffer.writeByte(0); + return; + } + + buffer.writeByte(object.amount()); + Type.VAR_INT.writePrimitive(buffer, object.identifier()); + + final Int2ObjectMap>> data = object.itemData(); + int valuesSize = 0; + int markersSize = 0; + for (final Int2ObjectMap.Entry>> entry : data.int2ObjectEntrySet()) { + if (entry.getValue().isPresent()) { + valuesSize++; + } else { + markersSize++; + } + } + + Type.VAR_INT.writePrimitive(buffer, valuesSize); + Type.VAR_INT.writePrimitive(buffer, markersSize); + + for (final Int2ObjectMap.Entry>> entry : data.int2ObjectEntrySet()) { + if (entry.getValue().isPresent()) { + dataType.write(buffer, entry.getValue().get()); + } + } + for (final Int2ObjectMap.Entry>> entry : data.int2ObjectEntrySet()) { + if (!entry.getValue().isPresent()) { + Type.VAR_INT.writePrimitive(buffer, entry.getIntKey()); + } + } + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/DynamicType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/DynamicType.java new file mode 100644 index 000000000..149bcad1f --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/misc/DynamicType.java @@ -0,0 +1,96 @@ +/* + * 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.types.misc; + +import com.viaversion.viaversion.api.data.FullMappings; +import com.viaversion.viaversion.api.protocol.Protocol; +import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.util.IdHolder; +import io.netty.buffer.ByteBuf; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; + +public abstract class DynamicType extends Type { + + protected final Int2ObjectMap> readers; + + protected DynamicType(final Int2ObjectMap> readers, final Class outputClass) { + super(outputClass.getSimpleName(), outputClass); + this.readers = readers; + } + + protected DynamicType(final Class outputClass) { + this(new Int2ObjectOpenHashMap<>(), outputClass); + } + + public DataFiller filler(final Protocol protocol) { + return filler(protocol, true); + } + + public DataFiller filler(final Protocol protocol, final boolean useMappedNames) { + return new DataFiller(protocol, useMappedNames); + } + + protected void readData(final ByteBuf buffer, final T value) throws Exception { + final DataReader reader = readers.get(value.id()); + if (reader != null) { + reader.read(buffer, value); + } + } + + public final class DataFiller { + + private final FullMappings mappings; + private final boolean useMappedNames; + + private DataFiller(final Protocol protocol, final boolean useMappedNames) { + this.mappings = mappings(protocol); + this.useMappedNames = useMappedNames; + } + + public DataFiller reader(final String identifier, final DataReader reader) { + readers.put(useMappedNames ? mappings.mappedId(identifier) : mappings.id(identifier), reader); + return this; + } + + public DataFiller reader(final int id, final DataReader reader) { + readers.put(id, reader); + return this; + } + } + + protected abstract FullMappings mappings(Protocol protocol); + + @FunctionalInterface + public interface DataReader { + + /** + * Reads a value from the buffer and adds it to the data. + * + * @param buf buffer + * @param value value + * @throws Exception if an error occurs during buffer reading + */ + void read(ByteBuf buf, T value) throws Exception; + } +} 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 433a23127..3f64c2cbe 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 @@ -23,40 +23,23 @@ package com.viaversion.viaversion.api.type.types.misc; import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.data.ParticleMappings; +import com.viaversion.viaversion.api.data.FullMappings; 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.util.Key; import io.netty.buffer.ByteBuf; -import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -public class ParticleType extends Type { - - private final Int2ObjectMap readers; - - public ParticleType(final Int2ObjectMap readers) { - super("Particle", Particle.class); - this.readers = readers; - } +public class ParticleType extends DynamicType { public ParticleType() { - this(new Int2ObjectArrayMap<>()); - } - - public ParticleTypeFiller filler(final Protocol protocol) { - return filler(protocol, true); - } - - public ParticleTypeFiller filler(final Protocol protocol, final boolean useMappedNames) { - return new ParticleTypeFiller(protocol, useMappedNames); + super(Particle.class); } @Override public void write(final ByteBuf buffer, final Particle object) throws Exception { - Type.VAR_INT.writePrimitive(buffer, object.getId()); + Type.VAR_INT.writePrimitive(buffer, object.id()); for (final Particle.ParticleData data : object.getArguments()) { data.write(buffer); } @@ -70,32 +53,30 @@ public class ParticleType extends Type { return particle; } - public void readData(final ByteBuf buffer, final Particle particle) throws Exception { - final ParticleReader reader = readers.get(particle.getId()); - if (reader != null) { - reader.read(buffer, particle); - } + @Override + protected FullMappings mappings(final Protocol protocol) { + return protocol.getMappingData().getParticleMappings(); } - public static ParticleReader itemHandler(final Type itemType) { + public static DataReader itemHandler(final Type itemType) { return (buf, particle) -> particle.add(itemType, itemType.read(buf)); } public static final class Readers { - public static final ParticleReader BLOCK = (buf, particle) -> { + public static final DataReader BLOCK = (buf, particle) -> { particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Flat Block }; - public static final ParticleReader ITEM1_13 = itemHandler(Type.ITEM1_13); - public static final ParticleReader ITEM1_13_2 = itemHandler(Type.ITEM1_13_2); - public static final ParticleReader ITEM1_20_2 = itemHandler(Type.ITEM1_20_2); - public static final ParticleReader DUST = (buf, particle) -> { + 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 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 }; - public static final ParticleReader DUST_TRANSITION = (buf, particle) -> { + 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 @@ -104,7 +85,7 @@ public class ParticleType extends Type { particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Green particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Blue }; - public static final ParticleReader VIBRATION = (buf, particle) -> { + public static final DataReader VIBRATION = (buf, particle) -> { particle.add(Type.POSITION1_14, Type.POSITION1_14.read(buf)); // From block pos String resourceLocation = Type.STRING.read(buf); @@ -120,7 +101,7 @@ public class ParticleType extends Type { } particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Arrival in ticks }; - public static final ParticleReader VIBRATION1_19 = (buf, particle) -> { + public static final DataReader VIBRATION1_19 = (buf, particle) -> { String resourceLocation = Type.STRING.read(buf); particle.add(Type.STRING, resourceLocation); @@ -135,7 +116,7 @@ public class ParticleType extends Type { } particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Arrival in ticks }; - public static final ParticleReader VIBRATION1_20_3 = (buf, particle) -> { + public static final DataReader VIBRATION1_20_3 = (buf, particle) -> { final int sourceTypeId = Type.VAR_INT.readPrimitive(buf); particle.add(Type.VAR_INT, sourceTypeId); if (sourceTypeId == 0) { // Block @@ -148,45 +129,11 @@ public class ParticleType extends Type { } particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Arrival in ticks }; - public static final ParticleReader SCULK_CHARGE = (buf, particle) -> { + public static final DataReader SCULK_CHARGE = (buf, particle) -> { particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Roll }; - public static final ParticleReader SHRIEK = (buf, particle) -> { + public static final DataReader SHRIEK = (buf, particle) -> { particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Delay }; } - - public final class ParticleTypeFiller { - - private final ParticleMappings mappings; - private final boolean useMappedNames; - - private ParticleTypeFiller(final Protocol protocol, final boolean useMappedNames) { - this.mappings = protocol.getMappingData().getParticleMappings(); - this.useMappedNames = useMappedNames; - } - - public ParticleTypeFiller reader(final String identifier, final ParticleReader reader) { - readers.put(useMappedNames ? mappings.mappedId(identifier) : mappings.id(identifier), reader); - return this; - } - - public ParticleTypeFiller reader(final int id, final ParticleReader reader) { - readers.put(id, reader); - return this; - } - } - - @FunctionalInterface - public interface ParticleReader { - - /** - * Reads particle data from the buffer and adds it to the particle data. - * - * @param buf buffer - * @param particle particle - * @throws Exception if an error occurs during buffer reading - */ - void read(ByteBuf buf, Particle particle) throws Exception; - } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/version/Types1_20_5.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/Types1_20_5.java index 8582cf478..7f3fc6da5 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/version/Types1_20_5.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/Types1_20_5.java @@ -22,9 +22,13 @@ */ package com.viaversion.viaversion.api.type.types.version; +import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaTypes1_20_5; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.ArrayType; +import com.viaversion.viaversion.api.type.types.item.ItemType1_20_5; +import com.viaversion.viaversion.api.type.types.item.ItemDataType; import com.viaversion.viaversion.api.type.types.metadata.MetaListType; import com.viaversion.viaversion.api.type.types.metadata.MetadataType; import com.viaversion.viaversion.api.type.types.misc.ParticleType; @@ -32,7 +36,12 @@ import java.util.List; public final class Types1_20_5 { - public static final ParticleType PARTICLE = new ParticleType(); // Only safe to use after protocol loading + // Only safe to use after protocol loading + public static final ParticleType PARTICLE = new ParticleType(); + public static final ItemDataType ITEM_DATA = new ItemDataType(); + public static final Type ITEM = new ItemType1_20_5(ITEM_DATA); + public static final Type ITEM_ARRAY = new ArrayType<>(ITEM); + public static final MetaTypes1_20_5 META_TYPES = new MetaTypes1_20_5(PARTICLE); public static final Type METADATA = new MetadataType(META_TYPES); public static final Type> METADATA_LIST = new MetaListType(METADATA); diff --git a/api/src/main/java/com/viaversion/viaversion/util/IdHolder.java b/api/src/main/java/com/viaversion/viaversion/util/IdHolder.java new file mode 100644 index 000000000..8c688afaf --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/util/IdHolder.java @@ -0,0 +1,28 @@ +/* + * 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.util; + +public interface IdHolder { + + int id(); +} diff --git a/api/src/main/java/com/viaversion/viaversion/util/Key.java b/api/src/main/java/com/viaversion/viaversion/util/Key.java index a44cee703..82af5b62c 100644 --- a/api/src/main/java/com/viaversion/viaversion/util/Key.java +++ b/api/src/main/java/com/viaversion/viaversion/util/Key.java @@ -22,8 +22,13 @@ */ package com.viaversion.viaversion.util; +import java.util.regex.Pattern; + public final class Key { + private static final Pattern PATTERN = Pattern.compile("([0-9a-z_.-]*:)?[0-9a-z_/.-]*"); + private static final int MINECRAFT_NAMESPACE_LENGTH = "minecraft:".length(); + public static String stripNamespace(final String identifier) { int index = identifier.indexOf(':'); if (index == -1) { @@ -34,13 +39,17 @@ public final class Key { public static String stripMinecraftNamespace(final String identifier) { if (identifier.startsWith("minecraft:")) { - return identifier.substring(10); - } else if (identifier.startsWith(":")) { + return identifier.substring(MINECRAFT_NAMESPACE_LENGTH); + } else if (!identifier.isEmpty() && identifier.charAt(0) == ':') { return identifier.substring(1); } return identifier; } + public static boolean equals(final String firstIdentifier, final String secondIdentifier) { + return stripNamespace(firstIdentifier).equals(stripNamespace(secondIdentifier)); + } + public static String namespaced(final String identifier) { final int index = identifier.indexOf(':'); if (index == -1) { @@ -52,7 +61,6 @@ public final class Key { } public static boolean isValid(final String identifier) { - return identifier.matches("([0-9a-z_.-]*:)?[0-9a-z_/.-]*"); + return PATTERN.matcher(identifier).matches(); } - } diff --git a/api/src/main/java/com/viaversion/viaversion/util/Unit.java b/api/src/main/java/com/viaversion/viaversion/util/Unit.java new file mode 100644 index 000000000..f2f04b152 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/util/Unit.java @@ -0,0 +1,28 @@ +/* + * 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.util; + +public enum Unit { + + INSTANCE +} diff --git a/common/src/main/java/com/viaversion/viaversion/data/entity/StoredEntityDataImpl.java b/common/src/main/java/com/viaversion/viaversion/data/entity/StoredEntityDataImpl.java index ea744c168..9cffdf1b7 100644 --- a/common/src/main/java/com/viaversion/viaversion/data/entity/StoredEntityDataImpl.java +++ b/common/src/main/java/com/viaversion/viaversion/data/entity/StoredEntityDataImpl.java @@ -19,12 +19,12 @@ package com.viaversion.viaversion.data.entity; import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.minecraft.entities.EntityType; +import java.util.HashMap; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import org.checkerframework.checker.nullness.qual.Nullable; public final class StoredEntityDataImpl implements StoredEntityData { - private final Map, Object> storedObjects = new ConcurrentHashMap<>(); + private final Map, Object> storedObjects = new HashMap<>(); private final EntityType type; public StoredEntityDataImpl(EntityType type) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/rewriter/RecipeRewriter1_19_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/rewriter/RecipeRewriter1_19_3.java index b54fc359e..ae476b0b4 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/rewriter/RecipeRewriter1_19_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/rewriter/RecipeRewriter1_19_3.java @@ -17,6 +17,7 @@ */ package com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.rewriter; +import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; @@ -48,7 +49,8 @@ public class RecipeRewriter1_19_3 extends Recip wrapper.passthrough(Type.STRING); // Group wrapper.passthrough(Type.VAR_INT); // Crafting book category handleIngredients(wrapper); - rewrite(wrapper.passthrough(itemType())); // Result + final Item result = rewrite(wrapper.read(itemType())); + wrapper.write(mappedItemType(), result); } @Override @@ -59,7 +61,8 @@ public class RecipeRewriter1_19_3 extends Recip for (int i = 0; i < ingredients; i++) { handleIngredient(wrapper); } - rewrite(wrapper.passthrough(itemType())); // Result + final Item result = rewrite(wrapper.read(itemType())); + wrapper.write(mappedItemType(), result); } @Override @@ -67,7 +70,8 @@ public class RecipeRewriter1_19_3 extends Recip wrapper.passthrough(Type.STRING); // Group wrapper.passthrough(Type.VAR_INT); // Crafting book category handleIngredient(wrapper); - rewrite(wrapper.passthrough(itemType())); // Result + final Item result = rewrite(wrapper.read(itemType())); + wrapper.write(mappedItemType(), result); wrapper.passthrough(Type.FLOAT); // EXP wrapper.passthrough(Type.VAR_INT); // Cooking time } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_3to1_20_2/rewriter/RecipeRewriter1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_3to1_20_2/rewriter/RecipeRewriter1_20_3.java index 9494458c2..8ef9e6098 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_3to1_20_2/rewriter/RecipeRewriter1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_3to1_20_2/rewriter/RecipeRewriter1_20_3.java @@ -38,7 +38,9 @@ public class RecipeRewriter1_20_3 extends Recip for (int i = 0; i < ingredients; i++) { handleIngredient(wrapper); } - rewrite(wrapper.passthrough(itemType())); // Result + + final Item item = rewrite(wrapper.read(itemType())); // Result + wrapper.write(mappedItemType(), item); wrapper.passthrough(Type.BOOLEAN); // Show notification } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/Protocol1_20_5To1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/Protocol1_20_5To1_20_3.java index d920f5398..975848357 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/Protocol1_20_5To1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/Protocol1_20_5To1_20_3.java @@ -22,11 +22,19 @@ import com.viaversion.viaversion.api.data.MappingData; import com.viaversion.viaversion.api.data.MappingDataBase; import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5; +import com.viaversion.viaversion.api.minecraft.item.data.BannerPattern; +import com.viaversion.viaversion.api.minecraft.item.data.Bee; +import com.viaversion.viaversion.api.minecraft.item.data.BlockStateProperties; +import com.viaversion.viaversion.api.minecraft.item.data.DyedColor; +import com.viaversion.viaversion.api.minecraft.item.data.GameProfile; +import com.viaversion.viaversion.api.minecraft.item.data.LodestoneTarget; +import com.viaversion.viaversion.api.minecraft.item.data.WrittenBook; import com.viaversion.viaversion.api.protocol.AbstractProtocol; 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.minecraft.item.data.Enchantments; 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; @@ -102,15 +110,57 @@ public final class Protocol1_20_5To1_20_3 extends AbstractProtocol createPacketTypesProvider() { return new SimplePacketTypesProvider<>( - packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_20_3.class, ClientboundConfigurationPackets1_20_3.class), - packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_20_5.class, ClientboundConfigurationPackets1_20_5.class), - packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_3.class, ServerboundConfigurationPackets1_20_2.class), - packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class) + packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_20_3.class, ClientboundConfigurationPackets1_20_3.class), + packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_20_5.class, ClientboundConfigurationPackets1_20_5.class), + packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_3.class, ServerboundConfigurationPackets1_20_2.class), + packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class) ); } } \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java index 59e61cd16..f6e5cb070 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java @@ -18,9 +18,14 @@ package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.rewriter; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.github.steveice10.opennbt.tag.builtin.NumberTag; +import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.data.ParticleMappings; import com.viaversion.viaversion.api.minecraft.Particle; +import com.viaversion.viaversion.api.minecraft.item.DataItem; +import com.viaversion.viaversion.api.minecraft.item.DynamicItem; import com.viaversion.viaversion.api.minecraft.item.Item; +import com.viaversion.viaversion.api.minecraft.item.ItemData; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; import com.viaversion.viaversion.api.type.types.version.Types1_20_3; @@ -34,11 +39,13 @@ import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.Serverb import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.rewriter.ItemRewriter; import com.viaversion.viaversion.util.Key; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import org.checkerframework.checker.nullness.qual.Nullable; public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter { public BlockItemPacketRewriter1_20_5(final Protocol1_20_5To1_20_3 protocol) { - super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_ARRAY); + super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_ARRAY, Types1_20_5.ITEM, Types1_20_5.ITEM_ARRAY); } @Override @@ -88,7 +95,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter recipeRewriter = new RecipeRewriter1_20_3<>(protocol); + final RecipeRewriter1_20_3 recipeRewriter = new RecipeRewriter1_20_3(protocol) { + @Override + protected Type mappedItemType() { + return Types1_20_5.ITEM; + } + + @Override + protected Type mappedItemArrayType() { + return Types1_20_5.ITEM_ARRAY; + } + }; protocol.registerClientbound(ClientboundPackets1_20_3.DECLARE_RECIPES, wrapper -> { final int size = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < size; i++) { @@ -148,4 +169,53 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter()); + if (tag == null) { + return dynamicItem; + } + + // Rewrite nbt to new data structures + final NumberTag damage = tag.getNumberTag("Damage"); + if (damage != null) { + addData(dynamicItem, "damage", Type.VAR_INT, damage.asInt()); + } + + final NumberTag repairCost = tag.getNumberTag("RepairCost"); + if (repairCost != null) { + addData(dynamicItem, "repair_cost", Type.VAR_INT, repairCost.asInt()); + } + return dynamicItem; + } + + private void addData(final DynamicItem item, final String serializer, final Type type, final T value) { + final int id = serializerId(serializer); + if (id == -1) { + Via.getPlatform().getLogger().severe("Could not find item data serializer for type " + type); + return; + } + + item.addData(new ItemData<>(type, value, id)); + } + + private int serializerId(final String type) { + return protocol.getMappingData().getItemDataSerializerMappings().mappedId(type); + } + + @Override + public @Nullable Item handleItemToServer(@Nullable final Item item) { + if (item == null) return null; + + super.handleItemToServer(item); + + final CompoundTag tag = new CompoundTag(); + return new DataItem(item.identifier(), (byte) item.amount(), (short) 0, tag); + } } \ No newline at end of file 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 011f9e381..47f07ef65 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java @@ -23,6 +23,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.protocol.packet.ClientboundPacketType; +import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; @@ -31,14 +32,22 @@ import com.viaversion.viaversion.api.type.Type; import org.checkerframework.checker.nullness.qual.Nullable; public class ItemRewriter> extends RewriterBase implements com.viaversion.viaversion.api.rewriter.ItemRewriter { + T extends Protocol> extends RewriterBase implements com.viaversion.viaversion.api.rewriter.ItemRewriter { private final Type itemType; + private final Type mappedItemType; private final Type itemArrayType; + private final Type mappedItemArrayType; - public ItemRewriter(T protocol, Type itemType, Type itemArrayType) { + public ItemRewriter(T protocol, Type itemType, Type itemArrayType, Type mappedItemType, Type mappedItemArrayType) { super(protocol); this.itemType = itemType; this.itemArrayType = itemArrayType; + this.mappedItemType = mappedItemType; + this.mappedItemArrayType = mappedItemArrayType; + } + + public ItemRewriter(T protocol, Type itemType, Type itemArrayType) { + this(protocol, itemType, itemArrayType, itemType, itemArrayType); } // These two methods always return the same item instance *for now* @@ -66,8 +75,13 @@ public class ItemRewriter { + Item[] items = wrapper.read(itemArrayType); + wrapper.write(mappedItemArrayType, items); + for (Item item : items) { + handleItemToClient(item); + } + }); } }); } @@ -79,12 +93,13 @@ public class ItemRewriter { - Item[] items = wrapper.passthrough(itemArrayType); + Item[] items = wrapper.read(itemArrayType); + wrapper.write(mappedItemArrayType, items); for (Item item : items) { handleItemToClient(item); } - handleItemToClient(wrapper.passthrough(itemType)); // Carried item + handleClientboundItem(wrapper); }); } }); @@ -115,8 +130,7 @@ public class ItemRewriter handleClientboundItem(wrapper)); } }); } @@ -128,8 +142,7 @@ public class ItemRewriter handleClientboundItem(wrapper)); } }); } @@ -139,11 +152,9 @@ public class ItemRewriter handleClientboundItem(wrapper)); } }); } @@ -160,7 +171,7 @@ public class ItemRewriter handleServerboundItem(wrapper)); } }); } @@ -187,9 +197,7 @@ public class ItemRewriter handleServerboundItem(wrapper)); } }); } @@ -209,11 +217,11 @@ public class ItemRewriter handleItemToServer(wrapper.get(type, 0)); } + private void handleClientboundItem(final PacketWrapper wrapper) throws Exception { + final Item item = handleItemToClient(wrapper.read(itemType)); + wrapper.write(mappedItemType, item); + } + + private void handleServerboundItem(final PacketWrapper wrapper) throws Exception { + final Item item = handleItemToServer(wrapper.read(mappedItemType)); + wrapper.write(itemType, item); + } + protected void rewriteParticle(Particle particle) { ParticleMappings mappings = protocol.getMappingData().getParticleMappings(); int id = particle.getId(); diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/RecipeRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/RecipeRewriter.java index 0651a1118..add8bf4ba 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/RecipeRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/RecipeRewriter.java @@ -95,19 +95,23 @@ public class RecipeRewriter { for (int i = 0; i < ingredientsNo; i++) { handleIngredient(wrapper); } - rewrite(wrapper.passthrough(itemType())); // Result + + final Item result = rewrite(wrapper.read(itemType())); + wrapper.write(mappedItemType(), result); } public void handleCraftingShapeless(PacketWrapper wrapper) throws Exception { wrapper.passthrough(Type.STRING); // Group handleIngredients(wrapper); - rewrite(wrapper.passthrough(itemType())); // Result + final Item result = rewrite(wrapper.read(itemType())); + wrapper.write(mappedItemType(), result); } public void handleSmelting(PacketWrapper wrapper) throws Exception { wrapper.passthrough(Type.STRING); // Group handleIngredient(wrapper); - rewrite(wrapper.passthrough(itemType())); // Result + final Item result = rewrite(wrapper.read(itemType())); + wrapper.write(mappedItemType(), result); wrapper.passthrough(Type.FLOAT); // EXP wrapper.passthrough(Type.VAR_INT); // Cooking time } @@ -115,13 +119,15 @@ public class RecipeRewriter { public void handleStonecutting(PacketWrapper wrapper) throws Exception { wrapper.passthrough(Type.STRING); // Group handleIngredient(wrapper); - rewrite(wrapper.passthrough(itemType())); // Result + final Item result = rewrite(wrapper.read(itemType())); + wrapper.write(mappedItemType(), result); } public void handleSmithing(PacketWrapper wrapper) throws Exception { handleIngredient(wrapper); // Base handleIngredient(wrapper); // Addition - rewrite(wrapper.passthrough(itemType())); // Result + final Item result = rewrite(wrapper.read(itemType())); + wrapper.write(mappedItemType(), result); } public void handleSimpleRecipe(final PacketWrapper wrapper) throws Exception { @@ -132,7 +138,8 @@ public class RecipeRewriter { handleIngredient(wrapper); // Template handleIngredient(wrapper); // Base handleIngredient(wrapper); // Additions - rewrite(wrapper.passthrough(itemType())); // Result + final Item result = rewrite(wrapper.read(itemType())); + wrapper.write(mappedItemType(), result); } public void handleSmithingTrim(final PacketWrapper wrapper) throws Exception { @@ -141,16 +148,19 @@ public class RecipeRewriter { handleIngredient(wrapper); // Additions } - protected void rewrite(@Nullable Item item) { + protected @Nullable Item rewrite(@Nullable Item item) { if (protocol.getItemRewriter() != null) { - protocol.getItemRewriter().handleItemToClient(item); + return protocol.getItemRewriter().handleItemToClient(item); } + return item; } protected void handleIngredient(final PacketWrapper wrapper) throws Exception { - final Item[] items = wrapper.passthrough(itemArrayType()); - for (final Item item : items) { - rewrite(item); + final Item[] items = wrapper.read(itemArrayType()); + wrapper.write(mappedItemArrayType(), items); + for (int i = 0; i < items.length; i++) { + Item item = items[i]; + items[i] = rewrite(item); } } @@ -174,4 +184,12 @@ public class RecipeRewriter { protected Type itemArrayType() { return Type.ITEM1_13_2_ARRAY; } + + protected Type mappedItemType() { + return itemType(); + } + + protected Type mappedItemArrayType() { + return itemArrayType(); + } } diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.20.3.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.20.3.nbt index 65f280b1f01b0622bccb170855a8828360c3f6f0..64ae6e14bded8a26e45a73aac09f38c3c69ad8f9 100644 GIT binary patch delta 766 zcmY*X%WfMn4CKK`YCEW%xIus(dg{HOBk|)TUG8P7vM=IsT7GPaiVx|xZRpqfyYB5?Ne}pdG}TTpE_(@ z*XYc`9^pP=m^}4~ub>4L(KhuF!)?Pz6$RGW zhGy{)+*%S_%6o)$VKp14KEhM6OoJ~4o2#}a*eugU n@X}-IGw2yz1wQZbd9ngno>@-jW&ur@?WJwQ$Nz6^J6Pc#XgwGQ delta 9 QcmaE_@?UO49X}%j02b5(ZvX%Q diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.20.5.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.20.5.nbt index 39f30a9d3b545b254d70ff72c7a9682eccaaffb6..5d3435dfc1a5eac7cdc84418e132c7e0f9bd2cd1 100644 GIT binary patch delta 766 zcmY*X%WfMn4CKK`YCEW%xIutkdg{5KB`DW1 zI5XtmFTcP3`m;LDVNHso6Kv!&{lq380N@)e<0Q(XOI|(PBtQBAVL6r1(C>W6b~(Q& zengmMZU}c+;h_M|50Z-fyRB*m%`OVNyK0krQpn+QR*r&k)S7eV?8w zq4Oz`5*MGHGH0a<%ZAlcbCE^iA(|$oJvzy(E_2+$=XXlnkg2HSJ+@|i@Mt$*1~L;z zR~vuFsAPsVX1HN;?@9$0>BXSP<`3qhujk`UKT?8K|0j&xOaT{xO$VyU>dX;Es0^^N zRN7!Xmu>>9FqLDa4INWYctia=;k@hLLz`T1afKMGZ zu4{B=VUKX1FieBdP~6$qt4$D(MM+;?!+r=;+@YHN3w9rRnpe<*ifEhqh~c(jq>2LT zY(um73OemhZ75r6c;IHmKWb(%Uod~e1a2*fE#*DJy0Ds!Qy<}}Sf;_3g3VQ16Kt00 oB6#UB^%?Yxt^%L;_&iwwEYB<_bF+XZ%=Xf@;p6`|wjHeS5A}W*;Q#;t delta 9 Qcmdn4dR%_PF@8n{02G1)NdN!< diff --git a/common/src/main/resources/assets/viaversion/data/mappings-1.20.3to1.20.5.nbt b/common/src/main/resources/assets/viaversion/data/mappings-1.20.3to1.20.5.nbt index c3f1074f5f0f0bdbe48f0dccca3d844e6adccfe9..1bd88ade32488982c06e576c13be16d0f7bd0c68 100644 GIT binary patch delta 153 zcmdnTa*t)gj(S5z2BypuMrH<<;>@a41_m}}ZU&~r5(WkaULZCDVtXK-1;opMcs&CH zV;=(pvjq@eXJBB>2I6f%ybFkT1Mz8~=8}A%LXc)>Aoc^|bwIoah>rs`F9&K20^(0V X#gl=U_x^t%05YBe@z2dFj8cpM^JW~o delta 139 zcmcb|vX5oLj(SZ-2BypuMrH<<;>@a41_m}}ZU&~r5(WkaP9Qb|VtXK-1;opMcs&CH z^K}LW)@&f&1;o37ic9i=5+KFSK4ywl3>>L>C7C6e Ssm06;T)Bw_1)IYe*%<*1rW~&T diff --git a/gradle.properties b/gradle.properties index 900668561..f3145a053 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project properties - we put these here so they can be modified without causing a recompile of the build scripts -projectVersion=4.10.0-24w07a-SNAPSHOT +projectVersion=4.10.0-24w09a-SNAPSHOT # Smile emoji mcVersions=1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9