List of usage examples for net.minecraftforge.event.world BlockEvent.PlaceEvent getPos
public BlockPos getPos()
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();//from ww w.java 2 s . c o m BlockPos pos = event.getPos(); 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 w w w. ja v a 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();// w w w . j a v a 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)); } }