From f2147179c2bcf9bd53affc36d0596088742d3725 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 28 Aug 2021 22:15:28 +0200 Subject: [PATCH] Small fixes, add majorVersion method, nicer getter names in some classes None of the deprecated methods will be removed anytime soon. --- .../api/protocol/ProtocolVersion.java | 6 ++-- .../com/viaversion/viaversion/api/ViaAPI.java | 16 +++++++-- .../viaversion/api/data/MappingDataBase.java | 6 ++-- .../viaversion/api/minecraft/BlockFace.java | 20 +++++++++++ .../viaversion/api/minecraft/Environment.java | 5 +++ .../viaversion/api/minecraft/EulerAngle.java | 15 ++++++++ .../viaversion/api/minecraft/Position.java | 25 +++++++++++--- .../api/minecraft/RegistryType.java | 5 +++ .../viaversion/api/minecraft/Vector.java | 34 ++++++++++++++----- .../api/minecraft/VillagerData.java | 15 ++++++++ .../api/minecraft/metadata/Metadata.java | 2 +- .../api/protocol/ProtocolPathEntry.java | 16 +++++++-- .../api/protocol/ProtocolPathKey.java | 14 ++++++-- .../api/protocol/version/ProtocolVersion.java | 6 ++-- .../api/protocol/version/VersionRange.java | 19 +++++++++-- .../type/types/minecraft/EulerAngleType.java | 6 ++-- .../types/minecraft/Position1_14Type.java | 6 ++-- .../type/types/minecraft/PositionType.java | 6 ++-- .../api/type/types/minecraft/VectorType.java | 6 ++-- .../types/minecraft/VillagerDataType.java | 6 ++-- .../bungee/handlers/BungeeServerHandler.java | 2 +- .../protocol/ProtocolManagerImpl.java | 2 +- .../protocol/ProtocolPathEntryImpl.java | 8 ++--- .../protocol/ProtocolPathKeyImpl.java | 4 +-- .../VersionedPacketTransformerImpl.java | 2 +- .../protocols/base/BaseProtocol.java | 4 +-- .../Protocol1_13To1_12_2.java | 6 ++-- .../blockconnections/ConnectionData.java | 6 ++-- .../blockconnections/ConnectionHandler.java | 2 +- .../StairConnectionHandler.java | 4 +-- .../packets/WorldPackets.java | 8 ++--- .../storage/BlockConnectionStorage.java | 4 +-- .../packets/WorldPackets.java | 14 ++++---- .../Protocol1_17To1_16_4.java | 4 +-- .../Protocol1_9_3To1_9_1_2.java | 6 ++-- .../packets/WorldPackets.java | 18 +++++----- .../storage/CommandBlockStorage.java | 4 +-- .../viaversion/rewriter/EntityRewriter.java | 4 +-- 38 files changed, 238 insertions(+), 98 deletions(-) diff --git a/api-legacy/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java b/api-legacy/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java index e83d85ddd..8a1d8f48c 100644 --- a/api-legacy/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java +++ b/api-legacy/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java @@ -167,12 +167,12 @@ public class ProtocolVersion { Preconditions.checkArgument(!versionWildcard || versionRange == null, "A version cannot be a wildcard and a range at the same time!"); if (versionRange != null) { includedVersions = new LinkedHashSet<>(); - for (int i = versionRange.getRangeFrom(); i <= versionRange.getRangeTo(); i++) { + for (int i = versionRange.rangeFrom(); i <= versionRange.rangeTo(); i++) { if (i == 0) { - includedVersions.add(versionRange.getBaseVersion()); // Keep both the base version and with ".0" appended + includedVersions.add(versionRange.baseVersion()); // Keep both the base version and with ".0" appended } - includedVersions.add(versionRange.getBaseVersion() + "." + i); + includedVersions.add(versionRange.baseVersion() + "." + i); } } else { includedVersions = Collections.singleton(name); diff --git a/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java b/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java index 46203d447..8243fad19 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java +++ b/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java @@ -46,13 +46,25 @@ import java.util.UUID; public interface ViaAPI { /** - * Returns the API version incremented with meaningful API changes. + * Returns the major version matching {@link #getVersion()}. + * It is highly advised to check against the major version and to disable/not initiate + * any hooks into ViaVersion if given and expected versions do not match. + * + * @return major plugin version + * @since 4.0.2 + */ + default int majorVersion() { + return 4; + } + + /** + * Returns an internally based API version incremented with meaningful API changes. * This includes breaking changes to existing API and larger additions. * * @return API version incremented with meaningful API changes */ default int apiVersion() { - return 4; + return 5; } /** diff --git a/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataBase.java b/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataBase.java index f298f9892..d7bad562f 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataBase.java +++ b/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataBase.java @@ -89,10 +89,10 @@ public class MappingDataBase implements MappingData { if (diffmapping != null && diffmapping.has("tags")) { this.tags = new EnumMap<>(RegistryType.class); JsonObject tags = diffmapping.getAsJsonObject("tags"); - if (tags.has(RegistryType.ITEM.getResourceLocation())) { + if (tags.has(RegistryType.ITEM.resourceLocation())) { loadTags(RegistryType.ITEM, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("items"))); } - if (tags.has(RegistryType.BLOCK.getResourceLocation())) { + if (tags.has(RegistryType.BLOCK.resourceLocation())) { loadTags(RegistryType.BLOCK, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("blocks"))); } } @@ -101,7 +101,7 @@ public class MappingDataBase implements MappingData { } private void loadTags(RegistryType type, JsonObject object, Object2IntMap typeMapping) { - JsonObject tags = object.getAsJsonObject(type.getResourceLocation()); + JsonObject tags = object.getAsJsonObject(type.resourceLocation()); List tagsList = new ArrayList<>(tags.size()); for (Map.Entry entry : tags.entrySet()) { JsonArray array = entry.getValue().getAsJsonArray(); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/BlockFace.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/BlockFace.java index 96539fd3f..6ab0863c7 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/BlockFace.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/BlockFace.java @@ -62,18 +62,38 @@ public enum BlockFace { return opposites.get(this); } + public byte modX() { + return modX; + } + + public byte modY() { + return modY; + } + + public byte modZ() { + return modZ; + } + + public EnumAxis axis() { + return axis; + } + + @Deprecated/*(forRemoval = true)*/ public byte getModX() { return modX; } + @Deprecated/*(forRemoval = true)*/ public byte getModY() { return modY; } + @Deprecated/*(forRemoval = true)*/ public byte getModZ() { return modZ; } + @Deprecated/*(forRemoval = true)*/ public EnumAxis getAxis() { return axis; } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/Environment.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/Environment.java index 4cb1b2588..325f0dfe8 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/Environment.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/Environment.java @@ -34,6 +34,11 @@ public enum Environment { this.id = id; } + public int id() { + return id; + } + + @Deprecated/*(forRemoval = true)*/ public int getId() { return id; } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/EulerAngle.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/EulerAngle.java index 49e6d1d93..4dd187dbd 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/EulerAngle.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/EulerAngle.java @@ -33,14 +33,29 @@ public class EulerAngle { this.z = z; } + public float x() { + return x; + } + + public float y() { + return y; + } + + public float z() { + return z; + } + + @Deprecated/*(forRemoval = true)*/ public float getX() { return x; } + @Deprecated/*(forRemoval = true)*/ public float getY() { return y; } + @Deprecated/*(forRemoval = true)*/ public float getZ() { return z; } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/Position.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/Position.java index 37eedcfa6..5033a7102 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/Position.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/Position.java @@ -33,28 +33,43 @@ public class Position { this.z = z; } + @Deprecated/*(forRemoval=true)*/ public Position(int x, short y, int z) { - this.x = x; - this.y = y; - this.z = z; + this(x, (int) y, z); } + @Deprecated/*(forRemoval=true)*/ public Position(Position toCopy) { - this(toCopy.getX(), toCopy.getY(), toCopy.getZ()); + this(toCopy.x(), toCopy.y(), toCopy.z()); } public Position getRelative(BlockFace face) { - return new Position(x + face.getModX(), (short) (y + face.getModY()), z + face.getModZ()); + return new Position(x + face.modX(), (short) (y + face.modY()), z + face.modZ()); } + public int x() { + return x; + } + + public int y() { + return y; + } + + public int z() { + return z; + } + + @Deprecated/*(forRemoval=true)*/ public int getX() { return x; } + @Deprecated/*(forRemoval=true)*/ public int getY() { return y; } + @Deprecated/*(forRemoval=true)*/ public int getZ() { return z; } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/RegistryType.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/RegistryType.java index 410c9c3b9..07e458b20 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/RegistryType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/RegistryType.java @@ -58,7 +58,12 @@ public enum RegistryType { this.resourceLocation = resourceLocation; } + @Deprecated/*(forRemoval = true)*/ public String getResourceLocation() { return resourceLocation; } + + public String resourceLocation() { + return resourceLocation; + } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/Vector.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/Vector.java index ab5f0882d..5e4b37dad 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/Vector.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/Vector.java @@ -33,26 +33,44 @@ public class Vector { this.blockZ = blockZ; } + public int blockX() { + return blockX; + } + + public int blockY() { + return blockY; + } + + public int blockZ() { + return blockZ; + } + + @Deprecated/*(forRemoval=true)*/ public int getBlockX() { return blockX; } - public void setBlockX(int blockX) { - this.blockX = blockX; - } - + @Deprecated/*(forRemoval=true)*/ public int getBlockY() { return blockY; } - public void setBlockY(int blockY) { - this.blockY = blockY; - } - + @Deprecated/*(forRemoval=true)*/ public int getBlockZ() { return blockZ; } + @Deprecated/*(forRemoval=true)*/ + public void setBlockX(int blockX) { + this.blockX = blockX; + } + + @Deprecated/*(forRemoval=true)*/ + public void setBlockY(int blockY) { + this.blockY = blockY; + } + + @Deprecated/*(forRemoval=true)*/ public void setBlockZ(int blockZ) { this.blockZ = blockZ; } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/VillagerData.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/VillagerData.java index 89973d642..19dec8af1 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/VillagerData.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/VillagerData.java @@ -33,14 +33,29 @@ public class VillagerData { this.level = level; } + public int type() { + return type; + } + + public int profession() { + return profession; + } + + public int level() { + return level; + } + + @Deprecated/*(forRemoval=true)*/ public int getType() { return type; } + @Deprecated/*(forRemoval=true)*/ public int getProfession() { return profession; } + @Deprecated/*(forRemoval=true)*/ public int getLevel() { return level; } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/Metadata.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/Metadata.java index 41ded9288..1c2677ba2 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/Metadata.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/Metadata.java @@ -121,7 +121,7 @@ public final class Metadata { if (o == null || getClass() != o.getClass()) return false; Metadata metadata = (Metadata) o; if (id != metadata.id) return false; - if (metaType != metaType) return false; + if (metaType != metadata.metaType) return false; return Objects.equals(value, metadata.value); } diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolPathEntry.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolPathEntry.java index 50c896623..ad0dc380e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolPathEntry.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolPathEntry.java @@ -26,16 +26,26 @@ public interface ProtocolPathEntry { /** * Returns the resulting protocol after transformation using - * the {@link #getProtocol()} protocol handlers. + * the {@link #protocol()} protocol handlers. * * @return output protocol version after transformation */ - int getOutputProtocolVersion(); + int outputProtocolVersion(); /** * Returns the protocol to be applied with this entry. * * @return protocol to be applied with this entry */ - Protocol getProtocol(); + Protocol protocol(); + + @Deprecated/*(forRemoval = true)*/ + default int getOutputProtocolVersion() { + return outputProtocolVersion(); + } + + @Deprecated/*(forRemoval = true)*/ + default Protocol getProtocol() { + return protocol(); + } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolPathKey.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolPathKey.java index a0724c9c3..65acff633 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolPathKey.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolPathKey.java @@ -29,12 +29,22 @@ public interface ProtocolPathKey { * * @return client protocol version */ - int getClientProtocolVersion(); + int clientProtocolVersion(); /** * Returns the server protocol version. * * @return server protocol version */ - int getServerProtocolVersion(); + int serverProtocolVersion(); + + @Deprecated/*(forRemoval = true)*/ + default int getClientProtocolVersion() { + return clientProtocolVersion(); + } + + @Deprecated/*(forRemoval = true)*/ + default int getServerProtocolVersion() { + return serverProtocolVersion(); + } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java index 9b216366c..15f7e226f 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java @@ -215,12 +215,12 @@ public class ProtocolVersion { Preconditions.checkArgument(!versionWildcard || versionRange == null, "A version cannot be a wildcard and a range at the same time!"); if (versionRange != null) { includedVersions = new LinkedHashSet<>(); - for (int i = versionRange.getRangeFrom(); i <= versionRange.getRangeTo(); i++) { + for (int i = versionRange.rangeFrom(); i <= versionRange.rangeTo(); i++) { if (i == 0) { - includedVersions.add(versionRange.getBaseVersion()); // Keep both the base version and with ".0" appended + includedVersions.add(versionRange.baseVersion()); // Keep both the base version and with ".0" appended } - includedVersions.add(versionRange.getBaseVersion() + "." + i); + includedVersions.add(versionRange.baseVersion() + "." + i); } } else { includedVersions = Collections.singleton(name); diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/VersionRange.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/VersionRange.java index ea2c55fd6..0c3fc90c0 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/VersionRange.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/VersionRange.java @@ -50,7 +50,7 @@ public class VersionRange { * * @return major version name */ - public String getBaseVersion() { + public String baseVersion() { return baseVersion; } @@ -59,7 +59,7 @@ public class VersionRange { * * @return lowest included minor version */ - public int getRangeFrom() { + public int rangeFrom() { return rangeFrom; } @@ -68,6 +68,21 @@ public class VersionRange { * * @return highest included minor version */ + public int rangeTo() { + return rangeTo; + } + + @Deprecated/*(forRemoval = true)*/ + public String getBaseVersion() { + return baseVersion; + } + + @Deprecated/*(forRemoval = true)*/ + public int getRangeFrom() { + return rangeFrom; + } + + @Deprecated/*(forRemoval = true)*/ public int getRangeTo() { return rangeTo; } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/EulerAngleType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/EulerAngleType.java index 39c6afa95..d4f281f8e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/EulerAngleType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/EulerAngleType.java @@ -42,8 +42,8 @@ public class EulerAngleType extends Type { @Override public void write(ByteBuf buffer, EulerAngle object) throws Exception { - Type.FLOAT.writePrimitive(buffer, object.getX()); - Type.FLOAT.writePrimitive(buffer, object.getY()); - Type.FLOAT.writePrimitive(buffer, object.getZ()); + Type.FLOAT.writePrimitive(buffer, object.x()); + Type.FLOAT.writePrimitive(buffer, object.y()); + Type.FLOAT.writePrimitive(buffer, object.z()); } } \ No newline at end of file diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/Position1_14Type.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/Position1_14Type.java index d3c9d3522..665734083 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/Position1_14Type.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/Position1_14Type.java @@ -44,8 +44,8 @@ public class Position1_14Type extends Type { @Override public void write(ByteBuf buffer, Position object) { - buffer.writeLong((((long) object.getX() & 0x3ffffff) << 38) - | (object.getY() & 0xfff) - | ((((long) object.getZ()) & 0x3ffffff) << 12)); + buffer.writeLong((((long) object.x() & 0x3ffffff) << 38) + | (object.y() & 0xfff) + | ((((long) object.z()) & 0x3ffffff) << 12)); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PositionType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PositionType.java index 81c9fb9a1..be714e708 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PositionType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PositionType.java @@ -44,8 +44,8 @@ public class PositionType extends Type { @Override public void write(ByteBuf buffer, Position object) { - buffer.writeLong((((long) object.getX() & 0x3ffffff) << 38) - | ((((long) object.getY()) & 0xfff) << 26) - | (object.getZ() & 0x3ffffff)); + buffer.writeLong((((long) object.x() & 0x3ffffff) << 38) + | ((((long) object.y()) & 0xfff) << 26) + | (object.z() & 0x3ffffff)); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/VectorType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/VectorType.java index d322027a1..baeacee64 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/VectorType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/VectorType.java @@ -42,8 +42,8 @@ public class VectorType extends Type { @Override public void write(ByteBuf buffer, Vector object) throws Exception { - Type.INT.write(buffer, object.getBlockX()); - Type.INT.write(buffer, object.getBlockY()); - Type.INT.write(buffer, object.getBlockZ()); + Type.INT.write(buffer, object.blockX()); + Type.INT.write(buffer, object.blockY()); + Type.INT.write(buffer, object.blockZ()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/VillagerDataType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/VillagerDataType.java index 1132026e5..7e391b3bc 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/VillagerDataType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/VillagerDataType.java @@ -38,8 +38,8 @@ public class VillagerDataType extends Type { @Override public void write(ByteBuf buffer, VillagerData object) throws Exception { - Type.VAR_INT.writePrimitive(buffer, object.getType()); - Type.VAR_INT.writePrimitive(buffer, object.getProfession()); - Type.VAR_INT.writePrimitive(buffer, object.getLevel()); + Type.VAR_INT.writePrimitive(buffer, object.type()); + Type.VAR_INT.writePrimitive(buffer, object.profession()); + Type.VAR_INT.writePrimitive(buffer, object.level()); } } diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java index a981d1525..836da0908 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java @@ -194,7 +194,7 @@ public class BungeeServerHandler implements Listener { } else { List protocols = new ArrayList<>(protocolPath.size()); for (ProtocolPathEntry entry : protocolPath) { - protocols.add(entry.getProtocol()); + protocols.add(entry.protocol()); } pipeline.add(protocols); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolManagerImpl.java b/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolManagerImpl.java index 53e8bea45..d50ed230a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolManagerImpl.java +++ b/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolManagerImpl.java @@ -236,7 +236,7 @@ public class ProtocolManagerImpl implements ProtocolManager { supportedVersions.add(version.getVersion()); for (ProtocolPathEntry pathEntry : protocolPath) { - supportedVersions.add(pathEntry.getOutputProtocolVersion()); + supportedVersions.add(pathEntry.outputProtocolVersion()); } } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPathEntryImpl.java b/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPathEntryImpl.java index 3cac8ac06..b65f6062a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPathEntryImpl.java +++ b/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPathEntryImpl.java @@ -22,20 +22,20 @@ import com.viaversion.viaversion.api.protocol.ProtocolPathEntry; public class ProtocolPathEntryImpl implements ProtocolPathEntry { private final int outputProtocolVersion; - private final Protocol protocol; + private final Protocol protocol; - public ProtocolPathEntryImpl(int outputProtocolVersion, Protocol protocol) { + public ProtocolPathEntryImpl(int outputProtocolVersion, Protocol protocol) { this.outputProtocolVersion = outputProtocolVersion; this.protocol = protocol; } @Override - public int getOutputProtocolVersion() { + public int outputProtocolVersion() { return outputProtocolVersion; } @Override - public Protocol getProtocol() { + public Protocol protocol() { return protocol; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPathKeyImpl.java b/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPathKeyImpl.java index 3c476dac8..68858cf62 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPathKeyImpl.java +++ b/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPathKeyImpl.java @@ -29,12 +29,12 @@ public class ProtocolPathKeyImpl implements ProtocolPathKey { } @Override - public int getClientProtocolVersion() { + public int clientProtocolVersion() { return clientProtocolVersion; } @Override - public int getServerProtocolVersion() { + public int serverProtocolVersion() { return serverProtocolVersion; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocol/packet/VersionedPacketTransformerImpl.java b/common/src/main/java/com/viaversion/viaversion/protocol/packet/VersionedPacketTransformerImpl.java index c7e7cfdf0..fa7145e1a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocol/packet/VersionedPacketTransformerImpl.java +++ b/common/src/main/java/com/viaversion/viaversion/protocol/packet/VersionedPacketTransformerImpl.java @@ -152,7 +152,7 @@ public class VersionedPacketTransformerImpl(path.size()); for (ProtocolPathEntry entry : path) { - protocolList.add(entry.getProtocol()); + protocolList.add(entry.protocol()); } } else if (serverProtocolVersion != clientProtocolVersion) { throw new RuntimeException("No protocol path between client version " + clientProtocolVersion + " and server version " + serverProtocolVersion); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java index 5ee673481..2c37f1d9a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java @@ -72,10 +72,10 @@ public class BaseProtocol extends AbstractProtocol { if (protocolPath != null) { List protocols = new ArrayList<>(protocolPath.size()); for (ProtocolPathEntry entry : protocolPath) { - protocols.add(entry.getProtocol()); + protocols.add(entry.protocol()); // Ensure mapping data has already been loaded - Via.getManager().getProtocolManager().completeMappingDataLoading(entry.getProtocol().getClass()); + Via.getManager().getProtocolManager().completeMappingDataLoading(entry.protocol().getClass()); } // Add protocols to pipeline diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index 0f4940027..4852653c7 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -108,9 +108,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol { Position position = wrapper.read(Type.POSITION); - wrapper.write(Type.INT, position.getX()); - wrapper.write(Type.INT, position.getY()); - wrapper.write(Type.INT, position.getZ()); + wrapper.write(Type.INT, position.x()); + wrapper.write(Type.INT, position.y()); + wrapper.write(Type.INT, position.z()); }; private static final PacketHandler SEND_DECLARE_COMMANDS_AND_TAGS = diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java index 797a0c488..5cdd823cd 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java @@ -58,7 +58,7 @@ public class ConnectionData { public static void update(UserConnection user, Position position) { for (BlockFace face : BlockFace.values()) { Position pos = position.getRelative(face); - int blockState = blockConnectionProvider.getBlockData(user, pos.getX(), pos.getY(), pos.getZ()); + int blockState = blockConnectionProvider.getBlockData(user, pos.x(), pos.y(), pos.z()); ConnectionHandler handler = connectionHandlerMap.get(blockState); if (handler == null) continue; @@ -151,12 +151,12 @@ public class ConnectionData { } public static void updateBlock(UserConnection user, Position pos, List records) { - int blockState = blockConnectionProvider.getBlockData(user, pos.getX(), pos.getY(), pos.getZ()); + int blockState = blockConnectionProvider.getBlockData(user, pos.x(), pos.y(), pos.z()); ConnectionHandler handler = getConnectionHandler(blockState); if (handler == null) return; int newBlockState = handler.connect(user, pos, blockState); - records.add(new BlockChangeRecord1_8(pos.getX() & 0xF, pos.getY(), pos.getZ() & 0xF, newBlockState)); + records.add(new BlockChangeRecord1_8(pos.x() & 0xF, pos.y(), pos.z() & 0xF, newBlockState)); } public static void updateBlockStorage(UserConnection userConnection, int x, int y, int z, int blockState) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionHandler.java index 4efcc8fb9..8f4ea3097 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionHandler.java @@ -27,6 +27,6 @@ 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.getX(), position.getY(), position.getZ()); + return Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockData(user, position.x(), position.y(), position.z()); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/StairConnectionHandler.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/StairConnectionHandler.java index 55383d9bb..952f28638 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/StairConnectionHandler.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/blockconnections/StairConnectionHandler.java @@ -122,7 +122,7 @@ public class StairConnectionHandler extends ConnectionHandler { StairData relativeStair = stairDataMap.get(getBlockData(user, position.getRelative(facing))); if (relativeStair != null && relativeStair.isBottom() == stair.isBottom()) { BlockFace facing2 = relativeStair.getFacing(); - if (facing.getAxis() != facing2.getAxis() && checkOpposite(user, stair, position, facing2.opposite())) { + if (facing.axis() != facing2.axis() && checkOpposite(user, stair, position, facing2.opposite())) { return facing2 == rotateAntiClockwise(facing) ? 3 : 4; // outer_left : outer_right } } @@ -130,7 +130,7 @@ public class StairConnectionHandler extends ConnectionHandler { relativeStair = stairDataMap.get(getBlockData(user, position.getRelative(facing.opposite()))); if (relativeStair != null && relativeStair.isBottom() == stair.isBottom()) { BlockFace facing2 = relativeStair.getFacing(); - if (facing.getAxis() != facing2.getAxis() && checkOpposite(user, stair, position, facing2)) { + if (facing.axis() != facing2.axis() && checkOpposite(user, stair, position, facing2)) { return facing2 == rotateAntiClockwise(facing) ? 1 : 2; // inner_left : inner_right } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java index 99220b3d1..a4a5e916d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java @@ -167,7 +167,7 @@ public class WorldPackets { if (blockId == 73) { // Note block PacketWrapper blockChange = wrapper.create(0x0B); // block change - blockChange.write(Type.POSITION, new Position(pos)); // Clone because position is mutable + blockChange.write(Type.POSITION, pos); blockChange.write(Type.VAR_INT, 249 + (action * 24 * 2) + (param * 2)); blockChange.send(Protocol1_13To1_12_2.class); } @@ -191,7 +191,7 @@ public class WorldPackets { UserConnection userConnection = wrapper.user(); if (Via.getConfig().isServersideBlockConnections()) { - ConnectionData.updateBlockStorage(userConnection, position.getX(), position.getY(), position.getZ(), newId); + ConnectionData.updateBlockStorage(userConnection, position.x(), position.y(), position.z(), newId); newId = ConnectionData.connect(userConnection, position, newId); } wrapper.set(Type.VAR_INT, 0, checkStorage(wrapper.user(), position, newId)); @@ -229,7 +229,7 @@ public class WorldPackets { record.getSectionZ() + (chunkZ * 16)); if (Via.getConfig().isServersideBlockConnections()) { - ConnectionData.updateBlockStorage(userConnection, position.getX(), position.getY(), position.getZ(), newBlock); + ConnectionData.updateBlockStorage(userConnection, position.x(), position.y(), position.z(), newBlock); } record.setBlockId(checkStorage(wrapper.user(), position, newBlock)); } @@ -297,7 +297,7 @@ public class WorldPackets { records[i] = position; // Set to air - ConnectionData.updateBlockStorage(userConnection, position.getX(), position.getY(), position.getZ(), 0); + ConnectionData.updateBlockStorage(userConnection, position.x(), position.y(), position.z(), 0); } // Workaround for packet order issue diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java index 9c324932b..5b38a5216 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java @@ -133,7 +133,7 @@ public class BlockConnectionStorage implements StorableObject { } private long getChunkSectionIndex(Position position) { - return getChunkSectionIndex(position.getX(), position.getY(), position.getZ()); + return getChunkSectionIndex(position.x(), position.y(), position.z()); } private short encodeBlockPos(int x, int y, int z) { @@ -141,7 +141,7 @@ public class BlockConnectionStorage implements StorableObject { } private short encodeBlockPos(Position pos) { - return encodeBlockPos(pos.getX(), pos.getY(), pos.getZ()); + return encodeBlockPos(pos.x(), pos.y(), pos.z()); } private Map createLongObjectMap() { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java index beb140bf7..f9d81957c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java @@ -410,14 +410,14 @@ public class WorldPackets { for (BlockFace blockFace : BlockFace.values()) { NibbleArray skyLightArray = section.getLight().getSkyLightNibbleArray(); NibbleArray blockLightArray = section.getLight().getBlockLightNibbleArray(); - int neighbourX = x + blockFace.getModX(); - int neighbourY = y + blockFace.getModY(); - int neighbourZ = z + blockFace.getModZ(); + int neighbourX = x + blockFace.modX(); + int neighbourY = y + blockFace.modY(); + int neighbourZ = z + blockFace.modZ(); - if (blockFace.getModX() != 0) { + if (blockFace.modX() != 0) { // Another chunk, nothing we can do without an unnecessary amount of caching if (neighbourX == 16 || neighbourX == -1) continue; - } else if (blockFace.getModY() != 0) { + } else if (blockFace.modY() != 0) { if (neighbourY == 16 || neighbourY == -1) { if (neighbourY == 16) { ySection += 1; @@ -435,7 +435,7 @@ public class WorldPackets { skyLightArray = newSection.getLight().getSkyLightNibbleArray(); blockLightArray = newSection.getLight().getBlockLightNibbleArray(); } - } else if (blockFace.getModZ() != 0) { + } else if (blockFace.modZ() != 0) { // Another chunk, nothing we can do without an unnecessary amount of caching if (neighbourZ == 16 || neighbourZ == -1) continue; } @@ -451,7 +451,7 @@ public class WorldPackets { if (skyLightArray != null && skyLight != 15) { int neighbourSkyLight = skyLightArray.get(neighbourX, neighbourY, neighbourZ); if (neighbourSkyLight == 15) { - if (blockFace.getModY() == 1) { + if (blockFace.modY() == 1) { // Keep 15 if block is exposed to sky skyLight = 15; continue; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java index 6b96ad3f9..36f3b911a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java @@ -67,7 +67,7 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol()); @@ -210,8 +210,8 @@ public class WorldPackets { // Send empty chunks surrounding the loaded chunk to force 1.9+ clients to render the new chunk if (Via.getConfig().isChunkBorderFix()) { for (BlockFace face : BlockFace.HORIZONTAL) { - int chunkX = chunk.getX() + face.getModX(); - int chunkZ = chunk.getZ() + face.getModZ(); + int chunkX = chunk.getX() + face.modX(); + int chunkZ = chunk.getZ() + face.modZ(); if (!clientChunks.getLoadedChunks().contains(ClientChunks.toLong(chunkX, chunkZ))) { PacketWrapper emptyChunk = wrapper.create(ClientboundPackets1_9.CHUNK_DATA); Chunk c = new BaseChunk(chunkX, chunkZ, true, false, 0, new ChunkSection[16], new int[256], new ArrayList<>()); @@ -406,9 +406,9 @@ public class WorldPackets { if (face == 255) return; Position p = wrapper.get(Type.POSITION, 0); - int x = p.getX(); - int y = p.getY(); - int z = p.getZ(); + int x = p.x(); + int y = p.y(); + int z = p.z(); switch (face) { case 0: y--; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/storage/CommandBlockStorage.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/storage/CommandBlockStorage.java index 237524ad0..3ac07d513 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/storage/CommandBlockStorage.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/storage/CommandBlockStorage.java @@ -52,8 +52,8 @@ public class CommandBlockStorage implements StorableObject { } private Pair getChunkCoords(Position position) { - int chunkX = Math.floorDiv(position.getX(), 16); - int chunkZ = Math.floorDiv(position.getZ(), 16); + int chunkX = Math.floorDiv(position.x(), 16); + int chunkZ = Math.floorDiv(position.z(), 16); return new Pair<>(chunkX, chunkZ); } diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java index b53cbfed4..73bb648b9 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java @@ -276,12 +276,12 @@ public abstract class EntityRewriter extends RewriterBase * @param entityType entity type * @param intType int type of the entity id */ - public void registerTracker(ClientboundPacketType packetType, EntityType entityType, Type intType) { + public void registerTracker(ClientboundPacketType packetType, EntityType entityType, Type intType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { handler(wrapper -> { - int entityId = (int) wrapper.passthrough(intType); + int entityId = wrapper.passthrough(intType); tracker(wrapper.user()).addEntity(entityId, entityType); }); }