Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Rename Position to BlockPosition
Dieser Commit ist enthalten in:
Ursprung
9547cf160d
Commit
c5756fe45c
@ -22,24 +22,19 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.minecraft;
|
package com.viaversion.viaversion.api.minecraft;
|
||||||
|
|
||||||
public class Position {
|
public class BlockPosition {
|
||||||
protected final int x;
|
protected final int x;
|
||||||
protected final int y;
|
protected final int y;
|
||||||
protected final int z;
|
protected final int z;
|
||||||
|
|
||||||
public Position(int x, int y, int z) {
|
public BlockPosition(int x, int y, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Deprecated/*(forRemoval=true)*/ Just leave this unchecked
|
public BlockPosition getRelative(BlockFace face) {
|
||||||
public Position(int x, short y, int z) {
|
return new BlockPosition(x + face.modX(), y + face.modY(), z + face.modZ());
|
||||||
this(x, (int) y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Position getRelative(BlockFace face) {
|
|
||||||
return new Position(x + face.modX(), (short) (y + face.modY()), z + face.modZ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int x() {
|
public int x() {
|
||||||
@ -54,15 +49,15 @@ public class Position {
|
|||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlobalPosition withDimension(String dimension) {
|
public GlobalBlockPosition withDimension(String dimension) {
|
||||||
return new GlobalPosition(dimension, x, y, z);
|
return new GlobalBlockPosition(dimension, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Position position = (Position) o;
|
BlockPosition position = (BlockPosition) o;
|
||||||
if (x != position.x) return false;
|
if (x != position.x) return false;
|
||||||
if (y != position.y) return false;
|
if (y != position.y) return false;
|
||||||
return z == position.z;
|
return z == position.z;
|
||||||
@ -78,7 +73,7 @@ public class Position {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Position{" +
|
return "BlockPosition{" +
|
||||||
"x=" + x +
|
"x=" + x +
|
||||||
", y=" + y +
|
", y=" + y +
|
||||||
", z=" + z +
|
", z=" + z +
|
@ -22,10 +22,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.minecraft;
|
package com.viaversion.viaversion.api.minecraft;
|
||||||
|
|
||||||
public final class GlobalPosition extends Position {
|
public final class GlobalBlockPosition extends BlockPosition {
|
||||||
private final String dimension;
|
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);
|
super(x, y, z);
|
||||||
this.dimension = dimension;
|
this.dimension = dimension;
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ public final class GlobalPosition extends Position {
|
|||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
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 (x != position.x) return false;
|
||||||
if (y != position.y) return false;
|
if (y != position.y) return false;
|
||||||
if (z != position.z) return false;
|
if (z != position.z) return false;
|
||||||
@ -56,7 +56,7 @@ public final class GlobalPosition extends Position {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "GlobalPosition{" +
|
return "GlobalBlockPosition{" +
|
||||||
"dimension='" + dimension + '\'' +
|
"dimension='" + dimension + '\'' +
|
||||||
", x=" + x +
|
", x=" + x +
|
||||||
", y=" + y +
|
", y=" + y +
|
@ -22,18 +22,18 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
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.Type;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
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<LodestoneTracker> TYPE = new Type<>(LodestoneTracker.class) {
|
public static final Type<LodestoneTracker> TYPE = new Type<>(LodestoneTracker.class) {
|
||||||
@Override
|
@Override
|
||||||
public LodestoneTracker read(final ByteBuf buffer) {
|
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();
|
final boolean tracked = buffer.readBoolean();
|
||||||
return new LodestoneTracker(position, tracked);
|
return new LodestoneTracker(position, tracked);
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,10 @@ import com.viaversion.nbt.tag.Tag;
|
|||||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||||
import com.viaversion.viaversion.api.minecraft.EulerAngle;
|
import com.viaversion.viaversion.api.minecraft.EulerAngle;
|
||||||
import com.viaversion.viaversion.api.minecraft.GameProfile;
|
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.HolderSet;
|
||||||
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
|
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.ProfileKey;
|
||||||
import com.viaversion.viaversion.api.minecraft.Quaternion;
|
import com.viaversion.viaversion.api.minecraft.Quaternion;
|
||||||
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
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.item.ItemType1_8;
|
||||||
import com.viaversion.viaversion.api.type.types.math.ChunkPositionType;
|
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.EulerAngleType;
|
||||||
import com.viaversion.viaversion.api.type.types.math.GlobalPositionType;
|
import com.viaversion.viaversion.api.type.types.math.GlobalBlockPositionType;
|
||||||
import com.viaversion.viaversion.api.type.types.math.PositionType1_14;
|
import com.viaversion.viaversion.api.type.types.math.BlockPositionType1_14;
|
||||||
import com.viaversion.viaversion.api.type.types.math.PositionType1_8;
|
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.QuaternionType;
|
||||||
import com.viaversion.viaversion.api.type.types.math.Vector3fType;
|
import com.viaversion.viaversion.api.type.types.math.Vector3fType;
|
||||||
import com.viaversion.viaversion.api.type.types.math.VectorType;
|
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();
|
public static final VarLongType VAR_LONG = new VarLongType();
|
||||||
|
|
||||||
/* MC Types */
|
/* MC Types */
|
||||||
public static final Type<Position> BLOCK_POSITION1_8 = new PositionType1_8();
|
public static final Type<BlockPosition> BLOCK_POSITION1_8 = new BlockPositionType1_8();
|
||||||
public static final Type<Position> OPTIONAL_POSITION1_8 = new PositionType1_8.OptionalPositionType();
|
public static final Type<BlockPosition> OPTIONAL_POSITION1_8 = new BlockPositionType1_8.OptionalBlockPositionType();
|
||||||
public static final Type<Position> BLOCK_POSITION1_14 = new PositionType1_14();
|
public static final Type<BlockPosition> BLOCK_POSITION1_14 = new BlockPositionType1_14();
|
||||||
public static final Type<Position> OPTIONAL_POSITION_1_14 = new PositionType1_14.OptionalPosition1_14Type();
|
public static final Type<BlockPosition> OPTIONAL_POSITION_1_14 = new BlockPositionType1_14.OptionalBlockPositionType();
|
||||||
public static final Type<EulerAngle> ROTATIONS = new EulerAngleType();
|
public static final Type<EulerAngle> ROTATIONS = new EulerAngleType();
|
||||||
public static final Type<Vector> VECTOR = new VectorType();
|
public static final Type<Vector> VECTOR = new VectorType();
|
||||||
public static final Type<Vector3f> VECTOR3F = new Vector3fType();
|
public static final Type<Vector3f> VECTOR3F = new Vector3fType();
|
||||||
@ -167,8 +167,8 @@ public final class Types {
|
|||||||
public static final Type<Tag[]> TAG_ARRAY = new ArrayType<>(TAG);
|
public static final Type<Tag[]> TAG_ARRAY = new ArrayType<>(TAG);
|
||||||
public static final Type<Tag> OPTIONAL_TAG = new TagType.OptionalTagType();
|
public static final Type<Tag> OPTIONAL_TAG = new TagType.OptionalTagType();
|
||||||
|
|
||||||
public static final Type<GlobalPosition> GLOBAL_POSITION = new GlobalPositionType();
|
public static final Type<GlobalBlockPosition> GLOBAL_POSITION = new GlobalBlockPositionType();
|
||||||
public static final Type<GlobalPosition> OPTIONAL_GLOBAL_POSITION = new GlobalPositionType.OptionalGlobalPositionType();
|
public static final Type<GlobalBlockPosition> OPTIONAL_GLOBAL_POSITION = new GlobalBlockPositionType.OptionalGlobalPositionType();
|
||||||
public static final Type<ChunkPosition> CHUNK_POSITION = new ChunkPositionType();
|
public static final Type<ChunkPosition> CHUNK_POSITION = new ChunkPositionType();
|
||||||
|
|
||||||
public static final Type<BlockEntity> BLOCK_ENTITY1_18 = new BlockEntityType1_18();
|
public static final Type<BlockEntity> BLOCK_ENTITY1_18 = new BlockEntityType1_18();
|
||||||
|
@ -22,38 +22,38 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.type.types.math;
|
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.OptionalType;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class PositionType1_14 extends Type<Position> {
|
public class BlockPositionType1_14 extends Type<BlockPosition> {
|
||||||
public PositionType1_14() {
|
public BlockPositionType1_14() {
|
||||||
super(Position.class);
|
super(BlockPosition.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Position read(ByteBuf buffer) {
|
public BlockPosition read(ByteBuf buffer) {
|
||||||
long val = buffer.readLong();
|
long val = buffer.readLong();
|
||||||
|
|
||||||
long x = (val >> 38);
|
long x = (val >> 38);
|
||||||
long y = val << 52 >> 52;
|
long y = val << 52 >> 52;
|
||||||
long z = val << 26 >> 38;
|
long z = val << 26 >> 38;
|
||||||
|
|
||||||
return new Position((int) x, (int) y, (int) z);
|
return new BlockPosition((int) x, (int) y, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buffer, Position object) {
|
public void write(ByteBuf buffer, BlockPosition object) {
|
||||||
buffer.writeLong((((long) object.x() & 0x3ffffff) << 38)
|
buffer.writeLong((((long) object.x() & 0x3ffffff) << 38)
|
||||||
| (object.y() & 0xfff)
|
| (object.y() & 0xfff)
|
||||||
| ((((long) object.z()) & 0x3ffffff) << 12));
|
| ((((long) object.z()) & 0x3ffffff) << 12));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class OptionalPosition1_14Type extends OptionalType<Position> {
|
public static final class OptionalBlockPositionType extends OptionalType<BlockPosition> {
|
||||||
|
|
||||||
public OptionalPosition1_14Type() {
|
public OptionalBlockPositionType() {
|
||||||
super(Types.BLOCK_POSITION1_14);
|
super(Types.BLOCK_POSITION1_14);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,36 +22,36 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.type.types.math;
|
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.OptionalType;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class PositionType1_8 extends Type<Position> {
|
public class BlockPositionType1_8 extends Type<BlockPosition> {
|
||||||
|
|
||||||
public PositionType1_8() {
|
public BlockPositionType1_8() {
|
||||||
super(Position.class);
|
super(BlockPosition.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Position read(ByteBuf buffer) {
|
public BlockPosition read(ByteBuf buffer) {
|
||||||
final long val = buffer.readLong();
|
final long val = buffer.readLong();
|
||||||
final long x = (val >> 38);
|
final long x = (val >> 38);
|
||||||
final long y = (val << 26) >> 52;
|
final long y = (val << 26) >> 52;
|
||||||
final long z = (val << 38) >> 38;
|
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
|
@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));
|
buffer.writeLong((object.x() & 0X3FFFFFFL) << 38 | (object.y() & 0XFFFL) << 26 | (object.z() & 0X3FFFFFFL));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class OptionalPositionType extends OptionalType<Position> {
|
public static final class OptionalBlockPositionType extends OptionalType<BlockPosition> {
|
||||||
|
|
||||||
public OptionalPositionType() {
|
public OptionalBlockPositionType() {
|
||||||
super(Types.BLOCK_POSITION1_8);
|
super(Types.BLOCK_POSITION1_8);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,31 +22,31 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.type.types.math;
|
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.OptionalType;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class GlobalPositionType extends Type<GlobalPosition> {
|
public class GlobalBlockPositionType extends Type<GlobalBlockPosition> {
|
||||||
|
|
||||||
public GlobalPositionType() {
|
public GlobalBlockPositionType() {
|
||||||
super(GlobalPosition.class);
|
super(GlobalBlockPosition.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalPosition read(ByteBuf buffer) {
|
public GlobalBlockPosition read(ByteBuf buffer) {
|
||||||
final String dimension = Types.STRING.read(buffer);
|
final String dimension = Types.STRING.read(buffer);
|
||||||
return Types.BLOCK_POSITION1_14.read(buffer).withDimension(dimension);
|
return Types.BLOCK_POSITION1_14.read(buffer).withDimension(dimension);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buffer, GlobalPosition object) {
|
public void write(ByteBuf buffer, GlobalBlockPosition object) {
|
||||||
Types.STRING.write(buffer, object.dimension());
|
Types.STRING.write(buffer, object.dimension());
|
||||||
Types.BLOCK_POSITION1_14.write(buffer, object);
|
Types.BLOCK_POSITION1_14.write(buffer, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class OptionalGlobalPositionType extends OptionalType<GlobalPosition> {
|
public static final class OptionalGlobalPositionType extends OptionalType<GlobalBlockPosition> {
|
||||||
|
|
||||||
public OptionalGlobalPositionType() {
|
public OptionalGlobalPositionType() {
|
||||||
super(Types.GLOBAL_POSITION);
|
super(Types.GLOBAL_POSITION);
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.bukkit.listeners.protocol1_9to1_8;
|
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.bukkit.listeners.ViaBukkitListener;
|
||||||
import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9;
|
import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9;
|
||||||
import com.viaversion.viaversion.protocols.v1_8to1_9.storage.EntityTracker1_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())) {
|
if (isOnPipe(e.getPlayer())) {
|
||||||
Block b = e.getBlockPlaced();
|
Block b = e.getBlockPlaced();
|
||||||
EntityTracker1_9 tracker = getUserConnection(e.getPlayer()).getEntityTracker(Protocol1_8To1_9.class);
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import com.google.gson.JsonParseException;
|
|||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
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.entities.EntityTypes1_13;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
@ -118,7 +118,7 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final PacketHandler POS_TO_3_INT = wrapper -> {
|
public static final PacketHandler POS_TO_3_INT = wrapper -> {
|
||||||
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.x());
|
||||||
wrapper.write(Types.INT, position.y());
|
wrapper.write(Types.INT, position.y());
|
||||||
wrapper.write(Types.INT, position.z());
|
wrapper.write(Types.INT, position.z());
|
||||||
@ -571,7 +571,7 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
// Fake the end of the packet
|
// Fake the end of the packet
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.write(Types.BOOLEAN, false);
|
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);
|
wrapper.write(Types.OPTIONAL_POSITION1_8, playerLookTarget);
|
||||||
if (!wrapper.isCancelled() && Via.getConfig().get1_13TabCompleteDelay() > 0) {
|
if (!wrapper.isCancelled() && Via.getConfig().get1_13TabCompleteDelay() > 0) {
|
||||||
TabCompleteTracker tracker = wrapper.user().get(TabCompleteTracker.class);
|
TabCompleteTracker tracker = wrapper.user().get(TabCompleteTracker.class);
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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 com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
@ -61,7 +61,7 @@ public abstract class AbstractFenceConnectionHandler implements ConnectionHandle
|
|||||||
return states;
|
return states;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte getStates(UserConnection user, Position position) {
|
protected byte getStates(UserConnection user, BlockPosition position) {
|
||||||
byte states = 0;
|
byte states = 0;
|
||||||
boolean pre1_12 = user.getProtocolInfo().serverProtocolVersion().olderThan(ProtocolVersion.v1_12);
|
boolean pre1_12 = user.getProtocolInfo().serverProtocolVersion().olderThan(ProtocolVersion.v1_12);
|
||||||
if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)), pre1_12)) states |= 1;
|
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
|
@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));
|
return STAIR_CONNECTION_HANDLER.connect(user, position, ConnectionHandler.super.getBlockData(user, position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)];
|
final int newBlockState = connectedBlockStates[getStates(user, position)];
|
||||||
return newBlockState == -1 ? blockState : newBlockState;
|
return newBlockState == -1 ? blockState : newBlockState;
|
||||||
}
|
}
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.IntOpenHashSet;
|
||||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
@ -55,7 +55,7 @@ public abstract class AbstractStempConnectionHandler implements ConnectionHandle
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int connect(UserConnection user, Position position, int blockState) {
|
public int connect(UserConnection user, BlockPosition position, int blockState) {
|
||||||
if (blockState != baseStateId) {
|
if (blockState != baseStateId) {
|
||||||
return blockState;
|
return blockState;
|
||||||
}
|
}
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
@ -62,7 +62,7 @@ class ChestConnectionHandler implements ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
BlockFace facing = CHEST_FACINGS.get(blockState);
|
||||||
byte states = 0;
|
byte states = 0;
|
||||||
states |= (facing.ordinal() << 2);
|
states |= (facing.ordinal() << 2);
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected byte getStates(UserConnection user, Position position) {
|
protected byte getStates(UserConnection user, BlockPosition position) {
|
||||||
byte states = super.getStates(user, position);
|
byte states = super.getStates(user, position);
|
||||||
if (connects(BlockFace.TOP, getBlockData(user, position.getRelative(BlockFace.TOP)), false)) states |= 16;
|
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;
|
if (connects(BlockFace.BOTTOM, getBlockData(user, position.getRelative(BlockFace.BOTTOM)), false)) states |= 32;
|
||||||
|
@ -29,7 +29,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_8;
|
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_8;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
@ -64,11 +64,11 @@ public final class ConnectionData {
|
|||||||
KEY_TO_ID.defaultReturnValue(-1);
|
KEY_TO_ID.defaultReturnValue(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void update(UserConnection user, Position position) {
|
public static void update(UserConnection user, BlockPosition position) {
|
||||||
Boolean inSync = null;
|
Boolean inSync = null;
|
||||||
|
|
||||||
for (BlockFace face : BlockFace.values()) {
|
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());
|
int blockState = blockConnectionProvider.getBlockData(user, pos.x(), pos.y(), pos.z());
|
||||||
ConnectionHandler handler = connectionHandlerMap.get(blockState);
|
ConnectionHandler handler = connectionHandlerMap.get(blockState);
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
@ -109,7 +109,7 @@ public final class ConnectionData {
|
|||||||
blockConnectionProvider.clearStorage(connection);
|
blockConnectionProvider.clearStorage(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void markModified(UserConnection connection, Position pos) {
|
public static void markModified(UserConnection connection, BlockPosition pos) {
|
||||||
if (!needStoreBlocks()) return;
|
if (!needStoreBlocks()) return;
|
||||||
blockConnectionProvider.modifiedBlock(connection, pos);
|
blockConnectionProvider.modifiedBlock(connection, pos);
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ public final class ConnectionData {
|
|||||||
continue;
|
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);
|
int connectedId = handler.connect(user, position, id);
|
||||||
if (connectedId != id) {
|
if (connectedId != id) {
|
||||||
blocks.setIdAt(idx, connectedId);
|
blocks.setIdAt(idx, connectedId);
|
||||||
@ -257,7 +257,7 @@ public final class ConnectionData {
|
|||||||
return connectionHandlerMap.containsKey(blockState);
|
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);
|
ConnectionHandler handler = connectionHandlerMap.get(blockState);
|
||||||
return handler != null ? handler.connect(user, position, blockState) : blockState;
|
return handler != null ? handler.connect(user, position, blockState) : blockState;
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ public final class ConnectionData {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Position pos = new Position(x, y, z);
|
BlockPosition pos = new BlockPosition(x, y, z);
|
||||||
int newBlockState = handler.connect(user, pos, blockState);
|
int newBlockState = handler.connect(user, pos, blockState);
|
||||||
if (blockState != newBlockState || !blockConnectionProvider.storesBlocks(user, null)) {
|
if (blockState != newBlockState || !blockConnectionProvider.storesBlocks(user, null)) {
|
||||||
records.add(new BlockChangeRecord1_8(x & 0xF, y, z & 0xF, newBlockState));
|
records.add(new BlockChangeRecord1_8(x & 0xF, y, z & 0xF, newBlockState));
|
||||||
|
@ -18,14 +18,14 @@
|
|||||||
package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections;
|
package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.BlockPosition;
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface ConnectionHandler {
|
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());
|
return ConnectionData.blockConnectionProvider.getBlockData(user, position.x(), position.y(), position.z());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -78,7 +78,7 @@ public class DoorConnectionHandler implements ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
DoorData doorData = DOOR_DATA_MAP.get(blockState);
|
||||||
if (doorData == null) return blockState;
|
if (doorData == null) return blockState;
|
||||||
short s = 0;
|
short s = 0;
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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 com.viaversion.viaversion.util.Key;
|
||||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
@ -76,7 +76,7 @@ public class FireConnectionHandler implements ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int connect(UserConnection user, Position position, int blockState) {
|
public int connect(UserConnection user, BlockPosition position, int blockState) {
|
||||||
byte states = 0;
|
byte states = 0;
|
||||||
if (FLAMMABLE_BLOCKS.contains(getBlockData(user, position.getRelative(BlockFace.EAST)))) states |= 1;
|
if (FLAMMABLE_BLOCKS.contains(getBlockData(user, position.getRelative(BlockFace.EAST)))) states |= 1;
|
||||||
if (FLAMMABLE_BLOCKS.contains(getBlockData(user, position.getRelative(BlockFace.NORTH)))) states |= 2;
|
if (FLAMMABLE_BLOCKS.contains(getBlockData(user, position.getRelative(BlockFace.NORTH)))) states |= 2;
|
||||||
|
@ -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.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.Int2IntMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -52,7 +52,7 @@ public class FlowerConnectionHandler implements ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 blockBelowId = getBlockData(user, position.getRelative(BlockFace.BOTTOM));
|
||||||
int connectBelow = FLOWERS.get(blockBelowId);
|
int connectBelow = FLOWERS.get(blockBelowId);
|
||||||
if (connectBelow != 0) {
|
if (connectBelow != 0) {
|
||||||
|
@ -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.ProtocolInfo;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
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 com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -54,7 +54,7 @@ public class GlassConnectionHandler extends AbstractFenceConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected byte getStates(UserConnection user, Position position) {
|
protected byte getStates(UserConnection user, BlockPosition position) {
|
||||||
byte states = super.getStates(user, position);
|
byte states = super.getStates(user, position);
|
||||||
if (states != 0) return states;
|
if (states != 0) return states;
|
||||||
|
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.Int2IntMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
@ -65,7 +65,7 @@ public class RedstoneConnectionHandler implements ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int connect(UserConnection user, Position position, int blockState) {
|
public int connect(UserConnection user, BlockPosition position, int blockState) {
|
||||||
short b = 0;
|
short b = 0;
|
||||||
b |= connects(user, position, BlockFace.EAST);
|
b |= connects(user, position, BlockFace.EAST);
|
||||||
b |= connects(user, position, BlockFace.NORTH) << 2;
|
b |= connects(user, position, BlockFace.NORTH) << 2;
|
||||||
@ -75,8 +75,8 @@ public class RedstoneConnectionHandler implements ConnectionHandler {
|
|||||||
return CONNECTED_BLOCK_STATES.getOrDefault(b, blockState);
|
return CONNECTED_BLOCK_STATES.getOrDefault(b, blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int connects(UserConnection user, Position position, BlockFace side) {
|
private int connects(UserConnection user, BlockPosition position, BlockFace side) {
|
||||||
final Position relative = position.getRelative(side);
|
final BlockPosition relative = position.getRelative(side);
|
||||||
int blockState = getBlockData(user, relative);
|
int blockState = getBlockData(user, relative);
|
||||||
if (connects(side, blockState)) {
|
if (connects(side, blockState)) {
|
||||||
return 1; //side
|
return 1; //side
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.IntOpenHashSet;
|
||||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
@ -55,7 +55,7 @@ public class SnowyGrassConnectionHandler implements ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 blockUpId = getBlockData(user, position.getRelative(BlockFace.TOP));
|
||||||
int newId = GRASS_BLOCKS.getInt(new GrassBlock(blockState, SNOWY_GRASS_BLOCKS.contains(blockUpId)));
|
int newId = GRASS_BLOCKS.getInt(new GrassBlock(blockState, SNOWY_GRASS_BLOCKS.contains(blockUpId)));
|
||||||
return newId != -1 ? newId : blockState;
|
return newId != -1 ? newId : blockState;
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -103,7 +103,7 @@ public class StairConnectionHandler implements ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
StairData stairData = STAIR_DATA_MAP.get(blockState);
|
||||||
if (stairData == null) return blockState;
|
if (stairData == null) return blockState;
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public class StairConnectionHandler implements ConnectionHandler {
|
|||||||
return newBlockState == null ? blockState : newBlockState;
|
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();
|
BlockFace facing = stair.facing();
|
||||||
|
|
||||||
StairData relativeStair = STAIR_DATA_MAP.get(getBlockData(user, position.getRelative(facing)));
|
StairData relativeStair = STAIR_DATA_MAP.get(getBlockData(user, position.getRelative(facing)));
|
||||||
@ -139,7 +139,7 @@ public class StairConnectionHandler implements ConnectionHandler {
|
|||||||
return 0; // straight
|
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)));
|
StairData relativeStair = STAIR_DATA_MAP.get(getBlockData(user, position.getRelative(face)));
|
||||||
return relativeStair == null || relativeStair.facing() != stair.facing() || relativeStair.bottom() != stair.bottom();
|
return relativeStair == null || relativeStair.facing() != stair.facing() || relativeStair.bottom() != stair.bottom();
|
||||||
}
|
}
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.Int2ObjectArrayMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
@ -65,7 +65,7 @@ public class TripwireConnectionHandler implements ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
TripwireData tripwireData = TRIPWIRE_DATA_MAP.get(blockState);
|
||||||
if (tripwireData == null) return blockState;
|
if (tripwireData == null) return blockState;
|
||||||
byte b = 0;
|
byte b = 0;
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.IntOpenHashSet;
|
||||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
|
|
||||||
@ -37,10 +37,10 @@ class VineConnectionHandler implements ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
if (isAttachedToBlock(user, position)) return blockState;
|
||||||
|
|
||||||
Position upperPos = position.getRelative(BlockFace.TOP);
|
BlockPosition upperPos = position.getRelative(BlockFace.TOP);
|
||||||
int upperBlock = getBlockData(user, upperPos);
|
int upperBlock = getBlockData(user, upperPos);
|
||||||
if (VINES.contains(upperBlock) && isAttachedToBlock(user, upperPos)) return blockState;
|
if (VINES.contains(upperBlock) && isAttachedToBlock(user, upperPos)) return blockState;
|
||||||
|
|
||||||
@ -48,14 +48,14 @@ class VineConnectionHandler implements ConnectionHandler {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAttachedToBlock(UserConnection user, Position position) {
|
private boolean isAttachedToBlock(UserConnection user, BlockPosition position) {
|
||||||
return isAttachedToBlock(user, position, BlockFace.EAST)
|
return isAttachedToBlock(user, position, BlockFace.EAST)
|
||||||
|| isAttachedToBlock(user, position, BlockFace.WEST)
|
|| isAttachedToBlock(user, position, BlockFace.WEST)
|
||||||
|| isAttachedToBlock(user, position, BlockFace.NORTH)
|
|| isAttachedToBlock(user, position, BlockFace.NORTH)
|
||||||
|| isAttachedToBlock(user, position, BlockFace.SOUTH);
|
|| 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)));
|
return ConnectionData.OCCLUDING_STATES.contains(getBlockData(user, position.getRelative(blockFace)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected byte getStates(UserConnection user, Position position) {
|
protected byte getStates(UserConnection user, BlockPosition position) {
|
||||||
byte states = super.getStates(user, position);
|
byte states = super.getStates(user, position);
|
||||||
if (up(user, position)) states |= 16;
|
if (up(user, position)) states |= 16;
|
||||||
return states;
|
return states;
|
||||||
@ -58,7 +58,7 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
|||||||
return 32;
|
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))))
|
if (isWall(getBlockData(user, position.getRelative(BlockFace.BOTTOM))) || isWall(getBlockData(user, position.getRelative(BlockFace.TOP))))
|
||||||
return true;
|
return true;
|
||||||
int blockFaces = getBlockFaces(user, position);
|
int blockFaces = getBlockFaces(user, position);
|
||||||
@ -69,7 +69,7 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getBlockFaces(UserConnection user, Position position) {
|
private int getBlockFaces(UserConnection user, BlockPosition position) {
|
||||||
int blockFaces = 0;
|
int blockFaces = 0;
|
||||||
for (int i = 0; i < BLOCK_FACES.length; i++) {
|
for (int i = 0; i < BLOCK_FACES.length; i++) {
|
||||||
if (isWall(getBlockData(user, position.getRelative(BLOCK_FACES[i])))) {
|
if (isWall(getBlockData(user, position.getRelative(BLOCK_FACES[i])))) {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.providers;
|
package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.providers;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
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.platform.providers.Provider;
|
||||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13;
|
import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -43,7 +43,7 @@ public abstract class BlockConnectionProvider implements Provider {
|
|||||||
public void clearStorage(UserConnection connection) {
|
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
|
* @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
|
* @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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.providers;
|
package com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.providers;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
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 com.viaversion.viaversion.protocols.v1_12_2to1_13.storage.BlockConnectionStorage;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ public class PacketBlockConnectionProvider extends BlockConnectionProvider {
|
|||||||
connection.get(BlockConnectionStorage.class).clear();
|
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);
|
connection.get(BlockConnectionStorage.class).markModified(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public class PacketBlockConnectionProvider extends BlockConnectionProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean storesBlocks(UserConnection connection, @Nullable Position pos) {
|
public boolean storesBlocks(UserConnection connection, @Nullable BlockPosition pos) {
|
||||||
if (pos == null || connection == null) return true;
|
if (pos == null || connection == null) return true;
|
||||||
|
|
||||||
return !connection.get(BlockConnectionStorage.class).recentlyModified(pos);
|
return !connection.get(BlockConnectionStorage.class).recentlyModified(pos);
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.nbt.tag.CompoundTag;
|
|||||||
import com.viaversion.nbt.tag.StringTag;
|
import com.viaversion.nbt.tag.StringTag;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
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.platform.providers.Provider;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
@ -57,7 +57,7 @@ public class BlockEntityProvider implements Provider {
|
|||||||
* @param sendUpdate send a block change update
|
* @param sendUpdate send a block change update
|
||||||
* @return new block id
|
* @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");
|
StringTag idTag = tag.getStringTag("id");
|
||||||
if (idTag == null) return -1;
|
if (idTag == null) return -1;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public class BlockEntityProvider implements Provider {
|
|||||||
return newBlock;
|
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);
|
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_13.BLOCK_UPDATE, null, user);
|
||||||
wrapper.write(Types.BLOCK_POSITION1_8, position);
|
wrapper.write(Types.BLOCK_POSITION1_8, position);
|
||||||
wrapper.write(Types.VAR_INT, blockId);
|
wrapper.write(Types.VAR_INT, blockId);
|
||||||
|
@ -18,13 +18,13 @@
|
|||||||
package com.viaversion.viaversion.protocols.v1_12_2to1_13.provider;
|
package com.viaversion.viaversion.protocols.v1_12_2to1_13.provider;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
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.platform.providers.Provider;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class PlayerLookTargetProvider implements Provider {
|
public class PlayerLookTargetProvider implements Provider {
|
||||||
@Nullable
|
@Nullable
|
||||||
public Position getPlayerLookTarget(final UserConnection info) {
|
public BlockPosition getPlayerLookTarget(final UserConnection info) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import com.viaversion.nbt.tag.ListTag;
|
|||||||
import com.viaversion.nbt.tag.NumberTag;
|
import com.viaversion.nbt.tag.NumberTag;
|
||||||
import com.viaversion.nbt.tag.StringTag;
|
import com.viaversion.nbt.tag.StringTag;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
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.Protocol1_12_2To1_13;
|
||||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.BlockEntityProvider;
|
import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.BlockEntityProvider;
|
||||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.storage.BlockStorage;
|
import com.viaversion.viaversion.protocols.v1_12_2to1_13.storage.BlockStorage;
|
||||||
@ -38,7 +38,7 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
@Override
|
@Override
|
||||||
public int transform(UserConnection user, CompoundTag tag) {
|
public int transform(UserConnection user, CompoundTag tag) {
|
||||||
BlockStorage storage = user.get(BlockStorage.class);
|
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)) {
|
if (!storage.contains(position)) {
|
||||||
Protocol1_12_2To1_13.LOGGER.warning("Received an banner color update packet, but there is no banner! O_o " + tag);
|
Protocol1_12_2To1_13.LOGGER.warning("Received an banner color update packet, but there is no banner! O_o " + tag);
|
||||||
|
@ -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.CompoundTag;
|
||||||
import com.viaversion.nbt.tag.NumberTag;
|
import com.viaversion.nbt.tag.NumberTag;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
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.Protocol1_12_2To1_13;
|
||||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.BlockEntityProvider;
|
import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.BlockEntityProvider;
|
||||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.storage.BlockStorage;
|
import com.viaversion.viaversion.protocols.v1_12_2to1_13.storage.BlockStorage;
|
||||||
@ -30,7 +30,7 @@ public class BedHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
@Override
|
@Override
|
||||||
public int transform(UserConnection user, CompoundTag tag) {
|
public int transform(UserConnection user, CompoundTag tag) {
|
||||||
BlockStorage storage = user.get(BlockStorage.class);
|
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)) {
|
if (!storage.contains(position)) {
|
||||||
Protocol1_12_2To1_13.LOGGER.warning("Received an bed color update packet, but there is no bed! O_o " + tag);
|
Protocol1_12_2To1_13.LOGGER.warning("Received an bed color update packet, but there is no bed! O_o " + tag);
|
||||||
|
@ -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.CompoundTag;
|
||||||
import com.viaversion.nbt.tag.NumberTag;
|
import com.viaversion.nbt.tag.NumberTag;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
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.Protocol1_12_2To1_13;
|
||||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.BlockEntityProvider;
|
import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.BlockEntityProvider;
|
||||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.storage.BlockStorage;
|
import com.viaversion.viaversion.protocols.v1_12_2to1_13.storage.BlockStorage;
|
||||||
@ -32,7 +32,7 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
@Override
|
@Override
|
||||||
public int transform(UserConnection user, CompoundTag tag) {
|
public int transform(UserConnection user, CompoundTag tag) {
|
||||||
BlockStorage storage = user.get(BlockStorage.class);
|
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)) {
|
if (!storage.contains(position)) {
|
||||||
Protocol1_12_2To1_13.LOGGER.warning("Received an head update packet, but there is no head! O_o " + tag);
|
Protocol1_12_2To1_13.LOGGER.warning("Received an head update packet, but there is no head! O_o " + tag);
|
||||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
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.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
@ -104,7 +104,7 @@ public class WorldPacketRewriter1_13 {
|
|||||||
map(Types.NAMED_COMPOUND_TAG); // 2 - NBT data
|
map(Types.NAMED_COMPOUND_TAG); // 2 - NBT data
|
||||||
|
|
||||||
handler(wrapper -> {
|
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);
|
short action = wrapper.get(Types.UNSIGNED_BYTE, 0);
|
||||||
CompoundTag tag = wrapper.get(Types.NAMED_COMPOUND_TAG, 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.UNSIGNED_BYTE); // Action param
|
||||||
map(Types.VAR_INT); // Block Id - /!\ NOT BLOCK STATE ID
|
map(Types.VAR_INT); // Block Id - /!\ NOT BLOCK STATE ID
|
||||||
handler(wrapper -> {
|
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 action = wrapper.get(Types.UNSIGNED_BYTE, 0);
|
||||||
short param = wrapper.get(Types.UNSIGNED_BYTE, 1);
|
short param = wrapper.get(Types.UNSIGNED_BYTE, 1);
|
||||||
int blockId = wrapper.get(Types.VAR_INT, 0);
|
int blockId = wrapper.get(Types.VAR_INT, 0);
|
||||||
@ -177,7 +177,7 @@ public class WorldPacketRewriter1_13 {
|
|||||||
map(Types.BLOCK_POSITION1_8);
|
map(Types.BLOCK_POSITION1_8);
|
||||||
map(Types.VAR_INT);
|
map(Types.VAR_INT);
|
||||||
handler(wrapper -> {
|
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));
|
int newId = toNewId(wrapper.get(Types.VAR_INT, 0));
|
||||||
|
|
||||||
UserConnection userConnection = wrapper.user();
|
UserConnection userConnection = wrapper.user();
|
||||||
@ -212,7 +212,7 @@ public class WorldPacketRewriter1_13 {
|
|||||||
// Convert ids
|
// Convert ids
|
||||||
for (BlockChangeRecord record : records) {
|
for (BlockChangeRecord record : records) {
|
||||||
int newBlock = toNewId(record.getBlockId());
|
int newBlock = toNewId(record.getBlockId());
|
||||||
Position position = new Position(
|
BlockPosition position = new BlockPosition(
|
||||||
record.getSectionX() + (chunkX << 4),
|
record.getSectionX() + (chunkX << 4),
|
||||||
record.getY(),
|
record.getY(),
|
||||||
record.getSectionZ() + (chunkZ << 4));
|
record.getSectionZ() + (chunkZ << 4));
|
||||||
@ -227,7 +227,7 @@ public class WorldPacketRewriter1_13 {
|
|||||||
for (BlockChangeRecord record : records) {
|
for (BlockChangeRecord record : records) {
|
||||||
int blockState = record.getBlockId();
|
int blockState = record.getBlockId();
|
||||||
|
|
||||||
Position position = new Position(
|
BlockPosition position = new BlockPosition(
|
||||||
record.getSectionX() + (chunkX * 16),
|
record.getSectionX() + (chunkX * 16),
|
||||||
record.getY(),
|
record.getY(),
|
||||||
record.getSectionZ() + (chunkZ * 16));
|
record.getSectionZ() + (chunkZ * 16));
|
||||||
@ -245,7 +245,7 @@ public class WorldPacketRewriter1_13 {
|
|||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
|
|
||||||
for (BlockChangeRecord record : records) {
|
for (BlockChangeRecord record : records) {
|
||||||
Position position = new Position(
|
BlockPosition position = new BlockPosition(
|
||||||
record.getSectionX() + (chunkX * 16),
|
record.getSectionX() + (chunkX * 16),
|
||||||
record.getY(),
|
record.getY(),
|
||||||
record.getSectionZ() + (chunkZ * 16));
|
record.getSectionZ() + (chunkZ * 16));
|
||||||
@ -275,10 +275,10 @@ public class WorldPacketRewriter1_13 {
|
|||||||
int y = (int) Math.floor(wrapper.get(Types.FLOAT, 1));
|
int y = (int) Math.floor(wrapper.get(Types.FLOAT, 1));
|
||||||
int z = (int) Math.floor(wrapper.get(Types.FLOAT, 2));
|
int z = (int) Math.floor(wrapper.get(Types.FLOAT, 2));
|
||||||
int recordCount = wrapper.get(Types.INT, 0);
|
int recordCount = wrapper.get(Types.INT, 0);
|
||||||
Position[] records = new Position[recordCount];
|
BlockPosition[] records = new BlockPosition[recordCount];
|
||||||
|
|
||||||
for (int i = 0; i < recordCount; i++) {
|
for (int i = 0; i < recordCount; i++) {
|
||||||
Position position = new Position(
|
BlockPosition position = new BlockPosition(
|
||||||
x + wrapper.passthrough(Types.BYTE),
|
x + wrapper.passthrough(Types.BYTE),
|
||||||
(short) (y + wrapper.passthrough(Types.BYTE)),
|
(short) (y + wrapper.passthrough(Types.BYTE)),
|
||||||
z + 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++) {
|
for (int idx = 0; idx < ChunkSection.SIZE; idx++) {
|
||||||
int id = blocks.idAt(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)) {
|
if (storage.isWelcome(id)) {
|
||||||
storage.store(position, id);
|
storage.store(position, id);
|
||||||
} else if (!chunk.isFullChunk()) { // Update
|
} else if (!chunk.isFullChunk()) { // Update
|
||||||
@ -426,10 +426,10 @@ public class WorldPacketRewriter1_13 {
|
|||||||
int newId = provider.transform(wrapper.user(), null, tag, false);
|
int newId = provider.transform(wrapper.user(), null, tag, false);
|
||||||
if (newId != -1) {
|
if (newId != -1) {
|
||||||
int x = tag.getNumberTag("x").asInt();
|
int x = tag.getNumberTag("x").asInt();
|
||||||
int y = tag.getNumberTag("y").asInt();
|
short y = tag.getNumberTag("y").asShort();
|
||||||
int z = tag.getNumberTag("z").asInt();
|
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
|
// Store the replacement blocks for blockupdates
|
||||||
BlockStorage.ReplacementData replacementData = storage.get(position);
|
BlockStorage.ReplacementData replacementData = storage.get(position);
|
||||||
if (replacementData != null) {
|
if (replacementData != null) {
|
||||||
@ -536,7 +536,7 @@ public class WorldPacketRewriter1_13 {
|
|||||||
|
|
||||||
// Incoming Packets
|
// Incoming Packets
|
||||||
protocol.registerServerbound(ServerboundPackets1_13.USE_ITEM_ON, wrapper -> {
|
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); // block face
|
||||||
wrapper.passthrough(Types.VAR_INT); // hand
|
wrapper.passthrough(Types.VAR_INT); // hand
|
||||||
wrapper.passthrough(Types.FLOAT); // cursor x
|
wrapper.passthrough(Types.FLOAT); // cursor x
|
||||||
@ -549,7 +549,7 @@ public class WorldPacketRewriter1_13 {
|
|||||||
});
|
});
|
||||||
protocol.registerServerbound(ServerboundPackets1_13.PLAYER_ACTION, wrapper -> {
|
protocol.registerServerbound(ServerboundPackets1_13.PLAYER_ACTION, wrapper -> {
|
||||||
int status = wrapper.passthrough(Types.VAR_INT); // Status
|
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
|
wrapper.passthrough(Types.UNSIGNED_BYTE); // block face
|
||||||
|
|
||||||
// 0 = Started digging: if in creative this causes the block to break directly
|
// 0 = Started digging: if in creative this causes the block to break directly
|
||||||
@ -583,7 +583,7 @@ public class WorldPacketRewriter1_13 {
|
|||||||
return 0;
|
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);
|
BlockStorage storage = user.get(BlockStorage.class);
|
||||||
if (storage.contains(position)) {
|
if (storage.contains(position)) {
|
||||||
BlockStorage.ReplacementData data = storage.get(position);
|
BlockStorage.ReplacementData data = storage.get(position);
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.v1_12_2to1_13.storage;
|
|||||||
import com.google.common.collect.EvictingQueue;
|
import com.google.common.collect.EvictingQueue;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
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.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -33,7 +33,7 @@ public class BlockConnectionStorage implements StorableObject {
|
|||||||
|
|
||||||
private final Map<Long, SectionData> blockStorage = createLongObjectMap();
|
private final Map<Long, SectionData> blockStorage = createLongObjectMap();
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
private final Queue<Position> modified = EvictingQueue.create(5);
|
private final Queue<BlockPosition> modified = EvictingQueue.create(5);
|
||||||
|
|
||||||
// Cache to retrieve section quicker
|
// Cache to retrieve section quicker
|
||||||
private long lastIndex = -1;
|
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
|
// Avoid saving the same pos twice
|
||||||
if (!modified.contains(pos)) {
|
if (!modified.contains(pos)) {
|
||||||
this.modified.add(pos);
|
this.modified.add(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean recentlyModified(Position pos) {
|
public boolean recentlyModified(BlockPosition pos) {
|
||||||
for (Position p : modified) {
|
for (BlockPosition p : modified) {
|
||||||
if (Math.abs(pos.x() - p.x()) + Math.abs(pos.y() - p.y()) + Math.abs(pos.z() - p.z()) <= 2) {
|
if (Math.abs(pos.x() - p.x()) + Math.abs(pos.y() - p.y()) + Math.abs(pos.z() - p.z()) <= 2) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.v1_12_2to1_13.storage;
|
package com.viaversion.viaversion.protocols.v1_12_2to1_13.storage;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
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.IntOpenHashSet;
|
||||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -27,7 +27,7 @@ import java.util.Map;
|
|||||||
// TODO Fix memory leak lolz (only a smol one tho)
|
// TODO Fix memory leak lolz (only a smol one tho)
|
||||||
public class BlockStorage implements StorableObject {
|
public class BlockStorage implements StorableObject {
|
||||||
private static final IntSet WHITELIST = new IntOpenHashSet(46, .99F);
|
private static final IntSet WHITELIST = new IntOpenHashSet(46, .99F);
|
||||||
private final Map<Position, ReplacementData> blocks = new HashMap<>();
|
private final Map<BlockPosition, ReplacementData> blocks = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Flower pots
|
// 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);
|
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))
|
if (!WHITELIST.contains(block))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -69,15 +69,15 @@ public class BlockStorage implements StorableObject {
|
|||||||
return WHITELIST.contains(block);
|
return WHITELIST.contains(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Position position) {
|
public boolean contains(BlockPosition position) {
|
||||||
return blocks.containsKey(position);
|
return blocks.containsKey(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplacementData get(Position position) {
|
public ReplacementData get(BlockPosition position) {
|
||||||
return blocks.get(position);
|
return blocks.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplacementData remove(Position position) {
|
public ReplacementData remove(BlockPosition position) {
|
||||||
return blocks.remove(position);
|
return blocks.remove(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.Via;
|
||||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
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.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13;
|
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);
|
PacketWrapper wrapper = PacketWrapper.create(ServerboundPackets1_12_1.COMMAND_SUGGESTION, null, connection);
|
||||||
wrapper.write(Types.STRING, lastTabComplete);
|
wrapper.write(Types.STRING, lastTabComplete);
|
||||||
wrapper.write(Types.BOOLEAN, false);
|
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.write(Types.OPTIONAL_POSITION1_8, playerLookTarget);
|
||||||
wrapper.scheduleSendToServer(Protocol1_12_2To1_13.class);
|
wrapper.scheduleSendToServer(Protocol1_12_2To1_13.class);
|
||||||
lastTabComplete = null;
|
lastTabComplete = null;
|
||||||
|
@ -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.Via;
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
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.VillagerData;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
||||||
@ -241,7 +241,7 @@ public class EntityPacketRewriter1_14 extends EntityRewriter<ClientboundPackets1
|
|||||||
int entityId = wrapper.get(Types.VAR_INT, 0);
|
int entityId = wrapper.get(Types.VAR_INT, 0);
|
||||||
tracker.setSleeping(entityId, true);
|
tracker.setSleeping(entityId, true);
|
||||||
|
|
||||||
Position position = wrapper.read(Types.BLOCK_POSITION1_8);
|
BlockPosition position = wrapper.read(Types.BLOCK_POSITION1_8);
|
||||||
List<EntityData> metadataList = new LinkedList<>();
|
List<EntityData> metadataList = new LinkedList<>();
|
||||||
metadataList.add(new EntityData(12, Types1_14.ENTITY_DATA_TYPES.optionalBlockPositionType, position));
|
metadataList.add(new EntityData(12, Types1_14.ENTITY_DATA_TYPES.optionalBlockPositionType, position));
|
||||||
if (tracker.clientEntityId() != entityId) {
|
if (tracker.clientEntityId() != entityId) {
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.nbt.tag.CompoundTag;
|
|||||||
import com.viaversion.nbt.tag.ListTag;
|
import com.viaversion.nbt.tag.ListTag;
|
||||||
import com.viaversion.nbt.tag.StringTag;
|
import com.viaversion.nbt.tag.StringTag;
|
||||||
import com.viaversion.viaversion.api.Via;
|
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.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
@ -127,7 +127,7 @@ public class PlayerPacketRewriter1_14 {
|
|||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_14.USE_ITEM_ON, wrapper -> {
|
protocol.registerServerbound(ServerboundPackets1_14.USE_ITEM_ON, wrapper -> {
|
||||||
int hand = wrapper.read(Types.VAR_INT);
|
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);
|
int face = wrapper.read(Types.VAR_INT);
|
||||||
float x = wrapper.read(Types.FLOAT);
|
float x = wrapper.read(Types.FLOAT);
|
||||||
float y = wrapper.read(Types.FLOAT);
|
float y = wrapper.read(Types.FLOAT);
|
||||||
|
@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.data.ParticleMappings;
|
import com.viaversion.viaversion.api.data.ParticleMappings;
|
||||||
import com.viaversion.viaversion.api.data.entity.DimensionData;
|
import com.viaversion.viaversion.api.data.entity.DimensionData;
|
||||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
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.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
|
||||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||||
@ -99,7 +99,7 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter<ClientboundPa
|
|||||||
wrapper.write(Types.VAR_INT, EntityTypes1_19.PAINTING.getId());
|
wrapper.write(Types.VAR_INT, EntityTypes1_19.PAINTING.getId());
|
||||||
|
|
||||||
final int motive = wrapper.read(Types.VAR_INT);
|
final int motive = wrapper.read(Types.VAR_INT);
|
||||||
final Position blockPosition = wrapper.read(Types.BLOCK_POSITION1_14);
|
final BlockPosition blockPosition = wrapper.read(Types.BLOCK_POSITION1_14);
|
||||||
final byte direction = wrapper.read(Types.BYTE);
|
final byte direction = wrapper.read(Types.BYTE);
|
||||||
wrapper.write(Types.DOUBLE, blockPosition.x() + 0.5d);
|
wrapper.write(Types.DOUBLE, blockPosition.x() + 0.5d);
|
||||||
wrapper.write(Types.DOUBLE, blockPosition.y() + 0.5d);
|
wrapper.write(Types.DOUBLE, blockPosition.y() + 0.5d);
|
||||||
|
@ -30,7 +30,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.data.ParticleMappings;
|
import com.viaversion.viaversion.api.data.ParticleMappings;
|
||||||
import com.viaversion.viaversion.api.minecraft.GameProfile;
|
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.Holder;
|
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||||
import com.viaversion.viaversion.api.minecraft.HolderSet;
|
import com.viaversion.viaversion.api.minecraft.HolderSet;
|
||||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
@ -1056,12 +1056,12 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateLodestoneTracker(final boolean tracked, final CompoundTag lodestonePosTag, final String lodestoneDimensionTag, final StructuredDataContainer data) {
|
private void updateLodestoneTracker(final boolean tracked, final CompoundTag lodestonePosTag, final String lodestoneDimensionTag, final StructuredDataContainer data) {
|
||||||
GlobalPosition position = null;
|
GlobalBlockPosition position = null;
|
||||||
if (lodestonePosTag != null && lodestoneDimensionTag != null) {
|
if (lodestonePosTag != null && lodestoneDimensionTag != null) {
|
||||||
final int x = lodestonePosTag.getInt("X");
|
final int x = lodestonePosTag.getInt("X");
|
||||||
final int y = lodestonePosTag.getInt("Y");
|
final int y = lodestonePosTag.getInt("Y");
|
||||||
final int z = lodestonePosTag.getInt("Z");
|
final int z = lodestonePosTag.getInt("Z");
|
||||||
position = new GlobalPosition(lodestoneDimensionTag, x, y, z);
|
position = new GlobalBlockPosition(lodestoneDimensionTag, x, y, z);
|
||||||
}
|
}
|
||||||
data.set(StructuredDataKey.LODESTONE_TRACKER, new LodestoneTracker(position, tracked));
|
data.set(StructuredDataKey.LODESTONE_TRACKER, new LodestoneTracker(position, tracked));
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import com.google.common.primitives.UnsignedBytes;
|
|||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.GameProfile;
|
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.Holder;
|
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||||
import com.viaversion.viaversion.api.minecraft.HolderSet;
|
import com.viaversion.viaversion.api.minecraft.HolderSet;
|
||||||
import com.viaversion.viaversion.api.minecraft.SoundEvent;
|
import com.viaversion.viaversion.api.minecraft.SoundEvent;
|
||||||
@ -989,7 +989,7 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> 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();
|
final CompoundTag posTag = new CompoundTag();
|
||||||
posTag.putString("dimension", position.dimension());
|
posTag.putString("dimension", position.dimension());
|
||||||
posTag.put("pos", new IntArrayTag(new int[]{position.x(), position.y(), position.z()}));
|
posTag.put("pos", new IntArrayTag(new int[]{position.x(), position.y(), position.z()}));
|
||||||
|
@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.v1_8to1_9.provider;
|
|||||||
|
|
||||||
import com.viaversion.nbt.tag.CompoundTag;
|
import com.viaversion.nbt.tag.CompoundTag;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
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.platform.providers.Provider;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
@ -31,12 +31,12 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public class CommandBlockProvider implements Provider {
|
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);
|
checkPermission(user);
|
||||||
getStorage(user).addOrUpdateBlock(position, tag);
|
getStorage(user).addOrUpdateBlock(position, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<CompoundTag> get(UserConnection user, Position position) {
|
public Optional<CompoundTag> get(UserConnection user, BlockPosition position) {
|
||||||
checkPermission(user);
|
checkPermission(user);
|
||||||
return getStorage(user).getCommandBlock(position);
|
return getStorage(user).getCommandBlock(position);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import com.viaversion.nbt.tag.StringTag;
|
|||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
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.BaseChunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
@ -290,7 +290,7 @@ public class WorldPacketRewriter1_9 {
|
|||||||
// Wipe the input buffer
|
// Wipe the input buffer
|
||||||
wrapper.clearInputBuffer();
|
wrapper.clearInputBuffer();
|
||||||
wrapper.setPacketType(ServerboundPackets1_8.USE_ITEM_ON);
|
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);
|
wrapper.write(Types.UNSIGNED_BYTE, (short) 255);
|
||||||
// Write item in hand
|
// Write item in hand
|
||||||
Item item = Protocol1_8To1_9.getHandItem(wrapper.user());
|
Item item = Protocol1_8To1_9.getHandItem(wrapper.user());
|
||||||
@ -362,7 +362,7 @@ public class WorldPacketRewriter1_9 {
|
|||||||
int face = wrapper.get(Types.UNSIGNED_BYTE, 0);
|
int face = wrapper.get(Types.UNSIGNED_BYTE, 0);
|
||||||
if (face == 255)
|
if (face == 255)
|
||||||
return;
|
return;
|
||||||
Position p = wrapper.get(Types.BLOCK_POSITION1_8, 0);
|
BlockPosition p = wrapper.get(Types.BLOCK_POSITION1_8, 0);
|
||||||
int x = p.x();
|
int x = p.x();
|
||||||
int y = p.y();
|
int y = p.y();
|
||||||
int z = p.z();
|
int z = p.z();
|
||||||
@ -375,14 +375,14 @@ public class WorldPacketRewriter1_9 {
|
|||||||
case 5 -> x++;
|
case 5 -> x++;
|
||||||
}
|
}
|
||||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class);
|
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
|
// Handle CommandBlocks
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class);
|
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<CompoundTag> tag = provider.get(wrapper.user(), pos);
|
Optional<CompoundTag> tag = provider.get(wrapper.user(), pos);
|
||||||
// Send the Update Block Entity packet if present
|
// Send the Update Block Entity packet if present
|
||||||
if (tag.isPresent()) {
|
if (tag.isPresent()) {
|
||||||
|
@ -20,14 +20,14 @@ package com.viaversion.viaversion.protocols.v1_8to1_9.storage;
|
|||||||
import com.viaversion.nbt.tag.ByteTag;
|
import com.viaversion.nbt.tag.ByteTag;
|
||||||
import com.viaversion.nbt.tag.CompoundTag;
|
import com.viaversion.nbt.tag.CompoundTag;
|
||||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
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 com.viaversion.viaversion.util.Pair;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class CommandBlockStorage implements StorableObject {
|
public class CommandBlockStorage implements StorableObject {
|
||||||
private final Map<Pair<Integer, Integer>, Map<Position, CompoundTag>> storedCommandBlocks = new ConcurrentHashMap<>();
|
private final Map<Pair<Integer, Integer>, Map<BlockPosition, CompoundTag>> storedCommandBlocks = new ConcurrentHashMap<>();
|
||||||
private boolean permissions;
|
private boolean permissions;
|
||||||
|
|
||||||
public void unloadChunk(int x, int z) {
|
public void unloadChunk(int x, int z) {
|
||||||
@ -35,14 +35,14 @@ public class CommandBlockStorage implements StorableObject {
|
|||||||
storedCommandBlocks.remove(chunkPos);
|
storedCommandBlocks.remove(chunkPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOrUpdateBlock(Position position, CompoundTag tag) {
|
public void addOrUpdateBlock(BlockPosition position, CompoundTag tag) {
|
||||||
Pair<Integer, Integer> chunkPos = getChunkCoords(position);
|
Pair<Integer, Integer> chunkPos = getChunkCoords(position);
|
||||||
|
|
||||||
if (!storedCommandBlocks.containsKey(chunkPos)) {
|
if (!storedCommandBlocks.containsKey(chunkPos)) {
|
||||||
storedCommandBlocks.put(chunkPos, new ConcurrentHashMap<>());
|
storedCommandBlocks.put(chunkPos, new ConcurrentHashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Position, CompoundTag> blocks = storedCommandBlocks.get(chunkPos);
|
Map<BlockPosition, CompoundTag> blocks = storedCommandBlocks.get(chunkPos);
|
||||||
|
|
||||||
if (blocks.containsKey(position) && blocks.get(position).equals(tag)) {
|
if (blocks.containsKey(position) && blocks.get(position).equals(tag)) {
|
||||||
return;
|
return;
|
||||||
@ -51,17 +51,17 @@ public class CommandBlockStorage implements StorableObject {
|
|||||||
blocks.put(position, tag);
|
blocks.put(position, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<Integer, Integer> getChunkCoords(Position position) {
|
private Pair<Integer, Integer> getChunkCoords(BlockPosition position) {
|
||||||
int chunkX = Math.floorDiv(position.x(), 16);
|
int chunkX = Math.floorDiv(position.x(), 16);
|
||||||
int chunkZ = Math.floorDiv(position.z(), 16);
|
int chunkZ = Math.floorDiv(position.z(), 16);
|
||||||
|
|
||||||
return new Pair<>(chunkX, chunkZ);
|
return new Pair<>(chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<CompoundTag> getCommandBlock(Position position) {
|
public Optional<CompoundTag> getCommandBlock(BlockPosition position) {
|
||||||
Pair<Integer, Integer> chunkCoords = getChunkCoords(position);
|
Pair<Integer, Integer> chunkCoords = getChunkCoords(position);
|
||||||
|
|
||||||
Map<Position, CompoundTag> blocks = storedCommandBlocks.get(chunkCoords);
|
Map<BlockPosition, CompoundTag> blocks = storedCommandBlocks.get(chunkCoords);
|
||||||
if (blocks == null)
|
if (blocks == null)
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
||||||
|
@ -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.BossColor;
|
||||||
import com.viaversion.viaversion.api.legacy.bossbar.BossStyle;
|
import com.viaversion.viaversion.api.legacy.bossbar.BossStyle;
|
||||||
import com.viaversion.viaversion.api.minecraft.GameMode;
|
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.entities.EntityTypes1_9.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
@ -58,14 +58,14 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
|||||||
private final Int2ObjectMap<BossBar> bossBarMap = new Int2ObjectOpenHashMap<>();
|
private final Int2ObjectMap<BossBar> bossBarMap = new Int2ObjectOpenHashMap<>();
|
||||||
private final IntSet validBlocking = new IntOpenHashSet();
|
private final IntSet validBlocking = new IntOpenHashSet();
|
||||||
private final IntSet knownHolograms = new IntOpenHashSet();
|
private final IntSet knownHolograms = new IntOpenHashSet();
|
||||||
private final Set<Position> blockInteractions = Collections.newSetFromMap(CacheBuilder.newBuilder()
|
private final Set<BlockPosition> blockInteractions = Collections.newSetFromMap(CacheBuilder.newBuilder()
|
||||||
.maximumSize(1000)
|
.maximumSize(1000)
|
||||||
.expireAfterAccess(250, TimeUnit.MILLISECONDS)
|
.expireAfterAccess(250, TimeUnit.MILLISECONDS)
|
||||||
.<Position, Boolean>build()
|
.<BlockPosition, Boolean>build()
|
||||||
.asMap());
|
.asMap());
|
||||||
private boolean blocking;
|
private boolean blocking;
|
||||||
private boolean autoTeam;
|
private boolean autoTeam;
|
||||||
private Position currentlyDigging;
|
private BlockPosition currentlyDigging;
|
||||||
private boolean teamExists;
|
private boolean teamExists;
|
||||||
private GameMode gameMode;
|
private GameMode gameMode;
|
||||||
private String currentTeam;
|
private String currentTeam;
|
||||||
@ -144,10 +144,10 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean interactedBlockRecently(int x, int y, int z) {
|
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);
|
blockInteractions.add(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
|||||||
return knownHolograms;
|
return knownHolograms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Position> getBlockInteractions() {
|
public Set<BlockPosition> getBlockInteractions() {
|
||||||
return blockInteractions;
|
return blockInteractions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,11 +347,11 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
|||||||
this.autoTeam = autoTeam;
|
this.autoTeam = autoTeam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position getCurrentlyDigging() {
|
public BlockPosition getCurrentlyDigging() {
|
||||||
return currentlyDigging;
|
return currentlyDigging;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentlyDigging(Position currentlyDigging) {
|
public void setCurrentlyDigging(BlockPosition currentlyDigging) {
|
||||||
this.currentlyDigging = currentlyDigging;
|
this.currentlyDigging = currentlyDigging;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.nbt.tag.IntTag;
|
|||||||
import com.viaversion.nbt.tag.StringTag;
|
import com.viaversion.nbt.tag.StringTag;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
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.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
@ -60,7 +60,7 @@ public class Protocol1_9_1To1_9_3 extends AbstractProtocol<ClientboundPackets1_9
|
|||||||
// Sign update packet
|
// Sign update packet
|
||||||
registerClientbound(ClientboundPackets1_9.UPDATE_SIGN, null, wrapper -> {
|
registerClientbound(ClientboundPackets1_9.UPDATE_SIGN, null, wrapper -> {
|
||||||
//read data
|
//read data
|
||||||
Position position = wrapper.read(Types.BLOCK_POSITION1_8);
|
BlockPosition position = wrapper.read(Types.BLOCK_POSITION1_8);
|
||||||
JsonElement[] lines = new JsonElement[4];
|
JsonElement[] lines = new JsonElement[4];
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
lines[i] = wrapper.read(Types.COMPONENT);
|
lines[i] = wrapper.read(Types.COMPONENT);
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.data.Mappings;
|
import com.viaversion.viaversion.api.data.Mappings;
|
||||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
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.BlockEntity;
|
||||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntityImpl;
|
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntityImpl;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
@ -45,10 +45,10 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
|
|
||||||
public class BlockRewriter<C extends ClientboundPacketType> {
|
public class BlockRewriter<C extends ClientboundPacketType> {
|
||||||
private final Protocol<C, ?, ?, ?> protocol;
|
private final Protocol<C, ?, ?, ?> protocol;
|
||||||
private final Type<Position> positionType;
|
private final Type<BlockPosition> positionType;
|
||||||
private final Type<CompoundTag> compoundTagType;
|
private final Type<CompoundTag> compoundTagType;
|
||||||
|
|
||||||
public BlockRewriter(Protocol<C, ?, ?, ?> protocol, Type<Position> positionType, Type<CompoundTag> compoundTagType) {
|
public BlockRewriter(Protocol<C, ?, ?, ?> protocol, Type<BlockPosition> positionType, Type<CompoundTag> compoundTagType) {
|
||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
this.positionType = positionType;
|
this.positionType = positionType;
|
||||||
this.compoundTagType = compoundTagType;
|
this.compoundTagType = compoundTagType;
|
||||||
@ -260,7 +260,7 @@ public class BlockRewriter<C extends ClientboundPacketType> {
|
|||||||
|
|
||||||
public void registerBlockEntityData(C packetType, @Nullable Consumer<BlockEntity> blockEntityHandler) {
|
public void registerBlockEntityData(C packetType, @Nullable Consumer<BlockEntity> blockEntityHandler) {
|
||||||
protocol.registerClientbound(packetType, wrapper -> {
|
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 int blockEntityId = wrapper.read(Types.VAR_INT);
|
||||||
final Mappings mappings = protocol.getMappingData().getBlockEntityMappings();
|
final Mappings mappings = protocol.getMappingData().getBlockEntityMappings();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren