Java Code Examples for net.minecraft.world.World#removeTileEntity()
The following examples show how to use
net.minecraft.world.World#removeTileEntity() .
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: GTUtility.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
public static boolean tryResetStrongholdPortal(World world, BlockPos pos) { List<BlockPos> portalBlockPos = AabbUtil.getTargets(world, pos, 5, new GTIBlockFilters.EndPortalFilter(), false, false, RotationList.ALL); if (portalBlockPos.isEmpty()) { return false; } BlockPos selectedPos = portalBlockPos.get(world.rand.nextInt(portalBlockPos.size() - 1)); IBlockState nearbyState = world.getBlockState(selectedPos); if (resetEndPortalFrame(world, selectedPos, nearbyState)) { boolean found = false; for (BlockPos portalPos : portalBlockPos) { if (world.getBlockState(portalPos).getBlock() == Blocks.END_PORTAL) { world.setBlockToAir(portalPos); world.removeTileEntity(portalPos); found = true; } } return found; } return false; }
Example 2
Source File: GTUtility.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
public static boolean tryExplodeOtherAbsorbers(World world, BlockPos checkPos) { Iterable<BlockPos> surroundingPos = BlockPos.getAllInBox(checkPos.offset(EnumFacing.SOUTH, 4).offset(EnumFacing.WEST, 4), checkPos.offset(EnumFacing.NORTH, 4).offset(EnumFacing.EAST, 4)); for (BlockPos absorberPos : surroundingPos) { if (absorberPos.equals(checkPos)) { continue; } TileEntity tile = world.getTileEntity(absorberPos); if (tile instanceof GTTileMagicEnergyAbsorber) { GTTileMagicEnergyAbsorber absorber = (GTTileMagicEnergyAbsorber) tile; if (absorber.portalMode && absorber.isAbovePortal) { world.setBlockToAir(absorberPos); world.removeTileEntity(absorberPos); world.createExplosion(null, absorberPos.getX(), absorberPos.getY(), absorberPos.getZ(), 8.0F, true); return true; } } } return false; }
Example 3
Source File: BlockInfestedLeaves.java From ExNihiloAdscensio with MIT License | 6 votes |
@Override public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) { if (!world.isRemote && !player.isCreative()) { TileEntity tile = world.getTileEntity(pos); if (tile != null) { if (tile instanceof TileInfestedLeaves) { TileInfestedLeaves leaves = (TileInfestedLeaves) tile; if (leaves != null && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ICrook) { if (world.rand.nextFloat() < leaves.getProgress() * Config.stringChance) { Util.dropItemInWorld(leaves, player, new ItemStack(Items.STRING, 1, 0), 0.02f); } if (world.rand.nextFloat() < leaves.getProgress() * Config.stringChance / 4.0d) { Util.dropItemInWorld(leaves, player, new ItemStack(Items.STRING, 1, 0), 0.02f); } } } world.removeTileEntity(pos); } } }
Example 4
Source File: TileEntityWoodProxy.java From GardenCollection with MIT License | 6 votes |
public static void syncTileEntityWithData (World world, int x, int y, int z, int metadata) { if (metadata < 16) { world.removeTileEntity(x, y, z); return; } TileEntityWoodProxy te = (TileEntityWoodProxy) world.getTileEntity(x, y, z); if (te == null) { te = new TileEntityWoodProxy(); world.setTileEntity(x, y, z, te); } Block block = getBlockFromComposedMetadata(metadata); int protoMeta = getMetaFromComposedMetadata(metadata); if (block != null) te.setProtoBlock(block, protoMeta); te.markDirty(); }
Example 5
Source File: BlockBarrel.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { if (state.getValue(CREATIVE) || this.retainsContentsWhenBroken(world, pos, state)) { world.updateComparatorOutputLevel(pos, this); world.removeTileEntity(pos); } else { TileEntityBarrel te = getTileEntitySafely(world, pos, TileEntityBarrel.class); if (te != null) { InventoryUtils.dropInventoryContentsInWorld(world, pos, te.getUpgradeInventory()); // Fail-safe for not spawning hundreds of thousands of items in the world, // if there is no structure upgrade installed and a barrel is forcibly broken (in Creative mode for example). ItemStack stack = te.getBaseItemHandler().getStackInSlot(0); if (stack.isEmpty() == false) { EntityUtils.dropItemStacksInWorld(world, pos, stack, Math.min(stack.getCount(), 4096), true); } world.updateComparatorOutputLevel(pos, this); world.removeTileEntity(pos); } } }
Example 6
Source File: BlockStorage.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { if (state.getValue(TYPE).retainsContents()) { world.updateComparatorOutputLevel(pos, this); world.removeTileEntity(pos); } else { super.breakBlock(world, pos, state); } }
Example 7
Source File: BlockPeripheral.java From AgriCraft with MIT License | 5 votes |
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { if (!world.isRemote) { world.removeTileEntity(pos); world.setBlockToAir(pos); } }
Example 8
Source File: BlockPhysicsInfuser.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntityPhysicsInfuser tileEntity = (TileEntityPhysicsInfuser) worldIn.getTileEntity(pos); // If there's a valid TileEntity, try dropping the contents of it's inventory. if (tileEntity != null && !tileEntity.isInvalid()) { IItemHandler handler = tileEntity .getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); // Safety in case the capabilities system breaks. If we can't find the handler then // there isn't anything to drop anyways. if (handler != null) { // Drop all the items for (int slot = 0; slot < handler.getSlots(); slot++) { ItemStack stack = handler.getStackInSlot(slot); InventoryHelper .spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), stack); } } } // Remove the dummy block of this physics infuser, if there is one. BlockPos dummyBlockPos = getDummyStatePos(state, pos); super.breakBlock(worldIn, pos, state); if (worldIn.getBlockState(dummyBlockPos) .getBlock() == ValkyrienSkiesMod.INSTANCE.physicsInfuserDummy) { worldIn.setBlockToAir(dummyBlockPos); } // Finally, delete the tile entity. worldIn.removeTileEntity(pos); }
Example 9
Source File: BlockSprinkler.java From AgriCraft with MIT License | 5 votes |
@Override public void observedNeighborChange(IBlockState state, World world, BlockPos pos, Block changedBlock, BlockPos changedBlockPos) { if (!this.canBlockStay(world, pos)) { this.dropBlockAsItem(world, pos, state, 0); world.removeTileEntity(pos); world.setBlockToAir(pos); } }
Example 10
Source File: Plot.java From MyTown2 with The Unlicense | 5 votes |
public void deleteSignBlocks(SignType signType, World world) { if(world.provider.dimensionId != dim) return; int x1 = getStartX(); int y1 = getStartY(); int z1 = getStartZ(); int x2 = getEndX(); int y2 = getEndY(); int z2 = getEndZ(); int cx1 = x1 >> 4; int cz1 = z1 >> 4; int cx2 = x2 >> 4; int cz2 = z2 >> 4; for(int cx = cx1; cx <= cx2; cx++) for(int cz = cz1; cz <= cz2; cz++) { Chunk chunk = world.getChunkFromChunkCoords(cx, cz); if(!chunk.isChunkLoaded) chunk = world.getChunkProvider().loadChunk(cx, cz); List<int[]> sellSigns = new ArrayList<int[]>(2); for(Object obj: chunk.chunkTileEntityMap.values()) { if(obj instanceof TileEntitySign) { TileEntitySign sign = (TileEntitySign) obj; if( sign.xCoord >= x1 && sign.xCoord <= x2 && sign.yCoord >= y1 && sign.yCoord <= y2 && sign.zCoord >= z1 && sign.zCoord <= z2 && signType.isTileValid(sign) ) sellSigns.add(new int[]{sign.xCoord, sign.yCoord, sign.zCoord}); } } for(int[] sellSign: sellSigns) { world.removeTileEntity(sellSign[0], sellSign[1], sellSign[2]); world.setBlock(sellSign[0], sellSign[1], sellSign[2], Blocks.air); } } }
Example 11
Source File: BlockKnowledgeBook.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public void breakThisBlock(World world, int x, int y, int z) { if(world.isRemote) return; ArrayList<ItemStack> stacks = getDrops(world, x, y, z, 0, 0); for(ItemStack i : stacks) { EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, i); world.spawnEntityInWorld(item); } world.removeTileEntity(x, y, z); world.setBlockToAir(x, y, z); world.markBlockForUpdate(x, y, z); }
Example 12
Source File: BlockContainerPL.java From Production-Line with MIT License | 5 votes |
@Override public void breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) { TileEntity tileentity = world.getTileEntity(pos); if (tileentity != null && tileentity instanceof IInventory) { Inventories.spill(world, pos, (IInventory) tileentity); world.removeTileEntity(pos); } world.destroyBlock(pos, true); }
Example 13
Source File: BlockEMTMachines.java From Electro-Magic-Tools with GNU General Public License v3.0 | 4 votes |
@Override public void breakBlock(World world, int x, int y, int z, Block par5, int par6) { dropItems(world, x, y, z); world.removeTileEntity(x, y, z); super.breakBlock(world, x, y, z, par5, par6); }
Example 14
Source File: BlockDroneRedstoneEmitter.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void breakBlock(World world, int x, int y, int z, Block block, int meta){ super.breakBlock(world, x, y, z, block, meta); world.removeTileEntity(x, y, z); }
Example 15
Source File: BlockEMTSolars.java From Electro-Magic-Tools with GNU General Public License v3.0 | 4 votes |
@Override public void breakBlock(World world, int x, int y, int z, Block par5, int par6) { world.removeTileEntity(x, y, z); super.breakBlock(world, x, y, z, par5, par6); }
Example 16
Source File: BlockCampfire.java From Sakura_mod with MIT License | 4 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) return true; ItemStack stack = playerIn.getHeldItem(hand); TileEntity tile = worldIn.getTileEntity(pos); if (hand == EnumHand.MAIN_HAND) { if (tile instanceof TileEntityCampfire) { TileEntityCampfire tileEntityCampfire = (TileEntityCampfire) tile; if(tileEntityCampfire.getInventory().isItemValid(0,stack)&& tileEntityCampfire.getInventory().getStackInSlot(0).getCount() < 16){ ItemStack campfireStack=new ItemStack(stack.getItem(),1,stack.getMetadata()); stack.shrink(1); tileEntityCampfire.getInventory().insertItem(0,campfireStack,false); return true; } if(stack.getItem()==ItemLoader.POT){ worldIn.setBlockToAir(pos); worldIn.removeTileEntity(pos); worldIn.setBlockState(pos, BlockLoader.CAMPFIRE_POT_IDLE.getDefaultState()); stack.shrink(1); return true; } if (WorldUtil.isItemFuel(stack)) { tileEntityCampfire.setBurningTime(tileEntityCampfire.getBurningTime() + TileEntityFurnace.getItemBurnTime(stack)); setState(true, worldIn, pos); if(stack.getItem().hasContainerItem(stack)) stack = stack.getItem().getContainerItem(stack); else stack.shrink(1); return true; } if (stack.getItem() == Items.FLINT_AND_STEEL) { tileEntityCampfire.setBurningTime(tileEntityCampfire.getBurningTime() + 10000); setState(true, worldIn, pos); stack.damageItem(1, playerIn); return true; } if(stack.isEmpty()){ Block.spawnAsEntity(worldIn, pos, ((TileEntityCampfire) tile).getInventory().getStackInSlot(0)); ((TileEntityCampfire) tile).getInventory().setStackInSlot(0, ItemStack.EMPTY); return true; } } } return true; }
Example 17
Source File: BlockTransportRail.java From Signals with GNU General Public License v3.0 | 4 votes |
/** * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated */ @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state){ super.breakBlock(worldIn, pos, state); worldIn.removeTileEntity(pos); }
Example 18
Source File: BlockEMTSolars2.java From Electro-Magic-Tools with GNU General Public License v3.0 | 4 votes |
@Override public void breakBlock(World world, int x, int y, int z, Block par5, int par6) { world.removeTileEntity(x, y, z); super.breakBlock(world, x, y, z, par5, par6); }
Example 19
Source File: BlockHelm.java From archimedes-ships with MIT License | 4 votes |
@Override public void breakBlock(World world, int x, int y, int z, Block block, int meta) { super.breakBlock(world, x, y, z, block, meta); world.removeTileEntity(x, y, z); }
Example 20
Source File: MapGenRuins.java From bartworks with MIT License | 4 votes |
protected TileEntity reSetGTTileEntity(IGregTechTileEntity bte, World worldObj, int x, int y, int z, int meta) { worldObj.removeTileEntity(x, y, z); this.setBlock(worldObj, x, y, z, Blocks.air, 0); return setGTMachineBlock(worldObj, x, y, z, meta); }