More primitive tag calls

This commit is contained in:
KennyTV 2021-03-15 10:28:29 +01:00 committed by Nassim
parent 388eb73782
commit b589561932
5 changed files with 13 additions and 11 deletions

View File

@ -479,7 +479,7 @@ public class InventoryPackets {
if (tag != null) { if (tag != null) {
// Check for valid tag // Check for valid tag
if (tag.get(NBT_TAG_NAME) instanceof IntTag) { if (tag.get(NBT_TAG_NAME) instanceof IntTag) {
rawId = (Integer) tag.get(NBT_TAG_NAME).getValue(); rawId = ((NumberTag) tag.get(NBT_TAG_NAME)).asInt();
// Remove the tag // Remove the tag
tag.remove(NBT_TAG_NAME); tag.remove(NBT_TAG_NAME);
gotRawIdFromTag = true; gotRawIdFromTag = true;

View File

@ -1,6 +1,7 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets; package us.myles.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 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 us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
@ -426,9 +427,9 @@ public class WorldPackets {
for (CompoundTag tag : chunk.getBlockEntities()) { for (CompoundTag tag : chunk.getBlockEntities()) {
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 = (int) tag.get("x").getValue(); int x = ((NumberTag) tag.get("x")).asInt();
int y = (int) tag.get("y").getValue(); int y = ((NumberTag) tag.get("y")).asInt();
int z = (int) tag.get("z").getValue(); int z = ((NumberTag) tag.get("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

View File

@ -61,7 +61,7 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
return blockId; return blockId;
} }
private long getLong(Tag tag) { private long getLong(NumberTag tag) {
return ((Integer) tag.getValue()).longValue(); return tag.asLong();
} }
} }

View File

@ -40,7 +40,7 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
return id; return id;
} }
private long getLong(Tag tag) { private long getLong(NumberTag tag) {
return ((Integer) tag.getValue()).longValue(); return tag.asLong();
} }
} }

View File

@ -1,6 +1,7 @@
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks; package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks;
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 us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
@ -41,9 +42,9 @@ public class BlockEntity {
if (newId == -1) if (newId == -1)
continue; continue;
int x = (int) tag.get("x").getValue(); int x = ((NumberTag) tag.get("x")).asInt();
int y = (int) tag.get("y").getValue(); int y = ((NumberTag) tag.get("y")).asInt();
int z = (int) tag.get("z").getValue(); int z = ((NumberTag) tag.get("z")).asInt();
Position pos = new Position(x, (short) y, z); Position pos = new Position(x, (short) y, z);