cn.nukkit.level.format.ChunkSection Java Examples

The following examples show how to use cn.nukkit.level.format.ChunkSection. 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 Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@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 #2
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@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 #3
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@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 #4
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@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 #5
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@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 #6
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@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 #7
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BaseChunk clone() {
    BaseChunk chunk = (BaseChunk) super.clone();
    if (this.biomes != null) chunk.biomes = this.biomes.clone();
    chunk.heightMap = this.getHeightMapArray().clone();
    if (sections != null && sections[0] != null) {
        chunk.sections = new ChunkSection[sections.length];
        for (int i = 0; i < sections.length; i++) {
            chunk.sections[i] = sections[i].copy();
        }
    }
    return chunk;
}
 
Example #8
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BaseChunk clone() {
    BaseChunk chunk = (BaseChunk) super.clone();
    chunk.biomeColors = this.getBiomeColorArray().clone();
    chunk.heightMap = this.getHeightMapArray().clone();
    if (sections != null && sections[0] != null) {
        chunk.sections = new ChunkSection[sections.length];
        for (int i = 0; i < sections.length; i++) {
            chunk.sections[i] = sections[i].clone();
        }
    }
    return chunk;
}
 
Example #9
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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 #10
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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 #11
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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 #12
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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 #13
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean setSection(float fY, ChunkSection section) {
    byte[] emptyIdArray = new byte[4096];
    byte[] emptyDataArray = new byte[2048];
    if (Arrays.equals(emptyIdArray, section.getIdArray()) && Arrays.equals(emptyDataArray, section.getDataArray())) {
        this.sections[(int) fY] = EmptyChunkSection.EMPTY[(int) fY];
    } else {
        this.sections[(int) fY] = section;
    }
    setChanged();
    return true;
}
 
Example #14
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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 #15
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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 #16
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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 #17
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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 #18
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean setSection(float fY, ChunkSection section) {
    byte[] emptyIdArray = new byte[4096];
    byte[] emptyDataArray = new byte[2048];
    if (Arrays.equals(emptyIdArray, section.getIdArray()) && Arrays.equals(emptyDataArray, section.getDataArray())) {
        this.sections[(int) fY] = EmptyChunkSection.EMPTY[(int) fY];
    } else {
        this.sections[(int) fY] = section;
    }
    setChanged();
    return true;
}
 
Example #19
Source File: BaseChunk.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean setSection(float fY, ChunkSection section) {
    byte[] emptyIdArray = new byte[4096];
    byte[] emptyDataArray = new byte[2048];
    if (Arrays.equals(emptyIdArray, section.getIdArray()) && Arrays.equals(emptyDataArray, section.getDataArray())) {
        this.sections[(int) fY] = new EmptyChunkSection((int) fY);
    } else {
        this.sections[(int) fY] = section;
    }
    this.hasChanged = true;
    return true;
}
 
Example #20
Source File: BaseChunk.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@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 #21
Source File: BaseChunk.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setBlockSkyLight(int x, int y, int z, int level) {
    try {
        this.sections[y >> 4].setBlockSkyLight(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.setBlockSkyLight(x, y, z, level);
    }
}
 
Example #22
Source File: BaseChunk.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setBlockData(int x, int y, int z, int data) {
    try {
        this.sections[y >> 4].setBlockData(x, y & 0x0f, z, data);
        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.setBlockData(x, y, z, data);
    }
}
 
Example #23
Source File: BaseChunk.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setBlockId(int x, int y, int z, int id) {
    try {
        this.sections[y >> 4].setBlockId(x, y & 0x0f, z, id);
        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.setBlockId(x, y, z, id);
    }
}
 
Example #24
Source File: BaseChunk.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BaseChunk clone() {
    BaseChunk chunk = (BaseChunk) super.clone();
    chunk.biomeColors = this.getBiomeColorArray().clone();
    chunk.heightMap = this.getHeightMapArray().clone();
    if (sections != null && sections[0] != null) {
        chunk.sections = new ChunkSection[sections.length];
        for (int i = 0; i < sections.length; i++) {
            chunk.sections[i] = sections[i].clone();
        }
    }
    return chunk;
}
 
Example #25
Source File: McRegion.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public static ChunkSection createChunkSection(int y) {
    return null;
}
 
Example #26
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ChunkSection getSection(float fY) {
    return this.sections[(int) fY];
}
 
Example #27
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
private void setInternalSection(float fY, ChunkSection section) {
    this.sections[(int) fY] = section;
    setChanged();
}
 
Example #28
Source File: BaseChunk.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ChunkSection[] getSections() {
    return sections;
}
 
Example #29
Source File: LevelDB.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
public static ChunkSection createChunkSection(int y) {
    return null;
}
 
Example #30
Source File: EmptyChunkSection.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ChunkSection clone() {
    return this;
}