Search in sources :

Example 21 with TileEntity

use of net.minecraft.server.v1_8_R2.TileEntity 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 22 with TileEntity

use of net.minecraft.server.v1_8_R2.TileEntity 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 23 with TileEntity

use of net.minecraft.server.v1_8_R2.TileEntity 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 24 with TileEntity

use of net.minecraft.server.v1_8_R2.TileEntity in project Slabbo by Sven65.

the class SlabboAPI_v1_8_R1 method setChestName.

public void setChestName(Block chestBlock, String name) {
    Chest chest = (Chest) chestBlock.getState();
    World nmsWorld = ((CraftWorld) chestBlock.getWorld()).getHandle();
    TileEntity tileEntity = nmsWorld.getTileEntity(new BlockPosition(chestBlock.getX(), chestBlock.getY(), chestBlock.getZ()));
    if (!(tileEntity instanceof TileEntityChest))
        return;
    ((TileEntityChest) tileEntity).a(name);
    chest.update();
}
Also used : TileEntity(net.minecraft.server.v1_8_R1.TileEntity) TileEntityChest(net.minecraft.server.v1_8_R1.TileEntityChest) Chest(org.bukkit.block.Chest) TileEntityChest(net.minecraft.server.v1_8_R1.TileEntityChest) BlockPosition(net.minecraft.server.v1_8_R1.BlockPosition) World(net.minecraft.server.v1_8_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld)

Example 25 with TileEntity

use of net.minecraft.server.v1_8_R2.TileEntity in project PaperDev by Kamillaova.

the class CraftBeacon method getEntitiesInRange.

@Override
public Collection<LivingEntity> getEntitiesInRange() {
    TileEntity tileEntity = this.getTileEntityFromWorld();
    if (tileEntity instanceof TileEntityBeacon) {
        TileEntityBeacon beacon = (TileEntityBeacon) tileEntity;
        Collection<EntityHuman> nms = beacon.getHumansInRange();
        Collection<LivingEntity> bukkit = new ArrayList<LivingEntity>(nms.size());
        for (EntityHuman human : nms) {
            bukkit.add(human.getBukkitEntity());
        }
        return bukkit;
    }
    // block is no longer a beacon
    return new ArrayList<LivingEntity>();
}
Also used : TileEntity(net.minecraft.server.v1_12_R1.TileEntity) LivingEntity(org.bukkit.entity.LivingEntity) TileEntityBeacon(net.minecraft.server.v1_12_R1.TileEntityBeacon) EntityHuman(net.minecraft.server.v1_12_R1.EntityHuman) ArrayList(java.util.ArrayList)

Aggregations

Chunk (org.bukkit.Chunk)15 Location (org.bukkit.Location)14 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)10 Map (java.util.Map)10 WildLoadersPlugin (com.bgsoftware.wildloaders.WildLoadersPlugin)8 Hologram (com.bgsoftware.wildloaders.api.holograms.Hologram)8 ChunkLoader (com.bgsoftware.wildloaders.api.loaders.ChunkLoader)8 ChunkLoaderNPC (com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC)8 ITileEntityChunkLoader (com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader)8 WChunkLoader (com.bgsoftware.wildloaders.loaders.WChunkLoader)8 Collection (java.util.Collection)8 Collections (java.util.Collections)8 UUID (java.util.UUID)8 TileEntity (net.minecraft.server.v1_12_R1.TileEntity)8 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)8 TileEntity (net.minecraft.server.v1_16_R3.TileEntity)8 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)7 List (java.util.List)6 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)6