From 6f8da18f6557c67e794cbf90ede28a11aa532877 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 22 May 2024 18:56:43 +0200 Subject: [PATCH] 24w21b, mostly --- .../api/data/BackwardsMappingData.java | 2 +- .../api/rewriters/TranslatableRewriter.java | 10 +- .../BlockItemPacketRewriter1_20_5.java | 4 +- .../v1_21to1_20_5/Protocol1_21To1_20_5.java | 103 +++++++++++++----- .../rewriter/BlockItemPacketRewriter1_21.java | 47 ++++---- .../rewriter/EntityPacketRewriter1_21.java | 28 +++-- .../data/mappings-1.21to1.20.5.nbt | Bin 818 -> 964 bytes .../data/translation-mappings.json | 102 +++++++++++++++++ gradle.properties | 2 +- gradle/libs.versions.toml | 2 +- settings.gradle.kts | 1 + .../template/protocol/Protocol1_98To1_99.java | 2 +- 12 files changed, 231 insertions(+), 72 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappingData.java b/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappingData.java index a1acfe5e..86ce4e85 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappingData.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappingData.java @@ -55,7 +55,7 @@ public class BackwardsMappingData extends MappingDataBase { public BackwardsMappingData(final String unmappedVersion, final String mappedVersion, @Nullable final Class> vvProtocolClass) { super(unmappedVersion, mappedVersion); - Preconditions.checkArgument(vvProtocolClass == null || !vvProtocolClass.isAssignableFrom(BackwardsProtocol.class)); + Preconditions.checkArgument(vvProtocolClass == null || !BackwardsProtocol.class.isAssignableFrom(vvProtocolClass)); this.vvProtocolClass = vvProtocolClass; } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java index 910f333b..9e94723d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java @@ -17,14 +17,14 @@ */ package com.viaversion.viabackwards.api.rewriters; +import com.viaversion.nbt.tag.CompoundTag; +import com.viaversion.nbt.tag.StringTag; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; -import com.viaversion.nbt.tag.CompoundTag; -import com.viaversion.nbt.tag.StringTag; import com.viaversion.viaversion.rewriter.ComponentRewriter; import java.util.HashMap; import java.util.Map; @@ -56,11 +56,11 @@ public class TranslatableRewriter extends Compo this(protocol, type, protocol.getClass().getSimpleName().replace("Protocol", "").split("To")[0].replace("_", ".")); } - public TranslatableRewriter(final BackwardsProtocol protocol, final ReadType type, final String sectionIdentifier) { + public TranslatableRewriter(final BackwardsProtocol protocol, final ReadType type, final String version) { super(protocol, type); - final Map translatableMappings = getTranslatableMappings(sectionIdentifier); + final Map translatableMappings = getTranslatableMappings(version); if (translatableMappings == null) { - protocol.getLogger().warning("Missing " + sectionIdentifier + " translatables!"); + protocol.getLogger().warning("Missing " + version + " translatables!"); this.translatables = new HashMap<>(); } else { this.translatables = translatableMappings; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java index 84e6de54..e81313bf 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java @@ -360,8 +360,8 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem // Convert to structured item first final Item structuredItem = vvProtocol.getItemRewriter().toStructuredItem(connection, item); - item.structuredData().setIdLookup(protocol, false); - enchantmentRewriter.handleToServer(item); + structuredItem.structuredData().setIdLookup(protocol, false); + enchantmentRewriter.handleToServer(structuredItem); return super.handleItemToServer(connection, structuredItem); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java index 4bc13851..ab4bf6c3 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5; import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider; import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.data.entity.EntityTrackerBase; 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; @@ -35,54 +36,98 @@ import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPac import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundConfigurationPackets1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5; -import com.viaversion.viaversion.rewriter.AttributeRewriter; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21; import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap; -public final class Protocol1_21To1_20_5 extends BackwardsProtocol { +public final class Protocol1_21To1_20_5 extends BackwardsProtocol { - public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.21", "1.20.5", Protocol1_21To1_20_5.class); + public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.21", "1.20.5", Protocol1_20_5To1_21.class); private final EntityPacketRewriter1_21 entityRewriter = new EntityPacketRewriter1_21(this); private final BlockItemPacketRewriter1_21 itemRewriter = new BlockItemPacketRewriter1_21(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); - private final TagRewriter tagRewriter = new TagRewriter<>(this); + private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_21To1_20_5() { - super(ClientboundPacket1_20_5.class, ClientboundPacket1_20_5.class, ServerboundPacket1_20_5.class, ServerboundPacket1_20_5.class); + super(ClientboundPacket1_21.class, ClientboundPacket1_20_5.class, ServerboundPacket1_20_5.class, ServerboundPacket1_20_5.class); } @Override protected void registerPackets() { super.registerPackets(); - tagRewriter.registerGeneric(ClientboundPackets1_20_5.UPDATE_TAGS); - tagRewriter.registerGeneric(ClientboundConfigurationPackets1_20_5.UPDATE_TAGS); + tagRewriter.registerGeneric(ClientboundPackets1_21.UPDATE_TAGS); + tagRewriter.registerGeneric(ClientboundConfigurationPackets1_21.UPDATE_TAGS); - final SoundRewriter soundRewriter = new SoundRewriter<>(this); - soundRewriter.registerSound1_19_3(ClientboundPackets1_20_5.SOUND); - soundRewriter.registerSound1_19_3(ClientboundPackets1_20_5.SOUND_ENTITY); - soundRewriter.registerStopSound(ClientboundPackets1_20_5.STOP_SOUND); + final SoundRewriter soundRewriter = new SoundRewriter<>(this); + soundRewriter.registerSound1_19_3(ClientboundPackets1_21.SOUND); + soundRewriter.registerSound1_19_3(ClientboundPackets1_21.SOUND_ENTITY); + soundRewriter.registerStopSound(ClientboundPackets1_21.STOP_SOUND); - new StatisticsRewriter<>(this).register(ClientboundPackets1_20_5.AWARD_STATS); - new AttributeRewriter<>(this).register1_20_5(ClientboundPackets1_20_5.UPDATE_ATTRIBUTES); + new StatisticsRewriter<>(this).register(ClientboundPackets1_21.AWARD_STATS); - translatableRewriter.registerOpenScreen(ClientboundPackets1_20_5.OPEN_SCREEN); - translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_ACTION_BAR_TEXT); - translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_TITLE_TEXT); - translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_SUBTITLE_TEXT); - translatableRewriter.registerBossEvent(ClientboundPackets1_20_5.BOSS_EVENT); - translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.DISCONNECT); - translatableRewriter.registerTabList(ClientboundPackets1_20_5.TAB_LIST); - translatableRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_20_5.PLAYER_COMBAT_KILL); - translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SYSTEM_CHAT); - translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.DISGUISED_CHAT); + translatableRewriter.registerOpenScreen(ClientboundPackets1_21.OPEN_SCREEN); + translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SET_ACTION_BAR_TEXT); + translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SET_TITLE_TEXT); + translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SET_SUBTITLE_TEXT); + translatableRewriter.registerBossEvent(ClientboundPackets1_21.BOSS_EVENT); + translatableRewriter.registerComponentPacket(ClientboundPackets1_21.DISCONNECT); + translatableRewriter.registerTabList(ClientboundPackets1_21.TAB_LIST); + translatableRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21.PLAYER_COMBAT_KILL); + translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SYSTEM_CHAT); + translatableRewriter.registerComponentPacket(ClientboundPackets1_21.DISGUISED_CHAT); translatableRewriter.registerPing(); // Format change we can't properly map - all this really results in is a desync one version earlier - cancelClientbound(ClientboundPackets1_20_5.PROJECTILE_POWER); + cancelClientbound(ClientboundPackets1_21.PROJECTILE_POWER); + + cancelClientbound(ClientboundPackets1_21.CUSTOM_REPORT_DETAILS); + cancelClientbound(ClientboundPackets1_21.SERVER_LINKS); + cancelClientbound(ClientboundConfigurationPackets1_21.CUSTOM_REPORT_DETAILS); + cancelClientbound(ClientboundConfigurationPackets1_21.SERVER_LINKS); + + registerClientbound(ClientboundPackets1_21.UPDATE_ATTRIBUTES, wrapper -> { + wrapper.passthrough(Types.VAR_INT); // Entity ID + + final int size = wrapper.passthrough(Types.VAR_INT); + int newSize = size; + for (int i = 0; i < size; i++) { + final int attributeId = wrapper.read(Types.VAR_INT); + final int mappedId = MAPPINGS.getNewAttributeId(attributeId); + if (mappedId == -1) { + newSize--; + + wrapper.read(Types.DOUBLE); // Base + final int modifierSize = wrapper.read(Types.VAR_INT); + for (int j = 0; j < modifierSize; j++) { + wrapper.read(Types.STRING); // ID + wrapper.read(Types.DOUBLE); // Amount + wrapper.read(Types.BYTE); // Operation + } + continue; + } + + wrapper.write(Types.VAR_INT, mappedId); + wrapper.passthrough(Types.DOUBLE); // Base + final int modifierSize = wrapper.passthrough(Types.VAR_INT); + for (int j = 0; j < modifierSize; j++) { + final String id = wrapper.read(Types.STRING); + wrapper.write(Types.UUID, Protocol1_20_5To1_21.mapAttributeId(id)); + wrapper.passthrough(Types.DOUBLE); // Amount + wrapper.passthrough(Types.BYTE); // Operation + } + } + + if (size != newSize) { + wrapper.set(Types.VAR_INT, 1, newSize); + } + }); } @Override @@ -107,19 +152,19 @@ public final class Protocol1_21To1_20_5 extends BackwardsProtocol getTranslatableRewriter() { + public TranslatableRewriter getTranslatableRewriter() { return translatableRewriter; } @Override - public TagRewriter getTagRewriter() { + public TagRewriter getTagRewriter() { return tagRewriter; } @Override - protected PacketTypesProvider createPacketTypesProvider() { + protected PacketTypesProvider createPacketTypesProvider() { return new SimplePacketTypesProvider<>( - packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_20_5.class, ClientboundConfigurationPackets1_20_5.class), + packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_21.class, ClientboundConfigurationPackets1_21.class), packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_20_5.class, ClientboundConfigurationPackets1_20_5.class), packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class), packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/BlockItemPacketRewriter1_21.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/BlockItemPacketRewriter1_21.java index eec85715..d9235166 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/BlockItemPacketRewriter1_21.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/BlockItemPacketRewriter1_21.java @@ -39,17 +39,20 @@ import com.viaversion.viaversion.api.type.types.version.Types1_21; import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap; import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.RecipeRewriter1_20_3; 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.ClientboundPacket1_20_5; -import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.rewriter.IdRewriteFunction; import java.util.ArrayList; import java.util.Arrays; import org.checkerframework.checker.nullness.qual.Nullable; -public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRewriter { +import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.downgradeItemData; +import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.updateItemData; + +public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRewriter { private final StructuredEnchantmentRewriter enchantmentRewriter = new StructuredEnchantmentRewriter(this); @@ -59,25 +62,25 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe @Override public void registerPackets() { - final BlockRewriter blockRewriter = BlockRewriter.for1_20_2(protocol); - blockRewriter.registerBlockEvent(ClientboundPackets1_20_5.BLOCK_EVENT); - blockRewriter.registerBlockUpdate(ClientboundPackets1_20_5.BLOCK_UPDATE); - blockRewriter.registerSectionBlocksUpdate1_20(ClientboundPackets1_20_5.SECTION_BLOCKS_UPDATE); - blockRewriter.registerLevelEvent(ClientboundPackets1_20_5.LEVEL_EVENT, 1010, 2001); - blockRewriter.registerLevelChunk1_19(ClientboundPackets1_20_5.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_20_2::new); - blockRewriter.registerBlockEntityData(ClientboundPackets1_20_5.BLOCK_ENTITY_DATA); + final BlockRewriter blockRewriter = BlockRewriter.for1_20_2(protocol); + blockRewriter.registerBlockEvent(ClientboundPackets1_21.BLOCK_EVENT); + blockRewriter.registerBlockUpdate(ClientboundPackets1_21.BLOCK_UPDATE); + blockRewriter.registerSectionBlocksUpdate1_20(ClientboundPackets1_21.SECTION_BLOCKS_UPDATE); + blockRewriter.registerLevelEvent(ClientboundPackets1_21.LEVEL_EVENT, 1010, 2001); + blockRewriter.registerLevelChunk1_19(ClientboundPackets1_21.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_20_2::new); + blockRewriter.registerBlockEntityData(ClientboundPackets1_21.BLOCK_ENTITY_DATA); - registerCooldown(ClientboundPackets1_20_5.COOLDOWN); - registerSetContent1_17_1(ClientboundPackets1_20_5.CONTAINER_SET_CONTENT); - registerSetSlot1_17_1(ClientboundPackets1_20_5.CONTAINER_SET_SLOT); - registerAdvancements1_20_3(ClientboundPackets1_20_5.UPDATE_ADVANCEMENTS); - registerSetEquipment(ClientboundPackets1_20_5.SET_EQUIPMENT); + registerCooldown(ClientboundPackets1_21.COOLDOWN); + registerSetContent1_17_1(ClientboundPackets1_21.CONTAINER_SET_CONTENT); + registerSetSlot1_17_1(ClientboundPackets1_21.CONTAINER_SET_SLOT); + registerAdvancements1_20_3(ClientboundPackets1_21.UPDATE_ADVANCEMENTS); + registerSetEquipment(ClientboundPackets1_21.SET_EQUIPMENT); registerContainerClick1_17_1(ServerboundPackets1_20_5.CONTAINER_CLICK); - registerMerchantOffers1_20_5(ClientboundPackets1_20_5.MERCHANT_OFFERS, Types1_21.ITEM_COST, Types1_20_5.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_20_5.OPTIONAL_ITEM_COST); + registerMerchantOffers1_20_5(ClientboundPackets1_21.MERCHANT_OFFERS, Types1_21.ITEM_COST, Types1_20_5.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_20_5.OPTIONAL_ITEM_COST); registerSetCreativeModeSlot(ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT); - registerContainerSetData(ClientboundPackets1_20_5.CONTAINER_SET_DATA); - registerLevelParticles1_20_5(ClientboundPackets1_20_5.LEVEL_PARTICLES, Types1_21.PARTICLE, Types1_20_5.PARTICLE); - registerExplosion(ClientboundPackets1_20_5.EXPLODE, Types1_21.PARTICLE, Types1_20_5.PARTICLE); + registerContainerSetData(ClientboundPackets1_21.CONTAINER_SET_DATA); + registerLevelParticles1_20_5(ClientboundPackets1_21.LEVEL_PARTICLES, Types1_21.PARTICLE, Types1_20_5.PARTICLE); + registerExplosion(ClientboundPackets1_21.EXPLODE, Types1_21.PARTICLE, Types1_20_5.PARTICLE); protocol.registerServerbound(ServerboundPackets1_20_5.USE_ITEM, wrapper -> { wrapper.passthrough(Types.VAR_INT); // Hand @@ -86,7 +89,7 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe wrapper.write(Types.FLOAT, 0f); // X rotation }); - new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_20_5.UPDATE_RECIPES); + new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_21.UPDATE_RECIPES); } @Override @@ -117,6 +120,8 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe enchantmentRewriter.rewriteEnchantmentsToClient(data, StructuredDataKey.ENCHANTMENTS, idRewriteFunction, descriptionSupplier, false); enchantmentRewriter.rewriteEnchantmentsToClient(data, StructuredDataKey.STORED_ENCHANTMENTS, idRewriteFunction, descriptionSupplier, true); + downgradeItemData(item); + return super.handleItemToClient(connection, item); } @@ -137,6 +142,8 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe // Restore originals if present enchantmentRewriter.handleToServer(item); + updateItemData(item); + return super.handleItemToServer(connection, item); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/EntityPacketRewriter1_21.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/EntityPacketRewriter1_21.java index 32391da9..47203b29 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/EntityPacketRewriter1_21.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/EntityPacketRewriter1_21.java @@ -33,16 +33,16 @@ 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_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.data.Paintings1_20_5; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21; import com.viaversion.viaversion.util.Key; import com.viaversion.viaversion.util.KeyMappings; import java.util.HashMap; import java.util.Map; -public final class EntityPacketRewriter1_21 extends EntityRewriter { +public final class EntityPacketRewriter1_21 extends EntityRewriter { private final Map oldPaintings = new HashMap<>(); @@ -57,12 +57,17 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter { + protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, wrapper -> { final String key = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING)); + if (key.equals("jukebox_song")) { + wrapper.cancel(); + return; + } + final RegistryEntry[] entries = wrapper.passthrough(Types.REGISTRY_ENTRY_ARRAY); final boolean paintingVariant = key.equals("painting_variant"); if (paintingVariant || key.equals("enchantment")) { @@ -92,7 +97,7 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter { + protocol.registerClientbound(ClientboundPackets1_21.RESPAWN, wrapper -> { final int dimensionId = wrapper.passthrough(Types.VAR_INT); final String world = wrapper.passthrough(Types.STRING); trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world); // Tracks world height and name for chunk data and entity (un)tracking @@ -151,7 +156,7 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter variant = data.value(); if (variant.hasId()) { - data.setTypeAndValue(Types1_20_5.ENTITY_DATA_TYPES.wolfVariantType, variant); + data.setTypeAndValue(Types1_20_5.ENTITY_DATA_TYPES.wolfVariantType, variant.id()); } else { event.cancel(); } @@ -168,7 +173,6 @@ public final class EntityPacketRewriter1_21 extends EntityRewritern zs9^qN5yo{9!YPR*iSfz#xdr)osd**wC6xuK%nV$)i3J6zDZ!alsX!Af7#Wx{Qy7^U zSc)M6mN3hifU;UZtPQh_31T>d*5>_;g^ZdU3`$8k`N`ROWr?LZC3;1vS*gh-@kOcS TiA5=?De(n4iIu5EK>Z8=Zbv|> delta 70 zcmX@YzKLzZLt`&)2ByRk1_lNe1_tIbAT9^u3LvfoN|fY-B>p1-kfO;djO#Y*GUYKc HF)#oCxrP>8 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 137bb38b..898fe93e 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,106 @@ { + "1.21": { + "argument.entity.selector.nearestEntity": "Nearest entity", + "attribute.name.generic.burning_time": "Burning Time", + "attribute.name.generic.explosion_knockback_resistance": "Explosion Knockback Resistance", + "attribute.name.generic.movement_efficiency": "Movement Efficiency", + "attribute.name.generic.oxygen_bonus": "Oxygen Bonus", + "attribute.name.generic.water_movement_efficiency": "Water Movement Efficiency", + "attribute.name.player.mining_efficiency": "Mining Efficiency", + "attribute.name.player.sneaking_speed": "Sneaking Speed", + "attribute.name.player.submerged_mining_speed": "Submerged Mining Speed", + "attribute.name.player.sweeping_damage_ratio": "Sweeping Damage Ratio", + "gamerule.entitiesWithPassengersCanUsePortals": "Entities with passengers can use portals", + "gamerule.entitiesWithPassengersCanUsePortals.description": "Allow entities with passengers to teleport through nether portals, end portals and end gateways.", + "gui.fileDropFailure.detail": "Rejected %d files", + "gui.fileDropFailure.title": "Failed to add files", + "gui.open_report_dir": "Open Report Directory", + "gui.report_to_server": "Report To Server", + "item.minecraft.music_disc_creator": "Music Disc", + "item.minecraft.music_disc_creator_music_box": "Music Disc", + "item.minecraft.music_disc_creator_music_box.desc": "Lena Raine - Creator (Music Box)", + "item.minecraft.music_disc_creator.desc": "Lena Raine - Creator", + "item.minecraft.music_disc_precipice": "Music Disc", + "item.minecraft.music_disc_precipice.desc": "Aaron Cherof - Precipice", + "item.modifiers.any": "When equipped:", + "item.modifiers.armor": "When worn:", + "item.modifiers.hand": "When held:", + "jukebox_song.minecraft.5": "Samuel �berg - 5", + "jukebox_song.minecraft.11": "C418 - 11", + "jukebox_song.minecraft.13": "C418 - 13", + "jukebox_song.minecraft.blocks": "C418 - blocks", + "jukebox_song.minecraft.cat": "C418 - cat", + "jukebox_song.minecraft.chirp": "C418 - chirp", + "jukebox_song.minecraft.creator": "Lena Raine - Creator", + "jukebox_song.minecraft.creator_music_box": "Lena Raine - Creator (Music Box)", + "jukebox_song.minecraft.far": "C418 - far", + "jukebox_song.minecraft.mall": "C418 - mall", + "jukebox_song.minecraft.mellohi": "C418 - mellohi", + "jukebox_song.minecraft.otherside": "Lena Raine - otherside", + "jukebox_song.minecraft.pigstep": "Lena Raine - Pigstep", + "jukebox_song.minecraft.precipice": "Aaron Cherof - Precipice", + "jukebox_song.minecraft.relic": "Aaron Cherof - Relic", + "jukebox_song.minecraft.stal": "C418 - stal", + "jukebox_song.minecraft.strad": "C418 - strad", + "jukebox_song.minecraft.wait": "C418 - wait", + "jukebox_song.minecraft.ward": "C418 - ward", + "known_server_link.report_bug": "Report Server Bug", + "mco.compatibility.incompatible.popup.title": "Incompatible version", + "mco.compatibility.incompatible.releaseType.popup.message": "The world you are trying to join is incompatible with the version you are on.", + "mco.compatibility.incompatible.series.popup.message": "This world was last played in version %s; you are on version %s.\n\nThese series are not compatible with each other. A new world is needed to play on this version.", + "mco.compatibility.upgrade.friend.description": "This world was last played in version %s; you are on version %s.\n\nA backup of the world will be saved under \"World Backups\".\n\nThe owner of the Realm can restore the world if needed.", + "mco.configure.world.resourcepack.question": "You need a custom resource pack to play on this realm\n\nDo you want to download it and play?", + "mco.download.confirmation.oversized": "The world you are going to download is larger than %s\n\nYou won't be able to upload this world to your realm again", + "mco.onlinePlayers": "Online Players", + "menu.feedback": "Feedback...", + "menu.feedback.title": "Feedback", + "menu.server_links": "Server Links...", + "menu.server_links.title": "Server Links", + "options.realmsNotifications.tooltip": "Fetches Realms news and invites in the title screen and displays their respective icon on the Realms button.", + "painting.minecraft.backyard.author": "Kristoffer Zetterstrand", + "painting.minecraft.backyard.title": "Backyard", + "painting.minecraft.baroque.author": "Sarah Boeving", + "painting.minecraft.baroque.title": "Baroque", + "painting.minecraft.bouquet.author": "Kristoffer Zetterstrand", + "painting.minecraft.bouquet.title": "Bouquet", + "painting.minecraft.cavebird.author": "Kristoffer Zetterstrand", + "painting.minecraft.cavebird.title": "Cavebird", + "painting.minecraft.changing.author": "Kristoffer Zetterstrand", + "painting.minecraft.changing.title": "Changing", + "painting.minecraft.cotan.author": "Kristoffer Zetterstrand", + "painting.minecraft.cotan.title": "Cot�n", + "painting.minecraft.endboss.author": "Kristoffer Zetterstrand", + "painting.minecraft.endboss.title": "Endboss", + "painting.minecraft.fern.author": "Kristoffer Zetterstrand", + "painting.minecraft.fern.title": "Fern", + "painting.minecraft.finding.author": "Kristoffer Zetterstrand", + "painting.minecraft.finding.title": "Finding", + "painting.minecraft.humble.author": "Sarah Boeving", + "painting.minecraft.humble.title": "Humble", + "painting.minecraft.lowmist.author": "Kristoffer Zetterstrand", + "painting.minecraft.lowmist.title": "Lowmist", + "painting.minecraft.meditative.author": "Sarah Boeving", + "painting.minecraft.meditative.title": "Meditative", + "painting.minecraft.orb.author": "Kristoffer Zetterstrand", + "painting.minecraft.orb.title": "Orb", + "painting.minecraft.owlemons.author": "Kristoffer Zetterstrand", + "painting.minecraft.owlemons.title": "Owlemons", + "painting.minecraft.passage.author": "Kristoffer Zetterstrand", + "painting.minecraft.passage.title": "Passage", + "painting.minecraft.pond.author": "Kristoffer Zetterstrand", + "painting.minecraft.pond.title": "Pond", + "painting.minecraft.prairie_ride.author": "Sarah Boeving", + "painting.minecraft.prairie_ride.title": "Prairie Ride", + "painting.minecraft.sunflowers.author": "Kristoffer Zetterstrand", + "painting.minecraft.sunflowers.title": "Sunflowers", + "painting.minecraft.tides.author": "Kristoffer Zetterstrand", + "painting.minecraft.tides.title": "Tides", + "painting.minecraft.unpacked.author": "Sarah Boeving", + "painting.minecraft.unpacked.title": "Unpacked", + "subtitles.block.trial_spawner.ambient_ominous": "Ominous crackling", + "subtitles.block.trial_spawner.ominous_activate": "Omen engulfs Trial Spawner", + "subtitles.block.vault.reject_rewarded_player": "Vault rejects already rewarded player" + }, "1.20.5": { "advancements.adventure.blowback.description": "Kill a Breeze with a deflected Breeze-shot Wind Charge", "advancements.adventure.blowback.title": "Blowback", diff --git a/gradle.properties b/gradle.properties index b7780858..0e6bc16e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -projectVersion=5.0.0-24w20a-SNAPSHOT +projectVersion=5.0.0-24w21b-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 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 50b5dd13..85907022 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ metadata.format.version = "1.1" [versions] # ViaVersion -viaver = "5.0.0-24w20a-SNAPSHOT" +viaver = "5.0.0-24w21a-SNAPSHOT" # Common provided netty = "4.0.20.Final" diff --git a/settings.gradle.kts b/settings.gradle.kts index 440aa545..b1053759 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,6 +4,7 @@ rootProject.name = "viabackwards-parent" dependencyResolutionManagement { repositories { + mavenLocal() maven("https://repo.viaversion.com") maven("https://repo.papermc.io/repository/maven-public/") mavenCentral() diff --git a/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To1_99.java b/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To1_99.java index e040897a..36888203 100644 --- a/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To1_99.java +++ b/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To1_99.java @@ -76,7 +76,7 @@ public final class Protocol1_98To1_99 extends BackwardsProtocol(this).register(ClientboundPackets1_20_5.AWARD_STATS); - //new AttributeRewriter<>(this).register1_20_5(ClientboundPackets1_20_5.ENTITY_PROPERTIES); + //new AttributeRewriter<>(this).register1_21(ClientboundPackets1_20_5.ENTITY_PROPERTIES); // Registers translatable mappings (missing a whole bunch still) //translatableRewriter.registerOpenWindow(ClientboundPackets1_20_5.OPEN_WINDOW); // Handled by registerOpenWindow in item rewriters