mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
rename some ByteBuffer functions
This commit is contained in:
parent
a910122ce2
commit
9cfda63e36
@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.mappings.blocks.actions;
|
|||||||
|
|
||||||
public class BeaconAction implements BlockAction {
|
public class BeaconAction implements BlockAction {
|
||||||
|
|
||||||
public BeaconAction(short status, short ignored) {
|
public BeaconAction(int status, int ignored) {
|
||||||
// only 1 action (id 1)
|
// only 1 action (id 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
package de.bixilon.minosoft.data.mappings.blocks.actions;
|
package de.bixilon.minosoft.data.mappings.blocks.actions;
|
||||||
|
|
||||||
public class ChestAction implements BlockAction {
|
public class ChestAction implements BlockAction {
|
||||||
private final short playersLookingInChest;
|
private final int playersLookingInChest;
|
||||||
|
|
||||||
public ChestAction(short unused, short playersLookingInChest) {
|
public ChestAction(int unused, int playersLookingInChest) {
|
||||||
this.playersLookingInChest = playersLookingInChest;
|
this.playersLookingInChest = playersLookingInChest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.mappings.blocks.actions;
|
|||||||
|
|
||||||
public class EndGatewayAction implements BlockAction {
|
public class EndGatewayAction implements BlockAction {
|
||||||
|
|
||||||
public EndGatewayAction(short status, short ignored) {
|
public EndGatewayAction(int status, int ignored) {
|
||||||
// only 1 action (id 1)
|
// only 1 action (id 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.mappings.blocks.actions;
|
|||||||
|
|
||||||
public class MobSpawnerAction implements BlockAction {
|
public class MobSpawnerAction implements BlockAction {
|
||||||
|
|
||||||
public MobSpawnerAction(short status, short ignored) {
|
public MobSpawnerAction(int status, int ignored) {
|
||||||
// only 1 action (id 1)
|
// only 1 action (id 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ package de.bixilon.minosoft.data.mappings.blocks.actions;
|
|||||||
|
|
||||||
public class NoteBlockAction implements BlockAction {
|
public class NoteBlockAction implements BlockAction {
|
||||||
private final Instruments instrument;
|
private final Instruments instrument;
|
||||||
private final short pitch;
|
private final int pitch;
|
||||||
|
|
||||||
public NoteBlockAction(short instrument, short pitch) {
|
public NoteBlockAction(int instrument, int pitch) {
|
||||||
this.instrument = Instruments.byId(instrument);
|
this.instrument = Instruments.byId(instrument);
|
||||||
this.pitch = pitch;
|
this.pitch = pitch;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class PistonAction implements BlockAction {
|
|||||||
private final PistonStates status;
|
private final PistonStates status;
|
||||||
private final Directions direction;
|
private final Directions direction;
|
||||||
|
|
||||||
public PistonAction(short status, short direction) {
|
public PistonAction(int status, int direction) {
|
||||||
this.status = PistonStates.byId(status);
|
this.status = PistonStates.byId(status);
|
||||||
this.direction = Directions.byId(direction);
|
this.direction = Directions.byId(direction);
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ public class PacketBlockAction extends ClientboundPacket {
|
|||||||
} else {
|
} else {
|
||||||
this.position = buffer.readBlockPosition();
|
this.position = buffer.readBlockPosition();
|
||||||
}
|
}
|
||||||
short byte1 = buffer.readUnsignedByte();
|
int byte1 = buffer.readUnsignedByte();
|
||||||
short byte2 = buffer.readUnsignedByte();
|
int byte2 = buffer.readUnsignedByte();
|
||||||
Block blockId = buffer.getConnection().getMapping().getBlockRegistry().get(buffer.readVarInt());
|
Block blockId = buffer.getConnection().getMapping().getBlockRegistry().get(buffer.readVarInt());
|
||||||
if (blockId == null) {
|
if (blockId == null) {
|
||||||
this.data = null;
|
this.data = null;
|
||||||
|
@ -36,7 +36,7 @@ public class PacketEntityTeleport extends ClientboundPacket {
|
|||||||
if (buffer.getVersionId() < V_16W06A) {
|
if (buffer.getVersionId() < V_16W06A) {
|
||||||
this.position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
this.position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||||
} else {
|
} else {
|
||||||
this.position = buffer.readLocation();
|
this.position = buffer.readEntityPosition();
|
||||||
}
|
}
|
||||||
this.yaw = buffer.readAngle();
|
this.yaw = buffer.readAngle();
|
||||||
this.pitch = buffer.readAngle();
|
this.pitch = buffer.readAngle();
|
||||||
|
@ -26,7 +26,7 @@ public class PacketFacePlayer extends ClientboundPacket {
|
|||||||
|
|
||||||
public PacketFacePlayer(InByteBuffer buffer) {
|
public PacketFacePlayer(InByteBuffer buffer) {
|
||||||
this.face = PlayerFaces.byId(buffer.readVarInt());
|
this.face = PlayerFaces.byId(buffer.readVarInt());
|
||||||
this.position = buffer.readLocation();
|
this.position = buffer.readEntityPosition();
|
||||||
if (buffer.readBoolean()) {
|
if (buffer.readBoolean()) {
|
||||||
// entity present
|
// entity present
|
||||||
this.entityId = buffer.readVarInt();
|
this.entityId = buffer.readVarInt();
|
||||||
|
@ -107,16 +107,15 @@ public class PacketMapData extends ClientboundPacket {
|
|||||||
this.pins.add(new MapPinSet(type, direction, x, z, displayName));
|
this.pins.add(new MapPinSet(type, direction, x, z, displayName));
|
||||||
}
|
}
|
||||||
|
|
||||||
short columns = buffer.readUnsignedByte();
|
int columns = buffer.readUnsignedByte();
|
||||||
if (columns > 0) {
|
if (columns > 0) {
|
||||||
short rows = buffer.readUnsignedByte();
|
int rows = buffer.readUnsignedByte();
|
||||||
short xOffset = buffer.readUnsignedByte();
|
int xOffset = buffer.readUnsignedByte();
|
||||||
short zOffset = buffer.readUnsignedByte();
|
int zOffset = buffer.readUnsignedByte();
|
||||||
|
|
||||||
int dataLength = buffer.readVarInt();
|
int dataLength = buffer.readVarInt();
|
||||||
this.data = buffer.readBytes(dataLength);
|
this.data = buffer.readBytes(dataLength);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,7 +47,7 @@ public class PacketParticle extends ClientboundPacket {
|
|||||||
if (buffer.getVersionId() < V_1_15_PRE4) {
|
if (buffer.getVersionId() < V_1_15_PRE4) {
|
||||||
this.position = buffer.readFloatPosition();
|
this.position = buffer.readFloatPosition();
|
||||||
} else {
|
} else {
|
||||||
this.position = buffer.readLocation();
|
this.position = buffer.readEntityPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
// offset
|
// offset
|
||||||
|
@ -33,7 +33,7 @@ public class PacketPlayerPositionAndRotation extends ClientboundPacket {
|
|||||||
private boolean dismountVehicle = true;
|
private boolean dismountVehicle = true;
|
||||||
|
|
||||||
public PacketPlayerPositionAndRotation(InByteBuffer buffer) {
|
public PacketPlayerPositionAndRotation(InByteBuffer buffer) {
|
||||||
this.position = buffer.readLocation();
|
this.position = buffer.readEntityPosition();
|
||||||
this.rotation = new EntityRotation(buffer.readFloat(), buffer.readFloat(), 0);
|
this.rotation = new EntityRotation(buffer.readFloat(), buffer.readFloat(), 0);
|
||||||
if (buffer.getVersionId() < V_14W03B) {
|
if (buffer.getVersionId() < V_14W03B) {
|
||||||
this.onGround = buffer.readBoolean();
|
this.onGround = buffer.readBoolean();
|
||||||
|
@ -33,7 +33,7 @@ public class PacketSpawnExperienceOrb extends ClientboundPacket {
|
|||||||
if (buffer.getVersionId() < V_16W06A) {
|
if (buffer.getVersionId() < V_16W06A) {
|
||||||
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||||
} else {
|
} else {
|
||||||
position = buffer.readLocation();
|
position = buffer.readEntityPosition();
|
||||||
}
|
}
|
||||||
int count = buffer.readUnsignedShort();
|
int count = buffer.readUnsignedShort();
|
||||||
this.entity = new ExperienceOrb(buffer.getConnection(), position, count);
|
this.entity = new ExperienceOrb(buffer.getConnection(), position, count);
|
||||||
|
@ -54,7 +54,7 @@ public class PacketSpawnMob extends ClientboundPacket {
|
|||||||
if (buffer.getVersionId() < V_16W06A) {
|
if (buffer.getVersionId() < V_16W06A) {
|
||||||
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||||
} else {
|
} else {
|
||||||
position = buffer.readLocation();
|
position = buffer.readEntityPosition();
|
||||||
}
|
}
|
||||||
EntityRotation rotation = new EntityRotation(buffer.readAngle(), buffer.readAngle(), buffer.readAngle());
|
EntityRotation rotation = new EntityRotation(buffer.readAngle(), buffer.readAngle(), buffer.readAngle());
|
||||||
this.velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort());
|
this.velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort());
|
||||||
|
@ -59,7 +59,7 @@ public class PacketSpawnObject extends ClientboundPacket {
|
|||||||
if (buffer.getVersionId() < V_16W06A) {
|
if (buffer.getVersionId() < V_16W06A) {
|
||||||
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||||
} else {
|
} else {
|
||||||
position = buffer.readLocation();
|
position = buffer.readEntityPosition();
|
||||||
}
|
}
|
||||||
EntityRotation rotation = new EntityRotation(buffer.readAngle(), buffer.readAngle(), 0);
|
EntityRotation rotation = new EntityRotation(buffer.readAngle(), buffer.readAngle(), 0);
|
||||||
int data = buffer.readInt();
|
int data = buffer.readInt();
|
||||||
|
@ -55,7 +55,7 @@ public class PacketSpawnPlayer extends ClientboundPacket {
|
|||||||
if (buffer.getVersionId() < V_16W06A) {
|
if (buffer.getVersionId() < V_16W06A) {
|
||||||
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||||
} else {
|
} else {
|
||||||
position = buffer.readLocation();
|
position = buffer.readEntityPosition();
|
||||||
}
|
}
|
||||||
short yaw = buffer.readAngle();
|
short yaw = buffer.readAngle();
|
||||||
short pitch = buffer.readAngle();
|
short pitch = buffer.readAngle();
|
||||||
|
@ -35,7 +35,7 @@ public class PacketSpawnWeatherEntity extends ClientboundPacket {
|
|||||||
if (buffer.getVersionId() < V_16W06A) {
|
if (buffer.getVersionId() < V_16W06A) {
|
||||||
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||||
} else {
|
} else {
|
||||||
position = buffer.readLocation();
|
position = buffer.readEntityPosition();
|
||||||
}
|
}
|
||||||
this.entity = new LightningBolt(buffer.getConnection(), this.entityId, position);
|
this.entity = new LightningBolt(buffer.getConnection(), this.entityId, position);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class PacketVehicleMovement extends ClientboundPacket {
|
|||||||
private final float pitch;
|
private final float pitch;
|
||||||
|
|
||||||
public PacketVehicleMovement(InByteBuffer buffer) {
|
public PacketVehicleMovement(InByteBuffer buffer) {
|
||||||
this.position = buffer.readLocation();
|
this.position = buffer.readEntityPosition();
|
||||||
this.yaw = buffer.readFloat();
|
this.yaw = buffer.readFloat();
|
||||||
this.pitch = buffer.readFloat();
|
this.pitch = buffer.readFloat();
|
||||||
}
|
}
|
||||||
|
@ -135,11 +135,11 @@ public class InByteBuffer {
|
|||||||
return readByte() == 1;
|
return readByte() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] readUnsignedLEShorts(int num) {
|
public int[] readUnsignedShortsLE(int count) {
|
||||||
if (num > ProtocolDefinition.PROTOCOL_PACKET_MAX_SIZE) {
|
if (count > ProtocolDefinition.PROTOCOL_PACKET_MAX_SIZE) {
|
||||||
throw new IllegalArgumentException("Trying to allocate to much memory");
|
throw new IllegalArgumentException("Trying to allocate to much memory");
|
||||||
}
|
}
|
||||||
int[] ret = new int[num];
|
int[] ret = new int[count];
|
||||||
for (int i = 0; i < ret.length; i++) {
|
for (int i = 0; i < ret.length; i++) {
|
||||||
ret[i] = ((readUnsignedByte()) | (readUnsignedByte() << 8));
|
ret[i] = ((readUnsignedByte()) | (readUnsignedByte() << 8));
|
||||||
}
|
}
|
||||||
@ -198,8 +198,8 @@ public class InByteBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IntRange(from = 0, to = ((int) Byte.MAX_VALUE) * 2 + 1)
|
@IntRange(from = 0, to = ((int) Byte.MAX_VALUE) * 2 + 1)
|
||||||
public short readUnsignedByte() {
|
public int readUnsignedByte() {
|
||||||
return (short) (this.bytes[this.position++] & 0xFF);
|
return (this.bytes[this.position++] & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3i readBlockPosition() {
|
public Vec3i readBlockPosition() {
|
||||||
@ -356,7 +356,7 @@ public class InByteBuffer {
|
|||||||
return (short) (readByte() * ProtocolDefinition.ANGLE_CALCULATION_CONSTANT);
|
return (short) (readByte() * ProtocolDefinition.ANGLE_CALCULATION_CONSTANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 readLocation() {
|
public Vec3 readEntityPosition() {
|
||||||
return new Vec3(readDouble(), readDouble(), readDouble());
|
return new Vec3(readDouble(), readDouble(), readDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,7 +448,7 @@ public class InByteBuffer {
|
|||||||
EntityMetaData.MetaDataHashMap sets = metaData.getSets();
|
EntityMetaData.MetaDataHashMap sets = metaData.getSets();
|
||||||
|
|
||||||
if (this.versionId < V_15W31A) { // ToDo: This version was 48, but this one does not exist!
|
if (this.versionId < V_15W31A) { // ToDo: This version was 48, but this one does not exist!
|
||||||
short item = readUnsignedByte();
|
int item = readUnsignedByte();
|
||||||
while (item != 0x7F) {
|
while (item != 0x7F) {
|
||||||
byte index = (byte) (item & 0x1F);
|
byte index = (byte) (item & 0x1F);
|
||||||
EntityMetaData.EntityMetaDataDataTypes type = this.connection.getMapping().getEntityMetaDataDataDataTypesRegistry().get((item & 0xFF) >> 5);
|
EntityMetaData.EntityMetaDataDataTypes type = this.connection.getMapping().getEntityMetaDataDataDataTypesRegistry().get((item & 0xFF) >> 5);
|
||||||
|
@ -114,7 +114,7 @@ object ChunkUtil {
|
|||||||
val totalEntries: Int = ProtocolDefinition.BLOCKS_PER_SECTION * sectionBitMask.cardinality()
|
val totalEntries: Int = ProtocolDefinition.BLOCKS_PER_SECTION * sectionBitMask.cardinality()
|
||||||
val totalHalfEntries = totalEntries / 2
|
val totalHalfEntries = totalEntries / 2
|
||||||
|
|
||||||
val blockData = buffer.readUnsignedLEShorts(totalEntries) // blocks >>> 4, data & 0xF
|
val blockData = buffer.readUnsignedShortsLE(totalEntries) // blocks >>> 4, data & 0xF
|
||||||
|
|
||||||
|
|
||||||
val light = buffer.readBytes(totalHalfEntries)
|
val light = buffer.readBytes(totalHalfEntries)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user