mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Re-added /iris std generator
Re-added the studio generator command. Fixed it up a bit (stopped random jitters that occurred)
This commit is contained in:
parent
9644693de3
commit
7370af0084
@ -42,6 +42,9 @@ public class CommandIrisStudio extends MortarCommand
|
|||||||
@Command
|
@Command
|
||||||
private CommandIrisStudioExplorer exp;
|
private CommandIrisStudioExplorer exp;
|
||||||
|
|
||||||
|
@Command
|
||||||
|
private CommandIrisStudioExplorerGenerator generator;
|
||||||
|
|
||||||
@Command
|
@Command
|
||||||
private CommandIrisStudioLoot loot;
|
private CommandIrisStudioLoot loot;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.volmit.iris.manager.command.studio;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.IrisSettings;
|
import com.volmit.iris.IrisSettings;
|
||||||
|
import com.volmit.iris.manager.IrisDataManager;
|
||||||
import com.volmit.iris.manager.gui.NoiseExplorer;
|
import com.volmit.iris.manager.gui.NoiseExplorer;
|
||||||
import com.volmit.iris.object.IrisGenerator;
|
import com.volmit.iris.object.IrisGenerator;
|
||||||
import com.volmit.iris.util.KList;
|
import com.volmit.iris.util.KList;
|
||||||
@ -14,7 +15,7 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
|
|||||||
public CommandIrisStudioExplorerGenerator()
|
public CommandIrisStudioExplorerGenerator()
|
||||||
{
|
{
|
||||||
super("generator", "gen", "g");
|
super("generator", "gen", "g");
|
||||||
setDescription("Explore different generators");
|
setDescription("Preview created noise noises generators");
|
||||||
requiresPermission(Iris.perm.studio);
|
requiresPermission(Iris.perm.studio);
|
||||||
setCategory("World");
|
setCategory("World");
|
||||||
}
|
}
|
||||||
@ -39,38 +40,31 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Iris.proj.isProjectOpen())
|
IrisGenerator generator;
|
||||||
{
|
long seed = 12345;
|
||||||
sender.sendMessage("No project is open");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.length == 0)
|
if (Iris.proj.isProjectOpen())
|
||||||
{
|
{
|
||||||
sender.sendMessage("Provide a generator name");
|
generator = Iris.proj.getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(args[0]);
|
||||||
return true;
|
seed = Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String g = args[0];
|
generator = IrisDataManager.loadAnyGenerator(args[0]);
|
||||||
IrisGenerator b = Iris.proj.getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(g);
|
}
|
||||||
|
|
||||||
if(b != null)
|
if (generator != null)
|
||||||
{
|
{
|
||||||
NoiseExplorer.launch((x, z) ->
|
long finalSeed = seed;
|
||||||
{
|
NoiseExplorer.launch((x, z) ->
|
||||||
return b.getHeight(x, z, new RNG(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSeed()).nextParallelRNG(3245).lmax());
|
generator.getHeight(x, z, new RNG(finalSeed).nextParallelRNG(3245).lmax()), "Gen: " + generator.getLoadKey());
|
||||||
}, "Gen: " + b.getLoadKey());
|
|
||||||
|
|
||||||
sender.sendMessage("Opening Noise Explorer for gen " + b.getLoadKey());
|
sender.sendMessage("Opening Noise Explorer for gen " + generator.getLoadKey() + " (" + generator.getLoader().getDataFolder().getName() + ")");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
else
|
{
|
||||||
{
|
sender.sendMessage("Invalid Generator");
|
||||||
sender.sendMessage("Invalid Generator");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -79,6 +73,6 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
|
|||||||
@Override
|
@Override
|
||||||
protected String getArgsUsage()
|
protected String getArgsUsage()
|
||||||
{
|
{
|
||||||
return "";
|
return "[generator]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,11 @@ package com.volmit.iris.manager.gui;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
@ -48,7 +47,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
|||||||
boolean colorMode = true;
|
boolean colorMode = true;
|
||||||
double scale = 1;
|
double scale = 1;
|
||||||
static boolean hd = false;
|
static boolean hd = false;
|
||||||
static double ascale = 10;
|
static double ascale = 1;
|
||||||
CNG cng = NoiseStyle.STATIC.create(new RNG(RNG.r.nextLong()));
|
CNG cng = NoiseStyle.STATIC.create(new RNG(RNG.r.nextLong()));
|
||||||
GroupedExecutor gx = new GroupedExecutor(Runtime.getRuntime().availableProcessors(), Thread.MAX_PRIORITY, "Iris Renderer");
|
GroupedExecutor gx = new GroupedExecutor(Runtime.getRuntime().availableProcessors(), Thread.MAX_PRIORITY, "Iris Renderer");
|
||||||
ReentrantLock l = new ReentrantLock();
|
ReentrantLock l = new ReentrantLock();
|
||||||
@ -58,22 +57,21 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
|||||||
static Function2<Double, Double, Double> generator;
|
static Function2<Double, Double, Double> generator;
|
||||||
static double oxp = 0;
|
static double oxp = 0;
|
||||||
static double ozp = 0;
|
static double ozp = 0;
|
||||||
double ox = 0;
|
double ox = 0; //Offset X
|
||||||
double oz = 0;
|
double oz = 0; //Offset Y
|
||||||
double mx = 0;
|
double mx = 0;
|
||||||
double mz = 0;
|
double mz = 0;
|
||||||
static double mxx = 0;
|
static double mxx = 0;
|
||||||
static double mzz = 0;
|
static double mzz = 0;
|
||||||
static boolean down = false;
|
static boolean down = false;
|
||||||
|
|
||||||
double lx = Double.MAX_VALUE;
|
double lx = Double.MAX_VALUE; //MouseX
|
||||||
double lz = Double.MAX_VALUE;
|
double lz = Double.MAX_VALUE; //MouseY
|
||||||
double tz = 1D;
|
int accuracy = 6;
|
||||||
double t = 1D;
|
|
||||||
|
|
||||||
public NoiseExplorer()
|
public NoiseExplorer()
|
||||||
{
|
{
|
||||||
addMouseWheelListener((MouseWheelListener) this);
|
addMouseWheelListener(this);
|
||||||
addMouseMotionListener(new MouseMotionListener()
|
addMouseMotionListener(new MouseMotionListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -105,7 +103,8 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
|||||||
int notches = e.getWheelRotation();
|
int notches = e.getWheelRotation();
|
||||||
if(e.isControlDown())
|
if(e.isControlDown())
|
||||||
{
|
{
|
||||||
t = t + ((0.0025 * t) * notches);
|
accuracy += notches > 0 ? 1 : -1;
|
||||||
|
if (accuracy < 3) accuracy = 3; //This limit is in place because the render lag of the GUI becomes immense when lower than 3
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,16 +125,6 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
|||||||
ascale += Math.abs(ascale - scale) * 0.16;
|
ascale += Math.abs(ascale - scale) * 0.16;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(t < tz)
|
|
||||||
{
|
|
||||||
tz -= Math.abs(t - tz) * 0.29;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(t > tz)
|
|
||||||
{
|
|
||||||
tz += Math.abs(tz - t) * 0.29;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ox < oxp)
|
if(ox < oxp)
|
||||||
{
|
{
|
||||||
oxp -= Math.abs(ox - oxp) * 0.16;
|
oxp -= Math.abs(ox - oxp) * 0.16;
|
||||||
@ -177,8 +166,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
int accuracy = hd ? 1 : M.clip((r.getAverage() / 6D), 1D, 128D).intValue();
|
int accuracy = hd ? 1 : this.accuracy;
|
||||||
accuracy = down ? accuracy * 4 : accuracy;
|
|
||||||
int v = 1000;
|
int v = 1000;
|
||||||
|
|
||||||
if(g instanceof Graphics2D)
|
if(g instanceof Graphics2D)
|
||||||
@ -206,7 +194,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
|||||||
int zz = z;
|
int zz = z;
|
||||||
gx.queue("a", () ->
|
gx.queue("a", () ->
|
||||||
{
|
{
|
||||||
double n = generator != null ? generator.apply(Double.valueOf((xx * ascale) + oxp), Double.valueOf((zz * ascale) + ozp)) : cng.noise((xx * ascale) + oxp, tz, (zz * ascale) + ozp);
|
double n = generator != null ? generator.apply((xx * ascale) + oxp, (zz * ascale) + ozp) : cng.noise((xx * ascale) + oxp, 100, (zz * ascale) + ozp);
|
||||||
|
|
||||||
if(n > 1 || n < 0)
|
if(n > 1 || n < 0)
|
||||||
{
|
{
|
||||||
@ -239,7 +227,6 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
|||||||
|
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
t += 1D;
|
|
||||||
r.put(p.getMilliseconds());
|
r.put(p.getMilliseconds());
|
||||||
|
|
||||||
if(!isVisible())
|
if(!isVisible())
|
||||||
@ -283,7 +270,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
|||||||
frame.setIconImage(ImageIO.read(file));
|
frame.setIconImage(ImageIO.read(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(IOException e)
|
catch(IOException ignored)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -301,15 +288,11 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
|||||||
combo = new JComboBox<String>(li.toArray(new String[li.size()]));
|
combo = new JComboBox<String>(li.toArray(new String[li.size()]));
|
||||||
combo.setSelectedItem("STATIC");
|
combo.setSelectedItem("STATIC");
|
||||||
combo.setFocusable(false);
|
combo.setFocusable(false);
|
||||||
combo.addActionListener(new ActionListener()
|
combo.addActionListener( e -> {
|
||||||
{
|
@SuppressWarnings("unchecked")
|
||||||
public void actionPerformed(ActionEvent e)
|
String b = (String) (((JComboBox<String>) e.getSource()).getSelectedItem());
|
||||||
{
|
NoiseStyle s = NoiseStyle.valueOf(b);
|
||||||
@SuppressWarnings("unchecked")
|
nv.cng = s.create(RNG.r.nextParallelRNG(RNG.r.imax()));
|
||||||
String b = (String) (((JComboBox<String>) e.getSource()).getSelectedItem());
|
|
||||||
NoiseStyle s = NoiseStyle.valueOf(b);
|
|
||||||
nv.cng = s.create(RNG.r.nextParallelRNG(RNG.r.imax()));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
combo.setSize(500, 30);
|
combo.setSize(500, 30);
|
||||||
@ -338,24 +321,12 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
|||||||
|
|
||||||
public static void launch(Function2<Double, Double, Double> gen, String genName)
|
public static void launch(Function2<Double, Double, Double> gen, String genName)
|
||||||
{
|
{
|
||||||
EventQueue.invokeLater(new Runnable()
|
EventQueue.invokeLater(() -> createAndShowGUI(gen, genName));
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
createAndShowGUI(gen, genName);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void launch()
|
public static void launch()
|
||||||
{
|
{
|
||||||
EventQueue.invokeLater(new Runnable()
|
EventQueue.invokeLater(() -> createAndShowGUI());
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
createAndShowGUI();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class HandScrollListener extends MouseAdapter
|
static class HandScrollListener extends MouseAdapter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user