Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Replace tag instanceof checks/unchecked casts with helper methods
Dieser Commit ist enthalten in:
Ursprung
ad62d8552c
Commit
8a485db580
@ -18,7 +18,6 @@
|
|||||||
package com.viaversion.viaversion.configuration;
|
package com.viaversion.viaversion.configuration;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
|
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
|
||||||
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
|
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
|
||||||
import com.viaversion.viaversion.api.protocol.version.BlockedProtocolVersions;
|
import com.viaversion.viaversion.api.protocol.version.BlockedProtocolVersions;
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
package com.viaversion.viaversion.data.entity;
|
package com.viaversion.viaversion.data.entity;
|
||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.api.data.entity.DimensionData;
|
import com.viaversion.viaversion.api.data.entity.DimensionData;
|
||||||
|
|
||||||
public final class DimensionDataImpl implements DimensionData {
|
public final class DimensionDataImpl implements DimensionData {
|
||||||
@ -34,19 +32,17 @@ public final class DimensionDataImpl implements DimensionData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DimensionDataImpl(final CompoundTag dimensionData) {
|
public DimensionDataImpl(final CompoundTag dimensionData) {
|
||||||
final Tag height = dimensionData.get("height");
|
final NumberTag height = dimensionData.getNumberTag("height");
|
||||||
if (height instanceof IntTag) {
|
if (height == null) {
|
||||||
this.height = ((NumberTag) height).asInt();
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("height missing in dimension data: " + dimensionData);
|
throw new IllegalArgumentException("height missing in dimension data: " + dimensionData);
|
||||||
}
|
}
|
||||||
|
this.height = height.asInt();
|
||||||
|
|
||||||
final Tag minY = dimensionData.get("min_y");
|
final NumberTag minY = dimensionData.getNumberTag("min_y");
|
||||||
if (minY instanceof IntTag) {
|
if (minY == null) {
|
||||||
this.minY = ((NumberTag) minY).asInt();
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("min_y missing in dimension data: " + dimensionData);
|
throw new IllegalArgumentException("min_y missing in dimension data: " + dimensionData);
|
||||||
}
|
}
|
||||||
|
this.minY = minY.asInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,10 +82,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectSortedMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectSortedMap;
|
||||||
import java.util.logging.Level;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -106,6 +102,9 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.locks.ReadWriteLock;
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||||
|
|
||||||
public class ProtocolManagerImpl implements ProtocolManager {
|
public class ProtocolManagerImpl implements ProtocolManager {
|
||||||
private static final Protocol BASE_PROTOCOL = new BaseProtocol();
|
private static final Protocol BASE_PROTOCOL = new BaseProtocol();
|
||||||
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.base;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BaseProtocol1_16 extends BaseProtocol1_7 {
|
public class BaseProtocol1_16 extends BaseProtocol1_7 {
|
||||||
|
@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_10to1_9_3;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
@ -28,13 +29,12 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_10to1_9_3.packets.InventoryPackets;
|
import com.viaversion.viaversion.protocols.protocol1_10to1_9_3.packets.InventoryPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_10to1_9_3.storage.ResourcePackTracker;
|
import com.viaversion.viaversion.protocols.protocol1_10to1_9_3.storage.ResourcePackTracker;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_11to1_10;
|
|||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
@ -115,12 +114,11 @@ public class EntityIdRewriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void toClient(CompoundTag tag, boolean backwards) {
|
public static void toClient(CompoundTag tag, boolean backwards) {
|
||||||
Tag idTag = tag.get("id");
|
StringTag idTag = tag.getStringTag("id");
|
||||||
if (idTag instanceof StringTag) {
|
if (idTag != null) {
|
||||||
StringTag id = (StringTag) idTag;
|
String newName = backwards ? oldToNewNames.inverse().get(idTag.getValue()) : oldToNewNames.get(idTag.getValue());
|
||||||
String newName = backwards ? oldToNewNames.inverse().get(id.getValue()) : oldToNewNames.get(id.getValue());
|
|
||||||
if (newName != null) {
|
if (newName != null) {
|
||||||
id.setValue(newName);
|
idTag.setValue(newName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,9 +130,9 @@ public class EntityIdRewriter {
|
|||||||
public static void toClientSpawner(CompoundTag tag, boolean backwards) {
|
public static void toClientSpawner(CompoundTag tag, boolean backwards) {
|
||||||
if (tag == null) return;
|
if (tag == null) return;
|
||||||
|
|
||||||
Tag spawnDataTag = tag.get("SpawnData");
|
CompoundTag spawnDataTag = tag.getCompoundTag("SpawnData");
|
||||||
if (spawnDataTag != null) {
|
if (spawnDataTag != null) {
|
||||||
toClient((CompoundTag) spawnDataTag, backwards);
|
toClient(spawnDataTag, backwards);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +142,7 @@ public class EntityIdRewriter {
|
|||||||
|
|
||||||
public static void toClientItem(Item item, boolean backwards) {
|
public static void toClientItem(Item item, boolean backwards) {
|
||||||
if (hasEntityTag(item)) {
|
if (hasEntityTag(item)) {
|
||||||
toClient(item.tag().get("EntityTag"), backwards);
|
toClient(item.tag().getCompoundTag("EntityTag"), backwards);
|
||||||
}
|
}
|
||||||
if (item != null && item.amount() <= 0) item.setAmount(1);
|
if (item != null && item.amount() <= 0) item.setAmount(1);
|
||||||
}
|
}
|
||||||
@ -156,13 +154,12 @@ public class EntityIdRewriter {
|
|||||||
public static void toServerItem(Item item, boolean backwards) {
|
public static void toServerItem(Item item, boolean backwards) {
|
||||||
if (!hasEntityTag(item)) return;
|
if (!hasEntityTag(item)) return;
|
||||||
|
|
||||||
CompoundTag entityTag = item.tag().get("EntityTag");
|
CompoundTag entityTag = item.tag().getCompoundTag("EntityTag");
|
||||||
Tag idTag = entityTag.get("id");
|
StringTag idTag = entityTag.getStringTag("id");
|
||||||
if (idTag instanceof StringTag) {
|
if (idTag != null) {
|
||||||
StringTag id = (StringTag) idTag;
|
String newName = backwards ? oldToNewNames.get(idTag.getValue()) : oldToNewNames.inverse().get(idTag.getValue());
|
||||||
String newName = backwards ? oldToNewNames.get(id.getValue()) : oldToNewNames.inverse().get(id.getValue());
|
|
||||||
if (newName != null) {
|
if (newName != null) {
|
||||||
id.setValue(newName);
|
idTag.setValue(newName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,7 +170,7 @@ public class EntityIdRewriter {
|
|||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
if (tag == null) return false;
|
if (tag == null) return false;
|
||||||
|
|
||||||
Tag entityTag = tag.get("EntityTag");
|
CompoundTag entityTag = tag.getCompoundTag("EntityTag");
|
||||||
return entityTag instanceof CompoundTag && ((CompoundTag) entityTag).get("id") instanceof StringTag;
|
return entityTag != null && entityTag.getStringTag("id") != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
@ -28,6 +29,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_11to1_10.data.PotionColorMapping;
|
import com.viaversion.viaversion.protocols.protocol1_11to1_10.data.PotionColorMapping;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_11to1_10.metadata.MetadataRewriter1_11To1_10;
|
import com.viaversion.viaversion.protocols.protocol1_11to1_10.metadata.MetadataRewriter1_11To1_10;
|
||||||
@ -35,8 +37,6 @@ import com.viaversion.viaversion.protocols.protocol1_11to1_10.packets.InventoryP
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_11to1_10.storage.EntityTracker1_11;
|
import com.viaversion.viaversion.protocols.protocol1_11to1_10.storage.EntityTracker1_11;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
|
||||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||||
import com.viaversion.viaversion.util.Pair;
|
import com.viaversion.viaversion.util.Pair;
|
||||||
|
|
||||||
@ -193,13 +193,15 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
|
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 1)
|
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 1) {
|
||||||
EntityIdRewriter.toClientSpawner(tag);
|
EntityIdRewriter.toClientSpawner(tag);
|
||||||
|
}
|
||||||
|
|
||||||
if (tag.contains("id"))
|
StringTag idTag = tag.getStringTag("id");
|
||||||
|
if (idTag != null) {
|
||||||
// Handle new identifier
|
// Handle new identifier
|
||||||
((StringTag) tag.get("id")).setValue(BlockEntityRewriter.toNewIdentifier((String) tag.get("id").getValue()));
|
idTag.setValue(BlockEntityRewriter.toNewIdentifier(idTag.getValue()));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -211,15 +213,18 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
|
|
||||||
if (chunk.getBlockEntities() == null) return;
|
if (chunk.getBlockEntities() == null) return;
|
||||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||||
if (tag.contains("id")) {
|
StringTag idTag = tag.getStringTag("id");
|
||||||
String identifier = ((StringTag) tag.get("id")).getValue();
|
if (idTag == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String identifier = idTag.getValue();
|
||||||
if (identifier.equals("MobSpawner")) {
|
if (identifier.equals("MobSpawner")) {
|
||||||
EntityIdRewriter.toClientSpawner(tag);
|
EntityIdRewriter.toClientSpawner(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle new identifier
|
// Handle new identifier
|
||||||
((StringTag) tag.get("id")).setValue(BlockEntityRewriter.toNewIdentifier(identifier));
|
idTag.setValue(BlockEntityRewriter.toNewIdentifier(identifier));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
@ -33,6 +34,7 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
|||||||
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.Type;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
||||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.metadata.MetadataRewriter1_12To1_11_1;
|
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.metadata.MetadataRewriter1_12To1_11_1;
|
||||||
@ -42,8 +44,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPacke
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_13_1to1_13;
|
|||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.data.MappingData;
|
import com.viaversion.viaversion.api.data.MappingData;
|
||||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
@ -35,7 +36,6 @@ import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets.Inventor
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets.WorldPackets;
|
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets.WorldPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
|
||||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
|
|
||||||
|
@ -17,16 +17,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets;
|
package com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
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.Type;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
|
|
||||||
public class WorldPackets {
|
public class WorldPackets {
|
||||||
|
@ -166,7 +166,7 @@ public final class ConnectionData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Via.getPlatform().getLogger().info("Loading block connection mappings ...");
|
Via.getPlatform().getLogger().info("Loading block connection mappings ...");
|
||||||
ListTag blockStates = MappingDataLoader.loadNBT("blockstates-1.13.nbt").get("blockstates");
|
ListTag blockStates = MappingDataLoader.loadNBT("blockstates-1.13.nbt").getListTag("blockstates");
|
||||||
for (int id = 0; id < blockStates.size(); id++) {
|
for (int id = 0; id < blockStates.size(); id++) {
|
||||||
String key = (String) blockStates.get(id).getValue();
|
String key = (String) blockStates.get(id).getValue();
|
||||||
KEY_TO_ID.put(key, id);
|
KEY_TO_ID.put(key, id);
|
||||||
@ -177,7 +177,7 @@ public final class ConnectionData {
|
|||||||
if (!Via.getConfig().isReduceBlockStorageMemory()) {
|
if (!Via.getConfig().isReduceBlockStorageMemory()) {
|
||||||
blockConnectionData = new Int2ObjectOpenHashMap<>(2048);
|
blockConnectionData = new Int2ObjectOpenHashMap<>(2048);
|
||||||
|
|
||||||
ListTag blockConnectionMappings = MappingDataLoader.loadNBT("blockConnections.nbt").get("data");
|
ListTag blockConnectionMappings = MappingDataLoader.loadNBT("blockConnections.nbt").getListTag("data");
|
||||||
for (Tag blockTag : blockConnectionMappings) {
|
for (Tag blockTag : blockConnectionMappings) {
|
||||||
CompoundTag blockCompoundTag = (CompoundTag) blockTag;
|
CompoundTag blockCompoundTag = (CompoundTag) blockTag;
|
||||||
BlockData blockData = new BlockData();
|
BlockData blockData = new BlockData();
|
||||||
@ -198,11 +198,11 @@ public final class ConnectionData {
|
|||||||
blockData.put(connectionTypeId, attachingFaces);
|
blockData.put(connectionTypeId, attachingFaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
NumberTag idTag = blockCompoundTag.get("id");
|
NumberTag idTag = blockCompoundTag.getNumberTag("id");
|
||||||
if (idTag != null) {
|
if (idTag != null) {
|
||||||
blockConnectionData.put(idTag.asInt(), blockData);
|
blockConnectionData.put(idTag.asInt(), blockData);
|
||||||
} else {
|
} else {
|
||||||
IntArrayTag idsTag = blockCompoundTag.get("ids");
|
IntArrayTag idsTag = blockCompoundTag.getIntArrayTag("ids");
|
||||||
for (int id : idsTag.getValue()) {
|
for (int id : idsTag.getValue()) {
|
||||||
blockConnectionData.put(id, blockData);
|
blockConnectionData.put(id, blockData);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import com.viaversion.viaversion.api.minecraft.Position;
|
|||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ public class ComponentRewriter1_13<C extends ClientboundPacketType> extends Comp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag itemTag = tag.get("tag");
|
CompoundTag itemTag = tag.getCompoundTag("tag");
|
||||||
NumberTag damageTag = tag.get("Damage");
|
NumberTag damageTag = tag.getNumberTag("Damage");
|
||||||
|
|
||||||
// Call item converter
|
// Call item converter
|
||||||
short damage = damageTag != null ? damageTag.asShort() : 0;
|
short damage = damageTag != null ? damageTag.asShort() : 0;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data;
|
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data;
|
||||||
|
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -28,18 +28,21 @@ import com.google.gson.JsonElement;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.data.*;
|
import com.viaversion.viaversion.api.data.BiMappings;
|
||||||
|
import com.viaversion.viaversion.api.data.Int2IntMapBiMappings;
|
||||||
|
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||||
|
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||||
|
import com.viaversion.viaversion.api.data.Mappings;
|
||||||
import com.viaversion.viaversion.util.GsonUtil;
|
import com.viaversion.viaversion.util.GsonUtil;
|
||||||
import com.viaversion.viaversion.util.Int2IntBiHashMap;
|
import com.viaversion.viaversion.util.Int2IntBiHashMap;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class MappingData extends MappingDataBase {
|
public class MappingData extends MappingDataBase {
|
||||||
private final Map<String, int[]> blockTags = new HashMap<>();
|
private final Map<String, int[]> blockTags = new HashMap<>();
|
||||||
@ -56,11 +59,11 @@ public class MappingData extends MappingDataBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadExtras(final CompoundTag data) {
|
protected void loadExtras(final CompoundTag data) {
|
||||||
loadTags(blockTags, data.get("block_tags"));
|
loadTags(blockTags, data.getCompoundTag("block_tags"));
|
||||||
loadTags(itemTags, data.get("item_tags"));
|
loadTags(itemTags, data.getCompoundTag("item_tags"));
|
||||||
loadTags(fluidTags, data.get("fluid_tags"));
|
loadTags(fluidTags, data.getCompoundTag("fluid_tags"));
|
||||||
|
|
||||||
CompoundTag legacyEnchantments = data.get("legacy_enchantments");
|
CompoundTag legacyEnchantments = data.getCompoundTag("legacy_enchantments");
|
||||||
loadEnchantments(oldEnchantmentsIds, legacyEnchantments);
|
loadEnchantments(oldEnchantmentsIds, legacyEnchantments);
|
||||||
|
|
||||||
// Map minecraft:snow[layers=1] of 1.12 to minecraft:snow[layers=2] in 1.13
|
// Map minecraft:snow[layers=1] of 1.12 to minecraft:snow[layers=2] in 1.13
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data;
|
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
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.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -20,7 +20,6 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data;
|
|||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class SpawnEggRewriter {
|
public class SpawnEggRewriter {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets;
|
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
||||||
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.Type;
|
||||||
@ -26,7 +27,6 @@ import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2;
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
|
||||||
|
|
||||||
public class EntityPackets {
|
public class EntityPackets {
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ShortTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
@ -284,85 +283,117 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
// Invert banner/shield color id
|
// Invert banner/shield color id
|
||||||
boolean banner = item.identifier() == 425;
|
boolean banner = item.identifier() == 425;
|
||||||
if (banner || item.identifier() == 442) {
|
if (banner || item.identifier() == 442) {
|
||||||
if (tag.get("BlockEntityTag") instanceof CompoundTag) {
|
CompoundTag blockEntityTag = tag.getCompoundTag("BlockEntityTag");
|
||||||
CompoundTag blockEntityTag = tag.get("BlockEntityTag");
|
if (blockEntityTag != null) {
|
||||||
if (blockEntityTag.get("Base") instanceof IntTag) {
|
NumberTag baseTag = blockEntityTag.getNumberTag("Base");
|
||||||
IntTag base = blockEntityTag.get("Base");
|
if (baseTag != null) {
|
||||||
// Set banner item id according to nbt
|
// Set banner item id according to nbt
|
||||||
if (banner) {
|
if (banner) {
|
||||||
rawId = 6800 + base.asInt();
|
rawId = 6800 + baseTag.asInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
base.setValue(15 - base.asInt());
|
blockEntityTag.putInt("Base", 15 - baseTag.asInt());
|
||||||
}
|
}
|
||||||
if (blockEntityTag.get("Patterns") instanceof ListTag) {
|
|
||||||
for (Tag pattern : (ListTag) blockEntityTag.get("Patterns")) {
|
ListTag patternsTag = blockEntityTag.getListTag("Patterns");
|
||||||
if (pattern instanceof CompoundTag) {
|
if (patternsTag != null) {
|
||||||
Tag c = ((CompoundTag) pattern).get("Color");
|
for (Tag pattern : patternsTag) {
|
||||||
if (c instanceof NumberTag) {
|
if (!(pattern instanceof CompoundTag)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag patternTag = (CompoundTag) pattern;
|
||||||
|
NumberTag colorTag = patternTag.getNumberTag("Color");
|
||||||
|
if (colorTag == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Invert color id
|
// Invert color id
|
||||||
((CompoundTag) pattern).put("Color",
|
patternTag.putInt("Color", 15 - colorTag.asInt());
|
||||||
new IntTag(15 - ((NumberTag) c).asInt()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Display Name now uses JSON
|
// Display Name now uses JSON
|
||||||
if (tag.get("display") instanceof CompoundTag) {
|
CompoundTag display = tag.getCompoundTag("display");
|
||||||
CompoundTag display = tag.get("display");
|
if (display != null) {
|
||||||
if (display.get("Name") instanceof StringTag) {
|
StringTag name = display.getStringTag("Name");
|
||||||
StringTag name = display.get("Name");
|
if (name != null) {
|
||||||
display.put(NBT_TAG_NAME + "|Name", new StringTag(name.getValue()));
|
display.putString(NBT_TAG_NAME + "|Name", name.getValue());
|
||||||
name.setValue(ComponentUtil.legacyToJsonString(name.getValue(), true));
|
name.setValue(ComponentUtil.legacyToJsonString(name.getValue(), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ench is now Enchantments and now uses identifiers
|
// ench is now Enchantments and now uses identifiers
|
||||||
if (tag.get("ench") instanceof ListTag) {
|
ListTag ench = tag.getListTag("ench");
|
||||||
ListTag ench = tag.get("ench");
|
if (ench != null) {
|
||||||
ListTag enchantments = new ListTag(CompoundTag.class);
|
ListTag enchantments = new ListTag(CompoundTag.class);
|
||||||
for (Tag enchEntry : ench) {
|
for (Tag enchEntry : ench) {
|
||||||
NumberTag idTag;
|
if (!(enchEntry instanceof CompoundTag)) {
|
||||||
if (enchEntry instanceof CompoundTag && (idTag = ((CompoundTag) enchEntry).get("id")) != null) {
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag entryTag = (CompoundTag) enchEntry;
|
||||||
|
NumberTag idTag = entryTag.getNumberTag("id");
|
||||||
|
if (idTag == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
CompoundTag enchantmentEntry = new CompoundTag();
|
CompoundTag enchantmentEntry = new CompoundTag();
|
||||||
short oldId = idTag.asShort();
|
short oldId = idTag.asShort();
|
||||||
String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
||||||
if (newId == null) {
|
if (newId == null) {
|
||||||
newId = "viaversion:legacy/" + oldId;
|
newId = "viaversion:legacy/" + oldId;
|
||||||
}
|
}
|
||||||
enchantmentEntry.put("id", new StringTag(newId));
|
enchantmentEntry.putString("id", newId);
|
||||||
enchantmentEntry.put("lvl", new ShortTag(((NumberTag) ((CompoundTag) enchEntry).get("lvl")).asShort()));
|
|
||||||
enchantments.add(enchantmentEntry);
|
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
||||||
|
if (levelTag != null) {
|
||||||
|
enchantmentEntry.putShort("lvl", levelTag.asShort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enchantments.add(enchantmentEntry);
|
||||||
}
|
}
|
||||||
tag.remove("ench");
|
tag.remove("ench");
|
||||||
tag.put("Enchantments", enchantments);
|
tag.put("Enchantments", enchantments);
|
||||||
}
|
}
|
||||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
|
||||||
ListTag storedEnch = tag.get("StoredEnchantments");
|
ListTag storedEnch = tag.getListTag("StoredEnchantments");
|
||||||
|
if (storedEnch != null) {
|
||||||
ListTag newStoredEnch = new ListTag(CompoundTag.class);
|
ListTag newStoredEnch = new ListTag(CompoundTag.class);
|
||||||
for (Tag enchEntry : storedEnch) {
|
for (Tag enchEntry : storedEnch) {
|
||||||
if (enchEntry instanceof CompoundTag) {
|
if (!(enchEntry instanceof CompoundTag)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag entryTag = (CompoundTag) enchEntry;
|
||||||
|
NumberTag idTag = entryTag.getNumberTag("id");
|
||||||
|
if (idTag == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
CompoundTag enchantmentEntry = new CompoundTag();
|
CompoundTag enchantmentEntry = new CompoundTag();
|
||||||
short oldId = ((NumberTag) ((CompoundTag) enchEntry).get("id")).asShort();
|
short oldId = idTag.asShort();
|
||||||
String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
||||||
if (newId == null) {
|
if (newId == null) {
|
||||||
newId = "viaversion:legacy/" + oldId;
|
newId = "viaversion:legacy/" + oldId;
|
||||||
}
|
}
|
||||||
enchantmentEntry.put("id", new StringTag(newId));
|
enchantmentEntry.putString("id", newId);
|
||||||
enchantmentEntry.put("lvl", new ShortTag(((NumberTag) ((CompoundTag) enchEntry).get("lvl")).asShort()));
|
|
||||||
|
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
||||||
|
if (levelTag != null) {
|
||||||
|
enchantmentEntry.putShort("lvl", levelTag.asShort());
|
||||||
|
}
|
||||||
|
|
||||||
newStoredEnch.add(enchantmentEntry);
|
newStoredEnch.add(enchantmentEntry);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
tag.remove("StoredEnchantments");
|
|
||||||
tag.put("StoredEnchantments", newStoredEnch);
|
tag.put("StoredEnchantments", newStoredEnch);
|
||||||
}
|
}
|
||||||
if (tag.get("CanPlaceOn") instanceof ListTag) {
|
|
||||||
ListTag old = tag.get("CanPlaceOn");
|
ListTag canPlaceOnTag = tag.getListTag("CanPlaceOn");
|
||||||
|
if (canPlaceOnTag != null) {
|
||||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
||||||
tag.put(NBT_TAG_NAME + "|CanPlaceOn", old.copy());
|
tag.put(NBT_TAG_NAME + "|CanPlaceOn", canPlaceOnTag.copy());
|
||||||
for (Tag oldTag : old) {
|
for (Tag oldTag : canPlaceOnTag) {
|
||||||
Object value = oldTag.getValue();
|
Object value = oldTag.getValue();
|
||||||
String oldId = Key.stripMinecraftNamespace(value.toString());
|
String oldId = Key.stripMinecraftNamespace(value.toString());
|
||||||
String numberConverted = BlockIdData.numberIdToString.get(Ints.tryParse(oldId));
|
String numberConverted = BlockIdData.numberIdToString.get(Ints.tryParse(oldId));
|
||||||
@ -380,11 +411,12 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
}
|
}
|
||||||
tag.put("CanPlaceOn", newCanPlaceOn);
|
tag.put("CanPlaceOn", newCanPlaceOn);
|
||||||
}
|
}
|
||||||
if (tag.get("CanDestroy") instanceof ListTag) {
|
|
||||||
ListTag old = tag.get("CanDestroy");
|
ListTag canDestroyTag = tag.getListTag("CanDestroy");
|
||||||
|
if (canDestroyTag != null) {
|
||||||
ListTag newCanDestroy = new ListTag(StringTag.class);
|
ListTag newCanDestroy = new ListTag(StringTag.class);
|
||||||
tag.put(NBT_TAG_NAME + "|CanDestroy", old.copy());
|
tag.put(NBT_TAG_NAME + "|CanDestroy", canDestroyTag.copy());
|
||||||
for (Tag oldTag : old) {
|
for (Tag oldTag : canDestroyTag) {
|
||||||
Object value = oldTag.getValue();
|
Object value = oldTag.getValue();
|
||||||
String oldId = Key.stripMinecraftNamespace(value.toString());
|
String oldId = Key.stripMinecraftNamespace(value.toString());
|
||||||
String numberConverted = BlockIdData.numberIdToString.get(Ints.tryParse(oldId));
|
String numberConverted = BlockIdData.numberIdToString.get(Ints.tryParse(oldId));
|
||||||
@ -404,18 +436,19 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
}
|
}
|
||||||
// Handle SpawnEggs
|
// Handle SpawnEggs
|
||||||
if (item.identifier() == 383) {
|
if (item.identifier() == 383) {
|
||||||
if (tag.get("EntityTag") instanceof CompoundTag) {
|
CompoundTag entityTag = tag.getCompoundTag("EntityTag");
|
||||||
CompoundTag entityTag = tag.get("EntityTag");
|
if (entityTag != null) {
|
||||||
if (entityTag.get("id") instanceof StringTag) {
|
StringTag idTag = entityTag.getStringTag("id");
|
||||||
StringTag identifier = entityTag.get("id");
|
if (idTag != null) {
|
||||||
rawId = SpawnEggRewriter.getSpawnEggId(identifier.getValue());
|
rawId = SpawnEggRewriter.getSpawnEggId(idTag.getValue());
|
||||||
if (rawId == -1) {
|
if (rawId == -1) {
|
||||||
rawId = 25100288; // Bat fallback
|
rawId = 25100288; // Bat fallback
|
||||||
} else {
|
} else {
|
||||||
entityTag.remove("id");
|
entityTag.remove("id");
|
||||||
if (entityTag.isEmpty())
|
if (entityTag.isEmpty()) {
|
||||||
tag.remove("EntityTag");
|
tag.remove("EntityTag");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fallback to bat
|
// Fallback to bat
|
||||||
rawId = 25100288;
|
rawId = 25100288;
|
||||||
@ -492,8 +525,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
// Use tag to get original ID and data
|
// Use tag to get original ID and data
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
// Check for valid tag
|
// Check for valid tag
|
||||||
if (tag.get(NBT_TAG_NAME) instanceof IntTag) {
|
NumberTag viaTag = tag.getNumberTag(NBT_TAG_NAME);
|
||||||
rawId = ((NumberTag) tag.get(NBT_TAG_NAME)).asInt();
|
if (viaTag != null) {
|
||||||
|
rawId = viaTag.asInt();
|
||||||
// Remove the tag
|
// Remove the tag
|
||||||
tag.remove(NBT_TAG_NAME);
|
tag.remove(NBT_TAG_NAME);
|
||||||
gotRawIdFromTag = true;
|
gotRawIdFromTag = true;
|
||||||
@ -533,97 +567,130 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
// NBT changes
|
// NBT changes
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
if (isDamageable(item.identifier())) {
|
if (isDamageable(item.identifier())) {
|
||||||
if (tag.get("Damage") instanceof IntTag) {
|
NumberTag damageTag = tag.getNumberTag("Damage");
|
||||||
|
if (damageTag != null) {
|
||||||
if (!gotRawIdFromTag) {
|
if (!gotRawIdFromTag) {
|
||||||
item.setData((short) (int) tag.get("Damage").getValue());
|
item.setData(damageTag.asShort());
|
||||||
}
|
}
|
||||||
tag.remove("Damage");
|
tag.remove("Damage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.identifier() == 358) { // map
|
if (item.identifier() == 358) { // map
|
||||||
if (tag.get("map") instanceof IntTag) {
|
NumberTag mapTag = tag.getNumberTag("map");
|
||||||
|
if (mapTag != null) {
|
||||||
if (!gotRawIdFromTag) {
|
if (!gotRawIdFromTag) {
|
||||||
item.setData((short) (int) tag.get("map").getValue());
|
item.setData(mapTag.asShort());
|
||||||
}
|
}
|
||||||
tag.remove("map");
|
tag.remove("map");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.identifier() == 442 || item.identifier() == 425) { // shield / banner
|
if (item.identifier() == 442 || item.identifier() == 425) { // shield / banner
|
||||||
if (tag.get("BlockEntityTag") instanceof CompoundTag) {
|
CompoundTag blockEntityTag = tag.getCompoundTag("BlockEntityTag");
|
||||||
CompoundTag blockEntityTag = tag.get("BlockEntityTag");
|
if (blockEntityTag != null) {
|
||||||
if (blockEntityTag.get("Base") instanceof IntTag) {
|
NumberTag baseTag = blockEntityTag.getNumberTag("Base");
|
||||||
IntTag base = blockEntityTag.get("Base");
|
if (baseTag != null) {
|
||||||
base.setValue(15 - base.asInt()); // invert color id
|
blockEntityTag.putInt("Base", 15 - baseTag.asInt()); // invert color id
|
||||||
}
|
}
|
||||||
if (blockEntityTag.get("Patterns") instanceof ListTag) {
|
|
||||||
for (Tag pattern : (ListTag) blockEntityTag.get("Patterns")) {
|
ListTag patternsTag = blockEntityTag.getListTag("Patterns");
|
||||||
if (pattern instanceof CompoundTag) {
|
if (patternsTag != null) {
|
||||||
IntTag c = ((CompoundTag) pattern).get("Color");
|
for (Tag pattern : patternsTag) {
|
||||||
c.setValue(15 - c.asInt()); // Invert color id
|
if (!(pattern instanceof CompoundTag)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompoundTag patternTag = (CompoundTag) pattern;
|
||||||
|
NumberTag colorTag = patternTag.getNumberTag("Color");
|
||||||
|
patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Display Name now uses JSON
|
// Display Name now uses JSON
|
||||||
if (tag.get("display") instanceof CompoundTag) {
|
CompoundTag display = tag.getCompoundTag("display");
|
||||||
CompoundTag display = tag.get("display");
|
if (display != null) {
|
||||||
if (display.get("Name") instanceof StringTag) {
|
StringTag name = display.getStringTag("Name");
|
||||||
StringTag name = display.get("Name");
|
if (name != null) {
|
||||||
StringTag via = display.remove(NBT_TAG_NAME + "|Name");
|
Tag via = display.remove(NBT_TAG_NAME + "|Name");
|
||||||
name.setValue(via != null ? via.getValue() : ComponentUtil.jsonToLegacy(name.getValue()));
|
name.setValue(via instanceof StringTag ? (String) via.getValue() : ComponentUtil.jsonToLegacy(name.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ench is now Enchantments and now uses identifiers
|
// ench is now Enchantments and now uses identifiers
|
||||||
if (tag.get("Enchantments") instanceof ListTag) {
|
ListTag enchantments = tag.getListTag("Enchantments");
|
||||||
ListTag enchantments = tag.get("Enchantments");
|
if (enchantments != null) {
|
||||||
ListTag ench = new ListTag(CompoundTag.class);
|
ListTag ench = new ListTag(CompoundTag.class);
|
||||||
for (Tag enchantmentEntry : enchantments) {
|
for (Tag enchantmentEntry : enchantments) {
|
||||||
if (enchantmentEntry instanceof CompoundTag) {
|
if (!(enchantmentEntry instanceof CompoundTag)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag entryTag = (CompoundTag) enchantmentEntry;
|
||||||
|
StringTag idTag = entryTag.getStringTag("id");
|
||||||
|
if (idTag == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
CompoundTag enchEntry = new CompoundTag();
|
CompoundTag enchEntry = new CompoundTag();
|
||||||
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
|
String newId = idTag.getValue();
|
||||||
Short oldId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().inverse().get(newId);
|
Short oldId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().inverse().get(newId);
|
||||||
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
||||||
oldId = Short.valueOf(newId.substring(18));
|
oldId = Short.valueOf(newId.substring(18));
|
||||||
}
|
}
|
||||||
if (oldId != null) {
|
if (oldId != null) {
|
||||||
enchEntry.put("id", new ShortTag(oldId));
|
enchEntry.putShort("id", oldId);
|
||||||
enchEntry.put("lvl", new ShortTag(((NumberTag) ((CompoundTag) enchantmentEntry).get("lvl")).asShort()));
|
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
||||||
ench.add(enchEntry);
|
if (levelTag != null) {
|
||||||
|
enchEntry.putShort("lvl", levelTag.asShort());
|
||||||
}
|
}
|
||||||
|
ench.add(enchEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag.remove("Enchantments");
|
tag.remove("Enchantments");
|
||||||
tag.put("ench", ench);
|
tag.put("ench", ench);
|
||||||
}
|
}
|
||||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
|
||||||
ListTag storedEnch = tag.get("StoredEnchantments");
|
|
||||||
|
ListTag storedEnch = tag.getListTag("StoredEnchantments");
|
||||||
|
if (storedEnch != null) {
|
||||||
ListTag newStoredEnch = new ListTag(CompoundTag.class);
|
ListTag newStoredEnch = new ListTag(CompoundTag.class);
|
||||||
for (Tag enchantmentEntry : storedEnch) {
|
for (Tag enchantmentEntry : storedEnch) {
|
||||||
if (enchantmentEntry instanceof CompoundTag) {
|
if (!(enchantmentEntry instanceof CompoundTag)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag entryTag = (CompoundTag) enchantmentEntry;
|
||||||
|
StringTag idTag = entryTag.getStringTag("id");
|
||||||
|
if (idTag == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
CompoundTag enchEntry = new CompoundTag();
|
CompoundTag enchEntry = new CompoundTag();
|
||||||
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
|
String newId = idTag.getValue();
|
||||||
Short oldId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().inverse().get(newId);
|
Short oldId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().inverse().get(newId);
|
||||||
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
||||||
oldId = Short.valueOf(newId.substring(18));
|
oldId = Short.valueOf(newId.substring(18));
|
||||||
}
|
}
|
||||||
if (oldId != null) {
|
|
||||||
enchEntry.put("id", new ShortTag(oldId));
|
if (oldId == null) {
|
||||||
enchEntry.put("lvl", new ShortTag(((NumberTag) ((CompoundTag) enchantmentEntry).get("lvl")).asShort()));
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
enchEntry.putShort("id", oldId);
|
||||||
|
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
||||||
|
if (levelTag != null) {
|
||||||
|
enchEntry.putShort("lvl", levelTag.asShort());
|
||||||
|
}
|
||||||
newStoredEnch.add(enchEntry);
|
newStoredEnch.add(enchEntry);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
tag.remove("StoredEnchantments");
|
|
||||||
tag.put("StoredEnchantments", newStoredEnch);
|
tag.put("StoredEnchantments", newStoredEnch);
|
||||||
}
|
}
|
||||||
if (tag.get(NBT_TAG_NAME + "|CanPlaceOn") instanceof ListTag) {
|
if (tag.getListTag(NBT_TAG_NAME + "|CanPlaceOn") != null) {
|
||||||
tag.put("CanPlaceOn", tag.remove(NBT_TAG_NAME + "|CanPlaceOn"));
|
tag.put("CanPlaceOn", tag.remove(NBT_TAG_NAME + "|CanPlaceOn"));
|
||||||
} else if (tag.get("CanPlaceOn") instanceof ListTag) {
|
} else if (tag.getListTag("CanPlaceOn") != null) {
|
||||||
ListTag old = tag.get("CanPlaceOn");
|
ListTag old = tag.getListTag("CanPlaceOn");
|
||||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
||||||
for (Tag oldTag : old) {
|
for (Tag oldTag : old) {
|
||||||
Object value = oldTag.getValue();
|
Object value = oldTag.getValue();
|
||||||
@ -640,10 +707,10 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
}
|
}
|
||||||
tag.put("CanPlaceOn", newCanPlaceOn);
|
tag.put("CanPlaceOn", newCanPlaceOn);
|
||||||
}
|
}
|
||||||
if (tag.get(NBT_TAG_NAME + "|CanDestroy") instanceof ListTag) {
|
if (tag.getListTag(NBT_TAG_NAME + "|CanDestroy") != null) {
|
||||||
tag.put("CanDestroy", tag.remove(NBT_TAG_NAME + "|CanDestroy"));
|
tag.put("CanDestroy", tag.remove(NBT_TAG_NAME + "|CanDestroy"));
|
||||||
} else if (tag.get("CanDestroy") instanceof ListTag) {
|
} else if (tag.getListTag("CanDestroy") != null) {
|
||||||
ListTag old = tag.get("CanDestroy");
|
ListTag old = tag.getListTag("CanDestroy");
|
||||||
ListTag newCanDestroy = new ListTag(StringTag.class);
|
ListTag newCanDestroy = new ListTag(StringTag.class);
|
||||||
for (Tag oldTag : old) {
|
for (Tag oldTag : old) {
|
||||||
Object value = oldTag.getValue();
|
Object value = oldTag.getValue();
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets;
|
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets;
|
||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||||
@ -50,7 +48,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockSto
|
|||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -428,9 +425,9 @@ public class WorldPackets {
|
|||||||
CompoundTag tag = iterator.next();
|
CompoundTag tag = iterator.next();
|
||||||
int newId = provider.transform(wrapper.user(), null, tag, false);
|
int newId = provider.transform(wrapper.user(), null, tag, false);
|
||||||
if (newId != -1) {
|
if (newId != -1) {
|
||||||
int x = ((NumberTag) tag.get("x")).asInt();
|
int x = tag.getNumberTag("x").asInt();
|
||||||
int y = ((NumberTag) tag.get("y")).asInt();
|
int y = tag.getNumberTag("y").asInt();
|
||||||
int z = ((NumberTag) tag.get("z")).asInt();
|
int z = tag.getNumberTag("z").asInt();
|
||||||
|
|
||||||
Position position = new Position(x, (short) y, z);
|
Position position = new Position(x, (short) y, z);
|
||||||
// Store the replacement blocks for blockupdates
|
// Store the replacement blocks for blockupdates
|
||||||
@ -442,10 +439,10 @@ public class WorldPackets {
|
|||||||
chunk.getSections()[y >> 4].palette(PaletteType.BLOCKS).setIdAt(x & 0xF, y & 0xF, z & 0xF, newId);
|
chunk.getSections()[y >> 4].palette(PaletteType.BLOCKS).setIdAt(x & 0xF, y & 0xF, z & 0xF, newId);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Tag idTag = tag.get("id");
|
final StringTag idTag = tag.getStringTag("id");
|
||||||
if (idTag instanceof StringTag) {
|
if (idTag != null) {
|
||||||
// No longer block entities
|
// No longer block entities
|
||||||
final String id = Key.namespaced(((StringTag) idTag).getValue());
|
final String id = Key.namespaced(idTag.getValue());
|
||||||
if (id.equals("minecraft:noteblock") || id.equals("minecraft:flower_pot")) {
|
if (id.equals("minecraft:noteblock") || id.equals("minecraft:flower_pot")) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers;
|
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers;
|
||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
@ -59,14 +59,13 @@ public class BlockEntityProvider implements Provider {
|
|||||||
* @throws Exception Gotta throw that exception
|
* @throws Exception Gotta throw that exception
|
||||||
*/
|
*/
|
||||||
public int transform(UserConnection user, Position position, CompoundTag tag, boolean sendUpdate) throws Exception {
|
public int transform(UserConnection user, Position position, CompoundTag tag, boolean sendUpdate) throws Exception {
|
||||||
Tag idTag = tag.get("id");
|
StringTag idTag = tag.getStringTag("id");
|
||||||
if (idTag == null) return -1;
|
if (idTag == null) return -1;
|
||||||
|
|
||||||
String id = (String) idTag.getValue();
|
BlockEntityHandler handler = handlers.get(idTag.getValue());
|
||||||
BlockEntityHandler handler = handlers.get(id);
|
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
if (Via.getManager().isDebug()) {
|
if (Via.getManager().isDebug()) {
|
||||||
Via.getPlatform().getLogger().warning("Unhandled BlockEntity " + id + " full tag: " + tag);
|
Via.getPlatform().getLogger().warning("Unhandled BlockEntity " + idTag.getValue() + " full tag: " + tag);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.platform.providers.Provider;
|
import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.blockentities;
|
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.blockentities;
|
||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
@ -40,7 +39,7 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
@Override
|
@Override
|
||||||
public int transform(UserConnection user, CompoundTag tag) {
|
public int transform(UserConnection user, CompoundTag tag) {
|
||||||
BlockStorage storage = user.get(BlockStorage.class);
|
BlockStorage storage = user.get(BlockStorage.class);
|
||||||
Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));
|
Position position = new Position(tag.getNumberTag("x").asInt(), tag.getNumberTag("y").asShort(), tag.getNumberTag("z").asInt());
|
||||||
|
|
||||||
if (!storage.contains(position)) {
|
if (!storage.contains(position)) {
|
||||||
Via.getPlatform().getLogger().warning("Received an banner color update packet, but there is no banner! O_o " + tag);
|
Via.getPlatform().getLogger().warning("Received an banner color update packet, but there is no banner! O_o " + tag);
|
||||||
@ -49,11 +48,8 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
|
|
||||||
int blockId = storage.get(position).getOriginal();
|
int blockId = storage.get(position).getOriginal();
|
||||||
|
|
||||||
Tag base = tag.get("Base");
|
NumberTag base = tag.getNumberTag("Base");
|
||||||
int color = 0;
|
int color = base != null ? base.asInt() : 0;
|
||||||
if (base instanceof NumberTag) {
|
|
||||||
color = ((NumberTag) base).asInt();
|
|
||||||
}
|
|
||||||
// Standing banner
|
// Standing banner
|
||||||
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
|
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
|
||||||
blockId += ((15 - color) * 16);
|
blockId += ((15 - color) * 16);
|
||||||
@ -64,27 +60,26 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
Via.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
|
Via.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag patterns = tag.get("Patterns");
|
ListTag patterns = tag.getListTag("Patterns");
|
||||||
if (patterns instanceof ListTag) {
|
if (patterns != null) {
|
||||||
for (Tag pattern : (ListTag) patterns) {
|
for (Tag pattern : patterns) {
|
||||||
if (pattern instanceof CompoundTag) {
|
if (!(pattern instanceof CompoundTag)) {
|
||||||
Tag c = ((CompoundTag) pattern).get("Color");
|
continue;
|
||||||
if (c instanceof IntTag) {
|
|
||||||
((IntTag) c).setValue(15 - (int) c.getValue()); // Invert color id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompoundTag patternTag = (CompoundTag) pattern;
|
||||||
|
NumberTag colorTag = patternTag.getNumberTag("Color");
|
||||||
|
if (colorTag != null) {
|
||||||
|
patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag name = tag.get("CustomName");
|
StringTag name = tag.getStringTag("CustomName");
|
||||||
if (name instanceof StringTag) {
|
if (name != null) {
|
||||||
((StringTag) name).setValue(ComponentUtil.legacyToJsonString(((StringTag) name).getValue()));
|
name.setValue(ComponentUtil.legacyToJsonString(name.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return blockId;
|
return blockId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getLong(NumberTag tag) {
|
|
||||||
return tag.asLong();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.block
|
|||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
@ -31,7 +30,7 @@ public class BedHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
@Override
|
@Override
|
||||||
public int transform(UserConnection user, CompoundTag tag) {
|
public int transform(UserConnection user, CompoundTag tag) {
|
||||||
BlockStorage storage = user.get(BlockStorage.class);
|
BlockStorage storage = user.get(BlockStorage.class);
|
||||||
Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));
|
Position position = new Position(tag.getNumberTag("x").asInt(), tag.getNumberTag("y").asShort(), tag.getNumberTag("z").asInt());
|
||||||
|
|
||||||
if (!storage.contains(position)) {
|
if (!storage.contains(position)) {
|
||||||
Via.getPlatform().getLogger().warning("Received an bed color update packet, but there is no bed! O_o " + tag);
|
Via.getPlatform().getLogger().warning("Received an bed color update packet, but there is no bed! O_o " + tag);
|
||||||
@ -41,15 +40,11 @@ public class BedHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
// RED_BED + FIRST_BED
|
// RED_BED + FIRST_BED
|
||||||
int blockId = storage.get(position).getOriginal() - 972 + 748;
|
int blockId = storage.get(position).getOriginal() - 972 + 748;
|
||||||
|
|
||||||
Tag color = tag.get("color");
|
NumberTag color = tag.getNumberTag("color");
|
||||||
if (color instanceof NumberTag) {
|
if (color != null) {
|
||||||
blockId += (((NumberTag) color).asInt() * 16);
|
blockId += (color.asInt() * 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
return blockId;
|
return blockId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getLong(NumberTag tag) {
|
|
||||||
return tag.asLong();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.block
|
|||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
@ -34,15 +33,16 @@ public class CommandBlockHandler implements BlockEntityProvider.BlockEntityHandl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int transform(UserConnection user, CompoundTag tag) {
|
public int transform(UserConnection user, CompoundTag tag) {
|
||||||
Tag name = tag.get("CustomName");
|
StringTag name = tag.getStringTag("CustomName");
|
||||||
if (name instanceof StringTag) {
|
if (name != null) {
|
||||||
((StringTag) name).setValue(ComponentUtil.legacyToJsonString(((StringTag) name).getValue()));
|
name.setValue(ComponentUtil.legacyToJsonString(name.getValue()));
|
||||||
}
|
}
|
||||||
Tag out = tag.get("LastOutput");
|
|
||||||
if (out instanceof StringTag) {
|
StringTag out = tag.getStringTag("LastOutput");
|
||||||
JsonElement value = JsonParser.parseString(((StringTag) out).getValue());
|
if (out != null) {
|
||||||
|
JsonElement value = JsonParser.parseString(out.getValue());
|
||||||
protocol.getComponentRewriter().processText(value);
|
protocol.getComponentRewriter().processText(value);
|
||||||
((StringTag) out).setValue(value.toString());
|
out.setValue(value.toString());
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
import com.viaversion.viaversion.util.Pair;
|
import com.viaversion.viaversion.util.Pair;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.block
|
|||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
@ -33,7 +32,7 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
@Override
|
@Override
|
||||||
public int transform(UserConnection user, CompoundTag tag) {
|
public int transform(UserConnection user, CompoundTag tag) {
|
||||||
BlockStorage storage = user.get(BlockStorage.class);
|
BlockStorage storage = user.get(BlockStorage.class);
|
||||||
Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));
|
Position position = new Position(tag.getNumberTag("x").asInt(), tag.getNumberTag("y").asShort(), tag.getNumberTag("z").asInt());
|
||||||
|
|
||||||
if (!storage.contains(position)) {
|
if (!storage.contains(position)) {
|
||||||
Via.getPlatform().getLogger().warning("Received an head update packet, but there is no head! O_o " + tag);
|
Via.getPlatform().getLogger().warning("Received an head update packet, but there is no head! O_o " + tag);
|
||||||
@ -42,13 +41,14 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
|
|
||||||
int id = storage.get(position).getOriginal();
|
int id = storage.get(position).getOriginal();
|
||||||
if (id >= SKULL_WALL_START && id <= SKULL_END) {
|
if (id >= SKULL_WALL_START && id <= SKULL_END) {
|
||||||
Tag skullType = tag.get("SkullType");
|
NumberTag skullType = tag.getNumberTag("SkullType");
|
||||||
if (skullType instanceof NumberTag) {
|
if (skullType != null) {
|
||||||
id += ((NumberTag) skullType).asInt() * 20;
|
id += skullType.asInt() * 20;
|
||||||
}
|
}
|
||||||
Tag rot = tag.get("Rot");
|
|
||||||
if (rot instanceof NumberTag) {
|
NumberTag rot = tag.getNumberTag("Rot");
|
||||||
id += ((NumberTag) rot).asInt();
|
if (rot != null) {
|
||||||
|
id += rot.asInt();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Via.getPlatform().getLogger().warning("Why does this block have the skull block entity? " + tag);
|
Via.getPlatform().getLogger().warning("Why does this block have the skull block entity? " + tag);
|
||||||
@ -57,8 +57,4 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getLong(NumberTag tag) {
|
|
||||||
return tag.asLong();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.block
|
|||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.EntityNameRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.EntityNameRewriter;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
|
||||||
@ -27,13 +26,12 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.BlockE
|
|||||||
public class SpawnerHandler implements BlockEntityProvider.BlockEntityHandler {
|
public class SpawnerHandler implements BlockEntityProvider.BlockEntityHandler {
|
||||||
@Override
|
@Override
|
||||||
public int transform(UserConnection user, CompoundTag tag) {
|
public int transform(UserConnection user, CompoundTag tag) {
|
||||||
Tag data = tag.get("SpawnData");
|
CompoundTag data = tag.getCompoundTag("SpawnData");
|
||||||
if (data instanceof CompoundTag) {
|
if (data != null) {
|
||||||
Tag id = ((CompoundTag) data).get("id");
|
StringTag id = data.getStringTag("id");
|
||||||
if (id instanceof StringTag) {
|
if (id != null) {
|
||||||
((StringTag) id).setValue(EntityNameRewriter.rewrite(((StringTag) id).getValue()));
|
id.setValue(EntityNameRewriter.rewrite(id.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always return -1 because the block is still the same id
|
// Always return -1 because the block is still the same id
|
||||||
|
@ -20,13 +20,12 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage;
|
|||||||
import com.google.common.collect.EvictingQueue;
|
import com.google.common.collect.EvictingQueue;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class BlockConnectionStorage implements StorableObject {
|
public class BlockConnectionStorage implements StorableObject {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_14to1_13_2;
|
package com.viaversion.viaversion.protocols.protocol1_14to1_13_2;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||||
@ -33,7 +34,6 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets.Inventor
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets.PlayerPackets;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets.PlayerPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets.WorldPackets;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets.WorldPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
|
||||||
import com.viaversion.viaversion.rewriter.CommandRewriter;
|
import com.viaversion.viaversion.rewriter.CommandRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||||
|
@ -36,11 +36,11 @@ public class MappingData extends MappingDataBase {
|
|||||||
@Override
|
@Override
|
||||||
public void loadExtras(final CompoundTag data) {
|
public void loadExtras(final CompoundTag data) {
|
||||||
final CompoundTag heightmap = MappingDataLoader.loadNBT("heightmap-1.14.nbt");
|
final CompoundTag heightmap = MappingDataLoader.loadNBT("heightmap-1.14.nbt");
|
||||||
final IntArrayTag motionBlocking = heightmap.get("motionBlocking");
|
final IntArrayTag motionBlocking = heightmap.getIntArrayTag("motionBlocking");
|
||||||
this.motionBlocking = new IntOpenHashSet(motionBlocking.getValue());
|
this.motionBlocking = new IntOpenHashSet(motionBlocking.getValue());
|
||||||
|
|
||||||
if (Via.getConfig().isNonFullBlockLightFix()) {
|
if (Via.getConfig().isNonFullBlockLightFix()) {
|
||||||
final IntArrayTag nonFullBlocks = heightmap.get("nonFullBlocks");
|
final IntArrayTag nonFullBlocks = heightmap.getIntArrayTag("nonFullBlocks");
|
||||||
this.nonFullBlocks = new IntOpenHashSet(nonFullBlocks.getValue());
|
this.nonFullBlocks = new IntOpenHashSet(nonFullBlocks.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,12 +242,10 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
if (item.tag() == null) return item;
|
if (item.tag() == null) return item;
|
||||||
|
|
||||||
// Display Lore now uses JSON
|
// Display Lore now uses JSON
|
||||||
Tag displayTag = item.tag().get("display");
|
CompoundTag display = item.tag().getCompoundTag("display");
|
||||||
if (displayTag instanceof CompoundTag) {
|
if (display != null) {
|
||||||
CompoundTag display = (CompoundTag) displayTag;
|
ListTag lore = display.getListTag("Lore");
|
||||||
Tag loreTag = display.get("Lore");
|
if (lore != null) {
|
||||||
if (loreTag instanceof ListTag) {
|
|
||||||
ListTag lore = (ListTag) loreTag;
|
|
||||||
display.put(NBT_TAG_NAME + "|Lore", new ListTag(lore.copy().getValue())); // Save old lore
|
display.put(NBT_TAG_NAME + "|Lore", new ListTag(lore.copy().getValue())); // Save old lore
|
||||||
for (Tag loreEntry : lore) {
|
for (Tag loreEntry : lore) {
|
||||||
if (loreEntry instanceof StringTag) {
|
if (loreEntry instanceof StringTag) {
|
||||||
@ -268,15 +266,13 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
if (item.tag() == null) return item;
|
if (item.tag() == null) return item;
|
||||||
|
|
||||||
// Display Name now uses JSON
|
// Display Name now uses JSON
|
||||||
Tag displayTag = item.tag().get("display");
|
CompoundTag display = item.tag().getCompoundTag("display");
|
||||||
if (displayTag instanceof CompoundTag) {
|
if (display != null) {
|
||||||
CompoundTag display = (CompoundTag) displayTag;
|
ListTag lore = display.getListTag("Lore");
|
||||||
Tag loreTag = display.get("Lore");
|
if (lore != null) {
|
||||||
if (loreTag instanceof ListTag) {
|
Tag savedLore = display.remove(NBT_TAG_NAME + "|Lore");
|
||||||
ListTag lore = (ListTag) loreTag;
|
if (savedLore instanceof ListTag) {
|
||||||
ListTag savedLore = display.remove(NBT_TAG_NAME + "|Lore");
|
display.put("Lore", new ListTag(((ListTag) savedLore).getValue()));
|
||||||
if (savedLore != null) {
|
|
||||||
display.put("Lore", new ListTag(savedLore.getValue()));
|
|
||||||
} else {
|
} else {
|
||||||
for (Tag loreEntry : lore) {
|
for (Tag loreEntry : lore) {
|
||||||
if (loreEntry instanceof StringTag) {
|
if (loreEntry instanceof StringTag) {
|
||||||
|
@ -20,7 +20,6 @@ package com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
@ -58,7 +57,7 @@ public class PlayerPackets {
|
|||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
if (tag == null) return;
|
if (tag == null) return;
|
||||||
|
|
||||||
Tag pages = tag.get("pages");
|
ListTag pages = tag.getListTag("pages");
|
||||||
|
|
||||||
// Fix for https://github.com/ViaVersion/ViaVersion/issues/2660
|
// Fix for https://github.com/ViaVersion/ViaVersion/issues/2660
|
||||||
if (pages == null) {
|
if (pages == null) {
|
||||||
@ -66,10 +65,9 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Client limit when editing a book was upped from 50 to 100 in 1.14, but some anti-exploit plugins ban with a size higher than the old client limit
|
// Client limit when editing a book was upped from 50 to 100 in 1.14, but some anti-exploit plugins ban with a size higher than the old client limit
|
||||||
if (Via.getConfig().isTruncate1_14Books() && pages instanceof ListTag) {
|
if (Via.getConfig().isTruncate1_14Books() && pages != null) {
|
||||||
ListTag listTag = (ListTag) pages;
|
if (pages.size() > 50) {
|
||||||
if (listTag.size() > 50) {
|
pages.setValue(pages.getValue().subList(0, 50));
|
||||||
listTag.setValue(listTag.getValue().subList(0, 50));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -22,6 +22,7 @@ import com.github.steveice10.opennbt.tag.builtin.LongArrayTag;
|
|||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
@ -30,13 +31,12 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
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.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_14;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_14;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
import com.viaversion.viaversion.util.CompactArrayUtil;
|
import com.viaversion.viaversion.util.CompactArrayUtil;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -23,10 +23,10 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
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.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14_4to1_14_3.ClientboundPackets1_14_4;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_14;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_15;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_15;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_14_4to1_14_3.ClientboundPackets1_14_4;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
|
|
||||||
public final class WorldPackets {
|
public final class WorldPackets {
|
||||||
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.data;
|
|||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||||
@ -39,12 +38,12 @@ public class MappingData extends MappingDataBase {
|
|||||||
dimensionRegistry = MappingDataLoader.loadNBTFromFile("dimension-registry-1.16.2.nbt");
|
dimensionRegistry = MappingDataLoader.loadNBTFromFile("dimension-registry-1.16.2.nbt");
|
||||||
|
|
||||||
// Data of each dimension
|
// Data of each dimension
|
||||||
final ListTag dimensions = ((CompoundTag) dimensionRegistry.get("minecraft:dimension_type")).get("value");
|
final ListTag dimensions = dimensionRegistry.getCompoundTag("minecraft:dimension_type").get("value");
|
||||||
for (final Tag dimension : dimensions) {
|
for (final Tag dimension : dimensions) {
|
||||||
final CompoundTag dimensionCompound = (CompoundTag) dimension;
|
final CompoundTag dimensionCompound = (CompoundTag) dimension;
|
||||||
// Copy with an empty name
|
// Copy with an empty name
|
||||||
final CompoundTag dimensionData = new CompoundTag(((CompoundTag) dimensionCompound.get("element")).getValue());
|
final CompoundTag dimensionData = dimensionCompound.getCompoundTag("element").copy();
|
||||||
dimensionDataMap.put(((StringTag) dimensionCompound.get("name")).getValue(), dimensionData);
|
dimensionDataMap.put(dimensionCompound.getStringTag("name").getValue(), dimensionData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16;
|
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -48,7 +48,6 @@ import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
|||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
import com.viaversion.viaversion.util.GsonUtil;
|
import com.viaversion.viaversion.util.GsonUtil;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -17,7 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets;
|
package com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets;
|
||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.*;
|
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.FloatTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.LongTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
|
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
|
||||||
@ -33,7 +39,6 @@ import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPacke
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.metadata.MetadataRewriter1_16To1_15_2;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.metadata.MetadataRewriter1_16To1_15_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ package com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.LongTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
@ -147,22 +146,22 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
|
|||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
|
|
||||||
if (item.identifier() == 771 && tag != null) {
|
if (item.identifier() == 771 && tag != null) {
|
||||||
Tag ownerTag = tag.get("SkullOwner");
|
CompoundTag ownerTag = tag.getCompoundTag("SkullOwner");
|
||||||
if (ownerTag instanceof CompoundTag) {
|
if (ownerTag != null) {
|
||||||
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
|
StringTag idTag = ownerTag.getStringTag("Id");
|
||||||
Tag idTag = ownerCompundTag.get("Id");
|
if (idTag != null) {
|
||||||
if (idTag instanceof StringTag) {
|
UUID id = UUID.fromString(idTag.getValue());
|
||||||
UUID id = UUID.fromString((String) idTag.getValue());
|
ownerTag.put("Id", new IntArrayTag(UUIDUtil.toIntArray(id)));
|
||||||
ownerCompundTag.put("Id", new IntArrayTag(UUIDUtil.toIntArray(id)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (item.identifier() == 759 && tag != null) {
|
} else if (item.identifier() == 759 && tag != null) {
|
||||||
Tag pages = tag.get("pages");
|
ListTag pages = tag.getListTag("pages");
|
||||||
if (pages instanceof ListTag) {
|
if (pages != null) {
|
||||||
for (Tag pageTag : (ListTag) pages) {
|
for (Tag pageTag : pages) {
|
||||||
if (!(pageTag instanceof StringTag)) {
|
if (!(pageTag instanceof StringTag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringTag page = (StringTag) pageTag;
|
StringTag page = (StringTag) pageTag;
|
||||||
page.setValue(protocol.getComponentRewriter().processText(page.getValue()).toString());
|
page.setValue(protocol.getComponentRewriter().processText(page.getValue()).toString());
|
||||||
}
|
}
|
||||||
@ -182,13 +181,12 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
|
|||||||
|
|
||||||
if (item.identifier() == 771 && item.tag() != null) {
|
if (item.identifier() == 771 && item.tag() != null) {
|
||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
Tag ownerTag = tag.get("SkullOwner");
|
CompoundTag ownerTag = tag.getCompoundTag("SkullOwner");
|
||||||
if (ownerTag instanceof CompoundTag) {
|
if (ownerTag != null) {
|
||||||
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
|
IntArrayTag idTag = ownerTag.getIntArrayTag("Id");
|
||||||
Tag idTag = ownerCompundTag.get("Id");
|
if (idTag != null) {
|
||||||
if (idTag instanceof IntArrayTag) {
|
UUID id = UUIDUtil.fromIntArray(idTag.getValue());
|
||||||
UUID id = UUIDUtil.fromIntArray((int[]) idTag.getValue());
|
ownerTag.putString("Id", id.toString());
|
||||||
ownerCompundTag.put("Id", new StringTag(id.toString()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,17 +198,19 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
|
|||||||
public static void oldToNewAttributes(Item item) {
|
public static void oldToNewAttributes(Item item) {
|
||||||
if (item.tag() == null) return;
|
if (item.tag() == null) return;
|
||||||
|
|
||||||
ListTag attributes = item.tag().get("AttributeModifiers");
|
ListTag attributes = item.tag().getListTag("AttributeModifiers");
|
||||||
if (attributes == null) return;
|
if (attributes == null) return;
|
||||||
|
|
||||||
for (Tag tag : attributes) {
|
for (Tag tag : attributes) {
|
||||||
|
if (!(tag instanceof CompoundTag)) continue;
|
||||||
|
|
||||||
CompoundTag attribute = (CompoundTag) tag;
|
CompoundTag attribute = (CompoundTag) tag;
|
||||||
rewriteAttributeName(attribute, "AttributeName", false);
|
rewriteAttributeName(attribute, "AttributeName", false);
|
||||||
rewriteAttributeName(attribute, "Name", false);
|
rewriteAttributeName(attribute, "Name", false);
|
||||||
Tag leastTag = attribute.get("UUIDLeast");
|
NumberTag leastTag = attribute.getNumberTag("UUIDLeast");
|
||||||
if (leastTag != null) {
|
NumberTag mostTag = attribute.getNumberTag("UUIDMost");
|
||||||
Tag mostTag = attribute.get("UUIDMost");
|
if (leastTag != null && mostTag != null) {
|
||||||
int[] uuidIntArray = UUIDUtil.toIntArray(((NumberTag) leastTag).asLong(), ((NumberTag) mostTag).asLong());
|
int[] uuidIntArray = UUIDUtil.toIntArray(leastTag.asLong(), mostTag.asLong());
|
||||||
attribute.put("UUID", new IntArrayTag(uuidIntArray));
|
attribute.put("UUID", new IntArrayTag(uuidIntArray));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,24 +219,26 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
|
|||||||
public static void newToOldAttributes(Item item) {
|
public static void newToOldAttributes(Item item) {
|
||||||
if (item.tag() == null) return;
|
if (item.tag() == null) return;
|
||||||
|
|
||||||
ListTag attributes = item.tag().get("AttributeModifiers");
|
ListTag attributes = item.tag().getListTag("AttributeModifiers");
|
||||||
if (attributes == null) return;
|
if (attributes == null) return;
|
||||||
|
|
||||||
for (Tag tag : attributes) {
|
for (Tag tag : attributes) {
|
||||||
|
if (!(tag instanceof CompoundTag)) continue;
|
||||||
|
|
||||||
CompoundTag attribute = (CompoundTag) tag;
|
CompoundTag attribute = (CompoundTag) tag;
|
||||||
rewriteAttributeName(attribute, "AttributeName", true);
|
rewriteAttributeName(attribute, "AttributeName", true);
|
||||||
rewriteAttributeName(attribute, "Name", true);
|
rewriteAttributeName(attribute, "Name", true);
|
||||||
IntArrayTag uuidTag = attribute.get("UUID");
|
IntArrayTag uuidTag = attribute.getIntArrayTag("UUID");
|
||||||
if (uuidTag != null && uuidTag.getValue().length == 4) {
|
if (uuidTag != null && uuidTag.getValue().length == 4) {
|
||||||
UUID uuid = UUIDUtil.fromIntArray(uuidTag.getValue());
|
UUID uuid = UUIDUtil.fromIntArray(uuidTag.getValue());
|
||||||
attribute.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
|
attribute.putLong("UUIDLeast", uuid.getLeastSignificantBits());
|
||||||
attribute.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
|
attribute.putLong("UUIDMost", uuid.getMostSignificantBits());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rewriteAttributeName(CompoundTag compoundTag, String entryName, boolean inverse) {
|
public static void rewriteAttributeName(CompoundTag compoundTag, String entryName, boolean inverse) {
|
||||||
StringTag attributeNameTag = compoundTag.get(entryName);
|
StringTag attributeNameTag = compoundTag.getStringTag(entryName);
|
||||||
if (attributeNameTag == null) return;
|
if (attributeNameTag == null) return;
|
||||||
|
|
||||||
String attributeName = attributeNameTag.getValue();
|
String attributeName = attributeNameTag.getValue();
|
||||||
|
@ -29,10 +29,10 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
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.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_15;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_15;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
import com.viaversion.viaversion.util.CompactArrayUtil;
|
import com.viaversion.viaversion.util.CompactArrayUtil;
|
||||||
import com.viaversion.viaversion.util.UUIDUtil;
|
import com.viaversion.viaversion.util.UUIDUtil;
|
||||||
@ -102,7 +102,7 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void handleBlockEntity(Protocol1_16To1_15_2 protocol, CompoundTag compoundTag) {
|
private static void handleBlockEntity(Protocol1_16To1_15_2 protocol, CompoundTag compoundTag) {
|
||||||
StringTag idTag = compoundTag.get("id");
|
StringTag idTag = compoundTag.getStringTag("id");
|
||||||
if (idTag == null) return;
|
if (idTag == null) return;
|
||||||
|
|
||||||
String id = idTag.getValue();
|
String id = idTag.getValue();
|
||||||
@ -113,11 +113,11 @@ public class WorldPackets {
|
|||||||
// target_uuid -> Target
|
// target_uuid -> Target
|
||||||
UUID targetUuid = UUID.fromString((String) targetUuidTag.getValue());
|
UUID targetUuid = UUID.fromString((String) targetUuidTag.getValue());
|
||||||
compoundTag.put("Target", new IntArrayTag(UUIDUtil.toIntArray(targetUuid)));
|
compoundTag.put("Target", new IntArrayTag(UUIDUtil.toIntArray(targetUuid)));
|
||||||
} else if (id.equals("minecraft:skull") && compoundTag.get("Owner") instanceof CompoundTag) {
|
} else if (id.equals("minecraft:skull") && compoundTag.getCompoundTag("Owner") != null) {
|
||||||
CompoundTag ownerTag = compoundTag.remove("Owner");
|
CompoundTag ownerTag = compoundTag.remove("Owner");
|
||||||
StringTag ownerUuidTag = ownerTag.remove("Id");
|
Tag ownerUuidTag = ownerTag.remove("Id");
|
||||||
if (ownerUuidTag != null) {
|
if (ownerUuidTag instanceof StringTag) {
|
||||||
UUID ownerUuid = UUID.fromString(ownerUuidTag.getValue());
|
UUID ownerUuid = UUID.fromString(((StringTag) ownerUuidTag).getValue());
|
||||||
ownerTag.put("Id", new IntArrayTag(UUIDUtil.toIntArray(ownerUuid)));
|
ownerTag.put("Id", new IntArrayTag(UUIDUtil.toIntArray(ownerUuid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,21 +129,18 @@ public class WorldPackets {
|
|||||||
compoundTag.put("SkullOwner", skullOwnerTag);
|
compoundTag.put("SkullOwner", skullOwnerTag);
|
||||||
} else if (id.equals("minecraft:sign")) {
|
} else if (id.equals("minecraft:sign")) {
|
||||||
for (int i = 1; i <= 4; i++) {
|
for (int i = 1; i <= 4; i++) {
|
||||||
Tag line = compoundTag.get("Text" + i);
|
StringTag line = compoundTag.getStringTag("Text" + i);
|
||||||
if (line instanceof StringTag) {
|
if (line != null) {
|
||||||
JsonElement text = protocol.getComponentRewriter().processText(((StringTag) line).getValue());
|
JsonElement text = protocol.getComponentRewriter().processText(line.getValue());
|
||||||
compoundTag.put("Text" + i, new StringTag(text.toString()));
|
compoundTag.putString("Text" + i, text.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (id.equals("minecraft:mob_spawner")) {
|
} else if (id.equals("minecraft:mob_spawner")) {
|
||||||
Tag spawnDataTag = compoundTag.get("SpawnData");
|
CompoundTag spawnDataTag = compoundTag.getCompoundTag("SpawnData");
|
||||||
if (spawnDataTag instanceof CompoundTag) {
|
if (spawnDataTag != null) {
|
||||||
Tag spawnDataIdTag = ((CompoundTag) spawnDataTag).get("id");
|
StringTag spawnDataIdTag = spawnDataTag.getStringTag("id");
|
||||||
if (spawnDataIdTag instanceof StringTag) {
|
if (spawnDataIdTag != null && spawnDataIdTag.getValue().equals("minecraft:zombie_pigman")) {
|
||||||
StringTag spawnDataIdStringTag = ((StringTag) spawnDataIdTag);
|
spawnDataIdTag.setValue("minecraft:zombified_piglin");
|
||||||
if (spawnDataIdStringTag.getValue().equals("minecraft:zombie_pigman")) {
|
|
||||||
spawnDataIdStringTag.setValue("minecraft:zombified_piglin");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets;
|
|||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
@ -135,7 +134,7 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_16_
|
|||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
item.setTag(tag = new CompoundTag());
|
item.setTag(tag = new CompoundTag());
|
||||||
}
|
}
|
||||||
if (!(tag.get("map") instanceof NumberTag)) {
|
if (tag.getNumberTag("map") == null) {
|
||||||
tag.put("map", new IntTag(0));
|
tag.put("map", new IntTag(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,11 @@ import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
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.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
|
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
|
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
|
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
@ -20,7 +20,6 @@ package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||||
@ -33,12 +32,12 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPaletteImpl;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
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.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.BlockEntityIds;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.BlockEntityIds;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.Protocol1_18To1_17_1;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.Protocol1_18To1_17_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.storage.ChunkLightStorage;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.storage.ChunkLightStorage;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
import com.viaversion.viaversion.util.MathUtil;
|
import com.viaversion.viaversion.util.MathUtil;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -107,10 +106,10 @@ public final class WorldPackets {
|
|||||||
|
|
||||||
final List<BlockEntity> blockEntities = new ArrayList<>(oldChunk.getBlockEntities().size());
|
final List<BlockEntity> blockEntities = new ArrayList<>(oldChunk.getBlockEntities().size());
|
||||||
for (final CompoundTag tag : oldChunk.getBlockEntities()) {
|
for (final CompoundTag tag : oldChunk.getBlockEntities()) {
|
||||||
final NumberTag xTag = tag.get("x");
|
final NumberTag xTag = tag.getNumberTag("x");
|
||||||
final NumberTag yTag = tag.get("y");
|
final NumberTag yTag = tag.getNumberTag("y");
|
||||||
final NumberTag zTag = tag.get("z");
|
final NumberTag zTag = tag.getNumberTag("z");
|
||||||
final StringTag idTag = tag.get("id");
|
final StringTag idTag = tag.getStringTag("id");
|
||||||
if (xTag == null || yTag == null || zTag == null || idTag == null) {
|
if (xTag == null || yTag == null || zTag == null || idTag == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -203,8 +202,8 @@ public final class WorldPackets {
|
|||||||
|
|
||||||
private static void handleSpawners(int typeId, final CompoundTag tag) {
|
private static void handleSpawners(int typeId, final CompoundTag tag) {
|
||||||
if (typeId == 8) {
|
if (typeId == 8) {
|
||||||
final Tag entity = tag.get("SpawnData");
|
final CompoundTag entity = tag.getCompoundTag("SpawnData");
|
||||||
if (entity instanceof CompoundTag) {
|
if (entity != null) {
|
||||||
final CompoundTag spawnData = new CompoundTag();
|
final CompoundTag spawnData = new CompoundTag();
|
||||||
tag.put("SpawnData", spawnData);
|
tag.put("SpawnData", spawnData);
|
||||||
spawnData.put("entity", entity);
|
spawnData.put("entity", entity);
|
||||||
|
@ -222,7 +222,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
chatTypeStorage.clear();
|
chatTypeStorage.clear();
|
||||||
|
|
||||||
final CompoundTag registry = wrapper.passthrough(Type.NAMED_COMPOUND_TAG);
|
final CompoundTag registry = wrapper.passthrough(Type.NAMED_COMPOUND_TAG);
|
||||||
final ListTag chatTypes = ((CompoundTag) registry.get("minecraft:chat_type")).get("value");
|
final ListTag chatTypes = registry.getCompoundTag("minecraft:chat_type").get("value");
|
||||||
for (final Tag chatType : chatTypes) {
|
for (final Tag chatType : chatTypes) {
|
||||||
final CompoundTag chatTypeCompound = (CompoundTag) chatType;
|
final CompoundTag chatTypeCompound = (CompoundTag) chatType;
|
||||||
final NumberTag idTag = chatTypeCompound.get("id");
|
final NumberTag idTag = chatTypeCompound.get("id");
|
||||||
@ -342,10 +342,10 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag chatData = chatType.<CompoundTag>get("element").get("chat");
|
CompoundTag chatData = chatType.getCompoundTag("element").getCompoundTag("chat");
|
||||||
boolean overlay = false;
|
boolean overlay = false;
|
||||||
if (chatData == null) {
|
if (chatData == null) {
|
||||||
chatData = chatType.<CompoundTag>get("element").get("overlay");
|
chatData = chatType.getCompoundTag("element").getCompoundTag("overlay");
|
||||||
if (chatData == null) {
|
if (chatData == null) {
|
||||||
// Either narration or something we don't know
|
// Either narration or something we don't know
|
||||||
return null;
|
return null;
|
||||||
@ -354,7 +354,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
overlay = true;
|
overlay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CompoundTag decoration = chatData.get("decoration");
|
final CompoundTag decoration = chatData.getCompoundTag("decoration");
|
||||||
if (decoration == null) {
|
if (decoration == null) {
|
||||||
return new ChatDecorationResult(message, overlay);
|
return new ChatDecorationResult(message, overlay);
|
||||||
}
|
}
|
||||||
@ -368,13 +368,13 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
@Nullable final JsonElement targetName,
|
@Nullable final JsonElement targetName,
|
||||||
final JsonElement message
|
final JsonElement message
|
||||||
) {
|
) {
|
||||||
final String translationKey = (String) tag.get("translation_key").getValue();
|
final String translationKey = tag.getStringTag("translation_key").getValue();
|
||||||
final Style style = new Style();
|
final Style style = new Style();
|
||||||
|
|
||||||
// Add the style
|
// Add the style
|
||||||
final CompoundTag styleTag = tag.get("style");
|
final CompoundTag styleTag = tag.getCompoundTag("style");
|
||||||
if (styleTag != null) {
|
if (styleTag != null) {
|
||||||
final StringTag color = styleTag.get("color");
|
final StringTag color = styleTag.getStringTag("color");
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
final TextFormatting textColor = TextFormatting.getByName(color.getValue());
|
final TextFormatting textColor = TextFormatting.getByName(color.getValue());
|
||||||
if (textColor != null) {
|
if (textColor != null) {
|
||||||
@ -383,12 +383,12 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final Map.Entry<String, TextFormatting> entry : TextFormatting.FORMATTINGS.entrySet()) {
|
for (final Map.Entry<String, TextFormatting> entry : TextFormatting.FORMATTINGS.entrySet()) {
|
||||||
final Tag formattingTag = styleTag.get(entry.getKey());
|
final NumberTag formattingTag = styleTag.getNumberTag(entry.getKey());
|
||||||
if (!(formattingTag instanceof ByteTag)) {
|
if (!(formattingTag instanceof ByteTag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean value = ((NumberTag) formattingTag).asBoolean();
|
final boolean value = formattingTag.asBoolean();
|
||||||
final TextFormatting formatting = entry.getValue();
|
final TextFormatting formatting = entry.getValue();
|
||||||
if (formatting == TextFormatting.OBFUSCATED) {
|
if (formatting == TextFormatting.OBFUSCATED) {
|
||||||
style.setObfuscated(value);
|
style.setObfuscated(value);
|
||||||
@ -405,7 +405,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the replacements
|
// Add the replacements
|
||||||
final ListTag parameters = tag.get("parameters");
|
final ListTag parameters = tag.getListTag("parameters");
|
||||||
final List<ATextComponent> arguments = new ArrayList<>();
|
final List<ATextComponent> arguments = new ArrayList<>();
|
||||||
if (parameters != null) {
|
if (parameters != null) {
|
||||||
for (final Tag element : parameters) {
|
for (final Tag element : parameters) {
|
||||||
|
@ -29,7 +29,6 @@ import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPacke
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.Protocol1_19_3To1_19_1;
|
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.Protocol1_19_3To1_19_1;
|
||||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||||
|
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ import com.viaversion.viaversion.api.minecraft.Particle;
|
|||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
@ -210,7 +209,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
|||||||
tag.put("minecraft:chat_type", CHAT_REGISTRY.copy());
|
tag.put("minecraft:chat_type", CHAT_REGISTRY.copy());
|
||||||
|
|
||||||
// Cache a whole lot of data
|
// Cache a whole lot of data
|
||||||
final ListTag dimensions = ((CompoundTag) tag.get("minecraft:dimension_type")).get("value");
|
final ListTag dimensions = tag.getCompoundTag("minecraft:dimension_type").get("value");
|
||||||
final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size());
|
final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size());
|
||||||
final Map<CompoundTag, String> dimensionsMap = new HashMap<>(dimensions.size());
|
final Map<CompoundTag, String> dimensionsMap = new HashMap<>(dimensions.size());
|
||||||
for (final Tag dimension : dimensions) {
|
for (final Tag dimension : dimensions) {
|
||||||
|
@ -24,8 +24,8 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2;
|
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19;
|
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19;
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
|
@ -36,11 +36,11 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|||||||
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.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.rewriter.RecipeRewriter1_19_4;
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.rewriter.RecipeRewriter1_19_4;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.util.PotionEffects;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.util.PotionEffects;
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||||
@ -441,14 +441,14 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final IntTag primaryEffect = tag.remove("Primary");
|
final Tag primaryEffect = tag.remove("Primary");
|
||||||
if (primaryEffect != null && primaryEffect.asInt() != 0) {
|
if (primaryEffect instanceof NumberTag && ((NumberTag) primaryEffect).asInt() != 0) {
|
||||||
tag.put("primary_effect", new StringTag(PotionEffects.idToKeyOrLuck(primaryEffect.asInt())));
|
tag.put("primary_effect", new StringTag(PotionEffects.idToKeyOrLuck(((NumberTag) primaryEffect).asInt())));
|
||||||
}
|
}
|
||||||
|
|
||||||
final IntTag secondaryEffect = tag.remove("Secondary");
|
final Tag secondaryEffect = tag.remove("Secondary");
|
||||||
if (secondaryEffect != null && secondaryEffect.asInt() != 0) {
|
if (secondaryEffect instanceof NumberTag && ((NumberTag) secondaryEffect).asInt() != 0) {
|
||||||
tag.put("secondary_effect", new StringTag(PotionEffects.idToKeyOrLuck(secondaryEffect.asInt())));
|
tag.put("secondary_effect", new StringTag(PotionEffects.idToKeyOrLuck(((NumberTag) secondaryEffect).asInt())));
|
||||||
}
|
}
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
@ -150,11 +150,11 @@ public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter<Clientboun
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePages(final CompoundTag tag, final String key) {
|
private void updatePages(final CompoundTag tag, final String key) {
|
||||||
if (!(tag.get(key) instanceof ListTag)) {
|
final ListTag pages = tag.getListTag(key);
|
||||||
|
if (pages == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ListTag pages = tag.get(key);
|
|
||||||
for (final Tag pageTag : pages) {
|
for (final Tag pageTag : pages) {
|
||||||
if (!(pageTag instanceof StringTag)) {
|
if (!(pageTag instanceof StringTag)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -22,6 +22,7 @@ import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
@ -32,10 +33,9 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_1;
|
||||||
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.viaversion.protocols.protocol1_9_3to1_9_1_2.chunks.FakeTileEntity;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.chunks.FakeTileEntity;
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_1;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -25,7 +25,6 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
|||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -162,10 +161,10 @@ public class ItemRewriter {
|
|||||||
if (item.identifier() == 383 && item.data() == 0) { // Monster Egg
|
if (item.identifier() == 383 && item.data() == 0) { // Monster Egg
|
||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
int data = 0;
|
int data = 0;
|
||||||
if (tag != null && tag.get("EntityTag") instanceof CompoundTag) {
|
if (tag != null && tag.getCompoundTag("EntityTag") != null) {
|
||||||
CompoundTag entityTag = tag.get("EntityTag");
|
CompoundTag entityTag = tag.getCompoundTag("EntityTag");
|
||||||
if (entityTag.get("id") instanceof StringTag) {
|
StringTag id = entityTag.getStringTag("id");
|
||||||
StringTag id = entityTag.get("id");
|
if (id != null) {
|
||||||
if (ENTITY_NAME_TO_ID.containsKey(id.getValue()))
|
if (ENTITY_NAME_TO_ID.containsKey(id.getValue()))
|
||||||
data = ENTITY_NAME_TO_ID.get(id.getValue());
|
data = ENTITY_NAME_TO_ID.get(id.getValue());
|
||||||
}
|
}
|
||||||
@ -177,8 +176,8 @@ public class ItemRewriter {
|
|||||||
if (item.identifier() == 373) { // Potion
|
if (item.identifier() == 373) { // Potion
|
||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
int data = 0;
|
int data = 0;
|
||||||
if (tag != null && tag.get("Potion") instanceof StringTag) {
|
if (tag != null && tag.getStringTag("Potion") != null) {
|
||||||
StringTag potion = tag.get("Potion");
|
StringTag potion = tag.getStringTag("Potion");
|
||||||
String potionName = Key.stripMinecraftNamespace(potion.getValue());
|
String potionName = Key.stripMinecraftNamespace(potion.getValue());
|
||||||
if (POTION_NAME_TO_ID.containsKey(potionName)) {
|
if (POTION_NAME_TO_ID.containsKey(potionName)) {
|
||||||
data = POTION_NAME_TO_ID.get(potionName);
|
data = POTION_NAME_TO_ID.get(potionName);
|
||||||
@ -193,8 +192,8 @@ public class ItemRewriter {
|
|||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
int data = 0;
|
int data = 0;
|
||||||
item.setIdentifier(373); // Potion
|
item.setIdentifier(373); // Potion
|
||||||
if (tag != null && tag.get("Potion") instanceof StringTag) {
|
if (tag != null && tag.getStringTag("Potion") != null) {
|
||||||
StringTag potion = tag.get("Potion");
|
StringTag potion = tag.getStringTag("Potion");
|
||||||
String potionName = Key.stripMinecraftNamespace(potion.getValue());
|
String potionName = Key.stripMinecraftNamespace(potion.getValue());
|
||||||
if (POTION_NAME_TO_ID.containsKey(potionName)) {
|
if (POTION_NAME_TO_ID.containsKey(potionName)) {
|
||||||
data = POTION_NAME_TO_ID.get(potionName) + 8192;
|
data = POTION_NAME_TO_ID.get(potionName) + 8192;
|
||||||
@ -220,11 +219,13 @@ public class ItemRewriter {
|
|||||||
if (id != 387) {
|
if (id != 387) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
ListTag pages = tag.get("pages");
|
ListTag pages = tag.getListTag("pages");
|
||||||
if (pages == null) { // is this even possible?
|
if (pages == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < pages.size(); i++) {
|
for (int i = 0; i < pages.size(); i++) {
|
||||||
Tag pageTag = pages.get(i);
|
Tag pageTag = pages.get(i);
|
||||||
if (!(pageTag instanceof StringTag)) {
|
if (!(pageTag instanceof StringTag)) {
|
||||||
@ -287,7 +288,8 @@ public class ItemRewriter {
|
|||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
tag = new CompoundTag();
|
tag = new CompoundTag();
|
||||||
}
|
}
|
||||||
ListTag pages = tag.get("pages");
|
|
||||||
|
ListTag pages = tag.getListTag("pages");
|
||||||
if (pages == null) {
|
if (pages == null) {
|
||||||
pages = new ListTag(Collections.singletonList(new StringTag(Protocol1_9To1_8.fixJson("").toString())));
|
pages = new ListTag(Collections.singletonList(new StringTag(Protocol1_9To1_8.fixJson("").toString())));
|
||||||
tag.put("pages", pages);
|
tag.put("pages", pages);
|
||||||
|
@ -32,9 +32,23 @@ import com.viaversion.viaversion.api.type.Type;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.*;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.EntityPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.*;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.InventoryPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.*;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.PlayerPackets;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.SpawnPackets;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.WorldPackets;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.BossBarProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CommandBlockProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CompressionProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.EntityIdProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MainHandProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.ClientChunks;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.CommandBlockStorage;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.InventoryTracker;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
||||||
import com.viaversion.viaversion.util.GsonUtil;
|
import com.viaversion.viaversion.util.GsonUtil;
|
||||||
|
|
||||||
public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, ClientboundPackets1_9, ServerboundPackets1_8, ServerboundPackets1_9> {
|
public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, ClientboundPackets1_9, ServerboundPackets1_8, ServerboundPackets1_9> {
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata;
|
package com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_8;
|
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_8;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||||
import com.viaversion.viaversion.util.Pair;
|
import com.viaversion.viaversion.util.Pair;
|
||||||
|
@ -36,8 +36,11 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRew
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
||||||
import com.viaversion.viaversion.util.Pair;
|
import com.viaversion.viaversion.util.Pair;
|
||||||
import com.viaversion.viaversion.util.Triple;
|
import com.viaversion.viaversion.util.Triple;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class EntityPackets {
|
public class EntityPackets {
|
||||||
public static final ValueTransformer<Byte, Short> toNewShort = new ValueTransformer<Byte, Short>(Type.SHORT) {
|
public static final ValueTransformer<Byte, Short> toNewShort = new ValueTransformer<Byte, Short>(Type.SHORT) {
|
||||||
|
@ -21,6 +21,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
@ -30,10 +31,11 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
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.Type;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.BulkChunkType1_8;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_8;
|
||||||
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_1;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ItemRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ItemRewriter;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
@ -43,8 +45,6 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.sounds.Effect;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.sounds.SoundEffect;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.sounds.SoundEffect;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.ClientChunks;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.ClientChunks;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_8;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.BulkChunkType1_8;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -215,14 +215,15 @@ public class WorldPackets {
|
|||||||
if (action == 1) { // Update Spawner
|
if (action == 1) { // Update Spawner
|
||||||
CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
if (tag.contains("EntityId")) {
|
StringTag entityId = tag.getStringTag("EntityId");
|
||||||
String entity = (String) tag.get("EntityId").getValue();
|
if (entityId != null) {
|
||||||
|
String entity = entityId.getValue();
|
||||||
CompoundTag spawn = new CompoundTag();
|
CompoundTag spawn = new CompoundTag();
|
||||||
spawn.put("id", new StringTag(entity));
|
spawn.putString("id", entity);
|
||||||
tag.put("SpawnData", spawn);
|
tag.put("SpawnData", spawn);
|
||||||
} else { // EntityID does not exist
|
} else { // EntityID does not exist
|
||||||
CompoundTag spawn = new CompoundTag();
|
CompoundTag spawn = new CompoundTag();
|
||||||
spawn.put("id", new StringTag("AreaEffectCloud")); //Make spawners show up as empty when no EntityId is given.
|
spawn.putString("id", "AreaEffectCloud"); //Make spawners show up as empty when no EntityId is given.
|
||||||
tag.put("SpawnData", spawn);
|
tag.put("SpawnData", spawn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import com.viaversion.viaversion.api.type.Type;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class MovementTransmitterProvider implements Provider {
|
public class MovementTransmitterProvider implements Provider {
|
||||||
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_9to1_8.storage;
|
|||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ClientChunks implements StorableObject {
|
public class ClientChunks implements StorableObject {
|
||||||
|
@ -267,24 +267,24 @@ public class ComponentRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void processCompoundTag(final CompoundTag tag) {
|
protected void processCompoundTag(final CompoundTag tag) {
|
||||||
final Tag translate = tag.get("translate");
|
final StringTag translate = tag.getStringTag("translate");
|
||||||
if (translate instanceof StringTag) {
|
if (translate != null) {
|
||||||
handleTranslate(tag, ((StringTag) translate));
|
handleTranslate(tag, translate);
|
||||||
|
|
||||||
final Tag with = tag.get("with");
|
final ListTag with = tag.getListTag("with");
|
||||||
if (with instanceof ListTag) {
|
if (with != null) {
|
||||||
processListTag((ListTag) with);
|
processListTag(with);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Tag extra = tag.get("extra");
|
final ListTag extra = tag.getListTag("extra");
|
||||||
if (extra instanceof ListTag) {
|
if (extra != null) {
|
||||||
processListTag((ListTag) extra);
|
processListTag(extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Tag hoverEvent = tag.get("hoverEvent");
|
final CompoundTag hoverEvent = tag.getCompoundTag("hoverEvent");
|
||||||
if (hoverEvent instanceof CompoundTag) {
|
if (hoverEvent != null) {
|
||||||
handleHoverEvent((CompoundTag) hoverEvent);
|
handleHoverEvent(hoverEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,19 +294,19 @@ public class ComponentRewriter<C extends ClientboundPacketType> {
|
|||||||
|
|
||||||
protected void handleHoverEvent(final CompoundTag hoverEventTag) {
|
protected void handleHoverEvent(final CompoundTag hoverEventTag) {
|
||||||
// To override if needed (don't forget to call super)
|
// To override if needed (don't forget to call super)
|
||||||
final Tag actionTag = hoverEventTag.get("action");
|
final StringTag actionTag = hoverEventTag.getStringTag("action");
|
||||||
if (!(actionTag instanceof StringTag)) {
|
if (actionTag == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String action = ((StringTag) actionTag).getValue();
|
final String action = actionTag.getValue();
|
||||||
if (action.equals("show_text")) {
|
if (action.equals("show_text")) {
|
||||||
final Tag value = hoverEventTag.get("value");
|
final Tag value = hoverEventTag.get("value");
|
||||||
processTag(value != null ? value : hoverEventTag.get("contents"));
|
processTag(value != null ? value : hoverEventTag.get("contents"));
|
||||||
} else if (action.equals("show_entity")) {
|
} else if (action.equals("show_entity")) {
|
||||||
final Tag contents = hoverEventTag.get("contents");
|
final CompoundTag contents = hoverEventTag.getCompoundTag("contents");
|
||||||
if (contents instanceof CompoundTag) {
|
if (contents != null) {
|
||||||
processTag(((CompoundTag) contents).get("name"));
|
processTag(contents.get("name"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,9 @@
|
|||||||
package com.viaversion.viaversion.rewriter;
|
package com.viaversion.viaversion.rewriter;
|
||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
@ -393,17 +392,17 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
EntityTracker tracker = tracker(wrapper.user());
|
EntityTracker tracker = tracker(wrapper.user());
|
||||||
|
|
||||||
CompoundTag registryData = wrapper.get(Type.NAMED_COMPOUND_TAG, nbtIndex);
|
CompoundTag registryData = wrapper.get(Type.NAMED_COMPOUND_TAG, nbtIndex);
|
||||||
Tag height = registryData.get("height");
|
NumberTag height = registryData.getNumberTag("height");
|
||||||
if (height instanceof IntTag) {
|
if (height != null) {
|
||||||
int blockHeight = ((IntTag) height).asInt();
|
int blockHeight = height.asInt();
|
||||||
tracker.setCurrentWorldSectionHeight(blockHeight >> 4);
|
tracker.setCurrentWorldSectionHeight(blockHeight >> 4);
|
||||||
} else {
|
} else {
|
||||||
Via.getPlatform().getLogger().warning("Height missing in dimension data: " + registryData);
|
Via.getPlatform().getLogger().warning("Height missing in dimension data: " + registryData);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag minY = registryData.get("min_y");
|
NumberTag minY = registryData.getNumberTag("min_y");
|
||||||
if (minY instanceof IntTag) {
|
if (minY != null) {
|
||||||
tracker.setCurrentMinY(((IntTag) minY).asInt());
|
tracker.setCurrentMinY(minY.asInt());
|
||||||
} else {
|
} else {
|
||||||
Via.getPlatform().getLogger().warning("Min Y missing in dimension data: " + registryData);
|
Via.getPlatform().getLogger().warning("Min Y missing in dimension data: " + registryData);
|
||||||
}
|
}
|
||||||
@ -466,12 +465,12 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
* Caches dimension data, later used to get height values and other important info.
|
* Caches dimension data, later used to get height values and other important info.
|
||||||
*/
|
*/
|
||||||
public void cacheDimensionData(final UserConnection connection, final CompoundTag registry) {
|
public void cacheDimensionData(final UserConnection connection, final CompoundTag registry) {
|
||||||
final ListTag dimensions = ((CompoundTag) registry.get("minecraft:dimension_type")).get("value");
|
final ListTag dimensions = registry.getCompoundTag("minecraft:dimension_type").get("value");
|
||||||
final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size());
|
final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size());
|
||||||
for (final Tag dimension : dimensions) {
|
for (final Tag dimension : dimensions) {
|
||||||
final CompoundTag dimensionCompound = (CompoundTag) dimension;
|
final CompoundTag dimensionCompound = (CompoundTag) dimension;
|
||||||
final CompoundTag element = dimensionCompound.get("element");
|
final CompoundTag element = dimensionCompound.get("element");
|
||||||
final String name = (String) dimensionCompound.get("name").getValue();
|
final String name = dimensionCompound.getStringTag("name").getValue();
|
||||||
dimensionDataMap.put(name, new DimensionDataImpl(element));
|
dimensionDataMap.put(name, new DimensionDataImpl(element));
|
||||||
}
|
}
|
||||||
tracker(connection).setDimensions(dimensionDataMap);
|
tracker(connection).setDimensions(dimensionDataMap);
|
||||||
|
@ -21,9 +21,8 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.data.entity.TrackedEntity;
|
import com.viaversion.viaversion.api.data.entity.TrackedEntity;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public interface MetaHandlerEvent {
|
public interface MetaHandlerEvent {
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.util.GsonUtil;
|
import com.viaversion.viaversion.util.GsonUtil;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@ -29,7 +28,6 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public final class UpdateUtil {
|
public final class UpdateUtil {
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.common.entities;
|
package com.viaversion.viaversion.common.entities;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
|
||||||
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.minecraft.entities.EntityTypes1_17;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -5,7 +5,7 @@ metadata.format.version = "1.1"
|
|||||||
gson = "2.10.1"
|
gson = "2.10.1"
|
||||||
fastutil = "8.5.12"
|
fastutil = "8.5.12"
|
||||||
flare = "2.0.1"
|
flare = "2.0.1"
|
||||||
vianbt = "4.0.1"
|
vianbt = "4.2.0"
|
||||||
mcstructs = "2.4.2-SNAPSHOT"
|
mcstructs = "2.4.2-SNAPSHOT"
|
||||||
|
|
||||||
# Common provided
|
# Common provided
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren