use of com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader in project WildLoaders by BG-Software-LLC.
the class NMSAdapter_v1_8_R3 method createLoader.
@Override
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
Location loaderLoc = chunkLoader.getLocation();
World world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityList.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 -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
}
return tileEntityChunkLoader;
}
use of com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader in project WildLoaders by BG-Software-LLC.
the class NMSAdapter_v1_7_R4 method createLoader.
@Override
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
Location loaderLoc = chunkLoader.getLocation();
World world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
int x = loaderLoc.getBlockX(), y = loaderLoc.getBlockY(), z = loaderLoc.getBlockZ();
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, x, y, z);
// noinspection unchecked
world.tileEntityList.add(tileEntityChunkLoader);
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
// noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
((TileEntity) tileEntity).a(nbtTagCompound);
});
}
return tileEntityChunkLoader;
}
use of com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader in project WildLoaders by BG-Software-LLC.
the class NMSAdapter_v1_12_R1 method createLoader.
@Override
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
Location loaderLoc = chunkLoader.getLocation();
World 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 -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
try {
compoundLoadMethod.invoke(tileEntity, nbtTagCompound);
} catch (Throwable ex) {
tileEntity.a(nbtTagCompound);
}
});
}
return tileEntityChunkLoader;
}
use of com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader 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;
}
Aggregations