Search in sources :

Example 31 with ChunkSection

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

the class v1_7_R4 method getBlock.

@Override
public Object getBlock(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 Blocks.AIR;
    return sc.getTypeId(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 32 with ChunkSection

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

the class v1_8_R1 method getBlock.

@Override
public Object getBlock(Object chunk, int x, int y, int z) {
    net.minecraft.server.v1_8_R1.Chunk c = (net.minecraft.server.v1_8_R1.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_R1.CraftChunk) ChunkSection(net.minecraft.server.v1_8_R1.ChunkSection)

Example 33 with ChunkSection

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

the class v1_8_R1 method setBlock.

@SuppressWarnings("unchecked")
@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
    net.minecraft.server.v1_8_R1.Chunk c = (net.minecraft.server.v1_8_R1.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_R1.TileEntity) BlockPosition(net.minecraft.server.v1_8_R1.BlockPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_8_R1.CraftChunk) IContainer(net.minecraft.server.v1_8_R1.IContainer) ChunkSection(net.minecraft.server.v1_8_R1.ChunkSection)

Example 34 with ChunkSection

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

the class v1_16_R3 method setBlock.

@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
    net.minecraft.server.v1_16_R3.Chunk c = (net.minecraft.server.v1_16_R3.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null) {
        c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4);
    }
    BlockPosition pos = new BlockPosition(x, y, z);
    // REMOVE TILE ENTITY
    c.tileEntities.remove(pos);
    sc.getBlocks().b(x & 15, y & 15, z & 15, (IBlockData) IblockData);
    // ADD TILE ENTITY
    if (IblockData instanceof ITileEntity) {
        TileEntity ent = ((ITileEntity) IblockData).createTile(c);
        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_16_R3.TileEntity) ITileEntity(net.minecraft.server.v1_16_R3.ITileEntity) ITileEntity(net.minecraft.server.v1_16_R3.ITileEntity) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) ChunkSection(net.minecraft.server.v1_16_R3.ChunkSection)

Example 35 with ChunkSection

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

the class v1_9_R1 method setBlock.

@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
    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) {
        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.getBlocks().setBlock(x & 15, y & 15, z & 15, (IBlockData) IblockData);
    // ADD TILE ENTITY
    if (IblockData instanceof ITileEntity) {
        TileEntity ent = ((ITileEntity) 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_9_R1.TileEntity) ITileEntity(net.minecraft.server.v1_9_R1.ITileEntity) ITileEntity(net.minecraft.server.v1_9_R1.ITileEntity) BlockPosition(net.minecraft.server.v1_9_R1.BlockPosition) CraftChunk(org.bukkit.craftbukkit.v1_9_R1.CraftChunk) Chunk(org.bukkit.Chunk) ChunkSection(net.minecraft.server.v1_9_R1.ChunkSection)

Aggregations

Chunk (org.bukkit.Chunk)31 ChunkSection (net.minecraft.server.v1_7_R4.ChunkSection)5 Field (java.lang.reflect.Field)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