mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-04 00:46:08 +00:00
- Fixed noStudio null pointer when not in studio lol
- Added a debugger for when creating images
This commit is contained in:
parent
b209f69bba
commit
289813b044
@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.gui.NoiseExplorerGUI;
|
import com.volmit.iris.core.gui.NoiseExplorerGUI;
|
||||||
import com.volmit.iris.core.gui.VisionGUI;
|
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.loader.IrisData;
|
||||||
import com.volmit.iris.core.project.IrisProject;
|
import com.volmit.iris.core.project.IrisProject;
|
||||||
import com.volmit.iris.core.service.ConversionSVC;
|
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.BlockVector;
|
||||||
import org.bukkit.util.Vector;
|
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.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
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());
|
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)
|
@Decree(name = "regen", description = "Regenerate nearby chunks.", aliases = "rg", sync = true, origin = DecreeOrigin.PLAYER)
|
||||||
public void regen(
|
public void regen(
|
||||||
@Param(name = "radius", description = "The radius of nearby cunks", defaultValue = "5")
|
@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!");
|
sender().sendMessage(C.RED + "No studio world is open!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!engine().isStudio()) {
|
if (engine() == null || !engine().isStudio()) {
|
||||||
sender().sendMessage(C.RED + "You must be in a studio world!");
|
sender().sendMessage(C.RED + "You must be in a studio world!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -123,8 +123,6 @@ public class IrisImage extends IrisRegistrant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeDebug(IrisImageChannel channel) {
|
public void writeDebug(IrisImageChannel channel) {
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
File at = new File(getLoadFile().getParentFile(), "debug-see-" + getLoadFile().getName());
|
File at = new File(getLoadFile().getParentFile(), "debug-see-" + getLoadFile().getName());
|
||||||
BufferedImage b = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
|
BufferedImage b = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
|
||||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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<IrisImageChannel> {
|
||||||
|
@Override
|
||||||
|
public KList<IrisImageChannel> 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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user