net.minecraft.world.chunk.Chunk.getTileEntity()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中net.minecraft.world.chunk.Chunk.getTileEntity()方法的一些代码示例,展示了Chunk.getTileEntity()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Chunk.getTileEntity()方法的具体详情如下:
包路径:net.minecraft.world.chunk.Chunk
类名称:Chunk
方法名:getTileEntity

Chunk.getTileEntity介绍

暂无

代码示例

代码示例来源:origin: thraaawn/CompactMachines

@Nullable
@Override
public TileEntity getTileEntity(BlockPos pos) {
  pos = pos.add(0, 40, 0);
  return chunk.getTileEntity(pos, IMMEDIATE);
}

代码示例来源:origin: ValkyrienWarfare/Valkyrien-Warfare-Revamped

@Nullable
public TileEntity getTileEntity(BlockPos pos) {
  int i = (pos.getX() >> 4) - this.minChunkX;
  int j = (pos.getZ() >> 4) - this.minChunkZ;
  if (i < 0 || i >= cachedChunks.length || j < 0 || j >= cachedChunks[i].length)
    return null;
  if (cachedChunks[i][j] == null)
    return null;
  return this.cachedChunks[i][j].getTileEntity(pos, Chunk.EnumCreateEntityType.IMMEDIATE);
}

代码示例来源:origin: AlgorithmX2/Chisels-and-Bits

public static TileEntity getTileEntitySafely(
    final @Nonnull IBlockAccess world,
    final @Nonnull BlockPos pos )
{
  // not going to lie, this is really stupid.
  if ( world instanceof ChunkCache )
  {
    return ( (ChunkCache) world ).getTileEntity( pos, Chunk.EnumCreateEntityType.CHECK );
  }
  // also stupid...
  else if ( world instanceof World )
  {
    return ( (World) world ).getChunkFromBlockCoords( pos ).getTileEntity( pos, Chunk.EnumCreateEntityType.CHECK );
  }
  // yep... stupid.
  else
  {
    return world.getTileEntity( pos );
  }
}

代码示例来源:origin: TeamLapen/Vampirism

@Override
  public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random) {
    //Fix related to #210
    //Tents with no tileentity set, create a new one and enable spawn
    //TODO remove sometime
    if (worldIn.getChunkFromBlockCoords(pos).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) == null) {
      TileEntity tile = worldIn.getTileEntity(pos);
      if (tile instanceof TileTent) {
        ((TileTent) tile).setSpawn(true);
      }
    }
  }
}

相关文章