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;
}
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));
}
}
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));
}
}
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));
}
}
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);
}
}
Aggregations