mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-26 22:10:18 +00:00
Fixes
This commit is contained in:
1 parent
29ff3f01a7
commit
927c48f8c7
18 files changed
+283
-89
No files matched your search
@@ -30,6 +30,7 @@ import art.arcane.iris.engine.object.TileData;
|
||||
import art.arcane.iris.modded.api.ModdedCustomContentRegistry;
|
||||
import art.arcane.iris.modded.command.ModdedGuiHost;
|
||||
import art.arcane.iris.modded.command.ModdedObjectUndo;
|
||||
import art.arcane.iris.modded.command.ModdedPregenBossBar;
|
||||
import art.arcane.iris.modded.command.ModdedPregenJob;
|
||||
import art.arcane.iris.modded.command.ModdedStudioCommands;
|
||||
import art.arcane.iris.modded.command.ModdedWandService;
|
||||
@@ -79,6 +80,7 @@ public final class ModdedEngineBootstrap {
|
||||
ModdedStartup.runOnce(server);
|
||||
ModdedPrimaryWorldRouter.tick(server);
|
||||
SERVICE_MANAGER.tick(server);
|
||||
ModdedPregenBossBar.tick(server);
|
||||
}
|
||||
|
||||
public static void start(MinecraftServer server) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.modded.api;
|
||||
|
||||
import art.arcane.iris.core.tools.IrisToolbelt;
|
||||
import art.arcane.iris.core.tools.WorldMaintenance;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.modded.IrisModdedChunkGenerator;
|
||||
import art.arcane.iris.modded.command.ModdedPregenJob;
|
||||
@@ -96,7 +96,7 @@ public final class IrisModdedAPI {
|
||||
if (sliceType == null) {
|
||||
return;
|
||||
}
|
||||
IrisToolbelt.retainMantleDataForSlice(sliceType.getCanonicalName());
|
||||
WorldMaintenance.retainMantleDataForSlice(sliceType.getCanonicalName());
|
||||
}
|
||||
|
||||
public static void registerProvider(ModdedDataProvider provider) {
|
||||
|
||||
+2
@@ -557,6 +557,7 @@ public final class IrisModdedCommands {
|
||||
fail(source, "A pregeneration task is already running. Stop it first with /iris pregen stop.");
|
||||
return 0;
|
||||
}
|
||||
ModdedPregenBossBar.begin(source.getPlayer());
|
||||
String guiNote;
|
||||
if (!gui) {
|
||||
guiNote = "";
|
||||
@@ -573,6 +574,7 @@ public final class IrisModdedCommands {
|
||||
|
||||
private static int pregenStop(CommandSourceStack source) {
|
||||
if (ModdedPregenJob.stop()) {
|
||||
ModdedPregenBossBar.clear();
|
||||
ok(source, "Stopping pregeneration; finishing up the current region...");
|
||||
return 1;
|
||||
}
|
||||
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
package art.arcane.iris.modded.command;
|
||||
|
||||
import art.arcane.iris.core.gui.PregeneratorJob;
|
||||
import art.arcane.volmlib.util.format.Form;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerBossEvent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.BossEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ModdedPregenBossBar {
|
||||
private static final UUID BAR_ID = UUID.fromString("14150000-1e15-4a2b-9c3d-1115e9a1cafe");
|
||||
private static final int UPDATE_INTERVAL_TICKS = 10;
|
||||
|
||||
private static volatile ServerBossEvent bar;
|
||||
private static volatile UUID viewer;
|
||||
private static int sinceUpdate;
|
||||
|
||||
private ModdedPregenBossBar() {
|
||||
}
|
||||
|
||||
public static synchronized void begin(ServerPlayer player) {
|
||||
clear();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
viewer = player.getUUID();
|
||||
bar = new ServerBossEvent(BAR_ID, Component.literal("Iris Pregen starting..."), BossEvent.BossBarColor.GREEN, BossEvent.BossBarOverlay.PROGRESS);
|
||||
bar.setProgress(0.0F);
|
||||
bar.addPlayer(player);
|
||||
sinceUpdate = UPDATE_INTERVAL_TICKS;
|
||||
}
|
||||
|
||||
public static void tick(MinecraftServer server) {
|
||||
ServerBossEvent active = bar;
|
||||
if (active == null) {
|
||||
return;
|
||||
}
|
||||
PregeneratorJob.PregenProgress progress = PregeneratorJob.progressSnapshot();
|
||||
if (progress == null) {
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
if (++sinceUpdate < UPDATE_INTERVAL_TICKS) {
|
||||
return;
|
||||
}
|
||||
sinceUpdate = 0;
|
||||
reattach(server, active);
|
||||
active.setProgress((float) clamp01(progress.percent() / 100.0D));
|
||||
active.setColor(progress.paused() ? BossEvent.BossBarColor.YELLOW : BossEvent.BossBarColor.GREEN);
|
||||
active.setName(nameFor(progress));
|
||||
}
|
||||
|
||||
private static void reattach(MinecraftServer server, ServerBossEvent active) {
|
||||
UUID id = viewer;
|
||||
if (id == null || server == null) {
|
||||
return;
|
||||
}
|
||||
ServerPlayer player = server.getPlayerList().getPlayer(id);
|
||||
if (player != null && !active.getPlayers().contains(player)) {
|
||||
active.addPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
private static Component nameFor(PregeneratorJob.PregenProgress progress) {
|
||||
MutableComponent name = Component.empty();
|
||||
name.append(ModdedCommandFeedback.text("Iris Pregen ", ModdedCommandFeedback.DARK_GREEN));
|
||||
name.append(ModdedCommandFeedback.text(Form.f(progress.generated()) + "/" + Form.f(progress.totalChunks()), ModdedCommandFeedback.VALUE));
|
||||
name.append(ModdedCommandFeedback.text(" " + String.format("%.1f", progress.percent()) + "%", ModdedCommandFeedback.USAGE));
|
||||
if (progress.paused()) {
|
||||
name.append(ModdedCommandFeedback.text(" PAUSED", ModdedCommandFeedback.REQUIRED));
|
||||
return name;
|
||||
}
|
||||
name.append(ModdedCommandFeedback.text(" " + Form.f((int) progress.chunksPerSecond()) + "/s", ModdedCommandFeedback.VALUE));
|
||||
if (progress.eta() > 0L) {
|
||||
name.append(ModdedCommandFeedback.text(" ETA " + Form.duration(progress.eta(), 1), ModdedCommandFeedback.DARK_GREEN));
|
||||
}
|
||||
if (progress.failed() > 0L) {
|
||||
name.append(ModdedCommandFeedback.text(" failed " + Form.f(progress.failed()), ModdedCommandFeedback.REQUIRED));
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private static double clamp01(double value) {
|
||||
if (value < 0.0D) {
|
||||
return 0.0D;
|
||||
}
|
||||
if (value > 1.0D) {
|
||||
return 1.0D;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static synchronized void clear() {
|
||||
ServerBossEvent existing = bar;
|
||||
if (existing != null) {
|
||||
existing.removeAllPlayers();
|
||||
existing.setVisible(false);
|
||||
}
|
||||
bar = null;
|
||||
viewer = null;
|
||||
sinceUpdate = 0;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.modded.command;
|
||||
|
||||
import art.arcane.iris.core.tools.IrisToolbelt;
|
||||
import art.arcane.iris.core.tools.WorldMaintenance;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.modded.IrisModdedChunkGenerator;
|
||||
@@ -107,7 +107,7 @@ public final class ModdedRegen {
|
||||
private void run() {
|
||||
long startedAt = M.ms();
|
||||
String worldName = engine.getWorld() == null ? null : engine.getWorld().name();
|
||||
IrisToolbelt.beginWorldMaintenance(worldName, "regen");
|
||||
WorldMaintenance.beginWorldMaintenance(worldName, "regen");
|
||||
try {
|
||||
resetMantleMargin();
|
||||
List<int[]> targets = ChunkSpiral.centerOut(centerX, centerZ, radius);
|
||||
@@ -120,7 +120,7 @@ public final class ModdedRegen {
|
||||
LOGGER.error("Iris regen failed", e);
|
||||
fail("Regen failed: " + e);
|
||||
} finally {
|
||||
IrisToolbelt.endWorldMaintenance(worldName, "regen");
|
||||
WorldMaintenance.endWorldMaintenance(worldName, "regen");
|
||||
ACTIVE.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import art.arcane.iris.core.IrisSettings;
|
||||
import art.arcane.iris.core.gui.PregeneratorJob;
|
||||
import art.arcane.iris.core.pregenerator.MantleHeapPressure;
|
||||
import art.arcane.iris.core.runtime.GoldenHashEngine;
|
||||
import art.arcane.iris.core.tools.IrisToolbelt;
|
||||
import art.arcane.iris.core.tools.WorldMaintenance;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.modded.ModdedWorldEngines;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
@@ -166,7 +166,7 @@ public final class ModdedEngineMaintenanceService implements ModdedTickableServi
|
||||
}
|
||||
|
||||
private boolean shouldSkipForMaintenance(Engine engine) {
|
||||
if (engine.getWorld() == null || !IrisToolbelt.isWorldMaintenanceActive(engine.getWorld().name())) {
|
||||
if (engine.getWorld() == null || !WorldMaintenance.isWorldMaintenanceActive(engine.getWorld().name())) {
|
||||
return false;
|
||||
}
|
||||
return !pregenTargets(engine);
|
||||
|
||||
Reference in new issue
Block a user