use of com.nukkitx.math.vector.Vector3i in project Geyser by GeyserMC.
the class ChunkUtils method updateBlock.
/**
* Sends a block update to the Bedrock client. If chunk caching is enabled and the platform is not Spigot, this also
* adds that block to the cache.
* @param session the Bedrock session to send/register the block to
* @param blockState the Java block state of the block
* @param position the position of the block
*/
public static void updateBlock(GeyserSession session, int blockState, Position position) {
Vector3i pos = Vector3i.from(position.getX(), position.getY(), position.getZ());
updateBlock(session, blockState, pos);
}
use of com.nukkitx.math.vector.Vector3i in project Protocol by CloudburstMC.
the class StructureBlockUpdateSerializer_v291 method serialize.
@Override
public void serialize(ByteBuf buffer, BedrockPacketHelper helper, StructureBlockUpdatePacket packet) {
StructureEditorData editorData = packet.getEditorData();
StructureSettings settings = editorData.getSettings();
helper.writeBlockPosition(buffer, packet.getBlockPosition());
VarInts.writeUnsignedInt(buffer, editorData.getType().ordinal());
// Structure Editor Data start
helper.writeString(buffer, editorData.getName());
helper.writeString(buffer, editorData.getName());
helper.writeBlockPosition(buffer, settings.getOffset());
helper.writeBlockPosition(buffer, settings.getSize());
buffer.writeBoolean(!settings.isIgnoringEntities());
buffer.writeBoolean(settings.isIgnoringBlocks());
buffer.writeBoolean(editorData.isIncludingPlayers());
// show air
buffer.writeBoolean(false);
// Structure Settings start
buffer.writeFloatLE(settings.getIntegrityValue());
VarInts.writeUnsignedInt(buffer, settings.getIntegritySeed());
VarInts.writeUnsignedInt(buffer, settings.getMirror().ordinal());
VarInts.writeUnsignedInt(buffer, settings.getRotation().ordinal());
buffer.writeBoolean(settings.isIgnoringEntities());
// ignore structure blocks
buffer.writeBoolean(true);
Vector3i min = packet.getBlockPosition().add(settings.getOffset());
helper.writeVector3i(buffer, min);
Vector3i max = min.add(settings.getSize());
helper.writeVector3i(buffer, max);
// Structure Settings end
// Structure Editor Data end
buffer.writeBoolean(editorData.isBoundingBoxVisible());
buffer.writeBoolean(packet.isPowered());
}
use of com.nukkitx.math.vector.Vector3i in project Protocol by CloudburstMC.
the class StructureBlockUpdateSerializer_v291 method deserialize.
@Override
public void deserialize(ByteBuf buffer, BedrockPacketHelper helper, StructureBlockUpdatePacket packet) {
packet.setBlockPosition(helper.readBlockPosition(buffer));
StructureBlockType structureType = StructureBlockType.values()[VarInts.readUnsignedInt(buffer)];
// Structure Editor Data start
String name = helper.readString(buffer);
String dataField = helper.readString(buffer);
Vector3i offset = helper.readBlockPosition(buffer);
Vector3i size = helper.readBlockPosition(buffer);
// include entities
buffer.readBoolean();
boolean ignoreBlocks = !buffer.readBoolean();
boolean includePlayers = buffer.readBoolean();
// show air
buffer.readBoolean();
// Structure Settings start
float structureIntegrity = buffer.readFloatLE();
int integritySeed = VarInts.readUnsignedInt(buffer);
StructureMirror mirror = StructureMirror.from(VarInts.readUnsignedInt(buffer));
StructureRotation rotation = StructureRotation.from(VarInts.readUnsignedInt(buffer));
boolean ignoreEntities = buffer.readBoolean();
// ignore structure bocks
buffer.readBoolean();
// bounding box min
helper.readVector3i(buffer);
// bounding box max
helper.readVector3i(buffer);
// Structure Settings end
// Structure Editor Data end
boolean boundingBoxVisible = buffer.readBoolean();
StructureSettings settings = new StructureSettings("", ignoreEntities, ignoreBlocks, size, offset, -1, rotation, mirror, StructureAnimationMode.NONE, 0, structureIntegrity, integritySeed, Vector3f.ZERO);
StructureEditorData editorData = new StructureEditorData(name, dataField, includePlayers, boundingBoxVisible, structureType, settings, StructureRedstoneSaveMode.SAVES_TO_DISK);
packet.setEditorData(editorData);
packet.setPowered(buffer.readBoolean());
}
use of com.nukkitx.math.vector.Vector3i in project Protocol by CloudburstMC.
the class StructureBlockUpdateSerializer_v340 method deserialize.
@Override
public void deserialize(ByteBuf buffer, BedrockPacketHelper helper, StructureBlockUpdatePacket packet) {
packet.setBlockPosition(helper.readBlockPosition(buffer));
StructureBlockType structureType = StructureBlockType.values()[VarInts.readUnsignedInt(buffer)];
// Structure Editor Data start
String name = helper.readString(buffer);
String dataField = helper.readString(buffer);
Vector3i offset = helper.readBlockPosition(buffer);
Vector3i size = helper.readBlockPosition(buffer);
// include entities
buffer.readBoolean();
boolean ignoreBlocks = !buffer.readBoolean();
boolean includePlayers = buffer.readBoolean();
// show air
buffer.readBoolean();
// Structure Settings start
float structureIntegrity = buffer.readFloatLE();
int integritySeed = VarInts.readUnsignedInt(buffer);
StructureMirror mirror = StructureMirror.from(VarInts.readUnsignedInt(buffer));
StructureRotation rotation = StructureRotation.from(VarInts.readUnsignedInt(buffer));
boolean ignoreEntities = buffer.readBoolean();
// ignore structure bocks
buffer.readBoolean();
// bounding box min
helper.readVector3i(buffer);
// bounding box max
helper.readVector3i(buffer);
// Structure Settings end
// Structure Editor Data end
boolean boundingBoxVisible = buffer.readBoolean();
StructureSettings settings = new StructureSettings("", ignoreEntities, ignoreBlocks, size, offset, -1, rotation, mirror, StructureAnimationMode.NONE, 0, structureIntegrity, integritySeed, Vector3f.ZERO);
StructureEditorData editorData = new StructureEditorData(name, dataField, includePlayers, boundingBoxVisible, structureType, settings, StructureRedstoneSaveMode.SAVES_TO_DISK);
packet.setEditorData(editorData);
packet.setPowered(buffer.readBoolean());
}
use of com.nukkitx.math.vector.Vector3i in project Protocol by CloudburstMC.
the class BedrockPacketHelper_v361 method readStructureSettings.
@Override
public StructureSettings readStructureSettings(ByteBuf buffer) {
String paletteName = this.readString(buffer);
boolean ignoringEntities = buffer.readBoolean();
boolean ignoringBlocks = buffer.readBoolean();
Vector3i size = this.readBlockPosition(buffer);
Vector3i offset = this.readBlockPosition(buffer);
long lastEditedByEntityId = VarInts.readLong(buffer);
StructureRotation rotation = StructureRotation.from(buffer.readByte());
StructureMirror mirror = StructureMirror.from(buffer.readByte());
float integrityValue = buffer.readFloatLE();
int integritySeed = buffer.readIntLE();
return new StructureSettings(paletteName, ignoringEntities, ignoringBlocks, size, offset, lastEditedByEntityId, rotation, mirror, StructureAnimationMode.NONE, 0, integrityValue, integritySeed, Vector3f.ZERO);
}
Aggregations