mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-27 12:45:25 +01:00
Run biomes async.
This commit is contained in:
parent
347e218462
commit
37d527b909
@ -5,6 +5,7 @@ import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandEnvironment;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -26,23 +27,31 @@ public class BiomeManager {
|
||||
Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island);
|
||||
int radius = (int) Math.ceil(island.getRadius());
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x++) {
|
||||
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) {
|
||||
location.getWorld().setBiome(x, z, biome);
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> {
|
||||
for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) {
|
||||
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) {
|
||||
Chunk chunk = location.getWorld().getChunkAt(x >> 4, z >> 4);
|
||||
updateBiome(island, chunk);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private Class<?> packetPlayOutMapChunkClass;
|
||||
private Class<?> chunkClass;
|
||||
|
||||
private void updateBiome(Island island, Chunk chunk) {
|
||||
Class<?> packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk");
|
||||
Class<?> chunkClass = NMSUtil.getNMSClass("Chunk");
|
||||
if (packetPlayOutMapChunkClass == null) {
|
||||
packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk");
|
||||
chunkClass = NMSUtil.getNMSClass("Chunk");
|
||||
}
|
||||
|
||||
for (Player all : skyblock.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user