本文整理了Java中net.minecraft.block.Block.hasTileEntity()
方法的一些代码示例,展示了Block.hasTileEntity()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.hasTileEntity()
方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:hasTileEntity
暂无
代码示例来源:origin: Vazkii/Botania
public MultiblockComponent(BlockPos relPos, IBlockState state, TileEntity tileEntity) {
this(relPos, state, state.getBlock().hasTileEntity(state) == (tileEntity != null), tileEntity);
}
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
public boolean matches(@Nonnull Block block, boolean hasSpoon) {
return !block.hasTileEntity();
}
},
代码示例来源:origin: GregTechCE/GregTech
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");
}
代码示例来源:origin: vadis365/TheErebus
@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;
}
代码示例来源:origin: vadis365/TheErebus
@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;
}
代码示例来源:origin: vadis365/TheErebus
protected boolean canBreakBlock(IBlockState state) {
if (state.getBlock() == ModBlocks.GNEISS)
return false;
if (state.getBlock().hasTileEntity(state))
return false;
return true;
}
代码示例来源:origin: Vazkii/Patchouli
@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;
}
代码示例来源:origin: TeamLapen/Vampirism
@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;
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final boolean isTileEntity = block.hasTileEntity( defaultState );
final boolean isFullCube = block.isFullCube( defaultState );
代码示例来源:origin: TeamLapen/Vampirism
@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));
}
代码示例来源:origin: vadis365/TheErebus
@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;
}
代码示例来源:origin: CyclopsMC/EvilCraft
/**
* 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;
}
代码示例来源:origin: Vazkii/Quark
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));
}
代码示例来源:origin: raoulvdberge/refinedstorage
@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);
}
代码示例来源:origin: GregTechCE/GregTech
@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);
}
}
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
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));
}
代码示例来源:origin: ForestryMC/ForestryMC
@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;
}
}
代码示例来源:origin: Vazkii/Quark
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);
}
}
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
if( blk != null && blk.hasTileEntity( state ) )
代码示例来源:origin: RS485/LogisticsPipes
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));
}
}
内容来源于网络,如有侵权,请联系作者删除!