use of org.bukkit.craftbukkit.v1_13_R1.CraftChunk in project MagicPlugin by elBukkit.
the class CompatibilityUtils method setBlockFast.
@Override
public boolean setBlockFast(Chunk chunk, int x, int y, int z, Material material, int data) {
LevelChunk nmsChunk = ((CraftChunk) chunk).getHandle();
net.minecraft.world.level.block.Block block = CraftMagicNumbers.getBlock(material);
BlockPos blockLocation = new BlockPos(x, y, z);
nmsChunk.setBlockState(blockLocation, block.defaultBlockState(), false);
return true;
}
use of org.bukkit.craftbukkit.v1_13_R1.CraftChunk in project MagicPlugin by elBukkit.
the class CompatibilityUtils method setBlockFast.
@Override
public boolean setBlockFast(Chunk chunk, int x, int y, int z, Material material, int data) {
LevelChunk nmsChunk = ((CraftChunk) chunk).getHandle();
net.minecraft.world.level.block.Block block = CraftMagicNumbers.getBlock(material);
BlockPos blockLocation = new BlockPos(x, y, z);
nmsChunk.setBlockState(blockLocation, block.defaultBlockState(), false);
return true;
}
use of org.bukkit.craftbukkit.v1_13_R1.CraftChunk 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 org.bukkit.craftbukkit.v1_13_R1.CraftChunk 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 org.bukkit.craftbukkit.v1_13_R1.CraftChunk 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);
}
});
}
}
Aggregations