Update VV usage

This commit is contained in:
Nassim Jahnke committed 2026-05-25 09:33:52 +02:00
1 parent c3f6271a0d
commit e651e1cef9
14 files changed
+21 -17

No files matched your search

@@ -80,7 +80,7 @@ import java.util.logging.Logger;
public interface ViaBackwardsPlatform { public interface ViaBackwardsPlatform {
String MINIMUM_VV_VERSION = "5.8.1"; String MINIMUM_VV_VERSION = "5.9.2";
default void init(final File configFile) { default void init(final File configFile) {
init(new ViaBackwardsConfig(configFile, getLogger())); init(new ViaBackwardsConfig(configFile, getLogger()));
@@ -80,7 +80,7 @@ final class Protocol99_1To98_1 extends BackwardsProtocol<ClientboundPacket26_1,
@Override @Override
public void init(final UserConnection connection) { public void init(final UserConnection connection) {
addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_11.PLAYER)); addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_11.PLAYER));
addItemHasher(connection, new ItemHasherBase(this, connection)); connection.addItemHasher(this.getClass(), new ItemHasherBase(this, connection));
} }
@Override @Override
@@ -240,7 +240,7 @@ public final class Protocol1_21_11To1_21_9 extends BackwardsProtocol<Clientbound
@Override @Override
public void init(final UserConnection connection) { public void init(final UserConnection connection) {
addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_11.PLAYER)); addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_11.PLAYER));
addItemHasher(connection, new ItemHasherBase(this, connection)); connection.addItemHasher(this.getClass(), new ItemHasherBase(this, connection));
connection.put(new GameTimeStorage()); connection.put(new GameTimeStorage());
} }
@@ -675,7 +675,10 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem
if (deathProtection != null) { if (deathProtection != null) {
final List<Consumable1_21_2.ConsumeEffect<?>> effects = new ArrayList<>(); final List<Consumable1_21_2.ConsumeEffect<?>> effects = new ArrayList<>();
for (int i = 0; i < deathProtection.size(); i++) { for (int i = 0; i < deathProtection.size(); i++) {
effects.add(convertConsumableEffect(deathProtection.get(i))); final Consumable1_21_2.ConsumeEffect<?> effect = convertConsumableEffect(deathProtection.get(i));
if (effect != null) {
effects.add(effect);
}
} }
data.set(StructuredDataKey.DEATH_PROTECTION, new DeathProtection(effects.toArray(Consumable1_21_2.ConsumeEffect[]::new))); data.set(StructuredDataKey.DEATH_PROTECTION, new DeathProtection(effects.toArray(Consumable1_21_2.ConsumeEffect[]::new)));
} }
@@ -178,7 +178,7 @@ public final class Protocol1_21_5To1_21_4 extends BackwardsProtocol<ClientboundP
@Override @Override
public void init(final UserConnection user) { public void init(final UserConnection user) {
addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_21_4.PLAYER)); addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_21_4.PLAYER));
user.put(new HashedItemConverterStorage(this)); user.put(new HashedItemConverterStorage(this, user));
} }
@Override @Override
@@ -161,7 +161,7 @@ public final class EntityPacketRewriter1_21_5 extends EntityRewriter<Clientbound
filter().dataType(mappedEntityDataTypes.frogVariantType).handler((event, data) -> { filter().dataType(mappedEntityDataTypes.frogVariantType).handler((event, data) -> {
final int value = data.value(); final int value = data.value();
final String variantKey = protocol.getRegistryDataRewriter().getMappings("frog_variant").idToKey(value); final String variantKey = tracker(event.user()).registryKeys("frog_variant").idToKey(value);
final int newValue = (variantKey == null) ? 0 : switch (variantKey) { final int newValue = (variantKey == null) ? 0 : switch (variantKey) {
case "cold" -> 2; case "cold" -> 2;
case "temperate" -> 0; case "temperate" -> 0;
@@ -172,7 +172,7 @@ public final class EntityPacketRewriter1_21_5 extends EntityRewriter<Clientbound
}); });
filter().dataType(mappedEntityDataTypes.catVariantType).handler((event, data) -> { filter().dataType(mappedEntityDataTypes.catVariantType).handler((event, data) -> {
final int value = data.value(); final int value = data.value();
final String variantKey = protocol.getRegistryDataRewriter().getMappings("cat_variant").idToKey(value); final String variantKey = tracker(event.user()).registryKeys("cat_variant").idToKey(value);
final int newValue = (variantKey == null) ? 1 : switch (variantKey) { final int newValue = (variantKey == null) ? 1 : switch (variantKey) {
case "all_black" -> 10; case "all_black" -> 10;
case "black" -> 1; case "black" -> 1;
@@ -18,6 +18,7 @@
package com.viaversion.viabackwards.protocol.v1_21_5to1_21_4.storage; package com.viaversion.viabackwards.protocol.v1_21_5to1_21_4.storage;
import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.codec.CodecContext; import com.viaversion.viaversion.api.minecraft.codec.CodecContext;
import com.viaversion.viaversion.api.minecraft.codec.CodecContext.RegistryAccess; import com.viaversion.viaversion.api.minecraft.codec.CodecContext.RegistryAccess;
import com.viaversion.viaversion.api.minecraft.codec.hash.Hasher; import com.viaversion.viaversion.api.minecraft.codec.hash.Hasher;
@@ -30,8 +31,8 @@ public class HashedItemConverterStorage implements StorableObject {
private final Hasher hasher; private final Hasher hasher;
public HashedItemConverterStorage(final Protocol<?, ?, ?, ?> protocol) { public HashedItemConverterStorage(final Protocol<?, ?, ?, ?> protocol, final UserConnection connection) {
final RegistryAccess registryAccess = RegistryAccess.of(protocol); final RegistryAccess registryAccess = RegistryAccess.of(protocol, connection);
final CodecContext context = new CodecRegistryContext(protocol, registryAccess, false); final CodecContext context = new CodecRegistryContext(protocol, registryAccess, false);
this.hasher = new HashOps(context, HashFunction.CRC32C); this.hasher = new HashOps(context, HashFunction.CRC32C);
} }
@@ -307,7 +307,7 @@ public final class Protocol1_21_6To1_21_5 extends BackwardsProtocol<ClientboundP
@Override @Override
public void init(final UserConnection user) { public void init(final UserConnection user) {
addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_21_6.PLAYER)); addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_21_6.PLAYER));
addItemHasher(user, new ItemHasherBase(this, user)); user.addItemHasher(this.getClass(), new ItemHasherBase(this, user));
user.put(new RegistryAndTags()); user.put(new RegistryAndTags());
user.put(new ClickEvents()); user.put(new ClickEvents());
} }
@@ -68,7 +68,7 @@ public final class Protocol1_21_7To1_21_6 extends BackwardsProtocol<ClientboundP
@Override @Override
public void init(final UserConnection connection) { public void init(final UserConnection connection) {
addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_6.PLAYER)); addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_6.PLAYER));
addItemHasher(connection, new ItemHasherBase(this, connection)); connection.addItemHasher(this.getClass(), new ItemHasherBase(this, connection));
} }
@Override @Override
@@ -193,7 +193,7 @@ public final class Protocol1_21_9To1_21_7 extends BackwardsProtocol<ClientboundP
@Override @Override
public void init(final UserConnection connection) { public void init(final UserConnection connection) {
addEntityTracker(connection, new EntityTracker1_21_9(connection, EntityTypes1_21_9.PLAYER)); addEntityTracker(connection, new EntityTracker1_21_9(connection, EntityTypes1_21_9.PLAYER));
addItemHasher(connection, new ItemHasherBase(this, connection)); connection.addItemHasher(this.getClass(), new ItemHasherBase(this, connection));
connection.put(new PlayerRotationStorage()); connection.put(new PlayerRotationStorage());
connection.put(new DimensionScaleStorage()); connection.put(new DimensionScaleStorage());
connection.put(new BundleStateTracker()); connection.put(new BundleStateTracker());
@@ -130,7 +130,7 @@ public final class Protocol26_1To1_21_11 extends BackwardsProtocol<ClientboundPa
final long totalTicks = wrapper.read(Types.VAR_LONG); final long totalTicks = wrapper.read(Types.VAR_LONG);
wrapper.read(Types.FLOAT); // Partial tick wrapper.read(Types.FLOAT); // Partial tick
final float tickRate = wrapper.read(Types.FLOAT); final float tickRate = wrapper.read(Types.FLOAT);
if (Key.equals(registryDataRewriter.getMappings("world_clock").idToKey(clockType), "overworld")) { if (Key.equals(entityRewriter.tracker(wrapper.user()).registryKeys("world_clock").idToKey(clockType), "overworld")) {
dayTime = totalTicks; dayTime = totalTicks;
advanceTime = tickRate != 0; advanceTime = tickRate != 0;
} }
@@ -169,7 +169,7 @@ public final class Protocol26_1To1_21_11 extends BackwardsProtocol<ClientboundPa
@Override @Override
public void init(final UserConnection connection) { public void init(final UserConnection connection) {
addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_11.PLAYER)); addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_11.PLAYER));
addItemHasher(connection, new ItemHasherBase(this, connection)); connection.addItemHasher(this.getClass(), new ItemHasherBase(this, connection));
connection.put(new DayTimeStorage()); connection.put(new DayTimeStorage());
connection.put(new GameModeStorage()); connection.put(new GameModeStorage());
} }
@@ -45,7 +45,7 @@ public final class BlockItemPacketRewriter26_1 extends BackwardsStructuredItemRe
@Override @Override
protected void handleItemDataComponentsToServer(final UserConnection connection, final Item item, final StructuredDataContainer container) { protected void handleItemDataComponentsToServer(final UserConnection connection, final Item item, final StructuredDataContainer container) {
super.handleItemDataComponentsToServer(connection, item, container); super.handleItemDataComponentsToServer(connection, item, container);
upgradeData(protocol, protocol.types().structuredDataKeys(), container); upgradeData(protocol, connection, protocol.types().structuredDataKeys(), container);
} }
@Override @Override
+1 -1
View File
@@ -3,7 +3,7 @@ metadata.format.version = "1.1"
[versions] [versions]
# ViaVersion # ViaVersion
viaver = "5.9.1" viaver = "5.9.2-SNAPSHOT"
# Common provided # Common provided
netty = "4.0.20.Final" netty = "4.0.20.Final"
@@ -47,7 +47,7 @@
}, },
{ {
"id": "viaversion", "id": "viaversion",
"version": "[5.8.1-SNAPSHOT,)" "version": "[5.9.2-SNAPSHOT,)"
} }
] ]
}, },