mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-23 16:44:06 +00:00
Show the pack you are working on in the noise explorer
/iris std noise listed the generators of whichever Iris world Bukkit listed first. A normal Iris world runs on its own copy of the pack from when it was created, so generators added to the pack since (like a new generators/2026 folder) were missing while you worked in the studio. The noise commands now use the world you stand in, and otherwise the open studio before any other Iris world. After a hotload the explorer stays on the world it was opened for. Model used: Claude Opus 5.5
This commit is contained in:
1 parent
e58d065ca4
commit
340e66105c
3 files changed
+44
-9
No files matched your search
@@ -250,7 +250,7 @@ public class CommandStudio implements DecreeExecutor {
|
||||
public void noise() {
|
||||
if (noGUI()) return;
|
||||
sender().sendMessage(C.GREEN + "Opening Noise Explorer!");
|
||||
NoiseExplorerGUI.launch();
|
||||
NoiseExplorerGUI.launch(engine());
|
||||
}
|
||||
|
||||
@Decree(description = "Preview the palettes around you (External GUI)", aliases = "pal", origin = DecreeOrigin.PLAYER)
|
||||
@@ -293,7 +293,7 @@ public class CommandStudio implements DecreeExecutor {
|
||||
) {
|
||||
if (noGUI()) return;
|
||||
sender().sendMessage(C.GREEN + "Opening Noise Explorer!");
|
||||
NoiseExplorerGUI.launchGeneratorKey(generator == null ? null : generator.getLoadKey(), generator, seed);
|
||||
NoiseExplorerGUI.launchGeneratorKey(engine(), generator == null ? null : generator.getLoadKey(), generator, seed);
|
||||
}
|
||||
|
||||
@Decree(description = "Hotload a studio", aliases = {"reload", "h"})
|
||||
|
||||
@@ -20,7 +20,9 @@ package com.volmit.iris.core.gui;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
|
||||
import com.volmit.iris.core.project.IrisProject;
|
||||
import com.volmit.iris.core.service.PreservationSVC;
|
||||
import com.volmit.iris.core.service.StudioSVC;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
@@ -94,7 +96,15 @@ public final class GuiHost {
|
||||
return new Dimension(Math.min(preferred.width, usable.width), Math.min(preferred.height, usable.height));
|
||||
}
|
||||
|
||||
/**
|
||||
* The engine of the open studio project, which reads the pack folder you edit, or else the first Iris world.
|
||||
* A normal Iris world runs on its own copy of the pack, made when the world was created.
|
||||
*/
|
||||
public static Engine findActiveEngine() {
|
||||
Engine studioEngine = findStudioEngine();
|
||||
if (studioEngine != null) {
|
||||
return studioEngine;
|
||||
}
|
||||
try {
|
||||
for (World world : new ArrayList<>(Bukkit.getWorlds())) {
|
||||
Engine engine = engineOf(world);
|
||||
@@ -107,6 +117,18 @@ public final class GuiHost {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Engine findStudioEngine() {
|
||||
try {
|
||||
StudioSVC studio = Iris.service(StudioSVC.class);
|
||||
IrisProject project = studio == null || !studio.isProjectOpen() ? null : studio.getActiveProject();
|
||||
PlatformChunkGenerator provider = project == null ? null : project.getActiveProvider();
|
||||
Engine engine = provider == null ? null : provider.getEngine();
|
||||
return engine == null || engine.isClosed() ? null : engine;
|
||||
} catch (Throwable ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Engine findEngine(UUID worldId) {
|
||||
World world = Bukkit.getWorld(worldId);
|
||||
return world == null ? null : engineOf(world);
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.volmit.iris.engine.object.NoiseStyle;
|
||||
import com.volmit.iris.util.function.NoiseProvider;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
import org.bukkit.World;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.BorderFactory;
|
||||
@@ -208,23 +209,26 @@ public final class NoiseExplorerGUI extends JPanel {
|
||||
GuiHost.registerHotloadHook(hotloadHook);
|
||||
}
|
||||
|
||||
public static void launch() {
|
||||
Engine engine = GuiHost.findActiveEngine();
|
||||
/**
|
||||
* @param engine the engine whose pack generators to list, or null for the open studio or first Iris world
|
||||
*/
|
||||
public static void launch(Engine engine) {
|
||||
Engine sourceEngine = engine != null ? engine : GuiHost.findActiveEngine();
|
||||
EventQueue.invokeLater(() -> {
|
||||
StudioTheme.install();
|
||||
NoiseExplorerGUI explorer = new NoiseExplorerGUI(ExplorerMode.NOISE, engine, null, null, null, DEFAULT_SEED, null);
|
||||
NoiseExplorerGUI explorer = new NoiseExplorerGUI(ExplorerMode.NOISE, sourceEngine, null, null, null, DEFAULT_SEED, null);
|
||||
buildNoiseFrame("Noise Explorer", explorer);
|
||||
});
|
||||
}
|
||||
|
||||
public static void launchGeneratorKey(String generatorKey, IrisGenerator fallbackGenerator, long initialSeed) {
|
||||
Engine engine = GuiHost.findActiveEngine();
|
||||
public static void launchGeneratorKey(Engine engine, String generatorKey, IrisGenerator fallbackGenerator, long initialSeed) {
|
||||
Engine sourceEngine = engine != null ? engine : GuiHost.findActiveEngine();
|
||||
String displayName = generatorKey == null || generatorKey.isBlank() ? "Custom Generator" : generatorKey;
|
||||
EventQueue.invokeLater(() -> {
|
||||
StudioTheme.install();
|
||||
NoiseExplorerGUI explorer = new NoiseExplorerGUI(
|
||||
ExplorerMode.NOISE,
|
||||
engine,
|
||||
sourceEngine,
|
||||
generatorKey,
|
||||
fallbackGenerator,
|
||||
displayName,
|
||||
@@ -1080,13 +1084,22 @@ public final class NoiseExplorerGUI extends JPanel {
|
||||
});
|
||||
}
|
||||
|
||||
// A hotload replaces the engine; the explorer stays on the world it was opened for.
|
||||
private Engine engineAfterHotload() {
|
||||
if (paletteStart != null) {
|
||||
return GuiHost.findEngine(paletteStart.worldId());
|
||||
}
|
||||
World world = activeEngine == null ? null : activeEngine.getWorld().realWorld();
|
||||
return world == null ? GuiHost.findActiveEngine() : GuiHost.findEngine(world.getUID());
|
||||
}
|
||||
|
||||
void resetViewport() {
|
||||
viewport = initialViewport;
|
||||
requestPreview();
|
||||
}
|
||||
|
||||
private void handleHotload() {
|
||||
Engine refreshedEngine = paletteStart == null ? GuiHost.findActiveEngine() : GuiHost.findEngine(paletteStart.worldId());
|
||||
Engine refreshedEngine = engineAfterHotload();
|
||||
EventQueue.invokeLater(() -> {
|
||||
if (disposed) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user