Example usage for net.minecraftforge.event.world BlockEvent.PlaceEvent getWorld

List of usage examples for net.minecraftforge.event.world BlockEvent.PlaceEvent getWorld

Introduction

In this page you can find the example usage for net.minecraftforge.event.world BlockEvent.PlaceEvent getWorld.

Prototype

public IWorld getWorld() 

Source Link

Usage

From source file:com.buuz135.industrial.proxy.event.SkullHandler.java

License:Open Source License

@SubscribeEvent
public void onBlockPlayerPlace(BlockEvent.PlaceEvent event) {
    if (event.getPlayer().isCreative())
        return;/*  w ww .  j  a v  a2  s  . c  o m*/
    if (!BlockRegistry.witherBuilderBlock.isHCWither())
        return;
    if (event.getPlayer() instanceof FakePlayer
            && event.getPlayer().equals(IndustrialForegoing.getFakePlayer(event.getWorld())))
        return;
    if (!(event.getPlacedBlock().getBlock().equals(Blocks.SKULL)
            && Blocks.SKULL.getMetaFromState(event.getState()) == 1))
        return;
    event.setCanceled(true);
}

From source file:com.plutomc.core.common.events.BlockHandler.java

License:Open Source License

@SubscribeEvent
public static void handlePlaceEvent(BlockEvent.PlaceEvent event) {
    World world = event.getWorld();
    BlockPos pos = event.getPos();//from   www . ja v  a2 s. c  om

    if (event.getPlacedBlock().getBlock() == BlockRegistry.CROCOITE) {
        BlockPos downPos = pos.down();
        IBlockState downState = world.getBlockState(downPos);
        if (downState.getBlock() == Blocks.MAGMA) {
            EnumFacing structDirection;
            BlockPos structPos;
            if (world.getBlockState(downPos.north()).getBlock() == Blocks.MAGMA) {
                structDirection = EnumFacing.NORTH;
                structPos = downPos.south(2).up(4);
            } else if (world.getBlockState(downPos.south()).getBlock() == Blocks.MAGMA) {
                structDirection = EnumFacing.SOUTH;
                structPos = downPos.south(3).up(4);
            } else if (world.getBlockState(downPos.east()).getBlock() == Blocks.MAGMA) {
                structDirection = EnumFacing.EAST;
                structPos = downPos.west(2).up(4);
            } else if (world.getBlockState(downPos.west()).getBlock() == Blocks.MAGMA) {
                structDirection = EnumFacing.WEST;
                structPos = downPos.west(3).up(4);
            } else {
                world.destroyBlock(pos, true);
                return;
            }
            BlockPos gatePos = (structDirection.getAxis() == EnumFacing.Axis.X ? structPos.east(2)
                    : structPos.north(2)).down(2);

            if (WorldRegistry.UNDERWORLD_GATE.isComplete(world, structPos, structDirection)) {
                event.setCanceled(true);
                event.getItemInHand().shrink(1);
                BlockUnderworldGate.create(world, gatePos, structDirection.getAxis());
            } else {
                world.destroyBlock(pos, true);
            }
        }
    }
}

From source file:hellfirepvp.astralsorcery.common.event.listener.EventHandlerServer.java

License:Open Source License

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlace(BlockEvent.PlaceEvent event) {
    if (event.getWorld().isRemote)
        return;/*from  ww  w. java  2s .c om*/
    BlockPos at = event.getPos();

    if (event.getPlacedBlock().getBlock().equals(Blocks.CRAFTING_TABLE)) {
        WorldNetworkHandler.getNetworkHandler(event.getWorld()).informTablePlacement(at);
    }
}

From source file:vazkii.quark.tweaks.feature.SpongeDriesInNether.java

License:Creative Commons License

@SubscribeEvent
public void onItemPlaced(BlockEvent.PlaceEvent event) {
    if (event.getPlacedBlock().equals(Blocks.SPONGE.getDefaultState().withProperty(BlockSponge.WET, true))
            && BiomeDictionary.getTypes(event.getWorld().getBiome(event.getPos()))
                    .contains(BiomeDictionary.Type.NETHER)) {
        World world = event.getWorld();//from w w  w  .  j a  va 2  s  .c  om
        world.playSound(null, event.getPos(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 1.0F,
                2.4F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.9F);
        world.setBlockState(event.getPos(),
                Blocks.SPONGE.getDefaultState().withProperty(BlockSponge.WET, false));
    }
}