@Override public void simulateBlockMine(BlockVector3 position) { BlockPos pos = ForgeAdapter.toBlockPos(position); IBlockState state = getWorld().getBlockState(pos); state.getBlock().dropBlockAsItem(getWorld(), pos, state, 0); getWorld().setBlockToAir(pos); }
((IHornHarvestable) block).harvestByHorn(world, currCoords, stack, type); else { block.dropBlockAsItem(world, currCoords, state, 0); world.setBlockToAir(currCoords); if(ConfigHandler.blockBreakParticles)
public default void dropPartAsItem(IPartInfo part, int fortune) { part.getState().getBlock().dropBlockAsItem(part.getActualWorld(), part.getPartPos(), part.getState(), fortune); } }
IBlockState theState = world.getBlockState(theCoord); theState.getBlock().dropBlockAsItem(world, theCoord, theState, 0);
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { world.setBlockToAir(pos); for (int i = 1; i < 3; i++) { BlockPos offset = pos.offset(EnumFacing.DOWN, i); IBlockState offsetState = world.getBlockState(offset); Block block = world.getBlockState(offset).getBlock(); if (block == Calculator.scarecrow) { block.dropBlockAsItem(world, offset, offsetState, 0); world.setBlockToAir(offset); } } }
private boolean placeProxyIfNotPresent(EntityGate gate, BlockPos pos, boolean openDefault) { IBlockState state = gate.world.getBlockState(pos); Block block = state.getBlock(); if (block != AWStructureBlocks.GATE_PROXY) { if (!gate.world.isAirBlock(pos)) { block.dropBlockAsItem(gate.world, pos, state, 0); } gate.world.setBlockState(pos, AWStructureBlocks.GATE_PROXY.getDefaultState()); WorldTools.getTile(gate.world, pos, TEGateProxy.class).ifPresent(t -> { t.setOwner(gate); t.setOpen(openDefault); }); return true; } return false; }
world.playEvent(2001, pos, Block.getStateId(state)); } else { state.getBlock().dropBlockAsItem(world, pos, state, 0);
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (!player.canPlayerEdit(pos, side, stack)) { return EnumActionResult.PASS; } Block block = world.getBlockState(pos).getBlock(); if (block == Blocks.OBSIDIAN || block instanceof IObsidianDrop && ((IObsidianDrop) block).canKeyDrop(world, pos)) { block.dropBlockAsItem(world, pos, world.getBlockState(pos), 0); world.setBlockToAir(pos); stack.damageItem(1, player); } return EnumActionResult.SUCCESS; } }
private void tryFlowInto(World worldIn, BlockPos pos, IBlockState state, int level) { if (this.canFlowInto(state)) { if (state.getMaterial() != net.minecraft.block.material.Material.AIR) { if (state.getBlock() != Blocks.SNOW_LAYER) { state.getBlock().dropBlockAsItem(worldIn, pos, state, 0); } } worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState().withProperty(LEVEL, level), 3); } }
public static boolean breakBlock(World world, BlockPos pos, int fortune, boolean doDrop) { if (world.isRemote) { return false; } IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if (world.isAirBlock(pos) || state.getBlockHardness(world, pos) < 0) { return false; } if (doDrop) { if (!canBreakBlock(world, pos, state)) { return false; } block.dropBlockAsItem(world, pos, state, fortune); } return world.setBlockToAir(pos); }
protected void interactWithBlock(World world, BlockPos pos) { IBlockState state = world.getBlockState(pos); if (state.getBlock().isAir(state, world, pos) || state.getBlock() == this) { return; } if (extreme && state.getMaterial() == Material.ROCK && state.getBlock().getBlockHardness(state, world, pos) > 0) { state.getBlock().dropBlockAsItem(world, pos, state, 0); world.setBlockToAir(pos); triggerInteractionEffects(world, pos); } else if (hasInteraction(state)) { world.setBlockState(pos, getInteraction(state), 3); } }
TileEntity i = world.getTileEntity(pos.add(X, -1, Z)); Block bi = world.getBlockState(pos.add(X, -1, Z)).getBlock(); bi.dropBlockAsItem(world, pos.add(X, -1, Z), state, 0); world.setBlockToAir(pos.add(X, -1, Z)); Block block = transmitter.getBlock(); if (block == Calculator.transmitter) { block.dropBlockAsItem(world, offset, state, 0); world.setBlockToAir(offset);
world.setBlockState(pos, state, flags); world.setTileEntity(pos, tile); block.dropBlockAsItem(world, pos, state, 0); world.setBlockToAir(pos); destroyed = true;
@SubscribeEvent public void handleCropRightClick(RightClickBlock event) { if (!ConfigHandler.allowCropRC) { return; } if (event.getEntityPlayer().getHeldItemMainhand().isEmpty() || !event.getEntityPlayer().isSneaking()) { BlockPos pos = event.getPos(); IBlockState blockState = event.getWorld().getBlockState(pos); for (IPlantInfo info : plants) { if (info.getGrownState() == blockState) { if (event.getWorld().isRemote) { event.getEntityPlayer().swingArm(EnumHand.MAIN_HAND); } else { currentPlant = info; blockState.getBlock().dropBlockAsItem(NullHelper.notnullF(event.getWorld(), "RightClickBlock.getWorld()"), pos, blockState, 0); currentPlant = null; IBlockState newBS = info.getResetState(); event.getWorld().setBlockState(pos, newBS, 3); event.setCanceled(true); } break; } } } }
if (state.getBlock() != null && state.getBlockHardness(player.getEntityWorld(), pos) <= 10F) { Utils.breakBlockWithParticles(player.getEntityWorld(), pos); state.getBlock().dropBlockAsItem(player.getEntityWorld(), pos, state, 0);