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) {
// 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;

View File

@ -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

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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);