From c5756fe45ce12eb9bf0f2147591199dc83b5d94f Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 21 May 2024 12:48:53 +0200 Subject: [PATCH] Rename Position to BlockPosition --- .../{Position.java => BlockPosition.java} | 21 +++++-------- ...Position.java => GlobalBlockPosition.java} | 8 ++--- .../minecraft/item/data/LodestoneTracker.java | 6 ++-- .../viaversion/viaversion/api/type/Types.java | 22 +++++++------- ...pe1_14.java => BlockPositionType1_14.java} | 18 +++++------ ...Type1_8.java => BlockPositionType1_8.java} | 18 +++++------ ...Type.java => GlobalBlockPositionType.java} | 14 ++++----- .../protocol1_9to1_8/BlockListener.java | 4 +-- .../v1_12_2to1_13/Protocol1_12_2To1_13.java | 6 ++-- .../AbstractFenceConnectionHandler.java | 8 ++--- .../AbstractStempConnectionHandler.java | 4 +-- .../ChestConnectionHandler.java | 4 +-- .../ChorusPlantConnectionHandler.java | 4 +-- .../blockconnections/ConnectionData.java | 14 ++++----- .../blockconnections/ConnectionHandler.java | 6 ++-- .../DoorConnectionHandler.java | 4 +-- .../FireConnectionHandler.java | 4 +-- .../FlowerConnectionHandler.java | 4 +-- .../GlassConnectionHandler.java | 4 +-- .../RedstoneConnectionHandler.java | 8 ++--- .../SnowyGrassConnectionHandler.java | 4 +-- .../StairConnectionHandler.java | 8 ++--- .../TripwireConnectionHandler.java | 4 +-- .../VineConnectionHandler.java | 10 +++---- .../WallConnectionHandler.java | 8 ++--- .../providers/BlockConnectionProvider.java | 6 ++-- .../PacketBlockConnectionProvider.java | 6 ++-- .../provider/BlockEntityProvider.java | 6 ++-- .../provider/PlayerLookTargetProvider.java | 4 +-- .../provider/blockentities/BannerHandler.java | 4 +-- .../provider/blockentities/BedHandler.java | 4 +-- .../provider/blockentities/SkullHandler.java | 4 +-- .../rewriter/WorldPacketRewriter1_13.java | 30 +++++++++---------- .../storage/BlockConnectionStorage.java | 10 +++---- .../v1_12_2to1_13/storage/BlockStorage.java | 14 ++++----- .../storage/TabCompleteTracker.java | 4 +-- .../rewriter/EntityPacketRewriter1_14.java | 4 +-- .../rewriter/PlayerPacketRewriter1_14.java | 4 +-- .../rewriter/EntityPacketRewriter1_19.java | 4 +-- .../BlockItemPacketRewriter1_20_5.java | 6 ++-- .../rewriter/ComponentRewriter1_20_5.java | 4 +-- .../provider/CommandBlockProvider.java | 6 ++-- .../rewriter/WorldPacketRewriter1_9.java | 10 +++---- .../storage/CommandBlockStorage.java | 14 ++++----- .../v1_8to1_9/storage/EntityTracker1_9.java | 18 +++++------ .../v1_9_1to1_9_3/Protocol1_9_1To1_9_3.java | 4 +-- .../viaversion/rewriter/BlockRewriter.java | 8 ++--- 47 files changed, 192 insertions(+), 197 deletions(-) rename api/src/main/java/com/viaversion/viaversion/api/minecraft/{Position.java => BlockPosition.java} (80%) rename api/src/main/java/com/viaversion/viaversion/api/minecraft/{GlobalPosition.java => GlobalBlockPosition.java} (89%) rename api/src/main/java/com/viaversion/viaversion/api/type/types/math/{PositionType1_14.java => BlockPositionType1_14.java} (78%) rename api/src/main/java/com/viaversion/viaversion/api/type/types/math/{PositionType1_8.java => BlockPositionType1_8.java} (78%) rename api/src/main/java/com/viaversion/viaversion/api/type/types/math/{GlobalPositionType.java => GlobalBlockPositionType.java} (83%) diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/Position.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/BlockPosition.java similarity index 80% rename from api/src/main/java/com/viaversion/viaversion/api/minecraft/Position.java rename to api/src/main/java/com/viaversion/viaversion/api/minecraft/BlockPosition.java index ea9ca5e8d..f8ab744d0 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/Position.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/BlockPosition.java @@ -22,24 +22,19 @@ */ package com.viaversion.viaversion.api.minecraft; -public class Position { +public class BlockPosition { protected final int x; protected final int y; protected final int z; - public Position(int x, int y, int z) { + public BlockPosition(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } - // @Deprecated/*(forRemoval=true)*/ Just leave this unchecked - public Position(int x, short y, int z) { - this(x, (int) y, z); - } - - public Position getRelative(BlockFace face) { - return new Position(x + face.modX(), (short) (y + face.modY()), z + face.modZ()); + public BlockPosition getRelative(BlockFace face) { + return new BlockPosition(x + face.modX(), y + face.modY(), z + face.modZ()); } public int x() { @@ -54,15 +49,15 @@ public class Position { return z; } - public GlobalPosition withDimension(String dimension) { - return new GlobalPosition(dimension, x, y, z); + public GlobalBlockPosition withDimension(String dimension) { + return new GlobalBlockPosition(dimension, x, y, z); } @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Position position = (Position) o; + BlockPosition position = (BlockPosition) o; if (x != position.x) return false; if (y != position.y) return false; return z == position.z; @@ -78,7 +73,7 @@ public class Position { @Override public String toString() { - return "Position{" + + return "BlockPosition{" + "x=" + x + ", y=" + y + ", z=" + z + diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/GlobalPosition.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/GlobalBlockPosition.java similarity index 89% rename from api/src/main/java/com/viaversion/viaversion/api/minecraft/GlobalPosition.java rename to api/src/main/java/com/viaversion/viaversion/api/minecraft/GlobalBlockPosition.java index a8b90c383..6f797c4a1 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/GlobalPosition.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/GlobalBlockPosition.java @@ -22,10 +22,10 @@ */ package com.viaversion.viaversion.api.minecraft; -public final class GlobalPosition extends Position { +public final class GlobalBlockPosition extends BlockPosition { private final String dimension; - public GlobalPosition(final String dimension, final int x, final int y, final int z) { + public GlobalBlockPosition(final String dimension, final int x, final int y, final int z) { super(x, y, z); this.dimension = dimension; } @@ -38,7 +38,7 @@ public final class GlobalPosition extends Position { public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - final GlobalPosition position = (GlobalPosition) o; + final GlobalBlockPosition position = (GlobalBlockPosition) o; if (x != position.x) return false; if (y != position.y) return false; if (z != position.z) return false; @@ -56,7 +56,7 @@ public final class GlobalPosition extends Position { @Override public String toString() { - return "GlobalPosition{" + + return "GlobalBlockPosition{" + "dimension='" + dimension + '\'' + ", x=" + x + ", y=" + y + diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTracker.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTracker.java index ed7cdf3c1..025079507 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTracker.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/LodestoneTracker.java @@ -22,18 +22,18 @@ */ package com.viaversion.viaversion.api.minecraft.item.data; -import com.viaversion.viaversion.api.minecraft.GlobalPosition; +import com.viaversion.viaversion.api.minecraft.GlobalBlockPosition; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; -public record LodestoneTracker(@Nullable GlobalPosition position, boolean tracked) { +public record LodestoneTracker(@Nullable GlobalBlockPosition position, boolean tracked) { public static final Type TYPE = new Type<>(LodestoneTracker.class) { @Override public LodestoneTracker read(final ByteBuf buffer) { - final GlobalPosition position = Types.OPTIONAL_GLOBAL_POSITION.read(buffer); + final GlobalBlockPosition position = Types.OPTIONAL_GLOBAL_POSITION.read(buffer); final boolean tracked = buffer.readBoolean(); return new LodestoneTracker(position, tracked); } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/Types.java b/api/src/main/java/com/viaversion/viaversion/api/type/Types.java index 655a3f618..8d6a7068e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/Types.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/Types.java @@ -28,10 +28,10 @@ import com.viaversion.nbt.tag.Tag; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.EulerAngle; import com.viaversion.viaversion.api.minecraft.GameProfile; -import com.viaversion.viaversion.api.minecraft.GlobalPosition; +import com.viaversion.viaversion.api.minecraft.GlobalBlockPosition; import com.viaversion.viaversion.api.minecraft.HolderSet; import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.minecraft.ProfileKey; import com.viaversion.viaversion.api.minecraft.Quaternion; import com.viaversion.viaversion.api.minecraft.RegistryEntry; @@ -81,9 +81,9 @@ import com.viaversion.viaversion.api.type.types.item.ItemType1_20_2; import com.viaversion.viaversion.api.type.types.item.ItemType1_8; import com.viaversion.viaversion.api.type.types.math.ChunkPositionType; import com.viaversion.viaversion.api.type.types.math.EulerAngleType; -import com.viaversion.viaversion.api.type.types.math.GlobalPositionType; -import com.viaversion.viaversion.api.type.types.math.PositionType1_14; -import com.viaversion.viaversion.api.type.types.math.PositionType1_8; +import com.viaversion.viaversion.api.type.types.math.GlobalBlockPositionType; +import com.viaversion.viaversion.api.type.types.math.BlockPositionType1_14; +import com.viaversion.viaversion.api.type.types.math.BlockPositionType1_8; import com.viaversion.viaversion.api.type.types.math.QuaternionType; import com.viaversion.viaversion.api.type.types.math.Vector3fType; import com.viaversion.viaversion.api.type.types.math.VectorType; @@ -149,10 +149,10 @@ public final class Types { public static final VarLongType VAR_LONG = new VarLongType(); /* MC Types */ - public static final Type BLOCK_POSITION1_8 = new PositionType1_8(); - public static final Type OPTIONAL_POSITION1_8 = new PositionType1_8.OptionalPositionType(); - public static final Type BLOCK_POSITION1_14 = new PositionType1_14(); - public static final Type OPTIONAL_POSITION_1_14 = new PositionType1_14.OptionalPosition1_14Type(); + public static final Type BLOCK_POSITION1_8 = new BlockPositionType1_8(); + public static final Type OPTIONAL_POSITION1_8 = new BlockPositionType1_8.OptionalBlockPositionType(); + public static final Type BLOCK_POSITION1_14 = new BlockPositionType1_14(); + public static final Type OPTIONAL_POSITION_1_14 = new BlockPositionType1_14.OptionalBlockPositionType(); public static final Type ROTATIONS = new EulerAngleType(); public static final Type VECTOR = new VectorType(); public static final Type VECTOR3F = new Vector3fType(); @@ -167,8 +167,8 @@ public final class Types { public static final Type TAG_ARRAY = new ArrayType<>(TAG); public static final Type OPTIONAL_TAG = new TagType.OptionalTagType(); - public static final Type GLOBAL_POSITION = new GlobalPositionType(); - public static final Type OPTIONAL_GLOBAL_POSITION = new GlobalPositionType.OptionalGlobalPositionType(); + public static final Type GLOBAL_POSITION = new GlobalBlockPositionType(); + public static final Type OPTIONAL_GLOBAL_POSITION = new GlobalBlockPositionType.OptionalGlobalPositionType(); public static final Type CHUNK_POSITION = new ChunkPositionType(); public static final Type BLOCK_ENTITY1_18 = new BlockEntityType1_18(); diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_14.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/BlockPositionType1_14.java similarity index 78% rename from api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_14.java rename to api/src/main/java/com/viaversion/viaversion/api/type/types/math/BlockPositionType1_14.java index 08bdac9eb..e900046dc 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_14.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/BlockPositionType1_14.java @@ -22,38 +22,38 @@ */ package com.viaversion.viaversion.api.type.types.math; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; -public class PositionType1_14 extends Type { - public PositionType1_14() { - super(Position.class); +public class BlockPositionType1_14 extends Type { + public BlockPositionType1_14() { + super(BlockPosition.class); } @Override - public Position read(ByteBuf buffer) { + public BlockPosition read(ByteBuf buffer) { long val = buffer.readLong(); long x = (val >> 38); long y = val << 52 >> 52; long z = val << 26 >> 38; - return new Position((int) x, (int) y, (int) z); + return new BlockPosition((int) x, (int) y, (int) z); } @Override - public void write(ByteBuf buffer, Position object) { + public void write(ByteBuf buffer, BlockPosition object) { buffer.writeLong((((long) object.x() & 0x3ffffff) << 38) | (object.y() & 0xfff) | ((((long) object.z()) & 0x3ffffff) << 12)); } - public static final class OptionalPosition1_14Type extends OptionalType { + public static final class OptionalBlockPositionType extends OptionalType { - public OptionalPosition1_14Type() { + public OptionalBlockPositionType() { super(Types.BLOCK_POSITION1_14); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_8.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/BlockPositionType1_8.java similarity index 78% rename from api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_8.java rename to api/src/main/java/com/viaversion/viaversion/api/type/types/math/BlockPositionType1_8.java index c401ff550..a152e9204 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/PositionType1_8.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/BlockPositionType1_8.java @@ -22,36 +22,36 @@ */ package com.viaversion.viaversion.api.type.types.math; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; -public class PositionType1_8 extends Type { +public class BlockPositionType1_8 extends Type { - public PositionType1_8() { - super(Position.class); + public BlockPositionType1_8() { + super(BlockPosition.class); } @Override - public Position read(ByteBuf buffer) { + public BlockPosition read(ByteBuf buffer) { final long val = buffer.readLong(); final long x = (val >> 38); final long y = (val << 26) >> 52; final long z = (val << 38) >> 38; - return new Position((int) x, (short) y, (int) z); + return new BlockPosition((int) x, (short) y, (int) z); } @Override - public void write(ByteBuf buffer, Position object) { + public void write(ByteBuf buffer, BlockPosition object) { buffer.writeLong((object.x() & 0X3FFFFFFL) << 38 | (object.y() & 0XFFFL) << 26 | (object.z() & 0X3FFFFFFL)); } - public static final class OptionalPositionType extends OptionalType { + public static final class OptionalBlockPositionType extends OptionalType { - public OptionalPositionType() { + public OptionalBlockPositionType() { super(Types.BLOCK_POSITION1_8); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/GlobalPositionType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/GlobalBlockPositionType.java similarity index 83% rename from api/src/main/java/com/viaversion/viaversion/api/type/types/math/GlobalPositionType.java rename to api/src/main/java/com/viaversion/viaversion/api/type/types/math/GlobalBlockPositionType.java index 84695dbf5..77b7b61e4 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/math/GlobalPositionType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/math/GlobalBlockPositionType.java @@ -22,31 +22,31 @@ */ package com.viaversion.viaversion.api.type.types.math; -import com.viaversion.viaversion.api.minecraft.GlobalPosition; +import com.viaversion.viaversion.api.minecraft.GlobalBlockPosition; import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; -public class GlobalPositionType extends Type { +public class GlobalBlockPositionType extends Type { - public GlobalPositionType() { - super(GlobalPosition.class); + public GlobalBlockPositionType() { + super(GlobalBlockPosition.class); } @Override - public GlobalPosition read(ByteBuf buffer) { + public GlobalBlockPosition read(ByteBuf buffer) { final String dimension = Types.STRING.read(buffer); return Types.BLOCK_POSITION1_14.read(buffer).withDimension(dimension); } @Override - public void write(ByteBuf buffer, GlobalPosition object) { + public void write(ByteBuf buffer, GlobalBlockPosition object) { Types.STRING.write(buffer, object.dimension()); Types.BLOCK_POSITION1_14.write(buffer, object); } - public static final class OptionalGlobalPositionType extends OptionalType { + public static final class OptionalGlobalPositionType extends OptionalType { public OptionalGlobalPositionType() { super(Types.GLOBAL_POSITION); diff --git a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/BlockListener.java b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/BlockListener.java index 856d2537f..1853c04ca 100644 --- a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/BlockListener.java +++ b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/BlockListener.java @@ -17,7 +17,7 @@ */ package com.viaversion.viaversion.bukkit.listeners.protocol1_9to1_8; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.storage.EntityTracker1_9; @@ -38,7 +38,7 @@ public class BlockListener extends ViaBukkitListener { if (isOnPipe(e.getPlayer())) { Block b = e.getBlockPlaced(); EntityTracker1_9 tracker = getUserConnection(e.getPlayer()).getEntityTracker(Protocol1_8To1_9.class); - tracker.addBlockInteraction(new Position(b.getX(), b.getY(), b.getZ())); + tracker.addBlockInteraction(new BlockPosition(b.getX(), b.getY(), b.getZ())); } } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java index c22f5c5be..55ceb6bd6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java @@ -24,7 +24,7 @@ import com.google.gson.JsonParseException; import com.viaversion.viaversion.api.Via; 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.BlockPosition; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; @@ -118,7 +118,7 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - Position position = wrapper.read(Types.BLOCK_POSITION1_8); + BlockPosition position = wrapper.read(Types.BLOCK_POSITION1_8); wrapper.write(Types.INT, position.x()); wrapper.write(Types.INT, position.y()); wrapper.write(Types.INT, position.z()); @@ -571,7 +571,7 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { wrapper.write(Types.BOOLEAN, false); - final Position playerLookTarget = Via.getManager().getProviders().get(PlayerLookTargetProvider.class).getPlayerLookTarget(wrapper.user()); + final BlockPosition playerLookTarget = Via.getManager().getProviders().get(PlayerLookTargetProvider.class).getPlayerLookTarget(wrapper.user()); wrapper.write(Types.OPTIONAL_POSITION1_8, playerLookTarget); if (!wrapper.isCancelled() && Via.getConfig().get1_13TabCompleteDelay() > 0) { TabCompleteTracker tracker = wrapper.user().get(TabCompleteTracker.class); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/AbstractFenceConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/AbstractFenceConnectionHandler.java index 78df6e22e..c4b11fa3a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/AbstractFenceConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/AbstractFenceConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; @@ -61,7 +61,7 @@ public abstract class AbstractFenceConnectionHandler implements ConnectionHandle return states; } - protected byte getStates(UserConnection user, Position position) { + protected byte getStates(UserConnection user, BlockPosition position) { byte states = 0; boolean pre1_12 = user.getProtocolInfo().serverProtocolVersion().olderThan(ProtocolVersion.v1_12); if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)), pre1_12)) states |= 1; @@ -76,12 +76,12 @@ public abstract class AbstractFenceConnectionHandler implements ConnectionHandle } @Override - public int getBlockData(UserConnection user, Position position) { + public int getBlockData(UserConnection user, BlockPosition position) { return STAIR_CONNECTION_HANDLER.connect(user, position, ConnectionHandler.super.getBlockData(user, position)); } @Override - public int connect(UserConnection user, Position position, int blockState) { + public int connect(UserConnection user, BlockPosition position, int blockState) { final int newBlockState = connectedBlockStates[getStates(user, position)]; return newBlockState == -1 ? blockState : newBlockState; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/AbstractStempConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/AbstractStempConnectionHandler.java index 99ec418e1..6b57b890a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/AbstractStempConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/AbstractStempConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; import java.util.EnumMap; @@ -55,7 +55,7 @@ public abstract class AbstractStempConnectionHandler implements ConnectionHandle } @Override - public int connect(UserConnection user, Position position, int blockState) { + public int connect(UserConnection user, BlockPosition position, int blockState) { if (blockState != baseStateId) { return blockState; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ChestConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ChestConnectionHandler.java index 47cf56585..ae069d392 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ChestConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ChestConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; @@ -62,7 +62,7 @@ class ChestConnectionHandler implements ConnectionHandler { } @Override - public int connect(UserConnection user, Position position, int blockState) { + public int connect(UserConnection user, BlockPosition position, int blockState) { BlockFace facing = CHEST_FACINGS.get(blockState); byte states = 0; states |= (facing.ordinal() << 2); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ChorusPlantConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ChorusPlantConnectionHandler.java index 310cb58ed..83af17aa0 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ChorusPlantConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ChorusPlantConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import java.util.ArrayList; import java.util.List; @@ -61,7 +61,7 @@ public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler } @Override - protected byte getStates(UserConnection user, Position position) { + protected byte getStates(UserConnection user, BlockPosition position) { byte states = super.getStates(user, position); if (connects(BlockFace.TOP, getBlockData(user, position.getRelative(BlockFace.TOP)), false)) states |= 16; if (connects(BlockFace.BOTTOM, getBlockData(user, position.getRelative(BlockFace.BOTTOM)), false)) states |= 32; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionData.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionData.java index 1e42bdcb2..17bfe2da0 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionData.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionData.java @@ -29,7 +29,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.MappingDataLoader; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_8; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; @@ -64,11 +64,11 @@ public final class ConnectionData { KEY_TO_ID.defaultReturnValue(-1); } - public static void update(UserConnection user, Position position) { + public static void update(UserConnection user, BlockPosition position) { Boolean inSync = null; for (BlockFace face : BlockFace.values()) { - Position pos = position.getRelative(face); + BlockPosition pos = position.getRelative(face); int blockState = blockConnectionProvider.getBlockData(user, pos.x(), pos.y(), pos.z()); ConnectionHandler handler = connectionHandlerMap.get(blockState); if (handler == null) { @@ -109,7 +109,7 @@ public final class ConnectionData { blockConnectionProvider.clearStorage(connection); } - public static void markModified(UserConnection connection, Position pos) { + public static void markModified(UserConnection connection, BlockPosition pos) { if (!needStoreBlocks()) return; blockConnectionProvider.modifiedBlock(connection, pos); } @@ -151,7 +151,7 @@ public final class ConnectionData { continue; } - Position position = new Position(xOff + ChunkSection.xFromIndex(idx), yOff + ChunkSection.yFromIndex(idx), zOff + ChunkSection.zFromIndex(idx)); + BlockPosition position = new BlockPosition(xOff + ChunkSection.xFromIndex(idx), yOff + ChunkSection.yFromIndex(idx), zOff + ChunkSection.zFromIndex(idx)); int connectedId = handler.connect(user, position, id); if (connectedId != id) { blocks.setIdAt(idx, connectedId); @@ -257,7 +257,7 @@ public final class ConnectionData { return connectionHandlerMap.containsKey(blockState); } - public static int connect(UserConnection user, Position position, int blockState) { + public static int connect(UserConnection user, BlockPosition position, int blockState) { ConnectionHandler handler = connectionHandlerMap.get(blockState); return handler != null ? handler.connect(user, position, blockState) : blockState; } @@ -357,7 +357,7 @@ public final class ConnectionData { return; } - Position pos = new Position(x, y, z); + BlockPosition pos = new BlockPosition(x, y, z); int newBlockState = handler.connect(user, pos, blockState); if (blockState != newBlockState || !blockConnectionProvider.storesBlocks(user, null)) { records.add(new BlockChangeRecord1_8(x & 0xF, y, z & 0xF, newBlockState)); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionHandler.java index 8c37c73a0..c1de3d26e 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/ConnectionHandler.java @@ -18,14 +18,14 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; @FunctionalInterface public interface ConnectionHandler { - int connect(UserConnection user, Position position, int blockState); + int connect(UserConnection user, BlockPosition position, int blockState); - default int getBlockData(UserConnection user, Position position) { + default int getBlockData(UserConnection user, BlockPosition position) { return ConnectionData.blockConnectionProvider.getBlockData(user, position.x(), position.y(), position.z()); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/DoorConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/DoorConnectionHandler.java index 9a43d16a5..1add68812 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/DoorConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/DoorConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.util.HashMap; @@ -78,7 +78,7 @@ public class DoorConnectionHandler implements ConnectionHandler { } @Override - public int connect(UserConnection user, Position position, int blockState) { + public int connect(UserConnection user, BlockPosition position, int blockState) { DoorData doorData = DOOR_DATA_MAP.get(blockState); if (doorData == null) return blockState; short s = 0; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/FireConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/FireConnectionHandler.java index cf9b1bcdf..4a462f3d7 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/FireConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/FireConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.util.Key; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; @@ -76,7 +76,7 @@ public class FireConnectionHandler implements ConnectionHandler { } @Override - public int connect(UserConnection user, Position position, int blockState) { + public int connect(UserConnection user, BlockPosition position, int blockState) { byte states = 0; if (FLAMMABLE_BLOCKS.contains(getBlockData(user, position.getRelative(BlockFace.EAST)))) states |= 1; if (FLAMMABLE_BLOCKS.contains(getBlockData(user, position.getRelative(BlockFace.NORTH)))) states |= 2; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/FlowerConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/FlowerConnectionHandler.java index 4879a49d4..b0a87bd42 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/FlowerConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/FlowerConnectionHandler.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import it.unimi.dsi.fastutil.ints.Int2IntMap; import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import java.util.HashSet; @@ -52,7 +52,7 @@ public class FlowerConnectionHandler implements ConnectionHandler { } @Override - public int connect(UserConnection user, Position position, int blockState) { + public int connect(UserConnection user, BlockPosition position, int blockState) { int blockBelowId = getBlockData(user, position.getRelative(BlockFace.BOTTOM)); int connectBelow = FLOWERS.get(blockBelowId); if (connectBelow != 0) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/GlassConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/GlassConnectionHandler.java index cf80ba61d..47205fafa 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/GlassConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/GlassConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.ProtocolInfo; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import java.util.ArrayList; import java.util.List; @@ -54,7 +54,7 @@ public class GlassConnectionHandler extends AbstractFenceConnectionHandler { } @Override - protected byte getStates(UserConnection user, Position position) { + protected byte getStates(UserConnection user, BlockPosition position) { byte states = super.getStates(user, position); if (states != 0) return states; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/RedstoneConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/RedstoneConnectionHandler.java index 37c846637..2782cd4b8 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/RedstoneConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/RedstoneConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import it.unimi.dsi.fastutil.ints.Int2IntMap; import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; @@ -65,7 +65,7 @@ public class RedstoneConnectionHandler implements ConnectionHandler { } @Override - public int connect(UserConnection user, Position position, int blockState) { + public int connect(UserConnection user, BlockPosition position, int blockState) { short b = 0; b |= connects(user, position, BlockFace.EAST); b |= connects(user, position, BlockFace.NORTH) << 2; @@ -75,8 +75,8 @@ public class RedstoneConnectionHandler implements ConnectionHandler { return CONNECTED_BLOCK_STATES.getOrDefault(b, blockState); } - private int connects(UserConnection user, Position position, BlockFace side) { - final Position relative = position.getRelative(side); + private int connects(UserConnection user, BlockPosition position, BlockFace side) { + final BlockPosition relative = position.getRelative(side); int blockState = getBlockData(user, relative); if (connects(side, blockState)) { return 1; //side diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/SnowyGrassConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/SnowyGrassConnectionHandler.java index e1e8e392e..8c6c4f5e6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/SnowyGrassConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/SnowyGrassConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; import it.unimi.dsi.fastutil.objects.Object2IntMap; @@ -55,7 +55,7 @@ public class SnowyGrassConnectionHandler implements ConnectionHandler { } @Override - public int connect(UserConnection user, Position position, int blockState) { + public int connect(UserConnection user, BlockPosition position, int blockState) { int blockUpId = getBlockData(user, position.getRelative(BlockFace.TOP)); int newId = GRASS_BLOCKS.getInt(new GrassBlock(blockState, SNOWY_GRASS_BLOCKS.contains(blockUpId))); return newId != -1 ? newId : blockState; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/StairConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/StairConnectionHandler.java index f77e6d2c0..1e45a548f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/StairConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/StairConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.util.HashMap; @@ -103,7 +103,7 @@ public class StairConnectionHandler implements ConnectionHandler { } @Override - public int connect(UserConnection user, Position position, int blockState) { + public int connect(UserConnection user, BlockPosition position, int blockState) { StairData stairData = STAIR_DATA_MAP.get(blockState); if (stairData == null) return blockState; @@ -117,7 +117,7 @@ public class StairConnectionHandler implements ConnectionHandler { return newBlockState == null ? blockState : newBlockState; } - private int getShape(UserConnection user, Position position, StairData stair) { + private int getShape(UserConnection user, BlockPosition position, StairData stair) { BlockFace facing = stair.facing(); StairData relativeStair = STAIR_DATA_MAP.get(getBlockData(user, position.getRelative(facing))); @@ -139,7 +139,7 @@ public class StairConnectionHandler implements ConnectionHandler { return 0; // straight } - private boolean checkOpposite(UserConnection user, StairData stair, Position position, BlockFace face) { + private boolean checkOpposite(UserConnection user, StairData stair, BlockPosition position, BlockFace face) { StairData relativeStair = STAIR_DATA_MAP.get(getBlockData(user, position.getRelative(face))); return relativeStair == null || relativeStair.facing() != stair.facing() || relativeStair.bottom() != stair.bottom(); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/TripwireConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/TripwireConnectionHandler.java index 6515054fb..cea995306 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/TripwireConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/TripwireConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; @@ -65,7 +65,7 @@ public class TripwireConnectionHandler implements ConnectionHandler { } @Override - public int connect(UserConnection user, Position position, int blockState) { + public int connect(UserConnection user, BlockPosition position, int blockState) { TripwireData tripwireData = TRIPWIRE_DATA_MAP.get(blockState); if (tripwireData == null) return blockState; byte b = 0; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/VineConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/VineConnectionHandler.java index 2d3b9840e..447a3f40f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/VineConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/VineConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; @@ -37,10 +37,10 @@ class VineConnectionHandler implements ConnectionHandler { } @Override - public int connect(UserConnection user, Position position, int blockState) { + public int connect(UserConnection user, BlockPosition position, int blockState) { if (isAttachedToBlock(user, position)) return blockState; - Position upperPos = position.getRelative(BlockFace.TOP); + BlockPosition upperPos = position.getRelative(BlockFace.TOP); int upperBlock = getBlockData(user, upperPos); if (VINES.contains(upperBlock) && isAttachedToBlock(user, upperPos)) return blockState; @@ -48,14 +48,14 @@ class VineConnectionHandler implements ConnectionHandler { return 0; } - private boolean isAttachedToBlock(UserConnection user, Position position) { + private boolean isAttachedToBlock(UserConnection user, BlockPosition position) { return isAttachedToBlock(user, position, BlockFace.EAST) || isAttachedToBlock(user, position, BlockFace.WEST) || isAttachedToBlock(user, position, BlockFace.NORTH) || isAttachedToBlock(user, position, BlockFace.SOUTH); } - private boolean isAttachedToBlock(UserConnection user, Position position, BlockFace blockFace) { + private boolean isAttachedToBlock(UserConnection user, BlockPosition position, BlockFace blockFace) { return ConnectionData.OCCLUDING_STATES.contains(getBlockData(user, position.getRelative(blockFace))); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/WallConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/WallConnectionHandler.java index 7761f291e..a2c90dbea 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/WallConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/WallConnectionHandler.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import java.util.ArrayList; import java.util.List; @@ -47,7 +47,7 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler { } @Override - protected byte getStates(UserConnection user, Position position) { + protected byte getStates(UserConnection user, BlockPosition position) { byte states = super.getStates(user, position); if (up(user, position)) states |= 16; return states; @@ -58,7 +58,7 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler { return 32; } - public boolean up(UserConnection user, Position position) { + public boolean up(UserConnection user, BlockPosition position) { if (isWall(getBlockData(user, position.getRelative(BlockFace.BOTTOM))) || isWall(getBlockData(user, position.getRelative(BlockFace.TOP)))) return true; int blockFaces = getBlockFaces(user, position); @@ -69,7 +69,7 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler { return false; } - private int getBlockFaces(UserConnection user, Position position) { + private int getBlockFaces(UserConnection user, BlockPosition position) { int blockFaces = 0; for (int i = 0; i < BLOCK_FACES.length; i++) { if (isWall(getBlockData(user, position.getRelative(BLOCK_FACES[i])))) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/providers/BlockConnectionProvider.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/providers/BlockConnectionProvider.java index ca69636c0..01ae4442a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/providers/BlockConnectionProvider.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/providers/BlockConnectionProvider.java @@ -18,7 +18,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.providers; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.platform.providers.Provider; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; import org.checkerframework.checker.nullness.qual.Nullable; @@ -43,7 +43,7 @@ public abstract class BlockConnectionProvider implements Provider { public void clearStorage(UserConnection connection) { } - public void modifiedBlock(UserConnection connection, Position position) { + public void modifiedBlock(UserConnection connection, BlockPosition position) { } @@ -61,7 +61,7 @@ public abstract class BlockConnectionProvider implements Provider { * @param position The position at which block reliability should be checked, null for general-purpose * @return true if the block and its neighbors are known to be correct */ - public boolean storesBlocks(UserConnection user, @Nullable Position position) { + public boolean storesBlocks(UserConnection user, @Nullable BlockPosition position) { return false; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/providers/PacketBlockConnectionProvider.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/providers/PacketBlockConnectionProvider.java index 7e6b8cfc0..c7d8d2182 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/providers/PacketBlockConnectionProvider.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/blockconnections/providers/PacketBlockConnectionProvider.java @@ -18,7 +18,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.providers; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.protocols.v1_12_2to1_13.storage.BlockConnectionStorage; import org.checkerframework.checker.nullness.qual.Nullable; @@ -44,7 +44,7 @@ public class PacketBlockConnectionProvider extends BlockConnectionProvider { connection.get(BlockConnectionStorage.class).clear(); } - public void modifiedBlock(UserConnection connection, Position position) { + public void modifiedBlock(UserConnection connection, BlockPosition position) { connection.get(BlockConnectionStorage.class).markModified(position); } @@ -59,7 +59,7 @@ public class PacketBlockConnectionProvider extends BlockConnectionProvider { } @Override - public boolean storesBlocks(UserConnection connection, @Nullable Position pos) { + public boolean storesBlocks(UserConnection connection, @Nullable BlockPosition pos) { if (pos == null || connection == null) return true; return !connection.get(BlockConnectionStorage.class).recentlyModified(pos); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/BlockEntityProvider.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/BlockEntityProvider.java index 689f12c11..c27f04d45 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/BlockEntityProvider.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/BlockEntityProvider.java @@ -21,7 +21,7 @@ import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.StringTag; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.platform.providers.Provider; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Types; @@ -57,7 +57,7 @@ public class BlockEntityProvider implements Provider { * @param sendUpdate send a block change update * @return new block id */ - public int transform(UserConnection user, Position position, CompoundTag tag, boolean sendUpdate) { + public int transform(UserConnection user, BlockPosition position, CompoundTag tag, boolean sendUpdate) { StringTag idTag = tag.getStringTag("id"); if (idTag == null) return -1; @@ -78,7 +78,7 @@ public class BlockEntityProvider implements Provider { return newBlock; } - private void sendBlockChange(UserConnection user, Position position, int blockId) { + private void sendBlockChange(UserConnection user, BlockPosition position, int blockId) { PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_13.BLOCK_UPDATE, null, user); wrapper.write(Types.BLOCK_POSITION1_8, position); wrapper.write(Types.VAR_INT, blockId); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/PlayerLookTargetProvider.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/PlayerLookTargetProvider.java index 3704f60f1..42be09759 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/PlayerLookTargetProvider.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/PlayerLookTargetProvider.java @@ -18,13 +18,13 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.provider; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.platform.providers.Provider; import org.checkerframework.checker.nullness.qual.Nullable; public class PlayerLookTargetProvider implements Provider { @Nullable - public Position getPlayerLookTarget(final UserConnection info) { + public BlockPosition getPlayerLookTarget(final UserConnection info) { return null; } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/BannerHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/BannerHandler.java index fa3855d99..4f3e93bea 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/BannerHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/BannerHandler.java @@ -22,7 +22,7 @@ import com.viaversion.nbt.tag.ListTag; import com.viaversion.nbt.tag.NumberTag; import com.viaversion.nbt.tag.StringTag; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.BlockEntityProvider; import com.viaversion.viaversion.protocols.v1_12_2to1_13.storage.BlockStorage; @@ -38,7 +38,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(tag.getNumberTag("x").asInt(), tag.getNumberTag("y").asShort(), tag.getNumberTag("z").asInt()); + BlockPosition position = new BlockPosition(tag.getNumberTag("x").asInt(), tag.getNumberTag("y").asShort(), tag.getNumberTag("z").asInt()); if (!storage.contains(position)) { Protocol1_12_2To1_13.LOGGER.warning("Received an banner color update packet, but there is no banner! O_o " + tag); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/BedHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/BedHandler.java index e60ba7a11..f9a39699f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/BedHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/BedHandler.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.blockentities import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.NumberTag; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.BlockEntityProvider; import com.viaversion.viaversion.protocols.v1_12_2to1_13.storage.BlockStorage; @@ -30,7 +30,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(tag.getNumberTag("x").asInt(), tag.getNumberTag("y").asShort(), tag.getNumberTag("z").asInt()); + BlockPosition position = new BlockPosition(tag.getNumberTag("x").asInt(), tag.getNumberTag("y").asShort(), tag.getNumberTag("z").asInt()); if (!storage.contains(position)) { Protocol1_12_2To1_13.LOGGER.warning("Received an bed color update packet, but there is no bed! O_o " + tag); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/SkullHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/SkullHandler.java index 24a1448a1..82b8ac60c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/SkullHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/blockentities/SkullHandler.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.blockentities import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.NumberTag; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.BlockEntityProvider; import com.viaversion.viaversion.protocols.v1_12_2to1_13.storage.BlockStorage; @@ -32,7 +32,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(tag.getNumberTag("x").asInt(), tag.getNumberTag("y").asShort(), tag.getNumberTag("z").asInt()); + BlockPosition position = new BlockPosition(tag.getNumberTag("x").asInt(), tag.getNumberTag("y").asShort(), tag.getNumberTag("z").asInt()); if (!storage.contains(position)) { Protocol1_12_2To1_13.LOGGER.warning("Received an head update packet, but there is no head! O_o " + tag); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/WorldPacketRewriter1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/WorldPacketRewriter1_13.java index c5e5d9dd2..a4a710de1 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/WorldPacketRewriter1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/WorldPacketRewriter1_13.java @@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Particle; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; @@ -104,7 +104,7 @@ public class WorldPacketRewriter1_13 { map(Types.NAMED_COMPOUND_TAG); // 2 - NBT data handler(wrapper -> { - Position position = wrapper.get(Types.BLOCK_POSITION1_8, 0); + BlockPosition position = wrapper.get(Types.BLOCK_POSITION1_8, 0); short action = wrapper.get(Types.UNSIGNED_BYTE, 0); CompoundTag tag = wrapper.get(Types.NAMED_COMPOUND_TAG, 0); @@ -134,7 +134,7 @@ public class WorldPacketRewriter1_13 { map(Types.UNSIGNED_BYTE); // Action param map(Types.VAR_INT); // Block Id - /!\ NOT BLOCK STATE ID handler(wrapper -> { - Position pos = wrapper.get(Types.BLOCK_POSITION1_8, 0); + BlockPosition pos = wrapper.get(Types.BLOCK_POSITION1_8, 0); short action = wrapper.get(Types.UNSIGNED_BYTE, 0); short param = wrapper.get(Types.UNSIGNED_BYTE, 1); int blockId = wrapper.get(Types.VAR_INT, 0); @@ -177,7 +177,7 @@ public class WorldPacketRewriter1_13 { map(Types.BLOCK_POSITION1_8); map(Types.VAR_INT); handler(wrapper -> { - Position position = wrapper.get(Types.BLOCK_POSITION1_8, 0); + BlockPosition position = wrapper.get(Types.BLOCK_POSITION1_8, 0); int newId = toNewId(wrapper.get(Types.VAR_INT, 0)); UserConnection userConnection = wrapper.user(); @@ -212,7 +212,7 @@ public class WorldPacketRewriter1_13 { // Convert ids for (BlockChangeRecord record : records) { int newBlock = toNewId(record.getBlockId()); - Position position = new Position( + BlockPosition position = new BlockPosition( record.getSectionX() + (chunkX << 4), record.getY(), record.getSectionZ() + (chunkZ << 4)); @@ -227,7 +227,7 @@ public class WorldPacketRewriter1_13 { for (BlockChangeRecord record : records) { int blockState = record.getBlockId(); - Position position = new Position( + BlockPosition position = new BlockPosition( record.getSectionX() + (chunkX * 16), record.getY(), record.getSectionZ() + (chunkZ * 16)); @@ -245,7 +245,7 @@ public class WorldPacketRewriter1_13 { wrapper.cancel(); for (BlockChangeRecord record : records) { - Position position = new Position( + BlockPosition position = new BlockPosition( record.getSectionX() + (chunkX * 16), record.getY(), record.getSectionZ() + (chunkZ * 16)); @@ -275,10 +275,10 @@ public class WorldPacketRewriter1_13 { int y = (int) Math.floor(wrapper.get(Types.FLOAT, 1)); int z = (int) Math.floor(wrapper.get(Types.FLOAT, 2)); int recordCount = wrapper.get(Types.INT, 0); - Position[] records = new Position[recordCount]; + BlockPosition[] records = new BlockPosition[recordCount]; for (int i = 0; i < recordCount; i++) { - Position position = new Position( + BlockPosition position = new BlockPosition( x + wrapper.passthrough(Types.BYTE), (short) (y + wrapper.passthrough(Types.BYTE)), z + wrapper.passthrough(Types.BYTE)); @@ -358,7 +358,7 @@ public class WorldPacketRewriter1_13 { } for (int idx = 0; idx < ChunkSection.SIZE; idx++) { int id = blocks.idAt(idx); - Position position = new Position(ChunkSection.xFromIndex(idx) + (chunk.getX() << 4), ChunkSection.yFromIndex(idx) + (s << 4), ChunkSection.zFromIndex(idx) + (chunk.getZ() << 4)); + BlockPosition position = new BlockPosition(ChunkSection.xFromIndex(idx) + (chunk.getX() << 4), ChunkSection.yFromIndex(idx) + (s << 4), ChunkSection.zFromIndex(idx) + (chunk.getZ() << 4)); if (storage.isWelcome(id)) { storage.store(position, id); } else if (!chunk.isFullChunk()) { // Update @@ -426,10 +426,10 @@ public class WorldPacketRewriter1_13 { int newId = provider.transform(wrapper.user(), null, tag, false); if (newId != -1) { int x = tag.getNumberTag("x").asInt(); - int y = tag.getNumberTag("y").asInt(); + short y = tag.getNumberTag("y").asShort(); int z = tag.getNumberTag("z").asInt(); - Position position = new Position(x, (short) y, z); + BlockPosition position = new BlockPosition(x, y, z); // Store the replacement blocks for blockupdates BlockStorage.ReplacementData replacementData = storage.get(position); if (replacementData != null) { @@ -536,7 +536,7 @@ public class WorldPacketRewriter1_13 { // Incoming Packets protocol.registerServerbound(ServerboundPackets1_13.USE_ITEM_ON, wrapper -> { - Position pos = wrapper.passthrough(Types.BLOCK_POSITION1_8); + BlockPosition pos = wrapper.passthrough(Types.BLOCK_POSITION1_8); wrapper.passthrough(Types.VAR_INT); // block face wrapper.passthrough(Types.VAR_INT); // hand wrapper.passthrough(Types.FLOAT); // cursor x @@ -549,7 +549,7 @@ public class WorldPacketRewriter1_13 { }); protocol.registerServerbound(ServerboundPackets1_13.PLAYER_ACTION, wrapper -> { int status = wrapper.passthrough(Types.VAR_INT); // Status - Position pos = wrapper.passthrough(Types.BLOCK_POSITION1_8); // Location + BlockPosition pos = wrapper.passthrough(Types.BLOCK_POSITION1_8); // Location wrapper.passthrough(Types.UNSIGNED_BYTE); // block face // 0 = Started digging: if in creative this causes the block to break directly @@ -583,7 +583,7 @@ public class WorldPacketRewriter1_13 { return 0; } - private static int checkStorage(UserConnection user, Position position, int newId) { + private static int checkStorage(UserConnection user, BlockPosition position, int newId) { BlockStorage storage = user.get(BlockStorage.class); if (storage.contains(position)) { BlockStorage.ReplacementData data = storage.get(position); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/BlockConnectionStorage.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/BlockConnectionStorage.java index eafdd3cca..83fe63783 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/BlockConnectionStorage.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/BlockConnectionStorage.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.storage; import com.google.common.collect.EvictingQueue; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.StorableObject; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; @@ -33,7 +33,7 @@ public class BlockConnectionStorage implements StorableObject { private final Map blockStorage = createLongObjectMap(); @SuppressWarnings("UnstableApiUsage") - private final Queue modified = EvictingQueue.create(5); + private final Queue modified = EvictingQueue.create(5); // Cache to retrieve section quicker private long lastIndex = -1; @@ -93,15 +93,15 @@ public class BlockConnectionStorage implements StorableObject { } } - public void markModified(Position pos) { + public void markModified(BlockPosition pos) { // Avoid saving the same pos twice if (!modified.contains(pos)) { this.modified.add(pos); } } - public boolean recentlyModified(Position pos) { - for (Position p : modified) { + public boolean recentlyModified(BlockPosition pos) { + for (BlockPosition p : modified) { if (Math.abs(pos.x() - p.x()) + Math.abs(pos.y() - p.y()) + Math.abs(pos.z() - p.z()) <= 2) { return true; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/BlockStorage.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/BlockStorage.java index c679e3b52..c908a2976 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/BlockStorage.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/BlockStorage.java @@ -18,7 +18,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.storage; import com.viaversion.viaversion.api.connection.StorableObject; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; import java.util.HashMap; @@ -27,7 +27,7 @@ import java.util.Map; // TODO Fix memory leak lolz (only a smol one tho) public class BlockStorage implements StorableObject { private static final IntSet WHITELIST = new IntOpenHashSet(46, .99F); - private final Map blocks = new HashMap<>(); + private final Map blocks = new HashMap<>(); static { // Flower pots @@ -54,11 +54,11 @@ public class BlockStorage implements StorableObject { } } - public void store(Position position, int block) { + public void store(BlockPosition position, int block) { store(position, block, -1); } - public void store(Position position, int block, int replacementId) { + public void store(BlockPosition position, int block, int replacementId) { if (!WHITELIST.contains(block)) return; @@ -69,15 +69,15 @@ public class BlockStorage implements StorableObject { return WHITELIST.contains(block); } - public boolean contains(Position position) { + public boolean contains(BlockPosition position) { return blocks.containsKey(position); } - public ReplacementData get(Position position) { + public ReplacementData get(BlockPosition position) { return blocks.get(position); } - public ReplacementData remove(Position position) { + public ReplacementData remove(BlockPosition position) { return blocks.remove(position); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/TabCompleteTracker.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/TabCompleteTracker.java index 2aa091997..0bae7527e 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/TabCompleteTracker.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/storage/TabCompleteTracker.java @@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.storage; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; @@ -38,7 +38,7 @@ public class TabCompleteTracker implements StorableObject { PacketWrapper wrapper = PacketWrapper.create(ServerboundPackets1_12_1.COMMAND_SUGGESTION, null, connection); wrapper.write(Types.STRING, lastTabComplete); wrapper.write(Types.BOOLEAN, false); - final Position playerLookTarget = Via.getManager().getProviders().get(PlayerLookTargetProvider.class).getPlayerLookTarget(connection); + final BlockPosition playerLookTarget = Via.getManager().getProviders().get(PlayerLookTargetProvider.class).getPlayerLookTarget(connection); wrapper.write(Types.OPTIONAL_POSITION1_8, playerLookTarget); wrapper.scheduleSendToServer(Protocol1_12_2To1_13.class); lastTabComplete = null; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/EntityPacketRewriter1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/EntityPacketRewriter1_14.java index 08a9c3776..03efa751f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/EntityPacketRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/EntityPacketRewriter1_14.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_13_2to1_14.rewriter; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.ClientWorld; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.minecraft.VillagerData; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; @@ -241,7 +241,7 @@ public class EntityPacketRewriter1_14 extends EntityRewriter metadataList = new LinkedList<>(); metadataList.add(new EntityData(12, Types1_14.ENTITY_DATA_TYPES.optionalBlockPositionType, position)); if (tracker.clientEntityId() != entityId) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/PlayerPacketRewriter1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/PlayerPacketRewriter1_14.java index 1a7f3f164..4ccf0a8da 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/PlayerPacketRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/PlayerPacketRewriter1_14.java @@ -21,7 +21,7 @@ import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.ListTag; import com.viaversion.nbt.tag.StringTag; import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Types; @@ -127,7 +127,7 @@ public class PlayerPacketRewriter1_14 { protocol.registerServerbound(ServerboundPackets1_14.USE_ITEM_ON, wrapper -> { int hand = wrapper.read(Types.VAR_INT); - Position position = wrapper.read(Types.BLOCK_POSITION1_14); + BlockPosition position = wrapper.read(Types.BLOCK_POSITION1_14); int face = wrapper.read(Types.VAR_INT); float x = wrapper.read(Types.FLOAT); float y = wrapper.read(Types.FLOAT); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/EntityPacketRewriter1_19.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/EntityPacketRewriter1_19.java index 38736b842..9151554d5 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/EntityPacketRewriter1_19.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/EntityPacketRewriter1_19.java @@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.data.ParticleMappings; import com.viaversion.viaversion.api.data.entity.DimensionData; import com.viaversion.viaversion.api.minecraft.Particle; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19; import com.viaversion.viaversion.api.minecraft.entitydata.EntityData; @@ -99,7 +99,7 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter extends Co } } - protected void convertGlobalPos(final CompoundTag tag, final GlobalPosition position) { + protected void convertGlobalPos(final CompoundTag tag, final GlobalBlockPosition position) { final CompoundTag posTag = new CompoundTag(); posTag.putString("dimension", position.dimension()); posTag.put("pos", new IntArrayTag(new int[]{position.x(), position.y(), position.z()})); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/provider/CommandBlockProvider.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/provider/CommandBlockProvider.java index ef50f0a13..e5910095b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/provider/CommandBlockProvider.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/provider/CommandBlockProvider.java @@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_8to1_9.provider; import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.platform.providers.Provider; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Types; @@ -31,12 +31,12 @@ import java.util.Optional; public class CommandBlockProvider implements Provider { - public void addOrUpdateBlock(UserConnection user, Position position, CompoundTag tag) { + public void addOrUpdateBlock(UserConnection user, BlockPosition position, CompoundTag tag) { checkPermission(user); getStorage(user).addOrUpdateBlock(position, tag); } - public Optional get(UserConnection user, Position position) { + public Optional get(UserConnection user, BlockPosition position) { checkPermission(user); return getStorage(user).getCommandBlock(position); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/WorldPacketRewriter1_9.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/WorldPacketRewriter1_9.java index 5fefe258a..7ce1c9f89 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/WorldPacketRewriter1_9.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/WorldPacketRewriter1_9.java @@ -22,7 +22,7 @@ import com.viaversion.nbt.tag.StringTag; import com.viaversion.viaversion.api.Via; 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.BlockPosition; import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; @@ -290,7 +290,7 @@ public class WorldPacketRewriter1_9 { // Wipe the input buffer wrapper.clearInputBuffer(); wrapper.setPacketType(ServerboundPackets1_8.USE_ITEM_ON); - wrapper.write(Types.BLOCK_POSITION1_8, new Position(-1, (short) -1, -1)); + wrapper.write(Types.BLOCK_POSITION1_8, new BlockPosition(-1, -1, -1)); wrapper.write(Types.UNSIGNED_BYTE, (short) 255); // Write item in hand Item item = Protocol1_8To1_9.getHandItem(wrapper.user()); @@ -362,7 +362,7 @@ public class WorldPacketRewriter1_9 { int face = wrapper.get(Types.UNSIGNED_BYTE, 0); if (face == 255) return; - Position p = wrapper.get(Types.BLOCK_POSITION1_8, 0); + BlockPosition p = wrapper.get(Types.BLOCK_POSITION1_8, 0); int x = p.x(); int y = p.y(); int z = p.z(); @@ -375,14 +375,14 @@ public class WorldPacketRewriter1_9 { case 5 -> x++; } EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class); - tracker.addBlockInteraction(new Position(x, y, z)); + tracker.addBlockInteraction(new BlockPosition(x, y, z)); }); // Handle CommandBlocks handler(wrapper -> { CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class); - Position pos = wrapper.get(Types.BLOCK_POSITION1_8, 0); + BlockPosition pos = wrapper.get(Types.BLOCK_POSITION1_8, 0); Optional tag = provider.get(wrapper.user(), pos); // Send the Update Block Entity packet if present if (tag.isPresent()) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/CommandBlockStorage.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/CommandBlockStorage.java index 40cf41193..994d69d48 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/CommandBlockStorage.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/CommandBlockStorage.java @@ -20,14 +20,14 @@ package com.viaversion.viaversion.protocols.v1_8to1_9.storage; import com.viaversion.nbt.tag.ByteTag; import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viaversion.api.connection.StorableObject; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.util.Pair; import java.util.Map; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; public class CommandBlockStorage implements StorableObject { - private final Map, Map> storedCommandBlocks = new ConcurrentHashMap<>(); + private final Map, Map> storedCommandBlocks = new ConcurrentHashMap<>(); private boolean permissions; public void unloadChunk(int x, int z) { @@ -35,14 +35,14 @@ public class CommandBlockStorage implements StorableObject { storedCommandBlocks.remove(chunkPos); } - public void addOrUpdateBlock(Position position, CompoundTag tag) { + public void addOrUpdateBlock(BlockPosition position, CompoundTag tag) { Pair chunkPos = getChunkCoords(position); if (!storedCommandBlocks.containsKey(chunkPos)) { storedCommandBlocks.put(chunkPos, new ConcurrentHashMap<>()); } - Map blocks = storedCommandBlocks.get(chunkPos); + Map blocks = storedCommandBlocks.get(chunkPos); if (blocks.containsKey(position) && blocks.get(position).equals(tag)) { return; @@ -51,17 +51,17 @@ public class CommandBlockStorage implements StorableObject { blocks.put(position, tag); } - private Pair getChunkCoords(Position position) { + private Pair getChunkCoords(BlockPosition position) { int chunkX = Math.floorDiv(position.x(), 16); int chunkZ = Math.floorDiv(position.z(), 16); return new Pair<>(chunkX, chunkZ); } - public Optional getCommandBlock(Position position) { + public Optional getCommandBlock(BlockPosition position) { Pair chunkCoords = getChunkCoords(position); - Map blocks = storedCommandBlocks.get(chunkCoords); + Map blocks = storedCommandBlocks.get(chunkCoords); if (blocks == null) return Optional.empty(); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/EntityTracker1_9.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/EntityTracker1_9.java index 45be3cb11..593b28c72 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/EntityTracker1_9.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/storage/EntityTracker1_9.java @@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.legacy.bossbar.BossBar; import com.viaversion.viaversion.api.legacy.bossbar.BossColor; import com.viaversion.viaversion.api.legacy.bossbar.BossStyle; import com.viaversion.viaversion.api.minecraft.GameMode; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_9.EntityType; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; @@ -58,14 +58,14 @@ public class EntityTracker1_9 extends EntityTrackerBase { private final Int2ObjectMap bossBarMap = new Int2ObjectOpenHashMap<>(); private final IntSet validBlocking = new IntOpenHashSet(); private final IntSet knownHolograms = new IntOpenHashSet(); - private final Set blockInteractions = Collections.newSetFromMap(CacheBuilder.newBuilder() + private final Set blockInteractions = Collections.newSetFromMap(CacheBuilder.newBuilder() .maximumSize(1000) .expireAfterAccess(250, TimeUnit.MILLISECONDS) - .build() + .build() .asMap()); private boolean blocking; private boolean autoTeam; - private Position currentlyDigging; + private BlockPosition currentlyDigging; private boolean teamExists; private GameMode gameMode; private String currentTeam; @@ -144,10 +144,10 @@ public class EntityTracker1_9 extends EntityTrackerBase { } public boolean interactedBlockRecently(int x, int y, int z) { - return blockInteractions.contains(new Position(x, y, z)); + return blockInteractions.contains(new BlockPosition(x, y, z)); } - public void addBlockInteraction(Position p) { + public void addBlockInteraction(BlockPosition p) { blockInteractions.add(p); } @@ -327,7 +327,7 @@ public class EntityTracker1_9 extends EntityTrackerBase { return knownHolograms; } - public Set getBlockInteractions() { + public Set getBlockInteractions() { return blockInteractions; } @@ -347,11 +347,11 @@ public class EntityTracker1_9 extends EntityTrackerBase { this.autoTeam = autoTeam; } - public Position getCurrentlyDigging() { + public BlockPosition getCurrentlyDigging() { return currentlyDigging; } - public void setCurrentlyDigging(Position currentlyDigging) { + public void setCurrentlyDigging(BlockPosition currentlyDigging) { this.currentlyDigging = currentlyDigging; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_1to1_9_3/Protocol1_9_1To1_9_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_1to1_9_3/Protocol1_9_1To1_9_3.java index cfffc4a4f..0067e2ad9 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_1to1_9_3/Protocol1_9_1To1_9_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_9_1to1_9_3/Protocol1_9_1To1_9_3.java @@ -23,7 +23,7 @@ import com.viaversion.nbt.tag.IntTag; import com.viaversion.nbt.tag.StringTag; 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.BlockPosition; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; @@ -60,7 +60,7 @@ public class Protocol1_9_1To1_9_3 extends AbstractProtocol { //read data - Position position = wrapper.read(Types.BLOCK_POSITION1_8); + BlockPosition position = wrapper.read(Types.BLOCK_POSITION1_8); JsonElement[] lines = new JsonElement[4]; for (int i = 0; i < 4; i++) { lines[i] = wrapper.read(Types.COMPONENT); diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java index c66c12f23..8887032fb 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java @@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.Mappings; import com.viaversion.viaversion.api.data.entity.EntityTracker; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; -import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity; import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntityImpl; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; @@ -45,10 +45,10 @@ import org.checkerframework.checker.nullness.qual.Nullable; public class BlockRewriter { private final Protocol protocol; - private final Type positionType; + private final Type positionType; private final Type compoundTagType; - public BlockRewriter(Protocol protocol, Type positionType, Type compoundTagType) { + public BlockRewriter(Protocol protocol, Type positionType, Type compoundTagType) { this.protocol = protocol; this.positionType = positionType; this.compoundTagType = compoundTagType; @@ -260,7 +260,7 @@ public class BlockRewriter { public void registerBlockEntityData(C packetType, @Nullable Consumer blockEntityHandler) { protocol.registerClientbound(packetType, wrapper -> { - final Position position = wrapper.passthrough(positionType); + final BlockPosition position = wrapper.passthrough(positionType); final int blockEntityId = wrapper.read(Types.VAR_INT); final Mappings mappings = protocol.getMappingData().getBlockEntityMappings();