From 8586ec67b69e3d6010684117d80a8df545d058ce Mon Sep 17 00:00:00 2001 From: Dan Macbook Date: Thu, 13 Aug 2020 10:45:59 -0400 Subject: [PATCH] Lint --- src/main/java/com/volmit/iris/NoiseView.java | 45 ++++++-- .../java/com/volmit/iris/ProjectManager.java | 31 +++++- .../iris/command/CommandIrisStudio.java | 17 ++- .../iris/command/CommandIrisStudioUpdate.java | 31 ++++++ src/main/java/com/volmit/iris/noise/CNG.java | 4 + .../iris/object/IrisAxisRotationClamp.java | 4 + .../com/volmit/iris/object/IrisBiome.java | 4 + .../iris/object/IrisBiomeDecorator.java | 5 + .../iris/object/IrisBiomeGeneratorLink.java | 24 ++--- .../iris/object/IrisBiomePaletteLayer.java | 3 + .../com/volmit/iris/object/IrisEffect.java | 102 ++++++++++-------- .../iris/object/IrisNoiseGenerator.java | 1 + .../java/com/volmit/iris/util/DependsOn.java | 13 +++ 13 files changed, 208 insertions(+), 76 deletions(-) create mode 100644 src/main/java/com/volmit/iris/command/CommandIrisStudioUpdate.java create mode 100644 src/main/java/com/volmit/iris/util/DependsOn.java diff --git a/src/main/java/com/volmit/iris/NoiseView.java b/src/main/java/com/volmit/iris/NoiseView.java index df74e0494..6deb26a7b 100644 --- a/src/main/java/com/volmit/iris/NoiseView.java +++ b/src/main/java/com/volmit/iris/NoiseView.java @@ -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 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.values()); + combo.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + @SuppressWarnings("unchecked") + NoiseStyle s = (NoiseStyle)(((JComboBox)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); } diff --git a/src/main/java/com/volmit/iris/ProjectManager.java b/src/main/java/com/volmit/iris/ProjectManager.java index e30595ba6..7136a77bc 100644 --- a/src/main/java/com/volmit/iris/ProjectManager.java +++ b/src/main/java/com/volmit/iris/ProjectManager.java @@ -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; diff --git a/src/main/java/com/volmit/iris/command/CommandIrisStudio.java b/src/main/java/com/volmit/iris/command/CommandIrisStudio.java index 944fc8fb5..3dc8b2bda 100644 --- a/src/main/java/com/volmit/iris/command/CommandIrisStudio.java +++ b/src/main/java/com/volmit/iris/command/CommandIrisStudio.java @@ -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]"; } } diff --git a/src/main/java/com/volmit/iris/command/CommandIrisStudioUpdate.java b/src/main/java/com/volmit/iris/command/CommandIrisStudioUpdate.java new file mode 100644 index 000000000..6cb13643e --- /dev/null +++ b/src/main/java/com/volmit/iris/command/CommandIrisStudioUpdate.java @@ -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 "); + return true; + } + + Iris.proj.updateWorkspace(Iris.proj.getWorkspaceFile(args[0])); + + return true; + } + + @Override + protected String getArgsUsage() { + return "[dimension]"; + } +} diff --git a/src/main/java/com/volmit/iris/noise/CNG.java b/src/main/java/com/volmit/iris/noise/CNG.java index 4b46a7d10..161e9b156 100644 --- a/src/main/java/com/volmit/iris/noise/CNG.java +++ b/src/main/java/com/volmit/iris/noise/CNG.java @@ -311,4 +311,8 @@ public class CNG { oct = octaves; return this; } + + public double getScale() { + return scale; + } } diff --git a/src/main/java/com/volmit/iris/object/IrisAxisRotationClamp.java b/src/main/java/com/volmit/iris/object/IrisAxisRotationClamp.java index 8faac41aa..7292883f9 100644 --- a/src/main/java/com/volmit/iris/object/IrisAxisRotationClamp.java +++ b/src/main/java/com/volmit/iris/object/IrisAxisRotationClamp.java @@ -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 diff --git a/src/main/java/com/volmit/iris/object/IrisBiome.java b/src/main/java/com/volmit/iris/object/IrisBiome.java index 41901cb6d..608f97fa9 100644 --- a/src/main/java/com/volmit/iris/object/IrisBiome.java +++ b/src/main/java/com/volmit/iris/object/IrisBiome.java @@ -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 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 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; diff --git a/src/main/java/com/volmit/iris/object/IrisBiomeDecorator.java b/src/main/java/com/volmit/iris/object/IrisBiomeDecorator.java index 3082c439e..c7abc70c5 100644 --- a/src/main/java/com/volmit/iris/object/IrisBiomeDecorator.java +++ b/src/main/java/com/volmit/iris/object/IrisBiomeDecorator.java @@ -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 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") diff --git a/src/main/java/com/volmit/iris/object/IrisBiomeGeneratorLink.java b/src/main/java/com/volmit/iris/object/IrisBiomeGeneratorLink.java index f59b60d08..a5754a009 100644 --- a/src/main/java/com/volmit/iris/object/IrisBiomeGeneratorLink.java +++ b/src/main/java/com/volmit/iris/object/IrisBiomeGeneratorLink.java @@ -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 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; diff --git a/src/main/java/com/volmit/iris/object/IrisBiomePaletteLayer.java b/src/main/java/com/volmit/iris/object/IrisBiomePaletteLayer.java index 23ad8b7b7..845a248ee 100644 --- a/src/main/java/com/volmit/iris/object/IrisBiomePaletteLayer.java +++ b/src/main/java/com/volmit/iris/object/IrisBiomePaletteLayer.java @@ -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 diff --git a/src/main/java/com/volmit/iris/object/IrisEffect.java b/src/main/java/com/volmit/iris/object/IrisEffect.java index db6dda29e..f0b5a70fb 100644 --- a/src/main/java/com/volmit/iris/object/IrisEffect.java +++ b/src/main/java/com/volmit/iris/object/IrisEffect.java @@ -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 pt = new AtomicCache<>(); private transient AtomicCache 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)); } } } diff --git a/src/main/java/com/volmit/iris/object/IrisNoiseGenerator.java b/src/main/java/com/volmit/iris/object/IrisNoiseGenerator.java index 0a5bfb79e..1d22f15ea 100644 --- a/src/main/java/com/volmit/iris/object/IrisNoiseGenerator.java +++ b/src/main/java/com/volmit/iris/object/IrisNoiseGenerator.java @@ -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; diff --git a/src/main/java/com/volmit/iris/util/DependsOn.java b/src/main/java/com/volmit/iris/util/DependsOn.java new file mode 100644 index 000000000..83dd51417 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/DependsOn.java @@ -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(); +}