mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
Switch all Position instances to Vector3i
This commit is contained in:
parent
055d1f5269
commit
0a733c7139
23 changed files with 58 additions and 63 deletions
|
@ -38,7 +38,7 @@ public class GlobalPos {
|
|||
|
||||
public static GlobalPos read(NetInput in) throws IOException {
|
||||
String dimension = Identifier.formalize(in.readString());
|
||||
Vector3i pos = Position.readNukkit(in);
|
||||
Vector3i pos = Position.read(in);
|
||||
return new GlobalPos(dimension, pos);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.github.steveice10.mc.protocol.data.game.level.particle.Particle;
|
|||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -37,8 +38,8 @@ public class MetadataType<T> {
|
|||
public static final MetadataType<ItemStack> ITEM = new MetadataType<>(ItemStack::read, ItemStack::write, ObjectEntityMetadata::new);
|
||||
public static final BooleanMetadataType BOOLEAN = new BooleanMetadataType(NetInput::readBoolean, NetOutput::writeBoolean, BooleanEntityMetadata::new);
|
||||
public static final MetadataType<Rotation> ROTATION = new MetadataType<>(Rotation::read, Rotation::write, ObjectEntityMetadata::new);
|
||||
public static final MetadataType<Position> POSITION = new MetadataType<>(Position::read, Position::write, ObjectEntityMetadata::new);
|
||||
public static final MetadataType<Optional<Position>> OPTIONAL_POSITION = new MetadataType<>(optionalReader(Position::read), optionalWriter(Position::write), ObjectEntityMetadata::new);
|
||||
public static final MetadataType<Vector3i> POSITION = new MetadataType<>(Position::read, Position::write, ObjectEntityMetadata::new);
|
||||
public static final MetadataType<Optional<Vector3i>> OPTIONAL_POSITION = new MetadataType<>(optionalReader(Position::read), optionalWriter(Position::write), ObjectEntityMetadata::new);
|
||||
public static final MetadataType<Direction> DIRECTION = new MetadataType<>(in -> in.readEnum(Direction.VALUES), NetOutput::writeEnum, ObjectEntityMetadata::new);
|
||||
public static final MetadataType<Optional<UUID>> OPTIONAL_UUID = new MetadataType<>(optionalReader(NetInput::readUUID), optionalWriter(NetOutput::writeUUID), ObjectEntityMetadata::new);
|
||||
public static final IntMetadataType BLOCK_STATE = new IntMetadataType(NetInput::readVarInt, NetOutput::writeVarInt, IntEntityMetadata::new);
|
||||
|
|
|
@ -3,43 +3,17 @@ package com.github.steveice10.mc.protocol.data.game.entity.metadata;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Position {
|
||||
public final class Position {
|
||||
private static final int POSITION_X_SIZE = 38;
|
||||
private static final int POSITION_Y_SIZE = 12;
|
||||
private static final int POSITION_Z_SIZE = 38;
|
||||
private static final int POSITION_Y_SHIFT = 0xFFF;
|
||||
private static final int POSITION_WRITE_SHIFT = 0x3FFFFFF;
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
|
||||
public static Position read(NetInput in) throws IOException {
|
||||
long val = in.readLong();
|
||||
|
||||
int x = (int) (val >> POSITION_X_SIZE);
|
||||
int y = (int) (val << 52 >> 52);
|
||||
int z = (int) (val << 26 >> POSITION_Z_SIZE);
|
||||
|
||||
return new Position(x, y, z);
|
||||
}
|
||||
|
||||
public static void write(NetOutput out, Position pos) throws IOException {
|
||||
long x = pos.getX() & POSITION_WRITE_SHIFT;
|
||||
long y = pos.getY() & POSITION_Y_SHIFT;
|
||||
long z = pos.getZ() & POSITION_WRITE_SHIFT;
|
||||
|
||||
out.writeLong(x << POSITION_X_SIZE | z << POSITION_Y_SIZE | y);
|
||||
}
|
||||
|
||||
public static Vector3i readNukkit(NetInput in) throws IOException {
|
||||
public static Vector3i read(NetInput in) throws IOException {
|
||||
long val = in.readLong();
|
||||
|
||||
int x = (int) (val >> POSITION_X_SIZE);
|
||||
|
@ -56,4 +30,7 @@ public class Position {
|
|||
|
||||
out.writeLong(x << POSITION_X_SIZE | z << POSITION_Y_SIZE | y);
|
||||
}
|
||||
|
||||
private Position() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.level.block;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -8,6 +8,6 @@ import lombok.NonNull;
|
|||
@Data
|
||||
@AllArgsConstructor
|
||||
public class BlockChangeEntry {
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull int block;
|
||||
private final @NonNull Vector3i position;
|
||||
private final int block;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.BlockBreakStage
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -17,7 +18,7 @@ import java.io.IOException;
|
|||
@AllArgsConstructor
|
||||
public class ClientboundBlockDestructionPacket implements Packet {
|
||||
private final int breakerEntityId;
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final @NonNull BlockBreakStage stage;
|
||||
|
||||
public ClientboundBlockDestructionPacket(NetInput in) throws IOException {
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -19,7 +20,7 @@ import java.io.IOException;
|
|||
@With
|
||||
@AllArgsConstructor
|
||||
public class ClientboundBlockEntityDataPacket implements Packet {
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final BlockEntityType type;
|
||||
private final @Nullable CompoundTag nbt;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.github.steveice10.mc.protocol.data.game.level.block.value.PistonValue
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -41,7 +42,7 @@ public class ClientboundBlockEventPacket implements Packet {
|
|||
private static final int SHULKER_BOX_LOWER = 523;
|
||||
private static final int SHULKER_BOX_HIGHER = 539;
|
||||
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final @NonNull BlockValueType type;
|
||||
private final @NonNull BlockValue value;
|
||||
private final int blockId;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -21,7 +21,7 @@ public class ClientboundExplodePacket implements Packet {
|
|||
private final float y;
|
||||
private final float z;
|
||||
private final float radius;
|
||||
private final @NonNull List<Position> exploded;
|
||||
private final @NonNull List<Vector3i> exploded;
|
||||
private final float pushX;
|
||||
private final float pushY;
|
||||
private final float pushZ;
|
||||
|
@ -34,7 +34,7 @@ public class ClientboundExplodePacket implements Packet {
|
|||
this.exploded = new ArrayList<>();
|
||||
int length = in.readVarInt();
|
||||
for (int count = 0; count < length; count++) {
|
||||
this.exploded.add(new Position(in.readByte(), in.readByte(), in.readByte()));
|
||||
this.exploded.add(Vector3i.from(in.readByte(), in.readByte(), in.readByte()));
|
||||
}
|
||||
|
||||
this.pushX = in.readFloat();
|
||||
|
@ -49,7 +49,7 @@ public class ClientboundExplodePacket implements Packet {
|
|||
out.writeFloat(this.z);
|
||||
out.writeFloat(this.radius);
|
||||
out.writeVarInt(this.exploded.size());
|
||||
for (Position record : this.exploded) {
|
||||
for (Vector3i record : this.exploded) {
|
||||
out.writeByte(record.getX());
|
||||
out.writeByte(record.getY());
|
||||
out.writeByte(record.getZ());
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.github.steveice10.mc.protocol.data.game.level.event.SoundEvent;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -28,11 +29,11 @@ import java.io.IOException;
|
|||
@AllArgsConstructor
|
||||
public class ClientboundLevelEventPacket implements Packet {
|
||||
private final @NonNull LevelEvent event;
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final LevelEventData data;
|
||||
private final boolean broadcast;
|
||||
|
||||
public ClientboundLevelEventPacket(@NonNull LevelEvent event, @NonNull Position position, @NonNull LevelEventData data) {
|
||||
public ClientboundLevelEventPacket(@NonNull LevelEvent event, @NonNull Vector3i position, @NonNull LevelEventData data) {
|
||||
this(event, position, data, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -15,7 +16,7 @@ import java.io.IOException;
|
|||
@With
|
||||
@AllArgsConstructor
|
||||
public class ClientboundOpenSignEditorPacket implements Packet {
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
|
||||
public ClientboundOpenSignEditorPacket(NetInput in) throws IOException {
|
||||
this.position = Position.read(in);
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.github.steveice10.mc.protocol.data.game.level.block.BlockChangeEntry;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.With;
|
||||
|
@ -48,7 +49,7 @@ public class ClientboundSectionBlocksUpdatePacket implements Packet {
|
|||
int x = (this.chunkX << 4) + (position >>> 8 & 0xF);
|
||||
int y = (this.chunkY << 4) + (position & 0xF);
|
||||
int z = (this.chunkZ << 4) + (position >>> 4 & 0xF);
|
||||
this.entries[index] = new BlockChangeEntry(new Position(x, y, z), (int) (blockData >>> 12));
|
||||
this.entries[index] = new BlockChangeEntry(Vector3i.from(x, y, z), (int) (blockData >>> 12));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -15,7 +16,7 @@ import java.io.IOException;
|
|||
@With
|
||||
@AllArgsConstructor
|
||||
public class ClientboundSetDefaultSpawnPositionPacket implements Packet {
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final float angle;
|
||||
|
||||
public ClientboundSetDefaultSpawnPositionPacket(NetInput in) throws IOException {
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.github.steveice10.mc.protocol.data.game.level.block.CommandBlockMode;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -21,7 +22,7 @@ public class ServerboundSetCommandBlockPacket implements Packet {
|
|||
private static final int FLAG_CONDITIONAL = 0x02;
|
||||
private static final int FLAG_AUTOMATIC = 0x04;
|
||||
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final @NonNull String command;
|
||||
private final @NonNull CommandBlockMode mode;
|
||||
private final boolean doesTrackOutput;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -15,7 +16,7 @@ import java.io.IOException;
|
|||
@With
|
||||
@AllArgsConstructor
|
||||
public class ServerboundSetJigsawBlockPacket implements Packet {
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final @NonNull String name;
|
||||
private final @NonNull String target;
|
||||
private final @NonNull String pool;
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.github.steveice10.mc.protocol.data.game.level.block.StructureRotation
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -24,12 +25,12 @@ public class ServerboundSetStructureBlockPacket implements Packet {
|
|||
private static final int FLAG_SHOW_AIR = 0x02;
|
||||
private static final int FLAG_SHOW_BOUNDING_BOX = 0x04;
|
||||
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final @NonNull UpdateStructureBlockAction action;
|
||||
private final @NonNull UpdateStructureBlockMode mode;
|
||||
private final @NonNull String name;
|
||||
private final @NonNull Position offset;
|
||||
private final @NonNull Position size;
|
||||
private final @NonNull Vector3i offset;
|
||||
private final @NonNull Vector3i size;
|
||||
private final @NonNull StructureMirror mirror;
|
||||
private final @NonNull StructureRotation rotation;
|
||||
private final @NonNull String metadata;
|
||||
|
@ -44,8 +45,8 @@ public class ServerboundSetStructureBlockPacket implements Packet {
|
|||
this.action = MagicValues.key(UpdateStructureBlockAction.class, in.readVarInt());
|
||||
this.mode = MagicValues.key(UpdateStructureBlockMode.class, in.readVarInt());
|
||||
this.name = in.readString();
|
||||
this.offset = new Position(in.readByte(), in.readByte(), in.readByte());
|
||||
this.size = new Position(in.readUnsignedByte(), in.readUnsignedByte(), in.readUnsignedByte());
|
||||
this.offset = Vector3i.from(in.readByte(), in.readByte(), in.readByte());
|
||||
this.size = Vector3i.from(in.readUnsignedByte(), in.readUnsignedByte(), in.readUnsignedByte());
|
||||
this.mirror = MagicValues.key(StructureMirror.class, in.readVarInt());
|
||||
this.rotation = MagicValues.key(StructureRotation.class, in.readVarInt());
|
||||
this.metadata = in.readString();
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -16,7 +17,7 @@ import java.io.IOException;
|
|||
@AllArgsConstructor
|
||||
public class ServerboundBlockEntityTagQuery implements Packet {
|
||||
private final int transactionId;
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
|
||||
public ServerboundBlockEntityTagQuery(NetInput in) throws IOException {
|
||||
this.transactionId = in.readVarInt();
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -15,7 +16,7 @@ import java.io.IOException;
|
|||
@With
|
||||
@AllArgsConstructor
|
||||
public class ServerboundJigsawGeneratePacket implements Packet {
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final int levels;
|
||||
private final boolean keepJigsaws;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.With;
|
||||
|
@ -14,10 +15,10 @@ import java.util.Arrays;
|
|||
@Data
|
||||
@With
|
||||
public class ServerboundSignUpdatePacket implements Packet {
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final @NonNull String[] lines;
|
||||
|
||||
public ServerboundSignUpdatePacket(@NonNull Position position, @NonNull String[] lines) {
|
||||
public ServerboundSignUpdatePacket(@NonNull Vector3i position, @NonNull String[] lines) {
|
||||
if (lines.length != 4) {
|
||||
throw new IllegalArgumentException("Lines must contain exactly 4 strings.");
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -19,7 +20,7 @@ import java.io.IOException;
|
|||
@AllArgsConstructor
|
||||
public class ServerboundPlayerActionPacket implements Packet {
|
||||
private final @NonNull PlayerAction action;
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final @NonNull Direction face;
|
||||
private final int sequence;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
|||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
@ -18,7 +19,7 @@ import java.io.IOException;
|
|||
@With
|
||||
@AllArgsConstructor
|
||||
public class ServerboundUseItemOnPacket implements Packet {
|
||||
private final @NonNull Position position;
|
||||
private final @NonNull Vector3i position;
|
||||
private final @NonNull Direction face;
|
||||
private final @NonNull Hand hand;
|
||||
private final float cursorX;
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockChangeEntry;
|
||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import org.junit.Before;
|
||||
|
||||
public class ClientboundBlockUpdatePacketTest extends PacketTest {
|
||||
|
@ -10,7 +11,7 @@ public class ClientboundBlockUpdatePacketTest extends PacketTest {
|
|||
public void setup() {
|
||||
this.setPackets(
|
||||
new ClientboundBlockUpdatePacket(new BlockChangeEntry(
|
||||
new Position(1, 61, -1), 3
|
||||
Vector3i.from(1, 61, -1), 3
|
||||
))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockChangeEntry;
|
||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import org.junit.Before;
|
||||
|
||||
public class ClientboundSectionBlocksUpdatePacketTest extends PacketTest {
|
||||
|
@ -10,7 +10,7 @@ public class ClientboundSectionBlocksUpdatePacketTest extends PacketTest {
|
|||
@Before
|
||||
public void setup() {
|
||||
this.setPackets(
|
||||
new ClientboundSectionBlocksUpdatePacket(3, 4, 12, false, new BlockChangeEntry(new Position(50, 65, 200), 3))
|
||||
new ClientboundSectionBlocksUpdatePacket(3, 4, 12, false, new BlockChangeEntry(Vector3i.from(50, 65, 200), 3))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.*;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEntityDataPacket;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
@ -25,7 +26,7 @@ public class ClientboundSetEntityDataPacketTest extends PacketTest {
|
|||
new ByteEntityMetadata(4, MetadataType.BYTE, (byte) 45),
|
||||
new IntEntityMetadata(2, MetadataType.INT, 555),
|
||||
new FloatEntityMetadata(3, MetadataType.FLOAT, 3.0f),
|
||||
new ObjectEntityMetadata<>(5, MetadataType.POSITION, new Position(0, 1, 0)),
|
||||
new ObjectEntityMetadata<>(5, MetadataType.POSITION, Vector3i.from(0, 1, 0)),
|
||||
new IntEntityMetadata(2, MetadataType.BLOCK_STATE, 60),
|
||||
new ObjectEntityMetadata<>(6, MetadataType.DIRECTION, Direction.EAST),
|
||||
new ObjectEntityMetadata<>(7, MetadataType.OPTIONAL_VARINT, OptionalInt.of(1038))
|
||||
|
|
Loading…
Reference in a new issue