Java Code Examples for cn.nukkit.blockentity.BlockEntity#isBlockEntityValid()
The following examples show how to use
cn.nukkit.blockentity.BlockEntity#isBlockEntityValid() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Level.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public void doChunkGarbageCollection() { this.timings.doChunkGC.startTiming(); // remove all invaild block entities. List<BlockEntity> toClose = new ArrayList<>(); for (BlockEntity anBlockEntity : blockEntities.values()) { if (anBlockEntity == null) continue; if (anBlockEntity.isBlockEntityValid()) continue; toClose.add(anBlockEntity); } for (BlockEntity be : toClose.toArray(new BlockEntity[toClose.size()])) { be.close(); } for (Long index : this.chunks.keySet()) { if (!this.unloadQueue.containsKey(index)) { int X = getHashX(index); int Z = getHashZ(index); if (!this.isSpawnChunk(X, Z)) { this.unloadChunkRequest(X, Z, true); } } } for (FullChunk chunk : new ArrayList<>(this.provider.getLoadedChunks().values())) { if (!this.chunks.containsKey(Level.chunkHash(chunk.getX(), chunk.getZ()))) { this.provider.unloadChunk(chunk.getX(), chunk.getZ(), false); } } this.provider.doGarbageCollection(); this.timings.doChunkGC.stopTiming(); }
Example 2
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 4 votes |
private void removeInvalidTile(int x, int y, int z) { BlockEntity entity = getTile(x, y, z); if (entity != null && !entity.isBlockEntityValid()) { removeBlockEntity(entity); } }