public boolean place(IBlockState state, EnumFacing direction, EnumHand hand) { if (!world.isBlockLoaded(blockPos)) return false; if (spawnProtection) { if (!world.isBlockModifiable(player, blockPos)) return false; } final BlockSnapshot snapshot = BlockSnapshot.getBlockSnapshot(world, blockPos); if (!world.setBlockState(blockPos, state, blockPlaceFlags)) return false; if (ForgeEventFactory.onPlayerBlockPlace(player, snapshot, direction, hand).isCanceled()) { world.restoringBlockSnapshots = true; snapshot.restore(true, false); world.restoringBlockSnapshots = false; return false; } return true; } }
placeEvent = ForgeEventFactory.onPlayerMultiBlockPlace(player, blockSnapshots, side, hand); } else if (blockSnapshots.size() == 1) { placeEvent = ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshots.get(0), side, hand);
public static boolean validBlock(World world, BlockPos voidPos, EntityPlayer player) { IBlockState currentBlock = world.getBlockState(voidPos); TileEntity te = world.getTileEntity(voidPos); if (currentBlock.getMaterial() == Material.AIR) return false; //if (currentBlock.getBlock().getMaterial(currentBlock).isLiquid()) return false; if (currentBlock.equals(ModBlocks.effectBlock.getDefaultState())) return false; if ((te != null) && !(te instanceof ConstructionBlockTileEntity)) return false; if (currentBlock.getBlockHardness(world, voidPos) < 0) return false; ItemStack tool = getGadget(player); if (tool.isEmpty()) return false; if (!player.isAllowEdit()) { return false; } if (!world.isBlockModifiable(player, voidPos)) { return false; } if (!world.isRemote) { BlockSnapshot blockSnapshot = BlockSnapshot.getBlockSnapshot(world, voidPos); if (ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshot, EnumFacing.UP, EnumHand.MAIN_HAND).isCanceled()) { return false; } BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(world, voidPos, currentBlock, player); if (MinecraftForge.EVENT_BUS.post(e)) { return false; } } return true; }
if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(player, blocksnapshot, net.minecraft.util.EnumFacing.UP).isCanceled()) { blocksnapshot.restore(true, false); return new ActionResult<>(EnumActionResult.FAIL, stack);
if (ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshot, EnumFacing.UP, EnumHand.MAIN_HAND).isCanceled()) { return;
if (ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshot, EnumFacing.UP, EnumHand.MAIN_HAND).isCanceled()) { return false;
if (ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshot, EnumFacing.UP, EnumHand.MAIN_HAND).isCanceled()) { return false;
if (world.mayPlace(ModBlocks.cuttingBoard, pos, false, event.getFace(), player)) { IBlockState placedState = ModBlocks.cuttingBoard.getStateForPlacement(world, pos, event.getFace(), 0.5f, 1f, 0.5f, 0, player, event.getHand()); BlockEvent.PlaceEvent placeEvent = ForgeEventFactory.onPlayerBlockPlace(player, new BlockSnapshot(world, pos, placedState), event.getFace(), event.getHand()); if (placeEvent.isCanceled()) { return;