24w21b, mostly

This commit is contained in:
Nassim Jahnke 2024-05-22 18:56:43 +02:00
parent 1a24ce6d87
commit 6f8da18f65
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
12 changed files with 231 additions and 72 deletions

View File

@ -55,7 +55,7 @@ public class BackwardsMappingData extends MappingDataBase {
public BackwardsMappingData(final String unmappedVersion, final String mappedVersion, @Nullable final Class<? extends Protocol<?, ?, ?, ?>> vvProtocolClass) { public BackwardsMappingData(final String unmappedVersion, final String mappedVersion, @Nullable final Class<? extends Protocol<?, ?, ?, ?>> vvProtocolClass) {
super(unmappedVersion, mappedVersion); super(unmappedVersion, mappedVersion);
Preconditions.checkArgument(vvProtocolClass == null || !vvProtocolClass.isAssignableFrom(BackwardsProtocol.class)); Preconditions.checkArgument(vvProtocolClass == null || !BackwardsProtocol.class.isAssignableFrom(vvProtocolClass));
this.vvProtocolClass = vvProtocolClass; this.vvProtocolClass = vvProtocolClass;
} }

View File

@ -17,14 +17,14 @@
*/ */
package com.viaversion.viabackwards.api.rewriters; 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.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader; import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject; 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 com.viaversion.viaversion.rewriter.ComponentRewriter;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -56,11 +56,11 @@ public class TranslatableRewriter<C extends ClientboundPacketType> extends Compo
this(protocol, type, protocol.getClass().getSimpleName().replace("Protocol", "").split("To")[0].replace("_", ".")); this(protocol, type, protocol.getClass().getSimpleName().replace("Protocol", "").split("To")[0].replace("_", "."));
} }
public TranslatableRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type, final String sectionIdentifier) { public TranslatableRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type, final String version) {
super(protocol, type); super(protocol, type);
final Map<String, String> translatableMappings = getTranslatableMappings(sectionIdentifier); final Map<String, String> translatableMappings = getTranslatableMappings(version);
if (translatableMappings == null) { if (translatableMappings == null) {
protocol.getLogger().warning("Missing " + sectionIdentifier + " translatables!"); protocol.getLogger().warning("Missing " + version + " translatables!");
this.translatables = new HashMap<>(); this.translatables = new HashMap<>();
} else { } else {
this.translatables = translatableMappings; this.translatables = translatableMappings;

View File

@ -360,8 +360,8 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem
// Convert to structured item first // Convert to structured item first
final Item structuredItem = vvProtocol.getItemRewriter().toStructuredItem(connection, item); final Item structuredItem = vvProtocol.getItemRewriter().toStructuredItem(connection, item);
item.structuredData().setIdLookup(protocol, false); structuredItem.structuredData().setIdLookup(protocol, false);
enchantmentRewriter.handleToServer(item); enchantmentRewriter.handleToServer(structuredItem);
return super.handleItemToServer(connection, structuredItem); return super.handleItemToServer(connection, structuredItem);
} }

View File

@ -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.minecraft.entities.EntityTypes1_20_5;
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider; import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider; 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.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.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.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.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.ServerboundPacket1_20_5;
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_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.ComponentRewriter.ReadType;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap; import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
public final class Protocol1_21To1_20_5 extends BackwardsProtocol<ClientboundPacket1_20_5, ClientboundPacket1_20_5, ServerboundPacket1_20_5, ServerboundPacket1_20_5> { public final class Protocol1_21To1_20_5 extends BackwardsProtocol<ClientboundPacket1_21, ClientboundPacket1_20_5, ServerboundPacket1_20_5, ServerboundPacket1_20_5> {
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 EntityPacketRewriter1_21 entityRewriter = new EntityPacketRewriter1_21(this);
private final BlockItemPacketRewriter1_21 itemRewriter = new BlockItemPacketRewriter1_21(this); private final BlockItemPacketRewriter1_21 itemRewriter = new BlockItemPacketRewriter1_21(this);
private final TranslatableRewriter<ClientboundPacket1_20_5> translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); private final TranslatableRewriter<ClientboundPacket1_21> translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT);
private final TagRewriter<ClientboundPacket1_20_5> tagRewriter = new TagRewriter<>(this); private final TagRewriter<ClientboundPacket1_21> tagRewriter = new TagRewriter<>(this);
public Protocol1_21To1_20_5() { 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 @Override
protected void registerPackets() { protected void registerPackets() {
super.registerPackets(); super.registerPackets();
tagRewriter.registerGeneric(ClientboundPackets1_20_5.UPDATE_TAGS); tagRewriter.registerGeneric(ClientboundPackets1_21.UPDATE_TAGS);
tagRewriter.registerGeneric(ClientboundConfigurationPackets1_20_5.UPDATE_TAGS); tagRewriter.registerGeneric(ClientboundConfigurationPackets1_21.UPDATE_TAGS);
final SoundRewriter<ClientboundPacket1_20_5> soundRewriter = new SoundRewriter<>(this); final SoundRewriter<ClientboundPacket1_21> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerSound1_19_3(ClientboundPackets1_20_5.SOUND); soundRewriter.registerSound1_19_3(ClientboundPackets1_21.SOUND);
soundRewriter.registerSound1_19_3(ClientboundPackets1_20_5.SOUND_ENTITY); soundRewriter.registerSound1_19_3(ClientboundPackets1_21.SOUND_ENTITY);
soundRewriter.registerStopSound(ClientboundPackets1_20_5.STOP_SOUND); soundRewriter.registerStopSound(ClientboundPackets1_21.STOP_SOUND);
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_5.AWARD_STATS); new StatisticsRewriter<>(this).register(ClientboundPackets1_21.AWARD_STATS);
new AttributeRewriter<>(this).register1_20_5(ClientboundPackets1_20_5.UPDATE_ATTRIBUTES);
translatableRewriter.registerOpenScreen(ClientboundPackets1_20_5.OPEN_SCREEN); translatableRewriter.registerOpenScreen(ClientboundPackets1_21.OPEN_SCREEN);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_ACTION_BAR_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SET_ACTION_BAR_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_TITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SET_TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_SUBTITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SET_SUBTITLE_TEXT);
translatableRewriter.registerBossEvent(ClientboundPackets1_20_5.BOSS_EVENT); translatableRewriter.registerBossEvent(ClientboundPackets1_21.BOSS_EVENT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_21.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_20_5.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_21.TAB_LIST);
translatableRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_20_5.PLAYER_COMBAT_KILL); translatableRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21.PLAYER_COMBAT_KILL);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SYSTEM_CHAT); translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SYSTEM_CHAT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.DISGUISED_CHAT); translatableRewriter.registerComponentPacket(ClientboundPackets1_21.DISGUISED_CHAT);
translatableRewriter.registerPing(); translatableRewriter.registerPing();
// Format change we can't properly map - all this really results in is a desync one version earlier // 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 @Override
@ -107,19 +152,19 @@ public final class Protocol1_21To1_20_5 extends BackwardsProtocol<ClientboundPac
} }
@Override @Override
public TranslatableRewriter<ClientboundPacket1_20_5> getTranslatableRewriter() { public TranslatableRewriter<ClientboundPacket1_21> getTranslatableRewriter() {
return translatableRewriter; return translatableRewriter;
} }
@Override @Override
public TagRewriter<ClientboundPacket1_20_5> getTagRewriter() { public TagRewriter<ClientboundPacket1_21> getTagRewriter() {
return tagRewriter; return tagRewriter;
} }
@Override @Override
protected PacketTypesProvider<ClientboundPacket1_20_5, ClientboundPacket1_20_5, ServerboundPacket1_20_5, ServerboundPacket1_20_5> createPacketTypesProvider() { protected PacketTypesProvider<ClientboundPacket1_21, ClientboundPacket1_20_5, ServerboundPacket1_20_5, ServerboundPacket1_20_5> createPacketTypesProvider() {
return new SimplePacketTypesProvider<>( 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(mappedClientboundPacketType, ClientboundPackets1_20_5.class, ClientboundConfigurationPackets1_20_5.class),
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class), packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class),
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class) packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class)

View File

@ -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.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_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.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.ServerboundPacket1_20_5;
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_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.BlockRewriter;
import com.viaversion.viaversion.rewriter.IdRewriteFunction; import com.viaversion.viaversion.rewriter.IdRewriteFunction;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRewriter<ClientboundPacket1_20_5, ServerboundPacket1_20_5, Protocol1_21To1_20_5> { 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<ClientboundPacket1_21, ServerboundPacket1_20_5, Protocol1_21To1_20_5> {
private final StructuredEnchantmentRewriter enchantmentRewriter = new StructuredEnchantmentRewriter(this); private final StructuredEnchantmentRewriter enchantmentRewriter = new StructuredEnchantmentRewriter(this);
@ -59,25 +62,25 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
@Override @Override
public void registerPackets() { public void registerPackets() {
final BlockRewriter<ClientboundPacket1_20_5> blockRewriter = BlockRewriter.for1_20_2(protocol); final BlockRewriter<ClientboundPacket1_21> blockRewriter = BlockRewriter.for1_20_2(protocol);
blockRewriter.registerBlockEvent(ClientboundPackets1_20_5.BLOCK_EVENT); blockRewriter.registerBlockEvent(ClientboundPackets1_21.BLOCK_EVENT);
blockRewriter.registerBlockUpdate(ClientboundPackets1_20_5.BLOCK_UPDATE); blockRewriter.registerBlockUpdate(ClientboundPackets1_21.BLOCK_UPDATE);
blockRewriter.registerSectionBlocksUpdate1_20(ClientboundPackets1_20_5.SECTION_BLOCKS_UPDATE); blockRewriter.registerSectionBlocksUpdate1_20(ClientboundPackets1_21.SECTION_BLOCKS_UPDATE);
blockRewriter.registerLevelEvent(ClientboundPackets1_20_5.LEVEL_EVENT, 1010, 2001); blockRewriter.registerLevelEvent(ClientboundPackets1_21.LEVEL_EVENT, 1010, 2001);
blockRewriter.registerLevelChunk1_19(ClientboundPackets1_20_5.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_20_2::new); blockRewriter.registerLevelChunk1_19(ClientboundPackets1_21.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_20_2::new);
blockRewriter.registerBlockEntityData(ClientboundPackets1_20_5.BLOCK_ENTITY_DATA); blockRewriter.registerBlockEntityData(ClientboundPackets1_21.BLOCK_ENTITY_DATA);
registerCooldown(ClientboundPackets1_20_5.COOLDOWN); registerCooldown(ClientboundPackets1_21.COOLDOWN);
registerSetContent1_17_1(ClientboundPackets1_20_5.CONTAINER_SET_CONTENT); registerSetContent1_17_1(ClientboundPackets1_21.CONTAINER_SET_CONTENT);
registerSetSlot1_17_1(ClientboundPackets1_20_5.CONTAINER_SET_SLOT); registerSetSlot1_17_1(ClientboundPackets1_21.CONTAINER_SET_SLOT);
registerAdvancements1_20_3(ClientboundPackets1_20_5.UPDATE_ADVANCEMENTS); registerAdvancements1_20_3(ClientboundPackets1_21.UPDATE_ADVANCEMENTS);
registerSetEquipment(ClientboundPackets1_20_5.SET_EQUIPMENT); registerSetEquipment(ClientboundPackets1_21.SET_EQUIPMENT);
registerContainerClick1_17_1(ServerboundPackets1_20_5.CONTAINER_CLICK); 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); registerSetCreativeModeSlot(ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT);
registerContainerSetData(ClientboundPackets1_20_5.CONTAINER_SET_DATA); registerContainerSetData(ClientboundPackets1_21.CONTAINER_SET_DATA);
registerLevelParticles1_20_5(ClientboundPackets1_20_5.LEVEL_PARTICLES, Types1_21.PARTICLE, Types1_20_5.PARTICLE); registerLevelParticles1_20_5(ClientboundPackets1_21.LEVEL_PARTICLES, Types1_21.PARTICLE, Types1_20_5.PARTICLE);
registerExplosion(ClientboundPackets1_20_5.EXPLODE, 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 -> { protocol.registerServerbound(ServerboundPackets1_20_5.USE_ITEM, wrapper -> {
wrapper.passthrough(Types.VAR_INT); // Hand wrapper.passthrough(Types.VAR_INT); // Hand
@ -86,7 +89,7 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
wrapper.write(Types.FLOAT, 0f); // X rotation 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 @Override
@ -117,6 +120,8 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
enchantmentRewriter.rewriteEnchantmentsToClient(data, StructuredDataKey.ENCHANTMENTS, idRewriteFunction, descriptionSupplier, false); enchantmentRewriter.rewriteEnchantmentsToClient(data, StructuredDataKey.ENCHANTMENTS, idRewriteFunction, descriptionSupplier, false);
enchantmentRewriter.rewriteEnchantmentsToClient(data, StructuredDataKey.STORED_ENCHANTMENTS, idRewriteFunction, descriptionSupplier, true); enchantmentRewriter.rewriteEnchantmentsToClient(data, StructuredDataKey.STORED_ENCHANTMENTS, idRewriteFunction, descriptionSupplier, true);
downgradeItemData(item);
return super.handleItemToClient(connection, item); return super.handleItemToClient(connection, item);
} }
@ -137,6 +142,8 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
// Restore originals if present // Restore originals if present
enchantmentRewriter.handleToServer(item); enchantmentRewriter.handleToServer(item);
updateItemData(item);
return super.handleItemToServer(connection, item); return super.handleItemToServer(connection, item);
} }

View File

@ -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;
import com.viaversion.viaversion.api.type.types.version.Types1_20_5; 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.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.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.Key;
import com.viaversion.viaversion.util.KeyMappings; import com.viaversion.viaversion.util.KeyMappings;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPacket1_20_5, Protocol1_21To1_20_5> { public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPacket1_21, Protocol1_21To1_20_5> {
private final Map<String, PaintingData> oldPaintings = new HashMap<>(); private final Map<String, PaintingData> oldPaintings = new HashMap<>();
@ -57,12 +57,17 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
@Override @Override
public void registerPackets() { public void registerPackets() {
registerTrackerWithData1_19(ClientboundPackets1_20_5.ADD_ENTITY, EntityTypes1_20_5.FALLING_BLOCK); registerTrackerWithData1_19(ClientboundPackets1_21.ADD_ENTITY, EntityTypes1_20_5.FALLING_BLOCK);
registerSetEntityData(ClientboundPackets1_20_5.SET_ENTITY_DATA, Types1_21.ENTITY_DATA_LIST, Types1_20_5.ENTITY_DATA_LIST); registerSetEntityData(ClientboundPackets1_21.SET_ENTITY_DATA, Types1_21.ENTITY_DATA_LIST, Types1_20_5.ENTITY_DATA_LIST);
registerRemoveEntities(ClientboundPackets1_20_5.REMOVE_ENTITIES); registerRemoveEntities(ClientboundPackets1_21.REMOVE_ENTITIES);
protocol.registerClientbound(ClientboundConfigurationPackets1_20_5.REGISTRY_DATA, wrapper -> { protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, wrapper -> {
final String key = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING)); 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 RegistryEntry[] entries = wrapper.passthrough(Types.REGISTRY_ENTRY_ARRAY);
final boolean paintingVariant = key.equals("painting_variant"); final boolean paintingVariant = key.equals("painting_variant");
if (paintingVariant || key.equals("enchantment")) { if (paintingVariant || key.equals("enchantment")) {
@ -92,7 +97,7 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
} }
}); });
protocol.registerClientbound(ClientboundPackets1_20_5.LOGIN, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_21.LOGIN, new PacketHandlers() {
@Override @Override
public void register() { public void register() {
map(Types.INT); // Entity id map(Types.INT); // Entity id
@ -110,7 +115,7 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
} }
}); });
protocol.registerClientbound(ClientboundPackets1_20_5.RESPAWN, wrapper -> { protocol.registerClientbound(ClientboundPackets1_21.RESPAWN, wrapper -> {
final int dimensionId = wrapper.passthrough(Types.VAR_INT); final int dimensionId = wrapper.passthrough(Types.VAR_INT);
final String world = wrapper.passthrough(Types.STRING); 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 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<ClientboundPa
if (type == Types1_21.ENTITY_DATA_TYPES.wolfVariantType) { if (type == Types1_21.ENTITY_DATA_TYPES.wolfVariantType) {
final Holder<WolfVariant> variant = data.value(); final Holder<WolfVariant> variant = data.value();
if (variant.hasId()) { 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 { } else {
event.cancel(); event.cancel();
} }
@ -168,7 +173,6 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
data.setDataType(Types1_20_5.ENTITY_DATA_TYPES.byId(type.typeId())); data.setDataType(Types1_20_5.ENTITY_DATA_TYPES.byId(type.typeId()));
} }
}); });
filter().mapDataType(Types1_20_5.ENTITY_DATA_TYPES::byId);
registerMetaTypeHandler1_20_3( registerMetaTypeHandler1_20_3(
Types1_20_5.ENTITY_DATA_TYPES.itemType, Types1_20_5.ENTITY_DATA_TYPES.itemType,

View File

@ -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 <20>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<6F>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": { "1.20.5": {
"advancements.adventure.blowback.description": "Kill a Breeze with a deflected Breeze-shot Wind Charge", "advancements.adventure.blowback.description": "Kill a Breeze with a deflected Breeze-shot Wind Charge",
"advancements.adventure.blowback.title": "Blowback", "advancements.adventure.blowback.title": "Blowback",

View File

@ -1,4 +1,4 @@
projectVersion=5.0.0-24w20a-SNAPSHOT projectVersion=5.0.0-24w21b-SNAPSHOT
# Smile emoji # 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 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

View File

@ -3,7 +3,7 @@ metadata.format.version = "1.1"
[versions] [versions]
# ViaVersion # ViaVersion
viaver = "5.0.0-24w20a-SNAPSHOT" viaver = "5.0.0-24w21a-SNAPSHOT"
# Common provided # Common provided
netty = "4.0.20.Final" netty = "4.0.20.Final"

View File

@ -4,6 +4,7 @@ rootProject.name = "viabackwards-parent"
dependencyResolutionManagement { dependencyResolutionManagement {
repositories { repositories {
mavenLocal()
maven("https://repo.viaversion.com") maven("https://repo.viaversion.com")
maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.papermc.io/repository/maven-public/")
mavenCentral() mavenCentral()

View File

@ -76,7 +76,7 @@ public final class Protocol1_98To1_99 extends BackwardsProtocol<ClientboundPacke
soundRewriter.registerStopSound(ClientboundPackets1_20_5.STOP_SOUND); soundRewriter.registerStopSound(ClientboundPackets1_20_5.STOP_SOUND);
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_5.AWARD_STATS); new StatisticsRewriter<>(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) // Registers translatable mappings (missing a whole bunch still)
//translatableRewriter.registerOpenWindow(ClientboundPackets1_20_5.OPEN_WINDOW); // Handled by registerOpenWindow in item rewriters //translatableRewriter.registerOpenWindow(ClientboundPackets1_20_5.OPEN_WINDOW); // Handled by registerOpenWindow in item rewriters