Search in sources :

Example 21 with Vector3i

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);
}
Also used : Vector3i(com.nukkitx.math.vector.Vector3i)

Example 22 with Vector3i

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());
}
Also used : Vector3i(com.nukkitx.math.vector.Vector3i)

Example 23 with Vector3i

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());
}
Also used : Vector3i(com.nukkitx.math.vector.Vector3i)

Example 24 with Vector3i

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());
}
Also used : Vector3i(com.nukkitx.math.vector.Vector3i)

Example 25 with Vector3i

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);
}
Also used : StructureRotation(com.nukkitx.protocol.bedrock.data.structure.StructureRotation) Vector3i(com.nukkitx.math.vector.Vector3i) StructureSettings(com.nukkitx.protocol.bedrock.data.structure.StructureSettings) StructureMirror(com.nukkitx.protocol.bedrock.data.structure.StructureMirror)

Aggregations

Vector3i (com.nukkitx.math.vector.Vector3i)25 UpdateBlockPacket (com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket)5 Vector3f (com.nukkitx.math.vector.Vector3f)4 Container (org.geysermc.geyser.inventory.Container)4 Position (com.github.steveice10.mc.protocol.data.game.entity.metadata.Position)3 NbtMap (com.nukkitx.nbt.NbtMap)3 NbtMapBuilder (com.nukkitx.nbt.NbtMapBuilder)3 StructureMirror (com.nukkitx.protocol.bedrock.data.structure.StructureMirror)3 StructureRotation (com.nukkitx.protocol.bedrock.data.structure.StructureRotation)3 StructureSettings (com.nukkitx.protocol.bedrock.data.structure.StructureSettings)3 ItemFrameEntity (org.geysermc.geyser.entity.type.ItemFrameEntity)3 CompoundTag (com.github.steveice10.opennbt.tag.builtin.CompoundTag)2 BlockEntityDataPacket (com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket)2 ContainerClosePacket (com.nukkitx.protocol.bedrock.packet.ContainerClosePacket)2 LevelChunkPacket (com.nukkitx.protocol.bedrock.packet.LevelChunkPacket)2 LevelSoundEventPacket (com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket)2 BitStorage (com.github.steveice10.mc.protocol.data.game.chunk.BitStorage)1 ChunkSection (com.github.steveice10.mc.protocol.data.game.chunk.ChunkSection)1 DataPalette (com.github.steveice10.mc.protocol.data.game.chunk.DataPalette)1 GlobalPalette (com.github.steveice10.mc.protocol.data.game.chunk.palette.GlobalPalette)1