Search in sources :

Example 11 with ChunkSection

use of net.minecraft.server.v1_12_R1.ChunkSection in project TheAPI by TheDevTec.

the class v1_7_R4 method getData.

@Override
public int getData(Object chunk, int x, int y, int z) {
    net.minecraft.server.v1_7_R4.Chunk c = (net.minecraft.server.v1_7_R4.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null)
        return 0;
    return sc.getData(x & 15, y & 15, z & 15);
}
Also used : Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_7_R4.CraftChunk) ChunkSection(net.minecraft.server.v1_7_R4.ChunkSection)

Example 12 with ChunkSection

use of net.minecraft.server.v1_12_R1.ChunkSection in project TheAPI by TheDevTec.

the class v1_8_R2 method getBlock.

@Override
public Object getBlock(Object chunk, int x, int y, int z) {
    net.minecraft.server.v1_8_R2.Chunk c = (net.minecraft.server.v1_8_R2.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null)
        return Blocks.AIR.getBlockData();
    return sc.getType(x & 15, y & 15, z & 15);
}
Also used : Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_8_R2.CraftChunk) ChunkSection(net.minecraft.server.v1_8_R2.ChunkSection)

Example 13 with ChunkSection

use of net.minecraft.server.v1_12_R1.ChunkSection in project TheAPI by TheDevTec.

the class v1_8_R3 method setBlock.

@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
    net.minecraft.server.v1_8_R3.Chunk c = (net.minecraft.server.v1_8_R3.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null) {
        c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
    }
    BlockPosition pos = new BlockPosition(x, y, z);
    // REMOVE TILE ENTITY
    c.tileEntities.remove(pos);
    sc.setType(x & 15, y & 15, z & 15, (IBlockData) IblockData);
    // ADD TILE ENTITY
    if (IblockData instanceof IContainer) {
        TileEntity ent = ((IContainer) IblockData).a(c.world, 0);
        c.tileEntities.put(pos, ent);
        Object packet = ent.getUpdatePacket();
        Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
    }
}
Also used : TileEntity(net.minecraft.server.v1_8_R3.TileEntity) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_8_R3.CraftChunk) IContainer(net.minecraft.server.v1_8_R3.IContainer) ChunkSection(net.minecraft.server.v1_8_R3.ChunkSection)

Example 14 with ChunkSection

use of net.minecraft.server.v1_12_R1.ChunkSection in project TheAPI by TheDevTec.

the class v1_9_R1 method getBlock.

@Override
public Object getBlock(Object chunk, int x, int y, int z) {
    net.minecraft.server.v1_9_R1.Chunk c = (net.minecraft.server.v1_9_R1.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null)
        return Blocks.AIR.getBlockData();
    return sc.getBlocks().a(x & 15, y & 15, z & 15);
}
Also used : CraftChunk(org.bukkit.craftbukkit.v1_9_R1.CraftChunk) Chunk(org.bukkit.Chunk) ChunkSection(net.minecraft.server.v1_9_R1.ChunkSection)

Example 15 with ChunkSection

use of net.minecraft.server.v1_12_R1.ChunkSection in project PaperDev by Kamillaova.

the class CraftChunk method getChunkSnapshot.

public ChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeBiome, boolean includeBiomeTempRain) {
    net.minecraft.server.v1_12_R1.Chunk chunk = getHandle();
    ChunkSection[] cs = chunk.getSections();
    short[][] sectionBlockIDs = new short[cs.length][];
    byte[][] sectionBlockData = new byte[cs.length][];
    byte[][] sectionSkyLights = new byte[cs.length][];
    byte[][] sectionEmitLights = new byte[cs.length][];
    boolean[] sectionEmpty = new boolean[cs.length];
    for (int i = 0; i < cs.length; i++) {
        if (cs[i] == null) {
            // Section is empty?
            sectionBlockIDs[i] = emptyBlockIDs;
            sectionBlockData[i] = emptyData;
            sectionSkyLights[i] = emptySkyLight;
            sectionEmitLights[i] = emptyData;
            sectionEmpty[i] = true;
        } else {
            // Not empty
            short[] blockids = new short[4096];
            byte[] rawIds = new byte[4096];
            NibbleArray data = new NibbleArray();
            cs[i].getBlocks().exportData(rawIds, data);
            byte[] dataValues = sectionBlockData[i] = data.asBytes();
            // Copy base IDs
            for (int j = 0; j < 4096; j++) {
                blockids[j] = (short) (rawIds[j] & 0xFF);
            }
            sectionBlockIDs[i] = blockids;
            if (cs[i].getSkyLightArray() == null) {
                sectionSkyLights[i] = emptyData;
            } else {
                sectionSkyLights[i] = new byte[2048];
                System.arraycopy(cs[i].getSkyLightArray().asBytes(), 0, sectionSkyLights[i], 0, 2048);
            }
            sectionEmitLights[i] = new byte[2048];
            System.arraycopy(cs[i].getEmittedLightArray().asBytes(), 0, sectionEmitLights[i], 0, 2048);
        }
    }
    int[] hmap = null;
    if (includeMaxBlockY) {
        // Get copy of height map
        hmap = new int[256];
        System.arraycopy(chunk.heightMap, 0, hmap, 0, 256);
    }
    BiomeBase[] biome = null;
    double[] biomeTemp = null;
    double[] biomeRain = null;
    if (includeBiome || includeBiomeTempRain) {
        WorldChunkManager wcm = chunk.world.getWorldChunkManager();
        if (includeBiome) {
            biome = new BiomeBase[256];
            for (int i = 0; i < 256; i++) {
                biome[i] = chunk.getBiome(new BlockPosition(i & 0xF, 0, i >> 4), wcm);
            }
        }
        if (includeBiomeTempRain) {
            biomeTemp = new double[256];
            biomeRain = new double[256];
            float[] dat = getTemperatures(wcm, getX() << 4, getZ() << 4);
            for (int i = 0; i < 256; i++) {
                biomeTemp[i] = dat[i];
            }
        /* Removed 15w46a
                dat = wcm.getWetness(null, getX() << 4, getZ() << 4, 16, 16);

                for (int i = 0; i < 256; i++) {
                    biomeRain[i] = dat[i];
                }
                */
        }
    }
    World world = getWorld();
    return new CraftChunkSnapshot(getX(), getZ(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionBlockData, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, biome, biomeTemp, biomeRain);
}
Also used : World(org.bukkit.World) net.minecraft.server.v1_12_R1(net.minecraft.server.v1_12_R1)

Aggregations

Chunk (org.bukkit.Chunk)31 Field (java.lang.reflect.Field)4 ChunkSection (net.minecraft.server.v1_7_R4.ChunkSection)4 ChunkSection (net.minecraft.server.v1_12_R1.ChunkSection)3 ChunkSection (net.minecraft.server.v1_14_R1.ChunkSection)3 ChunkSection (net.minecraft.server.v1_16_R3.ChunkSection)3 ChunkSection (net.minecraft.server.v1_10_R1.ChunkSection)2 ChunkSection (net.minecraft.server.v1_11_R1.ChunkSection)2 ChunkSection (net.minecraft.server.v1_13_R1.ChunkSection)2 ChunkSection (net.minecraft.server.v1_13_R2.ChunkSection)2 ChunkSection (net.minecraft.server.v1_15_R1.ChunkSection)2 ChunkSection (net.minecraft.server.v1_16_R1.ChunkSection)2 ChunkSection (net.minecraft.server.v1_16_R2.ChunkSection)2 ChunkSection (net.minecraft.server.v1_7_R3.ChunkSection)2 ChunkSection (net.minecraft.server.v1_8_R1.ChunkSection)2 CraftChunk (org.bukkit.craftbukkit.v1_11_R1.CraftChunk)2 CraftChunk (org.bukkit.craftbukkit.v1_12_R1.CraftChunk)2 CraftChunk (org.bukkit.craftbukkit.v1_16_R1.CraftChunk)2 CraftChunk (org.bukkit.craftbukkit.v1_7_R4.CraftChunk)2 CraftWorld (org.bukkit.craftbukkit.v1_7_R4.CraftWorld)2