diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/PaintingVariant.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/PaintingVariant.java new file mode 100644 index 000000000..90073d972 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/PaintingVariant.java @@ -0,0 +1,47 @@ +/* + * 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; + +import com.viaversion.viaversion.api.type.Types; +import com.viaversion.viaversion.api.type.types.misc.HolderType; +import io.netty.buffer.ByteBuf; + +public record PaintingVariant(int width, int height, String assetId) { + + public static HolderType TYPE = new HolderType<>() { + @Override + public PaintingVariant readDirect(final ByteBuf buffer) { + final int width = Types.VAR_INT.readPrimitive(buffer); + final int height = Types.VAR_INT.readPrimitive(buffer); + final String assetId = Types.STRING.read(buffer); + return new PaintingVariant(width, height, assetId); + } + + @Override + public void writeDirect(final ByteBuf buffer, final PaintingVariant variant) { + Types.VAR_INT.writePrimitive(buffer, variant.width()); + Types.VAR_INT.writePrimitive(buffer, variant.height()); + Types.STRING.write(buffer, variant.assetId()); + } + }; +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/WolfVariant.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/WolfVariant.java new file mode 100644 index 000000000..fbc246548 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/WolfVariant.java @@ -0,0 +1,49 @@ +/* + * 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; + +import com.viaversion.viaversion.api.type.Types; +import com.viaversion.viaversion.api.type.types.misc.HolderType; +import io.netty.buffer.ByteBuf; + +public record WolfVariant(String wildTexture, String tameTexture, String angryTexture, HolderSet biomes) { + + public static HolderType TYPE = new HolderType<>() { + @Override + public WolfVariant readDirect(final ByteBuf buffer) { + final String wildTexture = Types.STRING.read(buffer); + final String tameTexture = Types.STRING.read(buffer); + final String angryTexture = Types.STRING.read(buffer); + final HolderSet biomes = Types.HOLDER_SET.read(buffer); + return new WolfVariant(wildTexture, tameTexture, angryTexture, biomes); + } + + @Override + public void writeDirect(final ByteBuf buffer, final WolfVariant variant) { + Types.STRING.write(buffer, variant.wildTexture()); + Types.STRING.write(buffer, variant.tameTexture()); + Types.STRING.write(buffer, variant.angryTexture()); + Types.HOLDER_SET.write(buffer, variant.biomes()); + } + }; +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entitydata/types/EntityDataTypes1_21.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entitydata/types/EntityDataTypes1_21.java new file mode 100644 index 000000000..4d0134fcb --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entitydata/types/EntityDataTypes1_21.java @@ -0,0 +1,73 @@ +/* + * 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.entitydata.types; + +import com.viaversion.viaversion.api.minecraft.PaintingVariant; +import com.viaversion.viaversion.api.minecraft.Particle; +import com.viaversion.viaversion.api.minecraft.WolfVariant; +import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType; +import com.viaversion.viaversion.api.type.Types; +import com.viaversion.viaversion.api.type.types.ArrayType; +import com.viaversion.viaversion.api.type.types.misc.ParticleType; +import com.viaversion.viaversion.api.type.types.version.Types1_20_5; + +public final class EntityDataTypes1_21 extends AbstractEntityDataTypes { + + public final EntityDataType byteType = add(0, Types.BYTE); + public final EntityDataType varIntType = add(1, Types.VAR_INT); + public final EntityDataType longType = add(2, Types.VAR_LONG); + public final EntityDataType floatType = add(3, Types.FLOAT); + public final EntityDataType stringType = add(4, Types.STRING); + public final EntityDataType componentType = add(5, Types.TAG); + public final EntityDataType optionalComponentType = add(6, Types.OPTIONAL_TAG); + public final EntityDataType itemType = add(7, Types1_20_5.ITEM); + public final EntityDataType booleanType = add(8, Types.BOOLEAN); + public final EntityDataType rotationsType = add(9, Types.ROTATIONS); + public final EntityDataType blockPositionType = add(10, Types.BLOCK_POSITION1_14); + public final EntityDataType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14); + public final EntityDataType directionType = add(12, Types.VAR_INT); + public final EntityDataType optionalUUIDType = add(13, Types.OPTIONAL_UUID); + public final EntityDataType blockStateType = add(14, Types.VAR_INT); + public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT); + public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG); + public final EntityDataType particleType; + public final EntityDataType particlesType; + public final EntityDataType villagerDatatType = add(19, Types.VILLAGER_DATA); + public final EntityDataType optionalVarIntType = add(20, Types.OPTIONAL_VAR_INT); + public final EntityDataType poseType = add(21, Types.VAR_INT); + public final EntityDataType catVariantType = add(22, Types.VAR_INT); + public final EntityDataType wolfVariantType = add(23, WolfVariant.TYPE); + public final EntityDataType frogVariantType = add(24, Types.VAR_INT); + public final EntityDataType optionalGlobalPosition = add(25, Types.OPTIONAL_GLOBAL_POSITION); + public final EntityDataType paintingVariantType = add(26, PaintingVariant.TYPE); + public final EntityDataType snifferState = add(27, Types.VAR_INT); + public final EntityDataType armadilloState = add(28, Types.VAR_INT); + public final EntityDataType vector3FType = add(29, Types.VECTOR3F); + public final EntityDataType quaternionType = add(30, Types.QUATERNION); + + public EntityDataTypes1_21(final ParticleType particleType, final ArrayType particlesType) { + super(31); + this.particleType = add(17, particleType); + this.particlesType = add(18, particlesType); + } +} 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 6fdcf77f0..48ffe10e4 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 @@ -84,7 +84,7 @@ public class ProtocolVersion implements Comparable { 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, "1.20.5-1.20.6", new SubVersionRange("1.20", 5, 6)); - public static final ProtocolVersion v1_21 = register(767, 195, "1.21"); + public static final ProtocolVersion v1_21 = register(767, 196, "1.21"); 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/types/version/Types1_21.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/Types1_21.java index d8c4e878a..ce496d5ff 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/version/Types1_21.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/Types1_21.java @@ -25,7 +25,7 @@ package com.viaversion.viaversion.api.type.types.version; import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.data.StructuredData; import com.viaversion.viaversion.api.minecraft.entitydata.EntityData; -import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_20_5; +import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_21; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.ArrayType; @@ -50,7 +50,7 @@ public final class Types1_21 { public static final ParticleType PARTICLE = new ParticleType(); public static final ArrayType PARTICLES = new ArrayType<>(PARTICLE); - public static final EntityDataTypes1_20_5 ENTITY_DATA_TYPES = new EntityDataTypes1_20_5(PARTICLE, PARTICLES); + public static final EntityDataTypes1_21 ENTITY_DATA_TYPES = new EntityDataTypes1_21(PARTICLE, PARTICLES); public static final Type ENTITY_DATA = new EntityDataType(ENTITY_DATA_TYPES); public static final Type> ENTITY_DATA_LIST = new EntityDataListType(ENTITY_DATA); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/data/Paintings1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/data/Paintings1_20_5.java index 21bfc7006..75a113a20 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/data/Paintings1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/data/Paintings1_20_5.java @@ -17,62 +17,40 @@ */ package com.viaversion.viaversion.protocols.v1_20_5to1_21.data; +import com.viaversion.viaversion.api.minecraft.PaintingVariant; + public final class Paintings1_20_5 { public static final PaintingVariant[] PAINTINGS = { - new PaintingVariant("kebab", 1, 1), - new PaintingVariant("aztec", 1, 1), - new PaintingVariant("alban", 1, 1), - new PaintingVariant("aztec2", 1, 1), - new PaintingVariant("bomb", 1, 1), - new PaintingVariant("plant", 1, 1), - new PaintingVariant("wasteland", 1, 1), - new PaintingVariant("pool", 2, 1), - new PaintingVariant("courbet", 2, 1), - new PaintingVariant("sea", 2, 1), - new PaintingVariant("sunset", 2, 1), - new PaintingVariant("creebet", 2, 1), - new PaintingVariant("wanderer", 1, 2), - new PaintingVariant("graham", 1, 2), - new PaintingVariant("match", 2, 2), - new PaintingVariant("bust", 2, 2), - new PaintingVariant("stage", 2, 2), - new PaintingVariant("void", 2, 2), - new PaintingVariant("skull_and_roses", 2, 2), - new PaintingVariant("wither", 2, 2), - new PaintingVariant("fighters", 4, 2), - new PaintingVariant("pointer", 4, 4), - new PaintingVariant("pigscene", 4, 4), - new PaintingVariant("burning_skull", 4, 4), - new PaintingVariant("skeleton", 4, 3), - new PaintingVariant("earth", 2, 2), - new PaintingVariant("wind", 2, 2), - new PaintingVariant("water", 2, 2), - new PaintingVariant("fire", 2, 2), - new PaintingVariant("donkey_kong", 4, 3) + new PaintingVariant(1, 1, "kebab"), + new PaintingVariant(1, 1, "aztec"), + new PaintingVariant(1, 1, "alban"), + new PaintingVariant(1, 1, "aztec2"), + new PaintingVariant(1, 1, "bomb"), + new PaintingVariant(1, 1, "plant"), + new PaintingVariant(1, 1, "wasteland"), + new PaintingVariant(2, 1, "pool"), + new PaintingVariant(2, 1, "courbet"), + new PaintingVariant(2, 1, "sea"), + new PaintingVariant(2, 1, "sunset"), + new PaintingVariant(2, 1, "creebet"), + new PaintingVariant(1, 2, "wanderer"), + new PaintingVariant(1, 2, "graham"), + new PaintingVariant(2, 2, "match"), + new PaintingVariant(2, 2, "bust"), + new PaintingVariant(2, 2, "stage"), + new PaintingVariant(2, 2, "void"), + new PaintingVariant(2, 2, "skull_and_roses"), + new PaintingVariant(2, 2, "wither"), + new PaintingVariant(4, 2, "fighters"), + new PaintingVariant(4, 4, "pointer"), + new PaintingVariant(4, 4, "pigscene"), + new PaintingVariant(4, 4, "burning_skull"), + new PaintingVariant(4, 3, "skeleton"), + new PaintingVariant(2, 2, "earth"), + new PaintingVariant(2, 2, "wind"), + new PaintingVariant(2, 2, "water"), + new PaintingVariant(2, 2, "fire"), + new PaintingVariant(4, 3, "donkey_kong") }; - - public static final class PaintingVariant { - private final String key; - private final int width; - private final int height; - - public PaintingVariant(final String key, final int width, final int height) { - this.key = key; - this.width = width; - this.height = height; - } - - public String key() { - return key; - } - - public int width() { - return width; - } - - public int height() { - return height; - } - } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java index 556ebc95a..df5eacd2f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java @@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; import com.viaversion.viaversion.api.minecraft.item.Item; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.api.type.types.version.Types1_21; @@ -61,6 +62,13 @@ public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter { + wrapper.passthrough(Types.VAR_INT); // Hand + wrapper.passthrough(Types.VAR_INT); // Sequence + wrapper.read(Types.FLOAT); // Y rotation + wrapper.read(Types.FLOAT); // X rotation + }); + new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_20_5.UPDATE_RECIPES); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/EntityPacketRewriter1_21.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/EntityPacketRewriter1_21.java index 279a01597..ebfed4e87 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/EntityPacketRewriter1_21.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/EntityPacketRewriter1_21.java @@ -18,20 +18,23 @@ package com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter; import com.viaversion.nbt.tag.CompoundTag; +import com.viaversion.viaversion.api.minecraft.Holder; +import com.viaversion.viaversion.api.minecraft.PaintingVariant; import com.viaversion.viaversion.api.minecraft.RegistryEntry; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5; +import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.api.type.types.version.Types1_21; -import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21; -import com.viaversion.viaversion.protocols.v1_20_5to1_21.data.Paintings1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.data.Enchantments1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundConfigurationPackets1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.data.Paintings1_20_5; import com.viaversion.viaversion.rewriter.EntityRewriter; import com.viaversion.viaversion.util.Key; @@ -68,12 +71,12 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter { + final EntityDataType type = data.dataType(); + if (type == Types1_20_5.ENTITY_DATA_TYPES.wolfVariantType) { + final int variant = data.value(); + data.setTypeAndValue(Types1_21.ENTITY_DATA_TYPES.wolfVariantType, Holder.of(variant)); + } else if (type == Types1_20_5.ENTITY_DATA_TYPES.paintingVariantType) { + final int variant = data.value(); + data.setTypeAndValue(Types1_21.ENTITY_DATA_TYPES.paintingVariantType, Holder.of(variant)); + } else { + data.setDataType(Types1_21.ENTITY_DATA_TYPES.byId(type.typeId())); + } + }); registerEntityDataTypeHandler( Types1_21.ENTITY_DATA_TYPES.itemType, Types1_21.ENTITY_DATA_TYPES.blockStateType, diff --git a/gradle.properties b/gradle.properties index dba955c75..fddbc49f9 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=5.0.0-24w19b-SNAPSHOT +projectVersion=5.0.0-24w20a-SNAPSHOT # Smile emoji mcVersions=1.20.6,1.20.5,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