diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java index 1a4818c0..e5a81d90 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java @@ -35,6 +35,7 @@ import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.rewriter.StructuredItemRewriter; import java.util.ArrayList; import java.util.List; +import java.util.function.Function; import org.checkerframework.checker.nullness.qual.Nullable; public class BackwardsStructuredItemRewriter extends Compo super(protocol, type); final Map translatableMappings = getTranslatableMappings(version); if (translatableMappings == null) { - protocol.getLogger().warning("Missing " + version + " translatables!"); + ViaBackwards.getPlatform().getLogger().warning("Missing " + version + " translatables!"); this.translatables = new HashMap<>(); } else { this.translatables = translatableMappings; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/template/BlockItemPacketRewriter1_99.java b/common/src/main/java/com/viaversion/viabackwards/protocol/template/BlockItemPacketRewriter1_99.java index bf0987f5..b9c27c8a 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/template/BlockItemPacketRewriter1_99.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/template/BlockItemPacketRewriter1_99.java @@ -19,11 +19,11 @@ package com.viaversion.viabackwards.protocol.template; import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; -import com.viaversion.viaversion.api.type.types.version.Types1_21; -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.api.type.types.version.Types1_21_2; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ServerboundPacket1_21_2; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ServerboundPackets1_21_2; import com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.RecipeRewriter1_21_2; import com.viaversion.viaversion.rewriter.BlockRewriter; @@ -31,10 +31,10 @@ import com.viaversion.viaversion.rewriter.BlockRewriter; // ChunkType1_20_2 // RecipeRewriter1_20_3 // Types1_21 -final class BlockItemPacketRewriter1_99 extends BackwardsStructuredItemRewriter { +final class BlockItemPacketRewriter1_99 extends BackwardsStructuredItemRewriter { public BlockItemPacketRewriter1_99(final Protocol1_98To1_99 protocol) { - super(protocol, Types1_21.ITEM, Types1_21.ITEM_ARRAY); + super(protocol, Types1_21_2.ITEM, Types1_21_2.ITEM_ARRAY); /*super(protocol, Types1_21.ITEM, Types1_21.ITEM_ARRAY, Types1_OLD.ITEM, Types1_OLD.ITEM_ARRAY, Types1_21.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_OLD.ITEM_COST, Types1_OLD.OPTIONAL_ITEM_COST, @@ -44,27 +44,28 @@ final class BlockItemPacketRewriter1_99 extends BackwardsStructuredItemRewriter< @Override public void registerPackets() { - 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.registerLevelEvent1_21(ClientboundPackets1_21.LEVEL_EVENT, 2001); - blockRewriter.registerLevelChunk1_19(ClientboundPackets1_21.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_20_2::new); - blockRewriter.registerBlockEntityData(ClientboundPackets1_21.BLOCK_ENTITY_DATA); + final BlockRewriter blockRewriter = BlockRewriter.for1_20_2(protocol); + blockRewriter.registerBlockEvent(ClientboundPackets1_21_2.BLOCK_EVENT); + blockRewriter.registerBlockUpdate(ClientboundPackets1_21_2.BLOCK_UPDATE); + blockRewriter.registerSectionBlocksUpdate1_20(ClientboundPackets1_21_2.SECTION_BLOCKS_UPDATE); + blockRewriter.registerLevelEvent1_21(ClientboundPackets1_21_2.LEVEL_EVENT, 2001); + blockRewriter.registerLevelChunk1_19(ClientboundPackets1_21_2.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_20_2::new); + blockRewriter.registerBlockEntityData(ClientboundPackets1_21_2.BLOCK_ENTITY_DATA); - // registerOpenScreen(ClientboundPackets1_21.OPEN_SCREEN); - registerCooldown(ClientboundPackets1_21.COOLDOWN); - registerSetContent1_21_2(ClientboundPackets1_21.CONTAINER_SET_CONTENT); - registerSetSlot1_21_2(ClientboundPackets1_21.CONTAINER_SET_SLOT); - registerAdvancements1_20_3(ClientboundPackets1_21.UPDATE_ADVANCEMENTS); - registerSetEquipment(ClientboundPackets1_21.SET_EQUIPMENT); - registerContainerClick1_21_2(ServerboundPackets1_20_5.CONTAINER_CLICK); - registerMerchantOffers1_20_5(ClientboundPackets1_21.MERCHANT_OFFERS); - registerSetCreativeModeSlot(ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT); - registerContainerSetData(ClientboundPackets1_21.CONTAINER_SET_DATA); - registerLevelParticles1_20_5(ClientboundPackets1_21.LEVEL_PARTICLES); - registerExplosion1_21_2(ClientboundPackets1_21.EXPLODE); + // registerOpenScreen(ClientboundPackets1_21_2.OPEN_SCREEN); + protocol.registerClientbound(ClientboundPackets1_21_2.SET_CURSOR_ITEM, this::passthroughClientboundItem); + registerCooldown1_21_2(ClientboundPackets1_21_2.COOLDOWN); + registerSetContent1_21_2(ClientboundPackets1_21_2.CONTAINER_SET_CONTENT); + registerSetSlot1_21_2(ClientboundPackets1_21_2.CONTAINER_SET_SLOT); + registerAdvancements1_20_3(ClientboundPackets1_21_2.UPDATE_ADVANCEMENTS); + registerSetEquipment(ClientboundPackets1_21_2.SET_EQUIPMENT); + registerMerchantOffers1_20_5(ClientboundPackets1_21_2.MERCHANT_OFFERS); + registerContainerSetData(ClientboundPackets1_21_2.CONTAINER_SET_DATA); + registerLevelParticles1_20_5(ClientboundPackets1_21_2.LEVEL_PARTICLES); + registerExplosion1_21_2(ClientboundPackets1_21_2.EXPLODE); + registerContainerClick1_21_2(ServerboundPackets1_21_2.CONTAINER_CLICK); + registerSetCreativeModeSlot(ServerboundPackets1_21_2.SET_CREATIVE_MODE_SLOT); - new RecipeRewriter1_21_2<>(protocol).register1_20_5(ClientboundPackets1_21.UPDATE_RECIPES); + new RecipeRewriter1_21_2<>(protocol).register1_20_5(ClientboundPackets1_21_2.UPDATE_RECIPES); } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/template/EntityPacketRewriter1_99.java b/common/src/main/java/com/viaversion/viabackwards/protocol/template/EntityPacketRewriter1_99.java index 2ab161fb..94fc157b 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/template/EntityPacketRewriter1_99.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/template/EntityPacketRewriter1_99.java @@ -25,14 +25,14 @@ 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.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.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2; import com.viaversion.viaversion.util.Key; // Replace if needed // Types1_OLD // Types1_21 -final class EntityPacketRewriter1_99 extends EntityRewriter { +final class EntityPacketRewriter1_99 extends EntityRewriter { public EntityPacketRewriter1_99(final Protocol1_98To1_99 protocol) { super(protocol, Types1_20_5.ENTITY_DATA_TYPES.optionalComponentType, Types1_20_5.ENTITY_DATA_TYPES.booleanType); @@ -40,9 +40,9 @@ final class EntityPacketRewriter1_99 extends EntityRewriter { @@ -51,7 +51,7 @@ final class EntityPacketRewriter1_99 extends EntityRewriter { + protocol.registerClientbound(ClientboundPackets1_21_2.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 diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/template/Protocol1_98To1_99.java b/common/src/main/java/com/viaversion/viabackwards/protocol/template/Protocol1_98To1_99.java index f5cbb975..649021c7 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/template/Protocol1_98To1_99.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/template/Protocol1_98To1_99.java @@ -27,12 +27,12 @@ import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvide import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider; import com.viaversion.viaversion.data.entity.EntityTrackerBase; 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.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.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ServerboundPacket1_21_2; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ServerboundPackets1_21_2; import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -42,51 +42,51 @@ import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap; // Placeholders to replace (in the entire package): // Protocol1_98To1_99, EntityPacketRewriter1_99, BlockItemPacketRewriter1_99 // Protocol1_20_5To1_21 (the ViaVersion protocol class the mappings depend on) -// ClientboundPacket1_21 -// ServerboundPacket1_20_5 +// ClientboundPacket1_21_2 +// ServerboundPacket1_21_2 // ClientboundConfigurationPackets1_21 // ServerboundConfigurationPackets1_20_5 // EntityTypes1_20_5 (UNMAPPED type) // 1.99, 1.98 -final class Protocol1_98To1_99 extends BackwardsProtocol { +final class Protocol1_98To1_99 extends BackwardsProtocol { // ViaBackwards uses its own mappings and also needs a translatablerewriter for translation mappings public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.99", "1.98", Protocol1_20_5To1_21.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); - 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_98To1_99() { - super(ClientboundPacket1_21.class, ClientboundPacket1_21.class, ServerboundPacket1_20_5.class, ServerboundPacket1_20_5.class); + super(ClientboundPacket1_21_2.class, ClientboundPacket1_21_2.class, ServerboundPacket1_21_2.class, ServerboundPacket1_21_2.class); } @Override protected void registerPackets() { super.registerPackets(); - tagRewriter.registerGeneric(ClientboundPackets1_21.UPDATE_TAGS); + tagRewriter.registerGeneric(ClientboundPackets1_21_2.UPDATE_TAGS); tagRewriter.registerGeneric(ClientboundConfigurationPackets1_21.UPDATE_TAGS); - 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); + final SoundRewriter soundRewriter = new SoundRewriter<>(this); + soundRewriter.registerSound1_19_3(ClientboundPackets1_21_2.SOUND); + soundRewriter.registerSound1_19_3(ClientboundPackets1_21_2.SOUND_ENTITY); + soundRewriter.registerStopSound(ClientboundPackets1_21_2.STOP_SOUND); - new StatisticsRewriter<>(this).register(ClientboundPackets1_21.AWARD_STATS); - //new AttributeRewriter<>(this).register1_21(ClientboundPackets1_21.UPDATE_ATTRIBUTES); + new StatisticsRewriter<>(this).register(ClientboundPackets1_21_2.AWARD_STATS); + //new AttributeRewriter<>(this).register1_21(ClientboundPackets1_21_2.UPDATE_ATTRIBUTES); // Registers translatable mappings (missing a whole bunch still) - //translatableRewriter.registerOpenScreen(ClientboundPackets1_21.OPEN_SCREEN); // Handled by registerOpenScreen in item rewriters - 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.registerOpenScreen(ClientboundPackets1_21_2.OPEN_SCREEN); // Handled by registerOpenScreen in item rewriters + translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_ACTION_BAR_TEXT); + translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_TITLE_TEXT); + translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_SUBTITLE_TEXT); + translatableRewriter.registerBossEvent(ClientboundPackets1_21_2.BOSS_EVENT); + translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.DISCONNECT); + translatableRewriter.registerTabList(ClientboundPackets1_21_2.TAB_LIST); + translatableRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21_2.PLAYER_COMBAT_KILL); + translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SYSTEM_CHAT); + translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.DISGUISED_CHAT); translatableRewriter.registerPing(); } @@ -111,22 +111,22 @@ final class Protocol1_98To1_99 extends BackwardsProtocol getComponentRewriter() { + public TranslatableRewriter getComponentRewriter() { return translatableRewriter; } @Override - public TagRewriter getTagRewriter() { + public TagRewriter getTagRewriter() { return tagRewriter; } @Override - protected PacketTypesProvider createPacketTypesProvider() { + protected PacketTypesProvider createPacketTypesProvider() { return new SimplePacketTypesProvider<>( - packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_21.class, ClientboundConfigurationPackets1_21.class), - packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_21.class, ClientboundConfigurationPackets1_21.class), - packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class), - packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class) + packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_21_2.class, ClientboundConfigurationPackets1_21.class), + packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_21_2.class, ClientboundConfigurationPackets1_21.class), + packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_21_2.class, ServerboundConfigurationPackets1_20_5.class), + packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_21_2.class, ServerboundConfigurationPackets1_20_5.class) ); } } 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 ad93a2d9..3d0c5a64 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 @@ -50,6 +50,7 @@ import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPac import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter.StructuredDataConverter; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.util.Key; +import java.util.function.Function; import org.checkerframework.checker.nullness.qual.Nullable; public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItemRewriter { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java index 8ab65028..856bc3f0 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java @@ -35,6 +35,7 @@ import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPac import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_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.protocols.v1_21to1_21_2.Protocol1_21To1_21_2; import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2; import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2; @@ -138,7 +139,7 @@ public final class Protocol1_21_2To1_21 extends BackwardsProtocol createPacketTypesProvider() { return new SimplePacketTypesProvider<>( packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_21_2.class, ClientboundConfigurationPackets1_21.class), - packetTypeMap(mappedClientboundPacketType, ClientboundPacket1_21.class, ClientboundConfigurationPackets1_21.class), + packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_21.class, ClientboundConfigurationPackets1_21.class), packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_21_2.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_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java index 2dd45bc6..15eab7c6 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java @@ -19,7 +19,9 @@ package com.viaversion.viabackwards.protocol.v1_21_2to1_21.rewriter; import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter; import com.viaversion.viabackwards.protocol.v1_21_2to1_21.Protocol1_21_2To1_21; +import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.InventoryStateIdStorage; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.data.MappingData; import com.viaversion.viaversion.api.minecraft.HolderSet; import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.item.Item; @@ -61,13 +63,31 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem blockRewriter.registerLevelChunk1_19(ClientboundPackets1_21_2.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_20_2::new); blockRewriter.registerBlockEntityData(ClientboundPackets1_21_2.BLOCK_ENTITY_DATA); - registerCooldown(ClientboundPackets1_21_2.COOLDOWN); registerAdvancements1_20_3(ClientboundPackets1_21_2.UPDATE_ADVANCEMENTS); registerSetEquipment(ClientboundPackets1_21_2.SET_EQUIPMENT); registerMerchantOffers1_20_5(ClientboundPackets1_21_2.MERCHANT_OFFERS); registerSetCreativeModeSlot(ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT); registerLevelParticles1_20_5(ClientboundPackets1_21_2.LEVEL_PARTICLES); - registerExplosion1_21_2(ClientboundPackets1_21_2.EXPLODE); + + protocol.registerClientbound(ClientboundPackets1_21_2.COOLDOWN, wrapper -> { + final MappingData mappingData = protocol.getMappingData(); + final String itemIdentifier = wrapper.read(Types.STRING); + final int id = mappingData.getFullItemMappings().id(itemIdentifier); + if (id != -1) { + final int mappedId = mappingData.getFullItemMappings().getNewId(id); + wrapper.write(Types.VAR_INT, mappedId); + } else { + wrapper.cancel(); + } + }); + + protocol.registerClientbound(ClientboundPackets1_21_2.SET_CURSOR_ITEM, ClientboundPackets1_21.CONTAINER_SET_SLOT, wrapper -> { + wrapper.write(Types.BYTE, (byte) -1); // Player inventory + wrapper.write(Types.VAR_INT, wrapper.user().get(InventoryStateIdStorage.class).stateId()); // State id; re-use the last known one + wrapper.write(Types.SHORT, (short) -1); // Cursor + final Item item = wrapper.passthrough(Types1_21_2.ITEM); + handleItemToClient(wrapper.user(), item); + }); protocol.registerClientbound(ClientboundPackets1_21_2.CONTAINER_SET_CONTENT, wrapper -> { updateContainerId(wrapper); @@ -106,6 +126,17 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem passthroughServerboundItem(wrapper); }); + protocol.registerServerbound(ServerboundPackets1_20_5.USE_ITEM_ON, wrapper -> { + wrapper.passthrough(Types.VAR_INT); // Hand + wrapper.passthrough(Types.BLOCK_POSITION1_14); // Block position + wrapper.passthrough(Types.VAR_INT); // Direction + wrapper.passthrough(Types.FLOAT); // X + wrapper.passthrough(Types.FLOAT); // Y + wrapper.passthrough(Types.FLOAT); // Z + wrapper.passthrough(Types.BOOLEAN); // Inside + wrapper.write(Types.BOOLEAN, false); // World border hit + }); + protocol.registerClientbound(ClientboundPackets1_21_2.SET_PLAYER_INVENTORY, ClientboundPackets1_21.CONTAINER_SET_SLOT, wrapper -> { wrapper.write(Types.BYTE, (byte) -2); // Player inventory wrapper.write(Types.VAR_INT, 0); // 0 state id diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/EntityPacketRewriter1_21_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/EntityPacketRewriter1_21_2.java index bce3eb0f..e82a71c9 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/EntityPacketRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/EntityPacketRewriter1_21_2.java @@ -32,6 +32,7 @@ import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfi import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2; import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2; import com.viaversion.viaversion.util.Key; +import java.util.BitSet; import static com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.EntityPacketRewriter1_21_2.updateEnchantmentAttributes; @@ -119,6 +120,46 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter { + final BitSet actions = wrapper.passthrough(Types.PROFILE_ACTIONS_ENUM); + final int entries = wrapper.passthrough(Types.VAR_INT); + for (int i = 0; i < entries; i++) { + wrapper.passthrough(Types.UUID); + if (actions.get(0)) { + wrapper.passthrough(Types.STRING); // Player Name + + final int properties = wrapper.passthrough(Types.VAR_INT); + for (int j = 0; j < properties; j++) { + wrapper.passthrough(Types.STRING); // Name + wrapper.passthrough(Types.STRING); // Value + wrapper.passthrough(Types.OPTIONAL_STRING); // Signature + } + } + if (actions.get(1) && wrapper.passthrough(Types.BOOLEAN)) { + wrapper.passthrough(Types.UUID); // Session UUID + wrapper.passthrough(Types.PROFILE_KEY); + } + if (actions.get(2)) { + wrapper.passthrough(Types.VAR_INT); // Gamemode + } + if (actions.get(3)) { + wrapper.passthrough(Types.BOOLEAN); // Listed + } + if (actions.get(4)) { + wrapper.passthrough(Types.VAR_INT); // Latency + } + if (actions.get(5)) { + wrapper.passthrough(Types.TAG); // Display name + } + + // New one + if (actions.get(6)) { + actions.clear(6); + wrapper.read(Types.VAR_INT); // List order + } + } + }); } private void fixOnGround(final PacketWrapper wrapper) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/storage/InventoryStateIdStorage.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/storage/InventoryStateIdStorage.java new file mode 100644 index 00000000..0f6064fa --- /dev/null +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/storage/InventoryStateIdStorage.java @@ -0,0 +1,33 @@ +/* + * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards + * Copyright (C) 2016-2024 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.v1_21_2to1_21.storage; + +import com.viaversion.viaversion.api.connection.StorableObject; + +public final class InventoryStateIdStorage implements StorableObject { + + private int stateId = -1; + + public int stateId() { + return stateId; + } + + public void setStateId(final int stateId) { + this.stateId = stateId; + } +} diff --git a/common/src/main/resources/assets/viabackwards/data/mappings-1.21.2to1.21.nbt b/common/src/main/resources/assets/viabackwards/data/mappings-1.21.2to1.21.nbt index 1e876217..fbb9c28b 100644 Binary files a/common/src/main/resources/assets/viabackwards/data/mappings-1.21.2to1.21.nbt and b/common/src/main/resources/assets/viabackwards/data/mappings-1.21.2to1.21.nbt differ 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 d0e0c23f..2537fbfc 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,41 @@ { + "1.21.2": { + "attribute.name.tempt_range": "Mob Tempt Range", + "commands.schedule.macro": "Can't schedule a macro", + "commands.setidletimeout.success.disabled": "The player idle timeout is now disabled", + "dataPack.minecart_improvements.description": "Improved movement for Minecarts", + "dataPack.minecart_improvements.name": "Minecart Improvements", + "dataPack.redstone_experiments.description": "Experimental Redstone changes", + "dataPack.redstone_experiments.name": "Redstone Experiments", + "death.attack.mace_smash": "%1$s was smashed by %2$s", + "death.attack.mace_smash.item": "%1$s was smashed by %2$s with %3$s", + "gamerule.minecartMaxSpeed": "Minecart max speed", + "gamerule.minecartMaxSpeed.description": "Maximum default speed of a moving Minecart on land", + "gui.abuseReport.name.comment_box_label": "Please describe why you want to report this name:", + "gui.abuseReport.reason.sexually_inappropriate": "Sexually inappropriate", + "gui.abuseReport.reason.sexually_inappropriate.description": "Skins that are graphic in nature relating to sexual acts, sexual organs, and sexual violence.", + "item.minecraft.bordure_indented_banner_pattern": "Bordure Indented Banner Pattern", + "item.minecraft.bundle.empty.description": "Can hold a mixed stack of items", + "item.minecraft.bundle.full": "Full", + "item.minecraft.creeper_banner_pattern.new": "Creeper Charge Banner Pattern", + "item.minecraft.field_masoned_banner_pattern": "Field Masoned Banner Pattern", + "item.minecraft.flow_banner_pattern.new": "Flow Banner Pattern", + "item.minecraft.flower_banner_pattern.new": "Flower Charge Banner Pattern", + "item.minecraft.globe_banner_pattern.new": "Globe Banner Pattern", + "item.minecraft.guster_banner_pattern.new": "Guster Banner Pattern", + "item.minecraft.mojang_banner_pattern.new": "Thing Banner Pattern", + "item.minecraft.piglin_banner_pattern.new": "Snout Banner Pattern", + "item.minecraft.skull_banner_pattern.new": "Skull Charge Banner Pattern", + "optimizeWorld.confirm.proceed": "Create Backup and Optimize", + "options.inactivityFpsLimit": "Reduce FPS when", + "options.inactivityFpsLimit.afk": "AFK", + "options.inactivityFpsLimit.afk.tooltip": "Limits framerate to 30 when the game is not getting any player input for more than a minute. Further limits it to 10 after 9 more minutes.", + "options.inactivityFpsLimit.minimized": "Minimized", + "options.inactivityFpsLimit.minimized.tooltip": "Limits framerate only when the game window is minimized.", + "options.rotateWithMinecart": "Rotate with Minecarts", + "options.rotateWithMinecart.tooltip": "If the player's view should rotate with a turning Minecart. Only available in worlds with the 'Minecart Improvements' experimental setting turned on.", + "subtitles.item.bundle.insert_fail": "Bundle full" + }, "1.21": { "argument.entity.selector.nearestEntity": "Nearest entity", "attribute.name.generic.burning_time": "Burning Time", @@ -4691,4 +4728,4 @@ "entity.MinecartChest.name": "Minecart with Chest", "attribute.name.generic.armorToughness": "Armor Toughness" } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index c00f23c5..a9e4f680 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ projectVersion=5.1.0-SNAPSHOT # Smile emoji -mcVersions=1.21.1,1.21,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 -mcVersionRange=1.10-1.21.1 +mcVersions=1.21.2,1.21.1,1.21,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 +mcVersionRange=1.10-1.21.2 velocityVersion=3.3