Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Small fixes, add majorVersion method, nicer getter names in some classes
None of the deprecated methods will be removed anytime soon.
Dieser Commit ist enthalten in:
Ursprung
e7a0b4cf04
Commit
f2147179c2
@ -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);
|
||||
|
@ -46,13 +46,25 @@ import java.util.UUID;
|
||||
public interface ViaAPI<T> {
|
||||
|
||||
/**
|
||||
* Returns the API version incremented with meaningful API changes.
|
||||
* Returns the <b>major version</b> 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 <b>internally based API version</b> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<String> typeMapping) {
|
||||
JsonObject tags = object.getAsJsonObject(type.getResourceLocation());
|
||||
JsonObject tags = object.getAsJsonObject(type.resourceLocation());
|
||||
List<TagData> tagsList = new ArrayList<>(tags.size());
|
||||
for (Map.Entry<String, JsonElement> entry : tags.entrySet()) {
|
||||
JsonArray array = entry.getValue().getAsJsonArray();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -34,6 +34,11 @@ public enum Environment {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -58,7 +58,12 @@ public enum RegistryType {
|
||||
this.resourceLocation = resourceLocation;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public String getResourceLocation() {
|
||||
return resourceLocation;
|
||||
}
|
||||
|
||||
public String resourceLocation() {
|
||||
return resourceLocation;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ public class EulerAngleType extends Type<EulerAngle> {
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
@ -44,8 +44,8 @@ public class Position1_14Type extends Type<Position> {
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ public class PositionType extends Type<Position> {
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ public class VectorType extends Type<Vector> {
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
@ -38,8 +38,8 @@ public class VillagerDataType extends Type<VillagerData> {
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ public class BungeeServerHandler implements Listener {
|
||||
} else {
|
||||
List<Protocol> protocols = new ArrayList<>(protocolPath.size());
|
||||
for (ProtocolPathEntry entry : protocolPath) {
|
||||
protocols.add(entry.getProtocol());
|
||||
protocols.add(entry.protocol());
|
||||
}
|
||||
pipeline.add(protocols);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ public class VersionedPacketTransformerImpl<C extends ClientboundPacketType, S e
|
||||
if (path != null) {
|
||||
protocolList = new ArrayList<>(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);
|
||||
|
@ -72,10 +72,10 @@ public class BaseProtocol extends AbstractProtocol {
|
||||
if (protocolPath != null) {
|
||||
List<Protocol> 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
|
||||
|
@ -108,9 +108,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
|
||||
public static final PacketHandler POS_TO_3_INT = wrapper -> {
|
||||
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 =
|
||||
|
@ -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<BlockChangeRecord1_8> 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) {
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 <T> Map<Long, T> createLongObjectMap() {
|
||||
|
@ -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;
|
||||
|
@ -67,7 +67,7 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
||||
wrapper.write(Type.VAR_INT, 5);
|
||||
for (RegistryType type : RegistryType.getValues()) {
|
||||
// Prefix with resource location
|
||||
wrapper.write(Type.STRING, type.getResourceLocation());
|
||||
wrapper.write(Type.STRING, type.resourceLocation());
|
||||
|
||||
// Id conversion
|
||||
tagRewriter.handle(wrapper, tagRewriter.getRewriter(type), tagRewriter.getNewTags(type));
|
||||
@ -79,7 +79,7 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
||||
}
|
||||
|
||||
// New Game Event tags type
|
||||
wrapper.write(Type.STRING, RegistryType.GAME_EVENT.getResourceLocation());
|
||||
wrapper.write(Type.STRING, RegistryType.GAME_EVENT.resourceLocation());
|
||||
wrapper.write(Type.VAR_INT, NEW_GAME_EVENT_TAGS.length);
|
||||
for (String tag : NEW_GAME_EVENT_TAGS) {
|
||||
wrapper.write(Type.STRING, tag);
|
||||
|
@ -78,9 +78,9 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol<ClientboundPackets1
|
||||
//Create nbt
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("id", new StringTag("Sign"));
|
||||
tag.put("x", new IntTag(position.getX()));
|
||||
tag.put("y", new IntTag(position.getY()));
|
||||
tag.put("z", new IntTag(position.getZ()));
|
||||
tag.put("x", new IntTag(position.x()));
|
||||
tag.put("y", new IntTag(position.y()));
|
||||
tag.put("z", new IntTag(position.z()));
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
tag.put("Text" + (i + 1), new StringTag(lines[i].toString()));
|
||||
}
|
||||
|
@ -156,8 +156,8 @@ public class WorldPackets {
|
||||
// Unload the empty chunks
|
||||
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 unloadChunk = wrapper.create(ClientboundPackets1_9.UNLOAD_CHUNK);
|
||||
unloadChunk.write(Type.INT, chunkX);
|
||||
@ -174,8 +174,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<>());
|
||||
@ -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--;
|
||||
|
@ -52,8 +52,8 @@ public class CommandBlockStorage implements StorableObject {
|
||||
}
|
||||
|
||||
private Pair<Integer, Integer> 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);
|
||||
}
|
||||
|
@ -276,12 +276,12 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
* @param entityType entity type
|
||||
* @param intType int type of the entity id
|
||||
*/
|
||||
public void registerTracker(ClientboundPacketType packetType, EntityType entityType, Type<? extends Integer> intType) {
|
||||
public void registerTracker(ClientboundPacketType packetType, EntityType entityType, Type<Integer> 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);
|
||||
});
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren