本文整理了Java中net.minecraft.world.chunk.Chunk.isEmpty()
方法的一些代码示例,展示了Chunk.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Chunk.isEmpty()
方法的具体详情如下:
包路径:net.minecraft.world.chunk.Chunk
类名称: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()));
}
内容来源于网络,如有侵权,请联系作者删除!