use of org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState in project Magma by magmafoundation.
the class CraftEventFactory method handleBlockGrowEvent.
public static boolean handleBlockGrowEvent(World world, int x, int y, int z, net.minecraft.block.Block type, int data) {
Block block = world.getWorld().getBlockAt(x, y, z);
CraftBlockState state = (CraftBlockState) block.getState();
state.setTypeId(net.minecraft.block.Block.getIdFromBlock(type));
state.setRawData((byte) data);
BlockGrowEvent event = new BlockGrowEvent(block, state);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
state.update(true);
}
return !event.isCancelled();
}
use of org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState in project Magma-1.16.x by magmafoundation.
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_18_R2.block.CraftBlockState in project LoliServer by Loli-Server.
the class CraftEventFactory method callBlockFadeEvent.
/**
* BlockFadeEvent
*/
public static BlockFadeEvent callBlockFadeEvent(IWorld world, BlockPos pos, net.minecraft.block.BlockState newBlock) {
CraftBlockState state = CraftBlockState.getBlockState(world, pos);
state.setData(newBlock);
BlockFadeEvent event = new BlockFadeEvent(state.getBlock(), state);
Bukkit.getPluginManager().callEvent(event);
return event;
}
use of org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState in project Magma-1.16.x by magmafoundation.
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_18_R2.block.CraftBlockState in project Magma-1.16.x by magmafoundation.
the class CraftEventFactory method callBlockFadeEvent.
/**
* BlockFadeEvent
*/
public static BlockFadeEvent callBlockFadeEvent(IWorld world, BlockPos pos, net.minecraft.block.BlockState newBlock) {
CraftBlockState state = CraftBlockState.getBlockState(world, pos);
state.setData(newBlock);
BlockFadeEvent event = new BlockFadeEvent(state.getBlock(), state);
Bukkit.getPluginManager().callEvent(event);
return event;
}
Aggregations