Update Via API usage

Question to EntityPacketRewriter1_16_2: is it intended that the LOGIN handler doesn't copy the written dimensions tag or was that just forgotten?
This commit is contained in:
FlorianMichael 2024-05-12 17:49:15 +02:00 committed by Nassim Jahnke
parent a946632e8b
commit c27f720316
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
7 changed files with 17 additions and 17 deletions

View File

@ -24,6 +24,7 @@ import java.net.URL;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger;
public class ViaBackwardsConfig extends Config implements com.viaversion.viabackwards.api.ViaBackwardsConfig { public class ViaBackwardsConfig extends Config implements com.viaversion.viabackwards.api.ViaBackwardsConfig {
@ -34,8 +35,8 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
private boolean fix1_13FormattedInventoryTitles; private boolean fix1_13FormattedInventoryTitles;
private boolean handlePingsAsInvAcknowledgements; private boolean handlePingsAsInvAcknowledgements;
public ViaBackwardsConfig(File configFile) { public ViaBackwardsConfig(File configFile, Logger logger) {
super(configFile); super(configFile, logger);
} }
@Override @Override

View File

@ -74,7 +74,7 @@ public interface ViaBackwardsPlatform {
* Initialize ViaBackwards. * Initialize ViaBackwards.
*/ */
default void init(final File configFile) { default void init(final File configFile) {
ViaBackwardsConfig config = new ViaBackwardsConfig(configFile); ViaBackwardsConfig config = new ViaBackwardsConfig(configFile, getLogger());
config.reload(); config.reload();
Via.getManager().getConfigurationProvider().register(config); Via.getManager().getConfigurationProvider().register(config);

View File

@ -33,12 +33,11 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.DataItem;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.StringTag; import com.viaversion.nbt.tag.StringTag;
import com.viaversion.viaversion.protocols.v1_10to1_11.rewriter.EntityIdRewriter; import com.viaversion.viaversion.protocols.v1_10to1_11.data.EntityNames1_11;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
import com.viaversion.viaversion.util.IdAndData; import com.viaversion.viaversion.util.IdAndData;
@ -210,7 +209,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
// Handler Spawners // Handler Spawners
if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 1) { if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 1) {
CompoundTag tag = wrapper.get(Types.NAMED_COMPOUND_TAG, 0); CompoundTag tag = wrapper.get(Types.NAMED_COMPOUND_TAG, 0);
EntityIdRewriter.toClientSpawner(tag, true); EntityNames1_11.toClientSpawner(tag, true);
} }
}); });
} }
@ -281,7 +280,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
// Handle spawner block entity (map to itself with custom handler) // Handle spawner block entity (map to itself with custom handler)
MappedLegacyBlockItem data = itemReplacements.computeIfAbsent(IdAndData.toRawData(52), s -> new MappedLegacyBlockItem(52)); MappedLegacyBlockItem data = itemReplacements.computeIfAbsent(IdAndData.toRawData(52), s -> new MappedLegacyBlockItem(52));
data.setBlockEntityHandler((b, tag) -> { data.setBlockEntityHandler((b, tag) -> {
EntityIdRewriter.toClientSpawner(tag, true); EntityNames1_11.toClientSpawner(tag, true);
return tag; return tag;
}); });
@ -301,7 +300,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
if (tag == null) return item; if (tag == null) return item;
// Rewrite spawn eggs (id checks are done in the method itself) // Rewrite spawn eggs (id checks are done in the method itself)
EntityIdRewriter.toClientItem(item, true); EntityNames1_11.toClientItem(item, true);
enchantmentRewriter.handleToClient(item); enchantmentRewriter.handleToClient(item);
return item; return item;
@ -316,7 +315,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
if (tag == null) return item; if (tag == null) return item;
// Rewrite spawn eggs (id checks are done in the method itself) // Rewrite spawn eggs (id checks are done in the method itself)
EntityIdRewriter.toServerItem(item, true); EntityNames1_11.toServerItem(item, true);
enchantmentRewriter.handleToServer(item); enchantmentRewriter.handleToServer(item);
return item; return item;

View File

@ -26,10 +26,9 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_16; import com.viaversion.viaversion.api.type.types.version.Types1_16;
import com.viaversion.viaversion.protocols.v1_15_2to1_16.rewriter.EntityPacketRewriter1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.data.DimensionRegistries1_16;
import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.ListTag; import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.NumberTag; import com.viaversion.nbt.tag.NumberTag;
@ -90,7 +89,7 @@ public class EntityPacketRewriter1_16_2 extends EntityRewriter<ClientboundPacket
} }
// Just screw the registry and write the defaults for 1.16 and 1.16.1 clients // Just screw the registry and write the defaults for 1.16 and 1.16.1 clients
wrapper.write(Types.NAMED_COMPOUND_TAG, EntityPacketRewriter1_16.DIMENSIONS_TAG); wrapper.write(Types.NAMED_COMPOUND_TAG, DimensionRegistries1_16.getDimensionsTag());
CompoundTag dimensionData = wrapper.read(Types.NAMED_COMPOUND_TAG); CompoundTag dimensionData = wrapper.read(Types.NAMED_COMPOUND_TAG);
wrapper.write(Types.STRING, getDimensionFromData(dimensionData)); wrapper.write(Types.STRING, getDimensionFromData(dimensionData));

View File

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_16to1_15_2.data;
import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viaversion.protocols.v1_15_2to1_16.Protocol1_15_2To1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.Protocol1_15_2To1_16;
import com.viaversion.viaversion.protocols.v1_15_2to1_16.data.AttributeMappings; import com.viaversion.viaversion.protocols.v1_15_2to1_16.data.Attributes1_16;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -34,7 +34,7 @@ public class BackwardsMappingData1_16 extends BackwardsMappingData {
@Override @Override
protected void loadExtras(final CompoundTag data) { protected void loadExtras(final CompoundTag data) {
super.loadExtras(data); super.loadExtras(data);
for (Map.Entry<String, String> entry : AttributeMappings.attributeIdentifierMappings().entrySet()) { for (Map.Entry<String, String> entry : Attributes1_16.attributeIdentifierMappings().entrySet()) {
attributeMappings.put(entry.getValue(), entry.getKey()); attributeMappings.put(entry.getValue(), entry.getKey());
} }
} }

View File

@ -23,7 +23,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap; import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viaversion.protocols.v1_17_1to1_18.Protocol1_17_1To1_18; import com.viaversion.viaversion.protocols.v1_17_1to1_18.Protocol1_17_1To1_18;
import com.viaversion.viaversion.protocols.v1_17_1to1_18.data.BlockEntities; import com.viaversion.viaversion.protocols.v1_17_1to1_18.data.BlockEntities1_18;
public final class BackwardsMappingData1_18 extends BackwardsMappingData { public final class BackwardsMappingData1_18 extends BackwardsMappingData {
@ -37,7 +37,7 @@ public final class BackwardsMappingData1_18 extends BackwardsMappingData {
protected void loadExtras(final CompoundTag data) { protected void loadExtras(final CompoundTag data) {
super.loadExtras(data); super.loadExtras(data);
for (final Object2IntMap.Entry<String> entry : BlockEntities.blockEntityIds().object2IntEntrySet()) { for (final Object2IntMap.Entry<String> entry : BlockEntities1_18.blockEntityIds().object2IntEntrySet()) {
blockEntities.put(entry.getIntValue(), entry.getKey()); blockEntities.put(entry.getIntValue(), entry.getKey());
} }
} }

View File

@ -17,6 +17,7 @@
*/ */
package com.viaversion.viabackwards.protocol.v1_18to1_17_1.data; package com.viaversion.viabackwards.protocol.v1_18to1_17_1.data;
import com.viaversion.viaversion.protocols.v1_17_1to1_18.data.BlockEntityIds1_18;
import java.util.Arrays; import java.util.Arrays;
public final class BlockEntityIds { public final class BlockEntityIds {
@ -24,7 +25,7 @@ public final class BlockEntityIds {
private static final int[] IDS; private static final int[] IDS;
static { static {
final int[] ids = com.viaversion.viaversion.protocols.v1_17_1to1_18.data.BlockEntityIds.getIds(); final int[] ids = BlockEntityIds1_18.getIds();
IDS = new int[Arrays.stream(ids).max().getAsInt() + 1]; IDS = new int[Arrays.stream(ids).max().getAsInt() + 1];
Arrays.fill(IDS, -1); Arrays.fill(IDS, -1);
for (int i = 0; i < ids.length; i++) { for (int i = 0; i < ids.length; i++) {