Fxi regen (again)

Dieser Commit ist enthalten in:
Jesse Boyd 2019-11-23 18:41:05 +00:00
Ursprung edeb285152
Commit 50c9a2c2d2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
2 geänderte Dateien mit 40 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -227,11 +227,15 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
entity.valid = false; entity.valid = false;
} }
public Chunk ensureLoaded(net.minecraft.server.v1_14_R1.World nmsWorld, int X, int Z) {
return BukkitAdapter_1_14.ensureLoaded(nmsWorld, X, Z);
}
@Override @Override
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) { public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
try { try {
WorldServer nmsWorld = world; WorldServer nmsWorld = world;
Chunk nmsChunk = BukkitAdapter_1_14.ensureLoaded(nmsWorld, X, Z); Chunk nmsChunk = ensureLoaded(nmsWorld, X, Z);
// Remove existing tiles // Remove existing tiles
{ {
@ -628,7 +632,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
synchronized (this) { synchronized (this) {
tmp = nmsChunk; tmp = nmsChunk;
if (tmp == null) { if (tmp == null) {
nmsChunk = tmp = BukkitAdapter_1_14.ensureLoaded(this.world, X, Z); nmsChunk = tmp = ensureLoaded(this.world, X, Z);
} }
} }
} }

Datei anzeigen

@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl;
import com.bekvon.bukkit.residence.commands.material; import com.bekvon.bukkit.residence.commands.material;
import com.bekvon.bukkit.residence.commands.server; import com.bekvon.bukkit.residence.commands.server;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
import com.boydti.fawe.beta.implementation.queue.SingleThreadQueueExtent; import com.boydti.fawe.beta.implementation.queue.SingleThreadQueueExtent;
@ -30,6 +31,7 @@ import com.boydti.fawe.bukkit.adapter.mc1_14.BukkitAdapter_1_14;
import com.boydti.fawe.bukkit.adapter.mc1_14.BukkitGetBlocks_1_14; import com.boydti.fawe.bukkit.adapter.mc1_14.BukkitGetBlocks_1_14;
import com.boydti.fawe.bukkit.adapter.mc1_14.MapChunkUtil_1_14; import com.boydti.fawe.bukkit.adapter.mc1_14.MapChunkUtil_1_14;
import com.boydti.fawe.bukkit.adapter.mc1_14.nbt.LazyCompoundTag_1_14; import com.boydti.fawe.bukkit.adapter.mc1_14.nbt.LazyCompoundTag_1_14;
import com.boydti.fawe.util.TaskManager;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
@ -92,6 +94,7 @@ import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -101,6 +104,8 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.OptionalInt; import java.util.OptionalInt;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -393,22 +398,45 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
CraftServer server = originalWorld.getServer(); CraftServer server = originalWorld.getServer();
WorldNBTStorage originalDataManager = originalWorld.getDataManager(); WorldNBTStorage originalDataManager = originalWorld.getDataManager();
WorldNBTStorage saveHandler = new WorldNBTStorage(saveFolder, originalDataManager.getDirectory().getName(), server.getServer(), originalDataManager.getDataFixer()); WorldNBTStorage saveHandler = new WorldNBTStorage(saveFolder, originalDataManager.getDirectory().getName(), server.getServer(), originalDataManager.getDataFixer());
ChunkGenerator originalGen = world.getGenerator();
try (WorldServer freshWorld = new WorldServer(server.getServer(), try (WorldServer freshWorld = new WorldServer(server.getServer(),
server.getServer().executorService, saveHandler, server.getServer().executorService, saveHandler,
originalWorld.worldData, originalWorld.worldData,
originalWorld.worldProvider.getDimensionManager(), originalWorld.worldProvider.getDimensionManager(),
originalWorld.getMethodProfiler(), originalWorld.getMethodProfiler(),
server.getServer().worldLoadListenerFactory.create(11), server.getServer().worldLoadListenerFactory.create(11),
((CraftWorld) world).getEnvironment(), world.getEnvironment(),
server.getGenerator(world.getName()))) { originalGen)) {
// Pre-gen all the chunks // Pre-gen all the chunks
// We need to also pull one more chunk in every direction // We need to also pull one more chunk in every direction
Fawe.get().getQueueHandler().startSet(true);
try {
SingleThreadQueueExtent extent = new SingleThreadQueueExtent(); SingleThreadQueueExtent extent = new SingleThreadQueueExtent();
extent.init(null, (x, z) -> new BukkitGetBlocks_1_14(freshWorld, x, z), null); extent.init(null, (x, z) -> new BukkitGetBlocks_1_14(freshWorld, x, z) {
@Override
public Chunk ensureLoaded(World nmsWorld, int X, int Z) {
Chunk cached = nmsWorld.getChunkIfLoaded(X, Z);
if (cached != null) return cached;
Future<Chunk> future = Fawe.get().getQueueHandler().sync((Supplier<Chunk>) () -> freshWorld.getChunkAt(X, Z));
while (!future.isDone()) {
// this feels so dirty
freshWorld.getChunkProvider().runTasks();
}
try {
return future.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
}, null);
for (BlockVector3 vec : region) { for (BlockVector3 vec : region) {
editSession.setBlock(vec, extent.getFullBlock(vec)); editSession.setBlock(vec, extent.getFullBlock(vec));
} }
} finally {
Fawe.get().getQueueHandler().endSet(true);
}
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }