Search in sources :

Example 6 with CraftBlockState

use of org.bukkit.craftbukkit.v1_16_R3.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();
}
Also used : CraftBlockState(org.bukkit.craftbukkit.v1_12_R1.block.CraftBlockState) Block(org.bukkit.block.Block) CraftBlock(org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock)

Example 7 with CraftBlockState

use of org.bukkit.craftbukkit.v1_16_R3.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;
    }
}
Also used : CraftBlockState(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState) BlockPos(net.minecraft.util.math.BlockPos)

Example 8 with CraftBlockState

use of org.bukkit.craftbukkit.v1_16_R3.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;
}
Also used : CraftBlockState(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState) BlockFadeEvent(org.bukkit.event.block.BlockFadeEvent)

Example 9 with CraftBlockState

use of org.bukkit.craftbukkit.v1_16_R3.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();
}
Also used : MoistureChangeEvent(org.bukkit.event.block.MoistureChangeEvent) CraftBlockState(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState)

Example 10 with CraftBlockState

use of org.bukkit.craftbukkit.v1_16_R3.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;
}
Also used : CraftBlockState(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState) BlockFadeEvent(org.bukkit.event.block.BlockFadeEvent)

Aggregations

CraftBlockState (org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState)16 Block (org.bukkit.block.Block)8 CraftBlockState (org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState)8 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 List (java.util.List)4 NotNull (org.jetbrains.annotations.NotNull)4 BlockState (net.minecraft.world.level.block.state.BlockState)3 CraftBlock (org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock)3 BlockFadeEvent (org.bukkit.event.block.BlockFadeEvent)3 BlockFormEvent (org.bukkit.event.block.BlockFormEvent)3 BlockGrowEvent (org.bukkit.event.block.BlockGrowEvent)3 BlockSpreadEvent (org.bukkit.event.block.BlockSpreadEvent)3 EntityBlockFormEvent (org.bukkit.event.block.EntityBlockFormEvent)3 MoistureChangeEvent (org.bukkit.event.block.MoistureChangeEvent)3 TileEntity (net.minecraft.server.v1_8_R3.TileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 CraftBlock (org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock)2 CraftBlockState (org.bukkit.craftbukkit.v1_8_R3.block.CraftBlockState)2 BlockPos (net.minecraft.core.BlockPos)1