mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -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 BeaconAction(short status, short ignored) {
|
||||
public BeaconAction(int status, int ignored) {
|
||||
// only 1 action (id 1)
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,9 @@
|
||||
package de.bixilon.minosoft.data.mappings.blocks.actions;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.mappings.blocks.actions;
|
||||
|
||||
public class EndGatewayAction implements BlockAction {
|
||||
|
||||
public EndGatewayAction(short status, short ignored) {
|
||||
public EndGatewayAction(int status, int ignored) {
|
||||
// only 1 action (id 1)
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.mappings.blocks.actions;
|
||||
|
||||
public class MobSpawnerAction implements BlockAction {
|
||||
|
||||
public MobSpawnerAction(short status, short ignored) {
|
||||
public MobSpawnerAction(int status, int ignored) {
|
||||
// only 1 action (id 1)
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@ package de.bixilon.minosoft.data.mappings.blocks.actions;
|
||||
|
||||
public class NoteBlockAction implements BlockAction {
|
||||
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.pitch = pitch;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class PistonAction implements BlockAction {
|
||||
private final PistonStates status;
|
||||
private final Directions direction;
|
||||
|
||||
public PistonAction(short status, short direction) {
|
||||
public PistonAction(int status, int direction) {
|
||||
this.status = PistonStates.byId(status);
|
||||
this.direction = Directions.byId(direction);
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ public class PacketBlockAction extends ClientboundPacket {
|
||||
} else {
|
||||
this.position = buffer.readBlockPosition();
|
||||
}
|
||||
short byte1 = buffer.readUnsignedByte();
|
||||
short byte2 = buffer.readUnsignedByte();
|
||||
int byte1 = buffer.readUnsignedByte();
|
||||
int byte2 = buffer.readUnsignedByte();
|
||||
Block blockId = buffer.getConnection().getMapping().getBlockRegistry().get(buffer.readVarInt());
|
||||
if (blockId == null) {
|
||||
this.data = null;
|
||||
|
@ -36,7 +36,7 @@ public class PacketEntityTeleport extends ClientboundPacket {
|
||||
if (buffer.getVersionId() < V_16W06A) {
|
||||
this.position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||
} else {
|
||||
this.position = buffer.readLocation();
|
||||
this.position = buffer.readEntityPosition();
|
||||
}
|
||||
this.yaw = buffer.readAngle();
|
||||
this.pitch = buffer.readAngle();
|
||||
|
@ -26,7 +26,7 @@ public class PacketFacePlayer extends ClientboundPacket {
|
||||
|
||||
public PacketFacePlayer(InByteBuffer buffer) {
|
||||
this.face = PlayerFaces.byId(buffer.readVarInt());
|
||||
this.position = buffer.readLocation();
|
||||
this.position = buffer.readEntityPosition();
|
||||
if (buffer.readBoolean()) {
|
||||
// entity present
|
||||
this.entityId = buffer.readVarInt();
|
||||
|
@ -107,16 +107,15 @@ public class PacketMapData extends ClientboundPacket {
|
||||
this.pins.add(new MapPinSet(type, direction, x, z, displayName));
|
||||
}
|
||||
|
||||
short columns = buffer.readUnsignedByte();
|
||||
int columns = buffer.readUnsignedByte();
|
||||
if (columns > 0) {
|
||||
short rows = buffer.readUnsignedByte();
|
||||
short xOffset = buffer.readUnsignedByte();
|
||||
short zOffset = buffer.readUnsignedByte();
|
||||
int rows = buffer.readUnsignedByte();
|
||||
int xOffset = buffer.readUnsignedByte();
|
||||
int zOffset = buffer.readUnsignedByte();
|
||||
|
||||
int dataLength = buffer.readVarInt();
|
||||
this.data = buffer.readBytes(dataLength);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +47,7 @@ public class PacketParticle extends ClientboundPacket {
|
||||
if (buffer.getVersionId() < V_1_15_PRE4) {
|
||||
this.position = buffer.readFloatPosition();
|
||||
} else {
|
||||
this.position = buffer.readLocation();
|
||||
this.position = buffer.readEntityPosition();
|
||||
}
|
||||
|
||||
// offset
|
||||
|
@ -33,7 +33,7 @@ public class PacketPlayerPositionAndRotation extends ClientboundPacket {
|
||||
private boolean dismountVehicle = true;
|
||||
|
||||
public PacketPlayerPositionAndRotation(InByteBuffer buffer) {
|
||||
this.position = buffer.readLocation();
|
||||
this.position = buffer.readEntityPosition();
|
||||
this.rotation = new EntityRotation(buffer.readFloat(), buffer.readFloat(), 0);
|
||||
if (buffer.getVersionId() < V_14W03B) {
|
||||
this.onGround = buffer.readBoolean();
|
||||
|
@ -33,7 +33,7 @@ public class PacketSpawnExperienceOrb extends ClientboundPacket {
|
||||
if (buffer.getVersionId() < V_16W06A) {
|
||||
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||
} else {
|
||||
position = buffer.readLocation();
|
||||
position = buffer.readEntityPosition();
|
||||
}
|
||||
int count = buffer.readUnsignedShort();
|
||||
this.entity = new ExperienceOrb(buffer.getConnection(), position, count);
|
||||
|
@ -54,7 +54,7 @@ public class PacketSpawnMob extends ClientboundPacket {
|
||||
if (buffer.getVersionId() < V_16W06A) {
|
||||
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||
} else {
|
||||
position = buffer.readLocation();
|
||||
position = buffer.readEntityPosition();
|
||||
}
|
||||
EntityRotation rotation = new EntityRotation(buffer.readAngle(), buffer.readAngle(), buffer.readAngle());
|
||||
this.velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort());
|
||||
|
@ -59,7 +59,7 @@ public class PacketSpawnObject extends ClientboundPacket {
|
||||
if (buffer.getVersionId() < V_16W06A) {
|
||||
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||
} else {
|
||||
position = buffer.readLocation();
|
||||
position = buffer.readEntityPosition();
|
||||
}
|
||||
EntityRotation rotation = new EntityRotation(buffer.readAngle(), buffer.readAngle(), 0);
|
||||
int data = buffer.readInt();
|
||||
|
@ -55,7 +55,7 @@ public class PacketSpawnPlayer extends ClientboundPacket {
|
||||
if (buffer.getVersionId() < V_16W06A) {
|
||||
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||
} else {
|
||||
position = buffer.readLocation();
|
||||
position = buffer.readEntityPosition();
|
||||
}
|
||||
short yaw = buffer.readAngle();
|
||||
short pitch = buffer.readAngle();
|
||||
|
@ -35,7 +35,7 @@ public class PacketSpawnWeatherEntity extends ClientboundPacket {
|
||||
if (buffer.getVersionId() < V_16W06A) {
|
||||
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||
} else {
|
||||
position = buffer.readLocation();
|
||||
position = buffer.readEntityPosition();
|
||||
}
|
||||
this.entity = new LightningBolt(buffer.getConnection(), this.entityId, position);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class PacketVehicleMovement extends ClientboundPacket {
|
||||
private final float pitch;
|
||||
|
||||
public PacketVehicleMovement(InByteBuffer buffer) {
|
||||
this.position = buffer.readLocation();
|
||||
this.position = buffer.readEntityPosition();
|
||||
this.yaw = buffer.readFloat();
|
||||
this.pitch = buffer.readFloat();
|
||||
}
|
||||
|
@ -135,11 +135,11 @@ public class InByteBuffer {
|
||||
return readByte() == 1;
|
||||
}
|
||||
|
||||
public int[] readUnsignedLEShorts(int num) {
|
||||
if (num > ProtocolDefinition.PROTOCOL_PACKET_MAX_SIZE) {
|
||||
public int[] readUnsignedShortsLE(int count) {
|
||||
if (count > ProtocolDefinition.PROTOCOL_PACKET_MAX_SIZE) {
|
||||
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++) {
|
||||
ret[i] = ((readUnsignedByte()) | (readUnsignedByte() << 8));
|
||||
}
|
||||
@ -198,8 +198,8 @@ public class InByteBuffer {
|
||||
}
|
||||
|
||||
@IntRange(from = 0, to = ((int) Byte.MAX_VALUE) * 2 + 1)
|
||||
public short readUnsignedByte() {
|
||||
return (short) (this.bytes[this.position++] & 0xFF);
|
||||
public int readUnsignedByte() {
|
||||
return (this.bytes[this.position++] & 0xFF);
|
||||
}
|
||||
|
||||
public Vec3i readBlockPosition() {
|
||||
@ -356,7 +356,7 @@ public class InByteBuffer {
|
||||
return (short) (readByte() * ProtocolDefinition.ANGLE_CALCULATION_CONSTANT);
|
||||
}
|
||||
|
||||
public Vec3 readLocation() {
|
||||
public Vec3 readEntityPosition() {
|
||||
return new Vec3(readDouble(), readDouble(), readDouble());
|
||||
}
|
||||
|
||||
@ -448,7 +448,7 @@ public class InByteBuffer {
|
||||
EntityMetaData.MetaDataHashMap sets = metaData.getSets();
|
||||
|
||||
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) {
|
||||
byte index = (byte) (item & 0x1F);
|
||||
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 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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user