Java Code Examples for net.minecraft.world.IBlockAccess#getTileEntity()
The following examples show how to use
net.minecraft.world.IBlockAccess#getTileEntity() .
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: BlockPressureTube.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
/** * Returns true if the block is emitting indirect/weak redstone power on the * specified side. If isBlockNormalCube returns true, standard redstone * propagation rules will apply instead and this will not be called. Args: * World, X, Y, Z, side. Note that the side is reversed - eg it is 1 (up) * when checking the bottom of the block. */ @Override public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int side){ TileEntity te = par1IBlockAccess.getTileEntity(par2, par3, par4); if(te instanceof TileEntityPressureTube) { TileEntityPressureTube tePt = (TileEntityPressureTube)te; int redstoneLevel = 0; for(int i = 0; i < 6; i++) { if(tePt.modules[i] != null) { if((side ^ 1) == i || i != side && tePt.modules[i].isInline()) {//if we are on the same side, or when we have an 'in line' module that is not on the opposite side. redstoneLevel = Math.max(redstoneLevel, tePt.modules[i].getRedstoneLevel()); } } } return redstoneLevel; } return 0; }
Example 2
Source File: BlockFluidPipe.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public int getActiveNodeConnections(IBlockAccess world, BlockPos nodePos, IPipeTile<FluidPipeType, FluidPipeProperties> selfTileEntity) { int activeNodeConnections = 0; for (EnumFacing side : EnumFacing.VALUES) { BlockPos offsetPos = nodePos.offset(side); TileEntity tileEntity = world.getTileEntity(offsetPos); if(tileEntity != null) { EnumFacing opposite = side.getOpposite(); IFluidHandler sourceHandler = selfTileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); IFluidHandler receivedHandler = tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opposite); if (sourceHandler != null && receivedHandler != null && canPushIntoFluidHandler(selfTileEntity, tileEntity, sourceHandler, receivedHandler)) { activeNodeConnections |= 1 << side.getIndex(); } } } return activeNodeConnections; }
Example 3
Source File: BlockPresent.java From Chisel-2 with GNU General Public License v2.0 | 6 votes |
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z); if (!te.isConnected()) { setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F); } else { ForgeDirection dir = te.getConnectionDir(); switch (dir) { case EAST: setBlockBounds(0.0625F, 0, 0.0625F, 1, 0.875F, 0.9365F); break; case NORTH: setBlockBounds(0.0625F, 0, 0, 0.9375F, 0.875F, 0.9365F); break; case SOUTH: setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 1); break; case WEST: setBlockBounds(0, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F); break; default: setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F); break; } } }
Example 4
Source File: BlockReactorPart.java From BigReactors with MIT License | 6 votes |
private IIcon getCoolantPortIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { TileEntity te = blockAccess.getTileEntity(x, y, z); if(te instanceof TileEntityReactorCoolantPort) { TileEntityReactorCoolantPort port = (TileEntityReactorCoolantPort)te; if(!isReactorAssembled(port) || isOutwardsSide(port, side)) { if(port.isInlet()) { return _icons[METADATA_COOLANTPORT][PORT_INLET]; } else { return _icons[METADATA_COOLANTPORT][PORT_OUTLET]; } } } return blockIcon; }
Example 5
Source File: BlockElevatorCaller.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
/** * Returns true if the block is emitting indirect/weak redstone power on the * specified side. If isBlockNormalCube returns true, standard redstone * propagation rules will apply instead and this will not be called. Args: * World, X, Y, Z, side. Note that the side is reversed - eg it is 1 (up) * when checking the bottom of the block. */ @Override public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5){ TileEntity te = par1IBlockAccess.getTileEntity(par2, par3, par4); if(te instanceof TileEntityElevatorCaller) { TileEntityElevatorCaller teEc = (TileEntityElevatorCaller)te; return teEc.getEmittingRedstone() ? 15 : 0; } return 0; }
Example 6
Source File: BlockThinLog.java From GardenCollection with MIT License | 5 votes |
private TileEntityWoodProxy getTileEntity (IBlockAccess blockAccess, int x, int y, int z) { TileEntity te = blockAccess.getTileEntity(x, y, z); if (te != null && te instanceof TileEntityWoodProxy) return (TileEntityWoodProxy) te; return null; }
Example 7
Source File: GTBlockLamp.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); if (tile instanceof GTTileLamp) { return ((GTTileLamp) tile).redstoneLevel; } else { return 0; } }
Example 8
Source File: BlockStickyJar.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileStickyJar) { TileStickyJar stickyJar = (TileStickyJar) tile; if(stickyJar.isValid()) { return stickyJar.getParentBlock().getIcon(world, x, y, z, side); } } return iconTransparent; }
Example 9
Source File: GTBlockSuperconductorCable.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); if (!(tile instanceof GTTileBaseSuperconductorCable)) { return new AxisAlignedBB(0.25D, 0.25D, 0.25D, 0.75D, 0.75D, 0.75D); } else { GTTileBaseSuperconductorCable cable = (GTTileBaseSuperconductorCable) tile; double thickness = this.size / 32.0D; double minX = 0.5D - thickness; double minY = 0.5D - thickness; double minZ = 0.5D - thickness; double maxX = 0.5D + thickness; double maxY = 0.5D + thickness; double maxZ = 0.5D + thickness; if (cable.connection.contains(EnumFacing.WEST)) { minX = 0.0D; } if (cable.connection.contains(EnumFacing.DOWN)) { minY = 0.0D; } if (cable.connection.contains(EnumFacing.NORTH)) { minZ = 0.0D; } if (cable.connection.contains(EnumFacing.EAST)) { maxX = 1.0D; } if (cable.connection.contains(EnumFacing.UP)) { maxY = 1.0D; } if (cable.connection.contains(EnumFacing.SOUTH)) { maxZ = 1.0D; } return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ); } }
Example 10
Source File: BlockARHatch.java From AdvancedRocketry with MIT License | 5 votes |
@Override public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { if(blockAccess.getTileEntity(pos) instanceof TilePointer && !((TilePointer)blockAccess.getTileEntity(pos)).allowRedstoneOutputOnSide(side)) return 0; return blockState.getValue(VARIANT) >= 2 ? 15 : 0; }
Example 11
Source File: GTBlockStorage.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { List<ItemStack> items = new ArrayList<>(); TileEntity te = this.getLocalTile() == null ? world.getTileEntity(pos) : this.getLocalTile(); if (te instanceof IGTItemContainerTile) { items.addAll(((IGTItemContainerTile) te).getInventoryDrops()); return items; } return items; }
Example 12
Source File: BlockSignalBase.java From Signals with GNU General Public License v3.0 | 5 votes |
@Override public int getWeakPower(IBlockState state, IBlockAccess worldIn, BlockPos pos, EnumFacing side){ EnumLampStatus lampStatus = state.getValue(LAMP_STATUS); if(!(worldIn instanceof WorldServer) || state.getBlock() != this || lampStatus != EnumLampStatus.GREEN || state.getValue(BlockSignalBase.FACING).rotateY() != side) return 0; TileEntitySignalBase signal = (TileEntitySignalBase)worldIn.getTileEntity(pos); signal.setWorld((WorldServer)worldIn); return 15; }
Example 13
Source File: GTBlockBaseMachine.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override @Deprecated public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { TileEntity tile = blockAccess.getTileEntity(pos); if (tile instanceof TileEntityElectricBlock) { return ((TileEntityElectricBlock) tile).isEmittingRedstone() ? 15 : 0; } else { return super.getCommonPower(blockState, blockAccess, pos, side); } }
Example 14
Source File: MetaBlockPacket.java From bartworks with MIT License | 5 votes |
@Override public void process(IBlockAccess iBlockAccess) { if (iBlockAccess != null) { TileEntity tTileEntity = iBlockAccess.getTileEntity(this.x, this.y, this.z); if ((tTileEntity instanceof BW_MetaGenerated_Block_TE)) { ((BW_MetaGenerated_Block_TE) tTileEntity).mMetaData = this.meta; } if (((iBlockAccess instanceof World)) && (((World) iBlockAccess).isRemote)) { ((World) iBlockAccess).markBlockForUpdate(this.x, this.y, this.z); } } }
Example 15
Source File: ThaumcraftApiHelper.java From GardenCollection with MIT License | 5 votes |
public static TileEntity getConnectableTile(IBlockAccess world, int x, int y, int z, ForgeDirection face) { TileEntity te = world.getTileEntity(x+face.offsetX, y+face.offsetY, z+face.offsetZ); if (te instanceof IEssentiaTransport && ((IEssentiaTransport)te).isConnectable(face.getOpposite())) return te; else return null; }
Example 16
Source File: BlockLargePot.java From GardenCollection with MIT License | 4 votes |
@Override public TileEntityLargePot getTileEntity (IBlockAccess world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); return (te != null && te instanceof TileEntityLargePot) ? (TileEntityLargePot) te : null; }
Example 17
Source File: BlockPipe.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
/** * Just returns proper pipe tile entity */ public IPipeTile<PipeType, NodeDataType> getPipeTileEntity(IBlockAccess world, BlockPos selfPos) { TileEntity tileEntityAtPos = world.getTileEntity(selfPos); return getPipeTileEntity(tileEntityAtPos); }
Example 18
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
public static MetaTileEntity getMetaTileEntity(IBlockAccess blockAccess, BlockPos pos) { TileEntity holder = blockAccess.getTileEntity(pos); return holder instanceof MetaTileEntityHolder ? ((MetaTileEntityHolder) holder).getMetaTileEntity() : null; }
Example 19
Source File: BlockDecorativePot.java From GardenCollection with MIT License | 4 votes |
@Override public TileEntityDecorativePot getTileEntity (IBlockAccess world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); return (te != null && te instanceof TileEntityDecorativePot) ? (TileEntityDecorativePot) te : null; }
Example 20
Source File: BlockPneumaticCraft.java From PneumaticCraft with GNU General Public License v3.0 | 3 votes |
/** * Called when a tile entity on a side of this block changes is created or is destroyed. * @param world The world * @param x The x position of this block instance * @param y The y position of this block instance * @param z The z position of this block instance * @param tileX The x position of the tile that changed * @param tileY The y position of the tile that changed * @param tileZ The z position of the tile that changed */ @Override public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ){ if(world instanceof World && !((World)world).isRemote) { TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntityBase) { ((TileEntityBase)te).onNeighborTileUpdate(); } } }