Search in sources :

Example 21 with CraftBlockState

use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project Magma-1.16.x by magmafoundation.

the class CraftEventFactory method handleBlockGrowEvent.

public static boolean handleBlockGrowEvent(World world, BlockPos pos, net.minecraft.block.BlockState newData, int flag) {
    Block block = world.getWorldCB().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
    CraftBlockState state = (CraftBlockState) block.getState();
    state.setData(newData);
    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_16_R3.block.CraftBlockState) CraftBlock(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock) Block(org.bukkit.block.Block) BlockGrowEvent(org.bukkit.event.block.BlockGrowEvent)

Example 22 with CraftBlockState

use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project Magma-1.16.x by magmafoundation.

the class CraftEventFactory method handleBlockSpreadEvent.

public static boolean handleBlockSpreadEvent(World world, BlockPos source, BlockPos target, net.minecraft.block.BlockState block, int flag) {
    CraftBlockState state = CraftBlockState.getBlockState(world, target, flag);
    state.setData(block);
    BlockSpreadEvent event = new BlockSpreadEvent(world.getWorldCB().getBlockAt(target.getX(), target.getY(), target.getZ()), world.getWorldCB().getBlockAt(source.getX(), source.getY(), source.getZ()), state);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCancelled()) {
        state.update(true);
    }
    return !event.isCancelled();
}
Also used : CraftBlockState(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState) BlockSpreadEvent(org.bukkit.event.block.BlockSpreadEvent)

Example 23 with CraftBlockState

use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project Magma-1.16.x by magmafoundation.

the class CraftEventFactory method handleBlockFormEvent.

public static boolean handleBlockFormEvent(World world, BlockPos pos, net.minecraft.block.BlockState block, int flag, @Nullable Entity entity) {
    CraftBlockState blockState = CraftBlockState.getBlockState(world, pos, flag);
    blockState.setData(block);
    BlockFormEvent event = (entity == null) ? new BlockFormEvent(blockState.getBlock(), blockState) : new EntityBlockFormEvent(entity.getBukkitEntity(), blockState.getBlock(), blockState);
    world.getServerCB().getPluginManager().callEvent(event);
    if (!event.isCancelled()) {
        blockState.update(true);
    }
    return !event.isCancelled();
}
Also used : CraftBlockState(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState) EntityBlockFormEvent(org.bukkit.event.block.EntityBlockFormEvent) BlockFormEvent(org.bukkit.event.block.BlockFormEvent) EntityBlockFormEvent(org.bukkit.event.block.EntityBlockFormEvent)

Example 24 with CraftBlockState

use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project LoliServer by Loli-Server.

the class BlockStateListPopulator method setBlock.

@Override
public boolean setBlock(BlockPos pos, BlockState newState, int flags) {
    CraftBlockState state = CraftBlockState.getBlockState(world, pos, flags);
    state.setData(newState);
    list.remove(pos);
    list.put(pos.immutable(), state);
    return true;
}
Also used : CraftBlockState(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState)

Example 25 with CraftBlockState

use of org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState in project LoliServer by Loli-Server.

the class CraftEventFactory method handleBlockSpreadEvent.

public static boolean handleBlockSpreadEvent(World world, BlockPos source, BlockPos target, net.minecraft.block.BlockState block, int flag) {
    CraftBlockState state = CraftBlockState.getBlockState(world, target, flag);
    state.setData(block);
    BlockSpreadEvent event = new BlockSpreadEvent(world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()), world.getWorld().getBlockAt(source.getX(), source.getY(), source.getZ()), state);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCancelled()) {
        state.update(true);
    }
    return !event.isCancelled();
}
Also used : CraftBlockState(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState) BlockSpreadEvent(org.bukkit.event.block.BlockSpreadEvent)

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