Java Code Examples for net.minecraft.block.Block#hasTileEntity()
The following examples show how to use
net.minecraft.block.Block#hasTileEntity() .
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: MobileChunk.java From archimedes-ships with MIT License | 6 votes |
/** * Gets the TileEntity for a given block in this chunk */ @Override public TileEntity getTileEntity(int x, int y, int z) { ChunkPosition chunkposition = new ChunkPosition(x, y, z); TileEntity tileentity = chunkTileEntityMap.get(chunkposition); if (tileentity == null) { Block block = getBlock(x, y, z); int meta = getBlockMetadata(x, y, z); if (block == null || !block.hasTileEntity(meta)) { return null; } tileentity = block.createTileEntity(worldObj, meta); setTileEntity(x, y, z, tileentity); tileentity = chunkTileEntityMap.get(chunkposition); } return tileentity; }
Example 2
Source File: MobileChunk.java From archimedes-ships with MIT License | 6 votes |
/** * Sets the TileEntity for a given block in this chunk */ private void setChunkBlockTileEntity(int x, int y, int z, TileEntity tileentity) { ChunkPosition chunkposition = new ChunkPosition(x, y, z); tileentity.setWorldObj(worldObj); int ox = tileentity.xCoord; int oy = tileentity.yCoord; int oz = tileentity.zCoord; tileentity.xCoord = x; tileentity.yCoord = y; tileentity.zCoord = z; Block block = getBlock(x, y, z); if (block != null && block.hasTileEntity(getBlockMetadata(x, y, z))) { tileentity.blockMetadata = getBlockMetadata(x, y, z); tileentity.invalidate(); chunkTileEntityMap.put(chunkposition, tileentity); if (tileentity instanceof IShipTileEntity) { ((IShipTileEntity) tileentity).setParentShip(entityShip, ox, oy, oz); } } }
Example 3
Source File: GTHelperFluid.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
/** * Helper method to get an IFluidHandler for at tile position. * * Returns null if there is no valid fluid handler tile. */ @Nullable public static IFluidHandler getFluidHandler(World world, BlockPos blockPos, @Nullable EnumFacing side) { IBlockState state = world.getBlockState(blockPos); Block block = state.getBlock(); if (block.hasTileEntity(state)) { TileEntity tileEntity = world.getTileEntity(blockPos); if (tileEntity != null && tileEntity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) { return tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); } } return null; }
Example 4
Source File: FakeWorldTCGeneration.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean setBlock(int x, int y, int z, Block block, int meta, int flags) { if(block == ConfigBlocks.blockEldritchPortal) return true; if(block == ConfigBlocks.blockEldritch && (meta == 1 || meta == 2 || meta == 3)) return true; blockCount++; long chKey = ((long) x >> 4) | ((long) z >> 4) << 32; ChunkBuffer buf = chunks.get(chKey); int keyX = (x & 15) << 7 << 4; int keyZ = (z & 15) << 7; int key = keyX | keyZ | y; if(buf.blockData[key] != null) { blockOverwriteCount++; ChunkCoordinates cc = new ChunkCoordinates(x, y, z); if(gettedTE.containsKey(cc)) { gettedTE.remove(cc); } } /*if(block == ConfigBlocks.blockEldritchNothing) { if(BlockUtils.isBlockExposed(this, x, y, z)) { meta = 1; } }*/ buf.blockData[key] = block; buf.metaBuffer[key] = (byte) meta; if(block.hasTileEntity(meta)) buf.tiles.add(new Integer[] {x, y, z, key}); return true; }
Example 5
Source File: EntityGroup.java From TickDynamic with MIT License | 5 votes |
private List<Class> loadTilesByName(String name) { FMLControlledNamespacedRegistry<Block> blockRegistry = GameData.getBlockRegistry(); Block block = blockRegistry.getRaw(name); if(block == null) return null; //Get TileEntities for every metadata TileEntity currentTile; Class prevTile = null; List<Class> tileClassList = new ArrayList<Class>(16); for(byte b = 0; b < 16; b++) { if(block.hasTileEntity(b)) { //Might throw an exception while creating TileEntity, especially at initial load of global groups try { currentTile = block.createTileEntity(world, b); } catch(Exception e) { if(mod.debug) System.out.println("Exception while loading Tile for " + name + ":\n" + e.getMessage()); currentTile = null; } Class cls = currentTile.getClass(); if(currentTile != null && cls != prevTile) { if(!tileClassList.contains(cls)) tileClassList.add(currentTile.getClass()); } prevTile = cls; } } return tileClassList; }
Example 6
Source File: MobileChunk.java From archimedes-ships with MIT License | 5 votes |
public boolean setBlockMetadata(int x, int y, int z, int meta) { ExtendedBlockStorage storage = getBlockStorage(x, y, z); if (storage == null) return false; int currentmeta = storage.getExtBlockMetadata(x, y & 15, z); if (currentmeta == meta) { return false; } setChunkModified(); storage.setExtBlockMetadata(x & 15, y & 15, z & 15, meta); Block block = storage.getBlockByExtId(x & 15, y & 15, z & 15); if (block != null && block.hasTileEntity(meta)) { TileEntity tileentity = getTileEntity(x, y, z); if (tileentity != null) { tileentity.updateContainingBlockInfo(); tileentity.blockMetadata = meta; } } return true; }
Example 7
Source File: RenderChunkSchematicVbo.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
protected void renderBlocksAndOverlay(BlockPos pos, Set<TileEntity> tileEntities, boolean[] usedLayers, CompiledChunkSchematic data, BufferBuilderCache buffers) { IBlockState stateSchematic = this.schematicWorldView.getBlockState(pos); IBlockState stateClient = this.clientWorldView.getBlockState(pos); stateSchematic = stateSchematic.getActualState(this.schematicWorldView, pos); stateClient = stateClient.getActualState(this.clientWorldView, pos); Block blockSchematic = stateSchematic.getBlock(); Block blockClient = stateClient.getBlock(); boolean clientHasAir = blockClient == Blocks.AIR; boolean schematicHasAir = blockSchematic == Blocks.AIR; if (clientHasAir && schematicHasAir) { return; } // Schematic has a block, client has air if (clientHasAir || (stateSchematic != stateClient && this.renderColliding)) { if (blockSchematic.hasTileEntity()) { this.addTileEntity(pos, data, tileEntities); } BlockRenderLayer layer = this.renderAsTranslucent ? BlockRenderLayer.TRANSLUCENT : blockSchematic.getRenderLayer(); int layerIndex = layer.ordinal(); if (stateSchematic.getRenderType() != EnumBlockRenderType.INVISIBLE) { BufferBuilder bufferSchematic = buffers.getWorldRendererByLayerId(layerIndex); if (data.isLayerStarted(layer) == false) { data.setLayerStarted(layer); this.preRenderBlocks(bufferSchematic, this.getPosition()); } usedLayers[layerIndex] |= this.renderGlobal.renderBlock(stateSchematic, pos, this.schematicWorldView, bufferSchematic); } } if (this.overlayEnabled) { OverlayType type = this.getOverlayType(stateSchematic, stateClient); Color4f overlayColor = this.getOverlayColor(type); if (overlayColor != null) { this.renderOverlay(pos, stateSchematic, type, overlayColor, data, buffers); } } }
Example 8
Source File: AbstractPair.java From NEI-Integration with MIT License | 4 votes |
protected TileEntity getPairAt(WorldCoordinate coord) { if (!pairings.contains(coord)) return null; int x = coord.x; int y = coord.y; int z = coord.z; if (!IS_BUKKIT) { TileEntity cacheTarget = tileCache.get(coord); if (cacheTarget != null) { if (cacheTarget.isInvalid() || cacheTarget.xCoord != x || cacheTarget.yCoord != y || cacheTarget.zCoord != z) tileCache.remove(coord); else if (isValidPair(coord, cacheTarget)) return cacheTarget; } } if (y < 0) { clearPairing(coord); return null; } World world = tile.getWorldObj(); if (!world.blockExists(x, y, z)) return null; Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); if (!block.hasTileEntity(meta)) { pairingsToTest.add(coord); return null; } TileEntity target = world.getTileEntity(x, y, z); if (target != null && !isValidPair(coord, target)) { pairingsToTest.add(coord); return null; } if (!IS_BUKKIT && target != null) { tileCache.put(coord, target); } return target; }
Example 9
Source File: MobileChunk.java From archimedes-ships with MIT License | 4 votes |
public boolean setBlockIDWithMetadata(int x, int y, int z, Block block, int meta) { if (block == null) return false; ExtendedBlockStorage storage = getBlockStorageOrCreate(x, y, z); int i = x & 15; int j = y & 15; int k = z & 15; Block currentblock = storage.getBlockByExtId(i, j, k); int currentmeta = storage.getExtBlockMetadata(i, j, k); if (currentblock == block && currentmeta == meta) { return false; } storage.func_150818_a(i, j, k, block); storage.setExtBlockMetadata(i, j, k, meta); if (boundsInit) { minX = Math.min(minX, x); minY = Math.min(minY, y); minZ = Math.min(minZ, z); maxX = Math.max(maxX, x + 1); maxY = Math.max(maxY, y + 1); maxZ = Math.max(maxZ, z + 1); } else { boundsInit = true; minX = x; minY = y; minZ = z; maxX = x + 1; maxY = y + 1; maxZ = z + 1; } blockCount++; setChunkModified(); TileEntity tileentity; if (block.hasTileEntity(meta)) { tileentity = getTileEntity(x, y, z); if (tileentity == null) { setTileEntity(x, y, z, tileentity); } if (tileentity != null) { tileentity.updateContainingBlockInfo(); tileentity.blockType = block; tileentity.blockMetadata = meta; } } return true; }
Example 10
Source File: MultiblockComponent.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 4 votes |
public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta, TileEntity tileEntity) { this(relPos, block, meta, block.hasTileEntity() == (tileEntity != null), tileEntity); }