cn.nukkit.utils.ChunkException Java Examples
The following examples show how to use
cn.nukkit.utils.ChunkException.
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: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public boolean setBlock(int x, int y, int z, int blockId, int meta) { int Y = y >> 4; try { setChanged(); return this.sections[Y].setBlock(x, y & 0x0f, z, blockId, meta); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } return this.sections[Y].setBlock(x, y & 0x0f, z, blockId, meta); } finally { removeInvalidTile(x, y, z); } }
Example #2
Source File: Anvil.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void saveChunk(int x, int z, FullChunk chunk) { if (!(chunk instanceof Chunk)) { throw new ChunkException("Invalid Chunk class"); } int regionX = x >> 5; int regionZ = z >> 5; this.loadRegion(regionX, regionZ); chunk.setX(x); chunk.setZ(z); try { this.getRegion(regionX, regionZ).writeChunk(chunk); } catch (Exception e) { throw new RuntimeException(e); } }
Example #3
Source File: McRegion.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void setChunk(int chunkX, int chunkZ, FullChunk chunk) { if (!(chunk instanceof Chunk)) { throw new ChunkException("Invalid Chunk class"); } chunk.setProvider(this); int regionX = chunkX >> 5; int regionZ = chunkZ >> 5; this.loadRegion(regionX, regionZ); chunk.setX(chunkX); chunk.setZ(chunkZ); long index = Level.chunkHash(chunkX, chunkZ); if (this.chunks.containsKey(index) && !this.chunks.get(index).equals(chunk)) { this.unloadChunk(chunkX, chunkZ, false); } this.chunks.put(index, (Chunk) chunk); }
Example #4
Source File: BlockEntity.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public BlockEntity(FullChunk chunk, CompoundTag nbt) { if (chunk == null || chunk.getProvider() == null) { throw new ChunkException("Invalid garbage Chunk given to Block Entity"); } this.timing = Timings.getBlockEntityTiming(this); this.server = chunk.getProvider().getLevel().getServer(); this.chunk = chunk; this.setLevel(chunk.getProvider().getLevel()); this.namedTag = nbt; this.name = ""; this.lastUpdate = System.currentTimeMillis(); this.id = BlockEntity.count++; this.x = this.namedTag.getInt("x"); this.y = this.namedTag.getInt("y"); this.z = this.namedTag.getInt("z"); this.movable = this.namedTag.getBoolean("isMovable"); this.chunk.addBlockEntity(this); this.getLevel().addBlockEntity(this); }
Example #5
Source File: Anvil.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public synchronized void saveChunk(int x, int z, FullChunk chunk) { if (!(chunk instanceof Chunk)) { throw new ChunkException("Invalid Chunk class"); } int regionX = x >> 5; int regionZ = z >> 5; this.loadRegion(regionX, regionZ); chunk.setX(x); chunk.setZ(z); try { this.getRegion(regionX, regionZ).writeChunk(chunk); } catch (Exception e) { throw new RuntimeException(e); } }
Example #6
Source File: BlockEntity.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public BlockEntity(FullChunk chunk, CompoundTag nbt) { if (chunk == null || chunk.getProvider() == null) { throw new ChunkException("Invalid garbage Chunk given to Block Entity"); } this.timing = Timings.getBlockEntityTiming(this); this.server = chunk.getProvider().getLevel().getServer(); this.chunk = chunk; this.setLevel(chunk.getProvider().getLevel()); this.namedTag = nbt; this.name = ""; this.lastUpdate = System.currentTimeMillis(); this.id = BlockEntity.count++; this.x = this.namedTag.getInt("x"); this.y = this.namedTag.getInt("y"); this.z = this.namedTag.getInt("z"); this.movable = this.namedTag.getBoolean("isMovable"); this.initBlockEntity(); this.chunk.addBlockEntity(this); this.getLevel().addBlockEntity(this); }
Example #7
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void setBlockData(int x, int y, int z, int data) { int Y = y >> 4; try { this.sections[Y].setBlockData(x, y & 0x0f, z, data); setChanged(); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } this.sections[Y].setBlockData(x, y & 0x0f, z, data); } finally { removeInvalidTile(x, y, z); } }
Example #8
Source File: BaseChunk.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public boolean setBlock(int x, int y, int z, Integer blockId, Integer meta) { int id = blockId == null ? 0 : blockId; int damage = meta == null ? 0 : meta; try { this.hasChanged = true; return this.sections[y >> 4].setBlock(x, y & 0x0f, z, id, damage); } catch (ChunkException e) { int Y = y >> 4; try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } return this.sections[y >> 4].setBlock(x, y & 0x0f, z, id, damage); } }
Example #9
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void setBlockId(int x, int y, int z, int id) { int Y = y >> 4; try { this.sections[Y].setBlockId(x, y & 0x0f, z, id); setChanged(); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } this.sections[Y].setBlockId(x, y & 0x0f, z, id); } finally { removeInvalidTile(x, y, z); } }
Example #10
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public boolean setFullBlockId(int x, int y, int z, int fullId) { int Y = y >> 4; try { setChanged(); return this.sections[Y].setFullBlockId(x, y & 0x0f, z, fullId); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } return this.sections[Y].setFullBlockId(x, y & 0x0f, z, fullId); } finally { removeInvalidTile(x, y, z); } }
Example #11
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public Block getAndSetBlock(int x, int y, int z, Block block) { int Y = y >> 4; try { setChanged(); return this.sections[Y].getAndSetBlock(x, y & 0x0f, z, block); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } return this.sections[Y].getAndSetBlock(x, y & 0x0f, z, block); } finally { removeInvalidTile(x, y, z); } }
Example #12
Source File: Anvil.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void saveChunk(int x, int z, FullChunk chunk) { if (!(chunk instanceof Chunk)) { throw new ChunkException("Invalid Chunk class"); } int regionX = x >> 5; int regionZ = z >> 5; this.loadRegion(regionX, regionZ); chunk.setX(x); chunk.setZ(z); try { this.getRegion(regionX, regionZ).writeChunk(chunk); } catch (Exception e) { throw new RuntimeException(e); } }
Example #13
Source File: LevelDB.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void setChunk(int chunkX, int chunkZ, FullChunk chunk) { if (!(chunk instanceof Chunk)) { throw new ChunkException("Invalid Chunk class"); } chunk.setProvider(this); chunk.setX(chunkX); chunk.setZ(chunkZ); long index = Level.chunkHash(chunkX, chunkZ); if (this.chunks.containsKey(index) && !this.chunks.get(index).equals(chunk)) { this.unloadChunk(chunkX, chunkZ, false); } this.chunks.put(index, (Chunk) chunk); }
Example #14
Source File: BlockEntity.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public BlockEntity(FullChunk chunk, CompoundTag nbt) { if (chunk == null || chunk.getProvider() == null) { throw new ChunkException("Invalid garbage Chunk given to Block Entity"); } this.timing = Timings.getBlockEntityTiming(this); this.server = chunk.getProvider().getLevel().getServer(); this.chunk = chunk; this.setLevel(chunk.getProvider().getLevel()); this.namedTag = nbt; this.name = ""; this.lastUpdate = System.currentTimeMillis(); this.id = BlockEntity.count++; this.x = this.namedTag.getInt("x"); this.y = this.namedTag.getInt("y"); this.z = this.namedTag.getInt("z"); this.movable = this.namedTag.getBoolean("isMovable"); this.initBlockEntity(); this.chunk.addBlockEntity(this); this.getLevel().addBlockEntity(this); }
Example #15
Source File: BaseChunk.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void setBlockLight(int x, int y, int z, int level) { try { this.sections[y >> 4].setBlockLight(x, y & 0x0f, z, level); this.hasChanged = true; } catch (ChunkException e) { int Y = y >> 4; try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } this.setBlockLight(x, y, z, level); } }
Example #16
Source File: Anvil.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void setChunk(int chunkX, int chunkZ, FullChunk chunk) { if (!(chunk instanceof Chunk)) { throw new ChunkException("Invalid Chunk class"); } chunk.setProvider(this); int regionX = chunkX >> 5; int regionZ = chunkZ >> 5; this.loadRegion(regionX, regionZ); chunk.setX(chunkX); chunk.setZ(chunkZ); long index = Level.chunkHash(chunkX, chunkZ); this.chunks.put(index, (Chunk) chunk); }
Example #17
Source File: McRegion.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void saveChunk(int x, int z, FullChunk chunk) { if (!(chunk instanceof Chunk)) { throw new ChunkException("Invalid Chunk class"); } this.loadRegion(x >> 5, z >> 5); chunk.setX(x); chunk.setZ(z); try { this.getRegion(x >> 5, z >> 5).writeChunk(chunk); } catch (Exception e) { throw new RuntimeException(e); } }
Example #18
Source File: BaseLevelProvider.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void setChunk(int chunkX, int chunkZ, FullChunk chunk) { if (!(chunk instanceof BaseFullChunk)) { throw new ChunkException("Invalid Chunk class"); } chunk.setProvider(this); chunk.setPosition(chunkX, chunkZ); long index = Level.chunkHash(chunkX, chunkZ); synchronized (chunks) { if (this.chunks.containsKey(index) && !this.chunks.get(index).equals(chunk)) { this.unloadChunk(chunkX, chunkZ, false); } this.chunks.put(index, (BaseFullChunk) chunk); } }
Example #19
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void setBlockSkyLight(int x, int y, int z, int level) { int Y = y >> 4; try { this.sections[Y].setBlockSkyLight(x, y & 0x0f, z, level); setChanged(); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } this.sections[Y].setBlockSkyLight(x, y & 0x0f, z, level); } }
Example #20
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void setBlockLight(int x, int y, int z, int level) { int Y = y >> 4; try { this.sections[Y].setBlockLight(x, y & 0x0f, z, level); setChanged(); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } this.sections[Y].setBlockLight(x, y & 0x0f, z, level); } }
Example #21
Source File: McRegion.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void saveChunk(int x, int z, FullChunk chunk) { if (!(chunk instanceof Chunk)) { throw new ChunkException("Invalid Chunk class"); } this.loadRegion(x >> 5, z >> 5); chunk.setPosition(x, z); try { this.getRegion(x >> 5, z >> 5).writeChunk(chunk); } catch (Exception e) { throw new RuntimeException(e); } }
Example #22
Source File: Anvil.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public synchronized void saveChunk(int X, int Z) { BaseFullChunk chunk = this.getChunk(X, Z); if (chunk != null) { try { this.loadRegion(X >> 5, Z >> 5).writeChunk(chunk); } catch (Exception e) { throw new ChunkException("Error saving chunk (" + X + ", " + Z + ")", e); } } }
Example #23
Source File: BaseLevelProvider.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void setChunk(int chunkX, int chunkZ, FullChunk chunk) { if (!(chunk instanceof BaseFullChunk)) { throw new ChunkException("Invalid Chunk class"); } chunk.setProvider(this); chunk.setPosition(chunkX, chunkZ); long index = Level.chunkHash(chunkX, chunkZ); if (this.chunks.containsKey(index) && !this.chunks.get(index).equals(chunk)) { this.unloadChunk(chunkX, chunkZ, false); } this.chunks.put(index, (BaseFullChunk) chunk); }
Example #24
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public Block getAndSetBlock(int x, int y, int z, Block block) { int Y = y >> 4; try { setChanged(); return this.sections[Y].getAndSetBlock(x, y & 0x0f, z, block); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } return this.sections[Y].getAndSetBlock(x, y & 0x0f, z, block); } }
Example #25
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean setBlock(int x, int y, int z, int blockId, int meta) { int Y = y >> 4; try { setChanged(); return this.sections[Y].setBlock(x, y & 0x0f, z, blockId, meta); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } return this.sections[Y].setBlock(x, y & 0x0f, z, blockId, meta); } }
Example #26
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void setBlockId(int x, int y, int z, int id) { int Y = y >> 4; try { this.sections[Y].setBlockId(x, y & 0x0f, z, id); setChanged(); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } this.sections[Y].setBlockId(x, y & 0x0f, z, id); } }
Example #27
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void setBlockData(int x, int y, int z, int data) { int Y = y >> 4; try { this.sections[Y].setBlockData(x, y & 0x0f, z, data); setChanged(); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } this.sections[Y].setBlockData(x, y & 0x0f, z, data); } }
Example #28
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void setBlockSkyLight(int x, int y, int z, int level) { int Y = y >> 4; try { this.sections[Y].setBlockSkyLight(x, y & 0x0f, z, level); setChanged(); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } this.sections[Y].setBlockSkyLight(x, y & 0x0f, z, level); } }
Example #29
Source File: BaseChunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void setBlockLight(int x, int y, int z, int level) { int Y = y >> 4; try { this.sections[Y].setBlockLight(x, y & 0x0f, z, level); setChanged(); } catch (ChunkException e) { try { this.setInternalSection(Y, (ChunkSection) this.providerClass.getMethod("createChunkSection", int.class).invoke(this.providerClass, Y)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { Server.getInstance().getLogger().logException(e1); } this.sections[Y].setBlockLight(x, y & 0x0f, z, level); } }
Example #30
Source File: McRegion.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void saveChunk(int x, int z, FullChunk chunk) { if (!(chunk instanceof Chunk)) { throw new ChunkException("Invalid Chunk class"); } this.loadRegion(x >> 5, z >> 5); chunk.setPosition(x, z); try { this.getRegion(x >> 5, z >> 5).writeChunk(chunk); } catch (Exception e) { throw new RuntimeException(e); } }