diff --git a/core/src/main/java/com/volmit/iris/core/commands/CommandStudio.java b/core/src/main/java/com/volmit/iris/core/commands/CommandStudio.java
index 44525e1d8..92b66d01e 100644
--- a/core/src/main/java/com/volmit/iris/core/commands/CommandStudio.java
+++ b/core/src/main/java/com/volmit/iris/core/commands/CommandStudio.java
@@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.gui.NoiseExplorerGUI;
import com.volmit.iris.core.gui.VisionGUI;
+import com.volmit.iris.core.gui.components.IrisRenderer;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.service.ConversionSVC;
@@ -65,6 +66,9 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
+import javax.imageio.ImageIO;
+import java.awt.Color;
+import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -156,6 +160,37 @@ public class CommandStudio implements DecreeExecutor {
sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion());
}
+ @Decree(description = "Debug image")
+ public void printImageChannel(
+ @Param(name = "image", description = "Image found in the image folder inside the project")
+ String image,
+ @Param(name = "channel", description = "Image channel")
+ IrisImageChannel channel
+ ) {
+ if (noStudio()) return;
+ try {
+ File file = new File(access().getEngine().getComplex().getData().getDataFolder(), "images/" + image);
+ if (!file.exists()) {
+ sender().sendMessage(C.RED + "The image \"" + image + "\" does not exist.");
+ return;
+ }
+ BufferedImage buffer = ImageIO.read(file);
+ IrisImage irisImage = new IrisImage(buffer);
+ File at = new File(file.getParentFile(), "debug-see-" + file.getName());
+ BufferedImage b = new BufferedImage(buffer.getWidth(), buffer.getHeight(), BufferedImage.TYPE_INT_RGB);
+ for (int i = 0; i < buffer.getWidth(); i++) {
+ for (int j = 0; j < buffer.getHeight(); j++) {
+ b.setRGB(i, j, Color.getHSBColor(0, 0, (float) irisImage.getValue(channel, i, j)).getRGB());
+ }
+ }
+ ImageIO.write(b, "png", at);
+ sender().sendMessage(C.IRIS + "Debug image written to ./images for channel " + channel.name());
+ } catch (Exception e) {
+ sender().sendMessage(C.RED + "Something went wrong.. ");
+ e.printStackTrace();
+ }
+ }
+
@Decree(name = "regen", description = "Regenerate nearby chunks.", aliases = "rg", sync = true, origin = DecreeOrigin.PLAYER)
public void regen(
@Param(name = "radius", description = "The radius of nearby cunks", defaultValue = "5")
@@ -849,7 +884,7 @@ public class CommandStudio implements DecreeExecutor {
sender().sendMessage(C.RED + "No studio world is open!");
return true;
}
- if (!engine().isStudio()) {
+ if (engine() == null || !engine().isStudio()) {
sender().sendMessage(C.RED + "You must be in a studio world!");
return true;
}
diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisImage.java b/core/src/main/java/com/volmit/iris/engine/object/IrisImage.java
index 49afae0e4..ce94a13ed 100644
--- a/core/src/main/java/com/volmit/iris/engine/object/IrisImage.java
+++ b/core/src/main/java/com/volmit/iris/engine/object/IrisImage.java
@@ -123,8 +123,6 @@ public class IrisImage extends IrisRegistrant {
}
public void writeDebug(IrisImageChannel channel) {
-
-
try {
File at = new File(getLoadFile().getParentFile(), "debug-see-" + getLoadFile().getName());
BufferedImage b = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
diff --git a/core/src/main/java/com/volmit/iris/util/decree/handlers/ImageChannelHandler.java b/core/src/main/java/com/volmit/iris/util/decree/handlers/ImageChannelHandler.java
new file mode 100644
index 000000000..4dc0d5ca2
--- /dev/null
+++ b/core/src/main/java/com/volmit/iris/util/decree/handlers/ImageChannelHandler.java
@@ -0,0 +1,53 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2022 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.volmit.iris.util.decree.handlers;
+
+import com.volmit.iris.engine.object.IrisImageChannel;
+import com.volmit.iris.util.collection.KList;
+import com.volmit.iris.util.decree.DecreeParameterHandler;
+import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
+
+import java.util.Arrays;
+
+public class ImageChannelHandler implements DecreeParameterHandler {
+ @Override
+ public KList getPossibilities() {
+ return new KList<>(Arrays.stream(IrisImageChannel.values()).toList());
+ }
+
+ @Override
+ public String toString(IrisImageChannel channel) {
+ return channel.toString();
+ }
+
+ @Override
+ public IrisImageChannel parse(String in, boolean force) throws DecreeParsingException {
+ return IrisImageChannel.valueOf(in);
+ }
+
+ @Override
+ public boolean supports(Class> type) {
+ return type.equals(IrisImageChannel.class);
+ }
+
+ @Override
+ public String getRandomDefault() {
+ return IrisImageChannel.BRIGHTNESS.toString();
+ }
+}