From b58956193213352abd213f20702b1b2da38d5d41 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Mon, 15 Mar 2021 10:28:29 +0100 Subject: [PATCH] More primitive tag calls --- .../protocol1_13to1_12_2/packets/InventoryPackets.java | 2 +- .../protocol1_13to1_12_2/packets/WorldPackets.java | 7 ++++--- .../providers/blockentities/BannerHandler.java | 4 ++-- .../providers/blockentities/SkullHandler.java | 4 ++-- .../protocol1_9_1_2to1_9_3_4/chunks/BlockEntity.java | 7 ++++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java index 9d927c183..388aacc78 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java @@ -479,7 +479,7 @@ public class InventoryPackets { if (tag != null) { // Check for valid tag 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 tag.remove(NBT_TAG_NAME); gotRawIdFromTag = true; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java index 30943fe06..05a3d542e 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java @@ -1,6 +1,7 @@ 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.NumberTag; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; import us.myles.ViaVersion.api.PacketWrapper; @@ -426,9 +427,9 @@ public class WorldPackets { for (CompoundTag tag : chunk.getBlockEntities()) { int newId = provider.transform(wrapper.user(), null, tag, false); if (newId != -1) { - int x = (int) tag.get("x").getValue(); - int y = (int) tag.get("y").getValue(); - int z = (int) tag.get("z").getValue(); + int x = ((NumberTag) tag.get("x")).asInt(); + int y = ((NumberTag) tag.get("y")).asInt(); + int z = ((NumberTag) tag.get("z")).asInt(); Position position = new Position(x, (short) y, z); // Store the replacement blocks for blockupdates diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/BannerHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/BannerHandler.java index b40d666c9..18f621628 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/BannerHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/BannerHandler.java @@ -61,7 +61,7 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler { return blockId; } - private long getLong(Tag tag) { - return ((Integer) tag.getValue()).longValue(); + private long getLong(NumberTag tag) { + return tag.asLong(); } } \ No newline at end of file diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/SkullHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/SkullHandler.java index b805dda40..56412a270 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/SkullHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/SkullHandler.java @@ -40,7 +40,7 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler { return id; } - private long getLong(Tag tag) { - return ((Integer) tag.getValue()).longValue(); + private long getLong(NumberTag tag) { + return tag.asLong(); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/chunks/BlockEntity.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/chunks/BlockEntity.java index dbbcf6b84..ace9d85bc 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/chunks/BlockEntity.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/chunks/BlockEntity.java @@ -1,6 +1,7 @@ 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.NumberTag; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.UserConnection; @@ -41,9 +42,9 @@ public class BlockEntity { if (newId == -1) continue; - int x = (int) tag.get("x").getValue(); - int y = (int) tag.get("y").getValue(); - int z = (int) tag.get("z").getValue(); + int x = ((NumberTag) tag.get("x")).asInt(); + int y = ((NumberTag) tag.get("y")).asInt(); + int z = ((NumberTag) tag.get("z")).asInt(); Position pos = new Position(x, (short) y, z);