This commit is contained in:
Nassim Jahnke 2024-05-10 16:52:44 +02:00
parent 263790e9f6
commit 218b2abe45
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
5 changed files with 15 additions and 8 deletions

View File

@ -81,6 +81,9 @@ public final class Protocol1_20_5To1_21 extends BackwardsProtocol<ClientboundPac
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SYSTEM_CHAT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.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);
}
@Override

View File

@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.item.data.Enchantments;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
import com.viaversion.viaversion.api.type.types.version.Types1_20;
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.libs.fastutil.ints.Int2IntMap;
@ -53,7 +54,7 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
private final StructuredEnchantmentRewriter enchantmentRewriter = new StructuredEnchantmentRewriter(this);
public BlockItemPacketRewriter1_21(final Protocol1_20_5To1_21 protocol) {
super(protocol, Types1_20_5.ITEM, Types1_20_5.ITEM_ARRAY, Types1_21.ITEM, Types1_21.ITEM_ARRAY);
super(protocol, Types1_21.ITEM, Types1_21.ITEM_ARRAY, Types1_20_5.ITEM, Types1_20_5.ITEM_ARRAY);
}
@Override
@ -72,11 +73,11 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
registerAdvancements1_20_3(ClientboundPackets1_20_5.ADVANCEMENTS);
registerEntityEquipmentArray(ClientboundPackets1_20_5.ENTITY_EQUIPMENT);
registerClickWindow1_17_1(ServerboundPackets1_20_5.CLICK_WINDOW);
registerTradeList1_20_5(ClientboundPackets1_20_5.TRADE_LIST, Types1_20_5.ITEM_COST, Types1_20_5.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_21.OPTIONAL_ITEM_COST);
registerTradeList1_20_5(ClientboundPackets1_20_5.TRADE_LIST, Types1_21.ITEM_COST, Types1_20_5.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_20_5.OPTIONAL_ITEM_COST);
registerCreativeInvAction(ServerboundPackets1_20_5.CREATIVE_INVENTORY_ACTION);
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_20_5.WINDOW_PROPERTY);
registerSpawnParticle1_20_5(ClientboundPackets1_20_5.SPAWN_PARTICLE, Types1_20_5.PARTICLE, Types1_21.PARTICLE);
registerExplosion(ClientboundPackets1_20_5.EXPLOSION, Types1_20_5.PARTICLE, Types1_21.PARTICLE);
registerSpawnParticle1_20_5(ClientboundPackets1_20_5.SPAWN_PARTICLE, Types1_21.PARTICLE, Types1_20_5.PARTICLE);
registerExplosion(ClientboundPackets1_20_5.EXPLOSION, Types1_21.PARTICLE, Types1_20_5.PARTICLE);
new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_20_5.DECLARE_RECIPES);
}
@ -85,11 +86,12 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
public @Nullable Item handleItemToClient(final UserConnection connection, @Nullable final Item item) {
if (item == null) return null;
item.structuredData().setIdLookup(protocol, true);
final StructuredDataContainer data = item.structuredData();
data.setIdLookup(protocol, true);
data.replaceKey(StructuredDataKey.FOOD1_21, StructuredDataKey.FOOD1_20_5);
// Enchantments
final EnchantmentsPaintingsStorage storage = connection.get(EnchantmentsPaintingsStorage.class);
final StructuredDataContainer data = item.structuredData();
final IdRewriteFunction idRewriteFunction = id -> {
final String key = storage.enchantments().idToKey(id);
return key != null ? Enchantments1_20_5.keyToId(key) : -1;
@ -118,6 +120,8 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
final StructuredDataContainer dataContainer = item.structuredData();
dataContainer.setIdLookup(protocol, false);
dataContainer.replaceKey(StructuredDataKey.FOOD1_20_5, StructuredDataKey.FOOD1_21);
// Rewrite enchantments
final EnchantmentsPaintingsStorage storage = connection.get(EnchantmentsPaintingsStorage.class);
rewriteEnchantmentToServer(storage, item, StructuredDataKey.ENCHANTMENTS);

View File

@ -1,4 +1,4 @@
projectVersion=5.0.0-24w18a-SNAPSHOT
projectVersion=5.0.0-24w19a-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

View File

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