From 794f401bd04bc035635a59af84ee82641a9b7ef6 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 18 Dec 2023 19:34:53 +0100 Subject: [PATCH] Add armadildo state meta type --- .../metadata/types/MetaTypes1_20_5.java | 65 +++++++++++++++++++ .../api/type/types/version/Types1_20_5.java | 37 +++++++++++ .../rewriter/EntityPacketRewriter1_20_5.java | 20 ++++-- .../template/protocols/Protocol1_99To_98.java | 8 +-- .../rewriter/EntityPacketRewriter1_99.java | 26 ++++---- 5 files changed, 134 insertions(+), 22 deletions(-) create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_5.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/version/Types1_20_5.java 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 new file mode 100644 index 000000000..f56899da5 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_5.java @@ -0,0 +1,65 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2023 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.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; + +public final class MetaTypes1_20_5 extends AbstractMetaTypes { + + public final MetaType byteType = add(0, Type.BYTE); + public final MetaType varIntType = add(1, Type.VAR_INT); + public final MetaType longType = add(2, Type.VAR_LONG); + public final MetaType floatType = add(3, Type.FLOAT); + public final MetaType stringType = add(4, Type.STRING); + public final MetaType componentType = add(5, Type.TAG); + public final MetaType optionalComponentType = add(6, Type.OPTIONAL_TAG); + public final MetaType itemType = add(7, Type.ITEM1_20_2); + public final MetaType booleanType = add(8, Type.BOOLEAN); + public final MetaType rotationType = add(9, Type.ROTATION); + public final MetaType positionType = add(10, Type.POSITION1_14); + public final MetaType optionalPositionType = add(11, Type.OPTIONAL_POSITION_1_14); + public final MetaType directionType = add(12, Type.VAR_INT); + public final MetaType optionalUUIDType = add(13, Type.OPTIONAL_UUID); + public final MetaType blockStateType = add(14, Type.VAR_INT); + public final MetaType optionalBlockStateType = add(15, Type.VAR_INT); + public final MetaType nbtType = add(16, Type.COMPOUND_TAG); + public final MetaType particleType; + public final MetaType villagerDatatType = add(18, Type.VILLAGER_DATA); + public final MetaType optionalVarIntType = add(19, Type.OPTIONAL_VAR_INT); + public final MetaType poseType = add(20, Type.VAR_INT); + public final MetaType catVariantType = add(21, Type.VAR_INT); + public final MetaType frogVariantType = add(22, Type.VAR_INT); + public final MetaType optionalGlobalPosition = add(23, Type.OPTIONAL_GLOBAL_POSITION); + public final MetaType paintingVariantType = add(24, Type.VAR_INT); + public final MetaType snifferState = add(25, Type.VAR_INT); + public final MetaType armadilloState = add(26, Type.VAR_INT); + public final MetaType vectorType = add(27, Type.VECTOR3F); + public final MetaType quaternionType = add(28, Type.QUATERNION); + + public MetaTypes1_20_5(final ParticleType particleType) { + super(29); + this.particleType = add(17, particleType); + } +} 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 new file mode 100644 index 000000000..801eeb0ae --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/Types1_20_5.java @@ -0,0 +1,37 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2023 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.version; + +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.metadata.MetaListType; +import com.viaversion.viaversion.api.type.types.metadata.MetadataType; +import java.util.List; + +public final class Types1_20_5 { + + public static final MetaTypes1_20_5 META_TYPES = new MetaTypes1_20_5(Types1_20_3.PARTICLE); + public static final Type METADATA = new MetadataType(META_TYPES); + public static final Type> METADATA_LIST = new MetaListType(METADATA); +} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java index c8325ca9c..b62839f91 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java @@ -23,6 +23,7 @@ import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_20_3; +import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundConfigurationPackets1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3; @@ -39,7 +40,7 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter { + int id = meta.metaType().typeId(); + if (id >= Types1_20_5.META_TYPES.armadilloState.typeId()) { + id++; + } + + meta.setMetaType(Types1_20_5.META_TYPES.byId(id)); + }); + registerMetaTypeHandler( - Types1_20_3.META_TYPES.itemType, - Types1_20_3.META_TYPES.blockStateType, - Types1_20_3.META_TYPES.optionalBlockStateType, - Types1_20_3.META_TYPES.particleType + Types1_20_5.META_TYPES.itemType, + Types1_20_5.META_TYPES.blockStateType, + Types1_20_5.META_TYPES.optionalBlockStateType, + Types1_20_5.META_TYPES.particleType ); filter().filterFamily(EntityTypes1_20_5.MINECART_ABSTRACT).index(11).handler((event, meta) -> { diff --git a/template/src/main/java/com/viaversion/viaversion/template/protocols/Protocol1_99To_98.java b/template/src/main/java/com/viaversion/viaversion/template/protocols/Protocol1_99To_98.java index d9471724e..0e00c2d4f 100644 --- a/template/src/main/java/com/viaversion/viaversion/template/protocols/Protocol1_99To_98.java +++ b/template/src/main/java/com/viaversion/viaversion/template/protocols/Protocol1_99To_98.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.template.protocols; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.MappingData; import com.viaversion.viaversion.api.data.MappingDataBase; -import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_3; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; @@ -93,10 +93,10 @@ public final class Protocol1_99To_98 extends AbstractProtocol { public EntityPacketRewriter1_99(final Protocol1_99To_98 protocol) { @@ -40,8 +40,8 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter { - int id = meta.metaType().typeId(); + final int id = meta.metaType().typeId(); if (id >= SomeAddedIndex) { id++; } - meta.setMetaType(Types1_20_3.META_TYPES.byId(id)); + meta.setMetaType(Types1_20_5.META_TYPES.byId(id)); });*/ // Registers registry type id changes registerMetaTypeHandler( - Types1_20_3.META_TYPES.itemType, - Types1_20_3.META_TYPES.blockStateType, - Types1_20_3.META_TYPES.optionalBlockStateType, - Types1_20_3.META_TYPES.particleType + Types1_20_5.META_TYPES.itemType, + Types1_20_5.META_TYPES.blockStateType, + Types1_20_5.META_TYPES.optionalBlockStateType, + Types1_20_5.META_TYPES.particleType ); // Minecarts are special - filter().filterFamily(EntityTypes1_20_3.MINECART_ABSTRACT).index(11).handler((event, meta) -> { + filter().filterFamily(EntityTypes1_20_5.MINECART_ABSTRACT).index(11).handler((event, meta) -> { final int blockState = meta.value(); meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); }); @@ -115,6 +115,6 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter