use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project Denizen-For-Bukkit by DenizenScript.
the class BlockHelper_v1_8_R3 method setNbtData.
@Override
public void setNbtData(Block block, CompoundTag compoundTag) {
TileEntity tileEntity = ((CraftBlockState) block.getState()).getTileEntity();
if (tileEntity == null) {
return;
}
tileEntity.a(((CompoundTag_v1_8_R3) compoundTag).toNMSTag());
tileEntity.update();
}
use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project Denizen-For-Bukkit by DenizenScript.
the class BlockHelper_v1_9_R2 method setNbtData.
@Override
public void setNbtData(Block block, CompoundTag compoundTag) {
TileEntity tileEntity = ((CraftBlockState) block.getState()).getTileEntity();
if (tileEntity == null) {
return;
}
tileEntity.a(((CompoundTag_v1_9_R2) compoundTag).toNMSTag());
tileEntity.update();
}
use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project MechanicsMain by WeaponMechanics.
the class Block_1_17_R1 method getMultiBlockMaskPacket.
@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable org.bukkit.block.BlockState mask) {
if (blocks == null || blocks.isEmpty()) {
throw new IllegalArgumentException("No blocks are being changed!");
}
Map<SubChunk, List<Block>> sortedBlocks = new HashMap<>();
for (Block block : blocks) {
List<Block> list = sortedBlocks.computeIfAbsent(SubChunk.byBlock(block), chunk -> new ArrayList<>());
list.add(block);
}
List<Object> packets = new ArrayList<>(sortedBlocks.size());
BlockState theMask = mask == null ? null : ((CraftBlockState) mask).getHandle();
for (List<Block> entry : sortedBlocks.values()) {
packets.add(getMultiBlockMaskPacket(entry, theMask));
}
return packets;
}
use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project MechanicsMain by WeaponMechanics.
the class Block_1_18_R1 method getMultiBlockMaskPacket.
@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable org.bukkit.block.BlockState mask) {
if (blocks == null || blocks.isEmpty()) {
throw new IllegalArgumentException("No blocks are being changed!");
}
Map<SubChunk, List<Block>> sortedBlocks = new HashMap<>();
for (Block block : blocks) {
List<Block> list = sortedBlocks.computeIfAbsent(SubChunk.byBlock(block), chunk -> new ArrayList<>());
list.add(block);
}
List<Object> packets = new ArrayList<>(sortedBlocks.size());
BlockState theMask = mask == null ? null : ((CraftBlockState) mask).getHandle();
for (List<Block> entry : sortedBlocks.values()) {
packets.add(getMultiBlockMaskPacket(entry, theMask));
}
return packets;
}
use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project NotQuests by AlessioGr.
the class PacketInjector method sendBeaconUpdatePacket.
/* public static void sendMultiBlockChange(Player p, Block block) {
// Creating some blocks to set
Location loc = p.getLocation().clone();
// BlockData is just an object that stores a Location, int and byte
List<BlockData> blocks = new ArrayList<>();
for (int i = 0; i < 10; i++) {
blocks.add(new BlockData(loc, block.getType().getId() + 1, (byte) 0));
}
// Sending packet
PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange();
MultiBlockChangeInfo[] info = new MultiBlockChangeInfo[blocks.size()];
for (int i = 0; i < blocks.size(); i++) {
int blockId = blocks.get(i).getTypeId();
byte horizPos = (byte) (blocks.get(i).getLocation().getBlockX() << 4
+ blocks.get(i).getLocation().getBlockZ());
byte heigth = (byte) blocks.get(i).getLocation().getY();
byte id = (byte) (blockId << 4 | (0 & 15));
short data = (short) (horizPos + heigth + id);
info[i] = packet.new MultiBlockChangeInfo(data,
net.minecraft.server.v1_8_R3.Block.getByCombinedId(blockId));
}
setPrivateObject(PacketPlayOutMultiBlockChange.class, packet, "a",
new ChunkCoordIntPair(p.getLocation().getChunk().getX(), p.getLocation().getChunk().getZ()));
setPrivateObject(PacketPlayOutMultiBlockChange.class, packet, "b", info);
getNMSPlayer(p).playerConnection.sendPacket(packet);
p.sendMessage("Packet sent");
}*/
public void sendBeaconUpdatePacket(Player player, Location location, BlockState blockState) {
Connection connection = getConnection(getServerPlayer(player).connection);
CraftBlockState craftBlockState = (CraftBlockState) blockState;
net.minecraft.world.level.block.Block nmsBlock = craftBlockState.getHandle().getBlock();
BlockPos blockPos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
player.teleport(location.clone().add(0, 1, 0));
// player.sendMessage("nmsBlock: " + nmsBlock.getName().getString());
// BlockPost, Block, Action ID (1=recalculate), Action Type (ignored for beacons)
ClientboundBlockEventPacket clientboundBlockEventPacket = new ClientboundBlockEventPacket(blockPos, nmsBlock, 1, 1);
// player.sendMessage("sent!");
// connection.send(clientboundBlockEventPacket);
connection.send(clientboundBlockEventPacket, (future) -> {
// player.sendMessage("Arrived!");
});
}
Aggregations