Search in sources :

Example 6 with ITileEntity

use of net.minecraft.server.v1_16_R1.ITileEntity in project TheAPI by TheDevTec.

the class v1_15_R1 method setBlock.

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

Example 7 with ITileEntity

use of net.minecraft.server.v1_16_R1.ITileEntity in project TheAPI by TheDevTec.

the class v1_16_R2 method setBlock.

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

Example 8 with ITileEntity

use of net.minecraft.server.v1_16_R1.ITileEntity in project PaperDev by Kamillaova.

the class ItemMetaTest method testBlockStateMeta.

@Test
public void testBlockStateMeta() {
    for (Item item : (Iterable<Item>) Item.REGISTRY) {
        Block block = null;
        if (item instanceof ItemBlock) {
            block = ((ItemBlock) item).getBlock();
        } else if (item instanceof ItemReed) {
            block = ((ItemReed) item).a;
        }
        if (block != null) {
            if (block instanceof ITileEntity) {
                ItemStack stack = CraftItemStack.asNewCraftStack(Item.getItemOf(block));
                // Command blocks aren't unit testable atm
                if (stack.getType() == Material.AIR || stack.getType() == Material.COMMAND || stack.getType() == Material.COMMAND_CHAIN || stack.getType() == Material.COMMAND_REPEATING) {
                    return;
                }
                ItemMeta meta = stack.getItemMeta();
                assertTrue(stack + " has meta of type " + meta + " expected BlockStateMeta", meta instanceof BlockStateMeta);
                BlockStateMeta blockState = (BlockStateMeta) meta;
                assertNotNull(stack + " has null block state", blockState.getBlockState());
                blockState.setBlockState(blockState.getBlockState());
            }
        }
    }
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) Item(net.minecraft.server.v1_12_R1.Item) ITileEntity(net.minecraft.server.v1_12_R1.ITileEntity) Block(net.minecraft.server.v1_12_R1.Block) ItemBlock(net.minecraft.server.v1_12_R1.ItemBlock) ItemBlock(net.minecraft.server.v1_12_R1.ItemBlock) ItemStack(org.bukkit.inventory.ItemStack) ItemReed(net.minecraft.server.v1_12_R1.ItemReed) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Test(org.junit.Test)

Example 9 with ITileEntity

use of net.minecraft.server.v1_16_R1.ITileEntity in project TheAPI by TheDevTec.

the class v1_12_R1 method setBlock.

@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
    net.minecraft.server.v1_12_R1.Chunk c = (net.minecraft.server.v1_12_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 : ITileEntity(net.minecraft.server.v1_12_R1.ITileEntity) TileEntity(net.minecraft.server.v1_12_R1.TileEntity) ITileEntity(net.minecraft.server.v1_12_R1.ITileEntity) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_12_R1.CraftChunk) ChunkSection(net.minecraft.server.v1_12_R1.ChunkSection)

Example 10 with ITileEntity

use of net.minecraft.server.v1_16_R1.ITileEntity in project TheAPI by TheDevTec.

the class v1_16_R1 method setBlock.

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

Aggregations

Chunk (org.bukkit.Chunk)11 ITileEntity (net.minecraft.server.v1_12_R1.ITileEntity)2 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)1 ChunkSection (net.minecraft.server.v1_10_R1.ChunkSection)1 ITileEntity (net.minecraft.server.v1_10_R1.ITileEntity)1 TileEntity (net.minecraft.server.v1_10_R1.TileEntity)1 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)1 ChunkSection (net.minecraft.server.v1_11_R1.ChunkSection)1 ITileEntity (net.minecraft.server.v1_11_R1.ITileEntity)1 TileEntity (net.minecraft.server.v1_11_R1.TileEntity)1 Block (net.minecraft.server.v1_12_R1.Block)1 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)1 ChunkSection (net.minecraft.server.v1_12_R1.ChunkSection)1 Item (net.minecraft.server.v1_12_R1.Item)1 ItemBlock (net.minecraft.server.v1_12_R1.ItemBlock)1 ItemReed (net.minecraft.server.v1_12_R1.ItemReed)1 TileEntity (net.minecraft.server.v1_12_R1.TileEntity)1 BlockPosition (net.minecraft.server.v1_13_R1.BlockPosition)1 ChunkSection (net.minecraft.server.v1_13_R1.ChunkSection)1 DataBits (net.minecraft.server.v1_13_R1.DataBits)1