Search in sources :

Example 36 with TileEntity

use of net.minecraft.server.v1_15_R1.TileEntity in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method createLoader.

@Override
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
    Location loaderLoc = chunkLoader.getLocation();
    assert loaderLoc.getWorld() != null;
    WorldServer world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
    TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
    world.tileEntityListTick.add(tileEntityChunkLoader);
    for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
        Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
        chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
        world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
    }
    return tileEntityChunkLoader;
}
Also used : NBTTagLong(net.minecraft.server.v1_16_R3.NBTTagLong) ChunkLoader(com.bgsoftware.wildloaders.api.loaders.ChunkLoader) Block(net.minecraft.server.v1_16_R3.Block) IBlockData(net.minecraft.server.v1_16_R3.IBlockData) TileEntityMobSpawner(net.minecraft.server.v1_16_R3.TileEntityMobSpawner) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WChunkLoader(com.bgsoftware.wildloaders.loaders.WChunkLoader) Location(org.bukkit.Location) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) Map(java.util.Map) WildLoadersPlugin(com.bgsoftware.wildloaders.WildLoadersPlugin) ITileEntityChunkLoader(com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader) Hologram(com.bgsoftware.wildloaders.api.holograms.Hologram) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) NBTTagList(net.minecraft.server.v1_16_R3.NBTTagList) TileEntity(net.minecraft.server.v1_16_R3.TileEntity) World(net.minecraft.server.v1_16_R3.World) NBTTagString(net.minecraft.server.v1_16_R3.NBTTagString) TileEntityTypes(net.minecraft.server.v1_16_R3.TileEntityTypes) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) Collection(java.util.Collection) UUID(java.util.UUID) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) ChunkCoordIntPair(net.minecraft.server.v1_16_R3.ChunkCoordIntPair) ITickable(net.minecraft.server.v1_16_R3.ITickable) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) List(java.util.List) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) ChunkLoaderNPC(com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC) Collections(java.util.Collections) ITileEntityChunkLoader(com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) TileEntityMobSpawner(net.minecraft.server.v1_16_R3.TileEntityMobSpawner) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Location(org.bukkit.Location)

Example 37 with TileEntity

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

use of net.minecraft.server.v1_15_R1.TileEntity 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)

Example 39 with TileEntity

use of net.minecraft.server.v1_15_R1.TileEntity in project TheAPI by TheDevTec.

the class v1_8_R2 method setBlock.

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

Example 40 with TileEntity

use of net.minecraft.server.v1_15_R1.TileEntity in project TheAPI by TheDevTec.

the class v1_7_R4 method setBlock.

@SuppressWarnings("unchecked")
@Override
public void setBlock(Object chunk, int x, int y, int z, Object block, int data) {
    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) {
        c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
    }
    ChunkPosition pos = new ChunkPosition(x & 15, y & 15, z & 15);
    // REMOVE TILE ENTITY
    c.tileEntities.remove(pos);
    sc.setTypeId(x & 15, y & 15, z & 15, (Block) block);
    sc.setData(x & 15, y & 15, z & 15, data);
    // ADD TILE ENTITY
    if (block instanceof IContainer) {
        TileEntity ent = ((IContainer) block).a(c.world, 0);
        c.tileEntities.put(pos, ent);
        Object packet = ent.getUpdatePacket();
        for (Player player : Bukkit.getOnlinePlayers()) BukkitLoader.getPacketHandler().send(player, packet);
    }
}
Also used : TileEntity(net.minecraft.server.v1_7_R4.TileEntity) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer) EntityPlayer(net.minecraft.server.v1_7_R4.EntityPlayer) ChunkPosition(net.minecraft.server.v1_7_R4.ChunkPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_7_R4.CraftChunk) IContainer(net.minecraft.server.v1_7_R4.IContainer) ChunkSection(net.minecraft.server.v1_7_R4.ChunkSection)

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