Search in sources :

Example 1 with BlastEventBlockEdit

use of com.builtbroken.mc.api.event.blast.BlastEventBlockEdit in project Engine by VoltzEngine-Project.

the class Blast method prePlace.

/**
 * Called before block placement to check that
 * the placement is not canceled by an event
 *
 * @param vec - edit data, null and has changed checked
 * @return true if should continue
 */
protected boolean prePlace(final IWorldEdit vec) {
    BlastEventBlockEdit event;
    if (vec.getNewBlock() == Blocks.air) {
        event = new BlastEventBlockRemoved.Pre(this, world, vec.getBlock(), vec.getBlockMetadata(), (int) vec.x(), (int) vec.y(), (int) vec.z());
    } else {
        event = new BlastEventBlockReplaced.Pre(this, world, vec.getBlock(), vec.getBlockMetadata(), vec.getNewBlock(), vec.getNewMeta(), (int) vec.x(), (int) vec.y(), (int) vec.z());
    }
    boolean result = MinecraftForge.EVENT_BUS.post(event);
    if (vec instanceof BlockEdit && event instanceof BlastEventBlockReplaced.Pre) {
        ((BlockEdit) vec).set(((BlastEventBlockReplaced.Pre) event).newBlock, ((BlastEventBlockReplaced.Pre) event).newMeta);
    }
    return !result;
}
Also used : BlastEventBlockReplaced(com.builtbroken.mc.api.event.blast.BlastEventBlockReplaced) BlastEventBlockEdit(com.builtbroken.mc.api.event.blast.BlastEventBlockEdit) BlockEdit(com.builtbroken.mc.lib.world.edit.BlockEdit) BlastEventBlockEdit(com.builtbroken.mc.api.event.blast.BlastEventBlockEdit) BlastEventBlockRemoved(com.builtbroken.mc.api.event.blast.BlastEventBlockRemoved)

Example 2 with BlastEventBlockEdit

use of com.builtbroken.mc.api.event.blast.BlastEventBlockEdit in project Engine by VoltzEngine-Project.

the class BlastBasic method prePlace.

@Override
protected boolean prePlace(final IWorldEdit vec) {
    BlastEventBlockEdit event = new BlastEventDestroyBlock.Pre(this, BlastEventDestroyBlock.DestructionType.FORCE, world, vec.getBlock(), vec.getBlockMetadata(), (int) vec.x(), (int) vec.y(), (int) vec.z());
    boolean result = MinecraftForge.EVENT_BUS.post(event);
    if (vec instanceof BlockEdit && event instanceof BlastEventBlockReplaced.Pre) {
        ((BlockEdit) vec).set(((BlastEventBlockReplaced.Pre) event).newBlock, ((BlastEventBlockReplaced.Pre) event).newMeta);
    }
    return !result;
}
Also used : BlastEventBlockReplaced(com.builtbroken.mc.api.event.blast.BlastEventBlockReplaced) BlastEventBlockEdit(com.builtbroken.mc.api.event.blast.BlastEventBlockEdit) BlockEdit(com.builtbroken.mc.lib.world.edit.BlockEdit) BlastEventBlockEdit(com.builtbroken.mc.api.event.blast.BlastEventBlockEdit)

Aggregations

BlastEventBlockEdit (com.builtbroken.mc.api.event.blast.BlastEventBlockEdit)2 BlastEventBlockReplaced (com.builtbroken.mc.api.event.blast.BlastEventBlockReplaced)2 BlockEdit (com.builtbroken.mc.lib.world.edit.BlockEdit)2 BlastEventBlockRemoved (com.builtbroken.mc.api.event.blast.BlastEventBlockRemoved)1