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
|
||||
private CommandIrisStudioExplorer exp;
|
||||
|
||||
@Command
|
||||
private CommandIrisStudioExplorerGenerator generator;
|
||||
|
||||
@Command
|
||||
private CommandIrisStudioLoot loot;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.volmit.iris.manager.command.studio;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.manager.gui.NoiseExplorer;
|
||||
import com.volmit.iris.object.IrisGenerator;
|
||||
import com.volmit.iris.util.KList;
|
||||
@ -14,7 +15,7 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
|
||||
public CommandIrisStudioExplorerGenerator()
|
||||
{
|
||||
super("generator", "gen", "g");
|
||||
setDescription("Explore different generators");
|
||||
setDescription("Preview created noise noises generators");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setCategory("World");
|
||||
}
|
||||
@ -39,38 +40,31 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!Iris.proj.isProjectOpen())
|
||||
{
|
||||
sender.sendMessage("No project is open");
|
||||
return true;
|
||||
}
|
||||
IrisGenerator generator;
|
||||
long seed = 12345;
|
||||
|
||||
if(args.length == 0)
|
||||
if (Iris.proj.isProjectOpen())
|
||||
{
|
||||
sender.sendMessage("Provide a generator name");
|
||||
return true;
|
||||
generator = Iris.proj.getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(args[0]);
|
||||
seed = Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSeed();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
String g = args[0];
|
||||
IrisGenerator b = Iris.proj.getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(g);
|
||||
generator = IrisDataManager.loadAnyGenerator(args[0]);
|
||||
}
|
||||
|
||||
if(b != null)
|
||||
{
|
||||
NoiseExplorer.launch((x, z) ->
|
||||
{
|
||||
return b.getHeight(x, z, new RNG(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSeed()).nextParallelRNG(3245).lmax());
|
||||
}, "Gen: " + b.getLoadKey());
|
||||
if (generator != null)
|
||||
{
|
||||
long finalSeed = seed;
|
||||
NoiseExplorer.launch((x, z) ->
|
||||
generator.getHeight(x, z, new RNG(finalSeed).nextParallelRNG(3245).lmax()), "Gen: " + generator.getLoadKey());
|
||||
|
||||
sender.sendMessage("Opening Noise Explorer for gen " + b.getLoadKey());
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
sender.sendMessage("Invalid Generator");
|
||||
}
|
||||
sender.sendMessage("Opening Noise Explorer for gen " + generator.getLoadKey() + " (" + generator.getLoader().getDataFolder().getName() + ")");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage("Invalid Generator");
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -79,6 +73,6 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "";
|
||||
return "[generator]";
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,11 @@ package com.volmit.iris.manager.gui;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
@ -48,7 +47,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
||||
boolean colorMode = true;
|
||||
double scale = 1;
|
||||
static boolean hd = false;
|
||||
static double ascale = 10;
|
||||
static double ascale = 1;
|
||||
CNG cng = NoiseStyle.STATIC.create(new RNG(RNG.r.nextLong()));
|
||||
GroupedExecutor gx = new GroupedExecutor(Runtime.getRuntime().availableProcessors(), Thread.MAX_PRIORITY, "Iris Renderer");
|
||||
ReentrantLock l = new ReentrantLock();
|
||||
@ -58,22 +57,21 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
||||
static Function2<Double, Double, Double> generator;
|
||||
static double oxp = 0;
|
||||
static double ozp = 0;
|
||||
double ox = 0;
|
||||
double oz = 0;
|
||||
double ox = 0; //Offset X
|
||||
double oz = 0; //Offset Y
|
||||
double mx = 0;
|
||||
double mz = 0;
|
||||
static double mxx = 0;
|
||||
static double mzz = 0;
|
||||
static boolean down = false;
|
||||
|
||||
double lx = Double.MAX_VALUE;
|
||||
double lz = Double.MAX_VALUE;
|
||||
double tz = 1D;
|
||||
double t = 1D;
|
||||
double lx = Double.MAX_VALUE; //MouseX
|
||||
double lz = Double.MAX_VALUE; //MouseY
|
||||
int accuracy = 6;
|
||||
|
||||
public NoiseExplorer()
|
||||
{
|
||||
addMouseWheelListener((MouseWheelListener) this);
|
||||
addMouseWheelListener(this);
|
||||
addMouseMotionListener(new MouseMotionListener()
|
||||
{
|
||||
@Override
|
||||
@ -105,7 +103,8 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
||||
int notches = e.getWheelRotation();
|
||||
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;
|
||||
}
|
||||
|
||||
@ -126,16 +125,6 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
||||
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)
|
||||
{
|
||||
oxp -= Math.abs(ox - oxp) * 0.16;
|
||||
@ -177,8 +166,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
int accuracy = hd ? 1 : M.clip((r.getAverage() / 6D), 1D, 128D).intValue();
|
||||
accuracy = down ? accuracy * 4 : accuracy;
|
||||
int accuracy = hd ? 1 : this.accuracy;
|
||||
int v = 1000;
|
||||
|
||||
if(g instanceof Graphics2D)
|
||||
@ -206,7 +194,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
||||
int zz = z;
|
||||
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)
|
||||
{
|
||||
@ -239,7 +227,6 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
||||
|
||||
p.end();
|
||||
|
||||
t += 1D;
|
||||
r.put(p.getMilliseconds());
|
||||
|
||||
if(!isVisible())
|
||||
@ -283,7 +270,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
||||
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.setSelectedItem("STATIC");
|
||||
combo.setFocusable(false);
|
||||
combo.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
String b = (String) (((JComboBox<String>) e.getSource()).getSelectedItem());
|
||||
NoiseStyle s = NoiseStyle.valueOf(b);
|
||||
nv.cng = s.create(RNG.r.nextParallelRNG(RNG.r.imax()));
|
||||
}
|
||||
combo.addActionListener( e -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
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);
|
||||
@ -338,24 +321,12 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
||||
|
||||
public static void launch(Function2<Double, Double, Double> gen, String genName)
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
createAndShowGUI(gen, genName);
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(() -> createAndShowGUI(gen, genName));
|
||||
}
|
||||
|
||||
public static void launch()
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(() -> createAndShowGUI());
|
||||
}
|
||||
|
||||
static class HandScrollListener extends MouseAdapter
|
||||
|
Loading…
x
Reference in New Issue
Block a user