From ba725df33e49b150008004ac6db05bf545294a3b Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 18 Dec 2023 19:22:46 +0100 Subject: [PATCH] 23w51b --- .../api/ViaBackwardsPlatform.java | 6 +- .../api/rewriters/EntityRewriterBase.java | 31 +++- .../data/BackwardsMappings.java | 4 +- .../packets/EntityPackets1_16.java | 2 +- .../Protocol1_20_3To1_20_5.java | 113 ++++++++++++ .../BlockItemPacketRewriter1_20_5.java | 58 ++++++ .../rewriter/EntityPacketRewriter1_20_5.java | 167 ++++++++++++++++++ .../data/mappings-1.20.5to1.20.3.nbt | Bin 0 -> 1164 bytes .../data/translation-mappings.json | 25 +++ gradle.properties | 6 +- gradle/libs.versions.toml | 2 +- ...1_98To_99.java => Protocol1_98To1_99.java} | 23 +-- .../rewriter/BlockItemPacketRewriter1_99.java | 6 +- .../rewriter/EntityPacketRewriter1_99.java | 41 +++-- 14 files changed, 438 insertions(+), 46 deletions(-) create mode 100644 common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/Protocol1_20_3To1_20_5.java create mode 100644 common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java create mode 100644 common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java create mode 100644 common/src/main/resources/assets/viabackwards/data/mappings-1.20.5to1.20.3.nbt rename template/src/main/java/com/viaversion/viabackwards/template/protocol/{Protocol1_98To_99.java => Protocol1_98To1_99.java} (89%) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java index 1a8274af..36a066d0 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java @@ -52,6 +52,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_ import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.Protocol1_19_4To1_20; import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1; import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3; +import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.Protocol1_20_3To1_20_5; import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.Protocol1_20To1_20_2; import com.viaversion.viabackwards.protocol.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2To1_9_3_4; import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10; @@ -67,7 +68,7 @@ import java.util.logging.Logger; public interface ViaBackwardsPlatform { - String MINIMUM_VV_VERSION = "4.9.3"; + String MINIMUM_VV_VERSION = "4.10.0"; /** * Initialize ViaBackwards. @@ -136,6 +137,7 @@ public interface ViaBackwardsPlatform { protocolManager.registerProtocol(new Protocol1_19_4To1_20(), ProtocolVersion.v1_19_4, ProtocolVersion.v1_20); protocolManager.registerProtocol(new Protocol1_20To1_20_2(), ProtocolVersion.v1_20, ProtocolVersion.v1_20_2); protocolManager.registerProtocol(new Protocol1_20_2To1_20_3(), ProtocolVersion.v1_20_2, ProtocolVersion.v1_20_3); + protocolManager.registerProtocol(new Protocol1_20_3To1_20_5(), ProtocolVersion.v1_20_3, ProtocolVersion.v1_20_5); } /** @@ -149,7 +151,7 @@ public interface ViaBackwardsPlatform { String vvVersion = Via.getPlatform().getPluginVersion(); if (vvVersion != null && new Version(vvVersion).compareTo(new Version(MINIMUM_VV_VERSION + "--")) < 0) { getLogger().severe("================================"); - getLogger().severe("YOUR VIAVERSION IS OUTDATED"); + getLogger().severe("YOUR VIAVERSION IS OUTDATED (you are running " + vvVersion + ")"); getLogger().severe("PLEASE USE VIAVERSION " + MINIMUM_VV_VERSION + " OR NEWER"); getLogger().severe("LINK: https://ci.viaversion.com/"); getLogger().severe("VIABACKWARDS WILL NOW DISABLE"); diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java index f5450cde..bfabcbbc 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java @@ -199,11 +199,36 @@ public abstract class EntityRewriterBase { + MetaType type = meta.metaType(); + if (type == itemType) { + protocol.getItemRewriter().handleItemToClient(meta.value()); + } else if (type == blockStateType) { + int data = meta.value(); + meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); + } else if (type == optionalBlockStateType) { + int data = meta.value(); + if (data != 0) { + meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); } + } else if (type == particleType) { + rewriteParticle(meta.value()); + } else if (type == optionalComponentType || type == componentType) { + protocol.getTranslatableRewriter().processTag(meta.value()); } }); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/data/BackwardsMappings.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/data/BackwardsMappings.java index 9e319db6..ecbbf45d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/data/BackwardsMappings.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/data/BackwardsMappings.java @@ -32,12 +32,12 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back @Override protected void loadExtras(final CompoundTag data) { super.loadExtras(data); - for (Map.Entry entry : Protocol1_16To1_15_2.MAPPINGS.getAttributeMappings().entrySet()) { + for (Map.Entry entry : Protocol1_16To1_15_2.MAPPINGS.attributeIdentifierMappings().entrySet()) { attributeMappings.put(entry.getValue(), entry.getKey()); } } - public Map getAttributeMappings() { + public Map attributeIdentifierMappings() { return attributeMappings; } } \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java index 681b7d06..cbff7a9b 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java @@ -190,7 +190,7 @@ public class EntityPackets1_16 extends EntityRewriter. + */ +package com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5; + +import com.viaversion.viabackwards.api.BackwardsProtocol; +import com.viaversion.viabackwards.api.data.BackwardsMappings; +import com.viaversion.viabackwards.api.rewriters.SoundRewriter; +import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.rewriter.BlockItemPacketRewriter1_20_5; +import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.rewriter.EntityPacketRewriter1_20_5; +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5; +import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; +import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; +import com.viaversion.viaversion.api.protocol.packet.State; +import com.viaversion.viaversion.data.entity.EntityTrackerBase; +import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundConfigurationPackets1_20_2; +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_3to1_20_2.packet.ServerboundPackets1_20_3; +import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3; +import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType; +import com.viaversion.viaversion.rewriter.StatisticsRewriter; +import com.viaversion.viaversion.rewriter.TagRewriter; + +public final class Protocol1_20_3To1_20_5 extends BackwardsProtocol { + + public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.20.5", "1.20.3", Protocol1_20_5To1_20_3.class); + private final EntityPacketRewriter1_20_5 entityRewriter = new EntityPacketRewriter1_20_5(this); + private final BlockItemPacketRewriter1_20_5 itemRewriter = new BlockItemPacketRewriter1_20_5(this); + private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); + + public Protocol1_20_3To1_20_5() { + super(ClientboundPackets1_20_3.class, ClientboundPackets1_20_3.class, ServerboundPackets1_20_3.class, ServerboundPackets1_20_3.class); + } + + @Override + protected void registerPackets() { + super.registerPackets(); + + final TagRewriter tagRewriter = new TagRewriter<>(this); + tagRewriter.registerGeneric(ClientboundPackets1_20_3.TAGS); + tagRewriter.registerGeneric(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.UPDATE_TAGS); + + final SoundRewriter soundRewriter = new SoundRewriter<>(this); + soundRewriter.register1_19_3Sound(ClientboundPackets1_20_3.SOUND); + soundRewriter.registerSound(ClientboundPackets1_20_3.ENTITY_SOUND); + soundRewriter.registerStopSound(ClientboundPackets1_20_3.STOP_SOUND); + + new StatisticsRewriter<>(this).register(ClientboundPackets1_20_3.STATISTICS); + + translatableRewriter.registerComponentPacket(ClientboundPackets1_20_3.ACTIONBAR); + translatableRewriter.registerComponentPacket(ClientboundPackets1_20_3.TITLE_TEXT); + translatableRewriter.registerComponentPacket(ClientboundPackets1_20_3.TITLE_SUBTITLE); + translatableRewriter.registerBossBar(ClientboundPackets1_20_3.BOSSBAR); + translatableRewriter.registerComponentPacket(ClientboundPackets1_20_3.DISCONNECT); + translatableRewriter.registerTabList(ClientboundPackets1_20_3.TAB_LIST); + translatableRewriter.registerCombatKill1_20(ClientboundPackets1_20_3.COMBAT_KILL); + translatableRewriter.registerComponentPacket(ClientboundPackets1_20_3.SYSTEM_CHAT); + translatableRewriter.registerComponentPacket(ClientboundPackets1_20_3.DISGUISED_CHAT); + translatableRewriter.registerPing(); + } + + @Override + public void init(final UserConnection user) { + addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_20_5.PLAYER)); + } + + @Override + public BackwardsMappings getMappingData() { + return MAPPINGS; + } + + @Override + public EntityPacketRewriter1_20_5 getEntityRewriter() { + return entityRewriter; + } + + @Override + public BlockItemPacketRewriter1_20_5 getItemRewriter() { + return itemRewriter; + } + + @Override + public TranslatableRewriter getTranslatableRewriter() { + return translatableRewriter; + } + + @Override + protected ClientboundPacketType clientboundFinishConfigurationPacket() { + return ClientboundConfigurationPackets1_20_3.FINISH_CONFIGURATION; + } + + @Override + protected ServerboundPacketType serverboundFinishConfigurationPacket() { + return ServerboundConfigurationPackets1_20_2.FINISH_CONFIGURATION; + } +} \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java new file mode 100644 index 00000000..b2c762a2 --- /dev/null +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java @@ -0,0 +1,58 @@ +/* + * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards + * Copyright (C) 2023 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.rewriter; + +import com.viaversion.viabackwards.api.rewriters.ItemRewriter; +import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.Protocol1_20_3To1_20_5; +import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; +import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3; +import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ServerboundPackets1_20_3; +import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.rewriter.RecipeRewriter1_20_3; +import com.viaversion.viaversion.rewriter.BlockRewriter; + +public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter { + + public BlockItemPacketRewriter1_20_5(final Protocol1_20_3To1_20_5 protocol) { + super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_ARRAY); + } + + @Override + public void registerPackets() { + final BlockRewriter blockRewriter = BlockRewriter.for1_20_2(protocol); + blockRewriter.registerBlockAction(ClientboundPackets1_20_3.BLOCK_ACTION); + blockRewriter.registerBlockChange(ClientboundPackets1_20_3.BLOCK_CHANGE); + blockRewriter.registerVarLongMultiBlockChange1_20(ClientboundPackets1_20_3.MULTI_BLOCK_CHANGE); + blockRewriter.registerEffect(ClientboundPackets1_20_3.EFFECT, 1010, 2001); + blockRewriter.registerChunkData1_19(ClientboundPackets1_20_3.CHUNK_DATA, ChunkType1_20_2::new); + blockRewriter.registerBlockEntityData(ClientboundPackets1_20_3.BLOCK_ENTITY_DATA); + + registerSetCooldown(ClientboundPackets1_20_3.COOLDOWN); + registerWindowItems1_17_1(ClientboundPackets1_20_3.WINDOW_ITEMS); + registerSetSlot1_17_1(ClientboundPackets1_20_3.SET_SLOT); + registerAdvancements1_20_3(ClientboundPackets1_20_3.ADVANCEMENTS); + registerEntityEquipmentArray(ClientboundPackets1_20_3.ENTITY_EQUIPMENT); + registerClickWindow1_17_1(ServerboundPackets1_20_3.CLICK_WINDOW); + registerTradeList1_19(ClientboundPackets1_20_3.TRADE_LIST); + registerCreativeInvAction(ServerboundPackets1_20_3.CREATIVE_INVENTORY_ACTION); + registerWindowPropertyEnchantmentHandler(ClientboundPackets1_20_3.WINDOW_PROPERTY); + registerSpawnParticle1_19(ClientboundPackets1_20_3.SPAWN_PARTICLE); + + new RecipeRewriter1_20_3<>(protocol).register(ClientboundPackets1_20_3.DECLARE_RECIPES); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java new file mode 100644 index 00000000..6e0f9b64 --- /dev/null +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java @@ -0,0 +1,167 @@ +/* + * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards + * Copyright (C) 2023 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.rewriter; + +import com.viaversion.viabackwards.api.rewriters.EntityRewriter; +import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.Protocol1_20_3To1_20_5; +import com.viaversion.viaversion.api.minecraft.entities.EntityType; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5; +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.data.AttributeMappings; + +public final class EntityPacketRewriter1_20_5 extends EntityRewriter { + + public EntityPacketRewriter1_20_5(final Protocol1_20_3To1_20_5 protocol) { + super(protocol, Types1_20_3.META_TYPES.optionalComponentType, Types1_20_3.META_TYPES.booleanType); + } + + @Override + public void registerPackets() { + registerTrackerWithData1_19(ClientboundPackets1_20_3.SPAWN_ENTITY, EntityTypes1_20_5.FALLING_BLOCK); + registerMetadataRewriter(ClientboundPackets1_20_3.ENTITY_METADATA, Types1_20_5.METADATA_LIST, Types1_20_3.METADATA_LIST); + registerRemoveEntities(ClientboundPackets1_20_3.REMOVE_ENTITIES); + + protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.REGISTRY_DATA, new PacketHandlers() { + @Override + protected void register() { + map(Type.COMPOUND_TAG); // Registry data + handler(configurationDimensionDataHandler()); // Caches dimensions to access data like height later + handler(configurationBiomeSizeTracker()); // Tracks the amount of biomes sent for chunk data + } + }); + + protocol.registerClientbound(ClientboundPackets1_20_3.JOIN_GAME, new PacketHandlers() { + @Override + public void register() { + map(Type.INT); // Entity id + map(Type.BOOLEAN); // Hardcore + map(Type.STRING_ARRAY); // World List + map(Type.VAR_INT); // Max players + map(Type.VAR_INT); // View distance + map(Type.VAR_INT); // Simulation distance + map(Type.BOOLEAN); // Reduced debug info + map(Type.BOOLEAN); // Show death screen + map(Type.BOOLEAN); // Limited crafting + map(Type.STRING); // Dimension key + map(Type.STRING); // World + handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking + } + }); + + protocol.registerClientbound(ClientboundPackets1_20_3.RESPAWN, new PacketHandlers() { + @Override + public void register() { + map(Type.STRING); // Dimension + map(Type.STRING); // World + handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking + } + }); + + protocol.registerClientbound(ClientboundPackets1_20_3.ENTITY_EFFECT, wrapper -> { + wrapper.passthrough(Type.VAR_INT); // Entity ID + wrapper.passthrough(Type.VAR_INT); // Effect ID + wrapper.passthrough(Type.BYTE); // Amplifier + wrapper.passthrough(Type.VAR_INT); // Duration + wrapper.passthrough(Type.BYTE); // Flags + wrapper.write(Type.OPTIONAL_COMPOUND_TAG, null); // Add empty factor data + }); + + protocol.registerClientbound(ClientboundPackets1_20_3.ENTITY_PROPERTIES, wrapper -> { + wrapper.passthrough(Type.VAR_INT); // Entity ID + + final int size = wrapper.passthrough(Type.VAR_INT); + int newSize = size; + for (int i = 0; i < size; i++) { + // From a registry int ID to a string + final int id = protocol.getMappingData().getAttributeMappings().getNewId(wrapper.read(Type.VAR_INT)); + if (id == -1) { + // Remove new attributes from the list + newSize--; + + wrapper.read(Type.DOUBLE); // Base + final int modifierSize = wrapper.read(Type.VAR_INT); + for (int j = 0; j < modifierSize; j++) { + wrapper.read(Type.UUID); // ID + wrapper.read(Type.DOUBLE); // Amount + wrapper.read(Type.BYTE); // Operation + } + continue; + } + + final String attribute = AttributeMappings.attribute(id); + wrapper.write(Type.STRING, attribute); + + wrapper.passthrough(Type.DOUBLE); // Base + final int modifierSize = wrapper.passthrough(Type.VAR_INT); + for (int j = 0; j < modifierSize; j++) { + wrapper.passthrough(Type.UUID); // ID + wrapper.passthrough(Type.DOUBLE); // Amount + wrapper.passthrough(Type.BYTE); // Operation + } + } + + wrapper.set(Type.VAR_INT, 1, newSize); + }); + } + + @Override + protected void registerRewrites() { + filter().handler((event, meta) -> { + int id = meta.metaType().typeId(); + if (id >= Types1_20_5.META_TYPES.armadilloState.typeId()) { + id--; + } + + meta.setMetaType(Types1_20_3.META_TYPES.byId(id)); + }); + + registerMetaTypeHandler1_20_3( + 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_3.META_TYPES.componentType, + Types1_20_3.META_TYPES.optionalComponentType + ); + + filter().filterFamily(EntityTypes1_20_5.MINECART_ABSTRACT).index(11).handler((event, meta) -> { + final int blockState = meta.value(); + meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); + }); + + filter().type(EntityTypes1_20_5.ARMADILLO).removeIndex(17); // State + } + + @Override + public void onMappingDataLoaded() { + mapTypes(); + + mapEntityTypeWithData(EntityTypes1_20_5.ARMADILLO, EntityTypes1_20_5.COW).tagName(); + } + + @Override + public EntityType typeFromId(final int type) { + return EntityTypes1_20_5.getTypeFromId(type); + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/viabackwards/data/mappings-1.20.5to1.20.3.nbt b/common/src/main/resources/assets/viabackwards/data/mappings-1.20.5to1.20.3.nbt new file mode 100644 index 0000000000000000000000000000000000000000..422c61f17301da42c97411b9246d720fb0cd075d GIT binary patch literal 1164 zcma)+O>fgM7{{MBY1gKJ#5y*#ffR{*)FIX~-UbH_z;Q?%htqhCMG^Jd4#amH04WJW|Sj|O2Pr*8_)G%p|7i9&`-HA~Jkvsp#-Qo_N?-J$?yC(~gHzXJewb$4i03h_ zl?cn`)zOtIA`QqnV+qVRf%#gXiig!*DigOvU9bUq02hG-gaAaBYzvpG)uX<70U1kq z(IaPac!!4j!R=9S;J+-DPPl(OMMaf#K-*S&qEZ%#B#}$%n66s&l}t{3m`K$lcYidR z&~DQ&XYD78j+M zOElAvD&TKRk)OYV{OD#rZi8rZH19{8Rj`-wF{wP587L)X>&vm3b_b Hd64u6U`9+N literal 0 HcmV?d00001 diff --git a/common/src/main/resources/assets/viabackwards/data/translation-mappings.json b/common/src/main/resources/assets/viabackwards/data/translation-mappings.json index 112890a7..14677847 100644 --- a/common/src/main/resources/assets/viabackwards/data/translation-mappings.json +++ b/common/src/main/resources/assets/viabackwards/data/translation-mappings.json @@ -1,4 +1,29 @@ { + "1.20.5": { + "attribute.name.generic.block_interaction_range": "Block Interaction Range", + "attribute.name.generic.entity_interaction_range": "Entity Interaction Range", + "attribute.name.generic.scale": "Scale", + "attribute.name.generic.step_height": "Step Height", + "entity.minecraft.armadillo": "Armadillo", + "item.minecraft.armadillo_scute": "Armadillo Scute", + "item.minecraft.armadillo_spawn_egg": "Armadillo Spawn Egg", + "item.minecraft.turtle_scute": "Turtle Scute", + "item.minecraft.wolf_armor": "Wolf Armor", + "subtitles.entity.armadillo.ambient": "Armadillo grunts", + "subtitles.entity.armadillo.brush": "Armadillo brushes", + "subtitles.entity.armadillo.death": "Armadillo dies", + "subtitles.entity.armadillo.eat": "Armadillo eats", + "subtitles.entity.armadillo.hurt": "Armadillo hurts", + "subtitles.entity.armadillo.land": "Armadillo lands", + "subtitles.entity.armadillo.roll": "Armadillo rolls up", + "subtitles.entity.armadillo.scute_drop": "Scute drops", + "subtitles.entity.armadillo.unroll": "Armadillo unrolls", + "subtitles.entity.breeze.charge": "Breeze charges", + "subtitles.entity.breeze.deflect": "Breeze deflects", + "subtitles.entity.breeze.whirl": "Breeze whirls", + "subtitles.item.armor.equip_wolf": "Wolf armor straps", + "subtitles.item.armor.unequip_wolf": "Wolf armor slips off" + }, "1.20.3": { "accessibility.onboarding.accessibility.button": "Accessibility Settings...", "argument.style.invalid": "Invalid style: %s", diff --git a/gradle.properties b/gradle.properties index 76fdcfd3..7e197d96 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ -projectVersion=4.9.2-SNAPSHOT +projectVersion=4.10.0-23w51b-SNAPSHOT # Smile emoji -mcVersions=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 -mcVersionRange=1.10-1.20.3 +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 +mcVersionRange=1.10-1.20.4 waterfallVersion=1.20 velocityVersion=3.2 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8bcfa4ca..7ce3a5a5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ metadata.format.version = "1.1" [versions] # ViaVersion -viaver = "4.9.3-SNAPSHOT" +viaver = "4.10.0-23w51b-SNAPSHOT" # Common provided netty = "4.0.20.Final" diff --git a/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To_99.java b/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To1_99.java similarity index 89% rename from template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To_99.java rename to template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To1_99.java index 6d1f0acf..69fa2e49 100644 --- a/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To_99.java +++ b/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To1_99.java @@ -24,38 +24,38 @@ import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; import com.viaversion.viabackwards.template.protocol.rewriter.BlockItemPacketRewriter1_99; import com.viaversion.viabackwards.template.protocol.rewriter.EntityPacketRewriter1_99; import com.viaversion.viaversion.api.connection.UserConnection; -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.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; +import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundConfigurationPackets1_20_2; -import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2; 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_3to1_20_2.packet.ServerboundPackets1_20_3; +import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3; import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; -import org.checkerframework.checker.nullness.qual.Nullable; // Placeholders to replace (in the entire package): // Protocol1_98To_99, EntityPacketRewriter1_99, BlockItemPacketRewriter1_99 -// Protocol1_20_3To1_20_2 (the ViaVersion protocol class the mappings depend on) +// Protocol1_20_5To1_20_3 (the ViaVersion protocol class the mappings depend on) // ClientboundPackets1_20_3 // ServerboundPackets1_20_3 // ClientboundConfigurationPackets1_20_3 // ServerboundConfigurationPackets1_20_2 -// EntityTypes1_20_3 (UNMAPPED type) +// EntityTypes1_20_5 (UNMAPPED type) // 1.99, 1.98 -public final class Protocol1_98To_99 extends BackwardsProtocol { +public final class Protocol1_98To1_99 extends BackwardsProtocol { // ViaBackwards uses its own mappings and also needs a translatablerewriter for translation mappings - public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.99", "1.98", Protocol1_20_3To1_20_2.class); + public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.99", "1.98", Protocol1_20_5To1_20_3.class); private final EntityPacketRewriter1_99 entityRewriter = new EntityPacketRewriter1_99(this); private final BlockItemPacketRewriter1_99 itemRewriter = new BlockItemPacketRewriter1_99(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); - public Protocol1_98To_99() { + public Protocol1_98To1_99() { super(ClientboundPackets1_20_3.class, ClientboundPackets1_20_3.class, ServerboundPackets1_20_3.class, ServerboundPackets1_20_3.class); } @@ -65,6 +65,7 @@ public final class Protocol1_98To_99 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.registerGeneric(ClientboundPackets1_20_3.TAGS); + tagRewriter.registerGeneric(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.UPDATE_TAGS); final SoundRewriter soundRewriter = new SoundRewriter<>(this); soundRewriter.register1_19_3Sound(ClientboundPackets1_20_3.SOUND); @@ -85,11 +86,13 @@ public final class Protocol1_98To_99 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } diff --git a/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/BlockItemPacketRewriter1_99.java b/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/BlockItemPacketRewriter1_99.java index b9585cdd..28d11558 100644 --- a/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/BlockItemPacketRewriter1_99.java +++ b/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/BlockItemPacketRewriter1_99.java @@ -18,7 +18,7 @@ package com.viaversion.viabackwards.template.protocol.rewriter; import com.viaversion.viabackwards.api.rewriters.ItemRewriter; -import com.viaversion.viabackwards.template.protocol.Protocol1_98To_99; +import com.viaversion.viabackwards.template.protocol.Protocol1_98To1_99; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3; @@ -29,9 +29,9 @@ import com.viaversion.viaversion.rewriter.BlockRewriter; // To replace if needed: // ChunkType1_20_2 // RecipeRewriter1_20_3 -public final class BlockItemPacketRewriter1_99 extends ItemRewriter { +public final class BlockItemPacketRewriter1_99 extends ItemRewriter { - public BlockItemPacketRewriter1_99(final Protocol1_98To_99 protocol) { + public BlockItemPacketRewriter1_99(final Protocol1_98To1_99 protocol) { super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_ARRAY); } diff --git a/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/EntityPacketRewriter1_99.java b/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/EntityPacketRewriter1_99.java index 644762e5..7c87074c 100644 --- a/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/EntityPacketRewriter1_99.java +++ b/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/EntityPacketRewriter1_99.java @@ -18,29 +18,29 @@ package com.viaversion.viabackwards.template.protocol.rewriter; import com.viaversion.viabackwards.api.rewriters.EntityRewriter; -import com.viaversion.viabackwards.template.protocol.Protocol1_98To_99; +import com.viaversion.viabackwards.template.protocol.Protocol1_98To1_99; import com.viaversion.viaversion.api.minecraft.entities.EntityType; -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.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; // Replace if needed // Types1_OLD -// Types1_20_3 -public final class EntityPacketRewriter1_99 extends EntityRewriter { +// Types1_20_5 +public final class EntityPacketRewriter1_99 extends EntityRewriter { - public EntityPacketRewriter1_99(final Protocol1_98To_99 protocol) { - super(protocol, Types1_20_3.META_TYPES.optionalComponentType, Types1_20_3.META_TYPES.booleanType); + public EntityPacketRewriter1_99(final Protocol1_98To1_99 protocol) { + super(protocol, Types1_20_5.META_TYPES.optionalComponentType, Types1_20_5.META_TYPES.booleanType); } @Override public void registerPackets() { - registerTrackerWithData1_19(ClientboundPackets1_20_3.SPAWN_ENTITY, EntityTypes1_20_3.FALLING_BLOCK); - registerMetadataRewriter(ClientboundPackets1_20_3.ENTITY_METADATA, /*Types1_OLD.METADATA_LIST, */Types1_20_3.METADATA_LIST); // Specify old and new metadata list if changed + registerTrackerWithData1_19(ClientboundPackets1_20_3.SPAWN_ENTITY, EntityTypes1_20_5.FALLING_BLOCK); + registerMetadataRewriter(ClientboundPackets1_20_3.ENTITY_METADATA, /*Types1_OLD.METADATA_LIST, */Types1_20_5.METADATA_LIST); // Specify old and new metadata list if changed registerRemoveEntities(ClientboundPackets1_20_3.REMOVE_ENTITIES); protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.REGISTRY_DATA, new PacketHandlers() { @@ -93,23 +93,22 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter { + filter().filterFamily(EntityTypes1_20_5.MINECART_ABSTRACT).index(11).handler((event, meta) -> { final int blockState = meta.value(); meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); }); // Remove metadata of new entity type - // filter().type(Entity1_xTypes.SNIFFER).removeIndex(newIndex); + // filter().type(EntityTypes1_20_5.SNIFFER).removeIndex(newIndex); } @Override @@ -117,11 +116,11 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter