Java Code Examples for net.minecraft.world.World#setBlockToAir()
The following examples show how to use
net.minecraft.world.World#setBlockToAir() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockEngineeringTable.java From Cyberware with MIT License | 6 votes |
@Override public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) { BlockPos blockpos = pos.down(); BlockPos blockpos1 = pos.up(); if (player.capabilities.isCreativeMode && state.getValue(HALF) == EnumEngineeringHalf.UPPER && worldIn.getBlockState(blockpos).getBlock() == this) { worldIn.setBlockToAir(blockpos); } if (state.getValue(HALF) == EnumEngineeringHalf.LOWER && worldIn.getBlockState(blockpos1).getBlock() == this) { if (player.capabilities.isCreativeMode) { worldIn.setBlockToAir(pos); } worldIn.setBlockToAir(blockpos1); } }
Example 2
Source File: BlockSurgeryChamber.java From Cyberware with MIT License | 6 votes |
@Override public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) { BlockPos blockpos = pos.down(); BlockPos blockpos1 = pos.up(); if (player.capabilities.isCreativeMode && state.getValue(HALF) == EnumChamberHalf.UPPER && worldIn.getBlockState(blockpos).getBlock() == this) { worldIn.setBlockToAir(blockpos); } if (state.getValue(HALF) == EnumChamberHalf.LOWER && worldIn.getBlockState(blockpos1).getBlock() == this) { if (player.capabilities.isCreativeMode) { worldIn.setBlockToAir(pos); } worldIn.setBlockToAir(blockpos1); } }
Example 3
Source File: BlockLaserBeam.java From Artifacts with MIT License | 5 votes |
private void func_72149_e(World par1World, int par2, int par3, int par4, int par5) { int i1 = 0; boolean foundSource = false; boolean[] flag = new boolean[4]; while (i1 < 4) { int j1 = 1; while (true) { if (j1 < 16) { int k1 = par2 + Direction.offsetX[i1] * j1; int l1 = par4 + Direction.offsetZ[i1] * j1; Block i2 = par1World.getBlock(k1, par3, l1); if (i2 == BlockLaserBeamSource.instance.instance) { BlockLaserBeamSource.instance.updateLaserState(par1World, k1, par3, l1, i2, par1World.getBlockMetadata(k1, par3, l1), true, j1, par5); foundSource = true; flag[i1] = true; } else if (i2 == this.instance || !par1World.getBlock(k1, par3, l1).isOpaqueCube()) { ++j1; continue; } } ++i1; break; } } if(!foundSource) { par1World.setBlockToAir(par2, par3, par4); } }
Example 4
Source File: AutumnalLSCompound.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (!TerrainGen.saplingGrowTree(worldIn, rand, pos)) return; worldIn.setBlockToAir(pos); if (!new TraverseTreeGenerator(true, 4, TraverseTreeGenerator.OAK_LOG, lsLeaves.getDefaultState()).generate(worldIn, rand, pos)) { worldIn.setBlockState(pos, state); } }
Example 5
Source File: BlockTraverseSapling.java From Traverse-Legacy-1-12-2 with MIT License | 5 votes |
@Override public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (!TerrainGen.saplingGrowTree(worldIn, rand, pos)) return; if (generator.generate(worldIn, rand, pos)) { worldIn.setBlockToAir(pos); } }
Example 6
Source File: BlockFuton.java From Sakura_mod with MIT License | 5 votes |
@Override public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) { if (player.capabilities.isCreativeMode && state.getValue(PART) == EnumPartType.HEAD) { BlockPos blockpos = pos.offset(state.getValue(FACING).getOpposite()); if (worldIn.getBlockState(blockpos).getBlock() == this) { worldIn.setBlockToAir(blockpos); } } }
Example 7
Source File: WandHandler.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
private static void replaceJar(World world, int x, int y, int z, boolean isThaumcraft) { int[][][] blueprint = {{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 3, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}}; for (int yy = 0; yy < 4; yy++) { for (int xx = 0; xx < 3; xx++) { for (int zz = 0; zz < 3; zz++) { if (blueprint[yy][xx][zz] == 3) { handleJarForming(world, x, y, z, xx, yy, zz, isThaumcraft); } else { world.setBlockToAir(x + xx, y - yy + 2, z + zz); } } } } if(isThaumcraft) world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "thaumcraft:wand", 1.0F, 1.0F); }
Example 8
Source File: ClassroomDecoratorImplementation.java From malmo with MIT License | 5 votes |
private void drawJump(World world, Palette palette) { int entrance = rand.nextInt(this.back - this.front - 3); int exit = rand.nextInt(this.back - this.front - 3); for(int z=this.front; z<this.back; z++){ setBlockState(world, new BlockPos(this.x - 1, this.bottom - 1, z), palette.moatContainer); setBlockState(world, new BlockPos(this.x - 1, this.bottom, z), palette.wall); setBlockState(world, new BlockPos(this.x - 1, this.bottom + 1, z), palette.wall); setBlockState(world, new BlockPos(this.x, this.bottom - 2, z), palette.moatContainer); setBlockState(world, new BlockPos(this.x + 1, this.bottom - 1, z), palette.moatContainer); setBlockState(world, new BlockPos(this.x + 1, this.bottom, z), palette.wall); setBlockState(world, new BlockPos(this.x + 1, this.bottom + 1, z), palette.wall); if(z % 2 == 0){ setBlockState(world, new BlockPos(this.x, this.bottom - 1, z), palette.moatContainer); }else{ setBlockState(world, new BlockPos(this.x, this.bottom - 1, z), palette.moat); } } setBlockState(world, new BlockPos(this.x, this.bottom + ROOM_HEIGHT - 1, this.front), palette.light, null, Facing.SOUTH, null); setBlockState(world, new BlockPos(this.x, this.bottom + ROOM_HEIGHT - 1, this.back - 1), palette.light, null, Facing.NORTH, null); for(int i=0; i<3; i++){ world.setBlockToAir(new BlockPos(this.x - 1, this.bottom + 1, this.front + entrance + i)); world.setBlockToAir(new BlockPos(this.x + 1, this.bottom + 1, this.front + exit + i)); } if(this.hint){ setBlockState(world, new BlockPos(this.x - 1, this.bottom, this.front + entrance + 1), palette.hint); setBlockState(world, new BlockPos(this.x + 1, this.bottom, this.front + exit + 1), palette.hint); } }
Example 9
Source File: BlockCampfire.java From Sakura_mod with MIT License | 5 votes |
@Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { if (!this.canBlockStay(worldIn, pos)) { this.dropBlockAsItem(worldIn, pos, state, 0); worldIn.setBlockToAir(pos); } }
Example 10
Source File: BlockComponentBox.java From Cyberware with MIT License | 5 votes |
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityComponentBox) { /*if (player.isCreative() && player.isSneaking()) { TileEntityScanner scanner = ((TileEntityScanner) tileentity); scanner.ticks = CyberwareConfig.SCANNER_TIME - 200; }*/ if (player.isSneaking()) { TileEntityComponentBox box = (TileEntityComponentBox) tileentity; ItemStack toDrop = this.getStack(box); if (player.inventory.mainInventory[player.inventory.currentItem] == null) { player.inventory.mainInventory[player.inventory.currentItem] = toDrop; } else { if (!player.inventory.addItemStackToInventory(toDrop)) { InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), toDrop); } } box.doDrop = false; worldIn.setBlockToAir(pos); } else { player.openGui(Cyberware.INSTANCE, 5, worldIn, pos.getX(), pos.getY(), pos.getZ()); } } return true; }
Example 11
Source File: CrowbarBehaviour.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private boolean tryBreakRailBlock(IBlockState blockState, World world, BlockPos blockPos, EntityPlayer player) { if (world.canMineBlockBody(player, blockPos) && blockState.getBlock().canHarvestBlock(world, blockPos, player)) { for (ItemStack drops : blockState.getBlock().getDrops(world, blockPos, blockState, 0)) { Block.spawnAsEntity(world, blockPos, drops); } blockState.getBlock().onBlockDestroyedByPlayer(world, blockPos, blockState); blockState.getBlock().onBlockHarvested(world, blockPos, blockState, player); blockState.getBlock().breakBlock(world, blockPos, blockState); world.setBlockToAir(blockPos); return true; } return false; }
Example 12
Source File: BlockPneumaticCraft.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection side){ if(player.isSneaking()) { if(!player.capabilities.isCreativeMode) dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); world.setBlockToAir(x, y, z); return true; } else { if(isRotatable()) { int meta = world.getBlockMetadata(x, y, z); if(!rotateCustom(world, x, y, z, side, meta)) { int newMeta; if(rotateForgeWay()) { if(!canRotateToTopOrBottom()) side = ForgeDirection.UP; newMeta = ForgeDirection.getOrientation(meta).getRotation(side).ordinal(); world.setBlockMetadataWithNotify(x, y, z, newMeta, 3); } else { newMeta = (meta + 1) % 6; if(!canRotateToTopOrBottom()) { if(newMeta == 0) { newMeta = 2; } } } world.setBlockMetadataWithNotify(x, y, z, newMeta, 3); } TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntityBase) { ((TileEntityBase)te).onBlockRotated(); } return true; } else { return false; } } }
Example 13
Source File: BlockLaserBeamSource.java From Artifacts with MIT License | 5 votes |
@Override public boolean canBlockStay(World par1World, int par2, int par3, int par4) { if (!this.canPlaceBlockAt(par1World, par2, par3, par4)) { this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockToAir(par2, par3, par4); return false; } else { return true; } }
Example 14
Source File: Ladder.java From EmergingTechnology with MIT License | 5 votes |
@Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); if (!this.canAttachTo(worldIn, pos.offset(enumfacing.getOpposite()), enumfacing)) { this.dropBlockAsItem(worldIn, pos, state, 0); worldIn.setBlockToAir(pos); } super.neighborChanged(state, worldIn, pos, blockIn, fromPos); }
Example 15
Source File: BlockPortalBase.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
/** * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated * when broken, break the two adjacent portal blocks */ @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { super.breakBlock(worldIn, pos, state); if (worldIn.getBlockState(pos.up()).getBlock() == SubmodIntradimensionalPortals.intradimensional_portal_glowy_air) { worldIn.setBlockToAir(pos.up()); } if (worldIn.getBlockState(pos.down()).getBlock() == SubmodIntradimensionalPortals.intradimensional_portal_glowy_air) { worldIn.setBlockToAir(pos.down()); } }
Example 16
Source File: int3.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
public boolean removeBlock(World world) { return world.setBlockToAir(pos.toImmutable()); }
Example 17
Source File: BlockLaserBeamSource.java From Artifacts with MIT License | 4 votes |
@Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { int i1 = world.getBlockMetadata(x, y, z); if (block != this.instance) { if (this.canBlockStay(world, x, y, z)) { int j1 = i1 & 3; boolean flag = false; if (!world.getBlock(x - 1, y, z).isSideSolid(world, x - 1, y, z, EAST) && j1 == 3) { flag = true; } if (!world.getBlock(x + 1, y, z).isSideSolid(world, x + 1, y, z, WEST) && j1 == 1) { flag = true; } if (!world.getBlock(x, y, z - 1).isSideSolid(world, x, y, z - 1, SOUTH) && j1 == 0) { flag = true; } if (!world.getBlock(x, y, z + 1).isSideSolid(world, x, y, z + 1, NORTH) && j1 == 2) { flag = true; } if (flag) { this.dropBlockAsItem(world, x, y, z, i1, 0); world.setBlockToAir(x, y, z); } } } rebuildLaser(world, x, y, z, i1); }
Example 18
Source File: BlockLight.java From Artifacts with MIT License | 4 votes |
@Override public void updateTick(World world, int x, int y, int z, Random rand) { world.setBlockToAir(x, y, z); }
Example 19
Source File: BlockLogNatural2.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { if(world.isRemote) return true; //get our item parameters ItemStack stack = player.getHeldItemMainhand(); int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack); int maxCut = 0; if(stack.getItem() instanceof ItemAxe) { maxCut = ((ItemAxe)stack.getItem()).maxTreeSize; } else return false; //create the map of our tree BlockPosList tree = BlockLogNatural.getTreeForCut(world, pos); int count = tree.size(); //if the tree has too many blocks then prevent chopping if(count > maxCut) { player.sendMessage(new TextComponentTranslation(Core.translate("gui.axe.treetoobig"))); return false; } else if(count > stack.getMaxDamage() - stack.getItemDamage()) { player.sendMessage(new TextComponentTranslation(Core.translate("gui.axe.needsrepair"))); return false; } else { for(BlockPos p : tree) { IBlockState s = world.getBlockState(p); this.onBlockHarvested(world, pos, s, player); world.setBlockToAir(p); s.getBlock().dropBlockAsItem(world, p, s, fortune); } } stack.damageItem(count-1, player); return true; }
Example 20
Source File: ItemArmourStand.java From Et-Futurum with The Unlicense | 4 votes |
@Override @SuppressWarnings("unchecked") public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (side == 0) return false; else { if (side == 1) y++; if (side == 2) z--; if (side == 3) z++; if (side == 4) x--; if (side == 5) x++; if (!player.canPlayerEdit(x, y, z, side, stack)) return false; else { boolean flag1 = !world.isAirBlock(x, y, z) && !world.getBlock(x, y, z).isReplaceable(world, x, y, z); flag1 |= !world.isAirBlock(x, y + 1, z) && !world.getBlock(x, y + 1, z).isReplaceable(world, x, y + 1, z); if (flag1) return false; else { double d0 = x; double d1 = y; double d2 = z; List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(null, AxisAlignedBB.getBoundingBox(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D)); if (list.size() > 0) return false; else { if (!world.isRemote) { world.setBlockToAir(x, y, z); world.setBlockToAir(x, y + 1, z); EntityArmourStand stand = new EntityArmourStand(world, d0 + 0.5D, d1, d2 + 0.5D); float f3 = MathHelper.floor_float((MathHelper.wrapAngleTo180_float(player.rotationYaw - 180.0F) + 22.5F) / 45.0F) * 45.0F; stand.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, f3, 0.0F); applyRandomRotations(stand, world.rand); NBTTagCompound nbt = stack.getTagCompound(); if (nbt != null && nbt.hasKey("EntityTag", 10)) { NBTTagCompound nbt1 = new NBTTagCompound(); stand.writeToNBTOptional(nbt1); merge(nbt1, nbt.getCompoundTag("EntityTag")); stand.readFromNBT(nbt1); } world.spawnEntityInWorld(stand); } stack.stackSize--; return true; } } } } }