use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project LoliServer by Loli-Server.
the class CraftEventFactory method handleMoistureChangeEvent.
public static boolean handleMoistureChangeEvent(World world, BlockPos pos, net.minecraft.block.BlockState newBlock, int flag) {
CraftBlockState state = CraftBlockState.getBlockState(world, pos, flag);
state.setData(newBlock);
MoistureChangeEvent event = new MoistureChangeEvent(state.getBlock(), state);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
state.update(true);
}
return !event.isCancelled();
}
use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project LoliServer by Loli-Server.
the class CraftWorld method generateTree.
@Override
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
world.captureTreeGeneration = true;
world.captureBlockStates = true;
boolean grownTree = generateTree(loc, type);
world.captureBlockStates = false;
world.captureTreeGeneration = false;
if (grownTree) {
// Copy block data to delegate
for (org.bukkit.block.BlockState blockstate : world.capturedBlockStates.values()) {
BlockPos position = ((CraftBlockState) blockstate).getPosition();
net.minecraft.block.BlockState oldBlock = world.getBlockState(position);
int flag = ((CraftBlockState) blockstate).getFlag();
delegate.setBlockData(blockstate.getX(), blockstate.getY(), blockstate.getZ(), blockstate.getBlockData());
net.minecraft.block.BlockState newBlock = world.getBlockState(position);
world.markAndNotifyBlock(position, null, oldBlock, newBlock, flag, 512);
}
world.capturedBlockStates.clear();
return true;
} else {
world.capturedBlockStates.clear();
return false;
}
}
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 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