use of net.minecraft.server.v1_16_R1.Chunk in project fairy by FairyProject.
the class CacheBlockSetHandler method setType.
public void setType(CacheBlockChange blockChange) {
if (world.isChunkLoaded(blockChange.getX() >> 4, blockChange.getZ() >> 4)) {
Chunk chunk = ((CraftChunk) world.getChunkAt(blockChange.getX() >> 4, blockChange.getZ() >> 4)).getHandle();
final int combined = blockChange.getMaterial().getId() + (blockChange.getData() << 12);
final IBlockData ibd = net.minecraft.server.v1_8_R3.Block.getByCombinedId(combined);
int y = blockChange.getY().get(blockChange.getX(), blockChange.getZ(), chunk);
BlockPosition blockPosition = new BlockPosition(blockChange.getX(), y, blockChange.getZ());
chunk.a(blockPosition, ibd);
chunk.world.notify(blockPosition);
return;
}
long key = LongHash.toLong(blockChange.getX() >> 4, blockChange.getZ() >> 4);
if (cachedChanges.containsKey(key)) {
cachedChanges.get(key).add(blockChange);
return;
}
CacheChunkChanges chunkChanges = new CacheChunkChanges();
cachedChanges.put(key, chunkChanges);
chunkChanges.add(blockChange);
}
use of net.minecraft.server.v1_16_R1.Chunk in project WildLoaders by BG-Software-LLC.
the class NMSAdapter_v1_16_R3 method removeLoader.
@Override
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
Location loaderLoc = chunkLoader.getLocation();
assert loaderLoc.getWorld() != null;
WorldServer world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
long tileEntityLong = ChunkCoordIntPair.pair(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
TileEntityChunkLoader tileEntityChunkLoader = TileEntityChunkLoader.tileEntityChunkLoaderMap.remove(tileEntityLong);
if (tileEntityChunkLoader != null) {
tileEntityChunkLoader.holograms.forEach(EntityHolograms_v1_16_R3::removeHologram);
tileEntityChunkLoader.removed = true;
world.tileEntityListTick.remove(tileEntityChunkLoader);
}
if (spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
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 = 16);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, false);
}
}
use of net.minecraft.server.v1_16_R1.Chunk in project WildLoaders by BG-Software-LLC.
the class NMSAdapter_v1_12_R1 method removeLoader.
@Override
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
Location loaderLoc = chunkLoader.getLocation();
World world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
long tileEntityLong = LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
TileEntityChunkLoader tileEntityChunkLoader = TileEntityChunkLoader.tileEntityChunkLoaderMap.remove(tileEntityLong);
if (tileEntityChunkLoader != null) {
tileEntityChunkLoader.holograms.forEach(EntityHolograms_v1_12_R1::removeHologram);
tileEntityChunkLoader.removed = true;
world.tileEntityListTick.remove(tileEntityChunkLoader);
}
if (spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
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) 16);
try {
compoundLoadMethod.invoke(tileEntity, nbtTagCompound);
} catch (Throwable ex) {
tileEntity.a(nbtTagCompound);
}
});
}
}
use of net.minecraft.server.v1_16_R1.Chunk in project WildLoaders by BG-Software-LLC.
the class ChunkLoaderNPC_v1_16_R3 method removePlayer.
private static void removePlayer(WorldServer worldServer, EntityPlayer entityPlayer) {
Chunk currentChunk = worldServer.getChunkIfLoaded((int) entityPlayer.locX() >> 4, (int) entityPlayer.locZ() >> 4);
if (currentChunk != null)
currentChunk.b(entityPlayer);
worldServer.entitiesById.remove(entityPlayer.getId());
worldServer.unregisterEntity(entityPlayer);
try {
entityPlayer.shouldBeRemoved = true;
} catch (Throwable ignored) {
}
}
use of net.minecraft.server.v1_16_R1.Chunk 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;
}
Aggregations