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

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

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

Chunk.isEmpty介绍

暂无

代码示例

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

public VWChunkCache(World world, int mnX, int mnZ, int mxX, int mxZ) {
  worldFor = world;
  minChunkX = mnX >> 4;
  minChunkZ = mnZ >> 4;
  maxChunkX = mxX >> 4;
  maxChunkZ = mxZ >> 4;
  cachedChunks = new Chunk[maxChunkX - minChunkX + 1][maxChunkZ - minChunkZ + 1];
  isChunkLoaded = new boolean[maxChunkX - minChunkX + 1][maxChunkZ - minChunkZ + 1];
  for (int x = minChunkX; x <= maxChunkX; x++) {
    for (int z = minChunkZ; z <= maxChunkZ; z++) {
      cachedChunks[x - minChunkX][z - minChunkZ] = world.getChunkFromChunkCoords(x, z);
      isChunkLoaded[x - minChunkX][z - minChunkZ] = !cachedChunks[x - minChunkX][z - minChunkZ].isEmpty();
      if (!isChunkLoaded[x - minChunkX][z - minChunkZ]) {
        allLoaded = false;
      }
    }
  }
}

代码示例来源:origin: cabaletta/baritone

@Override
public List<BlockPos> scanChunk(IPlayerContext ctx, List<Block> blocks, ChunkPos pos, int max, int yLevelThreshold) {
  if (blocks.isEmpty()) {
    return Collections.emptyList();
  }
  ChunkProviderClient chunkProvider = (ChunkProviderClient) ctx.world().getChunkProvider();
  Chunk chunk = chunkProvider.getLoadedChunk(pos.x, pos.z);
  int playerY = ctx.playerFeet().getY();
  if (chunk == null || chunk.isEmpty()) {
    return Collections.emptyList();
  }
  ArrayList<BlockPos> res = new ArrayList<>();
  scanChunkInto(pos.x << 4, pos.z << 4, chunk, blocks, res, max, yLevelThreshold, playerY);
  return res;
}

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

@Inject(method = "addEntity(Lnet/minecraft/entity/Entity;)V", at = @At("HEAD"), cancellable = true)
  public void preAddEntity(Entity entityIn, CallbackInfo callbackInfo) {
    World world = this.world;

    int i = MathHelper.floor(entityIn.posX / 16.0D);
    int j = MathHelper.floor(entityIn.posZ / 16.0D);

    if (i == this.x && j == this.z) {
      //do nothing, and let vanilla code take over after our injected code is done (now)
    } else {
      Chunk realChunkFor = world.getChunkFromChunkCoords(i, j);
      if (!realChunkFor.isEmpty() && realChunkFor.loaded) {
        realChunkFor.addEntity(entityIn);
        callbackInfo.cancel(); //don't run the code on this chunk!!!
      }
    }
  }
}

代码示例来源:origin: TerraFirmaCraft/TerraFirmaCraft

if (mc.world.isBlockLoaded(blockpos) && !chunk.isEmpty())

代码示例来源:origin: MightyPirates/TIS-3D

/**
 * Convenience check for determining whether a module is actually visible.
 * <p>
 * This can allow for some optimizations, such as sending state updates
 * much more or infrequently (or not at all) while invisible. If rendering
 * a module's overlay is exceptionally complex,
 *
 * @return whether the module is currently visible.
 */
protected boolean isVisible() {
  final World world = getCasing().getCasingWorld();
  final BlockPos neighborPos = getCasing().getPosition().offset(Face.toEnumFacing(getFace()));
  if (!world.isBlockLoaded(neighborPos)) {
    // If the neighbor isn't loaded, we can assume we're also not visible on that side.
    return false;
  }
  final Chunk chunk = world.getChunkFromBlockCoords(neighborPos);
  if (chunk.isEmpty()) {
    // If the neighbor chunk is empty, we must assume we're visible.
    return true;
  }
  // Otherwise check if the neighboring block blocks visibility to our face.
  final IBlockState neighborState = world.getBlockState(neighborPos);
  final Block neighborBlock = neighborState.getBlock();
  return !neighborBlock.doesSideBlockRendering(neighborState, world, neighborPos, Face.toEnumFacing(getFace().getOpposite()));
}

相关文章