mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-25 18:19:14 +00:00
Lint
This commit is contained in:
@@ -1,12 +1,19 @@
|
||||
package com.volmit.iris;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.volmit.iris.noise.CNG;
|
||||
@@ -17,13 +24,14 @@ import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import com.volmit.iris.util.RollingSequence;
|
||||
|
||||
public class NoiseView extends JPanel {
|
||||
public class NoiseView extends JPanel implements MouseWheelListener {
|
||||
|
||||
private static final long serialVersionUID = 2094606939770332040L;
|
||||
|
||||
static JComboBox<NoiseStyle> combo;
|
||||
RollingSequence r = new RollingSequence(60);
|
||||
boolean colorMode = true;
|
||||
CNG cng = NoiseStyle.SIMPLEX.create(new RNG(RNG.r.nextLong())).scale(0.25);
|
||||
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();
|
||||
@@ -35,11 +43,19 @@ public class NoiseView extends JPanel {
|
||||
for (int i = 0; i < 60; i++) {
|
||||
r.put(10000);
|
||||
}
|
||||
|
||||
addMouseWheelListener((MouseWheelListener) this);
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
int notches = e.getWheelRotation();
|
||||
cng.scale(cng.getScale() + ((0.05*cng.getScale())* notches));
|
||||
cng.scale(cng.getScale() < 0.00001 ? 0.00001 : cng.getScale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
int accuracy = M.clip(r.getAverage() / 13D, 1D, 128D).intValue();
|
||||
|
||||
@@ -60,7 +76,7 @@ public class NoiseView extends JPanel {
|
||||
int xx = x;
|
||||
gx.queue("a", () -> {
|
||||
for (int z = 0; z < getParent().getHeight(); z += accuracy) {
|
||||
double n = cng.noise(xx, Math.sin((double) M.ms() / 10000D) * 400D, z);
|
||||
double n = cng.noise(xx, Math.sin((double) M.ms() / 10000D) * 800D, z);
|
||||
|
||||
if (n > 1 || n < 0) {
|
||||
System.out.println("EXCEEDED " + n);
|
||||
@@ -88,7 +104,6 @@ public class NoiseView extends JPanel {
|
||||
|
||||
p.end();
|
||||
r.put(p.getMilliseconds());
|
||||
|
||||
EventQueue.invokeLater(() -> {
|
||||
repaint();
|
||||
});
|
||||
@@ -96,10 +111,24 @@ public class NoiseView extends JPanel {
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame frame = new JFrame("Iris");
|
||||
NoiseView nv = new NoiseView();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.add(new NoiseView());
|
||||
frame.setLocationByPlatform(true);
|
||||
frame.pack();
|
||||
combo = new JComboBox<NoiseStyle>(NoiseStyle.values());
|
||||
combo.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
NoiseStyle s = (NoiseStyle)(((JComboBox<NoiseStyle>)e.getSource()).getSelectedItem());
|
||||
nv.cng = s.create(RNG.r.nextParallelRNG(RNG.r.imax()));
|
||||
}
|
||||
});
|
||||
combo.setSize(500, 100);
|
||||
JLayeredPane pane = new JLayeredPane();
|
||||
nv.setSize(new Dimension(1440, 820));
|
||||
pane.add(nv, 1, 0);
|
||||
pane.add(combo, 2, 0);
|
||||
frame.add(pane);
|
||||
frame.setSize(1440, 820);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.volmit.iris.object.NoiseStyle;
|
||||
import com.volmit.iris.object.StructureTileCondition;
|
||||
import com.volmit.iris.util.ArrayType;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import com.volmit.iris.util.DependsOn;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.Form;
|
||||
import com.volmit.iris.util.IO;
|
||||
@@ -514,11 +515,31 @@ public class ProjectManager {
|
||||
return ws;
|
||||
}
|
||||
|
||||
public File getWorkspaceFile(String dim) {
|
||||
return Iris.instance.getDataFile("packs", dim, dim + ".code-workspace");
|
||||
}
|
||||
|
||||
public void updateWorkspace(File ws) {
|
||||
try {
|
||||
J.attemptAsync(() -> writeDocs(ws.getParentFile()));
|
||||
JSONObject j = new JSONObject(IO.readAll(ws));
|
||||
JSONObject s = j.getJSONObject("settings");
|
||||
JSONObject jc = new JSONObject();
|
||||
jc.put("editor.autoIndent", "brackets");
|
||||
jc.put("editor.acceptSuggestionOnEnter", "smart");
|
||||
jc.put("editor.cursorSmoothCaretAnimation", true);
|
||||
jc.put("editor.dragAndDrop", false);
|
||||
jc.put("files.trimTrailingWhitespace", true);
|
||||
jc.put("diffEditor.ignoreTrimWhitespace", true);
|
||||
jc.put("files.trimFinalNewlines", true);
|
||||
jc.put("editor.suggest.showKeywords", false);
|
||||
jc.put("editor.suggest.showSnippets", false);
|
||||
jc.put("editor.suggest.showWords", false);
|
||||
JSONObject st = new JSONObject();
|
||||
st.put("strings", true);
|
||||
jc.put("editor.quickSuggestions", st);
|
||||
jc.put("editor.suggest.insertMode", "replace");
|
||||
s.put("[json]", jc);
|
||||
s.put("json.schemas", buildSchemas());
|
||||
j.put("settings", s);
|
||||
IO.writeAll(ws, j.toString(4));
|
||||
@@ -589,11 +610,16 @@ public class ProjectManager {
|
||||
|
||||
JSONObject properties = new JSONObject();
|
||||
JSONArray req = new JSONArray();
|
||||
JSONObject deps = new JSONObject();
|
||||
|
||||
for (java.lang.reflect.Field k : i.getDeclaredFields()) {
|
||||
JSONObject prop = new JSONObject();
|
||||
|
||||
if (k.isAnnotationPresent(Desc.class)) {
|
||||
|
||||
if (k.isAnnotationPresent(DependsOn.class)) {
|
||||
deps.put(k.getName(), new JSONArray(k.getDeclaredAnnotation(DependsOn.class).value()));
|
||||
}
|
||||
|
||||
String tp = "object";
|
||||
|
||||
if (k.getType().equals(int.class) || k.getType().equals(long.class)) {
|
||||
@@ -672,6 +698,7 @@ public class ProjectManager {
|
||||
|
||||
if (tp.equals("object")) {
|
||||
if (k.getType().isAnnotationPresent(Desc.class)) {
|
||||
prop.put("additionalProperties", false);
|
||||
prop.put("properties",
|
||||
getSchemaFor(k.getType(), step - 1, def).getJSONObject("properties"));
|
||||
}
|
||||
@@ -778,8 +805,10 @@ public class ProjectManager {
|
||||
}
|
||||
}
|
||||
|
||||
schema.put("additionalProperties", false);
|
||||
schema.put("properties", properties);
|
||||
schema.put("required", req);
|
||||
schema.put("dependencies", deps);
|
||||
}
|
||||
|
||||
return schema;
|
||||
|
||||
@@ -5,8 +5,7 @@ import com.volmit.iris.util.Command;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisStudio extends MortarCommand
|
||||
{
|
||||
public class CommandIrisStudio extends MortarCommand {
|
||||
@Command
|
||||
private CommandIrisStudioCreate create;
|
||||
|
||||
@@ -18,31 +17,31 @@ public class CommandIrisStudio extends MortarCommand
|
||||
|
||||
@Command
|
||||
private CommandIrisStudioPackage pkg;
|
||||
|
||||
|
||||
@Command
|
||||
private CommandIrisStudioVerify verify;
|
||||
|
||||
@Command
|
||||
private CommandIrisStudioUpdate update;
|
||||
|
||||
@Command
|
||||
private CommandIrisStudioList list;
|
||||
|
||||
public CommandIrisStudio()
|
||||
{
|
||||
public CommandIrisStudio() {
|
||||
super("studio", "std");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setCategory("Studio");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
sender.sendMessage("Iris Studio Commands");
|
||||
printHelp(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[subcommand]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.volmit.iris.command;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisStudioUpdate extends MortarCommand {
|
||||
public CommandIrisStudioUpdate() {
|
||||
super("update", "upd");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Update your dimension project.");
|
||||
setCategory("Studio");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("/iris std package <DIMENSION>");
|
||||
return true;
|
||||
}
|
||||
|
||||
Iris.proj.updateWorkspace(Iris.proj.getWorkspaceFile(args[0]));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage() {
|
||||
return "[dimension]";
|
||||
}
|
||||
}
|
||||
@@ -311,4 +311,8 @@ public class CNG {
|
||||
oct = octaves;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getScale() {
|
||||
return scale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.volmit.iris.object;
|
||||
|
||||
import com.volmit.iris.util.DependsOn;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import com.volmit.iris.util.M;
|
||||
@@ -18,6 +19,7 @@ public class IrisAxisRotationClamp
|
||||
private boolean enabled = false;
|
||||
|
||||
@Required
|
||||
@DependsOn({"max"})
|
||||
@MinNumber(-360)
|
||||
@MaxNumber(360)
|
||||
@DontObfuscate
|
||||
@@ -25,6 +27,7 @@ public class IrisAxisRotationClamp
|
||||
private double min = 0;
|
||||
|
||||
@Required
|
||||
@DependsOn({"min"})
|
||||
@MinNumber(-360)
|
||||
@MaxNumber(360)
|
||||
@DontObfuscate
|
||||
@@ -32,6 +35,7 @@ public class IrisAxisRotationClamp
|
||||
private double max = 0;
|
||||
|
||||
@Required
|
||||
@DependsOn({"min", "max"})
|
||||
@MinNumber(0)
|
||||
@MaxNumber(360)
|
||||
@DontObfuscate
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.volmit.iris.gen.atomics.AtomicCache;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.noise.RarityCellGenerator;
|
||||
import com.volmit.iris.util.ArrayType;
|
||||
import com.volmit.iris.util.DependsOn;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import com.volmit.iris.util.IRare;
|
||||
@@ -39,11 +40,13 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
private KList<IrisEffect> effects = new KList<>();
|
||||
|
||||
@DontObfuscate
|
||||
@DependsOn({"biomeStyle", "biomeZoom", "biomeScatter"})
|
||||
@Desc("This changes the dispersion of the biome colors if multiple derivatives are chosen.")
|
||||
private NoiseStyle biomeStyle = NoiseStyle.SIMPLEX;
|
||||
|
||||
@MinNumber(0.0001)
|
||||
@DontObfuscate
|
||||
@DependsOn({"biomeStyle", "biomeZoom", "biomeScatter"})
|
||||
@Desc("This zooms in the biome colors if multiple derivatives are chosen")
|
||||
private double biomeZoom = 1;
|
||||
|
||||
@@ -73,6 +76,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
private KList<Biome> biomeSkyScatter = new KList<>();
|
||||
|
||||
@DontObfuscate
|
||||
@DependsOn({"children"})
|
||||
@Desc("If this biome has children biomes, and the gen layer chooses one of this biomes children, how much smaller will it be (inside of this biome). Higher values means a smaller biome relative to this biome's size. Set higher than 1.0 and below 3.0 for best results.")
|
||||
private double childShrinkFactor = 1.5;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.volmit.iris.gen.atomics.AtomicCache;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.util.ArrayType;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.DependsOn;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import com.volmit.iris.util.KList;
|
||||
@@ -28,6 +29,7 @@ public class IrisBiomeDecorator {
|
||||
@Desc("Dispersion is used to pick places to spawn. Scatter randomly places them (vanilla) or Wispy for a streak like patch system.")
|
||||
private NoiseStyle dispersion = NoiseStyle.STATIC;
|
||||
|
||||
@DependsOn({"stackMin", "stackMax"})
|
||||
@DontObfuscate
|
||||
@Desc("If this decorator has a height more than 1 this changes how it picks the height between your maxes. Scatter = random, Wispy = wavy heights")
|
||||
private NoiseStyle heightVariance = NoiseStyle.STATIC;
|
||||
@@ -36,12 +38,14 @@ public class IrisBiomeDecorator {
|
||||
@Desc("Tells iris where this decoration is a part of. I.e. SHORE_LINE or SEA_SURFACE")
|
||||
private DecorationPart partOf = DecorationPart.NONE;
|
||||
|
||||
@DependsOn({"stackMin", "stackMax"})
|
||||
@MinNumber(1)
|
||||
@MaxNumber(256)
|
||||
@DontObfuscate
|
||||
@Desc("The minimum repeat stack height (setting to 3 would stack 3 of <block> on top of each other")
|
||||
private int stackMin = 1;
|
||||
|
||||
@DependsOn({"stackMin", "stackMax"})
|
||||
@MinNumber(1)
|
||||
@MaxNumber(256)
|
||||
@DontObfuscate
|
||||
@@ -58,6 +62,7 @@ public class IrisBiomeDecorator {
|
||||
@Desc("The zoom is for zooming in or out variance. Makes patches have more or less of one type.")
|
||||
private double varianceZoom = 1;
|
||||
|
||||
@DependsOn({"stackMin", "stackMax"})
|
||||
@MinNumber(0.0001)
|
||||
@DontObfuscate
|
||||
@Desc("The vertical zoom is for wispy stack heights. Zooming this in makes stack heights more slowly change over a distance")
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.volmit.iris.object;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.ContextualChunkGenerator;
|
||||
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||
import com.volmit.iris.util.DependsOn;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
@@ -14,12 +15,12 @@ import lombok.Data;
|
||||
|
||||
@Desc("This represents a link to a generator for a biome")
|
||||
@Data
|
||||
public class IrisBiomeGeneratorLink
|
||||
{
|
||||
public class IrisBiomeGeneratorLink {
|
||||
@DontObfuscate
|
||||
@Desc("The generator id")
|
||||
private String generator = "default";
|
||||
|
||||
@DependsOn({ "min", "max" })
|
||||
@Required
|
||||
@MinNumber(-256)
|
||||
@MaxNumber(256)
|
||||
@@ -27,6 +28,7 @@ public class IrisBiomeGeneratorLink
|
||||
@Desc("The min block value (value + fluidHeight)")
|
||||
private int min = 0;
|
||||
|
||||
@DependsOn({ "min", "max" })
|
||||
@Required
|
||||
@MinNumber(-256)
|
||||
@MaxNumber(256)
|
||||
@@ -36,19 +38,16 @@ public class IrisBiomeGeneratorLink
|
||||
|
||||
private transient AtomicCache<IrisGenerator> gen = new AtomicCache<>();
|
||||
|
||||
public IrisBiomeGeneratorLink()
|
||||
{
|
||||
public IrisBiomeGeneratorLink() {
|
||||
|
||||
}
|
||||
|
||||
public IrisGenerator getCachedGenerator(ContextualChunkGenerator g)
|
||||
{
|
||||
return gen.aquire(() ->
|
||||
{
|
||||
IrisGenerator gen = g != null ? g.loadGenerator(getGenerator()) : Iris.globaldata.getGeneratorLoader().load(getGenerator());
|
||||
public IrisGenerator getCachedGenerator(ContextualChunkGenerator g) {
|
||||
return gen.aquire(() -> {
|
||||
IrisGenerator gen = g != null ? g.loadGenerator(getGenerator())
|
||||
: Iris.globaldata.getGeneratorLoader().load(getGenerator());
|
||||
|
||||
if(gen == null)
|
||||
{
|
||||
if (gen == null) {
|
||||
gen = new IrisGenerator();
|
||||
}
|
||||
|
||||
@@ -56,8 +55,7 @@ public class IrisBiomeGeneratorLink
|
||||
});
|
||||
}
|
||||
|
||||
public double getHeight(ContextualChunkGenerator xg, double x, double z, long seed)
|
||||
{
|
||||
public double getHeight(ContextualChunkGenerator xg, double x, double z, long seed) {
|
||||
double g = getCachedGenerator(xg).getHeight(x, z, seed);
|
||||
g = g < 0 ? 0 : g;
|
||||
g = g > 1 ? 1 : g;
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.volmit.iris.gen.atomics.AtomicCache;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.util.ArrayType;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.DependsOn;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import com.volmit.iris.util.KList;
|
||||
@@ -23,12 +24,14 @@ public class IrisBiomePaletteLayer {
|
||||
@Desc("The style of noise")
|
||||
private NoiseStyle style = NoiseStyle.STATIC;
|
||||
|
||||
@DependsOn({"minHeight", "maxHeight"})
|
||||
@MinNumber(0)
|
||||
@MaxNumber(256)
|
||||
@DontObfuscate
|
||||
@Desc("The min thickness of this layer")
|
||||
private int minHeight = 1;
|
||||
|
||||
@DependsOn({"minHeight", "maxHeight"})
|
||||
@MinNumber(1)
|
||||
@MaxNumber(256)
|
||||
@DontObfuscate
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.IrisChunkGenerator;
|
||||
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import com.volmit.iris.util.DependsOn;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import com.volmit.iris.util.MaxNumber;
|
||||
@@ -22,8 +23,7 @@ import lombok.Data;
|
||||
|
||||
@Desc("An iris effect")
|
||||
@Data
|
||||
public class IrisEffect
|
||||
{
|
||||
public class IrisEffect {
|
||||
@DontObfuscate
|
||||
@Desc("The potion effect to apply in this area")
|
||||
private String potionEffect = "";
|
||||
@@ -32,38 +32,45 @@ public class IrisEffect
|
||||
@Desc("The particle effect to apply in the area")
|
||||
private Particle particleEffect = null;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@MinNumber(-32)
|
||||
@MaxNumber(32)
|
||||
@DontObfuscate
|
||||
@Desc("Randomly offset from the surface to this surface+value")
|
||||
private int particleOffset = 0;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@DontObfuscate
|
||||
@Desc("The alt x, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double particleAltX = 0;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@DontObfuscate
|
||||
@Desc("The alt y, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double particleAltY = 0;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@DontObfuscate
|
||||
@Desc("The alt z, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double particleAltZ = 0;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@DontObfuscate
|
||||
@Desc("Randomize the altX by -altX to altX")
|
||||
private boolean randomAltX = true;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@DontObfuscate
|
||||
@Desc("Randomize the altY by -altY to altY")
|
||||
private boolean randomAltY = false;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@DontObfuscate
|
||||
@Desc("Randomize the altZ by -altZ to altZ")
|
||||
private boolean randomAltZ = true;
|
||||
@@ -72,63 +79,74 @@ public class IrisEffect
|
||||
@Desc("The sound to play")
|
||||
private Sound sound = null;
|
||||
|
||||
@DependsOn({ "sound" })
|
||||
@MinNumber(0)
|
||||
@MaxNumber(512)
|
||||
@DontObfuscate
|
||||
@Desc("The max distance from the player the sound will play")
|
||||
private int soundDistance = 12;
|
||||
|
||||
@DependsOn({ "sound", "maxPitch" })
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(1.99)
|
||||
@DontObfuscate
|
||||
@Desc("The minimum sound pitch")
|
||||
private double minPitch = 0.5D;
|
||||
|
||||
@DependsOn({ "sound", "minVolume" })
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(1.99)
|
||||
@DontObfuscate
|
||||
@Desc("The max sound pitch")
|
||||
private double maxPitch = 1.5D;
|
||||
|
||||
@DependsOn({ "sound" })
|
||||
@MinNumber(0.001)
|
||||
@MaxNumber(512)
|
||||
@DontObfuscate
|
||||
@Desc("The sound volume.")
|
||||
private double volume = 1.5D;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@MinNumber(0)
|
||||
@MaxNumber(512)
|
||||
@DontObfuscate
|
||||
@Desc("The particle count. Try setting to zero for using the alt xyz to a motion value instead of an offset")
|
||||
private int particleCount = 0;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@MinNumber(0)
|
||||
@MaxNumber(64)
|
||||
@DontObfuscate
|
||||
@Desc("How far away from the player particles can play")
|
||||
private int particleDistance = 20;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@MinNumber(0)
|
||||
@MaxNumber(128)
|
||||
@DontObfuscate
|
||||
@Desc("How wide the particles can play (player's view left and right) RADIUS")
|
||||
private int particleDistanceWidth = 24;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@DontObfuscate
|
||||
@Desc("An extra value for some particles... Which bukkit doesn't even document.")
|
||||
private double extra = 0;
|
||||
|
||||
@DependsOn({ "potionEffect" })
|
||||
@MinNumber(-1)
|
||||
@MaxNumber(1024)
|
||||
@DontObfuscate
|
||||
@Desc("The Potion Strength or -1 to disable")
|
||||
private int potionStrength = -1;
|
||||
|
||||
@DependsOn({ "potionEffect", "potionTicksMin" })
|
||||
@MinNumber(1)
|
||||
@DontObfuscate
|
||||
@Desc("The max time the potion will last for")
|
||||
private int potionTicksMax = 155;
|
||||
|
||||
@DependsOn({ "potionEffect", "potionTicksMax" })
|
||||
@MinNumber(1)
|
||||
@DontObfuscate
|
||||
@Desc("The min time the potion will last for")
|
||||
@@ -140,6 +158,7 @@ public class IrisEffect
|
||||
@Desc("The effect interval in milliseconds")
|
||||
private int interval = 150;
|
||||
|
||||
@DependsOn({ "particleEffect" })
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@DontObfuscate
|
||||
@@ -155,33 +174,25 @@ public class IrisEffect
|
||||
private transient AtomicCache<PotionEffectType> pt = new AtomicCache<>();
|
||||
private transient AtomicCache<ChronoLatch> latch = new AtomicCache<>();
|
||||
|
||||
public IrisEffect()
|
||||
{
|
||||
public IrisEffect() {
|
||||
|
||||
}
|
||||
|
||||
public boolean canTick()
|
||||
{
|
||||
public boolean canTick() {
|
||||
return latch.aquire(() -> new ChronoLatch(interval)).flip();
|
||||
}
|
||||
|
||||
public PotionEffectType getRealType()
|
||||
{
|
||||
return pt.aquire(() ->
|
||||
{
|
||||
public PotionEffectType getRealType() {
|
||||
return pt.aquire(() -> {
|
||||
PotionEffectType t = PotionEffectType.LUCK;
|
||||
|
||||
if(getPotionEffect().isEmpty())
|
||||
{
|
||||
if (getPotionEffect().isEmpty()) {
|
||||
return t;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
for(PotionEffectType i : PotionEffectType.values())
|
||||
{
|
||||
if(i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect()))
|
||||
{
|
||||
try {
|
||||
for (PotionEffectType i : PotionEffectType.values()) {
|
||||
if (i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) {
|
||||
t = i;
|
||||
|
||||
return t;
|
||||
@@ -189,8 +200,7 @@ public class IrisEffect
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
catch (Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -200,55 +210,57 @@ public class IrisEffect
|
||||
});
|
||||
}
|
||||
|
||||
public void apply(Player p, IrisChunkGenerator g)
|
||||
{
|
||||
if(!canTick())
|
||||
{
|
||||
public void apply(Player p, IrisChunkGenerator g) {
|
||||
if (!canTick()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(RNG.r.nextInt(chance) != 0)
|
||||
{
|
||||
if (RNG.r.nextInt(chance) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(sound != null)
|
||||
{
|
||||
Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance));
|
||||
if (sound != null) {
|
||||
Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance),
|
||||
RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance));
|
||||
p.playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch));
|
||||
}
|
||||
|
||||
if(particleEffect != null)
|
||||
{
|
||||
Location part = p.getLocation().clone().add(p.getLocation().getDirection().clone().multiply(RNG.r.i(particleDistance) + particleAway)).clone().add(p.getLocation().getDirection().clone().rotateAroundY(Math.toRadians(90)).multiply(RNG.r.d(-particleDistanceWidth, particleDistanceWidth)));
|
||||
if (particleEffect != null) {
|
||||
Location part = p.getLocation().clone()
|
||||
.add(p.getLocation().getDirection().clone().multiply(RNG.r.i(particleDistance) + particleAway))
|
||||
.clone().add(p.getLocation().getDirection().clone().rotateAroundY(Math.toRadians(90))
|
||||
.multiply(RNG.r.d(-particleDistanceWidth, particleDistanceWidth)));
|
||||
|
||||
part.setY(Math.round(g.getTerrainHeight(part.getBlockX(), part.getBlockZ())) + 1);
|
||||
part.add(RNG.r.d(), 0, RNG.r.d());
|
||||
if(extra != 0)
|
||||
{
|
||||
p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(), particleCount, randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ, extra);
|
||||
if (extra != 0) {
|
||||
p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(),
|
||||
particleCount, randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ, extra);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(), particleCount, randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ);
|
||||
else {
|
||||
p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(),
|
||||
particleCount, randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ);
|
||||
}
|
||||
}
|
||||
|
||||
if(potionStrength > -1)
|
||||
{
|
||||
if(p.hasPotionEffect(getRealType()))
|
||||
{
|
||||
if (potionStrength > -1) {
|
||||
if (p.hasPotionEffect(getRealType())) {
|
||||
PotionEffect e = p.getPotionEffect(getRealType());
|
||||
if(e.getAmplifier() > getPotionStrength())
|
||||
{
|
||||
if (e.getAmplifier() > getPotionStrength()) {
|
||||
return;
|
||||
}
|
||||
|
||||
p.removePotionEffect(getRealType());
|
||||
}
|
||||
|
||||
p.addPotionEffect(new PotionEffect(getRealType(), RNG.r.i(Math.min(potionTicksMax, potionTicksMin), Math.max(potionTicksMax, potionTicksMin)), getPotionStrength(), true, false, false));
|
||||
p.addPotionEffect(new PotionEffect(getRealType(),
|
||||
RNG.r.i(Math.min(potionTicksMax, potionTicksMin), Math.max(potionTicksMax, potionTicksMin)),
|
||||
getPotionStrength(), true, false, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ public class IrisNoiseGenerator
|
||||
@Desc("Enable / disable. Outputs offsetY if disabled")
|
||||
private boolean enabled = true;
|
||||
|
||||
@Required
|
||||
@DontObfuscate
|
||||
@Desc("The Noise Style")
|
||||
private NoiseStyle style = NoiseStyle.IRIS;
|
||||
|
||||
13
src/main/java/com/volmit/iris/util/DependsOn.java
Normal file
13
src/main/java/com/volmit/iris/util/DependsOn.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@Target({ FIELD })
|
||||
public @interface DependsOn {
|
||||
String[] value();
|
||||
}
|
||||
Reference in New Issue
Block a user