use of com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket in project Geyser by GeyserMC.
the class ItemFrameEntity method updateBlock.
/**
* Updates the item frame as a block
*/
public void updateBlock(boolean force) {
if (!changed && !force) {
// Don't send a block update packet - nothing changed
return;
}
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
updateBlockPacket.setDataLayer(0);
updateBlockPacket.setBlockPosition(bedrockPosition);
updateBlockPacket.setRuntimeId(bedrockRuntimeId);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NETWORK);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
session.sendUpstreamPacket(updateBlockPacket);
BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket();
blockEntityDataPacket.setBlockPosition(bedrockPosition);
if (cachedTag != null) {
blockEntityDataPacket.setData(cachedTag);
} else {
blockEntityDataPacket.setData(getDefaultTag());
}
session.sendUpstreamPacket(blockEntityDataPacket);
changed = false;
}
use of com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket in project Geyser by GeyserMC.
the class BlockEntityUtils method updateBlockEntity.
public static void updateBlockEntity(GeyserSession session, @Nonnull NbtMap blockEntity, Vector3i position) {
BlockEntityDataPacket blockEntityPacket = new BlockEntityDataPacket();
blockEntityPacket.setBlockPosition(position);
blockEntityPacket.setData(blockEntity);
session.sendUpstreamPacket(blockEntityPacket);
}
use of com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket in project JukeboxMC by LucGamesYT.
the class BlockEntitySign method updateBlockEntitySign.
public void updateBlockEntitySign() {
BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket();
blockEntityDataPacket.setBlockPosition(this.block.getLocation().toVector3i());
blockEntityDataPacket.setData(this.toCompound().build());
this.block.getWorld().sendDimensionPacket(blockEntityDataPacket, this.block.getLocation().getDimension());
}
use of com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket in project JukeboxMC by LucGamesYT.
the class BlockEntitySign method updateBlockEntitySign.
public void updateBlockEntitySign(NbtMap nbt, Player player) {
String text = nbt.getString("Text", "");
String[] splitLine = text.split("\n");
ArrayList<String> lineList = new ArrayList<>();
Collections.addAll(lineList, splitLine);
BlockSignChangeEvent blockSignChangeEvent = new BlockSignChangeEvent(this.block, player, lineList);
Server.getInstance().getPluginManager().callEvent(blockSignChangeEvent);
if (blockSignChangeEvent.isCancelled()) {
return;
}
this.lines.clear();
this.lines.addAll(blockSignChangeEvent.getLines());
BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket();
blockEntityDataPacket.setBlockPosition(this.block.getLocation().toVector3i());
blockEntityDataPacket.setData(this.toCompound().build());
this.block.getWorld().sendDimensionPacket(blockEntityDataPacket, this.block.getLocation().getDimension());
}
use of com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket in project JukeboxMC by LucGamesYT.
the class BlockEntity method spawn.
public BlockEntity spawn() {
World world = this.block.getWorld();
Vector location = this.block.getLocation();
BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket();
blockEntityDataPacket.setBlockPosition(location.toVector3i());
blockEntityDataPacket.setData(this.toCompound().build());
world.sendDimensionPacket(blockEntityDataPacket, location.getDimension());
world.setBlockEntity(location, this, location.getDimension());
return this;
}
Aggregations