diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/BlockListener.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/BlockListener.java index 0523a409d..613ac2034 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/BlockListener.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/BlockListener.java @@ -22,7 +22,7 @@ public class BlockListener extends ViaBukkitListener { Block b = e.getBlockPlaced(); getUserConnection(e.getPlayer()) .get(EntityTracker1_9.class) - .addBlockInteraction(new Position((long) b.getX(), (long) b.getY(), (long) b.getZ())); + .addBlockInteraction(new Position(b.getX(), (short) b.getY(), b.getZ())); } } } diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java index 4154ad0c1..0acf86965 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java @@ -34,7 +34,7 @@ public class HandItemCache extends BukkitRunnable { } public static Item convert(ItemStack itemInHand) { - if (itemInHand == null) return new Item((short) 0, (byte) 0, (short) 0, null); - return new Item((short) itemInHand.getTypeId(), (byte) itemInHand.getAmount(), itemInHand.getDurability(), null); + if (itemInHand == null) return new Item(0, (byte) 0, (short) 0, null); + return new Item(itemInHand.getTypeId(), (byte) itemInHand.getAmount(), itemInHand.getDurability(), null); } } diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitBlockConnectionProvider.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitBlockConnectionProvider.java index 7d072ad6e..929771696 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitBlockConnectionProvider.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitBlockConnectionProvider.java @@ -16,16 +16,16 @@ public class BukkitBlockConnectionProvider extends BlockConnectionProvider { private Chunk lastChunk; @Override - public int getWorldBlockData(UserConnection user, Position position) { + public int getWorldBlockData(UserConnection user, int bx, int by, int bz) { UUID uuid = user.get(ProtocolInfo.class).getUuid(); Player player = Bukkit.getPlayer(uuid); if (player != null) { World world = player.getWorld(); - int x = position.getPosX() >> 4; - int z = position.getPosZ() >> 4; + int x = bx >> 4; + int z = bx >> 4; if (world.isChunkLoaded(x, z)) { Chunk c = getChunk(world, x, z); - Block b = c.getBlock(position.getPosX(), position.getPosY(), position.getPosZ()); + Block b = c.getBlock(bx, by, bz); return b.getTypeId() << 4 | b.getData(); } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/Position.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/Position.java index a9dec12b3..f93b16199 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/Position.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/Position.java @@ -10,59 +10,22 @@ import lombok.ToString; @ToString @EqualsAndHashCode public class Position { - private int posX; - private short posY; - private int posZ; - - @Deprecated - public Position(Long x, Long y, Long z) { - this.posX = x.intValue(); - this.posY = y.shortValue(); - this.posZ = z.intValue(); - } + private int x; + private short y; + private int z; public Position(Position toCopy) { - this(toCopy.getPosX(), toCopy.getPosY(), toCopy.getPosZ()); - } - - @Deprecated - public void setX(Long x) { - this.posX = x.intValue(); - } - - @Deprecated - public void setY(Long y) { - this.posY = y.shortValue(); - } - - @Deprecated - public void setZ(Long z) { - this.posZ = z.intValue(); - } - - @Deprecated - public Long getX() { - return (long) this.posX; - } - - @Deprecated - public Long getY() { - return (long) this.posY; - } - - @Deprecated - public Long getZ() { - return (long) this.posZ; + this(toCopy.getX(), toCopy.getY(), toCopy.getZ()); } public Position getRelative(BlockFace face) { - return new Position(posX + face.getModX(), (short) (posY + face.getModY()), posZ + face.getModZ()); + return new Position(x + face.getModX(), (short) (y + face.getModY()), z + face.getModZ()); } public Position shift(BlockFace face) { - this.posX += face.getModX(); - this.posY += face.getModY(); - this.posZ += face.getModZ(); + this.x += face.getModX(); + this.y += face.getModY(); + this.z += face.getModZ(); return this; } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/item/Item.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/item/Item.java index be2e260f8..889d29f0e 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/item/Item.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/item/Item.java @@ -17,24 +17,6 @@ public class Item { private short data; private CompoundTag tag; - @Deprecated - public short getId() { - return (short) identifier; - } - - @Deprecated - public void setId(short id) { - identifier = id; - } - - @Deprecated - public Item(short id, byte amount, short data, CompoundTag tag) { - this.identifier = id; - this.amount = amount; - this.data = data; - this.tag = tag; - } - public Item(Item toCopy) { this(toCopy.getIdentifier(), toCopy.getAmount(), toCopy.getData(), toCopy.getTag()); } diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/Position1_14Type.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/Position1_14Type.java index f7fda5298..0dfa6e437 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/Position1_14Type.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/Position1_14Type.java @@ -22,8 +22,8 @@ public class Position1_14Type extends Type { @Override public void write(ByteBuf buffer, Position object) { - buffer.writeLong((((long) object.getPosX() & 0x3ffffff) << 38) - | (object.getPosY() & 0xfff) - | ((object.getPosZ() & 0x3ffffff) << 12)); + buffer.writeLong((((long) object.getX() & 0x3ffffff) << 38) + | (object.getY() & 0xfff) + | ((object.getZ() & 0x3ffffff) << 12)); } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/PositionType.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/PositionType.java index 8857579fe..9606c4bb7 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/PositionType.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/PositionType.java @@ -22,8 +22,8 @@ public class PositionType extends Type { @Override public void write(ByteBuf buffer, Position object) { - buffer.writeLong((((long) object.getPosX() & 0x3ffffff) << 38) - | ((object.getPosY() & 0xfff) << 26) - | (object.getPosZ() & 0x3ffffff)); + buffer.writeLong((((long) object.getX() & 0x3ffffff) << 38) + | ((object.getY() & 0xfff) << 26) + | (object.getZ() & 0x3ffffff)); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index 280528218..f83926d5f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -47,9 +47,9 @@ public class Protocol1_13To1_12_2 extends Protocol { @Override public void handle(PacketWrapper wrapper) throws Exception { Position position = wrapper.read(Type.POSITION); - wrapper.write(Type.INT, position.getPosX()); - wrapper.write(Type.INT, (int) position.getPosY()); - wrapper.write(Type.INT, position.getPosZ()); + wrapper.write(Type.INT, position.getX()); + wrapper.write(Type.INT, (int) position.getY()); + wrapper.write(Type.INT, position.getZ()); } }; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java index 6526ccf59..41ac95c1b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java @@ -31,7 +31,7 @@ public class ConnectionData { BlockConnectionProvider connectionProvider = Via.getManager().getProviders().get(BlockConnectionProvider.class); for (BlockFace face : BlockFace.values()) { Position pos = position.getRelative(face); - int blockState = connectionProvider.getBlockdata(user, pos); + int blockState = connectionProvider.getBlockData(user, pos.getX(), pos.getY(), pos.getZ()); ConnectionHandler handler = connectionHandlerMap.get(blockState); if (handler == null) continue; @@ -124,24 +124,24 @@ public class ConnectionData { } public static void updateBlock(UserConnection user, Position pos, List records) { - int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, pos); + int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockData(user, pos.getX(), pos.getY(), pos.getZ()); ConnectionHandler handler = getConnectionHandler(blockState); if (handler == null) return; int newBlockState = handler.connect(user, pos, blockState); - records.add(new BlockChangeRecord((short) (((pos.getPosX() & 0xF) << 4) | (pos.getPosZ() & 0xF)), pos.getPosY(), newBlockState)); + records.add(new BlockChangeRecord((short) (((pos.getX() & 0xF) << 4) | (pos.getZ() & 0xF)), pos.getY(), newBlockState)); } public static BlockConnectionProvider getProvider() { return Via.getManager().getProviders().get(BlockConnectionProvider.class); } - public static void updateBlockStorage(UserConnection userConnection, Position position, int blockState) { + public static void updateBlockStorage(UserConnection userConnection, int x, int y, int z, int blockState) { if (!needStoreBlocks()) return; if (ConnectionData.isWelcome(blockState)) { - ConnectionData.getProvider().storeBlock(userConnection, position, blockState); + ConnectionData.getProvider().storeBlock(userConnection, x, y, z, blockState); } else { - ConnectionData.getProvider().removeBlock(userConnection, position); + ConnectionData.getProvider().removeBlock(userConnection, x, y, z); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionHandler.java index ccc27b600..e017bce73 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionHandler.java @@ -9,7 +9,7 @@ public abstract class ConnectionHandler { public abstract int connect(UserConnection user, Position position, int blockState); public int getBlockData(UserConnection user, Position position) { - return Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, position); + return Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockData(user, position.getX(), position.getY(), position.getZ()); } public boolean canConnect(int id) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/providers/BlockConnectionProvider.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/providers/BlockConnectionProvider.java index 26330d7d9..447926ffe 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/providers/BlockConnectionProvider.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/providers/BlockConnectionProvider.java @@ -6,28 +6,23 @@ import us.myles.ViaVersion.api.platform.providers.Provider; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData; public class BlockConnectionProvider implements Provider { - - public int getBlockdata(UserConnection connection, Position position) { - int oldId = getWorldBlockData(connection, position); + public int getBlockData(UserConnection connection, int x, int y, int z) { + int oldId = getWorldBlockData(connection, x, y, z); return MappingData.blockMappings.getNewId(oldId); } - public int getWorldBlockData(UserConnection connection, Position position) { + public int getWorldBlockData(UserConnection connection, int x, int y, int z) { return -1; } - public void storeBlock(UserConnection connection, Position position, int blockState) { + public void storeBlock(UserConnection connection, int x, int y, int z, int blockState) { } - public void removeBlock(UserConnection connection, Position position) { + public void removeBlock(UserConnection connection, int x, int y, int z) { } - public void storeBlock(UserConnection connection, long x, long y, long z, int blockState) { - storeBlock(connection, new Position(x, y, z), blockState); - } - public void clearStorage(UserConnection connection) { } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/providers/PacketBlockConnectionProvider.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/providers/PacketBlockConnectionProvider.java index bfbd8346f..7ce459696 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/providers/PacketBlockConnectionProvider.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/providers/PacketBlockConnectionProvider.java @@ -1,24 +1,23 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers; import us.myles.ViaVersion.api.data.UserConnection; -import us.myles.ViaVersion.api.minecraft.Position; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockConnectionStorage; public class PacketBlockConnectionProvider extends BlockConnectionProvider { @Override - public void storeBlock(UserConnection connection, Position position, int blockState) { - connection.get(BlockConnectionStorage.class).store(position, blockState); + public void storeBlock(UserConnection connection, int x, int y, int z, int blockState) { + connection.get(BlockConnectionStorage.class).store(x, y, z, blockState); } @Override - public void removeBlock(UserConnection connection, Position position) { - connection.get(BlockConnectionStorage.class).remove(position); + public void removeBlock(UserConnection connection, int x, int y, int z) { + connection.get(BlockConnectionStorage.class).remove(x, y, z); } @Override - public int getBlockdata(UserConnection connection, Position position) { - return connection.get(BlockConnectionStorage.class).get(position); + public int getBlockData(UserConnection connection, int x, int y, int z) { + return connection.get(BlockConnectionStorage.class).get(x, y, z); } @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java index 4ec271722..0b3a69646 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java @@ -127,9 +127,9 @@ public class ParticleRewriter { public Particle handler(Particle particle, Integer[] data) { Item item; if (data.length == 1) - item = new Item(data[0].shortValue(), (byte) 1, (short) 0, null); + item = new Item(data[0], (byte) 1, (short) 0, null); else if (data.length == 2) - item = new Item(data[0].shortValue(), (byte) 1, data[1].shortValue(), null); + item = new Item(data[0], (byte) 1, data[1].shortValue(), null); else return particle; 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 2997f62f9..18891ff82 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 @@ -177,7 +177,7 @@ public class WorldPackets { UserConnection userConnection = wrapper.user(); if (Via.getConfig().isServersideBlockConnections()) { - ConnectionData.updateBlockStorage(userConnection, position, newId); + ConnectionData.updateBlockStorage(userConnection, position.getX(), position.getY(), position.getZ(), newId); newId = ConnectionData.connect(userConnection, position, newId); } wrapper.set(Type.VAR_INT, 0, checkStorage(wrapper.user(), position, newId)); @@ -216,7 +216,7 @@ public class WorldPackets { (record.getHorizontal() & 15) + (chunkZ * 16)); if (Via.getConfig().isServersideBlockConnections()) { - ConnectionData.updateBlockStorage(userConnection, position, newBlock); + ConnectionData.updateBlockStorage(userConnection, position.getX(), position.getY(), position.getZ(), newBlock); } record.setBlockId(checkStorage(wrapper.user(), position, newBlock)); } @@ -226,9 +226,9 @@ public class WorldPackets { int blockState = record.getBlockId(); Position position = new Position( - (long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16), - (long) record.getY(), - (long) (record.getHorizontal() & 15) + (chunkZ * 16)); + (record.getHorizontal() >> 4 & 15) + (chunkX * 16), + record.getY(), + (record.getHorizontal() & 15) + (chunkZ * 16)); ConnectionHandler handler = ConnectionData.getConnectionHandler(blockState); if (handler != null) { @@ -242,9 +242,9 @@ public class WorldPackets { for (BlockChangeRecord record : records) { Position position = new Position( - (long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16), - (long) record.getY(), - (long) (record.getHorizontal() & 15) + (chunkZ * 16)); + (record.getHorizontal() >> 4 & 15) + (chunkX * 16), + record.getY(), + (record.getHorizontal() & 15) + (chunkZ * 16)); ConnectionData.update(userConnection, position); } } @@ -393,7 +393,7 @@ public class WorldPackets { int y = (int) tag.get("y").getValue(); int z = (int) tag.get("z").getValue(); - Position position = new Position((long) x, (long) y, (long) z); + Position position = new Position(x, (short) y, z); // Store the replacement blocks for blockupdates if (storage.contains(position)) storage.get(position).setReplacement(newId); 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 da69a8322..9f3c87af8 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 @@ -18,7 +18,7 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler { @Override public int transform(UserConnection user, CompoundTag tag) { BlockStorage storage = user.get(BlockStorage.class); - Position position = new Position(getLong(tag.get("x")), getLong(tag.get("y")), getLong(tag.get("z"))); + Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z"))); if (!storage.contains(position)) { Via.getPlatform().getLogger().warning("Received an banner color update packet, but there is no banner! O_o " + tag); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/BedHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/BedHandler.java index 3558a9fed..121d06792 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/BedHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/blockentities/BedHandler.java @@ -13,7 +13,7 @@ public class BedHandler implements BlockEntityProvider.BlockEntityHandler { @Override public int transform(UserConnection user, CompoundTag tag) { BlockStorage storage = user.get(BlockStorage.class); - Position position = new Position(getLong(tag.get("x")), getLong(tag.get("y")), getLong(tag.get("z"))); + Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z"))); if (!storage.contains(position)) { Via.getPlatform().getLogger().warning("Received an bed color update packet, but there is no bed! O_o " + tag); 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 7fb61cb20..412028944 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 @@ -15,7 +15,7 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler { @Override public int transform(UserConnection user, CompoundTag tag) { BlockStorage storage = user.get(BlockStorage.class); - Position position = new Position(getLong(tag.get("x")), getLong(tag.get("y")), getLong(tag.get("z"))); + Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z"))); if (!storage.contains(position)) { Via.getPlatform().getLogger().warning("Received an head update packet, but there is no head! O_o " + tag); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java index 1bf5f64b9..8845822f2 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java @@ -37,35 +37,35 @@ public class BlockConnectionStorage extends StoredObject { super(user); } - public void store(Position position, int blockState) { + public void store(int x, int y, int z, int blockState) { Short mapping = reverseBlockMappings.get((short) blockState); if (mapping == null) return; blockState = mapping; - long pair = getChunkSectionIndex(position); + long pair = getChunkSectionIndex(x, y, z); Pair map = getChunkSection(pair, (blockState & 0xF) != 0); - int blockIndex = encodeBlockPos(position); + int blockIndex = encodeBlockPos(x, y, z); map.getKey()[blockIndex] = (byte) (blockState >> 4); NibbleArray nibbleArray = map.getValue(); if (nibbleArray != null) nibbleArray.set(blockIndex, blockState); } - public int get(Position position) { - long pair = getChunkSectionIndex(position); + public int get(int x, int y, int z) { + long pair = getChunkSectionIndex(x, y, z); Pair map = blockStorage.get(pair); if (map == null) return 0; - short blockPosition = encodeBlockPos(position); + short blockPosition = encodeBlockPos(x, y, z); NibbleArray nibbleArray = map.getValue(); return WorldPackets.toNewId( ((map.getKey()[blockPosition] & 0xFF) << 4) - | (nibbleArray == null ? 0 : nibbleArray.get(blockPosition)) + | (nibbleArray == null ? 0 : nibbleArray.get(blockPosition)) ); } - public void remove(Position position) { - long pair = getChunkSectionIndex(position); + public void remove(int x, int y, int z) { + long pair = getChunkSectionIndex(x, y, z); Pair map = blockStorage.get(pair); if (map == null) return; - int blockIndex = encodeBlockPos(position); + int blockIndex = encodeBlockPos(x, y, z); NibbleArray nibbleArray = map.getValue(); if (nibbleArray != null) { nibbleArray.set(blockIndex, 0); @@ -112,7 +112,7 @@ public class BlockConnectionStorage extends StoredObject { } private long getChunkSectionIndex(Position position) { - return getChunkSectionIndex(position.getPosX(), position.getPosY(), position.getPosZ()); + return getChunkSectionIndex(position.getX(), position.getY(), position.getZ()); } private short encodeBlockPos(int x, int y, int z) { @@ -120,7 +120,7 @@ public class BlockConnectionStorage extends StoredObject { } private short encodeBlockPos(Position pos) { - return encodeBlockPos(pos.getPosX(), pos.getPosY(), pos.getPosZ()); + return encodeBlockPos(pos.getX(), pos.getY(), pos.getZ()); } private Map createLongObjectMap() { 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 01cfeba43..dbbcf6b84 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 @@ -45,7 +45,7 @@ public class BlockEntity { int y = (int) tag.get("y").getValue(); int z = (int) tag.get("z").getValue(); - Position pos = new Position((long) x, (long) y, (long) z); + Position pos = new Position(x, (short) y, z); updateBlockEntity(pos, (short) newId, tag, connection); } catch (Exception e) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java index dd88b96f8..a64368a92 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java @@ -55,9 +55,9 @@ public class Protocol1_9_3To1_9_1_2 extends Protocol { //Create nbt CompoundTag tag = new CompoundTag(""); tag.put(new StringTag("id", "Sign")); - tag.put(new IntTag("x", position.getPosX())); - tag.put(new IntTag("y", position.getPosY())); - tag.put(new IntTag("z", position.getPosZ())); + tag.put(new IntTag("x", position.getX())); + tag.put(new IntTag("y", position.getY())); + tag.put(new IntTag("z", position.getZ())); for (int i = 0; i < lines.length; i++) tag.put(new StringTag("Text" + (i + 1), lines[i])); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/SpawnPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/SpawnPackets.java index 46ef416ac..1ed6d246c 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/SpawnPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/SpawnPackets.java @@ -103,7 +103,7 @@ public class SpawnPackets { public void write(PacketWrapper wrapper) throws Exception { wrapper.write(Type.VAR_INT, entityID); List meta = new ArrayList<>(); - Item item = new Item((short) 373, (byte) 1, (short) data, null); // Potion + Item item = new Item(373, (byte) 1, (short) data, null); // Potion ItemRewriter.toClient(item); // Rewrite so that it gets the right nbt // TEMP FIX FOR POTIONS UNTIL WE FIGURE OUT HOW TO TRANSFORM SENT PACKETS Metadata potion = new Metadata(5, MetaType1_9.Slot, item); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java index 5ef4d1be1..6561afdcf 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -303,7 +303,7 @@ public class WorldPackets { if (hand == 0) { if (!tracker.isBlocking()) { tracker.setBlocking(true); - Item shield = new Item((short) 442, (byte) 1, (short) 0, null); + Item shield = new Item(442, (byte) 1, (short) 0, null); tracker.setSecondHand(shield); } wrapper.cancel(); @@ -363,9 +363,9 @@ public class WorldPackets { if (face == 255) return; Position p = wrapper.get(Type.POSITION, 0); - int x = p.getPosX(); - short y = p.getPosY(); - int z = p.getPosZ(); + int x = p.getX(); + short y = p.getY(); + int z = p.getZ(); switch (face) { case 0: y--; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/providers/HandItemProvider.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/providers/HandItemProvider.java index a839dc353..3f9aef55b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/providers/HandItemProvider.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/providers/HandItemProvider.java @@ -6,6 +6,6 @@ import us.myles.ViaVersion.api.platform.providers.Provider; public class HandItemProvider implements Provider { public Item getHandItem(final UserConnection info) { - return new Item((short) 0, (byte) 0, (short) 0, null); + return new Item(0, (byte) 0, (short) 0, null); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/CommandBlockStorage.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/CommandBlockStorage.java index dc17ea89e..f20d7e944 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/CommandBlockStorage.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/CommandBlockStorage.java @@ -44,8 +44,8 @@ public class CommandBlockStorage extends StoredObject { } private Pair getChunkCoords(Position position) { - int chunkX = Math.floorDiv(position.getPosX(), 16); - int chunkZ = Math.floorDiv(position.getPosZ(), 16); + int chunkX = Math.floorDiv(position.getX(), 16); + int chunkZ = Math.floorDiv(position.getZ(), 16); return new Pair<>(chunkX, chunkZ); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker1_9.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker1_9.java index 90feeec85..74d014817 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker1_9.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker1_9.java @@ -153,7 +153,7 @@ public class EntityTracker1_9 extends EntityTracker { if (entityId != getProvidedEntityId() && Via.getConfig().isShieldBlocking()) { if ((data & 0x10) == 0x10) { if (validBlocking.contains(entityId)) { - Item shield = new Item((short) 442, (byte) 1, (short) 0, null); + Item shield = new Item(442, (byte) 1, (short) 0, null); setSecondHand(entityId, shield); } else { setSecondHand(entityId, null); diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/listeners/protocol1_9to1_8/BlockListener.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/listeners/protocol1_9to1_8/BlockListener.java index b2d5f678e..b5c0b75ee 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/listeners/protocol1_9to1_8/BlockListener.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/listeners/protocol1_9to1_8/BlockListener.java @@ -23,7 +23,7 @@ public class BlockListener extends ViaSpongeListener { Location loc = e.getTransactions().get(0).getFinal().getLocation().get(); getUserConnection(player.getUniqueId()) .get(EntityTracker1_9.class) - .addBlockInteraction(new Position((long) loc.getX(), (long) loc.getY(), (long) loc.getZ())); + .addBlockInteraction(new Position(loc.getBlockX(), (short) loc.getBlockY(), loc.getBlockZ())); } } } diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/listeners/protocol1_9to1_8/HandItemCache.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/listeners/protocol1_9to1_8/HandItemCache.java index cba7897f5..694218d7d 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/listeners/protocol1_9to1_8/HandItemCache.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/listeners/protocol1_9to1_8/HandItemCache.java @@ -51,7 +51,7 @@ public class HandItemCache implements Runnable { } public static Item convert(ItemStack itemInHand) { - if (itemInHand == null) return new Item((short) 0, (byte) 0, (short) 0, null); + if (itemInHand == null) return new Item(0, (byte) 0, (short) 0, null); if (GET_DAMAGE == null) { try { GET_DAMAGE = itemInHand.getClass().getDeclaredField("field_77991_e"); @@ -87,7 +87,7 @@ public class HandItemCache implements Runnable { e.printStackTrace(); } } - return new Item((short) id, (byte) itemInHand.getQuantity(), (short) damage, null); + return new Item(id, (byte) itemInHand.getQuantity(), (short) damage, null); } }