public MultiblockComponent(BlockPos relPos, IBlockState state, TileEntity tileEntity) { this(relPos, state, state.getBlock().hasTileEntity(state) == (tileEntity != null), tileEntity); }
@Override public boolean matches(@Nonnull Block block, boolean hasSpoon) { return !block.hasTileEntity(); } },
public BlockInfo(IBlockState blockState, TileEntity tileEntity) { this.blockState = blockState; this.tileEntity = tileEntity; Preconditions.checkArgument(tileEntity == null || blockState.getBlock().hasTileEntity(blockState), "Cannot create block info with tile entity for block not having it"); }
@Override protected boolean canEatBlock(IBlockState state) { Block block = state.getBlock(); if (block == null) return false; if (block instanceof BlockCrops && block.getMetaFromState(state) < 7) return true; else if (block.hasTileEntity(state)) return false; return false; }
@Override protected boolean canEatBlock(IBlockState state) { Block block = state.getBlock(); if (block == null) return false; if (block instanceof BlockCrops && block.getMetaFromState(state) >= 7) return true; else if (block.hasTileEntity(state)) return false; return false; }
protected boolean canBreakBlock(IBlockState state) { if (state.getBlock() == ModBlocks.GNEISS) return false; if (state.getBlock().hasTileEntity(state)) return false; return true; }
@Override @Nullable public TileEntity getTileEntity(BlockPos pos) { IBlockState state = getBlockState(pos); if (state.getBlock().hasTileEntity(state)) { return teCache.computeIfAbsent(pos.toImmutable(), p -> state.getBlock().createTileEntity(world, state)); } return null; }
@Nullable public static IItemHandler tryGetItemHandler(IBlockAccess world, BlockPos pos, @Nullable EnumFacing side) { IBlockState state = world.getBlockState(pos); if (state.getBlock().hasTileEntity(state)) { TileEntity tile = world.getTileEntity(pos); if (tile != null) { if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) { return tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); } } } return null; }
final boolean isTileEntity = block.hasTileEntity( defaultState ); final boolean isFullCube = block.isFullCube( defaultState );
@Override public boolean doesSneakBypassUse(ItemStack stack, IBlockAccess world, BlockPos pos, EntityPlayer player) { IBlockState b = world.getBlockState(pos); return (b.getBlock().hasTileEntity(b) && world.getTileEntity(pos).hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)); }
@Override protected boolean canEatBlock(IBlockState state) { Block block = state.getBlock(); if (block == null) return false; if (block == Blocks.DIRT || block == Blocks.GRASS) return true; if (block == Blocks.FARMLAND && blackAnt.getEntityWorld().isAirBlock(new BlockPos(cropX, cropY + 1, cropZ))) return true; else if (block.hasTileEntity(state)) return false; return false; }
/** * If the given blockState can be set to an inner blockState of this. * @param blockState The blockState to set as inner blockState. * @param block The block to set as inner blockState. * @param world The world. * @param blockPos The position. * @return If the blockState can be set as inner blockState. */ public boolean canSetInnerBlock(IBlockState blockState, Block block, IBlockAccess world, BlockPos blockPos) { return block != null && !block.isAir(blockState, world, blockPos) && block.isOpaqueCube(blockState) && !block.hasTileEntity(world.getBlockState(blockPos)) && block.getRenderType(blockState) == EnumBlockRenderType.MODEL; }
private static boolean canMove(IBlockState state, World world, BlockPos pos) { // TODO change to isAir Block block = state.getBlock(); if(block == Blocks.PISTON || block == Blocks.STICKY_PISTON) return !state.getValue(BlockPistonBase.EXTENDED); return !block.isAir(state, world, pos) && state.getMobilityFlag() == EnumPushReaction.NORMAL && (!block.hasTileEntity() || !PistonsMoveTEs.shouldMoveTE(true, state)); }
@SuppressWarnings("deprecation") public static boolean isValidCover(ItemStack item) { if (item.isEmpty()) { return false; } Block block = getBlock(item); IBlockState state = getBlockState(item); return block != null && state != null && ((isModelSupported(state) && block.isTopSolid(state) && !block.getTickRandomly() && !block.hasTileEntity(state)) || block instanceof BlockGlass || block instanceof BlockStainedGlass); }
@Override public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) { if (blockState.getBlock().hasTileEntity(blockState)) { EnumFacing sideHit = data.getSideHit(); TileEntity tileEntity = world.getTileEntity(data.getPos()); if (tileEntity == null) return; Capability<T> capability = getCapability(); T resultCapability = tileEntity.getCapability(capability, sideHit); if (resultCapability != null && allowDisplaying(resultCapability)) { addProbeInfo(resultCapability, probeInfo, tileEntity, sideHit); } } }
public boolean isBlacklisted(World world, EntityPlayer player, ItemStack stack) { if (stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock)stack.getItem()).getBlock(); if (block.hasTileEntity(block.getStateForPlacement(world, BlockPos.ORIGIN, EnumFacing.DOWN, 0F, 0F, 0F, stack.getItemDamage(), player, stack))) return true; } return registry.getValueOf(stack) == null && (stack.getItem().isDamageable() || blacklist.contains(stack)); }
@Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) { boolean placed = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState); if (placed) { if (block.hasTileEntity(newState)) { if (stack.getItem() instanceof ItemBlockNBT && stack.getTagCompound() != null) { TileForestry tile = TileUtil.getTile(world, pos, TileForestry.class); if (tile != null) { tile.readFromNBT(stack.getTagCompound()); tile.setPos(pos); } } } if (block instanceof IBlockRotatable) { ((IBlockRotatable) block).rotateAfterPlacement(player, world, pos, side); } } return placed; } }
public static void detachTileEntities(World world, BlockPos sourcePos, BlockPistonStructureHelper helper, EnumFacing facing, boolean extending) { if(!ModuleLoader.isFeatureEnabled(PistonsMoveTEs.class)) return; List<BlockPos> moveList = helper.getBlocksToMove(); for(BlockPos pos : moveList) { IBlockState state = world.getBlockState(pos); if(state.getBlock().hasTileEntity(state)) { TileEntity tile = world.getTileEntity(pos); if(tile instanceof IPistonCallback) ((IPistonCallback) tile).onPistonMovementStarted(); world.removeTileEntity(pos); registerMovement(world, pos.offset(facing), tile); } } }
if( blk != null && blk.hasTileEntity( state ) )
public void refresh() { if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe != null && ((LogisticsTileGenericPipe) tile).pipe.preventRemove()) { if (world.getBlockState(new BlockPos(x, y, z)) == null) { return; } } tile = null; block = null; if (!loadUnloaded) { return; } IBlockState blockState = world.getBlockState(new BlockPos(x, y, z)); block = blockState != null ? blockState.getBlock() : null; if (block != null && block.hasTileEntity(world.getBlockState(new BlockPos(x, y, z)))) { tile = world.getTileEntity(new BlockPos(x, y, z)); } }