Cleanup SRC

This commit is contained in:
Daniel Mills
2021-07-14 02:34:13 -04:00
parent f29015426f
commit 6ca6fc6989
605 changed files with 53283 additions and 64305 deletions
+91 -193
View File
@@ -1,18 +1,15 @@
package com.volmit.iris; package com.volmit.iris;
import com.google.gson.Gson;
import com.volmit.iris.manager.*; import com.volmit.iris.manager.*;
import com.volmit.iris.manager.command.CommandIris; import com.volmit.iris.manager.command.CommandIris;
import com.volmit.iris.manager.command.world.CommandLocate;
import com.volmit.iris.manager.command.PermissionIris; import com.volmit.iris.manager.command.PermissionIris;
import com.volmit.iris.manager.command.world.CommandLocate;
import com.volmit.iris.manager.link.BKLink; import com.volmit.iris.manager.link.BKLink;
import com.volmit.iris.manager.link.CitizensLink; import com.volmit.iris.manager.link.CitizensLink;
import com.volmit.iris.manager.link.MultiverseCoreLink; import com.volmit.iris.manager.link.MultiverseCoreLink;
import com.volmit.iris.manager.link.MythicMobsLink; import com.volmit.iris.manager.link.MythicMobsLink;
import com.volmit.iris.nms.INMS; import com.volmit.iris.nms.INMS;
import com.volmit.iris.object.IrisCompat; import com.volmit.iris.object.IrisCompat;
import com.volmit.iris.object.IrisObject;
import com.volmit.iris.object.IrisObjectPlacement;
import com.volmit.iris.scaffold.IrisWorlds; import com.volmit.iris.scaffold.IrisWorlds;
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator; import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
import com.volmit.iris.util.*; import com.volmit.iris.util.*;
@@ -21,20 +18,19 @@ import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.io.*; import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.List;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
public class Iris extends VolmitPlugin implements Listener public class Iris extends VolmitPlugin implements Listener {
{
public static KList<GroupedExecutor> executors = new KList<>(); public static KList<GroupedExecutor> executors = new KList<>();
public static Iris instance; public static Iris instance;
public static ProjectManager proj; public static ProjectManager proj;
@@ -60,20 +56,17 @@ public class Iris extends VolmitPlugin implements Listener
@com.volmit.iris.util.Command @com.volmit.iris.util.Command
public CommandIris commandIris; public CommandIris commandIris;
public Iris() public Iris() {
{
instance = this; instance = this;
INMS.get(); INMS.get();
IO.delete(new File("iris")); IO.delete(new File("iris"));
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4; lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4;
} }
public static int getThreadCount() public static int getThreadCount() {
{
int tc = IrisSettings.get().getConcurrency().getThreadCount(); int tc = IrisSettings.get().getConcurrency().getThreadCount();
if(tc <= 0) if (tc <= 0) {
{
int p = Runtime.getRuntime().availableProcessors(); int p = Runtime.getRuntime().availableProcessors();
return p > 16 ? 16 : p < 4 ? 4 : p; return p > 16 ? 16 : p < 4 ? 4 : p;
@@ -82,51 +75,36 @@ public class Iris extends VolmitPlugin implements Listener
return tc; return tc;
} }
private static boolean doesSupport3DBiomes() private static boolean doesSupport3DBiomes() {
{ try {
try
{
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
return v >= 15; return v >= 15;
} } catch (Throwable e) {
catch(Throwable e)
{
} }
return false; return false;
} }
private static boolean doesSupportCustomModels() private static boolean doesSupportCustomModels() {
{ try {
try
{
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
return v >= 14; return v >= 14;
} } catch (Throwable e) {
catch(Throwable e)
{
} }
return false; return false;
} }
private static boolean doesSupportAwareness() private static boolean doesSupportAwareness() {
{ try {
try
{
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
return v >= 15; return v >= 15;
} } catch (Throwable e) {
catch(Throwable e)
{
} }
@@ -134,25 +112,21 @@ public class Iris extends VolmitPlugin implements Listener
} }
@Override @Override
public void start() public void start() {
{
} }
@Override @Override
public void stop() public void stop() {
{
} }
@Override @Override
public String getTag(String subTag) public String getTag(String subTag) {
{
return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.GREEN + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": "; return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.GREEN + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": ";
} }
public void onEnable() public void onEnable() {
{
instance = this; instance = this;
try { try {
compat = IrisCompat.configured(getDataFile("compat.json")); compat = IrisCompat.configured(getDataFile("compat.json"));
@@ -181,8 +155,7 @@ public class Iris extends VolmitPlugin implements Listener
} }
private void checkConfigHotload() { private void checkConfigHotload() {
if(configWatcher.checkModified()) if (configWatcher.checkModified()) {
{
IrisSettings.invalidate(); IrisSettings.invalidate();
IrisSettings.get(); IrisSettings.get();
configWatcher.checkModified(); configWatcher.checkModified();
@@ -190,22 +163,17 @@ public class Iris extends VolmitPlugin implements Listener
} }
} }
public void onDisable() public void onDisable() {
{ if (IrisSettings.get().isStudio()) {
if(IrisSettings.get().isStudio())
{
proj.close(); proj.close();
for(World i : Bukkit.getWorlds()) for (World i : Bukkit.getWorlds()) {
{ if (IrisWorlds.isIrisWorld(i)) {
if(IrisWorlds.isIrisWorld(i))
{
IrisWorlds.access(i).close(); IrisWorlds.access(i).close();
} }
} }
for(GroupedExecutor i : executors) for (GroupedExecutor i : executors) {
{
i.close(); i.close();
} }
} }
@@ -217,44 +185,32 @@ public class Iris extends VolmitPlugin implements Listener
super.onDisable(); super.onDisable();
} }
public static void sq(Runnable r) public static void sq(Runnable r) {
{ synchronized (syncJobs) {
synchronized(syncJobs)
{
syncJobs.queue(r); syncJobs.queue(r);
} }
} }
private void tickQueue() private void tickQueue() {
{ synchronized (Iris.syncJobs) {
synchronized(Iris.syncJobs) if (!Iris.syncJobs.hasNext()) {
{
if(!Iris.syncJobs.hasNext())
{
return; return;
} }
long ms = M.ms(); long ms = M.ms();
while(Iris.syncJobs.hasNext() && M.ms() - ms < 25) while (Iris.syncJobs.hasNext() && M.ms() - ms < 25) {
{ try {
try
{
Iris.syncJobs.next().run(); Iris.syncJobs.next().run();
} } catch (Throwable e) {
catch(Throwable e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
} }
private void bstats() private void bstats() {
{ if (IrisSettings.get().getGeneral().isPluginMetrics()) {
if(IrisSettings.get().getGeneral().isPluginMetrics())
{
J.s(() -> { J.s(() -> {
Metrics m = new Metrics(Iris.instance, 8757); Metrics m = new Metrics(Iris.instance, 8757);
@@ -275,31 +231,25 @@ public class Iris extends VolmitPlugin implements Listener
} }
} }
public static File getTemp() public static File getTemp() {
{
return instance.getDataFolder("cache", "temp"); return instance.getDataFolder("cache", "temp");
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
{
return super.onCommand(sender, command, label, args); return super.onCommand(sender, command, label, args);
} }
public void imsg(CommandSender s, String msg) public void imsg(CommandSender s, String msg) {
{
s.sendMessage(C.GREEN + "[" + C.DARK_GRAY + "Iris" + C.GREEN + "]" + C.GRAY + ": " + msg); s.sendMessage(C.GREEN + "[" + C.DARK_GRAY + "Iris" + C.GREEN + "]" + C.GRAY + ": " + msg);
} }
@Override @Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
{
String dimension = IrisSettings.get().getGenerator().getDefaultWorldType(); String dimension = IrisSettings.get().getGenerator().getDefaultWorldType();
if(id != null && !id.isEmpty()) if (id != null && !id.isEmpty()) {
{
dimension = id; dimension = id;
Iris.info("Generator ID: " + id + " requested by bukkit/plugin. Assuming IrisDimension: " + id); Iris.info("Generator ID: " + id + " requested by bukkit/plugin. Assuming IrisDimension: " + id);
} }
@@ -307,46 +257,33 @@ public class Iris extends VolmitPlugin implements Listener
return new EngineCompositeGenerator(dimension, true); return new EngineCompositeGenerator(dimension, true);
} }
public static void msg(String string) public static void msg(String string) {
{ try {
try if (instance == null) {
{
if(instance == null)
{
System.out.println("[Iris]: " + string); System.out.println("[Iris]: " + string);
return; return;
} }
String msg = C.GRAY + "[" + C.GREEN + "Iris" + C.GRAY + "]: " + string; String msg = C.GRAY + "[" + C.GREEN + "Iris" + C.GRAY + "]: " + string;
Bukkit.getConsoleSender().sendMessage(msg); Bukkit.getConsoleSender().sendMessage(msg);
} } catch (Throwable e) {
catch(Throwable e)
{
System.out.println("[Iris]: " + string); System.out.println("[Iris]: " + string);
} }
} }
public static File getCached(String name, String url) public static File getCached(String name, String url) {
{
String h = IO.hash(name + "@" + url); String h = IO.hash(name + "@" + url);
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h); File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
if(!f.exists()) if (!f.exists()) {
{ try (BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) {
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f))
{
byte[] dataBuffer = new byte[1024]; byte[] dataBuffer = new byte[1024];
int bytesRead; int bytesRead;
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
{
fileOutputStream.write(dataBuffer, 0, bytesRead); fileOutputStream.write(dataBuffer, 0, bytesRead);
Iris.verbose("Aquiring " + name); Iris.verbose("Aquiring " + name);
} }
} } catch (IOException ignored) {
catch(IOException ignored)
{
} }
} }
@@ -354,107 +291,78 @@ public class Iris extends VolmitPlugin implements Listener
return f.exists() ? f : null; return f.exists() ? f : null;
} }
public static String getNonCached(String name, String url) public static String getNonCached(String name, String url) {
{
String h = IO.hash(name + "*" + url); String h = IO.hash(name + "*" + url);
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h); File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) try (BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) {
{
byte[] dataBuffer = new byte[1024]; byte[] dataBuffer = new byte[1024];
int bytesRead; int bytesRead;
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
{
fileOutputStream.write(dataBuffer, 0, bytesRead); fileOutputStream.write(dataBuffer, 0, bytesRead);
} }
} } catch (IOException ignored) {
catch(IOException ignored)
{
} }
try try {
{
return IO.readAll(f); return IO.readAll(f);
} } catch (IOException ignored) {
catch(IOException ignored)
{
} }
return ""; return "";
} }
public static File getNonCachedFile(String name, String url) public static File getNonCachedFile(String name, String url) {
{
String h = IO.hash(name + "*" + url); String h = IO.hash(name + "*" + url);
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h); File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
Iris.verbose("Download " + name + " -> " + url); Iris.verbose("Download " + name + " -> " + url);
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) try (BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) {
{
byte[] dataBuffer = new byte[1024]; byte[] dataBuffer = new byte[1024];
int bytesRead; int bytesRead;
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
{
fileOutputStream.write(dataBuffer, 0, bytesRead); fileOutputStream.write(dataBuffer, 0, bytesRead);
} }
} } catch (IOException e) {
catch(IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
return f; return f;
} }
public static void warn(String string) public static void warn(String string) {
{
msg(C.YELLOW + string); msg(C.YELLOW + string);
} }
public static void error(String string) public static void error(String string) {
{
msg(C.RED + string); msg(C.RED + string);
} }
public static void verbose(String string) public static void verbose(String string) {
{ try {
try if (IrisSettings.get().getGeneral().isVerbose()) {
{ msg(C.GRAY + string);
if(IrisSettings.get().getGeneral().isVerbose()) }
{ } catch (Throwable e) {
msg(C.GRAY + string); msg(C.GRAY + string);
} }
} }
catch(Throwable e) public static void success(String string) {
{
msg(C.GRAY + string);
}
}
public static void success(String string)
{
msg(C.GREEN + string); msg(C.GREEN + string);
} }
public static void info(String string) public static void info(String string) {
{
msg(C.WHITE + string); msg(C.WHITE + string);
} }
public void hit(long hits2) public void hit(long hits2) {
{
board.hits.put(hits2); board.hits.put(hits2);
} }
public void splash() public void splash() {
{ if (!IrisSettings.get().getGeneral().isSplashLogoStartup()) {
if(!IrisSettings.get().getGeneral().isSplashLogoStartup())
{
return; return;
} }
@@ -469,60 +377,47 @@ public class Iris extends VolmitPlugin implements Listener
Iris.info("Server type & version: " + Bukkit.getVersion()); Iris.info("Server type & version: " + Bukkit.getVersion());
Iris.info("Bukkit version: " + Bukkit.getBukkitVersion()); Iris.info("Bukkit version: " + Bukkit.getBukkitVersion());
Iris.info("Java version: " + getJavaVersion()); Iris.info("Java version: " + getJavaVersion());
for(int i = 0; i < info.length; i++) for (int i = 0; i < info.length; i++) {
{
splash[i] += info[i]; splash[i] += info[i];
} }
Iris.info("\n\n " + new KList<>(splash).toString("\n") + "\n"); Iris.info("\n\n " + new KList<>(splash).toString("\n") + "\n");
if(lowMemoryMode) if (lowMemoryMode) {
{
Iris.verbose("* Low Memory mode Activated! For better performance, allocate 4gb or more to this server."); Iris.verbose("* Low Memory mode Activated! For better performance, allocate 4gb or more to this server.");
} }
if(!biome3d) if (!biome3d) {
{
Iris.verbose("* This version of minecraft does not support 3D biomes (1.15 and up). Iris will generate as normal, but biome colors will not vary underground & in the sky."); Iris.verbose("* This version of minecraft does not support 3D biomes (1.15 and up). Iris will generate as normal, but biome colors will not vary underground & in the sky.");
} }
if(!customModels) if (!customModels) {
{
Iris.verbose("* This version of minecraft does not support custom model data in loot items (1.14 and up). Iris will generate as normal, but loot will not have custom models."); Iris.verbose("* This version of minecraft does not support custom model data in loot items (1.14 and up). Iris will generate as normal, but loot will not have custom models.");
} }
if(!doesSupportAwareness()) if (!doesSupportAwareness()) {
{
Iris.verbose("* This version of minecraft does not support entity awareness."); Iris.verbose("* This version of minecraft does not support entity awareness.");
} }
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void later(NastyRunnable object) public static void later(NastyRunnable object) {
{
Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () -> Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () ->
{ {
try try {
{
object.run(); object.run();
} } catch (Throwable e) {
catch(Throwable e)
{
e.printStackTrace(); e.printStackTrace();
} }
}, RNG.r.i(100, 1200)); }, RNG.r.i(100, 1200));
} }
public static int jobCount() public static int jobCount() {
{
return syncJobs.size(); return syncJobs.size();
} }
public static void clearQueues() public static void clearQueues() {
{ synchronized (syncJobs) {
synchronized(syncJobs)
{
syncJobs.clear(); syncJobs.clear();
} }
} }
@@ -533,8 +428,11 @@ public class Iris extends VolmitPlugin implements Listener
version = version.substring(2, 3); version = version.substring(2, 3);
} else { } else {
int dot = version.indexOf("."); int dot = version.indexOf(".");
if(dot != -1) { version = version.substring(0, dot); } if (dot != -1) {
} return Integer.parseInt(version); version = version.substring(0, dot);
}
}
return Integer.parseInt(version);
} }
public boolean isMCA() { public boolean isMCA() {
+31 -74
View File
@@ -8,8 +8,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
@Data @Data
public class IrisSettings public class IrisSettings {
{
public static transient IrisSettings settings; public static transient IrisSettings settings;
private IrisSettingsCache cache = new IrisSettingsCache(); private IrisSettingsCache cache = new IrisSettingsCache();
private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency(); private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency();
@@ -35,22 +34,19 @@ public class IrisSettings
} }
@Data @Data
public static class IrisSettingsCache public static class IrisSettingsCache {
{
@DontObfuscate @DontObfuscate
public int streamingCacheSize = 8192; public int streamingCacheSize = 8192;
} }
@Data @Data
public static class IrisSettingsConcurrency public static class IrisSettingsConcurrency {
{
@DontObfuscate @DontObfuscate
public int threadCount = -1; public int threadCount = -1;
} }
@Data @Data
public static class IrisSettingsParallax public static class IrisSettingsParallax {
{
@DontObfuscate @DontObfuscate
public int parallaxRegionEvictionMS = 15000; public int parallaxRegionEvictionMS = 15000;
@@ -59,8 +55,7 @@ public class IrisSettings
} }
@Data @Data
public static class IrisSettingsGeneral public static class IrisSettingsGeneral {
{
@DontObfuscate @DontObfuscate
public boolean commandSounds = true; public boolean commandSounds = true;
@@ -82,8 +77,7 @@ public class IrisSettings
} }
@Data @Data
public static class IrisSettingsGUI public static class IrisSettingsGUI {
{
@DontObfuscate @DontObfuscate
public boolean useServerLaunchedGuis = true; public boolean useServerLaunchedGuis = true;
@@ -95,8 +89,7 @@ public class IrisSettings
} }
@Data @Data
public static class IrisSettingsGenerator public static class IrisSettingsGenerator {
{
@DontObfuscate @DontObfuscate
public String defaultWorldType = "overworld"; public String defaultWorldType = "overworld";
@@ -118,8 +111,7 @@ public class IrisSettings
} }
@Data @Data
public static class IrisSettingsStudio public static class IrisSettingsStudio {
{
@DontObfuscate @DontObfuscate
public boolean studio = true; public boolean studio = true;
@@ -131,84 +123,59 @@ public class IrisSettings
public boolean disableTimeAndWeather = true; public boolean disableTimeAndWeather = true;
} }
public static IrisSettings get() public static IrisSettings get() {
{ if (settings != null) {
if(settings != null)
{
return settings; return settings;
} }
IrisSettings defaults = new IrisSettings(); IrisSettings defaults = new IrisSettings();
JSONObject def = new JSONObject(new Gson().toJson(defaults)); JSONObject def = new JSONObject(new Gson().toJson(defaults));
if(settings == null) if (settings == null) {
{
settings = new IrisSettings(); settings = new IrisSettings();
File s = Iris.instance.getDataFile("settings.json"); File s = Iris.instance.getDataFile("settings.json");
if(!s.exists()) if (!s.exists()) {
{ try {
try
{
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4)); IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
} } catch (JSONException | IOException e) {
catch(JSONException | IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} } else {
try {
else
{
try
{
String ss = IO.readAll(s); String ss = IO.readAll(s);
settings = new Gson().fromJson(ss, IrisSettings.class); settings = new Gson().fromJson(ss, IrisSettings.class);
J.a(() -> J.a(() ->
{ {
try try {
{
JSONObject j = new JSONObject(ss); JSONObject j = new JSONObject(ss);
boolean u = false; boolean u = false;
for(String i : def.keySet()) for (String i : def.keySet()) {
{ if (!j.has(i)) {
if(!j.has(i))
{
u = true; u = true;
j.put(i, def.get(i)); j.put(i, def.get(i));
Iris.warn("Adding new config key: " + i); Iris.warn("Adding new config key: " + i);
} }
} }
for(String i : new KSet<>(j.keySet())) for (String i : new KSet<>(j.keySet())) {
{ if (!def.has(i)) {
if(!def.has(i))
{
u = true; u = true;
j.remove(i); j.remove(i);
Iris.warn("Removing unused config key: " + i); Iris.warn("Removing unused config key: " + i);
} }
} }
if(u) if (u) {
{ try {
try
{
IO.writeAll(s, j.toString(4)); IO.writeAll(s, j.toString(4));
Iris.info("Updated Configuration Files"); Iris.info("Updated Configuration Files");
} } catch (Throwable e) {
catch(Throwable e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
} } catch (Throwable ee) {
catch(Throwable ee)
{
Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage()); Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage());
Iris.warn("Attempting to fix configuration while retaining valid in-memory settings..."); Iris.warn("Attempting to fix configuration while retaining valid in-memory settings...");
@@ -221,10 +188,7 @@ public class IrisSettings
} }
} }
}); });
} } catch (Throwable ee) {
catch(Throwable ee)
{
Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage()); Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage());
Iris.warn("Attempting to fix configuration while retaining valid in-memory settings..."); Iris.warn("Attempting to fix configuration while retaining valid in-memory settings...");
@@ -238,15 +202,10 @@ public class IrisSettings
} }
} }
if(!s.exists()) if (!s.exists()) {
{ try {
try
{
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4)); IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
} } catch (JSONException | IOException e) {
catch(JSONException | IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -255,10 +214,8 @@ public class IrisSettings
return settings; return settings;
} }
public static void invalidate() public static void invalidate() {
{ synchronized (settings) {
synchronized(settings)
{
settings = null; settings = null;
} }
} }
@@ -12,15 +12,17 @@ import com.volmit.iris.scaffold.data.DataProvider;
import com.volmit.iris.scaffold.engine.Engine; import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.stream.ProceduralStream; import com.volmit.iris.scaffold.stream.ProceduralStream;
import com.volmit.iris.scaffold.stream.interpolation.Interpolated; import com.volmit.iris.scaffold.stream.interpolation.Interpolated;
import com.volmit.iris.util.*; import com.volmit.iris.util.CaveResult;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.M;
import com.volmit.iris.util.RNG;
import lombok.Data; import lombok.Data;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@Data @Data
public class IrisComplex implements DataProvider public class IrisComplex implements DataProvider {
{
private RNG rng; private RNG rng;
private double fluidHeight; private double fluidHeight;
private IrisDataManager data; private IrisDataManager data;
@@ -55,10 +57,8 @@ public class IrisComplex implements DataProvider
private ProceduralStream<BlockData> fluidStream; private ProceduralStream<BlockData> fluidStream;
private IrisBiome focus; private IrisBiome focus;
public ProceduralStream<IrisBiome> getBiomeStream(InferredType type) public ProceduralStream<IrisBiome> getBiomeStream(InferredType type) {
{ switch (type) {
switch(type)
{
case CAVE: case CAVE:
return caveBiomeStream; return caveBiomeStream;
case LAND: case LAND:
@@ -77,8 +77,7 @@ public class IrisComplex implements DataProvider
return null; return null;
} }
public IrisComplex(Engine engine) public IrisComplex(Engine engine) {
{
int cacheSize = IrisSettings.get().getCache().getStreamingCacheSize(); int cacheSize = IrisSettings.get().getCache().getStreamingCacheSize();
this.rng = new RNG(engine.getWorld().getSeed()); this.rng = new RNG(engine.getWorld().getSeed());
this.data = engine.getData(); this.data = engine.getData();
@@ -115,8 +114,7 @@ public class IrisComplex implements DataProvider
.selectRarity(r.getCaveBiomes()) .selectRarity(r.getCaveBiomes())
.onNull("") .onNull("")
.convertCached((s) -> { .convertCached((s) -> {
if(s.isEmpty()) if (s.isEmpty()) {
{
return new IrisBiome(); return new IrisBiome();
} }
@@ -197,31 +195,24 @@ public class IrisComplex implements DataProvider
int heightf = (int) Math.round(getHeightStream().get(rx, rz)); int heightf = (int) Math.round(getHeightStream().get(rx, rz));
int m = heightf; int m = heightf;
if(engine.getDimension().isCarving()) if (engine.getDimension().isCarving()) {
{ if (engine.getDimension().isCarved(rx, m, rz, ((IrisTerrainActuator) engine.getFramework().getTerrainActuator()).getRng(), heightf)) {
if(engine.getDimension().isCarved(rx, m, rz, ((IrisTerrainActuator)engine.getFramework().getTerrainActuator()).getRng(), heightf))
{
m--; m--;
while(engine.getDimension().isCarved(rx, m, rz, ((IrisTerrainActuator)engine.getFramework().getTerrainActuator()).getRng(), heightf)) while (engine.getDimension().isCarved(rx, m, rz, ((IrisTerrainActuator) engine.getFramework().getTerrainActuator()).getRng(), heightf)) {
{
m--; m--;
} }
} }
} }
if(engine.getDimension().isCaves()) if (engine.getDimension().isCaves()) {
{
KList<CaveResult> caves = ((IrisCaveModifier) engine.getFramework().getCaveModifier()).genCaves(rx, rz, 0, 0, null); KList<CaveResult> caves = ((IrisCaveModifier) engine.getFramework().getCaveModifier()).genCaves(rx, rz, 0, 0, null);
boolean again = true; boolean again = true;
while(again) while (again) {
{
again = false; again = false;
for(CaveResult i : caves) for (CaveResult i : caves) {
{ if (i.getCeiling() > m && i.getFloor() < m) {
if(i.getCeiling() > m && i.getFloor() < m)
{
m = i.getFloor(); m = i.getFloor();
again = true; again = true;
} }
@@ -233,11 +224,10 @@ public class IrisComplex implements DataProvider
}, Interpolated.INT).cache2D(cacheSize); }, Interpolated.INT).cache2D(cacheSize);
//@done //@done
} }
private IrisRegion findRegion(IrisBiome focus, Engine engine) { private IrisRegion findRegion(IrisBiome focus, Engine engine) {
for(IrisRegion i : engine.getDimension().getAllRegions(engine)) for (IrisRegion i : engine.getDimension().getAllRegions(engine)) {
{ if (i.getAllBiomeIds().contains(focus.getLoadKey())) {
if(i.getAllBiomeIds().contains(focus.getLoadKey()))
{
return i; return i;
} }
} }
@@ -245,21 +235,17 @@ public class IrisComplex implements DataProvider
return null; return null;
} }
private IrisDecorator decorateFor(IrisBiome b, double x, double z, DecorationPart part) private IrisDecorator decorateFor(IrisBiome b, double x, double z, DecorationPart part) {
{
RNG rngc = chunkRngStream.get(x, z); RNG rngc = chunkRngStream.get(x, z);
for(IrisDecorator i : b.getDecorators()) for (IrisDecorator i : b.getDecorators()) {
{ if (!i.getPartOf().equals(part)) {
if(!i.getPartOf().equals(part))
{
continue; continue;
} }
BlockData block = i.getBlockData(b, rngc, x, z, data); BlockData block = i.getBlockData(b, rngc, x, z, data);
if(block != null) if (block != null) {
{
return i; return i;
} }
} }
@@ -267,25 +253,20 @@ public class IrisComplex implements DataProvider
return null; return null;
} }
private IrisBiome implode(IrisBiome b, Double x, Double z) private IrisBiome implode(IrisBiome b, Double x, Double z) {
{ if (b.getChildren().isEmpty()) {
if(b.getChildren().isEmpty())
{
return b; return b;
} }
return implode(b, x, z, 3); return implode(b, x, z, 3);
} }
private IrisBiome implode(IrisBiome b, Double x, Double z, int max) private IrisBiome implode(IrisBiome b, Double x, Double z, int max) {
{ if (max < 0) {
if(max < 0)
{
return b; return b;
} }
if(b.getChildren().isEmpty()) if (b.getChildren().isEmpty()) {
{
return b; return b;
} }
@@ -297,50 +278,39 @@ public class IrisComplex implements DataProvider
return implode(biome, x, z, max - 1); return implode(biome, x, z, max - 1);
} }
private IrisBiome fixBiomeType(Double height, IrisBiome biome, IrisRegion region, Double x, Double z, double fluidHeight) private IrisBiome fixBiomeType(Double height, IrisBiome biome, IrisRegion region, Double x, Double z, double fluidHeight) {
{
double sh = region.getShoreHeight(x, z); double sh = region.getShoreHeight(x, z);
if(height >= fluidHeight-1 && height <= fluidHeight + sh && !biome.isShore()) if (height >= fluidHeight - 1 && height <= fluidHeight + sh && !biome.isShore()) {
{
return shoreBiomeStream.get(x, z); return shoreBiomeStream.get(x, z);
} }
if(height > fluidHeight + sh && !biome.isLand()) if (height > fluidHeight + sh && !biome.isLand()) {
{
return landBiomeStream.get(x, z); return landBiomeStream.get(x, z);
} }
if(height < fluidHeight && !biome.isAquatic()) if (height < fluidHeight && !biome.isAquatic()) {
{
return seaBiomeStream.get(x, z); return seaBiomeStream.get(x, z);
} }
if(height == fluidHeight && !biome.isShore()) if (height == fluidHeight && !biome.isShore()) {
{
return shoreBiomeStream.get(x, z); return shoreBiomeStream.get(x, z);
} }
return biome; return biome;
} }
private double getHeight(Engine engine, IrisBiome b, double x, double z, long seed) private double getHeight(Engine engine, IrisBiome b, double x, double z, long seed) {
{
double h = 0; double h = 0;
for(IrisGenerator gen : generators) for (IrisGenerator gen : generators) {
{
double hi = gen.getInterpolator().interpolate(x, z, (xx, zz) -> double hi = gen.getInterpolator().interpolate(x, z, (xx, zz) ->
{ {
try try {
{
IrisBiome bx = baseBiomeStream.get(xx, zz); IrisBiome bx = baseBiomeStream.get(xx, zz);
return bx.getGenLinkMax(gen.getLoadKey()); return bx.getGenLinkMax(gen.getLoadKey());
} } catch (Throwable e) {
catch(Throwable e)
{
Iris.warn("Failed to sample hi biome at " + xx + " " + zz + " using the generator " + gen.getLoadKey()); Iris.warn("Failed to sample hi biome at " + xx + " " + zz + " using the generator " + gen.getLoadKey());
} }
@@ -349,15 +319,11 @@ public class IrisComplex implements DataProvider
double lo = gen.getInterpolator().interpolate(x, z, (xx, zz) -> double lo = gen.getInterpolator().interpolate(x, z, (xx, zz) ->
{ {
try try {
{
IrisBiome bx = baseBiomeStream.get(xx, zz); IrisBiome bx = baseBiomeStream.get(xx, zz);
return bx.getGenLinkMin(gen.getLoadKey()); return bx.getGenLinkMin(gen.getLoadKey());
} } catch (Throwable e) {
catch(Throwable e)
{
Iris.warn("Failed to sample lo biome at " + xx + " " + zz + " using the generator " + gen.getLoadKey()); Iris.warn("Failed to sample lo biome at " + xx + " " + zz + " using the generator " + gen.getLoadKey());
} }
@@ -373,12 +339,9 @@ public class IrisComplex implements DataProvider
return Math.min(engine.getHeight(), Math.max(noise.get(), 0)); return Math.min(engine.getHeight(), Math.max(noise.get(), 0));
} }
private void registerGenerator(IrisGenerator cachedGenerator) private void registerGenerator(IrisGenerator cachedGenerator) {
{ for (IrisGenerator i : generators) {
for(IrisGenerator i : generators) if (i.getLoadKey().equals(cachedGenerator.getLoadKey())) {
{
if(i.getLoadKey().equals(cachedGenerator.getLoadKey()))
{
return; return;
} }
} }
@@ -2,7 +2,6 @@ package com.volmit.iris.generator;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.object.IrisBiome; import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.scaffold.cache.AtomicCache;
import com.volmit.iris.scaffold.engine.*; import com.volmit.iris.scaffold.engine.*;
import com.volmit.iris.scaffold.hunk.Hunk; import com.volmit.iris.scaffold.hunk.Hunk;
import com.volmit.iris.util.J; import com.volmit.iris.util.J;
@@ -19,8 +18,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Random; import java.util.Random;
public class IrisEngine extends BlockPopulator implements Engine public class IrisEngine extends BlockPopulator implements Engine {
{
@Getter @Getter
private final EngineCompound compound; private final EngineCompound compound;
@@ -54,8 +52,7 @@ public class IrisEngine extends BlockPopulator implements Engine
private int cacheId; private int cacheId;
private final int art; private final int art;
public IrisEngine(EngineTarget target, EngineCompound compound, int index) public IrisEngine(EngineTarget target, EngineCompound compound, int index) {
{
Iris.info("Initializing Engine: " + target.getWorld().getName() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)"); Iris.info("Initializing Engine: " + target.getWorld().getName() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)");
metrics = new EngineMetrics(32); metrics = new EngineMetrics(32);
this.target = target; this.target = target;
@@ -72,8 +69,7 @@ public class IrisEngine extends BlockPopulator implements Engine
} }
@Override @Override
public void close() public void close() {
{
J.car(art); J.car(art);
closed = true; closed = true;
getWorldManager().close(); getWorldManager().close();
@@ -102,8 +98,7 @@ public class IrisEngine extends BlockPopulator implements Engine
@Override @Override
public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<Biome> vbiomes) { public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<Biome> vbiomes) {
try try {
{
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
Hunk<BlockData> blocks = vblocks.synchronize().listen((xx, y, zz, t) -> catchBlockUpdates(x + xx, y + getMinHeight(), z + zz, t)); Hunk<BlockData> blocks = vblocks.synchronize().listen((xx, y, zz, t) -> catchBlockUpdates(x + xx, y + getMinHeight(), z + zz, t));
getFramework().getEngineParallax().generateParallaxArea(x >> 4, z >> 4); getFramework().getEngineParallax().generateParallaxArea(x >> 4, z >> 4);
@@ -116,18 +111,14 @@ public class IrisEngine extends BlockPopulator implements Engine
getFramework().getEngineParallax().insertParallax(x, z, blocks); getFramework().getEngineParallax().insertParallax(x, z, blocks);
getFramework().getDepositModifier().modify(x, z, blocks); getFramework().getDepositModifier().modify(x, z, blocks);
getMetrics().getTotal().put(p.getMilliseconds()); getMetrics().getTotal().put(p.getMilliseconds());
} } catch (Throwable e) {
catch(Throwable e)
{
fail("Failed to generate " + x + ", " + z, e); fail("Failed to generate " + x + ", " + z, e);
} }
} }
@Override @Override
public IrisBiome getFocus() { public IrisBiome getFocus() {
if(getDimension().getFocus() == null || getDimension().getFocus().trim().isEmpty()) if (getDimension().getFocus() == null || getDimension().getFocus().trim().isEmpty()) {
{
return null; return null;
} }
@@ -135,8 +126,7 @@ public class IrisEngine extends BlockPopulator implements Engine
} }
@Override @Override
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk c) public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk c) {
{
getWorldManager().spawnInitialEntities(c); getWorldManager().spawnInitialEntities(c);
updateChunk(c); updateChunk(c);
placeTiles(c); placeTiles(c);
@@ -14,10 +14,6 @@ import com.volmit.iris.scaffold.parallel.MultiBurst;
import com.volmit.iris.util.*; import com.volmit.iris.util.*;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.minecraft.core.BlockPosition;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.StructureGenerator;
import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@@ -27,14 +23,7 @@ import org.bukkit.event.world.WorldSaveEvent;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import java.io.File; import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
public class IrisEngineCompound implements EngineCompound { public class IrisEngineCompound implements EngineCompound {
@Getter @Getter
@@ -65,8 +54,7 @@ public class IrisEngineCompound implements EngineCompound {
@Setter @Setter
private boolean studio; private boolean studio;
public IrisEngineCompound(World world, IrisDimension rootDimension, IrisDataManager data, int maximumThreads) public IrisEngineCompound(World world, IrisDimension rootDimension, IrisDataManager data, int maximumThreads) {
{
wallClock = new AtomicRollingSequence(32); wallClock = new AtomicRollingSequence(32);
this.rootDimension = rootDimension; this.rootDimension = rootDimension;
Iris.info("Initializing Engine Composite for " + world.getName()); Iris.info("Initializing Engine Composite for " + world.getName());
@@ -78,35 +66,28 @@ public class IrisEngineCompound implements EngineCompound {
saveEngineMetadata(); saveEngineMetadata();
populators = new KList<>(); populators = new KList<>();
if(rootDimension.getDimensionalComposite().isEmpty()) if (rootDimension.getDimensionalComposite().isEmpty()) {
{
burster = null; burster = null;
// TODO: WARNING HEIGHT // TODO: WARNING HEIGHT
engines = new Engine[]{new IrisEngine(new EngineTarget(world, rootDimension, data, 256, maximumThreads), this, 0)}; engines = new Engine[]{new IrisEngine(new EngineTarget(world, rootDimension, data, 256, maximumThreads), this, 0)};
defaultEngine = engines[0]; defaultEngine = engines[0];
} } else {
else
{
double totalWeight = 0D; double totalWeight = 0D;
engines = new Engine[rootDimension.getDimensionalComposite().size()]; engines = new Engine[rootDimension.getDimensionalComposite().size()];
burster = engines.length > 1 ? new MultiBurst(engines.length) : null; burster = engines.length > 1 ? new MultiBurst(engines.length) : null;
int threadDist = (Math.max(2, maximumThreads - engines.length)) / engines.length; int threadDist = (Math.max(2, maximumThreads - engines.length)) / engines.length;
if((threadDist * engines.length) + engines.length > maximumThreads) if ((threadDist * engines.length) + engines.length > maximumThreads) {
{
Iris.warn("Using " + ((threadDist * engines.length) + engines.length) + " threads instead of the configured " + maximumThreads + " maximum thread count due to the requirements of this dimension!"); Iris.warn("Using " + ((threadDist * engines.length) + engines.length) + " threads instead of the configured " + maximumThreads + " maximum thread count due to the requirements of this dimension!");
} }
for(IrisDimensionIndex i : rootDimension.getDimensionalComposite()) for (IrisDimensionIndex i : rootDimension.getDimensionalComposite()) {
{
totalWeight += i.getWeight(); totalWeight += i.getWeight();
} }
int buf = 0; int buf = 0;
for(int i = 0; i < engines.length; i++) for (int i = 0; i < engines.length; i++) {
{
IrisDimensionIndex index = rootDimension.getDimensionalComposite().get(i); IrisDimensionIndex index = rootDimension.getDimensionalComposite().get(i);
IrisDimension dimension = data.getDimensionLoader().load(index.getDimension()); IrisDimension dimension = data.getDimensionLoader().load(index.getDimension());
// TODO: WARNING HEIGHT // TODO: WARNING HEIGHT
@@ -114,22 +95,18 @@ public class IrisEngineCompound implements EngineCompound {
engines[i].setMinHeight(buf); engines[i].setMinHeight(buf);
buf += engines[i].getHeight(); buf += engines[i].getHeight();
if(index.isPrimary()) if (index.isPrimary()) {
{
defaultEngine = engines[i]; defaultEngine = engines[i];
} }
} }
if(defaultEngine == null) if (defaultEngine == null) {
{
defaultEngine = engines[0]; defaultEngine = engines[0];
} }
} }
for(Engine i : engines) for (Engine i : engines) {
{ if (i instanceof BlockPopulator) {
if(i instanceof BlockPopulator)
{
populators.add((BlockPopulator) i); populators.add((BlockPopulator) i);
} }
} }
@@ -137,40 +114,33 @@ public class IrisEngineCompound implements EngineCompound {
Iris.instance.registerListener(this); Iris.instance.registerListener(this);
} }
public List<IrisPosition> getStrongholdPositions() public List<IrisPosition> getStrongholdPositions() {
{
return engineMetadata.getStrongholdPositions(); return engineMetadata.getStrongholdPositions();
} }
@EventHandler @EventHandler
public void on(WorldSaveEvent e) public void on(WorldSaveEvent e) {
{ if (world != null && e.getWorld().equals(world)) {
if(world != null &&e.getWorld().equals(world))
{
save(); save();
} }
} }
public void printMetrics(CommandSender sender) public void printMetrics(CommandSender sender) {
{
KMap<String, Double> totals = new KMap<>(); KMap<String, Double> totals = new KMap<>();
KMap<String, Double> weights = new KMap<>(); KMap<String, Double> weights = new KMap<>();
double masterWallClock = wallClock.getAverage(); double masterWallClock = wallClock.getAverage();
for(int i = 0; i < getSize(); i++) for (int i = 0; i < getSize(); i++) {
{
Engine e = getEngine(i); Engine e = getEngine(i);
KMap<String, Double> timings = e.getMetrics().pull(); KMap<String, Double> timings = e.getMetrics().pull();
double totalWeight = 0; double totalWeight = 0;
double wallClock = e.getMetrics().getTotal().getAverage(); double wallClock = e.getMetrics().getTotal().getAverage();
for(double j : timings.values()) for (double j : timings.values()) {
{
totalWeight += j; totalWeight += j;
} }
for(String j : timings.k()) for (String j : timings.k()) {
{
weights.put(e.getName() + "[" + e.getIndex() + "]." + j, (wallClock / totalWeight) * timings.get(j)); weights.put(e.getName() + "[" + e.getIndex() + "]." + j, (wallClock / totalWeight) * timings.get(j));
} }
@@ -179,39 +149,33 @@ public class IrisEngineCompound implements EngineCompound {
double mtotals = 0; double mtotals = 0;
for(double i : totals.values()) for (double i : totals.values()) {
{
mtotals += i; mtotals += i;
} }
for(String i : totals.k()) for (String i : totals.k()) {
{
totals.put(i, (masterWallClock / mtotals) * totals.get(i)); totals.put(i, (masterWallClock / mtotals) * totals.get(i));
} }
double v = 0; double v = 0;
for(double i : weights.values()) for (double i : weights.values()) {
{
v += i; v += i;
} }
for(String i : weights.k()) for (String i : weights.k()) {
{
weights.put(i, weights.get(i) / v); weights.put(i, weights.get(i) / v);
} }
sender.sendMessage("Total: " + C.BOLD + C.WHITE + Form.duration(masterWallClock, 0)); sender.sendMessage("Total: " + C.BOLD + C.WHITE + Form.duration(masterWallClock, 0));
for(String i : totals.k()) for (String i : totals.k()) {
{
sender.sendMessage(" Engine " + C.UNDERLINE + C.GREEN + i + C.RESET + ": " + C.BOLD + C.WHITE + Form.duration(totals.get(i), 0)); sender.sendMessage(" Engine " + C.UNDERLINE + C.GREEN + i + C.RESET + ": " + C.BOLD + C.WHITE + Form.duration(totals.get(i), 0));
} }
sender.sendMessage("Details: "); sender.sendMessage("Details: ");
for(String i : weights.sortKNumber().reverse()) for (String i : weights.sortKNumber().reverse()) {
{
String befb = C.UNDERLINE + "" + C.GREEN + "" + i.split("\\Q[\\E")[0] + C.RESET + C.GRAY + "["; String befb = C.UNDERLINE + "" + C.GREEN + "" + i.split("\\Q[\\E")[0] + C.RESET + C.GRAY + "[";
String num = C.GOLD + i.split("\\Q[\\E")[1].split("]")[0] + C.RESET + C.GRAY + "]."; String num = C.GOLD + i.split("\\Q[\\E")[1].split("]")[0] + C.RESET + C.GRAY + "].";
String afb = C.ITALIC + "" + C.AQUA + i.split("\\Q]\\E")[1].substring(1) + C.RESET + C.GRAY; String afb = C.ITALIC + "" + C.AQUA + i.split("\\Q]\\E")[1].substring(1) + C.RESET + C.GRAY;
@@ -225,30 +189,23 @@ public class IrisEngineCompound implements EngineCompound {
} }
@Override @Override
public void generate(int x, int z, Hunk<BlockData> blocks, Hunk<BlockData> postblocks, Hunk<Biome> biomes) public void generate(int x, int z, Hunk<BlockData> blocks, Hunk<BlockData> postblocks, Hunk<Biome> biomes) {
{
recycle(); recycle();
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
if(engines.length == 1 && !getEngine(0).getTarget().isInverted()) if (engines.length == 1 && !getEngine(0).getTarget().isInverted()) {
{
engines[0].generate(x, z, blocks, biomes); engines[0].generate(x, z, blocks, biomes);
} } else {
else
{
int i; int i;
int offset = 0; int offset = 0;
for(i = 0; i < engines.length; i++) for (i = 0; i < engines.length; i++) {
{
Engine engine = engines[i]; Engine engine = engines[i];
int doffset = offset; int doffset = offset;
int height = engine.getTarget().getHeight(); int height = engine.getTarget().getHeight();
Hunk<BlockData> cblock = Hunk.newArrayHunk(16, height, 16); Hunk<BlockData> cblock = Hunk.newArrayHunk(16, height, 16);
Hunk<Biome> cbiome = Hunk.newArrayHunk(16, height, 16); Hunk<Biome> cbiome = Hunk.newArrayHunk(16, height, 16);
if(engine.getTarget().isInverted()) if (engine.getTarget().isInverted()) {
{
cblock = cblock.invertY(); cblock = cblock.invertY();
cbiome = cbiome.invertY(); cbiome = cbiome.invertY();
} }
@@ -301,8 +258,7 @@ public class IrisEngineCompound implements EngineCompound {
@Override @Override
public void hotload() { public void hotload() {
for(int i = 0; i < getSize(); i++) for (int i = 0; i < getSize(); i++) {
{
getEngine(i).hotload(); getEngine(i).hotload();
} }
} }
@@ -15,8 +15,8 @@ import java.util.UUID;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
public class IrisEngineEffects extends EngineAssignedComponent implements EngineEffects { public class IrisEngineEffects extends EngineAssignedComponent implements EngineEffects {
private KMap<UUID, EnginePlayer> players; private final KMap<UUID, EnginePlayer> players;
private Semaphore limit; private final Semaphore limit;
public IrisEngineEffects(Engine engine) { public IrisEngineEffects(Engine engine) {
super(engine, "FX"); super(engine, "FX");
@@ -30,28 +30,20 @@ public class IrisEngineEffects extends EngineAssignedComponent implements Engine
if (pr == null) return; //Fix for paper returning a world with a null playerlist if (pr == null) return; //Fix for paper returning a world with a null playerlist
for(Player i : pr) for (Player i : pr) {
{
Location l = i.getLocation(); Location l = i.getLocation();
boolean pcc = players.containsKey(i.getUniqueId()); boolean pcc = players.containsKey(i.getUniqueId());
if(getEngine().contains(l)) if (getEngine().contains(l)) {
{ if (!pcc) {
if(!pcc)
{
players.put(i.getUniqueId(), new EnginePlayer(getEngine(), i)); players.put(i.getUniqueId(), new EnginePlayer(getEngine(), i));
} }
} } else if (pcc) {
else if(pcc)
{
players.remove(i.getUniqueId()); players.remove(i.getUniqueId());
} }
} }
for(UUID i : players.k()) for (UUID i : players.k()) {
{ if (!pr.contains(players.get(i).getPlayer())) {
if(!pr.contains(players.get(i).getPlayer()))
{
players.remove(i); players.remove(i);
} }
} }
@@ -59,17 +51,14 @@ public class IrisEngineEffects extends EngineAssignedComponent implements Engine
@Override @Override
public void tickRandomPlayer() { public void tickRandomPlayer() {
if(limit.tryAcquire()) if (limit.tryAcquire()) {
{ if (M.r(0.02)) {
if(M.r(0.02))
{
updatePlayerMap(); updatePlayerMap();
limit.release(); limit.release();
return; return;
} }
if(players.isEmpty()) if (players.isEmpty()) {
{
limit.release(); limit.release();
return; return;
} }
@@ -78,8 +67,7 @@ public class IrisEngineEffects extends EngineAssignedComponent implements Engine
int max = players.size(); int max = players.size();
PrecisionStopwatch p = new PrecisionStopwatch(); PrecisionStopwatch p = new PrecisionStopwatch();
while(max-- > 0 && M.ms() - p.getMilliseconds() < limitms) while (max-- > 0 && M.ms() - p.getMilliseconds() < limitms) {
{
players.v().getRandom().tick(); players.v().getRandom().tick();
} }
@@ -52,8 +52,7 @@ public class IrisEngineFramework implements EngineFramework {
private final AtomicBoolean cleaning; private final AtomicBoolean cleaning;
private final ChronoLatch cleanLatch; private final ChronoLatch cleanLatch;
public IrisEngineFramework(Engine engine) public IrisEngineFramework(Engine engine) {
{
this.engine = engine; this.engine = engine;
this.complex = new IrisComplex(getEngine()); this.complex = new IrisComplex(getEngine());
this.engineParallax = new IrisEngineParallax(getEngine()); this.engineParallax = new IrisEngineParallax(getEngine());
@@ -70,27 +69,21 @@ public class IrisEngineFramework implements EngineFramework {
@Override @Override
public synchronized void recycle() { public synchronized void recycle() {
if(!cleanLatch.flip()) if (!cleanLatch.flip()) {
{
return; return;
} }
if (cleaning.get()) if (cleaning.get()) {
{
cleanLatch.flipDown(); cleanLatch.flipDown();
return; return;
} }
cleaning.set(true); cleaning.set(true);
try try {
{
getEngine().getParallax().cleanup(); getEngine().getParallax().cleanup();
getData().getObjectLoader().clean(); getData().getObjectLoader().clean();
} } catch (Throwable e) {
catch(Throwable e)
{
Iris.error("Cleanup failed!"); Iris.error("Cleanup failed!");
e.printStackTrace(); e.printStackTrace();
} }
@@ -99,8 +92,7 @@ public class IrisEngineFramework implements EngineFramework {
} }
@Override @Override
public void close() public void close() {
{
getEngineParallax().close(); getEngineParallax().close();
getTerrainActuator().close(); getTerrainActuator().close();
getDecorantActuator().close(); getDecorantActuator().close();
@@ -11,8 +11,7 @@ public class IrisEngineParallax implements EngineParallaxManager {
@Getter @Getter
private final int parallaxSize; private final int parallaxSize;
public IrisEngineParallax(Engine engine) public IrisEngineParallax(Engine engine) {
{
this.engine = engine; this.engine = engine;
parallaxSize = computeParallaxSize(); parallaxSize = computeParallaxSize();
} }
@@ -37,8 +37,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
RNG rng = new RNG(Cache.key(c)); RNG rng = new RNG(Cache.key(c));
getEngine().getParallaxAccess().getEntitiesR(c.getX(), c.getZ()).iterateSync((x, y, z, e) -> { getEngine().getParallaxAccess().getEntitiesR(c.getX(), c.getZ()).iterateSync((x, y, z, e) -> {
if(e != null) if (e != null) {
{
IrisEntity en = getData().getEntityLoader().load(e); IrisEntity en = getData().getEntityLoader().load(e);
if (en != null) { if (en != null) {
@@ -61,17 +60,13 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
} }
@Override @Override
public void onEntitySpawn(EntitySpawnEvent e) public void onEntitySpawn(EntitySpawnEvent e) {
{ if (getTarget().getWorld() == null || !getTarget().getWorld().equals(e.getEntity().getWorld())) {
if(getTarget().getWorld() == null || !getTarget().getWorld().equals(e.getEntity().getWorld()))
{
return; return;
} }
try try {
{ if (!IrisSettings.get().getGenerator().isSystemEntitySpawnOverrides()) {
if(!IrisSettings.get().getGenerator().isSystemEntitySpawnOverrides())
{
return; return;
} }
@@ -81,14 +76,12 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
J.a(() -> J.a(() ->
{ {
if(spawnable) if (spawnable) {
{
IrisDimension dim = getDimension(); IrisDimension dim = getDimension();
IrisRegion region = getEngine().getRegion(x, z); IrisRegion region = getEngine().getRegion(x, z);
IrisBiome above = getEngine().getSurfaceBiome(x, z); IrisBiome above = getEngine().getSurfaceBiome(x, z);
IrisBiome bbelow = getEngine().getBiome(x, y, z); IrisBiome bbelow = getEngine().getBiome(x, y, z);
if(above.getLoadKey().equals(bbelow.getLoadKey())) if (above.getLoadKey().equals(bbelow.getLoadKey())) {
{
bbelow = null; bbelow = null;
} }
@@ -96,54 +89,40 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
J.s(() -> J.s(() ->
{ {
if(below != null) if (below != null) {
{ if (trySpawn(below.getEntitySpawnOverrides(), e)) {
if(trySpawn(below.getEntitySpawnOverrides(), e))
{
return; return;
} }
} }
if(trySpawn(above.getEntitySpawnOverrides(), e)) if (trySpawn(above.getEntitySpawnOverrides(), e)) {
{
return; return;
} }
if(trySpawn(region.getEntitySpawnOverrides(), e)) if (trySpawn(region.getEntitySpawnOverrides(), e)) {
{
return; return;
} }
if(trySpawn(dim.getEntitySpawnOverrides(), e)) if (trySpawn(dim.getEntitySpawnOverrides(), e)) {
{
return; return;
} }
}); });
} }
}); });
} } catch (Throwable xe) {
catch(Throwable xe)
{
} }
} }
private boolean trySpawn(KList<IrisEntitySpawnOverride> s, EntitySpawnEvent e) private boolean trySpawn(KList<IrisEntitySpawnOverride> s, EntitySpawnEvent e) {
{ for (IrisEntitySpawnOverride i : s) {
for(IrisEntitySpawnOverride i : s)
{
spawnable = false; spawnable = false;
if(i.on(getEngine(), e.getLocation(), e.getEntityType(), e) != null) if (i.on(getEngine(), e.getLocation(), e.getEntityType(), e) != null) {
{
e.setCancelled(true); e.setCancelled(true);
e.getEntity().remove(); e.getEntity().remove();
return true; return true;
} } else {
else
{
spawnable = true; spawnable = true;
} }
} }
@@ -151,10 +130,8 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
return false; return false;
} }
private void trySpawn(KList<IrisEntityInitialSpawn> s, Chunk c, RNG rng) private void trySpawn(KList<IrisEntityInitialSpawn> s, Chunk c, RNG rng) {
{ for (IrisEntityInitialSpawn i : s) {
for(IrisEntityInitialSpawn i : s)
{
i.spawn(getEngine(), c, rng); i.spawn(getEngine(), c, rng);
} }
} }
@@ -9,8 +9,7 @@ import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
public class IrisBiomeActuator extends EngineAssignedActuator<Biome> public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
{
public IrisBiomeActuator(Engine engine) { public IrisBiomeActuator(Engine engine) {
super(engine, "Biome"); super(engine, "Biome");
} }
@@ -21,17 +20,14 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome>
int zf, hh; int zf, hh;
BurstExecutor burst = MultiBurst.burst.burst(h.getWidth() * h.getDepth()); BurstExecutor burst = MultiBurst.burst.burst(h.getWidth() * h.getDepth());
for(int xf = 0; xf < h.getWidth(); xf++) for (int xf = 0; xf < h.getWidth(); xf++) {
{ for (zf = 0; zf < h.getDepth(); zf++) {
for(zf = 0; zf < h.getDepth(); zf++)
{
int xxf = xf; int xxf = xf;
int zzf = zf; int zzf = zf;
burst.queue(() -> { burst.queue(() -> {
Biome v = getComplex().getTrueBiomeStream().get(modX(xxf + x), modZ(zzf + z)).getSkyBiome(RNG.r, x, 0, z); Biome v = getComplex().getTrueBiomeStream().get(modX(xxf + x), modZ(zzf + z)).getSkyBiome(RNG.r, x, 0, z);
for(int i = 0; i < h.getHeight(); i++) for (int i = 0; i < h.getHeight(); i++) {
{
h.set(xxf, i, zzf, v); h.set(xxf, i, zzf, v);
} }
}); });
@@ -1,25 +1,20 @@
package com.volmit.iris.generator.actuator; package com.volmit.iris.generator.actuator;
import com.volmit.iris.generator.decorator.IrisSeaFloorDecorator; import com.volmit.iris.generator.decorator.*;
import com.volmit.iris.object.IrisBiome; import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RNG;
import com.volmit.iris.generator.decorator.IrisCeilingDecorator;
import com.volmit.iris.generator.decorator.IrisSeaSurfaceDecorator;
import com.volmit.iris.generator.decorator.IrisShoreLineDecorator;
import com.volmit.iris.generator.decorator.IrisSurfaceDecorator;
import com.volmit.iris.scaffold.engine.Engine; import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.engine.EngineAssignedActuator; import com.volmit.iris.scaffold.engine.EngineAssignedActuator;
import com.volmit.iris.scaffold.engine.EngineDecorator; import com.volmit.iris.scaffold.engine.EngineDecorator;
import com.volmit.iris.scaffold.hunk.Hunk; import com.volmit.iris.scaffold.hunk.Hunk;
import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RNG;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import java.util.function.Predicate; import java.util.function.Predicate;
public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
{
private static final Predicate<BlockData> PREDICATE_SOLID = (b) -> b != null && !b.getMaterial().isAir() && !b.getMaterial().equals(Material.WATER) && !b.getMaterial().equals(Material.LAVA); private static final Predicate<BlockData> PREDICATE_SOLID = (b) -> b != null && !b.getMaterial().isAir() && !b.getMaterial().equals(Material.WATER) && !b.getMaterial().equals(Material.LAVA);
private final RNG rng; private final RNG rng;
@Getter @Getter
@@ -47,8 +42,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
@Override @Override
public void onActuate(int x, int z, Hunk<BlockData> output) { public void onActuate(int x, int z, Hunk<BlockData> output) {
if(!getEngine().getDimension().isDecorate()) if (!getEngine().getDimension().isDecorate()) {
{
return; return;
} }
@@ -57,10 +51,8 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
int j, realX, realZ, height; int j, realX, realZ, height;
IrisBiome biome, cave; IrisBiome biome, cave;
for(int i = 0; i < output.getWidth(); i++) for (int i = 0; i < output.getWidth(); i++) {
{ for (j = 0; j < output.getDepth(); j++) {
for(j = 0; j < output.getDepth(); j++)
{
boolean solid; boolean solid;
int emptyFor = 0; int emptyFor = 0;
int lastSolid = 0; int lastSolid = 0;
@@ -70,49 +62,38 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
biome = getComplex().getTrueBiomeStream().get(realX, realZ); biome = getComplex().getTrueBiomeStream().get(realX, realZ);
cave = shouldRay ? getComplex().getCaveBiomeStream().get(realX, realZ) : null; cave = shouldRay ? getComplex().getCaveBiomeStream().get(realX, realZ) : null;
if(biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) if (biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) {
{
continue; continue;
} }
if(height == getDimension().getFluidHeight()) if (height == getDimension().getFluidHeight()) {
{
getShoreLineDecorator().decorate(i, j, getShoreLineDecorator().decorate(i, j,
realX, (int) Math.round(modX(x + i + 1)), (int) Math.round(modX(x + i - 1)), realX, (int) Math.round(modX(x + i + 1)), (int) Math.round(modX(x + i - 1)),
realZ, (int) Math.round(modZ(z + j + 1)), (int) Math.round(modZ(z + j - 1)), realZ, (int) Math.round(modZ(z + j + 1)), (int) Math.round(modZ(z + j - 1)),
output, biome, height, getEngine().getHeight() - height); output, biome, height, getEngine().getHeight() - height);
} } else if (height == getDimension().getFluidHeight() + 1) {
else if (height == getDimension().getFluidHeight() + 1)
{
getSeaSurfaceDecorator().decorate(i, j, getSeaSurfaceDecorator().decorate(i, j,
realX, (int) Math.round(modX(x + i + 1)), (int) Math.round(modX(x + i - 1)), realX, (int) Math.round(modX(x + i + 1)), (int) Math.round(modX(x + i - 1)),
realZ, (int) Math.round(modZ(z + j + 1)), (int) Math.round(modZ(z + j - 1)), realZ, (int) Math.round(modZ(z + j + 1)), (int) Math.round(modZ(z + j - 1)),
output, biome, height, getEngine().getHeight() - getDimension().getFluidHeight()); output, biome, height, getEngine().getHeight() - getDimension().getFluidHeight());
} } else if (height < getDimension().getFluidHeight()) {
else if(height < getDimension().getFluidHeight())
{
getSeaFloorDecorator().decorate(i, j, realX, realZ, output, biome, height + 1, getDimension().getFluidHeight()); getSeaFloorDecorator().decorate(i, j, realX, realZ, output, biome, height + 1, getDimension().getFluidHeight());
} }
getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height); getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height);
if(cave != null && cave.getDecorators().isNotEmpty()) if (cave != null && cave.getDecorators().isNotEmpty()) {
{ for (int k = height; k > 0; k--) {
for(int k = height; k > 0; k--)
{
solid = PREDICATE_SOLID.test(output.get(i, k, j)); solid = PREDICATE_SOLID.test(output.get(i, k, j));
if(solid) if (solid) {
{
if (emptyFor > 0) { if (emptyFor > 0) {
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor); getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor);
getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor); getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor);
emptyFor = 0; emptyFor = 0;
} }
lastSolid = k; lastSolid = k;
} } else {
else
{
emptyFor++; emptyFor++;
} }
} }
@@ -123,8 +104,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
getEngine().getMetrics().getDecoration().put(p.getMilliseconds()); getEngine().getMetrics().getDecoration().put(p.getMilliseconds());
} }
private boolean shouldRayDecorate() private boolean shouldRayDecorate() {
{
return getEngine().getDimension().isCarving() || getEngine().getDimension().isCaves() || getEngine().getDimension().isRavines(); return getEngine().getDimension().isCarving() || getEngine().getDimension().isCaves() || getEngine().getDimension().isRavines();
} }
} }
@@ -1,18 +1,17 @@
package com.volmit.iris.generator.actuator; package com.volmit.iris.generator.actuator;
import com.volmit.iris.object.IrisBiome; import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RNG;
import com.volmit.iris.scaffold.engine.Engine; import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.engine.EngineAssignedActuator; import com.volmit.iris.scaffold.engine.EngineAssignedActuator;
import com.volmit.iris.scaffold.hunk.Hunk; import com.volmit.iris.scaffold.hunk.Hunk;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RNG;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
public class IrisTerrainActuator extends EngineAssignedActuator<BlockData> public class IrisTerrainActuator extends EngineAssignedActuator<BlockData> {
{
private static final BlockData AIR = Material.AIR.createBlockData(); private static final BlockData AIR = Material.AIR.createBlockData();
private static final BlockData BEDROCK = Material.BEDROCK.createBlockData(); private static final BlockData BEDROCK = Material.BEDROCK.createBlockData();
private static final BlockData CAVE_AIR = Material.CAVE_AIR.createBlockData(); private static final BlockData CAVE_AIR = Material.CAVE_AIR.createBlockData();
@@ -37,56 +36,46 @@ public class IrisTerrainActuator extends EngineAssignedActuator<BlockData>
IrisBiome biome; IrisBiome biome;
KList<BlockData> blocks, fblocks; KList<BlockData> blocks, fblocks;
for(int xf = 0; xf < h.getWidth(); xf++) for (int xf = 0; xf < h.getWidth(); xf++) {
{ for (zf = 0; zf < h.getDepth(); zf++) {
for(zf = 0; zf < h.getDepth(); zf++)
{
realX = (int) modX(xf + x); realX = (int) modX(xf + x);
realZ = (int) modZ(zf + z); realZ = (int) modZ(zf + z);
b = hasUnder ? (int) Math.round(getDimension().getUndercarriage().get(rng, realX, realZ)) : 0; b = hasUnder ? (int) Math.round(getDimension().getUndercarriage().get(rng, realX, realZ)) : 0;
he = (int) Math.round(Math.min(h.getHeight(), getComplex().getHeightStream().get(realX, realZ))); he = (int) Math.round(Math.min(h.getHeight(), getComplex().getHeightStream().get(realX, realZ)));
hf = (int) Math.round(Math.max(Math.min(h.getHeight(), getDimension().getFluidHeight()), he)); hf = Math.round(Math.max(Math.min(h.getHeight(), getDimension().getFluidHeight()), he));
biome = getComplex().getTrueBiomeStream().get(realX, realZ); biome = getComplex().getTrueBiomeStream().get(realX, realZ);
blocks = null; blocks = null;
fblocks = null; fblocks = null;
if(hf < b) if (hf < b) {
{
continue; continue;
} }
for (i = hf; i >= b; i--) { for (i = hf; i >= b; i--) {
if (i >= h.getHeight()) if (i >= h.getHeight()) {
{
continue; continue;
} }
if(i == b) if (i == b) {
{ if (getDimension().isBedrock()) {
if(getDimension().isBedrock())
{
h.set(xf, i, zf, BEDROCK); h.set(xf, i, zf, BEDROCK);
lastBedrock = i; lastBedrock = i;
continue; continue;
} }
} }
if(carving && getDimension().isCarved(realX, i, realZ, rng, he)) if (carving && getDimension().isCarved(realX, i, realZ, rng, he)) {
{
continue; continue;
} }
if(i > he && i <= hf) if (i > he && i <= hf) {
{
fdepth = hf - i; fdepth = hf - i;
if(fblocks == null) if (fblocks == null) {
{
fblocks = biome.generateSeaLayers(realX, realZ, rng, hf - he, getData()); fblocks = biome.generateSeaLayers(realX, realZ, rng, hf - he, getData());
} }
if(fblocks.hasIndex(fdepth)) if (fblocks.hasIndex(fdepth)) {
{
h.set(xf, i, zf, fblocks.get(fdepth)); h.set(xf, i, zf, fblocks.get(fdepth));
continue; continue;
} }
@@ -95,16 +84,13 @@ public class IrisTerrainActuator extends EngineAssignedActuator<BlockData>
continue; continue;
} }
if(i <= he) if (i <= he) {
{
depth = he - i; depth = he - i;
if(blocks == null) if (blocks == null) {
{ blocks = biome.generateLayers(realX, realZ, rng, he, he, getData(), getComplex());
blocks = biome.generateLayers(realX, realZ, rng, (int)he, (int)he, getData(), getComplex());
} }
if(blocks.hasIndex(depth)) if (blocks.hasIndex(depth)) {
{
h.set(xf, i, zf, blocks.get(depth)); h.set(xf, i, zf, blocks.get(depth));
continue; continue;
} }
@@ -8,8 +8,7 @@ import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.hunk.Hunk; import com.volmit.iris.scaffold.hunk.Hunk;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
public class IrisCeilingDecorator extends IrisEngineDecorator public class IrisCeilingDecorator extends IrisEngineDecorator {
{
public IrisCeilingDecorator(Engine engine) { public IrisCeilingDecorator(Engine engine) {
super(engine, "Ceiling", DecorationPart.CEILING); super(engine, "Ceiling", DecorationPart.CEILING);
} }
@@ -18,28 +17,20 @@ public class IrisCeilingDecorator extends IrisEngineDecorator
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) { public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
IrisDecorator decorator = getDecorator(biome, realX, realZ); IrisDecorator decorator = getDecorator(biome, realX, realZ);
if(decorator != null) if (decorator != null) {
{ if (!decorator.isStacking()) {
if(!decorator.isStacking()) if (height >= 0 || height < getEngine().getHeight()) {
{
if(height >= 0 || height < getEngine().getHeight())
{
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
} }
} } else {
else
{
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
stack = Math.min(max + 1, stack); stack = Math.min(max + 1, stack);
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
for(int i = 0; i < stack; i++) for (int i = 0; i < stack; i++) {
{ if (height - i < 0 || height - i > getEngine().getHeight()) {
if(height - i < 0 || height - i > getEngine().getHeight())
{
continue; continue;
} }
@@ -5,11 +5,11 @@ import com.volmit.iris.object.DecorationPart;
import com.volmit.iris.object.IrisBiome; import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisDecorator; import com.volmit.iris.object.IrisDecorator;
import com.volmit.iris.scaffold.cache.Cache; import com.volmit.iris.scaffold.cache.Cache;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.RNG;
import com.volmit.iris.scaffold.engine.Engine; import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.engine.EngineAssignedComponent; import com.volmit.iris.scaffold.engine.EngineAssignedComponent;
import com.volmit.iris.scaffold.engine.EngineDecorator; import com.volmit.iris.scaffold.engine.EngineDecorator;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.RNG;
import lombok.Getter; import lombok.Getter;
public abstract class IrisEngineDecorator extends EngineAssignedComponent implements EngineDecorator { public abstract class IrisEngineDecorator extends EngineAssignedComponent implements EngineDecorator {
@@ -26,23 +26,16 @@ public abstract class IrisEngineDecorator extends EngineAssignedComponent implem
this.rng = new RNG(getSeed() + 29356788 - (part.ordinal() * 10439677)); this.rng = new RNG(getSeed() + 29356788 - (part.ordinal() * 10439677));
} }
protected IrisDecorator getDecorator(IrisBiome biome, double realX, double realZ) protected IrisDecorator getDecorator(IrisBiome biome, double realX, double realZ) {
{
KList<IrisDecorator> v = new KList<>(); KList<IrisDecorator> v = new KList<>();
RNG rng = new RNG(Cache.key((int) realX, (int) realZ)); RNG rng = new RNG(Cache.key((int) realX, (int) realZ));
for(IrisDecorator i : biome.getDecorators()) for (IrisDecorator i : biome.getDecorators()) {
{ try {
try if (i.getPartOf().equals(part) && i.getBlockData(biome, this.rng, realX, realZ, getData()) != null) {
{
if(i.getPartOf().equals(part) && i.getBlockData(biome, this.rng, realX, realZ, getData()) != null)
{
v.add(i); v.add(i);
} }
} } catch (Throwable e) {
catch(Throwable e)
{
Iris.error("PART OF: " + biome.getLoadFile().getAbsolutePath() + " HAS AN INVALID DECORATOR near 'partOf'!!!"); Iris.error("PART OF: " + biome.getLoadFile().getAbsolutePath() + " HAS AN INVALID DECORATOR near 'partOf'!!!");
} }
} }
@@ -8,8 +8,7 @@ import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.hunk.Hunk; import com.volmit.iris.scaffold.hunk.Hunk;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
public class IrisSeaFloorDecorator extends IrisEngineDecorator public class IrisSeaFloorDecorator extends IrisEngineDecorator {
{
public IrisSeaFloorDecorator(Engine engine) { public IrisSeaFloorDecorator(Engine engine) {
super(engine, "Sea Floor", DecorationPart.SEA_FLOOR); super(engine, "Sea Floor", DecorationPart.SEA_FLOOR);
} }
@@ -20,32 +19,24 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator
IrisDecorator decorator = getDecorator(biome, realX, realZ); IrisDecorator decorator = getDecorator(biome, realX, realZ);
if(decorator != null) if (decorator != null) {
{ if (!decorator.isStacking()) {
if(!decorator.isStacking()) if (height >= 0 || height < getEngine().getHeight()) {
{
if(height >= 0 || height < getEngine().getHeight())
{
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
} }
} } else {
else
{
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
stack = Math.min(stack, getDimension().getFluidHeight() - height + 2); stack = Math.min(stack, getDimension().getFluidHeight() - height + 2);
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
for(int i = 0; i < stack; i++) for (int i = 0; i < stack; i++) {
{ if (height - i < 0 || height - i > getEngine().getHeight()) {
if(height - i < 0 || height - i > getEngine().getHeight())
{
continue; continue;
} }
if(height+i > getDimension().getFluidHeight()) if (height + i > getDimension().getFluidHeight()) {
{
continue; continue;
} }
@@ -8,8 +8,7 @@ import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.hunk.Hunk; import com.volmit.iris.scaffold.hunk.Hunk;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
public class IrisSeaSurfaceDecorator extends IrisEngineDecorator public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
{
public IrisSeaSurfaceDecorator(Engine engine) { public IrisSeaSurfaceDecorator(Engine engine) {
super(engine, "Sea Surface", DecorationPart.SEA_SURFACE); super(engine, "Sea Surface", DecorationPart.SEA_SURFACE);
} }
@@ -18,26 +17,18 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) { public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
IrisDecorator decorator = getDecorator(biome, realX, realZ); IrisDecorator decorator = getDecorator(biome, realX, realZ);
if(decorator != null) if (decorator != null) {
{ if (!decorator.isStacking()) {
if(!decorator.isStacking()) if (height >= 0 || height < getEngine().getHeight()) {
{
if(height >= 0 || height < getEngine().getHeight())
{
data.set(x, getDimension().getFluidHeight() + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); data.set(x, getDimension().getFluidHeight() + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
} }
} } else {
else
{
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
for(int i = 0; i < stack; i++) for (int i = 0; i < stack; i++) {
{ if (height - i < 0 || height - i > getEngine().getHeight()) {
if(height - i < 0 || height - i > getEngine().getHeight())
{
continue; continue;
} }
@@ -8,8 +8,7 @@ import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.hunk.Hunk; import com.volmit.iris.scaffold.hunk.Hunk;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
public class IrisShoreLineDecorator extends IrisEngineDecorator public class IrisShoreLineDecorator extends IrisEngineDecorator {
{
public IrisShoreLineDecorator(Engine engine) { public IrisShoreLineDecorator(Engine engine) {
super(engine, "Shore Line", DecorationPart.SHORE_LINE); super(engine, "Shore Line", DecorationPart.SHORE_LINE);
} }
@@ -22,25 +21,19 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator
Math.round(getComplex().getHeightStream().get(realX_1, realZ)) < getComplex().getFluidHeight() || Math.round(getComplex().getHeightStream().get(realX_1, realZ)) < getComplex().getFluidHeight() ||
Math.round(getComplex().getHeightStream().get(realX, realZ1)) < getComplex().getFluidHeight() || Math.round(getComplex().getHeightStream().get(realX, realZ1)) < getComplex().getFluidHeight() ||
Math.round(getComplex().getHeightStream().get(realX, realZ_1)) < getComplex().getFluidHeight() Math.round(getComplex().getHeightStream().get(realX, realZ_1)) < getComplex().getFluidHeight()
) ) {
{
IrisDecorator decorator = getDecorator(biome, realX, realZ); IrisDecorator decorator = getDecorator(biome, realX, realZ);
if(decorator != null) if (decorator != null) {
{ if (!decorator.isStacking()) {
if(!decorator.isStacking())
{
data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
} } else {
else
{
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
for(int i = 0; i < stack; i++) for (int i = 0; i < stack; i++) {
{
double threshold = ((double) i) / (stack - 1); double threshold = ((double) i) / (stack - 1);
data.set(x, height + 1 + i, z, threshold >= decorator.getTopThreshold() ? top : fill); data.set(x, height + 1 + i, z, threshold >= decorator.getTopThreshold() ? top : fill);
} }
@@ -10,16 +10,14 @@ import com.volmit.iris.scaffold.hunk.Hunk;
import org.bukkit.block.data.Bisected; import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
public class IrisSurfaceDecorator extends IrisEngineDecorator public class IrisSurfaceDecorator extends IrisEngineDecorator {
{
public IrisSurfaceDecorator(Engine engine) { public IrisSurfaceDecorator(Engine engine) {
super(engine, "Surface", DecorationPart.NONE); super(engine, "Surface", DecorationPart.NONE);
} }
@Override @Override
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) { public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
if(biome.getInferredType().equals(InferredType.SHORE) && height < getDimension().getFluidHeight()) if (biome.getInferredType().equals(InferredType.SHORE) && height < getDimension().getFluidHeight()) {
{
return; return;
} }
@@ -28,31 +26,22 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator
bdx = data.get(x, height, z); bdx = data.get(x, height, z);
boolean underwater = height < getDimension().getFluidHeight(); boolean underwater = height < getDimension().getFluidHeight();
if(decorator != null) if (decorator != null) {
{ if (!decorator.isStacking()) {
if(!decorator.isStacking())
{
bd = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); bd = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
if(!underwater) if (!underwater) {
{ if (!canGoOn(bd, bdx)) {
if(!canGoOn(bd, bdx))
{
return; return;
} }
} }
if(bd instanceof Bisected) if (bd instanceof Bisected) {
{
bd = bd.clone(); bd = bd.clone();
((Bisected) bd).setHalf(Bisected.Half.TOP); ((Bisected) bd).setHalf(Bisected.Half.TOP);
try try {
{
data.set(x, height + 2, z, bd); data.set(x, height + 2, z, bd);
} } catch (Throwable e) {
catch(Throwable e)
{
} }
bd = bd.clone(); bd = bd.clone();
@@ -61,11 +50,8 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator
data.set(x, height + 1, z, bd); data.set(x, height + 1, z, bd);
} } else {
else if (height < getDimension().getFluidHeight()) {
{
if (height < getDimension().getFluidHeight())
{
max = getDimension().getFluidHeight() - height; max = getDimension().getFluidHeight() - height;
} }
@@ -73,23 +59,19 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
for(int i = 0; i < stack; i++) for (int i = 0; i < stack; i++) {
{
double threshold = ((double) i) / (stack - 1); double threshold = ((double) i) / (stack - 1);
bd = threshold >= decorator.getTopThreshold() ? top : fill; bd = threshold >= decorator.getTopThreshold() ? top : fill;
if(bd == null) if (bd == null) {
{
break; break;
} }
if(i == 0 && !underwater && !canGoOn(bd, bdx)) if (i == 0 && !underwater && !canGoOn(bd, bdx)) {
{
break; break;
} }
if(underwater && height + 1 + i > getDimension().getFluidHeight()) if (underwater && height + 1 + i > getDimension().getFluidHeight()) {
{
break; break;
} }
@@ -12,8 +12,7 @@ import org.bukkit.block.data.BlockData;
import java.util.function.Function; import java.util.function.Function;
public class IrisCaveModifier extends EngineAssignedModifier<BlockData> public class IrisCaveModifier extends EngineAssignedModifier<BlockData> {
{
public static final BlockData CAVE_AIR = B.get("CAVE_AIR"); public static final BlockData CAVE_AIR = B.get("CAVE_AIR");
public static final BlockData AIR = B.get("AIR"); public static final BlockData AIR = B.get("AIR");
private static final KList<CaveResult> EMPTY = new KList<>(); private static final KList<CaveResult> EMPTY = new KList<>();
@@ -28,31 +27,24 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
@Override @Override
public void onModify(int x, int z, Hunk<BlockData> a) { public void onModify(int x, int z, Hunk<BlockData> a) {
if(!getDimension().isCaves()) if (!getDimension().isCaves()) {
{
return; return;
} }
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
for(int i = 0; i < a.getWidth(); i++) for (int i = 0; i < a.getWidth(); i++) {
{ for (int j = 0; j < a.getDepth(); j++) {
for(int j = 0; j < a.getDepth(); j++)
{
KList<CaveResult> caves = genCaves(x + i, z + j, i, j, a); KList<CaveResult> caves = genCaves(x + i, z + j, i, j, a);
int he = (int) Math.round(getComplex().getHeightStream().get(x + i, z + j)); int he = (int) Math.round(getComplex().getHeightStream().get(x + i, z + j));
if(caves != null && caves.isNotEmpty()) if (caves != null && caves.isNotEmpty()) {
{
IrisBiome cave = getComplex().getCaveBiomeStream().get(x + i, z + j); IrisBiome cave = getComplex().getCaveBiomeStream().get(x + i, z + j);
if(cave == null) if (cave == null) {
{
continue; continue;
} }
for(CaveResult cl : caves) for (CaveResult cl : caves) {
{ if (cl.getFloor() < 0 || cl.getFloor() > getEngine().getHeight() || cl.getCeiling() > getEngine().getHeight() || cl.getCeiling() < 0) {
if(cl.getFloor() < 0 || cl.getFloor() > getEngine().getHeight() || cl.getCeiling() > getEngine().getHeight() || cl.getCeiling() < 0)
{
continue; continue;
} }
@@ -61,13 +53,11 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
he - cl.getCeiling(), he - cl.getCeiling(),
he - cl.getCeiling(), getData(), getComplex()); he - cl.getCeiling(), getData(), getComplex());
for(int g = 0; g < floor.size(); g++) for (int g = 0; g < floor.size(); g++) {
{
a.set(i, cl.getFloor() - g, j, floor.get(g)); a.set(i, cl.getFloor() - g, j, floor.get(g));
} }
for(int g = ceiling.size() - 1; g > 0; g--) for (int g = ceiling.size() - 1; g > 0; g--) {
{
a.set(i, cl.getCeiling() + g, j, ceiling.get(g)); a.set(i, cl.getCeiling() + g, j, ceiling.get(g));
} }
} }
@@ -78,10 +68,8 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
getEngine().getMetrics().getCave().put(p.getMilliseconds()); getEngine().getMetrics().getCave().put(p.getMilliseconds());
} }
public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, Hunk<BlockData> data) public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, Hunk<BlockData> data) {
{ if (!getDimension().isCaves()) {
if(!getDimension().isCaves())
{
return EMPTY; return EMPTY;
} }
@@ -90,8 +78,7 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
gg.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub); gg.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
gg.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural); gg.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
for(int i = 0; i < getDimension().getCaveLayers().size(); i++) for (int i = 0; i < getDimension().getCaveLayers().size(); i++) {
{
IrisCaveLayer layer = getDimension().getCaveLayers().get(i); IrisCaveLayer layer = getDimension().getCaveLayers().get(i);
generateCave(result, wxx, wzz, x, z, data, layer, i); generateCave(result, wxx, wzz, x, z, data, layer, i);
} }
@@ -99,23 +86,17 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
return result; return result;
} }
public void generateCave(KList<CaveResult> result, double wxx, double wzz, int x, int z, Hunk<BlockData> data, IrisCaveLayer layer, int seed) public void generateCave(KList<CaveResult> result, double wxx, double wzz, int x, int z, Hunk<BlockData> data, IrisCaveLayer layer, int seed) {
{
double scale = layer.getCaveZoom(); double scale = layer.getCaveZoom();
Function<Integer, BlockData> fluid = (height) -> Function<Integer, BlockData> fluid = (height) ->
{ {
if(!layer.getFluid().hasFluid(getData())) if (!layer.getFluid().hasFluid(getData())) {
{
return CAVE_AIR; return CAVE_AIR;
} }
if(layer.getFluid().isInverseHeight() && height >= layer.getFluid().getFluidHeight()) if (layer.getFluid().isInverseHeight() && height >= layer.getFluid().getFluidHeight()) {
{
return layer.getFluid().getFluid(getData()); return layer.getFluid().getFluid(getData());
} } else if (!layer.getFluid().isInverseHeight() && height <= layer.getFluid().getFluidHeight()) {
else if(!layer.getFluid().isInverseHeight() && height <= layer.getFluid().getFluidHeight())
{
return layer.getFluid().getFluid(getData()); return layer.getFluid().getFluid(getData());
} }
@@ -130,8 +111,7 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
double distanceTake = 0.0022 * baseWidth; double distanceTake = 0.0022 * baseWidth;
double caveHeightNoise = layer.getVerticalSlope().get(rng, wxx, wzz); double caveHeightNoise = layer.getVerticalSlope().get(rng, wxx, wzz);
if(caveHeightNoise > 259 || caveHeightNoise < -1) if (caveHeightNoise > 259 || caveHeightNoise < -1) {
{
return; return;
} }
@@ -139,62 +119,48 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
int ceiling = -256; int ceiling = -256;
int floor = 512; int floor = 512;
for(double tunnelHeight = 1; tunnelHeight <= baseWidth; tunnelHeight++) for (double tunnelHeight = 1; tunnelHeight <= baseWidth; tunnelHeight++) {
{
double distance = (gg.GetCellular(((wx + (10000 * seed)) / layer.getCaveZoom()), ((wz - (10000 * seed)) / layer.getCaveZoom())) + 1D) / 2D; double distance = (gg.GetCellular(((wx + (10000 * seed)) / layer.getCaveZoom()), ((wz - (10000 * seed)) / layer.getCaveZoom())) + 1D) / 2D;
if(distance < distanceCheck - (tunnelHeight * distanceTake)) if (distance < distanceCheck - (tunnelHeight * distanceTake)) {
{
int caveHeight = (int) Math.round(caveHeightNoise); int caveHeight = (int) Math.round(caveHeightNoise);
int pu = (int) (caveHeight + tunnelHeight); int pu = (int) (caveHeight + tunnelHeight);
int pd = (int) (caveHeight - tunnelHeight); int pd = (int) (caveHeight - tunnelHeight);
if(pd > surface + 1) if (pd > surface + 1) {
{
continue; continue;
} }
if(!layer.isCanBreakSurface() && pu > surface - 3) if (!layer.isCanBreakSurface() && pu > surface - 3) {
{
continue; continue;
} }
if((pu > 255 && pd > 255) || (pu < 0 && pd < 0)) if ((pu > 255 && pd > 255) || (pu < 0 && pd < 0)) {
{
continue; continue;
} }
if(data == null) if (data == null) {
{
ceiling = Math.max(pu, ceiling); ceiling = Math.max(pu, ceiling);
floor = Math.min(pu, floor); floor = Math.min(pu, floor);
ceiling = Math.max(pd, ceiling); ceiling = Math.max(pd, ceiling);
floor = Math.min(pd, floor); floor = Math.min(pd, floor);
if(tunnelHeight == 1) if (tunnelHeight == 1) {
{
ceiling = Math.max(caveHeight, ceiling); ceiling = Math.max(caveHeight, ceiling);
floor = Math.min(caveHeight, floor); floor = Math.min(caveHeight, floor);
} }
} } else {
if (dig(x, pu, z, data, fluid)) {
else
{
if(dig(x, pu, z, data, fluid))
{
ceiling = Math.max(pu, ceiling); ceiling = Math.max(pu, ceiling);
floor = Math.min(pu, floor); floor = Math.min(pu, floor);
} }
if(dig(x, pd, z, data, fluid)) if (dig(x, pd, z, data, fluid)) {
{
ceiling = Math.max(pd, ceiling); ceiling = Math.max(pd, ceiling);
floor = Math.min(pd, floor); floor = Math.min(pd, floor);
} }
if(tunnelHeight == 1) if (tunnelHeight == 1) {
{ if (dig(x, caveHeight, z, data, fluid)) {
if(dig(x, caveHeight, z, data, fluid))
{
ceiling = Math.max(caveHeight, ceiling); ceiling = Math.max(caveHeight, ceiling);
floor = Math.min(caveHeight, floor); floor = Math.min(caveHeight, floor);
} }
@@ -203,26 +169,22 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
} }
} }
if(floor >= 0 && ceiling <= 255) if (floor >= 0 && ceiling <= 255) {
{
result.add(new CaveResult(floor, ceiling)); result.add(new CaveResult(floor, ceiling));
} }
} }
private Material mat(int x, int y, int z, Hunk<BlockData> data) private Material mat(int x, int y, int z, Hunk<BlockData> data) {
{
BlockData d = data.get(Math.max(x, 0), Math.max(y, 0), Math.max(z, 0)); BlockData d = data.get(Math.max(x, 0), Math.max(y, 0), Math.max(z, 0));
if(d != null) if (d != null) {
{
return d.getMaterial(); return d.getMaterial();
} }
return Material.CAVE_AIR; return Material.CAVE_AIR;
} }
public boolean dig(int x, int y, int z, Hunk<BlockData> data, Function<Integer, BlockData> caveFluid) public boolean dig(int x, int y, int z, Hunk<BlockData> data, Function<Integer, BlockData> caveFluid) {
{
Material a = mat(x, y, z, data); Material a = mat(x, y, z, data);
Material c = mat(x, y + 1, z, data); Material c = mat(x, y + 1, z, data);
Material d = mat(x, y + 2, z, data); Material d = mat(x, y + 2, z, data);
@@ -231,8 +193,7 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
BlockData b = caveFluid.apply(y); BlockData b = caveFluid.apply(y);
BlockData b2 = caveFluid.apply(y + 1); BlockData b2 = caveFluid.apply(y + 1);
if(can(a) && canAir(c, b) && canAir(f, b) && canWater(d) && canWater(e)) if (can(a) && canAir(c, b) && canAir(f, b) && canWater(d) && canWater(e)) {
{
data.set(x, y, z, b); data.set(x, y, z, b);
data.set(x, y + 1, z, b2); data.set(x, y + 1, z, b2);
return true; return true;
@@ -241,8 +202,7 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
return false; return false;
} }
public boolean canAir(Material m, BlockData caveFluid) public boolean canAir(Material m, BlockData caveFluid) {
{
return (B.isSolid(m) || return (B.isSolid(m) ||
(B.isDecorant(m.createBlockData())) || m.equals(Material.AIR) (B.isDecorant(m.createBlockData())) || m.equals(Material.AIR)
|| m.equals(caveFluid.getMaterial()) || || m.equals(caveFluid.getMaterial()) ||
@@ -250,13 +210,11 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
&& !m.equals(Material.BEDROCK); && !m.equals(Material.BEDROCK);
} }
public boolean canWater(Material m) public boolean canWater(Material m) {
{
return !m.equals(Material.WATER); return !m.equals(Material.WATER);
} }
public boolean can(Material m) public boolean can(Material m) {
{
return B.isSolid(m) && !m.equals(Material.BEDROCK); return B.isSolid(m) && !m.equals(Material.BEDROCK);
} }
} }
@@ -15,6 +15,7 @@ import org.bukkit.util.BlockVector;
public class IrisDepositModifier extends EngineAssignedModifier<BlockData> { public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
private final RNG rng; private final RNG rng;
public IrisDepositModifier(Engine engine) { public IrisDepositModifier(Engine engine) {
super(engine, "Deposit"); super(engine, "Deposit");
rng = new RNG(getEngine().getWorld().getSeed() + 12938).nextParallelRNG(28348777); rng = new RNG(getEngine().getWorld().getSeed() + 12938).nextParallelRNG(28348777);
@@ -27,50 +28,40 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
getEngine().getMetrics().getDeposit().put(p.getMilliseconds()); getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
} }
public void generateDeposits(RNG rx, Hunk<BlockData> terrain, int x, int z) public void generateDeposits(RNG rx, Hunk<BlockData> terrain, int x, int z) {
{
RNG ro = rx.nextParallelRNG(x * x).nextParallelRNG(z * z); RNG ro = rx.nextParallelRNG(x * x).nextParallelRNG(z * z);
IrisRegion region = getComplex().getRegionStream().get((x * 16) + 7, (z * 16) + 7); IrisRegion region = getComplex().getRegionStream().get((x * 16) + 7, (z * 16) + 7);
IrisBiome biome = getComplex().getTrueBiomeStream().get((x * 16) + 7, (z * 16) + 7); IrisBiome biome = getComplex().getTrueBiomeStream().get((x * 16) + 7, (z * 16) + 7);
for(IrisDepositGenerator k : getDimension().getDeposits()) for (IrisDepositGenerator k : getDimension().getDeposits()) {
{
generate(k, terrain, ro, x, z, false); generate(k, terrain, ro, x, z, false);
} }
for(IrisDepositGenerator k : region.getDeposits()) for (IrisDepositGenerator k : region.getDeposits()) {
{ for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
{
generate(k, terrain, ro, x, z, false); generate(k, terrain, ro, x, z, false);
} }
} }
for(IrisDepositGenerator k : biome.getDeposits()) for (IrisDepositGenerator k : biome.getDeposits()) {
{ for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
{
generate(k, terrain, ro, x, z, false); generate(k, terrain, ro, x, z, false);
} }
} }
} }
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe) public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe) {
{
generate(k, data, rng, cx, cz, safe, null); generate(k, data, rng, cx, cz, safe, null);
} }
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, HeightMap he) public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, HeightMap he) {
{ for (int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
for(int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
{
IrisObject clump = k.getClump(rng, getData()); IrisObject clump = k.getClump(rng, getData());
int af = (int) Math.ceil(clump.getW() / 2D); int af = (int) Math.ceil(clump.getW() / 2D);
int bf = (int) Math.floor(16D - (clump.getW() / 2D)); int bf = (int) Math.floor(16D - (clump.getW() / 2D));
if(af > bf || af < 0 || bf > 15 || af > 15 || bf < 0) if (af > bf || af < 0 || bf > 15 || af > 15 || bf < 0) {
{
af = 6; af = 6;
bf = 9; bf = 9;
} }
@@ -81,8 +72,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
getComplex().getHeightStream().get((cx << 4) + x, (cz << 4) + z) getComplex().getHeightStream().get((cx << 4) + x, (cz << 4) + z)
))) - 7; ))) - 7;
if(height <= 0) if (height <= 0) {
{
return; return;
} }
@@ -90,26 +80,22 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
// TODO: WARNING HEIGHT // TODO: WARNING HEIGHT
int a = Math.min(height, Math.min(256, k.getMaxHeight())); int a = Math.min(height, Math.min(256, k.getMaxHeight()));
if(i >= a) if (i >= a) {
{
return; return;
} }
int h = rng.i(i, a); int h = rng.i(i, a);
if(h > k.getMaxHeight() || h < k.getMinHeight() || h > height - 2) if (h > k.getMaxHeight() || h < k.getMinHeight() || h > height - 2) {
{
return; return;
} }
for(BlockVector j : clump.getBlocks().keySet()) for (BlockVector j : clump.getBlocks().keySet()) {
{
int nx = j.getBlockX() + x; int nx = j.getBlockX() + x;
int ny = j.getBlockY() + h; int ny = j.getBlockY() + h;
int nz = j.getBlockZ() + z; int nz = j.getBlockZ() + z;
if(ny > height || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15) if (ny > height || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15) {
{
continue; continue;
} }
@@ -125,8 +111,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
} }
} }
if(allow) if (allow) {
{
data.set(nx, ny, nz, clump.getBlocks().get(j)); data.set(nx, ny, nz, clump.getBlocks().get(j));
} }
} }
@@ -31,11 +31,9 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
BurstExecutor b = MultiBurst.burst.burst(output.getWidth() * output.getDepth()); BurstExecutor b = MultiBurst.burst.burst(output.getWidth() * output.getDepth());
int i, j; int i, j;
for(i = 0; i < output.getWidth(); i++) for (i = 0; i < output.getWidth(); i++) {
{
int ii = i; int ii = i;
for(j = 0; j < output.getDepth(); j++) for (j = 0; j < output.getDepth(); j++) {
{
int jj = j; int jj = j;
b.queue(() -> post(ii, jj, output, ii + x, jj + z)); b.queue(() -> post(ii, jj, output, ii + x, jj + z));
} }
@@ -55,8 +53,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
// Floating Nibs // Floating Nibs
int g = 0; int g = 0;
if(h < 1) if (h < 1) {
{
return; return;
} }
@@ -65,14 +62,11 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
g += hc < h - 1 ? 1 : 0; g += hc < h - 1 ? 1 : 0;
g += hd < h - 1 ? 1 : 0; g += hd < h - 1 ? 1 : 0;
if(g == 4 && isAir(x, h - 1, z, currentPostX, currentPostZ, currentData)) if (g == 4 && isAir(x, h - 1, z, currentPostX, currentPostZ, currentData)) {
{
setPostBlock(x, h, z, AIR, currentPostX, currentPostZ, currentData); setPostBlock(x, h, z, AIR, currentPostX, currentPostZ, currentData);
for(int i = h - 1; i > 0; i--) for (int i = h - 1; i > 0; i--) {
{ if (!isAir(x, i, z, currentPostX, currentPostZ, currentData)) {
if(!isAir(x, i, z, currentPostX, currentPostZ, currentData))
{
h = i; h = i;
break; break;
} }
@@ -86,24 +80,18 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
g += hc == h - 1 ? 1 : 0; g += hc == h - 1 ? 1 : 0;
g += hd == h - 1 ? 1 : 0; g += hd == h - 1 ? 1 : 0;
if(g >= 4) if (g >= 4) {
{
BlockData bc = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData); BlockData bc = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
BlockData b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData); BlockData b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData);
Material m = bc.getMaterial(); Material m = bc.getMaterial();
if((b.getMaterial().isOccluding() && b.getMaterial().isSolid())) if ((b.getMaterial().isOccluding() && b.getMaterial().isSolid())) {
{ if (m.isSolid()) {
if(m.isSolid())
{
setPostBlock(x, h, z, b, currentPostX, currentPostZ, currentData); setPostBlock(x, h, z, b, currentPostX, currentPostZ, currentData);
h--; h--;
} }
} }
} } else {
else
{
// Potholes // Potholes
g = 0; g = 0;
g += ha == h + 1 ? 1 : 0; g += ha == h + 1 ? 1 : 0;
@@ -111,8 +99,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
g += hc == h + 1 ? 1 : 0; g += hc == h + 1 ? 1 : 0;
g += hd == h + 1 ? 1 : 0; g += hd == h + 1 ? 1 : 0;
if(g >= 4) if (g >= 4) {
{
BlockData ba = getPostBlock(x, ha, z, currentPostX, currentPostZ, currentData); BlockData ba = getPostBlock(x, ha, z, currentPostX, currentPostZ, currentData);
BlockData bb = getPostBlock(x, hb, z, currentPostX, currentPostZ, currentData); BlockData bb = getPostBlock(x, hb, z, currentPostX, currentPostZ, currentData);
BlockData bc = getPostBlock(x, hc, z, currentPostX, currentPostZ, currentData); BlockData bc = getPostBlock(x, hc, z, currentPostX, currentPostZ, currentData);
@@ -123,8 +110,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
g = B.isSolid(bc) ? g + 1 : g; g = B.isSolid(bc) ? g + 1 : g;
g = B.isSolid(bd) ? g + 1 : g; g = B.isSolid(bd) ? g + 1 : g;
if(g >= 3) if (g >= 3) {
{
setPostBlock(x, h + 1, z, getPostBlock(x, h, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData); setPostBlock(x, h + 1, z, getPostBlock(x, h, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData);
h++; h++;
} }
@@ -134,25 +120,18 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
// Wall Patcher // Wall Patcher
IrisBiome biome = getComplex().getTrueBiomeStream().get(x, z); IrisBiome biome = getComplex().getTrueBiomeStream().get(x, z);
if(getDimension().isPostProcessingWalls()) if (getDimension().isPostProcessingWalls()) {
{ if (!biome.getWall().getPalette().isEmpty()) {
if(!biome.getWall().getPalette().isEmpty()) if (ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2) {
{
if(ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2)
{
boolean brokeGround = false; boolean brokeGround = false;
int max = Math.abs(Math.max(h - ha, Math.max(h - hb, Math.max(h - hc, h - hd)))); int max = Math.abs(Math.max(h - ha, Math.max(h - hb, Math.max(h - hc, h - hd))));
for(int i = h; i > h - max; i--) for (int i = h; i > h - max; i--) {
{
BlockData d = biome.getWall().get(rng, x + i, i + h, z + i, getData()); BlockData d = biome.getWall().get(rng, x + i, i + h, z + i, getData());
if(d != null) if (d != null) {
{ if (isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData)) {
if(isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData)) if (brokeGround) {
{
if(brokeGround)
{
break; break;
} }
@@ -168,8 +147,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
} }
// Slab // Slab
if(getDimension().isPostProcessingSlabs()) if (getDimension().isPostProcessingSlabs()) {
{
//@builder //@builder
if ((ha == h + 1 && isSolidNonSlab(x + 1, ha, z, currentPostX, currentPostZ, currentData)) if ((ha == h + 1 && isSolidNonSlab(x + 1, ha, z, currentPostX, currentPostZ, currentData))
|| (hb == h + 1 && isSolidNonSlab(x, hb, z + 1, currentPostX, currentPostZ, currentData)) || (hb == h + 1 && isSolidNonSlab(x, hb, z + 1, currentPostX, currentPostZ, currentData))
@@ -179,27 +157,18 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
{ {
BlockData d = biome.getSlab().get(rng, x, h, z, getData()); BlockData d = biome.getSlab().get(rng, x, h, z, getData());
if(d != null) if (d != null) {
{ boolean cancel = B.isAir(d);
boolean cancel = false;
if(B.isAir(d)) if (d.getMaterial().equals(Material.SNOW) && h + 1 <= getDimension().getFluidHeight()) {
{
cancel = true; cancel = true;
} }
if(d.getMaterial().equals(Material.SNOW) && h + 1 <= getDimension().getFluidHeight()) if (isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData)) {
{
cancel = true; cancel = true;
} }
if(isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData)) if (!cancel && isAirOrWater(x, h + 1, z, currentPostX, currentPostZ, currentData)) {
{
cancel = true;
}
if(!cancel && isAirOrWater(x, h + 1, z, currentPostX, currentPostZ, currentData))
{
setPostBlock(x, h + 1, z, d, currentPostX, currentPostZ, currentData); setPostBlock(x, h + 1, z, d, currentPostX, currentPostZ, currentData);
h++; h++;
} }
@@ -210,34 +179,24 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
// Waterlogging // Waterlogging
BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData); BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
if(b instanceof Waterlogged) if (b instanceof Waterlogged) {
{
Waterlogged ww = (Waterlogged) b.clone(); Waterlogged ww = (Waterlogged) b.clone();
boolean w = false; boolean w = false;
if (h <= getDimension().getFluidHeight() + 1) { if (h <= getDimension().getFluidHeight() + 1) {
if(isWaterOrWaterlogged(x, h + 1, z, currentPostX, currentPostZ, currentData)) if (isWaterOrWaterlogged(x, h + 1, z, currentPostX, currentPostZ, currentData)) {
{
w = true; w = true;
} } else if ((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) {
else if((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData)))
{
w = true; w = true;
} }
} }
if(w != ww.isWaterlogged()) if (w != ww.isWaterlogged()) {
{
ww.setWaterlogged(w); ww.setWaterlogged(w);
setPostBlock(x, h, z, ww, currentPostX, currentPostZ, currentData); setPostBlock(x, h, z, ww, currentPostX, currentPostZ, currentData);
} }
} } else if (b.getMaterial().equals(Material.AIR) && h <= getDimension().getFluidHeight()) {
if ((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) {
else if(b.getMaterial().equals(Material.AIR) && h <= getDimension().getFluidHeight())
{
if((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData)))
{
setPostBlock(x, h, z, WATER, currentPostX, currentPostZ, currentData); setPostBlock(x, h, z, WATER, currentPostX, currentPostZ, currentData);
} }
} }
@@ -245,26 +204,20 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
// Foliage // Foliage
b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData); b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData);
if(B.isFoliage(b) || b.getMaterial().equals(Material.DEAD_BUSH)) if (B.isFoliage(b) || b.getMaterial().equals(Material.DEAD_BUSH)) {
{
Material onto = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData).getMaterial(); Material onto = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData).getMaterial();
if(!B.canPlaceOnto(b.getMaterial(), onto)) if (!B.canPlaceOnto(b.getMaterial(), onto)) {
{
setPostBlock(x, h + 1, z, AIR, currentPostX, currentPostZ, currentData); setPostBlock(x, h + 1, z, AIR, currentPostX, currentPostZ, currentData);
} }
} }
if(getDimension().isPostProcessCaves()) if (getDimension().isPostProcessCaves()) {
{
IrisBiome cave = getComplex().getCaveBiomeStream().get(x, z); IrisBiome cave = getComplex().getCaveBiomeStream().get(x, z);
if(cave != null) if (cave != null) {
{ for (CaveResult i : ((IrisCaveModifier) getFramework().getCaveModifier()).genCaves(x, z, 0, 0, null)) {
for(CaveResult i : ((IrisCaveModifier)getFramework().getCaveModifier()).genCaves(x, z, 0, 0, null)) if (i.getCeiling() >= currentData.getMax2DParallelism() || i.getFloor() < 0) {
{
if(i.getCeiling() >= currentData.getMax2DParallelism() || i.getFloor() < 0)
{
continue; continue;
} }
@@ -286,21 +239,16 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
g += fc == f - 1 ? 1 : 0; g += fc == f - 1 ? 1 : 0;
g += fd == f - 1 ? 1 : 0; g += fd == f - 1 ? 1 : 0;
if(g >= 4) if (g >= 4) {
{
BlockData bc = getPostBlock(x, f, z, currentPostX, currentPostZ, currentData); BlockData bc = getPostBlock(x, f, z, currentPostX, currentPostZ, currentData);
b = getPostBlock(x, f + 1, z, currentPostX, currentPostZ, currentData); b = getPostBlock(x, f + 1, z, currentPostX, currentPostZ, currentData);
Material m = bc.getMaterial(); Material m = bc.getMaterial();
if(m.isSolid()) if (m.isSolid()) {
{
setPostBlock(x, f, z, b, currentPostX, currentPostZ, currentData); setPostBlock(x, f, z, b, currentPostX, currentPostZ, currentData);
h--; h--;
} }
} } else {
else
{
// Cave Potholes // Cave Potholes
g = 0; g = 0;
g += fa == f + 1 ? 1 : 0; g += fa == f + 1 ? 1 : 0;
@@ -308,8 +256,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
g += fc == f + 1 ? 1 : 0; g += fc == f + 1 ? 1 : 0;
g += fd == f + 1 ? 1 : 0; g += fd == f + 1 ? 1 : 0;
if(g >= 4) if (g >= 4) {
{
BlockData ba = getPostBlock(x, fa, z, currentPostX, currentPostZ, currentData); BlockData ba = getPostBlock(x, fa, z, currentPostX, currentPostZ, currentData);
BlockData bb = getPostBlock(x, fb, z, currentPostX, currentPostZ, currentData); BlockData bb = getPostBlock(x, fb, z, currentPostX, currentPostZ, currentData);
BlockData bc = getPostBlock(x, fc, z, currentPostX, currentPostZ, currentData); BlockData bc = getPostBlock(x, fc, z, currentPostX, currentPostZ, currentData);
@@ -320,16 +267,14 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
g = B.isSolid(bc) ? g + 1 : g; g = B.isSolid(bc) ? g + 1 : g;
g = B.isSolid(bd) ? g + 1 : g; g = B.isSolid(bd) ? g + 1 : g;
if(g >= 4) if (g >= 4) {
{
setPostBlock(x, f + 1, z, getPostBlock(x, f, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData); setPostBlock(x, f + 1, z, getPostBlock(x, f, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData);
h++; h++;
} }
} }
} }
if(getDimension().isPostProcessingSlabs()) if (getDimension().isPostProcessingSlabs()) {
{
//@builder //@builder
if ((fa == f + 1 && isSolidNonSlab(x + 1, fa, z, currentPostX, currentPostZ, currentData)) if ((fa == f + 1 && isSolidNonSlab(x + 1, fa, z, currentPostX, currentPostZ, currentData))
|| (fb == f + 1 && isSolidNonSlab(x, fb, z + 1, currentPostX, currentPostZ, currentData)) || (fb == f + 1 && isSolidNonSlab(x, fb, z + 1, currentPostX, currentPostZ, currentData))
@@ -339,27 +284,18 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
{ {
BlockData d = cave.getSlab().get(rng, x, f, z, getData()); BlockData d = cave.getSlab().get(rng, x, f, z, getData());
if(d != null) if (d != null) {
{ boolean cancel = B.isAir(d);
boolean cancel = false;
if(B.isAir(d)) if (d.getMaterial().equals(Material.SNOW) && f + 1 <= getDimension().getFluidHeight()) {
{
cancel = true; cancel = true;
} }
if(d.getMaterial().equals(Material.SNOW) && f + 1 <= getDimension().getFluidHeight()) if (isSnowLayer(x, f, z, currentPostX, currentPostZ, currentData)) {
{
cancel = true; cancel = true;
} }
if(isSnowLayer(x, f, z, currentPostX, currentPostZ, currentData)) if (!cancel && isAirOrWater(x, f + 1, z, currentPostX, currentPostZ, currentData)) {
{
cancel = true;
}
if(!cancel && isAirOrWater(x, f + 1, z, currentPostX, currentPostZ, currentData))
{
setPostBlock(x, f + 1, z, d, currentPostX, currentPostZ, currentData); setPostBlock(x, f + 1, z, d, currentPostX, currentPostZ, currentData);
} }
} }
@@ -374,27 +310,18 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
{ {
BlockData d = cave.getSlab().get(rng, x, c, z, getData()); BlockData d = cave.getSlab().get(rng, x, c, z, getData());
if(d != null) if (d != null) {
{ boolean cancel = B.isAir(d);
boolean cancel = false;
if(B.isAir(d)) if (!(d instanceof Slab)) {
{
cancel = true; cancel = true;
} }
if(!(d instanceof Slab)) if (isSnowLayer(x, c, z, currentPostX, currentPostZ, currentData)) {
{
cancel = true; cancel = true;
} }
if(isSnowLayer(x, c, z, currentPostX, currentPostZ, currentData)) if (!cancel && isAirOrWater(x, c, z, currentPostX, currentPostZ, currentData)) {
{
cancel = true;
}
if(!cancel && isAirOrWater(x, c, z, currentPostX, currentPostZ, currentData))
{
Slab slab = (Slab) d.clone(); Slab slab = (Slab) d.clone();
slab.setType(Slab.Type.TOP); slab.setType(Slab.Type.TOP);
setPostBlock(x, c, z, slab, currentPostX, currentPostZ, currentData); setPostBlock(x, c, z, slab, currentPostX, currentPostZ, currentData);
@@ -407,29 +334,20 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
} }
} }
private int nearestCaveFloor(int floor, int x, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) private int nearestCaveFloor(int floor, int x, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{ if (floor >= currentData.getHeight()) {
if(floor >= currentData.getHeight())
{
return currentData.getHeight() - 1; return currentData.getHeight() - 1;
} }
if(B.isAir(getPostBlock(x, floor, z, currentPostX, currentPostZ, currentData))) if (B.isAir(getPostBlock(x, floor, z, currentPostX, currentPostZ, currentData))) {
{ if (B.isAir(getPostBlock(x, floor - 1, z, currentPostX, currentPostZ, currentData))) {
if(B.isAir(getPostBlock(x, floor - 1, z, currentPostX, currentPostZ, currentData)))
{
return floor - 2; return floor - 2;
} }
return floor - 1; return floor - 1;
} } else {
if (!B.isAir(getPostBlock(x, floor + 1, z, currentPostX, currentPostZ, currentData))) {
else if (!B.isAir(getPostBlock(x, floor + 2, z, currentPostX, currentPostZ, currentData))) {
{
if(!B.isAir(getPostBlock(x, floor + 1, z, currentPostX, currentPostZ, currentData)))
{
if(!B.isAir(getPostBlock(x, floor + 2, z, currentPostX, currentPostZ, currentData)))
{
return floor + 2; return floor + 2;
} }
@@ -440,29 +358,20 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
} }
} }
private int nearestCaveCeiling(int ceiling, int x, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) private int nearestCaveCeiling(int ceiling, int x, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{ if (ceiling >= currentData.getHeight()) {
if(ceiling >= currentData.getHeight())
{
return currentData.getHeight() - 1; return currentData.getHeight() - 1;
} }
if(B.isAir(getPostBlock(x, ceiling, z, currentPostX, currentPostZ, currentData))) if (B.isAir(getPostBlock(x, ceiling, z, currentPostX, currentPostZ, currentData))) {
{ if (B.isAir(getPostBlock(x, ceiling + 1, z, currentPostX, currentPostZ, currentData))) {
if(B.isAir(getPostBlock(x, ceiling + 1, z, currentPostX, currentPostZ, currentData)))
{
return ceiling + 2; return ceiling + 2;
} }
return ceiling + 1; return ceiling + 1;
} } else {
if (!B.isAir(getPostBlock(x, ceiling - 1, z, currentPostX, currentPostZ, currentData))) {
else if (!B.isAir(getPostBlock(x, ceiling - 2, z, currentPostX, currentPostZ, currentData))) {
{
if(!B.isAir(getPostBlock(x, ceiling - 1, z, currentPostX, currentPostZ, currentData)))
{
if(!B.isAir(getPostBlock(x, ceiling - 2, z, currentPostX, currentPostZ, currentData)))
{
return ceiling - 2; return ceiling - 2;
} }
@@ -473,77 +382,64 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
} }
} }
public boolean isAir(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) public boolean isAir(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR); return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR);
} }
public boolean hasGravity(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) public boolean hasGravity(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.SAND) || d.getMaterial().equals(Material.RED_SAND) || d.getMaterial().equals(Material.BLACK_CONCRETE_POWDER) || d.getMaterial().equals(Material.BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.BROWN_CONCRETE_POWDER) || d.getMaterial().equals(Material.CYAN_CONCRETE_POWDER) || d.getMaterial().equals(Material.GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.GREEN_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIME_CONCRETE_POWDER) || d.getMaterial().equals(Material.MAGENTA_CONCRETE_POWDER) || d.getMaterial().equals(Material.ORANGE_CONCRETE_POWDER) || d.getMaterial().equals(Material.PINK_CONCRETE_POWDER) || d.getMaterial().equals(Material.PURPLE_CONCRETE_POWDER) || d.getMaterial().equals(Material.RED_CONCRETE_POWDER) || d.getMaterial().equals(Material.WHITE_CONCRETE_POWDER) || d.getMaterial().equals(Material.YELLOW_CONCRETE_POWDER); return d.getMaterial().equals(Material.SAND) || d.getMaterial().equals(Material.RED_SAND) || d.getMaterial().equals(Material.BLACK_CONCRETE_POWDER) || d.getMaterial().equals(Material.BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.BROWN_CONCRETE_POWDER) || d.getMaterial().equals(Material.CYAN_CONCRETE_POWDER) || d.getMaterial().equals(Material.GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.GREEN_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIME_CONCRETE_POWDER) || d.getMaterial().equals(Material.MAGENTA_CONCRETE_POWDER) || d.getMaterial().equals(Material.ORANGE_CONCRETE_POWDER) || d.getMaterial().equals(Material.PINK_CONCRETE_POWDER) || d.getMaterial().equals(Material.PURPLE_CONCRETE_POWDER) || d.getMaterial().equals(Material.RED_CONCRETE_POWDER) || d.getMaterial().equals(Material.WHITE_CONCRETE_POWDER) || d.getMaterial().equals(Material.YELLOW_CONCRETE_POWDER);
} }
public boolean isSolid(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) public boolean isSolid(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().isSolid(); return d.getMaterial().isSolid();
} }
public boolean isSolidNonSlab(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) public boolean isSolidNonSlab(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().isSolid() && !(d instanceof Slab); return d.getMaterial().isSolid() && !(d instanceof Slab);
} }
public boolean isAirOrWater(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) public boolean isAirOrWater(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.WATER) || d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR); return d.getMaterial().equals(Material.WATER) || d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR);
} }
public boolean isSlab(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) public boolean isSlab(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d instanceof Slab; return d instanceof Slab;
} }
public boolean isSnowLayer(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) public boolean isSnowLayer(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.SNOW); return d.getMaterial().equals(Material.SNOW);
} }
public boolean isWater(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) public boolean isWater(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.WATER); return d.getMaterial().equals(Material.WATER);
} }
public boolean isWaterOrWaterlogged(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) public boolean isWaterOrWaterlogged(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.WATER) || (d instanceof Waterlogged && ((Waterlogged) d).isWaterlogged()); return d.getMaterial().equals(Material.WATER) || (d instanceof Waterlogged && ((Waterlogged) d).isWaterlogged());
} }
public boolean isLiquid(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) public boolean isLiquid(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d instanceof Levelled; return d instanceof Levelled;
} }
public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
{ if (y < currentData.getHeight()) {
if(y < currentData.getHeight())
{
currentData.set(x & 15, y, z & 15, d); currentData.set(x & 15, y, z & 15, d);
} }
} }
public BlockData getPostBlock(int x, int y, int z, int cpx, int cpz, Hunk<BlockData> h) public BlockData getPostBlock(int x, int y, int z, int cpx, int cpz, Hunk<BlockData> h) {
{
BlockData b = h.getClosest(x & 15, y, z & 15); BlockData b = h.getClosest(x & 15, y, z & 15);
return b == null ? AIR : b; return b == null ? AIR : b;
@@ -2,18 +2,18 @@ package com.volmit.iris.generator.modifier;
import com.volmit.iris.generator.noise.CNG; import com.volmit.iris.generator.noise.CNG;
import com.volmit.iris.object.NoiseStyle; import com.volmit.iris.object.NoiseStyle;
import com.volmit.iris.util.*;
import com.volmit.iris.scaffold.engine.Engine; import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.engine.EngineAssignedModifier; import com.volmit.iris.scaffold.engine.EngineAssignedModifier;
import com.volmit.iris.scaffold.hunk.Hunk; import com.volmit.iris.scaffold.hunk.Hunk;
import com.volmit.iris.util.*;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
public class IrisRavineModifier extends EngineAssignedModifier<BlockData> { public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
private static final BlockData CAVE_AIR = B.get("CAVE_AIR"); private static final BlockData CAVE_AIR = B.get("CAVE_AIR");
private static final BlockData LAVA = B.get("LAVA"); private static final BlockData LAVA = B.get("LAVA");
private CNG cng; private final CNG cng;
private RNG rng; private final RNG rng;
public IrisRavineModifier(Engine engine) { public IrisRavineModifier(Engine engine) {
super(engine, "Ravine"); super(engine, "Ravine");
@@ -23,8 +23,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
@Override @Override
public void onModify(int x, int z, Hunk<BlockData> output) { public void onModify(int x, int z, Hunk<BlockData> output) {
if(!getDimension().isRavines()) if (!getDimension().isRavines()) {
{
return; return;
} }
@@ -33,61 +32,51 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
getEngine().getMetrics().getRavine().put(p.getMilliseconds()); getEngine().getMetrics().getRavine().put(p.getMilliseconds());
} }
private void set(Hunk<BlockData> pos, int x, int y, int z, BlockData b) private void set(Hunk<BlockData> pos, int x, int y, int z, BlockData b) {
{
pos.set(x, y, z, b); pos.set(x, y, z, b);
} }
private BlockData get(Hunk<BlockData> pos, int x, int y, int z) private BlockData get(Hunk<BlockData> pos, int x, int y, int z) {
{
BlockData bb = pos.get(x, y, z); BlockData bb = pos.get(x, y, z);
if(bb == null) if (bb == null) {
{
bb = CAVE_AIR; bb = CAVE_AIR;
} }
return bb; return bb;
} }
private BlockData getSurfaceBlock(int n6, int i, RNG rmg) private BlockData getSurfaceBlock(int n6, int i, RNG rmg) {
{
return getComplex().getTrueBiomeStream().get(n6, i).getSurfaceBlock(n6, i, rmg, getData()); return getComplex().getTrueBiomeStream().get(n6, i).getSurfaceBlock(n6, i, rmg, getData());
} }
private float[] ravineCache = new float[1024]; private final float[] ravineCache = new float[1024];
private void doRavine(long seed, int tx, int tz, ChunkPosition pos, double sx, double sy, double sz, float f, float f2, float f3, int n3, int n4, double d4, RNG bbx, Hunk<BlockData> terrain) private void doRavine(long seed, int tx, int tz, ChunkPosition pos, double sx, double sy, double sz, float f, float f2, float f3, int n3, int n4, double d4, RNG bbx, Hunk<BlockData> terrain) {
{
int n5; int n5;
RNG random = new RNG(seed); RNG random = new RNG(seed);
double x = tx * 16 + 8; double x = tx * 16 + 8;
double z = tz * 16 + 8; double z = tz * 16 + 8;
float f4 = 0.0f; float f4 = 0.0f;
float f5 = 0.0f; float f5 = 0.0f;
if(n4 <= 0) if (n4 <= 0) {
{
n5 = 8 * 16 - 16; n5 = 8 * 16 - 16;
n4 = n5 - random.nextInt(n5 / 4); n4 = n5 - random.nextInt(n5 / 4);
} }
n5 = 0; n5 = 0;
if(n3 == -1) if (n3 == -1) {
{
n3 = n4 / 2; n3 = n4 / 2;
n5 = 1; n5 = 1;
} }
float f6 = 1.0f; float f6 = 1.0f;
// TODO: WARNING HEIGHT // TODO: WARNING HEIGHT
for(int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i) {
{ if (i == 0 || random.nextInt(getDimension().getRavineRibRarity()) == 0) {
if(i == 0 || random.nextInt(getDimension().getRavineRibRarity()) == 0)
{
f6 = 1.0f + random.nextFloat() * random.nextFloat() * 1.0f; f6 = 1.0f + random.nextFloat() * random.nextFloat() * 1.0f;
} }
this.ravineCache[i] = f6 * f6; this.ravineCache[i] = f6 * f6;
} }
while(n3 < n4) while (n3 < n4) {
{
double d7 = 1.5 + (double) (MathHelper.sin((float) n3 * 3.1415927f / (float) n4) * f * 1.0f); double d7 = 1.5 + (double) (MathHelper.sin((float) n3 * 3.1415927f / (float) n4) * f * 1.0f);
double d8 = d7 * d4; double d8 = d7 * d4;
d7 *= (double) random.nextFloat() * 0.25 + 0.75; d7 *= (double) random.nextFloat() * 0.25 + 0.75;
@@ -104,18 +93,15 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
f4 *= 0.5f; f4 *= 0.5f;
f5 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0f; f5 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0f;
f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0f; f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0f;
if(n5 != 0 || random.nextInt(4) != 0) if (n5 != 0 || random.nextInt(4) != 0) {
{
double d9 = sx - x; double d9 = sx - x;
double d10 = sz - z; double d10 = sz - z;
double d11 = n4 - n3; double d11 = n4 - n3;
double d12 = f + 2.0f + 16.0f; double d12 = f + 2.0f + 16.0f;
if(d9 * d9 + d10 * d10 - d11 * d11 > d12 * d12) if (d9 * d9 + d10 * d10 - d11 * d11 > d12 * d12) {
{
return; return;
} }
if(sx >= x - 16.0 - d7 * 2.0 && sz >= z - 16.0 - d7 * 2.0 && sx <= x + 16.0 + d7 * 2.0 && sz <= z + 16.0 + d7 * 2.0) if (sx >= x - 16.0 - d7 * 2.0 && sz >= z - 16.0 - d7 * 2.0 && sx <= x + 16.0 + d7 * 2.0 && sz <= z + 16.0 + d7 * 2.0) {
{
int n6; int n6;
int n7 = MathHelper.floor(sx - d7) - tx * 16 - 1; int n7 = MathHelper.floor(sx - d7) - tx * 16 - 1;
int n8 = MathHelper.floor(sx + d7) - tx * 16 + 1; int n8 = MathHelper.floor(sx + d7) - tx * 16 + 1;
@@ -123,52 +109,40 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
int n10 = MathHelper.floor(sy + d8) + 1; int n10 = MathHelper.floor(sy + d8) + 1;
int n11 = MathHelper.floor(sz - d7) - tz * 16 - 1; int n11 = MathHelper.floor(sz - d7) - tz * 16 - 1;
int n12 = MathHelper.floor(sz + d7) - tz * 16 + 1; int n12 = MathHelper.floor(sz + d7) - tz * 16 + 1;
if(n7 < 0) if (n7 < 0) {
{
n7 = 0; n7 = 0;
} }
if(n8 > 16) if (n8 > 16) {
{
n8 = 16; n8 = 16;
} }
if(n9 < 1) if (n9 < 1) {
{
n9 = 1; n9 = 1;
} }
if(n10 > 248) if (n10 > 248) {
{
n10 = 248; n10 = 248;
} }
if(n11 < 0) if (n11 < 0) {
{
n11 = 0; n11 = 0;
} }
if(n12 > 16) if (n12 > 16) {
{
n12 = 16; n12 = 16;
} }
boolean bl = false; boolean bl = false;
for(int i = n7; !bl && i < n8; ++i) for (int i = n7; !bl && i < n8; ++i) {
{ for (n6 = n11; !bl && n6 < n12; ++n6) {
for(n6 = n11; !bl && n6 < n12; ++n6) for (int j = n10 + 1; !bl && j >= n9 - 1; --j) {
{
for(int j = n10 + 1; !bl && j >= n9 - 1; --j)
{
// TODO: WARNING HEIGHT // TODO: WARNING HEIGHT
if(j < 0 || j >= 256) if (j < 0 || j >= 256) {
{
continue; continue;
} }
BlockData bb = get(terrain, i, j, n6); BlockData bb = get(terrain, i, j, n6);
if(B.isWater(bb)) if (B.isWater(bb)) {
{
bl = true; bl = true;
} }
if(j == n9 - 1 || i == n7 || i == n8 - 1 || n6 == n11 || n6 == n12 - 1) if (j == n9 - 1 || i == n7 || i == n8 - 1 || n6 == n11 || n6 == n12 - 1) {
{
continue; continue;
} }
j = n9; j = n9;
@@ -212,8 +186,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
} }
} }
} }
if (n5 != 0) if (n5 != 0) {
{
break; break;
} }
} }
@@ -223,17 +196,15 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
} }
} }
private BlockPosition cSet(BlockPosition bb, double var0, double var2, double var4) private BlockPosition cSet(BlockPosition bb, double var0, double var2, double var4) {
{ bb.setX(MathHelper.floor(var0));
bb.setX(MathHelper.floor((double) var0)); bb.setY(MathHelper.floor(var2));
bb.setY(MathHelper.floor((double) var2)); bb.setZ(MathHelper.floor(var4));
bb.setZ(MathHelper.floor((double) var4));
return bb; return bb;
} }
private boolean isDirt(BlockData d) private boolean isDirt(BlockData d) {
{
//@builder //@builder
Material m = d.getMaterial(); Material m = d.getMaterial();
return m.equals(Material.DIRT) || return m.equals(Material.DIRT) ||
@@ -242,8 +213,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
//@done //@done
} }
private boolean isSurface(BlockData d) private boolean isSurface(BlockData d) {
{
//@builder //@builder
Material m = d.getMaterial(); Material m = d.getMaterial();
return m.equals(Material.GRASS_BLOCK) || return m.equals(Material.GRASS_BLOCK) ||
@@ -254,16 +224,13 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
//@done //@done
} }
public void genRavines(int n, int n2, ChunkPosition chunkSnapshot, RNG bbb, Hunk<BlockData> terrain) public void genRavines(int n, int n2, ChunkPosition chunkSnapshot, RNG bbb, Hunk<BlockData> terrain) {
{
RNG b = this.rng.nextParallelRNG(21949666); RNG b = this.rng.nextParallelRNG(21949666);
RNG bx = this.rng.nextParallelRNG(6676121); RNG bx = this.rng.nextParallelRNG(6676121);
long l = b.nextLong(); long l = b.nextLong();
long l2 = b.nextLong(); long l2 = b.nextLong();
for(int i = n - 8; i <= n + 8; ++i) for (int i = n - 8; i <= n + 8; ++i) {
{ for (int j = n2 - 8; j <= n2 + 8; ++j) {
for(int j = n2 - 8; j <= n2 + 8; ++j)
{
long l3 = (long) i * l; long l3 = (long) i * l;
long l4 = (long) j * l2; long l4 = (long) j * l2;
bx = this.rng.nextParallelRNG((int) (l3 ^ l4 ^ 6676121)); bx = this.rng.nextParallelRNG((int) (l3 ^ l4 ^ 6676121));
@@ -272,10 +239,8 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
} }
} }
private void doRavines(int tx, int tz, int sx, int sz, ChunkPosition chunkSnapshot, RNG b, Hunk<BlockData> terrain) private void doRavines(int tx, int tz, int sx, int sz, ChunkPosition chunkSnapshot, RNG b, Hunk<BlockData> terrain) {
{ if (b.nextInt(getDimension().getRavineRarity()) != 0) {
if(b.nextInt(getDimension().getRavineRarity()) != 0)
{
return; return;
} }
@@ -283,8 +248,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
double d2 = b.nextInt(b.nextInt(40) + 8) + 20; double d2 = b.nextInt(b.nextInt(40) + 8) + 20;
double z = tz * 16 + b.nextInt(16); double z = tz * 16 + b.nextInt(16);
int n5 = 1; int n5 = 1;
for(int i = 0; i < n5; ++i) for (int i = 0; i < n5; ++i) {
{
float f = b.nextFloat() * 3.1415927f * 2.0f; float f = b.nextFloat() * 3.1415927f * 2.0f;
float f2 = (b.nextFloat() - 0.5f) * 2.0f / 8.0f; float f2 = (b.nextFloat() - 0.5f) * 2.0f / 8.0f;
float f3 = (b.nextFloat() * 2.0f + b.nextFloat()) * 2.0f; float f3 = (b.nextFloat() * 2.0f + b.nextFloat()) * 2.0f;
@@ -292,8 +256,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
} }
} }
public void generateRavines(RNG nextParallelRNG, int x, int z, Hunk<BlockData> terrain) public void generateRavines(RNG nextParallelRNG, int x, int z, Hunk<BlockData> terrain) {
{
genRavines(x, z, new ChunkPosition(x, z), nextParallelRNG.nextParallelRNG(x).nextParallelRNG(z), terrain); genRavines(x, z, new ChunkPosition(x, z), nextParallelRNG.nextParallelRNG(x).nextParallelRNG(z), terrain);
} }
} }
@@ -9,8 +9,7 @@ import lombok.Data;
import java.util.List; import java.util.List;
@Data @Data
public class CNG public class CNG {
{
public static long hits = 0; public static long hits = 0;
public static long creates = 0; public static long creates = 0;
public static final NoiseInjector ADD = (s, v) -> new double[]{s + v, 1}; public static final NoiseInjector ADD = (s, v) -> new double[]{s + v, 1};
@@ -40,67 +39,55 @@ public class CNG
private double down; private double down;
private double power; private double power;
public NoiseGenerator getGen() public NoiseGenerator getGen() {
{
return generator; return generator;
} }
public ProceduralStream<Double> stream() public ProceduralStream<Double> stream() {
{
return new CNGStream(this); return new CNGStream(this);
} }
public ProceduralStream<Double> stream(double min, double max) public ProceduralStream<Double> stream(double min, double max) {
{
return new FittedStream<Double>(stream(), min, max); return new FittedStream<Double>(stream(), min, max);
} }
public static CNG signature(RNG rng) public static CNG signature(RNG rng) {
{
return signature(rng, NoiseType.SIMPLEX); return signature(rng, NoiseType.SIMPLEX);
} }
public static CNG signatureHalf(RNG rng) public static CNG signatureHalf(RNG rng) {
{
return signatureHalf(rng, NoiseType.SIMPLEX); return signatureHalf(rng, NoiseType.SIMPLEX);
} }
public static CNG signatureThick(RNG rng) public static CNG signatureThick(RNG rng) {
{
return signatureThick(rng, NoiseType.SIMPLEX); return signatureThick(rng, NoiseType.SIMPLEX);
} }
public static CNG signatureDouble(RNG rng) public static CNG signatureDouble(RNG rng) {
{
return signatureDouble(rng, NoiseType.SIMPLEX); return signatureDouble(rng, NoiseType.SIMPLEX);
} }
public static CNG signatureDouble(RNG rng, NoiseType t) public static CNG signatureDouble(RNG rng, NoiseType t) {
{
return signatureThick(rng, t).fractureWith(signature(rng.nextParallelRNG(4956)), 93); return signatureThick(rng, t).fractureWith(signature(rng.nextParallelRNG(4956)), 93);
} }
public static CNG signatureDoubleFast(RNG rng, NoiseType t, NoiseType f) public static CNG signatureDoubleFast(RNG rng, NoiseType t, NoiseType f) {
{
return signatureThickFast(rng, t, f) return signatureThickFast(rng, t, f)
.fractureWith(signatureFast(rng.nextParallelRNG(4956), t, f), 93); .fractureWith(signatureFast(rng.nextParallelRNG(4956), t, f), 93);
} }
public static CNG signature(RNG rng, NoiseType t) public static CNG signature(RNG rng, NoiseType t) {
{
// @NoArgsConstructor // @NoArgsConstructor
return new CNG(rng.nextParallelRNG(17), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.9).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.21).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.9), 620), 145), 44).bake(); return new CNG(rng.nextParallelRNG(17), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.9).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.21).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.9), 620), 145), 44).bake();
// @done // @done
} }
public static CNG signaturePerlin(RNG rng) public static CNG signaturePerlin(RNG rng) {
{
return signaturePerlin(rng, NoiseType.PERLIN); return signaturePerlin(rng, NoiseType.PERLIN);
} }
public static CNG signaturePerlin(RNG rng, NoiseType t) public static CNG signaturePerlin(RNG rng, NoiseType t) {
{
// @NoArgsConstructor // @NoArgsConstructor
return new CNG(rng.nextParallelRNG(124996), t, 1D, 1) return new CNG(rng.nextParallelRNG(124996), t, 1D, 1)
.fractureWith(new CNG(rng.nextParallelRNG(18), NoiseType.PERLIN, 1, 1).scale(1.25), 250) .fractureWith(new CNG(rng.nextParallelRNG(18), NoiseType.PERLIN, 1, 1).scale(1.25), 250)
@@ -108,8 +95,7 @@ public class CNG
// @done // @done
} }
public static CNG signatureFast(RNG rng, NoiseType t, NoiseType f) public static CNG signatureFast(RNG rng, NoiseType t, NoiseType f) {
{
// @NoArgsConstructor // @NoArgsConstructor
return new CNG(rng.nextParallelRNG(17), t, 1D, 1) return new CNG(rng.nextParallelRNG(17), t, 1D, 1)
.fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1) .fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1)
@@ -121,15 +107,13 @@ public class CNG
// @done // @done
} }
public static CNG signatureThick(RNG rng, NoiseType t) public static CNG signatureThick(RNG rng, NoiseType t) {
{
// @NoArgsConstructor // @NoArgsConstructor
return new CNG(rng.nextParallelRNG(133), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.5).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.11).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.4), 620), 145), 44).bake(); return new CNG(rng.nextParallelRNG(133), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.5).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.11).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.4), 620), 145), 44).bake();
// @done // @done
} }
public static CNG signatureThickFast(RNG rng, NoiseType t, NoiseType f) public static CNG signatureThickFast(RNG rng, NoiseType t, NoiseType f) {
{
// @NoArgsConstructor // @NoArgsConstructor
return new CNG(rng.nextParallelRNG(133), t, 1D, 1) return new CNG(rng.nextParallelRNG(133), t, 1D, 1)
.fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1) .fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1)
@@ -139,15 +123,13 @@ public class CNG
// @done // @done
} }
public static CNG signatureHalf(RNG rng, NoiseType t) public static CNG signatureHalf(RNG rng, NoiseType t) {
{
// @NoArgsConstructor // @NoArgsConstructor
return new CNG(rng.nextParallelRNG(127), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.9).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.21).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.9), 420), 99), 22).bake(); return new CNG(rng.nextParallelRNG(127), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.9).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.21).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.9), 420), 99), 22).bake();
// @done // @done
} }
public static CNG signatureHalfFast(RNG rng, NoiseType t, NoiseType f) public static CNG signatureHalfFast(RNG rng, NoiseType t, NoiseType f) {
{
// @NoArgsConstructor // @NoArgsConstructor
return new CNG(rng.nextParallelRNG(127), t, 1D, 1) return new CNG(rng.nextParallelRNG(127), t, 1D, 1)
.fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1).scale(0.9) .fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1).scale(0.9)
@@ -156,23 +138,19 @@ public class CNG
// @done // @done
} }
public CNG(RNG random) public CNG(RNG random) {
{
this(random, 1); this(random, 1);
} }
public CNG(RNG random, int octaves) public CNG(RNG random, int octaves) {
{
this(random, 1D, octaves); this(random, 1D, octaves);
} }
public CNG(RNG random, double opacity, int octaves) public CNG(RNG random, double opacity, int octaves) {
{
this(random, NoiseType.SIMPLEX, opacity, octaves); this(random, NoiseType.SIMPLEX, opacity, octaves);
} }
public CNG(RNG random, NoiseType t, double opacity, int octaves) public CNG(RNG random, NoiseType t, double opacity, int octaves) {
{
creates++; creates++;
noscale = t.equals(NoiseType.WHITE); noscale = t.equals(NoiseType.WHITE);
this.oct = octaves; this.oct = octaves;
@@ -189,23 +167,19 @@ public class CNG
this.opacity = opacity; this.opacity = opacity;
this.injector = ADD; this.injector = ADD;
if(generator instanceof OctaveNoise) if (generator instanceof OctaveNoise) {
{
((OctaveNoise) generator).setOctaves(octaves); ((OctaveNoise) generator).setOctaves(octaves);
} }
} }
public CNG bake() public CNG bake() {
{
bakedScale *= scale; bakedScale *= scale;
scale = 1; scale = 1;
return this; return this;
} }
public CNG child(CNG c) public CNG child(CNG c) {
{ if (children == null) {
if(children == null)
{
children = new KList<>(); children = new KList<>();
} }
@@ -213,146 +187,114 @@ public class CNG
return this; return this;
} }
public RNG getRNG() public RNG getRNG() {
{
return rng; return rng;
} }
public CNG fractureWith(CNG c, double scale) public CNG fractureWith(CNG c, double scale) {
{
fracture = c; fracture = c;
fscale = scale; fscale = scale;
return this; return this;
} }
public CNG scale(double c) public CNG scale(double c) {
{
scale = c; scale = c;
return this; return this;
} }
public CNG patch(double c) public CNG patch(double c) {
{
patch = c; patch = c;
return this; return this;
} }
public CNG up(double c) public CNG up(double c) {
{
up = c; up = c;
return this; return this;
} }
public CNG down(double c) public CNG down(double c) {
{
down = c; down = c;
return this; return this;
} }
public CNG injectWith(NoiseInjector i) public CNG injectWith(NoiseInjector i) {
{
injector = i; injector = i;
return this; return this;
} }
public <T extends IRare> T fitRarity(KList<T> b, double... dim) public <T extends IRare> T fitRarity(KList<T> b, double... dim) {
{ if (b.size() == 0) {
if(b.size() == 0)
{
return null; return null;
} }
if(b.size() == 1) if (b.size() == 1) {
{
return b.get(0); return b.get(0);
} }
KList<T> rarityMapped = new KList<>(); KList<T> rarityMapped = new KList<>();
boolean o = false; boolean o = false;
int max = 1; int max = 1;
for(T i : b) for (T i : b) {
{ if (i.getRarity() > max) {
if(i.getRarity() > max)
{
max = i.getRarity(); max = i.getRarity();
} }
} }
max++; max++;
for(T i : b) for (T i : b) {
{ for (int j = 0; j < max - i.getRarity(); j++) {
for(int j = 0; j < max - i.getRarity(); j++) if (o = !o) {
{
if(o = !o)
{
rarityMapped.add(i); rarityMapped.add(i);
} } else {
else
{
rarityMapped.add(0, i); rarityMapped.add(0, i);
} }
} }
} }
if(rarityMapped.size() == 1) if (rarityMapped.size() == 1) {
{
return rarityMapped.get(0); return rarityMapped.get(0);
} }
if(rarityMapped.isEmpty()) if (rarityMapped.isEmpty()) {
{
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly ")); throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
} }
return fit(rarityMapped, dim); return fit(rarityMapped, dim);
} }
public <T> T fit(T[] v, double... dim) public <T> T fit(T[] v, double... dim) {
{ if (v.length == 0) {
if(v.length == 0)
{
return null; return null;
} }
if(v.length == 1) if (v.length == 1) {
{
return v[0]; return v[0];
} }
return v[fit(0, v.length - 1, dim)]; return v[fit(0, v.length - 1, dim)];
} }
public <T> T fit(List<T> v, double... dim) public <T> T fit(List<T> v, double... dim) {
{ if (v.size() == 0) {
if(v.size() == 0)
{
return null; return null;
} }
if(v.size() == 1) if (v.size() == 1) {
{
return v.get(0); return v.get(0);
} }
try try {
{
return v.get(fit(0, v.size() - 1, dim)); return v.get(fit(0, v.size() - 1, dim));
} } catch (Throwable e) {
catch(Throwable e)
{
} }
return v.get(0); return v.get(0);
} }
public int fit(int min, int max, double... dim) public int fit(int min, int max, double... dim) {
{ if (min == max) {
if(min == max)
{
return min; return min;
} }
@@ -361,10 +303,8 @@ public class CNG
return (int) Math.round(IrisInterpolation.lerp(min, max, noise)); return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
} }
public int fit(double min, double max, double... dim) public int fit(double min, double max, double... dim) {
{ if (min == max) {
if(min == max)
{
return (int) Math.round(min); return (int) Math.round(min);
} }
@@ -373,10 +313,8 @@ public class CNG
return (int) Math.round(IrisInterpolation.lerp(min, max, noise)); return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
} }
public double fitDouble(double min, double max, double... dim) public double fitDouble(double min, double max, double... dim) {
{ if (min == max) {
if(min == max)
{
return min; return min;
} }
@@ -385,12 +323,9 @@ public class CNG
return IrisInterpolation.lerp(min, max, noise); return IrisInterpolation.lerp(min, max, noise);
} }
private double getNoise(double... dim) private double getNoise(double... dim) {
{ if (isTrueFracturing()) {
if(isTrueFracturing()) if (dim.length == 2) {
{
if(dim.length == 2)
{
double scale = noscale ? 1 : this.bakedScale * this.scale; double scale = noscale ? 1 : this.bakedScale * this.scale;
double f1 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[0], dim[1]) - 0.5) * fscale : 0D); double f1 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[0], dim[1]) - 0.5) * fscale : 0D);
double f2 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[1], dim[0]) - 0.5) * fscale : 0D); double f2 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[1], dim[0]) - 0.5) * fscale : 0D);
@@ -398,10 +333,7 @@ public class CNG
double y = dim[1] + -f1; double y = dim[1] + -f1;
double z = 0D; double z = 0D;
return generator.noise(x * scale, y * scale, z * scale) * opacity; return generator.noise(x * scale, y * scale, z * scale) * opacity;
} } else if (dim.length == 3) {
else if(dim.length == 3)
{
double scale = noscale ? 1 : this.bakedScale * this.scale; double scale = noscale ? 1 : this.bakedScale * this.scale;
double f1 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[0], dim[2], dim[1]) - 0.5) * fscale : 0D); double f1 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[0], dim[2], dim[1]) - 0.5) * fscale : 0D);
double f2 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[1], dim[0], dim[2]) - 0.5) * fscale : 0D); double f2 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[1], dim[0], dim[2]) - 0.5) * fscale : 0D);
@@ -421,19 +353,16 @@ public class CNG
return generator.noise(x * scale, y * scale, z * scale) * opacity; return generator.noise(x * scale, y * scale, z * scale) * opacity;
} }
public double noise(double... dim) public double noise(double... dim) {
{
double n = getNoise(dim); double n = getNoise(dim);
n = power != 1D ? (n < 0 ? -Math.pow(Math.abs(n), power) : Math.pow(n, power)) : n; n = power != 1D ? (n < 0 ? -Math.pow(Math.abs(n), power) : Math.pow(n, power)) : n;
double m = 1; double m = 1;
hits += oct; hits += oct;
if(children == null) if (children == null) {
{
return (n - down + up) * patch; return (n - down + up) * patch;
} }
for(CNG i : children) for (CNG i : children) {
{
double[] r = injector.combine(n, i.noise(dim)); double[] r = injector.combine(n, i.noise(dim));
n = r[0]; n = r[0];
m += r[1]; m += r[1];
@@ -442,20 +371,17 @@ public class CNG
return ((n / m) - down + up) * patch; return ((n / m) - down + up) * patch;
} }
public CNG pow(double power) public CNG pow(double power) {
{
this.power = power; this.power = power;
return this; return this;
} }
public CNG oct(int octaves) public CNG oct(int octaves) {
{
oct = octaves; oct = octaves;
return this; return this;
} }
public double getScale() public double getScale() {
{
return scale; return scale;
} }
@@ -3,7 +3,6 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
@FunctionalInterface @FunctionalInterface
public interface CNGFactory public interface CNGFactory {
{
CNG create(RNG seed); CNG create(RNG seed);
} }
@@ -1,15 +1,13 @@
package com.volmit.iris.generator.noise; package com.volmit.iris.generator.noise;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
public class CellGenerator public class CellGenerator {
{ private final FastNoiseDouble fn;
private FastNoiseDouble fn; private final FastNoiseDouble fd;
private FastNoiseDouble fd; private final CNG cng;
private CNG cng;
@Getter @Getter
@Setter @Setter
@@ -19,8 +17,7 @@ public class CellGenerator
@Setter @Setter
private double shuffle; private double shuffle;
public CellGenerator(RNG rng) public CellGenerator(RNG rng) {
{
shuffle = 128; shuffle = 128;
cellScale = 0.73; cellScale = 0.73;
cng = CNG.signature(rng.nextParallelRNG(3204)); cng = CNG.signature(rng.nextParallelRNG(3204));
@@ -36,50 +33,40 @@ public class CellGenerator
fd.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural); fd.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
} }
public double getDistance(double x, double z) public double getDistance(double x, double z) {
{
return ((fd.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle)))) + 1f) / 2f; return ((fd.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle)))) + 1f) / 2f;
} }
public double getDistance(double x, double y, double z) public double getDistance(double x, double y, double z) {
{
return ((fd.GetCellular(((x * cellScale) + (cng.noise(x, y, z) * shuffle)), ((y * cellScale) + (cng.noise(x, y, z) * shuffle)), ((z * cellScale) + (cng.noise(z, y, x) * shuffle)))) + 1f) / 2f; return ((fd.GetCellular(((x * cellScale) + (cng.noise(x, y, z) * shuffle)), ((y * cellScale) + (cng.noise(x, y, z) * shuffle)), ((z * cellScale) + (cng.noise(z, y, x) * shuffle)))) + 1f) / 2f;
} }
public double getValue(double x, double z, int possibilities) public double getValue(double x, double z, int possibilities) {
{ if (possibilities == 1) {
if(possibilities == 1)
{
return 0; return 0;
} }
return ((fn.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle))) + 1f) / 2f) * (possibilities - 1); return ((fn.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle))) + 1f) / 2f) * (possibilities - 1);
} }
public double getValue(double x, double y, double z, int possibilities) public double getValue(double x, double y, double z, int possibilities) {
{ if (possibilities == 1) {
if(possibilities == 1)
{
return 0; return 0;
} }
return ((fn.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((y * 8 * cellScale) + (cng.noise(x, y * 8) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle))) + 1f) / 2f) * (possibilities - 1); return ((fn.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((y * 8 * cellScale) + (cng.noise(x, y * 8) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle))) + 1f) / 2f) * (possibilities - 1);
} }
public int getIndex(double x, double z, int possibilities) public int getIndex(double x, double z, int possibilities) {
{ if (possibilities == 1) {
if(possibilities == 1)
{
return 0; return 0;
} }
return (int) Math.round(getValue(x, z, possibilities)); return (int) Math.round(getValue(x, z, possibilities));
} }
public int getIndex(double x, double y, double z, int possibilities) public int getIndex(double x, double y, double z, int possibilities) {
{ if (possibilities == 1) {
if(possibilities == 1)
{
return 0; return 0;
} }
@@ -3,38 +3,32 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.util.M; import com.volmit.iris.util.M;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class CellHeightNoise implements NoiseGenerator public class CellHeightNoise implements NoiseGenerator {
{
private final FastNoiseDouble n; private final FastNoiseDouble n;
public CellHeightNoise(long seed) public CellHeightNoise(long seed) {
{
this.n = new FastNoiseDouble(new RNG(seed).lmax()); this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular); n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub); n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural); n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
} }
private double filter(double noise) private double filter(double noise) {
{
return M.clip(1D - ((noise / 2D) + 0.5D), 0D, 1D); return M.clip(1D - ((noise / 2D) + 0.5D), 0D, 1D);
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return filter(n.GetCellular(x, 0)); return filter(n.GetCellular(x, 0));
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return filter(n.GetCellular(x, z)); return filter(n.GetCellular(x, z));
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return filter(n.GetCellular(x, y, z)); return filter(n.GetCellular(x, y, z));
} }
} }
@@ -2,12 +2,10 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class CellularNoise implements NoiseGenerator public class CellularNoise implements NoiseGenerator {
{
private final FastNoise n; private final FastNoise n;
public CellularNoise(long seed) public CellularNoise(long seed) {
{
this.n = new FastNoise(new RNG(seed).imax()); this.n = new FastNoise(new RNG(seed).imax());
n.SetNoiseType(FastNoise.NoiseType.Cellular); n.SetNoiseType(FastNoise.NoiseType.Cellular);
n.SetCellularReturnType(FastNoise.CellularReturnType.CellValue); n.SetCellularReturnType(FastNoise.CellularReturnType.CellValue);
@@ -15,20 +13,17 @@ public class CellularNoise implements NoiseGenerator
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return (n.GetCellular((float) x, 0) / 2D) + 0.5D; return (n.GetCellular((float) x, 0) / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return (n.GetCellular((float) x, (float) z) / 2D) + 0.5D; return (n.GetCellular((float) x, (float) z) / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return (n.GetCellular((float) x, (float) y, (float) z) / 2D) + 0.5D; return (n.GetCellular((float) x, (float) y, (float) z) / 2D) + 0.5D;
} }
} }
@@ -2,35 +2,29 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class CubicNoise implements NoiseGenerator public class CubicNoise implements NoiseGenerator {
{
private final FastNoiseDouble n; private final FastNoiseDouble n;
public CubicNoise(long seed) public CubicNoise(long seed) {
{
this.n = new FastNoiseDouble(new RNG(seed).lmax()); this.n = new FastNoiseDouble(new RNG(seed).lmax());
} }
private double f(double n) private double f(double n) {
{
return (n / 2D) + 0.5D; return (n / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return f(n.GetCubic(x, 0)); return f(n.GetCubic(x, 0));
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return f(n.GetCubic(x, z)); return f(n.GetCubic(x, z));
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return f(n.GetCubic(x, y, z)); return f(n.GetCubic(x, y, z));
} }
} }
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,27 +1,22 @@
package com.volmit.iris.generator.noise; package com.volmit.iris.generator.noise;
public class FlatNoise implements NoiseGenerator public class FlatNoise implements NoiseGenerator {
{ public FlatNoise(long seed) {
public FlatNoise(long seed)
{
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return 1D; return 1D;
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return 1D; return 1D;
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return 1D; return 1D;
} }
} }
@@ -3,43 +3,36 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType; import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class FractalBillowPerlinNoise implements NoiseGenerator, OctaveNoise public class FractalBillowPerlinNoise implements NoiseGenerator, OctaveNoise {
{
private final FastNoiseDouble n; private final FastNoiseDouble n;
public FractalBillowPerlinNoise(long seed) public FractalBillowPerlinNoise(long seed) {
{
this.n = new FastNoiseDouble(new RNG(seed).lmax()); this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setFractalOctaves(1); n.setFractalOctaves(1);
n.setFractalType(FractalType.Billow); n.setFractalType(FractalType.Billow);
} }
public double f(double v) public double f(double v) {
{
return (v / 2D) + 0.5D; return (v / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return f(n.GetPerlinFractal(x, 0f)); return f(n.GetPerlinFractal(x, 0f));
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return f(n.GetPerlinFractal(x, z)); return f(n.GetPerlinFractal(x, z));
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return f(n.GetPerlinFractal(x, y, z)); return f(n.GetPerlinFractal(x, y, z));
} }
@Override @Override
public void setOctaves(int o) public void setOctaves(int o) {
{
n.setFractalOctaves(o); n.setFractalOctaves(o);
} }
} }
@@ -3,43 +3,36 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType; import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class FractalBillowSimplexNoise implements NoiseGenerator, OctaveNoise public class FractalBillowSimplexNoise implements NoiseGenerator, OctaveNoise {
{
private final FastNoiseDouble n; private final FastNoiseDouble n;
public FractalBillowSimplexNoise(long seed) public FractalBillowSimplexNoise(long seed) {
{
this.n = new FastNoiseDouble(new RNG(seed).lmax()); this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setFractalOctaves(1); n.setFractalOctaves(1);
n.setFractalType(FractalType.Billow); n.setFractalType(FractalType.Billow);
} }
public double f(double v) public double f(double v) {
{
return (v / 2D) + 0.5D; return (v / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return f(n.GetSimplexFractal(x, 0d)); return f(n.GetSimplexFractal(x, 0d));
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return f(n.GetSimplexFractal(x, z)); return f(n.GetSimplexFractal(x, z));
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return f(n.GetSimplexFractal(x, y, z)); return f(n.GetSimplexFractal(x, y, z));
} }
@Override @Override
public void setOctaves(int o) public void setOctaves(int o) {
{
n.setFractalOctaves(o); n.setFractalOctaves(o);
} }
} }
@@ -3,36 +3,30 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType; import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class FractalCubicNoise implements NoiseGenerator public class FractalCubicNoise implements NoiseGenerator {
{
private final FastNoiseDouble n; private final FastNoiseDouble n;
public FractalCubicNoise(long seed) public FractalCubicNoise(long seed) {
{
this.n = new FastNoiseDouble(new RNG(seed).lmax()); this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setFractalType(FractalType.Billow); n.setFractalType(FractalType.Billow);
} }
private double f(double n) private double f(double n) {
{
return (n / 2D) + 0.5D; return (n / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return f(n.GetCubicFractal(x, 0)); return f(n.GetCubicFractal(x, 0));
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return f(n.GetCubicFractal(x, z)); return f(n.GetCubicFractal(x, z));
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return f(n.GetCubicFractal(x, y, z)); return f(n.GetCubicFractal(x, y, z));
} }
} }
@@ -3,43 +3,36 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType; import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class FractalFBMSimplexNoise implements NoiseGenerator, OctaveNoise public class FractalFBMSimplexNoise implements NoiseGenerator, OctaveNoise {
{
private final FastNoiseDouble n; private final FastNoiseDouble n;
public FractalFBMSimplexNoise(long seed) public FractalFBMSimplexNoise(long seed) {
{
this.n = new FastNoiseDouble(new RNG(seed).lmax()); this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setFractalOctaves(1); n.setFractalOctaves(1);
n.setFractalType(FractalType.FBM); n.setFractalType(FractalType.FBM);
} }
public double f(double v) public double f(double v) {
{
return (v / 2D) + 0.5D; return (v / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return f(n.GetSimplexFractal(x, 0d)); return f(n.GetSimplexFractal(x, 0d));
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return f(n.GetSimplexFractal(x, z)); return f(n.GetSimplexFractal(x, z));
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return f(n.GetSimplexFractal(x, y, z)); return f(n.GetSimplexFractal(x, y, z));
} }
@Override @Override
public void setOctaves(int o) public void setOctaves(int o) {
{
n.setFractalOctaves(o); n.setFractalOctaves(o);
} }
} }
@@ -3,43 +3,36 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType; import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class FractalRigidMultiSimplexNoise implements NoiseGenerator, OctaveNoise public class FractalRigidMultiSimplexNoise implements NoiseGenerator, OctaveNoise {
{
private final FastNoiseDouble n; private final FastNoiseDouble n;
public FractalRigidMultiSimplexNoise(long seed) public FractalRigidMultiSimplexNoise(long seed) {
{
this.n = new FastNoiseDouble(new RNG(seed).lmax()); this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setFractalOctaves(1); n.setFractalOctaves(1);
n.setFractalType(FractalType.RigidMulti); n.setFractalType(FractalType.RigidMulti);
} }
public double f(double v) public double f(double v) {
{
return (v / 2D) + 0.5D; return (v / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return f(n.GetSimplexFractal(x, 0d)); return f(n.GetSimplexFractal(x, 0d));
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return f(n.GetSimplexFractal(x, z)); return f(n.GetSimplexFractal(x, z));
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return f(n.GetSimplexFractal(x, y, z)); return f(n.GetSimplexFractal(x, y, z));
} }
@Override @Override
public void setOctaves(int o) public void setOctaves(int o) {
{
n.setFractalOctaves(o); n.setFractalOctaves(o);
} }
} }
@@ -2,38 +2,32 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class GlobNoise implements NoiseGenerator public class GlobNoise implements NoiseGenerator {
{
private final FastNoiseDouble n; private final FastNoiseDouble n;
public GlobNoise(long seed) public GlobNoise(long seed) {
{
this.n = new FastNoiseDouble(new RNG(seed).lmax()); this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular); n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Div); n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Div);
n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural); n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
} }
private double f(double n) private double f(double n) {
{
return n + 1D; return n + 1D;
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return f(n.GetCellular(x, 0)); return f(n.GetCellular(x, 0));
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return f(n.GetCellular(x, z)); return f(n.GetCellular(x, z));
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return f(n.GetCellular(x, y, z)); return f(n.GetCellular(x, y, z));
} }
} }
@@ -1,7 +1,6 @@
package com.volmit.iris.generator.noise; package com.volmit.iris.generator.noise;
@FunctionalInterface @FunctionalInterface
public interface NoiseFactory public interface NoiseFactory {
{
NoiseGenerator create(long seed); NoiseGenerator create(long seed);
} }
@@ -1,15 +1,13 @@
package com.volmit.iris.generator.noise; package com.volmit.iris.generator.noise;
public interface NoiseGenerator public interface NoiseGenerator {
{ double noise(double x);
public double noise(double x);
public double noise(double x, double z); double noise(double x, double z);
public double noise(double x, double y, double z); double noise(double x, double y, double z);
public default boolean isStatic() default boolean isStatic() {
{
return false; return false;
} }
} }
@@ -18,7 +18,7 @@ public enum NoiseType {
private final NoiseFactory f; private final NoiseFactory f;
private NoiseType(NoiseFactory f) { NoiseType(NoiseFactory f) {
this.f = f; this.f = f;
} }
@@ -1,6 +1,5 @@
package com.volmit.iris.generator.noise; package com.volmit.iris.generator.noise;
public interface OctaveNoise public interface OctaveNoise {
{ void setOctaves(int o);
public void setOctaves(int o);
} }
@@ -2,27 +2,22 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class PerlinNoise implements NoiseGenerator, OctaveNoise public class PerlinNoise implements NoiseGenerator, OctaveNoise {
{
private final FastNoiseDouble n; private final FastNoiseDouble n;
private int octaves; private int octaves;
public PerlinNoise(long seed) public PerlinNoise(long seed) {
{
this.n = new FastNoiseDouble(new RNG(seed).lmax()); this.n = new FastNoiseDouble(new RNG(seed).lmax());
octaves = 1; octaves = 1;
} }
public double f(double v) public double f(double v) {
{
return (v / 2D) + 0.5D; return (v / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{ if (octaves <= 1) {
if(octaves <= 1)
{
return f(n.GetPerlin(x, 0)); return f(n.GetPerlin(x, 0));
} }
@@ -30,8 +25,7 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise
double m = 0; double m = 0;
double v = 0; double v = 0;
for(int i = 0; i < octaves; i++) for (int i = 0; i < octaves; i++) {
{
v += n.GetPerlin((x * (f == 1 ? f++ : (f *= 2))), 0) * f; v += n.GetPerlin((x * (f == 1 ? f++ : (f *= 2))), 0) * f;
m += f; m += f;
} }
@@ -40,18 +34,15 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{ if (octaves <= 1) {
if(octaves <= 1)
{
return f(n.GetPerlin(x, z)); return f(n.GetPerlin(x, z));
} }
double f = 1; double f = 1;
double m = 0; double m = 0;
double v = 0; double v = 0;
for(int i = 0; i < octaves; i++) for (int i = 0; i < octaves; i++) {
{
f = f == 1 ? f + 1 : f * 2; f = f == 1 ? f + 1 : f * 2;
v += n.GetPerlin((x * f), (z * f)) * f; v += n.GetPerlin((x * f), (z * f)) * f;
m += f; m += f;
@@ -61,18 +52,15 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{ if (octaves <= 1) {
if(octaves <= 1)
{
return f(n.GetPerlin(x, y, z)); return f(n.GetPerlin(x, y, z));
} }
double f = 1; double f = 1;
double m = 0; double m = 0;
double v = 0; double v = 0;
for(int i = 0; i < octaves; i++) for (int i = 0; i < octaves; i++) {
{
f = f == 1 ? f + 1 : f * 2; f = f == 1 ? f + 1 : f * 2;
v += n.GetPerlin((x * f), (y * f), (z * f)) * f; v += n.GetPerlin((x * f), (y * f), (z * f)) * f;
m += f; m += f;
@@ -82,8 +70,7 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise
} }
@Override @Override
public void setOctaves(int o) public void setOctaves(int o) {
{
octaves = o; octaves = o;
} }
@@ -91,6 +78,7 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise
n.m_longerp = FastNoiseDouble.Longerp.Hermite; n.m_longerp = FastNoiseDouble.Longerp.Hermite;
return this; return this;
} }
public NoiseGenerator quad() { public NoiseGenerator quad() {
n.m_longerp = FastNoiseDouble.Longerp.Qulongic; n.m_longerp = FastNoiseDouble.Longerp.Qulongic;
return this; return this;
@@ -4,61 +4,46 @@ import com.volmit.iris.util.IRare;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class RarityCellGenerator<T extends IRare> extends CellGenerator public class RarityCellGenerator<T extends IRare> extends CellGenerator {
{ public RarityCellGenerator(RNG rng) {
public RarityCellGenerator(RNG rng)
{
super(rng); super(rng);
} }
public T get(double x, double z, KList<T> b) public T get(double x, double z, KList<T> b) {
{ if (b.size() == 0) {
if(b.size() == 0)
{
return null; return null;
} }
if(b.size() == 1) if (b.size() == 1) {
{
return b.get(0); return b.get(0);
} }
KList<T> rarityMapped = new KList<>(); KList<T> rarityMapped = new KList<>();
boolean o = false; boolean o = false;
int max = 1; int max = 1;
for(T i : b) for (T i : b) {
{ if (i.getRarity() > max) {
if(i.getRarity() > max)
{
max = i.getRarity(); max = i.getRarity();
} }
} }
max++; max++;
for(T i : b) for (T i : b) {
{ for (int j = 0; j < max - i.getRarity(); j++) {
for(int j = 0; j < max - i.getRarity(); j++) if (o = !o) {
{
if(o = !o)
{
rarityMapped.add(i); rarityMapped.add(i);
} } else {
else
{
rarityMapped.add(0, i); rarityMapped.add(0, i);
} }
} }
} }
if(rarityMapped.size() == 1) if (rarityMapped.size() == 1) {
{
return rarityMapped.get(0); return rarityMapped.get(0);
} }
if(rarityMapped.isEmpty()) if (rarityMapped.isEmpty()) {
{
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly ")); throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
} }
@@ -2,27 +2,22 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class SimplexNoise implements NoiseGenerator, OctaveNoise public class SimplexNoise implements NoiseGenerator, OctaveNoise {
{
private final FastNoiseDouble n; private final FastNoiseDouble n;
private int octaves; private int octaves;
public SimplexNoise(long seed) public SimplexNoise(long seed) {
{
this.n = new FastNoiseDouble(new RNG(seed).lmax()); this.n = new FastNoiseDouble(new RNG(seed).lmax());
octaves = 1; octaves = 1;
} }
public double f(double v) public double f(double v) {
{
return (v / 2D) + 0.5D; return (v / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{ if (octaves <= 1) {
if(octaves <= 1)
{
return f(n.GetSimplex(x, 0d)); return f(n.GetSimplex(x, 0d));
} }
@@ -30,8 +25,7 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise
double m = 0; double m = 0;
double v = 0; double v = 0;
for(int i = 0; i < octaves; i++) for (int i = 0; i < octaves; i++) {
{
v += n.GetSimplex((x * (f == 1 ? f++ : (f *= 2))), 0d) * f; v += n.GetSimplex((x * (f == 1 ? f++ : (f *= 2))), 0d) * f;
m += f; m += f;
} }
@@ -40,18 +34,15 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{ if (octaves <= 1) {
if(octaves <= 1)
{
return f(n.GetSimplex(x, z)); return f(n.GetSimplex(x, z));
} }
double f = 1; double f = 1;
double m = 0; double m = 0;
double v = 0; double v = 0;
for(int i = 0; i < octaves; i++) for (int i = 0; i < octaves; i++) {
{
f = f == 1 ? f + 1 : f * 2; f = f == 1 ? f + 1 : f * 2;
v += n.GetSimplex((x * f), (z * f)) * f; v += n.GetSimplex((x * f), (z * f)) * f;
m += f; m += f;
@@ -61,18 +52,15 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{ if (octaves <= 1) {
if(octaves <= 1)
{
return f(n.GetSimplex(x, y, z)); return f(n.GetSimplex(x, y, z));
} }
double f = 1; double f = 1;
double m = 0; double m = 0;
double v = 0; double v = 0;
for(int i = 0; i < octaves; i++) for (int i = 0; i < octaves; i++) {
{
f = f == 1 ? f + 1 : f * 2; f = f == 1 ? f + 1 : f * 2;
v += n.GetSimplex((x * f), (y * f), (z * f)) * f; v += n.GetSimplex((x * f), (y * f), (z * f)) * f;
m += f; m += f;
@@ -82,8 +70,7 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise
} }
@Override @Override
public void setOctaves(int o) public void setOctaves(int o) {
{
octaves = o; octaves = o;
} }
} }
@@ -3,38 +3,32 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.util.M; import com.volmit.iris.util.M;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class VascularNoise implements NoiseGenerator public class VascularNoise implements NoiseGenerator {
{
private final FastNoiseDouble n; private final FastNoiseDouble n;
public VascularNoise(long seed) public VascularNoise(long seed) {
{
this.n = new FastNoiseDouble(new RNG(seed).lmax()); this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular); n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub); n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural); n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
} }
private double filter(double noise) private double filter(double noise) {
{
return M.clip((noise / 2D) + 0.5D, 0D, 1D); return M.clip((noise / 2D) + 0.5D, 0D, 1D);
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return filter(n.GetCellular(x, 0)); return filter(n.GetCellular(x, 0));
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return filter(n.GetCellular(x, z)); return filter(n.GetCellular(x, z));
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return filter(n.GetCellular(x, y, z)); return filter(n.GetCellular(x, y, z));
} }
} }
@@ -2,40 +2,33 @@ package com.volmit.iris.generator.noise;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class WhiteNoise implements NoiseGenerator public class WhiteNoise implements NoiseGenerator {
{
private final FastNoise n; private final FastNoise n;
public WhiteNoise(long seed) public WhiteNoise(long seed) {
{
n = new FastNoise(new RNG(seed).imax()); n = new FastNoise(new RNG(seed).imax());
} }
public boolean isStatic() public boolean isStatic() {
{
return true; return true;
} }
private double f(double m) private double f(double m) {
{
return (m % 8192) * 1024; return (m % 8192) * 1024;
} }
@Override @Override
public double noise(double x) public double noise(double x) {
{
return (n.GetWhiteNoise(f(x), 0d) / 2D) + 0.5D; return (n.GetWhiteNoise(f(x), 0d) / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z) {
{
return (n.GetWhiteNoise(f(x), f(z)) / 2D) + 0.5D; return (n.GetWhiteNoise(f(x), f(z)) / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z) {
{
return (n.GetWhiteNoise(f(x), f(y), f(z)) / 2D) + 0.5D; return (n.GetWhiteNoise(f(x), f(y), f(z)) / 2D) + 0.5D;
} }
} }
@@ -4,12 +4,12 @@ import com.google.gson.Gson;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.object.*; import com.volmit.iris.object.*;
import com.volmit.iris.pregen.DirectWorldWriter; import com.volmit.iris.pregen.DirectWorldWriter;
import com.volmit.iris.util.*;
import com.volmit.iris.scaffold.data.nbt.io.NBTUtil; import com.volmit.iris.scaffold.data.nbt.io.NBTUtil;
import com.volmit.iris.scaffold.data.nbt.io.NamedTag; import com.volmit.iris.scaffold.data.nbt.io.NamedTag;
import com.volmit.iris.scaffold.data.nbt.tag.CompoundTag; import com.volmit.iris.scaffold.data.nbt.tag.CompoundTag;
import com.volmit.iris.scaffold.data.nbt.tag.IntTag; import com.volmit.iris.scaffold.data.nbt.tag.IntTag;
import com.volmit.iris.scaffold.data.nbt.tag.ListTag; import com.volmit.iris.scaffold.data.nbt.tag.ListTag;
import com.volmit.iris.util.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@@ -19,13 +19,11 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class ConversionManager public class ConversionManager {
{ private final KList<Converter> converters;
private KList<Converter> converters; private final File folder;
private File folder;
public ConversionManager() public ConversionManager() {
{
folder = Iris.instance.getDataFolder("convert"); folder = Iris.instance.getDataFolder("convert");
converters = new KList<>(); converters = new KList<>();
@@ -33,46 +31,37 @@ public class ConversionManager
{ {
J.attemptAsync(() -> J.attemptAsync(() ->
{ {
if(Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) {
{ converters.add(new Converter() {
converters.add(new Converter()
{
@Override @Override
public String getOutExtension() public String getOutExtension() {
{
return "iob"; return "iob";
} }
@Override @Override
public String getInExtension() public String getInExtension() {
{
return "schem"; return "schem";
} }
@Override @Override
public void convert(File in, File out) public void convert(File in, File out) {
{
SKConversion.convertSchematic(in, out); SKConversion.convertSchematic(in, out);
} }
}); });
converters.add(new Converter() converters.add(new Converter() {
{
@Override @Override
public String getOutExtension() public String getOutExtension() {
{
return "iob"; return "iob";
} }
@Override @Override
public String getInExtension() public String getInExtension() {
{
return "schematic"; return "schematic";
} }
@Override @Override
public void convert(File in, File out) public void convert(File in, File out) {
{
SKConversion.convertSchematic(in, out); SKConversion.convertSchematic(in, out);
} }
}); });
@@ -81,13 +70,11 @@ public class ConversionManager
}, 5); }, 5);
} }
private String toPoolName(String poolReference) private String toPoolName(String poolReference) {
{
return poolReference.split("\\Q:\\E")[1]; return poolReference.split("\\Q:\\E")[1];
} }
public void convertStructures(File in, File out, MortarSender s) public void convertStructures(File in, File out, MortarSender s) {
{
KMap<String, IrisJigsawPool> pools = new KMap<>(); KMap<String, IrisJigsawPool> pools = new KMap<>();
KList<File> roots = new KList<>(); KList<File> roots = new KList<>();
AtomicInteger total = new AtomicInteger(0); AtomicInteger total = new AtomicInteger(0);
@@ -96,16 +83,13 @@ public class ConversionManager
destPools.mkdirs(); destPools.mkdirs();
findAllNBT(in, (folder, file) -> { findAllNBT(in, (folder, file) -> {
total.getAndIncrement(); total.getAndIncrement();
if(roots.addIfMissing(folder)) if (roots.addIfMissing(folder)) {
{
String b = in.toURI().relativize(folder.toURI()).getPath(); String b = in.toURI().relativize(folder.toURI()).getPath();
if(b.startsWith("/")) if (b.startsWith("/")) {
{
b = b.substring(1); b = b.substring(1);
} }
if(b.endsWith("/")) if (b.endsWith("/")) {
{
b = b.substring(0, b.length() - 1); b = b.substring(0, b.length() - 1);
} }
@@ -115,13 +99,11 @@ public class ConversionManager
findAllNBT(in, (folder, file) -> { findAllNBT(in, (folder, file) -> {
at.getAndIncrement(); at.getAndIncrement();
String b = in.toURI().relativize(folder.toURI()).getPath(); String b = in.toURI().relativize(folder.toURI()).getPath();
if(b.startsWith("/")) if (b.startsWith("/")) {
{
b = b.substring(1); b = b.substring(1);
} }
if(b.endsWith("/")) if (b.endsWith("/")) {
{
b = b.substring(0, b.length() - 1); b = b.substring(0, b.length() - 1);
} }
IrisJigsawPool jpool = pools.get(b); IrisJigsawPool jpool = pools.get(b);
@@ -134,8 +116,7 @@ public class ConversionManager
NamedTag tag = NBTUtil.read(file); NamedTag tag = NBTUtil.read(file);
CompoundTag compound = (CompoundTag) tag.getTag(); CompoundTag compound = (CompoundTag) tag.getTag();
if (compound.containsKey("blocks") && compound.containsKey("palette") && compound.containsKey("size")) if (compound.containsKey("blocks") && compound.containsKey("palette") && compound.containsKey("size")) {
{
String id = in.toURI().relativize(folder.toURI()).getPath() + file.getName().split("\\Q.\\E")[0]; String id = in.toURI().relativize(folder.toURI()).getPath() + file.getName().split("\\Q.\\E")[0];
ListTag<IntTag> size = (ListTag<IntTag>) compound.getListTag("size"); ListTag<IntTag> size = (ListTag<IntTag>) compound.getListTag("size");
int w = size.get(0).asInt(); int w = size.get(0).asInt();
@@ -143,16 +124,14 @@ public class ConversionManager
int d = size.get(2).asInt(); int d = size.get(2).asInt();
KList<BlockData> palette = new KList<>(); KList<BlockData> palette = new KList<>();
ListTag<CompoundTag> paletteList = (ListTag<CompoundTag>) compound.getListTag("palette"); ListTag<CompoundTag> paletteList = (ListTag<CompoundTag>) compound.getListTag("palette");
for(int i = 0; i < paletteList.size(); i++) for (int i = 0; i < paletteList.size(); i++) {
{
CompoundTag cp = paletteList.get(i); CompoundTag cp = paletteList.get(i);
palette.add(DirectWorldWriter.getBlockData(cp)); palette.add(DirectWorldWriter.getBlockData(cp));
} }
IrisJigsawPiece piece = new IrisJigsawPiece(); IrisJigsawPiece piece = new IrisJigsawPiece();
IrisObject object = new IrisObject(w, h, d); IrisObject object = new IrisObject(w, h, d);
ListTag<CompoundTag> blockList = (ListTag<CompoundTag>) compound.getListTag("blocks"); ListTag<CompoundTag> blockList = (ListTag<CompoundTag>) compound.getListTag("blocks");
for(int i = 0; i < blockList.size(); i++) for (int i = 0; i < blockList.size(); i++) {
{
CompoundTag cp = blockList.get(i); CompoundTag cp = blockList.get(i);
ListTag<IntTag> pos = (ListTag<IntTag>) cp.getListTag("pos"); ListTag<IntTag> pos = (ListTag<IntTag>) cp.getListTag("pos");
int x = pos.get(0).asInt(); int x = pos.get(0).asInt();
@@ -160,8 +139,7 @@ public class ConversionManager
int z = pos.get(2).asInt(); int z = pos.get(2).asInt();
BlockData bd = palette.get(cp.getInt("state")).clone(); BlockData bd = palette.get(cp.getInt("state")).clone();
if(bd.getMaterial().equals(Material.JIGSAW) && cp.containsKey("nbt")) if (bd.getMaterial().equals(Material.JIGSAW) && cp.containsKey("nbt")) {
{
piece.setObject(in.toURI().relativize(folder.toURI()).getPath() + file.getName().split("\\Q.\\E")[0]); piece.setObject(in.toURI().relativize(folder.toURI()).getPath() + file.getName().split("\\Q.\\E")[0]);
IrisPosition spos = new IrisPosition(object.getSigned(x, y, z)); IrisPosition spos = new IrisPosition(object.getSigned(x, y, z));
CompoundTag nbt = cp.getCompoundTag("nbt"); CompoundTag nbt = cp.getCompoundTag("nbt");
@@ -183,16 +161,14 @@ public class ConversionManager
connector.getPools().add(poolId); connector.getPools().add(poolId);
connector.setDirection(IrisDirection.getDirection(((Jigsaw) jd).getOrientation())); connector.setDirection(IrisDirection.getDirection(((Jigsaw) jd).getOrientation()));
if(target.equals("minecraft:building_entrance")) if (target.equals("minecraft:building_entrance")) {
{
connector.setInnerConnector(true); connector.setInnerConnector(true);
} }
piece.getConnectors().add(connector); piece.getConnectors().add(connector);
} }
if(!bd.getMaterial().equals(Material.STRUCTURE_VOID) && !bd.getMaterial().equals(Material.AIR)) if (!bd.getMaterial().equals(Material.STRUCTURE_VOID) && !bd.getMaterial().equals(Material.AIR)) {
{
object.setUnsigned(x, y, z, bd); object.setUnsigned(x, y, z, bd);
} }
} }
@@ -207,8 +183,7 @@ public class ConversionManager
} }
}); });
for(String i : pools.k()) for (String i : pools.k()) {
{
try { try {
IO.writeAll(new File(destPools, i + ".json"), new JSONObject(new Gson().toJson(pools.get(i))).toString(4)); IO.writeAll(new File(destPools, i + ".json"), new JSONObject(new Gson().toJson(pools.get(i))).toString(4));
} catch (IOException e) { } catch (IOException e) {
@@ -219,44 +194,32 @@ public class ConversionManager
Iris.info("Done! Exported " + Form.f((total.get() * 2) + pools.size()) + " Files!"); Iris.info("Done! Exported " + Form.f((total.get() * 2) + pools.size()) + " Files!");
} }
public void findAllNBT(File path, Consumer2<File, File> inFile) public void findAllNBT(File path, Consumer2<File, File> inFile) {
{ if (path == null) {
if(path == null)
{
return; return;
} }
if(path.isFile() && path.getName().endsWith(".nbt")) if (path.isFile() && path.getName().endsWith(".nbt")) {
{
inFile.accept(path.getParentFile(), path); inFile.accept(path.getParentFile(), path);
return; return;
} }
for(File i : path.listFiles()) for (File i : path.listFiles()) {
{ if (i.isDirectory()) {
if(i.isDirectory())
{
findAllNBT(i, inFile); findAllNBT(i, inFile);
} } else if (i.isFile() && i.getName().endsWith(".nbt")) {
else if(i.isFile() && i.getName().endsWith(".nbt"))
{
inFile.accept(path, i); inFile.accept(path, i);
} }
} }
} }
public void check(MortarSender s) public void check(MortarSender s) {
{
int m = 0; int m = 0;
Iris.instance.getDataFolder("convert"); Iris.instance.getDataFolder("convert");
for(File i : folder.listFiles()) for (File i : folder.listFiles()) {
{ for (Converter j : converters) {
for(Converter j : converters) if (i.getName().endsWith("." + j.getInExtension())) {
{
if(i.getName().endsWith("." + j.getInExtension()))
{
File out = new File(folder, i.getName().replaceAll("\\Q." + j.getInExtension() + "\\E", "." + j.getOutExtension())); File out = new File(folder, i.getName().replaceAll("\\Q." + j.getInExtension() + "\\E", "." + j.getOutExtension()));
m++; m++;
j.convert(i, out); j.convert(i, out);
@@ -267,8 +230,7 @@ public class ConversionManager
if (i.isDirectory() && i.getName().equals("structures")) { if (i.isDirectory() && i.getName().equals("structures")) {
File f = new File(folder, "jigsaw"); File f = new File(folder, "jigsaw");
if (!f.exists()) if (!f.exists()) {
{
s.sendMessage("Converting NBT Structures into Iris Jigsaw Structures..."); s.sendMessage("Converting NBT Structures into Iris Jigsaw Structures...");
f.mkdirs(); f.mkdirs();
J.a(() -> convertStructures(i, f, s)); J.a(() -> convertStructures(i, f, s));
@@ -1,13 +1,5 @@
package com.volmit.iris.manager; package com.volmit.iris.manager;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldUnloadEvent;
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.edit.BlockEditor; import com.volmit.iris.manager.edit.BlockEditor;
@@ -15,102 +7,83 @@ import com.volmit.iris.manager.edit.BukkitBlockEditor;
import com.volmit.iris.manager.edit.WEBlockEditor; import com.volmit.iris.manager.edit.WEBlockEditor;
import com.volmit.iris.util.KMap; import com.volmit.iris.util.KMap;
import com.volmit.iris.util.M; import com.volmit.iris.util.M;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldUnloadEvent;
public class EditManager implements Listener public class EditManager implements Listener {
{ private final KMap<World, BlockEditor> editors;
private KMap<World, BlockEditor> editors;
public EditManager() public EditManager() {
{
this.editors = new KMap<>(); this.editors = new KMap<>();
Iris.instance.registerListener(this); Iris.instance.registerListener(this);
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::update, 0, 0); Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::update, 0, 0);
} }
public BlockData get(World world, int x, int y, int z) public BlockData get(World world, int x, int y, int z) {
{
return open(world).get(x, y, z); return open(world).get(x, y, z);
} }
public void set(World world, int x, int y, int z, BlockData d) public void set(World world, int x, int y, int z, BlockData d) {
{
open(world).set(x, y, z, d); open(world).set(x, y, z, d);
} }
public void setBiome(World world, int x, int y, int z, Biome d) public void setBiome(World world, int x, int y, int z, Biome d) {
{
open(world).setBiome(x, y, z, d); open(world).setBiome(x, y, z, d);
} }
public void setBiome(World world, int x, int z, Biome d) public void setBiome(World world, int x, int z, Biome d) {
{
open(world).setBiome(x, z, d); open(world).setBiome(x, z, d);
} }
public Biome getBiome(World world, int x, int y, int z) public Biome getBiome(World world, int x, int y, int z) {
{
return open(world).getBiome(x, y, z); return open(world).getBiome(x, y, z);
} }
public Biome getBiome(World world, int x, int z) public Biome getBiome(World world, int x, int z) {
{
return open(world).getBiome(x, z); return open(world).getBiome(x, z);
} }
@EventHandler @EventHandler
public void on(WorldUnloadEvent e) public void on(WorldUnloadEvent e) {
{ if (editors.containsKey(e.getWorld())) {
if(editors.containsKey(e.getWorld()))
{
editors.remove(e.getWorld()).close(); editors.remove(e.getWorld()).close();
} }
} }
public void update() public void update() {
{ for (World i : editors.k()) {
for(World i : editors.k()) if (M.ms() - editors.get(i).last() > 1000) {
{
if(M.ms() - editors.get(i).last() > 1000)
{
editors.remove(i).close(); editors.remove(i).close();
} }
} }
} }
public void flushNow() public void flushNow() {
{ for (World i : editors.k()) {
for(World i : editors.k())
{
editors.remove(i).close(); editors.remove(i).close();
} }
} }
public BlockEditor open(World world) public BlockEditor open(World world) {
{ if (editors.containsKey(world)) {
if(editors.containsKey(world))
{
return editors.get(world); return editors.get(world);
} }
BlockEditor e = null; BlockEditor e = null;
if(Bukkit.getPluginManager().isPluginEnabled("WorldEdit") && !PaperLib.isPaper() && !IrisSettings.get().getGeneral().isIgnoreWorldEdit()) if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit") && !PaperLib.isPaper() && !IrisSettings.get().getGeneral().isIgnoreWorldEdit()) {
{ try {
try
{
e = new WEBlockEditor(world); e = new WEBlockEditor(world);
} } catch (Throwable ex) {
catch(Throwable ex)
{
e = new BukkitBlockEditor(world); e = new BukkitBlockEditor(world);
} }
} } else {
else
{
e = new BukkitBlockEditor(world); e = new BukkitBlockEditor(world);
} }
@@ -13,18 +13,16 @@ import org.bukkit.event.player.PlayerChangedWorldEvent;
import java.util.List; import java.util.List;
public class IrisBoardManager implements BoardProvider, Listener public class IrisBoardManager implements BoardProvider, Listener {
{
@DontObfuscate @DontObfuscate
private BoardManager manager; private final BoardManager manager;
private String mem = "..."; private String mem = "...";
public RollingSequence hits = new RollingSequence(20); public RollingSequence hits = new RollingSequence(20);
public RollingSequence tp = new RollingSequence(100); public RollingSequence tp = new RollingSequence(100);
private ChronoLatch cl = new ChronoLatch(1000); private final ChronoLatch cl = new ChronoLatch(1000);
@DontObfuscate @DontObfuscate
public IrisBoardManager() public IrisBoardManager() {
{
Iris.instance.registerListener(this); Iris.instance.registerListener(this);
//@builder //@builder
manager = new BoardManager(Iris.instance, BoardSettings.builder() manager = new BoardManager(Iris.instance, BoardSettings.builder()
@@ -35,52 +33,41 @@ public class IrisBoardManager implements BoardProvider, Listener
} }
@EventHandler @EventHandler
public void on(PlayerChangedWorldEvent e) public void on(PlayerChangedWorldEvent e) {
{
J.s(() -> updatePlayer(e.getPlayer())); J.s(() -> updatePlayer(e.getPlayer()));
} }
@DontObfuscate @DontObfuscate
private boolean isIrisWorld(World w) private boolean isIrisWorld(World w) {
{
return IrisWorlds.isIrisWorld(w) && IrisWorlds.access(w).isStudio(); return IrisWorlds.isIrisWorld(w) && IrisWorlds.access(w).isStudio();
} }
public void updatePlayer(Player p) public void updatePlayer(Player p) {
{ if (isIrisWorld(p.getWorld())) {
if(isIrisWorld(p.getWorld()))
{
manager.remove(p); manager.remove(p);
manager.setup(p); manager.setup(p);
} } else {
else
{
manager.remove(p); manager.remove(p);
} }
} }
@Override @Override
public String getTitle(Player player) public String getTitle(Player player) {
{
return C.GREEN + "Iris"; return C.GREEN + "Iris";
} }
@DontObfuscate @DontObfuscate
@Override @Override
public List<String> getLines(Player player) public List<String> getLines(Player player) {
{
KList<String> v = new KList<>(); KList<String> v = new KList<>();
if(!isIrisWorld(player.getWorld())) if (!isIrisWorld(player.getWorld())) {
{
return v; return v;
} }
IrisAccess g = IrisWorlds.access(player.getWorld()); IrisAccess g = IrisWorlds.access(player.getWorld());
if(cl.flip()) if (cl.flip()) {
{
// TODO MEMORY // TODO MEMORY
mem = Form.memSize(0, 2); mem = Form.memSize(0, 2);
} }
@@ -96,8 +83,7 @@ public class IrisBoardManager implements BoardProvider, Listener
long memoryGuess = 0; long memoryGuess = 0;
int loadedObjects = 0; int loadedObjects = 0;
for(int i = 0; i < g.getCompound().getSize(); i++) for (int i = 0; i < g.getCompound().getSize(); i++) {
{
parallaxRegions += g.getCompound().getEngine(i).getParallax().getRegionCount(); parallaxRegions += g.getCompound().getEngine(i).getParallax().getRegionCount();
parallaxChunks += g.getCompound().getEngine(i).getParallax().getChunkCount(); parallaxChunks += g.getCompound().getEngine(i).getParallax().getChunkCount();
loadedObjects += g.getCompound().getData().getObjectLoader().getSize(); loadedObjects += g.getCompound().getData().getObjectLoader().getSize();
@@ -109,13 +95,11 @@ public class IrisBoardManager implements BoardProvider, Listener
tp.put(0); // TODO: CHUNK SPEED tp.put(0); // TODO: CHUNK SPEED
v.add("&7&m------------------"); v.add("&7&m------------------");
v.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(g.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / g.getGeneratedPerSecond(), 0)); v.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(g.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / g.getGeneratedPerSecond(), 0));
v.add(C.GREEN + "Memory Use" + C.GRAY + ": ~" + Form.memSize(memoryGuess, 0)); v.add(C.GREEN + "Memory Use" + C.GRAY + ": ~" + Form.memSize(memoryGuess, 0));
if(engine != null) if (engine != null) {
{
v.add("&7&m------------------"); v.add("&7&m------------------");
v.add(C.AQUA + "Engine" + C.GRAY + ": " + engine.getName() + " " + engine.getMinHeight() + "-" + engine.getMaxHeight()); v.add(C.AQUA + "Engine" + C.GRAY + ": " + engine.getName() + " " + engine.getMinHeight() + "-" + engine.getMaxHeight());
v.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName()); v.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
@@ -124,8 +108,7 @@ public class IrisBoardManager implements BoardProvider, Listener
v.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getFramework().getComplex().getSlopeStream().get(x, z), 2)); v.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getFramework().getComplex().getSlopeStream().get(x, z), 2));
} }
if(Iris.jobCount() > 0) if (Iris.jobCount() > 0) {
{
v.add("&7&m------------------"); v.add("&7&m------------------");
v.add(C.LIGHT_PURPLE + "Tasks" + C.GRAY + ": " + Iris.jobCount()); v.add(C.LIGHT_PURPLE + "Tasks" + C.GRAY + ": " + Iris.jobCount());
} }
@@ -136,8 +119,7 @@ public class IrisBoardManager implements BoardProvider, Listener
} }
@DontObfuscate @DontObfuscate
public void disable() public void disable() {
{
manager.onDisable(); manager.onDisable();
} }
} }
@@ -12,8 +12,7 @@ import java.util.Objects;
import java.util.function.Function; import java.util.function.Function;
@Data @Data
public class IrisDataManager public class IrisDataManager {
{
private ResourceLoader<IrisBiome> biomeLoader; private ResourceLoader<IrisBiome> biomeLoader;
private ResourceLoader<IrisLootTable> lootLoader; private ResourceLoader<IrisLootTable> lootLoader;
private ResourceLoader<IrisRegion> regionLoader; private ResourceLoader<IrisRegion> regionLoader;
@@ -29,21 +28,18 @@ public class IrisDataManager
private final File dataFolder; private final File dataFolder;
private final int id; private final int id;
public IrisDataManager(File dataFolder) public IrisDataManager(File dataFolder) {
{
this(dataFolder, false); this(dataFolder, false);
} }
public IrisDataManager(File dataFolder, boolean oneshot) public IrisDataManager(File dataFolder, boolean oneshot) {
{
this.dataFolder = dataFolder; this.dataFolder = dataFolder;
this.id = RNG.r.imax(); this.id = RNG.r.imax();
closed = false; closed = false;
hotloaded(); hotloaded();
} }
public void close() public void close() {
{
closed = true; closed = true;
dump(); dump();
this.lootLoader = null; this.lootLoader = null;
@@ -59,8 +55,7 @@ public class IrisDataManager
this.objectLoader = null; this.objectLoader = null;
} }
private static void printData(ResourceLoader<?> rl) private static void printData(ResourceLoader<?> rl) {
{
Iris.warn(" " + rl.getResourceTypeName() + " @ /" + rl.getFolderName() + ": Cache=" + rl.getLoadCache().size() + " Folders=" + rl.getFolders().size()); Iris.warn(" " + rl.getResourceTypeName() + " @ /" + rl.getFolderName() + ": Cache=" + rl.getLoadCache().size() + " Folders=" + rl.getFolders().size());
} }
@@ -68,10 +63,8 @@ public class IrisDataManager
return new IrisDataManager(dataFolder); return new IrisDataManager(dataFolder);
} }
public void hotloaded() public void hotloaded() {
{ if (closed) {
if(closed)
{
return; return;
} }
@@ -90,10 +83,8 @@ public class IrisDataManager
this.objectLoader = new ObjectResourceLoader(packs, this, "objects", "Object"); this.objectLoader = new ObjectResourceLoader(packs, this, "objects", "Object");
} }
public void dump() public void dump() {
{ if (closed) {
if(closed)
{
return; return;
} }
biomeLoader.clearCache(); biomeLoader.clearCache();
@@ -109,10 +100,8 @@ public class IrisDataManager
generatorLoader.clearCache(); generatorLoader.clearCache();
} }
public void clearLists() public void clearLists() {
{ if (closed) {
if(closed)
{
return; return;
} }
@@ -129,81 +118,63 @@ public class IrisDataManager
objectLoader.clearList(); objectLoader.clearList();
} }
public static IrisObject loadAnyObject(String key) public static IrisObject loadAnyObject(String key) {
{
return loadAny(key, (dm) -> dm.getObjectLoader().load(key, false)); return loadAny(key, (dm) -> dm.getObjectLoader().load(key, false));
} }
public static IrisBiome loadAnyBiome(String key) public static IrisBiome loadAnyBiome(String key) {
{
return loadAny(key, (dm) -> dm.getBiomeLoader().load(key, false)); return loadAny(key, (dm) -> dm.getBiomeLoader().load(key, false));
} }
public static IrisJigsawPiece loadAnyJigsawPiece(String key) public static IrisJigsawPiece loadAnyJigsawPiece(String key) {
{
return loadAny(key, (dm) -> dm.getJigsawPieceLoader().load(key, false)); return loadAny(key, (dm) -> dm.getJigsawPieceLoader().load(key, false));
} }
public static IrisJigsawPool loadAnyJigsawPool(String key) public static IrisJigsawPool loadAnyJigsawPool(String key) {
{
return loadAny(key, (dm) -> dm.getJigsawPoolLoader().load(key, false)); return loadAny(key, (dm) -> dm.getJigsawPoolLoader().load(key, false));
} }
public static IrisEntity loadAnyEntity(String key) public static IrisEntity loadAnyEntity(String key) {
{
return loadAny(key, (dm) -> dm.getEntityLoader().load(key, false)); return loadAny(key, (dm) -> dm.getEntityLoader().load(key, false));
} }
public static IrisLootTable loadAnyLootTable(String key) public static IrisLootTable loadAnyLootTable(String key) {
{
return loadAny(key, (dm) -> dm.getLootLoader().load(key, false)); return loadAny(key, (dm) -> dm.getLootLoader().load(key, false));
} }
public static IrisBlockData loadAnyBlock(String key) public static IrisBlockData loadAnyBlock(String key) {
{
return loadAny(key, (dm) -> dm.getBlockLoader().load(key, false)); return loadAny(key, (dm) -> dm.getBlockLoader().load(key, false));
} }
public static IrisRegion loadAnyRegion(String key) public static IrisRegion loadAnyRegion(String key) {
{
return loadAny(key, (dm) -> dm.getRegionLoader().load(key, false)); return loadAny(key, (dm) -> dm.getRegionLoader().load(key, false));
} }
public static IrisDimension loadAnyDimension(String key) public static IrisDimension loadAnyDimension(String key) {
{
return loadAny(key, (dm) -> dm.getDimensionLoader().load(key, false)); return loadAny(key, (dm) -> dm.getDimensionLoader().load(key, false));
} }
public static IrisJigsawStructure loadAnyJigsawStructure(String key) public static IrisJigsawStructure loadAnyJigsawStructure(String key) {
{
return loadAny(key, (dm) -> dm.getJigsawStructureLoader().load(key, false)); return loadAny(key, (dm) -> dm.getJigsawStructureLoader().load(key, false));
} }
public static IrisGenerator loadAnyGenerator(String key) public static IrisGenerator loadAnyGenerator(String key) {
{
return loadAny(key, (dm) -> dm.getGeneratorLoader().load(key, false)); return loadAny(key, (dm) -> dm.getGeneratorLoader().load(key, false));
} }
public static <T extends IrisRegistrant> T loadAny(String key, Function<IrisDataManager, T> v) { public static <T extends IrisRegistrant> T loadAny(String key, Function<IrisDataManager, T> v) {
try try {
{ for (File i : Objects.requireNonNull(Iris.instance.getDataFolder("packs").listFiles())) {
for(File i : Objects.requireNonNull(Iris.instance.getDataFolder("packs").listFiles())) if (i.isDirectory()) {
{
if(i.isDirectory())
{
IrisDataManager dm = new IrisDataManager(i, true); IrisDataManager dm = new IrisDataManager(i, true);
T t = v.apply(dm); T t = v.apply(dm);
if(t != null) if (t != null) {
{
return t; return t;
} }
} }
} }
} } catch (Throwable e) {
catch(Throwable e)
{
e.printStackTrace(); e.printStackTrace();
} }
@@ -24,25 +24,21 @@ import java.util.Objects;
import java.util.UUID; import java.util.UUID;
@Data @Data
public class IrisProject public class IrisProject {
{
private File path; private File path;
private String name; private String name;
private IrisAccess activeProvider; private IrisAccess activeProvider;
public IrisProject(File path) public IrisProject(File path) {
{
this.path = path; this.path = path;
this.name = path.getName(); this.name = path.getName();
} }
public KList<Report> scanForErrors() public KList<Report> scanForErrors() {
{
KList<Report> reports = new KList<>(); KList<Report> reports = new KList<>();
IrisDataManager data = new IrisDataManager(path); IrisDataManager data = new IrisDataManager(path);
for(int i = 0; i < getActiveProvider().getCompound().getSize(); i++) for (int i = 0; i < getActiveProvider().getCompound().getSize(); i++) {
{
Engine e = getActiveProvider().getCompound().getEngine(i); Engine e = getActiveProvider().getCompound().getEngine(i);
IrisDimension dim = e.getDimension(); IrisDimension dim = e.getDimension();
reports.add(scanForErrors(dim)); reports.add(scanForErrors(dim));
@@ -54,8 +50,7 @@ public class IrisProject
private KList<Report> scanForErrors(IrisDimension dim) { private KList<Report> scanForErrors(IrisDimension dim) {
KList<Report> reports = new KList<>(); KList<Report> reports = new KList<>();
if(dim.getFocus() != null && !dim.getFocus().isEmpty()) if (dim.getFocus() != null && !dim.getFocus().isEmpty()) {
{
reports.add(Report.builder() reports.add(Report.builder()
.type(ReportType.NOTICE) .type(ReportType.NOTICE)
.title("Focus Mode is Enabled") .title("Focus Mode is Enabled")
@@ -64,8 +59,7 @@ public class IrisProject
.build()); .build());
} }
for(IrisRegion i : dim.getAllRegions(getActiveProvider())) for (IrisRegion i : dim.getAllRegions(getActiveProvider())) {
{
scanForErrors(i); scanForErrors(i);
} }
@@ -75,8 +69,7 @@ public class IrisProject
private KList<Report> scanForErrors(IrisRegion region) { private KList<Report> scanForErrors(IrisRegion region) {
KList<Report> reports = new KList<>(); KList<Report> reports = new KList<>();
if(region.getRarity() > 60) if (region.getRarity() > 60) {
{
reports.add(Report.builder() reports.add(Report.builder()
.type(ReportType.WARNING) .type(ReportType.WARNING)
.title("Region " + region.getName() + " has a rarity of " + region.getRarity()) .title("Region " + region.getName() + " has a rarity of " + region.getRarity())
@@ -85,8 +78,7 @@ public class IrisProject
.build()); .build());
} }
for(IrisBiome i : region.getAllBiomes(getActiveProvider())) for (IrisBiome i : region.getAllBiomes(getActiveProvider())) {
{
reports.add(scanForErrors(i)); reports.add(scanForErrors(i));
} }
@@ -96,18 +88,15 @@ public class IrisProject
private KList<Report> scanForErrors(IrisBiome biome) { private KList<Report> scanForErrors(IrisBiome biome) {
KList<Report> reports = new KList<>(); KList<Report> reports = new KList<>();
for(IrisObjectPlacement i : biome.getObjects()) for (IrisObjectPlacement i : biome.getObjects()) {
{
reports.add(scanForErrors(biome, i)); reports.add(scanForErrors(biome, i));
} }
for(IrisBiomePaletteLayer i : biome.getLayers()) for (IrisBiomePaletteLayer i : biome.getLayers()) {
{
reports.add(scanForErrors(biome, i)); reports.add(scanForErrors(biome, i));
} }
for(IrisBiomePaletteLayer i : biome.getSeaLayers()) for (IrisBiomePaletteLayer i : biome.getSeaLayers()) {
{
reports.add(scanForErrorsSeaLayers(biome, i)); reports.add(scanForErrorsSeaLayers(biome, i));
} }
@@ -132,25 +121,18 @@ public class IrisProject
return reports; return reports;
} }
public boolean isOpen() public boolean isOpen() {
{
return activeProvider != null; return activeProvider != null;
} }
public KList<File> collectFiles(File f, String json) public KList<File> collectFiles(File f, String json) {
{
KList<File> l = new KList<>(); KList<File> l = new KList<>();
if(f.isDirectory()) if (f.isDirectory()) {
{ for (File i : f.listFiles()) {
for(File i : f.listFiles())
{
l.addAll(collectFiles(i, json)); l.addAll(collectFiles(i, json));
} }
} } else if (f.getName().endsWith("." + json)) {
else if(f.getName().endsWith("."+json))
{
l.add(f); l.add(f);
} }
@@ -161,23 +143,19 @@ public class IrisProject
return collectFiles(path, json); return collectFiles(path, json);
} }
public void open(MortarSender sender) public void open(MortarSender sender) {
{
open(sender, () -> open(sender, () ->
{ {
}); });
} }
public void open(MortarSender sender, Runnable onDone) public void open(MortarSender sender, Runnable onDone) {
{ if (isOpen()) {
if(isOpen())
{
close(); close();
} }
IrisDimension d = IrisDataManager.loadAnyDimension(getName()); IrisDimension d = IrisDataManager.loadAnyDimension(getName());
if(d == null) if (d == null) {
{
sender.sendMessage("Can't find dimension: " + getName()); sender.sendMessage("Can't find dimension: " + getName());
return; return;
} else if (sender.isPlayer()) { } else if (sender.isPlayer()) {
@@ -187,18 +165,15 @@ public class IrisProject
J.attemptAsync(() -> J.attemptAsync(() ->
{ {
try try {
{
if (d.getLoader() == null) { if (d.getLoader() == null) {
sender.sendMessage("Could not get dimension loader"); sender.sendMessage("Could not get dimension loader");
return; return;
} }
File f = d.getLoader().getDataFolder(); File f = d.getLoader().getDataFolder();
boolean foundWork = false; boolean foundWork = false;
for(File i : Objects.requireNonNull(f.listFiles())) for (File i : Objects.requireNonNull(f.listFiles())) {
{ if (i.getName().endsWith(".code-workspace")) {
if(i.getName().endsWith(".code-workspace"))
{
foundWork = true; foundWork = true;
sender.sendMessage("Updating Workspace..."); sender.sendMessage("Updating Workspace...");
J.a(() -> J.a(() ->
@@ -207,8 +182,7 @@ public class IrisProject
sender.sendMessage("Workspace Updated"); sender.sendMessage("Workspace Updated");
}); });
if(IrisSettings.get().getStudio().isOpenVSCode()) if (IrisSettings.get().getStudio().isOpenVSCode()) {
{
if (!GraphicsEnvironment.isHeadless()) { if (!GraphicsEnvironment.isHeadless()) {
Iris.msg("Opening VSCode. You may see the output from VSCode."); Iris.msg("Opening VSCode. You may see the output from VSCode.");
Iris.msg("VSCode output always starts with: '(node:#####) electron'"); Iris.msg("VSCode output always starts with: '(node:#####) electron'");
@@ -220,28 +194,20 @@ public class IrisProject
} }
} }
if(!foundWork) if (!foundWork) {
{
File ff = new File(d.getLoader().getDataFolder(), d.getLoadKey() + ".code-workspace"); File ff = new File(d.getLoader().getDataFolder(), d.getLoadKey() + ".code-workspace");
Iris.warn("Project missing code-workspace: " + ff.getAbsolutePath() + " Re-creating code workspace."); Iris.warn("Project missing code-workspace: " + ff.getAbsolutePath() + " Re-creating code workspace.");
try try {
{
IO.writeAll(ff, createCodeWorkspaceConfig()); IO.writeAll(ff, createCodeWorkspaceConfig());
} } catch (IOException e1) {
catch(IOException e1)
{
e1.printStackTrace(); e1.printStackTrace();
} }
sender.sendMessage("Updating Workspace..."); sender.sendMessage("Updating Workspace...");
updateWorkspace(); updateWorkspace();
sender.sendMessage("Workspace Updated"); sender.sendMessage("Workspace Updated");
} }
} } catch (Throwable e) {
catch(Throwable e)
{
e.printStackTrace(); e.printStackTrace();
} }
}); });
@@ -267,8 +233,7 @@ public class IrisProject
double lpc = 0; double lpc = 0;
boolean fc; boolean fc;
while(!done.get()) while (!done.get()) {
{
boolean derp = false; boolean derp = false;
assert gx != null; assert gx != null;
@@ -276,19 +241,14 @@ public class IrisProject
fc = lpc != v; fc = lpc != v;
lpc = v; lpc = v;
if(last > v || v > 1) if (last > v || v > 1) {
{
derp = true; derp = true;
v = last; v = last;
} } else {
else
{
last = v; last = v;
} }
if(fc) if (fc) {
{
sender.sendMessage(C.WHITE + "Generating " + Form.pc(v) + (derp ? (C.GRAY + " (Waiting on Server...)") : (C.GRAY + " (" + (req - gx.getGenerated()) + " Left)"))); sender.sendMessage(C.WHITE + "Generating " + Form.pc(v) + (derp ? (C.GRAY + " (Waiting on Server...)") : (C.GRAY + " (" + (req - gx.getGenerated()) + " Left)")));
} }
@@ -298,8 +258,7 @@ public class IrisProject
J.sleep(1500); J.sleep(1500);
if(gx.isFailing()) if (gx.isFailing()) {
{
sender.sendMessage("Generation Failed!"); sender.sendMessage("Generation Failed!");
return; return;
@@ -319,8 +278,7 @@ public class IrisProject
done.set(true); done.set(true);
sender.sendMessage(C.WHITE + "Generating Complete!"); sender.sendMessage(C.WHITE + "Generating Complete!");
if(sender.isPlayer()) if (sender.isPlayer()) {
{
assert world != null; assert world != null;
sender.player().teleport(world.getSpawnLocation()); sender.player().teleport(world.getSpawnLocation());
} }
@@ -329,8 +287,7 @@ public class IrisProject
{ {
sender.sendMessage("Hotloading Active! Change any files and watch your changes appear as you load new chunks!"); sender.sendMessage("Hotloading Active! Change any files and watch your changes appear as you load new chunks!");
if(sender.isPlayer()) if (sender.isPlayer()) {
{
sender.player().setGameMode(GameMode.SPECTATOR); sender.player().setGameMode(GameMode.SPECTATOR);
} }
@@ -338,8 +295,7 @@ public class IrisProject
}, 0); }, 0);
} }
public void close() public void close() {
{
activeProvider.close(); activeProvider.close();
File folder = activeProvider.getTarget().getWorld().getWorldFolder(); File folder = activeProvider.getTarget().getWorld().getWorldFolder();
Iris.linkMultiverseCore.removeFromConfig(activeProvider.getTarget().getWorld().getName()); Iris.linkMultiverseCore.removeFromConfig(activeProvider.getTarget().getWorld().getName());
@@ -348,18 +304,15 @@ public class IrisProject
activeProvider = null; activeProvider = null;
} }
public File getCodeWorkspaceFile() public File getCodeWorkspaceFile() {
{
return new File(path, getName() + ".code-workspace"); return new File(path, getName() + ".code-workspace");
} }
public boolean updateWorkspace() public boolean updateWorkspace() {
{
getPath().mkdirs(); getPath().mkdirs();
File ws = getCodeWorkspaceFile(); File ws = getCodeWorkspaceFile();
try try {
{
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
Iris.info("Building Workspace: " + ws.getPath()); Iris.info("Building Workspace: " + ws.getPath());
JSONObject j = createCodeWorkspaceConfig(); JSONObject j = createCodeWorkspaceConfig();
@@ -367,19 +320,12 @@ public class IrisProject
p.end(); p.end();
Iris.info("Building Workspace: " + ws.getPath() + " took " + Form.duration(p.getMilliseconds(), 2)); Iris.info("Building Workspace: " + ws.getPath() + " took " + Form.duration(p.getMilliseconds(), 2));
return true; return true;
} } catch (Throwable e) {
catch(Throwable e)
{
Iris.warn("Project invalid: " + ws.getAbsolutePath() + " Re-creating. You may loose some vs-code workspace settings! But not your actual project!"); Iris.warn("Project invalid: " + ws.getAbsolutePath() + " Re-creating. You may loose some vs-code workspace settings! But not your actual project!");
ws.delete(); ws.delete();
try try {
{
IO.writeAll(ws, createCodeWorkspaceConfig()); IO.writeAll(ws, createCodeWorkspaceConfig());
} } catch (IOException e1) {
catch(IOException e1)
{
e1.printStackTrace(); e1.printStackTrace();
} }
} }
@@ -387,8 +333,7 @@ public class IrisProject
return false; return false;
} }
public JSONObject createCodeWorkspaceConfig() public JSONObject createCodeWorkspaceConfig() {
{
JSONObject ws = new JSONObject(); JSONObject ws = new JSONObject();
JSONArray folders = new JSONArray(); JSONArray folders = new JSONArray();
JSONObject folder = new JSONObject(); JSONObject folder = new JSONObject();
@@ -436,8 +381,7 @@ public class IrisProject
return ws; return ws;
} }
public JSONObject getSchemaEntry(Class<?> i, IrisDataManager dat, String... fileMatch) public JSONObject getSchemaEntry(Class<?> i, IrisDataManager dat, String... fileMatch) {
{
Iris.verbose("Processing Folder " + i.getSimpleName() + " " + fileMatch[0]); Iris.verbose("Processing Folder " + i.getSimpleName() + " " + fileMatch[0]);
JSONObject o = new JSONObject(); JSONObject o = new JSONObject();
o.put("fileMatch", new JSONArray(fileMatch)); o.put("fileMatch", new JSONArray(fileMatch));
@@ -446,8 +390,7 @@ public class IrisProject
return o; return o;
} }
public File compilePackage(MortarSender sender, boolean obfuscate, boolean minify) public File compilePackage(MortarSender sender, boolean obfuscate, boolean minify) {
{
String dimm = getName(); String dimm = getName();
IrisDataManager dm = new IrisDataManager(path); IrisDataManager dm = new IrisDataManager(path);
IrisDimension dimension = dm.getDimensionLoader().load(dimm); IrisDimension dimension = dm.getDimensionLoader().load(dimm);
@@ -461,8 +404,7 @@ public class IrisProject
KSet<IrisLootTable> loot = new KSet<>(); KSet<IrisLootTable> loot = new KSet<>();
KSet<IrisBlockData> blocks = new KSet<>(); KSet<IrisBlockData> blocks = new KSet<>();
for(String i : dm.getDimensionLoader().getPossibleKeys()) for (String i : dm.getDimensionLoader().getPossibleKeys()) {
{
blocks.add(dm.getBlockLoader().load(i)); blocks.add(dm.getBlockLoader().load(i));
} }
@@ -485,17 +427,13 @@ public class IrisProject
StringBuilder c = new StringBuilder(); StringBuilder c = new StringBuilder();
sender.sendMessage("Serializing Objects"); sender.sendMessage("Serializing Objects");
for(IrisBiome i : biomes) for (IrisBiome i : biomes) {
{ for (IrisObjectPlacement j : i.getObjects()) {
for(IrisObjectPlacement j : i.getObjects())
{
b.append(j.hashCode()); b.append(j.hashCode());
KList<String> newNames = new KList<>(); KList<String> newNames = new KList<>();
for(String k : j.getPlace()) for (String k : j.getPlace()) {
{ if (renameObjects.containsKey(k)) {
if(renameObjects.containsKey(k))
{
newNames.add(renameObjects.get(k)); newNames.add(renameObjects.get(k));
continue; continue;
} }
@@ -510,17 +448,13 @@ public class IrisProject
} }
} }
for(IrisBiomeMutation i : dimension.getMutations()) for (IrisBiomeMutation i : dimension.getMutations()) {
{ for (IrisObjectPlacement j : i.getObjects()) {
for(IrisObjectPlacement j : i.getObjects())
{
b.append(j.hashCode()); b.append(j.hashCode());
KList<String> newNames = new KList<>(); KList<String> newNames = new KList<>();
for(String k : j.getPlace()) for (String k : j.getPlace()) {
{ if (renameObjects.containsKey(k)) {
if(renameObjects.containsKey(k))
{
newNames.add(renameObjects.get(k)); newNames.add(renameObjects.get(k));
continue; continue;
} }
@@ -542,46 +476,36 @@ public class IrisProject
ggg.set(0); ggg.set(0);
biomes.forEach((i) -> i.getObjects().forEach((j) -> j.getPlace().forEach((k) -> biomes.forEach((i) -> i.getObjects().forEach((j) -> j.getPlace().forEach((k) ->
{ {
try try {
{
File f = dm.getObjectLoader().findFile(lookupObjects.get(k).get(0)); File f = dm.getObjectLoader().findFile(lookupObjects.get(k).get(0));
IO.copyFile(f, new File(folder, "objects/" + k + ".iob")); IO.copyFile(f, new File(folder, "objects/" + k + ".iob"));
gb.append(IO.hash(f)); gb.append(IO.hash(f));
ggg.set(ggg.get() + 1); ggg.set(ggg.get() + 1);
if(cl.flip()) if (cl.flip()) {
{
int g = ggg.get(); int g = ggg.get();
ggg.set(0); ggg.set(0);
sender.sendMessage("Wrote another " + g + " Objects"); sender.sendMessage("Wrote another " + g + " Objects");
} }
} } catch (Throwable ignored) {
catch(Throwable ignored)
{
} }
}))); })));
dimension.getMutations().forEach((i) -> i.getObjects().forEach((j) -> j.getPlace().forEach((k) -> dimension.getMutations().forEach((i) -> i.getObjects().forEach((j) -> j.getPlace().forEach((k) ->
{ {
try try {
{
File f = dm.getObjectLoader().findFile(lookupObjects.get(k).get(0)); File f = dm.getObjectLoader().findFile(lookupObjects.get(k).get(0));
IO.copyFile(f, new File(folder, "objects/" + k + ".iob")); IO.copyFile(f, new File(folder, "objects/" + k + ".iob"));
gb.append(IO.hash(f)); gb.append(IO.hash(f));
ggg.set(ggg.get() + 1); ggg.set(ggg.get() + 1);
if(cl.flip()) if (cl.flip()) {
{
int g = ggg.get(); int g = ggg.get();
ggg.set(0); ggg.set(0);
sender.sendMessage("Wrote another " + g + " Objects"); sender.sendMessage("Wrote another " + g + " Objects");
} }
} } catch (Throwable ignored) {
catch(Throwable ignored)
{
} }
}))); })));
@@ -592,14 +516,12 @@ public class IrisProject
Iris.info("Writing Dimensional Scaffold"); Iris.info("Writing Dimensional Scaffold");
try try {
{
a = new JSONObject(new Gson().toJson(dimension)).toString(minify ? 0 : 4); a = new JSONObject(new Gson().toJson(dimension)).toString(minify ? 0 : 4);
IO.writeAll(new File(folder, "dimensions/" + dimension.getLoadKey() + ".json"), a); IO.writeAll(new File(folder, "dimensions/" + dimension.getLoadKey() + ".json"), a);
b.append(IO.hash(a)); b.append(IO.hash(a));
for(IrisGenerator i : generators) for (IrisGenerator i : generators) {
{
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
IO.writeAll(new File(folder, "generators/" + i.getLoadKey() + ".json"), a); IO.writeAll(new File(folder, "generators/" + i.getLoadKey() + ".json"), a);
b.append(IO.hash(a)); b.append(IO.hash(a));
@@ -608,36 +530,31 @@ public class IrisProject
c.append(IO.hash(b.toString())); c.append(IO.hash(b.toString()));
b = new StringBuilder(); b = new StringBuilder();
for(IrisRegion i : regions) for (IrisRegion i : regions) {
{
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
IO.writeAll(new File(folder, "regions/" + i.getLoadKey() + ".json"), a); IO.writeAll(new File(folder, "regions/" + i.getLoadKey() + ".json"), a);
b.append(IO.hash(a)); b.append(IO.hash(a));
} }
for(IrisBlockData i : blocks) for (IrisBlockData i : blocks) {
{
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
IO.writeAll(new File(folder, "blocks/" + i.getLoadKey() + ".json"), a); IO.writeAll(new File(folder, "blocks/" + i.getLoadKey() + ".json"), a);
b.append(IO.hash(a)); b.append(IO.hash(a));
} }
for(IrisBiome i : biomes) for (IrisBiome i : biomes) {
{
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
IO.writeAll(new File(folder, "biomes/" + i.getLoadKey() + ".json"), a); IO.writeAll(new File(folder, "biomes/" + i.getLoadKey() + ".json"), a);
b.append(IO.hash(a)); b.append(IO.hash(a));
} }
for(IrisEntity i : entities) for (IrisEntity i : entities) {
{
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
IO.writeAll(new File(folder, "entities/" + i.getLoadKey() + ".json"), a); IO.writeAll(new File(folder, "entities/" + i.getLoadKey() + ".json"), a);
b.append(IO.hash(a)); b.append(IO.hash(a));
} }
for(IrisLootTable i : loot) for (IrisLootTable i : loot) {
{
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
IO.writeAll(new File(folder, "loot/" + i.getLoadKey() + ".json"), a); IO.writeAll(new File(folder, "loot/" + i.getLoadKey() + ".json"), a);
b.append(IO.hash(a)); b.append(IO.hash(a));
@@ -657,10 +574,7 @@ public class IrisProject
sender.sendMessage("Package Compiled!"); sender.sendMessage("Package Compiled!");
return p; return p;
} } catch (Throwable e) {
catch(Throwable e)
{
e.printStackTrace(); e.printStackTrace();
} }
sender.sendMessage("Failed!"); sender.sendMessage("Failed!");
@@ -8,47 +8,34 @@ import com.volmit.iris.object.IrisDimension;
import com.volmit.iris.scaffold.cache.AtomicCache; import com.volmit.iris.scaffold.cache.AtomicCache;
import com.volmit.iris.util.*; import com.volmit.iris.util.*;
import lombok.Data; import lombok.Data;
import org.bukkit.potion.PotionEffectType;
import org.zeroturnaround.zip.ZipUtil; import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.commons.FileUtils; import org.zeroturnaround.zip.commons.FileUtils;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.IOException; import java.io.IOException;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Data @Data
public class ProjectManager public class ProjectManager {
{
public static final String LISTING = "https://raw.githubusercontent.com/IrisDimensions/_listing/main/listing-v2.json"; public static final String LISTING = "https://raw.githubusercontent.com/IrisDimensions/_listing/main/listing-v2.json";
public static final String WORKSPACE_NAME = "packs"; public static final String WORKSPACE_NAME = "packs";
private KMap<String, String> cacheListing = null; private KMap<String, String> cacheListing = null;
private IrisProject activeProject; private IrisProject activeProject;
private static final AtomicCache<Integer> counter = new AtomicCache<>(); private static final AtomicCache<Integer> counter = new AtomicCache<>();
public ProjectManager() public ProjectManager() {
{ if (IrisSettings.get().isStudio()) {
if(IrisSettings.get().isStudio())
{
J.a(() -> J.a(() ->
{ {
File ignore = getWorkspaceFile(".gitignore"); File ignore = getWorkspaceFile(".gitignore");
if(!ignore.exists()) if (!ignore.exists()) {
{
File m = Iris.getCached("Pack Ignore (.gitignore)", "https://raw.githubusercontent.com/VolmitSoftware/Iris/master/packignore.ignore"); File m = Iris.getCached("Pack Ignore (.gitignore)", "https://raw.githubusercontent.com/VolmitSoftware/Iris/master/packignore.ignore");
if(m != null) if (m != null) {
{ try {
try
{
IO.copyFile(m, ignore); IO.copyFile(m, ignore);
} } catch (IOException e) {
catch(IOException e)
{
} }
} }
@@ -61,27 +48,17 @@ public class ProjectManager
int vv = counter.aquire(() -> { int vv = counter.aquire(() -> {
int v = 0; int v = 0;
try try {
{ for (File i : Iris.instance.getDataFolder(WORKSPACE_NAME).listFiles()) {
for(File i : Iris.instance.getDataFolder(WORKSPACE_NAME).listFiles()) try {
{ if (i.isDirectory() && i.list().length > 0 && !Iris.proj.getListing(true).containsKey(i.getName())) {
try
{
if(i.isDirectory() && i.list().length > 0 && !Iris.proj.getListing(true).keySet().contains(i.getName()))
{
v++; v++;
} }
} } catch (Throwable ignored) {
catch(Throwable ignored)
{
} }
} }
} } catch (Throwable ignored) {
catch(Throwable ignored)
{
} }
@@ -91,73 +68,48 @@ public class ProjectManager
return vv; return vv;
} }
public IrisDimension installIntoWorld(MortarSender sender, String type, File folder) public IrisDimension installIntoWorld(MortarSender sender, String type, File folder) {
{
sender.sendMessage("Looking for Package: " + type); sender.sendMessage("Looking for Package: " + type);
File iris = new File(folder, "iris"); File iris = new File(folder, "iris");
File irispack = new File(folder, "iris/pack"); File irispack = new File(folder, "iris/pack");
IrisDimension dim = IrisDataManager.loadAnyDimension(type); IrisDimension dim = IrisDataManager.loadAnyDimension(type);
if(dim == null) if (dim == null) {
{ for (File i : Iris.proj.getWorkspaceFolder().listFiles()) {
for(File i : Iris.proj.getWorkspaceFolder().listFiles()) if (i.isFile() && i.getName().equals(type + ".iris")) {
{
if(i.isFile() && i.getName().equals(type + ".iris"))
{
sender.sendMessage("Found " + type + ".iris in " + ProjectManager.WORKSPACE_NAME + " folder"); sender.sendMessage("Found " + type + ".iris in " + ProjectManager.WORKSPACE_NAME + " folder");
ZipUtil.unpack(i, irispack); ZipUtil.unpack(i, irispack);
break; break;
} }
} }
} } else {
else
{
sender.sendMessage("Found " + type + " dimension in " + ProjectManager.WORKSPACE_NAME + " folder. Repackaging"); sender.sendMessage("Found " + type + " dimension in " + ProjectManager.WORKSPACE_NAME + " folder. Repackaging");
File f = new IrisProject(new File(getWorkspaceFolder(), type)).getPath(); File f = new IrisProject(new File(getWorkspaceFolder(), type)).getPath();
try try {
{
FileUtils.copyDirectory(f, irispack); FileUtils.copyDirectory(f, irispack);
} } catch (IOException e) {
catch(IOException e)
{
} }
} }
File dimf = new File(irispack, "dimensions/" + type + ".json"); File dimf = new File(irispack, "dimensions/" + type + ".json");
if(!dimf.exists() || !dimf.isFile()) if (!dimf.exists() || !dimf.isFile()) {
{
Iris.proj.downloadSearch(sender, type, false); Iris.proj.downloadSearch(sender, type, false);
File downloaded = Iris.proj.getWorkspaceFolder(type); File downloaded = Iris.proj.getWorkspaceFolder(type);
for(File i : downloaded.listFiles()) for (File i : downloaded.listFiles()) {
{ if (i.isFile()) {
if(i.isFile()) try {
{
try
{
FileUtils.copyFile(i, new File(irispack, i.getName())); FileUtils.copyFile(i, new File(irispack, i.getName()));
} } catch (IOException e) {
catch(IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} } else {
try {
else
{
try
{
FileUtils.copyDirectory(i, new File(irispack, i.getName())); FileUtils.copyDirectory(i, new File(irispack, i.getName()));
} } catch (IOException e) {
catch(IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -166,8 +118,7 @@ public class ProjectManager
IO.delete(downloaded); IO.delete(downloaded);
} }
if(!dimf.exists() || !dimf.isFile()) if (!dimf.exists() || !dimf.isFile()) {
{
sender.sendMessage("Can't find the " + dimf.getName() + " in the dimensions folder of this pack! Failed!"); sender.sendMessage("Can't find the " + dimf.getName() + " in the dimensions folder of this pack! Failed!");
return null; return null;
} }
@@ -175,8 +126,7 @@ public class ProjectManager
IrisDataManager dm = new IrisDataManager(irispack); IrisDataManager dm = new IrisDataManager(irispack);
dim = dm.getDimensionLoader().load(type); dim = dm.getDimensionLoader().load(type);
if(dim == null) if (dim == null) {
{
sender.sendMessage("Can't load the dimension! Failed!"); sender.sendMessage("Can't load the dimension! Failed!");
return null; return null;
} }
@@ -185,17 +135,14 @@ public class ProjectManager
return dim; return dim;
} }
public void downloadSearch(MortarSender sender, String key, boolean trim) public void downloadSearch(MortarSender sender, String key, boolean trim) {
{
downloadSearch(sender, key, trim, false); downloadSearch(sender, key, trim, false);
} }
public void downloadSearch(MortarSender sender, String key, boolean trim, boolean forceOverwrite) public void downloadSearch(MortarSender sender, String key, boolean trim, boolean forceOverwrite) {
{
String url = "?"; String url = "?";
try try {
{
url = getListing(false).get(key); url = getListing(false).get(key);
url = url == null ? key : url; url = url == null ? key : url;
Iris.info("Assuming URL " + url); Iris.info("Assuming URL " + url);
@@ -204,22 +151,17 @@ public class ProjectManager
String repo = nodes[0] + "/" + nodes[1]; String repo = nodes[0] + "/" + nodes[1];
branch = nodes.length > 2 ? nodes[2] : branch; branch = nodes.length > 2 ? nodes[2] : branch;
download(sender, repo, branch, trim, forceOverwrite); download(sender, repo, branch, trim, forceOverwrite);
} } catch (Throwable e) {
catch(Throwable e)
{
e.printStackTrace(); e.printStackTrace();
sender.sendMessage("Failed to download '" + key + "' from " + url + "."); sender.sendMessage("Failed to download '" + key + "' from " + url + ".");
} }
} }
public void download(MortarSender sender, String repo, String branch, boolean trim) throws JsonSyntaxException, IOException public void download(MortarSender sender, String repo, String branch, boolean trim) throws JsonSyntaxException, IOException {
{
download(sender, repo, branch, trim, false); download(sender, repo, branch, trim, false);
} }
public void download(MortarSender sender, String repo, String branch, boolean trim, boolean forceOverwrite) throws JsonSyntaxException, IOException public void download(MortarSender sender, String repo, String branch, boolean trim, boolean forceOverwrite) throws JsonSyntaxException, IOException {
{
String url = "https://codeload.github.com/" + repo + "/zip/refs/heads/" + branch; String url = "https://codeload.github.com/" + repo + "/zip/refs/heads/" + branch;
sender.sendMessage("Downloading " + url); sender.sendMessage("Downloading " + url);
File zip = Iris.getNonCachedFile("pack-" + trim + "-" + repo, url); File zip = Iris.getNonCachedFile("pack-" + trim + "-" + repo, url);
@@ -255,16 +197,14 @@ public class ProjectManager
return; return;
} }
if(dir == null) if (dir == null) {
{
sender.sendMessage("Invalid Format. Missing root folder or too many folders!"); sender.sendMessage("Invalid Format. Missing root folder or too many folders!");
return; return;
} }
File dimensions = new File(dir, "dimensions"); File dimensions = new File(dir, "dimensions");
if(!(dimensions.exists() && dimensions.isDirectory())) if (!(dimensions.exists() && dimensions.isDirectory())) {
{
sender.sendMessage("Invalid Format. Missing dimensions folder"); sender.sendMessage("Invalid Format. Missing dimensions folder");
return; return;
} }
@@ -272,17 +212,14 @@ public class ProjectManager
if (dimensions.listFiles() == null) { if (dimensions.listFiles() == null) {
sender.sendMessage("No dimension file found in the extracted zip file."); sender.sendMessage("No dimension file found in the extracted zip file.");
sender.sendMessage("Check it is there on GitHub and report this to staff!"); sender.sendMessage("Check it is there on GitHub and report this to staff!");
} } else if (dimensions.listFiles().length != 1) {
else if (dimensions.listFiles().length != 1)
{
sender.sendMessage("Dimensions folder must have 1 file in it"); sender.sendMessage("Dimensions folder must have 1 file in it");
return; return;
} }
File dim = dimensions.listFiles()[0]; File dim = dimensions.listFiles()[0];
if(!dim.isFile()) if (!dim.isFile()) {
{
sender.sendMessage("Invalid dimension (folder) in dimensions folder"); sender.sendMessage("Invalid dimension (folder) in dimensions folder");
return; return;
} }
@@ -292,27 +229,23 @@ public class ProjectManager
sender.sendMessage("Importing " + d.getName() + " (" + key + ")"); sender.sendMessage("Importing " + d.getName() + " (" + key + ")");
File packEntry = new File(packs, key); File packEntry = new File(packs, key);
if(forceOverwrite) if (forceOverwrite) {
{
IO.delete(packEntry); IO.delete(packEntry);
} }
if(IrisDataManager.loadAnyDimension(key) != null) if (IrisDataManager.loadAnyDimension(key) != null) {
{
sender.sendMessage("Another dimension in the packs folder is already using the key " + key + " IMPORT FAILED!"); sender.sendMessage("Another dimension in the packs folder is already using the key " + key + " IMPORT FAILED!");
return; return;
} }
if(packEntry.exists() && packEntry.listFiles().length > 0) if (packEntry.exists() && packEntry.listFiles().length > 0) {
{
sender.sendMessage("Another pack is using the key " + key + ". IMPORT FAILED!"); sender.sendMessage("Another pack is using the key " + key + ". IMPORT FAILED!");
return; return;
} }
FileUtils.copyDirectory(dir, packEntry); FileUtils.copyDirectory(dir, packEntry);
if(trim) if (trim) {
{
sender.sendMessage("Trimming " + key); sender.sendMessage("Trimming " + key);
File cp = compilePackage(sender, key, false, false); File cp = compilePackage(sender, key, false, false);
IO.delete(packEntry); IO.delete(packEntry);
@@ -323,42 +256,33 @@ public class ProjectManager
sender.sendMessage("Successfully Aquired " + d.getName()); sender.sendMessage("Successfully Aquired " + d.getName());
} }
public KMap<String, String> getListing(boolean cached) public KMap<String, String> getListing(boolean cached) {
{ if (cached && cacheListing != null) {
if(cached && cacheListing != null)
{
return cacheListing; return cacheListing;
} }
JSONObject a; JSONObject a;
if(cached) if (cached) {
{
a = new JSONObject(Iris.getCached("cachedlisting", LISTING)); a = new JSONObject(Iris.getCached("cachedlisting", LISTING));
} } else {
else
{
a = new JSONObject(Iris.getNonCached(true + "listing", LISTING)); a = new JSONObject(Iris.getNonCached(true + "listing", LISTING));
} }
KMap<String, String> l = new KMap<>(); KMap<String, String> l = new KMap<>();
for(String i : a.keySet()) for (String i : a.keySet()) {
{
l.put(i, a.getString(i)); l.put(i, a.getString(i));
} }
return l; return l;
} }
public boolean isProjectOpen() public boolean isProjectOpen() {
{
return activeProject != null && activeProject.isOpen(); return activeProject != null && activeProject.isOpen();
} }
public void open(MortarSender sender, String dimm) public void open(MortarSender sender, String dimm) {
{
try { try {
open(sender, dimm, () -> open(sender, dimm, () ->
{ {
@@ -371,10 +295,8 @@ public class ProjectManager
} }
} }
public void open(MortarSender sender, String dimm, Runnable onDone) public void open(MortarSender sender, String dimm, Runnable onDone) {
{ if (isProjectOpen()) {
if(isProjectOpen())
{
close(); close();
} }
@@ -383,55 +305,42 @@ public class ProjectManager
project.open(sender, onDone); project.open(sender, onDone);
} }
public File getWorkspaceFolder(String... sub) public File getWorkspaceFolder(String... sub) {
{
return Iris.instance.getDataFolderList(WORKSPACE_NAME, sub); return Iris.instance.getDataFolderList(WORKSPACE_NAME, sub);
} }
public File getWorkspaceFile(String... sub) public File getWorkspaceFile(String... sub) {
{
return Iris.instance.getDataFileList(WORKSPACE_NAME, sub); return Iris.instance.getDataFileList(WORKSPACE_NAME, sub);
} }
public void close() public void close() {
{ if (isProjectOpen()) {
if(isProjectOpen())
{
activeProject.close(); activeProject.close();
activeProject = null; activeProject = null;
} }
} }
public File compilePackage(MortarSender sender, String d, boolean obfuscate, boolean minify) public File compilePackage(MortarSender sender, String d, boolean obfuscate, boolean minify) {
{
return new IrisProject(new File(getWorkspaceFolder(), d)).compilePackage(sender, obfuscate, minify); return new IrisProject(new File(getWorkspaceFolder(), d)).compilePackage(sender, obfuscate, minify);
} }
public void createFrom(String existingPack, String newName) public void createFrom(String existingPack, String newName) {
{
File importPack = getWorkspaceFolder(existingPack); File importPack = getWorkspaceFolder(existingPack);
File newPack = getWorkspaceFolder(newName); File newPack = getWorkspaceFolder(newName);
if(importPack.listFiles().length == 0) if (importPack.listFiles().length == 0) {
{
Iris.warn("Couldn't find the pack to create a new dimension from."); Iris.warn("Couldn't find the pack to create a new dimension from.");
return; return;
} }
try try {
{ FileUtils.copyDirectory(importPack, newPack, new FileFilter() {
FileUtils.copyDirectory(importPack, newPack, new FileFilter()
{
@Override @Override
public boolean accept(File pathname) public boolean accept(File pathname) {
{
return !pathname.getAbsolutePath().contains(".git"); return !pathname.getAbsolutePath().contains(".git");
} }
}, false); }, false);
} } catch (IOException e) {
catch(IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
@@ -439,94 +348,72 @@ public class ProjectManager
File dimFile = new File(importPack, "dimensions/" + existingPack + ".json"); File dimFile = new File(importPack, "dimensions/" + existingPack + ".json");
File newDimFile = new File(newPack, "dimensions/" + newName + ".json"); File newDimFile = new File(newPack, "dimensions/" + newName + ".json");
try try {
{
FileUtils.copyFile(dimFile, newDimFile); FileUtils.copyFile(dimFile, newDimFile);
} } catch (IOException e) {
catch(IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
new File(newPack, "dimensions/" + existingPack + ".json").delete(); new File(newPack, "dimensions/" + existingPack + ".json").delete();
try try {
{
JSONObject json = new JSONObject(IO.readAll(newDimFile)); JSONObject json = new JSONObject(IO.readAll(newDimFile));
if(json.has("name")) if (json.has("name")) {
{
json.put("name", Form.capitalizeWords(newName.replaceAll("\\Q-\\E", " "))); json.put("name", Form.capitalizeWords(newName.replaceAll("\\Q-\\E", " ")));
IO.writeAll(newDimFile, json.toString(4)); IO.writeAll(newDimFile, json.toString(4));
} }
} } catch (JSONException | IOException e) {
catch(JSONException | IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
try try {
{
IrisProject p = new IrisProject(getWorkspaceFolder(newName)); IrisProject p = new IrisProject(getWorkspaceFolder(newName));
JSONObject ws = p.createCodeWorkspaceConfig(); JSONObject ws = p.createCodeWorkspaceConfig();
IO.writeAll(getWorkspaceFile(newName, newName + ".code-workspace"), ws.toString(0)); IO.writeAll(getWorkspaceFile(newName, newName + ".code-workspace"), ws.toString(0));
} } catch (JSONException | IOException e) {
catch(JSONException | IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
public void create(MortarSender sender, String s, String downloadable) public void create(MortarSender sender, String s, String downloadable) {
{
boolean shouldDelete = false; boolean shouldDelete = false;
File importPack = getWorkspaceFolder(downloadable); File importPack = getWorkspaceFolder(downloadable);
if(importPack.listFiles().length == 0) if (importPack.listFiles().length == 0) {
{
downloadSearch(sender, downloadable, false); downloadSearch(sender, downloadable, false);
if(importPack.listFiles().length > 0) if (importPack.listFiles().length > 0) {
{
shouldDelete = true; shouldDelete = true;
} }
} }
if(importPack.listFiles().length == 0) if (importPack.listFiles().length == 0) {
{
sender.sendMessage("Couldn't find the pack to create a new dimension from."); sender.sendMessage("Couldn't find the pack to create a new dimension from.");
return; return;
} }
File importDimensionFile = new File(importPack, "dimensions/" + downloadable + ".json"); File importDimensionFile = new File(importPack, "dimensions/" + downloadable + ".json");
if(!importDimensionFile.exists()) if (!importDimensionFile.exists()) {
{
sender.sendMessage("Missing Imported Dimension File"); sender.sendMessage("Missing Imported Dimension File");
return; return;
} }
sender.sendMessage("Importing " + downloadable + " into new Project " + s); sender.sendMessage("Importing " + downloadable + " into new Project " + s);
createFrom(downloadable, s); createFrom(downloadable, s);
if(shouldDelete) if (shouldDelete) {
{
importPack.delete(); importPack.delete();
} }
open(sender, s); open(sender, s);
} }
public void create(MortarSender sender, String s) public void create(MortarSender sender, String s) {
{
create(sender, s, "example"); create(sender, s, "example");
} }
public void updateWorkspace() public void updateWorkspace() {
{ if (isProjectOpen()) {
if(isProjectOpen())
{
activeProject.updateWorkspace(); activeProject.updateWorkspace();
} }
} }
File diff suppressed because it is too large Load Diff
@@ -26,55 +26,43 @@ public class WandManager implements Listener {
private static ItemStack wand; private static ItemStack wand;
private static ItemStack dust; private static ItemStack dust;
public WandManager() public WandManager() {
{
wand = createWand(); wand = createWand();
dust = createDust(); dust = createDust();
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () -> Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () ->
{ {
for(Player i : Bukkit.getOnlinePlayers()) for (Player i : Bukkit.getOnlinePlayers()) {
{
tick(i); tick(i);
} }
}, 0, 5); }, 0, 5);
} }
public void tick(Player p) public void tick(Player p) {
{ try {
try if (isWand(p.getInventory().getItemInMainHand())) {
{
if(isWand(p.getInventory().getItemInMainHand()))
{
Location[] d = getCuboid(p.getInventory().getItemInMainHand()); Location[] d = getCuboid(p.getInventory().getItemInMainHand());
draw(d, p); draw(d, p);
} }
} } catch (Throwable ignored) {
catch(Throwable ignored)
{
} }
} }
public void draw(Cuboid d, Player p) public void draw(Cuboid d, Player p) {
{
draw(new Location[]{d.getLowerNE(), d.getUpperSW()}, p); draw(new Location[]{d.getLowerNE(), d.getUpperSW()}, p);
} }
public void draw(Location[] d, Player p) public void draw(Location[] d, Player p) {
{
Vector gx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65); Vector gx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65);
d[0].getWorld().spawnParticle(Particle.CRIT_MAGIC, d[0], 1, 0.5 + gx.getX(), 0.5 + gx.getY(), 0.5 + gx.getZ(), 0, null, false); d[0].getWorld().spawnParticle(Particle.CRIT_MAGIC, d[0], 1, 0.5 + gx.getX(), 0.5 + gx.getY(), 0.5 + gx.getZ(), 0, null, false);
Vector gxx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65); Vector gxx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65);
d[1].getWorld().spawnParticle(Particle.CRIT, d[1], 1, 0.5 + gxx.getX(), 0.5 + gxx.getY(), 0.5 + gxx.getZ(), 0, null, false); d[1].getWorld().spawnParticle(Particle.CRIT, d[1], 1, 0.5 + gxx.getX(), 0.5 + gxx.getY(), 0.5 + gxx.getZ(), 0, null, false);
if(!d[0].getWorld().equals(d[1].getWorld())) if (!d[0].getWorld().equals(d[1].getWorld())) {
{
return; return;
} }
if(d[0].distanceSquared(d[1]) > 64 * 64) if (d[0].distanceSquared(d[1]) > 64 * 64) {
{
return; return;
} }
@@ -85,49 +73,38 @@ public class WandManager implements Listener {
int maxy = Math.max(d[0].getBlockY(), d[1].getBlockY()); int maxy = Math.max(d[0].getBlockY(), d[1].getBlockY());
int maxz = Math.max(d[0].getBlockZ(), d[1].getBlockZ()); int maxz = Math.max(d[0].getBlockZ(), d[1].getBlockZ());
for(double j = minx - 1; j < maxx + 1; j += 0.25) for (double j = minx - 1; j < maxx + 1; j += 0.25) {
{ for (double k = miny - 1; k < maxy + 1; k += 0.25) {
for(double k = miny - 1; k < maxy + 1; k += 0.25) for (double l = minz - 1; l < maxz + 1; l += 0.25) {
{ if (M.r(0.2)) {
for(double l = minz - 1; l < maxz + 1; l += 0.25)
{
if(M.r(0.2))
{
boolean jj = j == minx || j == maxx; boolean jj = j == minx || j == maxx;
boolean kk = k == miny || k == maxy; boolean kk = k == miny || k == maxy;
boolean ll = l == minz || l == maxz; boolean ll = l == minz || l == maxz;
if((jj && kk) || (jj && ll) || (ll && kk)) if ((jj && kk) || (jj && ll) || (ll && kk)) {
{
Vector push = new Vector(0, 0, 0); Vector push = new Vector(0, 0, 0);
if(j == minx) if (j == minx) {
{
push.add(new Vector(-0.55, 0, 0)); push.add(new Vector(-0.55, 0, 0));
} }
if(k == miny) if (k == miny) {
{
push.add(new Vector(0, -0.55, 0)); push.add(new Vector(0, -0.55, 0));
} }
if(l == minz) if (l == minz) {
{
push.add(new Vector(0, 0, -0.55)); push.add(new Vector(0, 0, -0.55));
} }
if(j == maxx) if (j == maxx) {
{
push.add(new Vector(0.55, 0, 0)); push.add(new Vector(0.55, 0, 0));
} }
if(k == maxy) if (k == maxy) {
{
push.add(new Vector(0, 0.55, 0)); push.add(new Vector(0, 0.55, 0));
} }
if(l == maxz) if (l == maxz) {
{
push.add(new Vector(0, 0, 0.55)); push.add(new Vector(0, 0, 0.55));
} }
@@ -145,22 +122,15 @@ public class WandManager implements Listener {
} }
@EventHandler @EventHandler
public void on(PlayerInteractEvent e) public void on(PlayerInteractEvent e) {
{ try {
try if (isWand(e.getPlayer())) {
{ if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
if(isWand(e.getPlayer()))
{
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK))
{
e.setCancelled(true); e.setCancelled(true);
e.getPlayer().getInventory().setItemInMainHand(update(true, Objects.requireNonNull(e.getClickedBlock()).getLocation(), e.getPlayer().getInventory().getItemInMainHand())); e.getPlayer().getInventory().setItemInMainHand(update(true, Objects.requireNonNull(e.getClickedBlock()).getLocation(), e.getPlayer().getInventory().getItemInMainHand()));
e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 0.67f); e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 0.67f);
e.getPlayer().updateInventory(); e.getPlayer().updateInventory();
} } else if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
else if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
{
e.setCancelled(true); e.setCancelled(true);
e.getPlayer().getInventory().setItemInMainHand(update(false, Objects.requireNonNull(e.getClickedBlock()).getLocation(), e.getPlayer().getInventory().getItemInMainHand())); e.getPlayer().getInventory().setItemInMainHand(update(false, Objects.requireNonNull(e.getClickedBlock()).getLocation(), e.getPlayer().getInventory().getItemInMainHand()));
e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 1.17f); e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 1.17f);
@@ -168,38 +138,29 @@ public class WandManager implements Listener {
} }
} }
if(isDust(e.getPlayer())) if (isDust(e.getPlayer())) {
{ if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
{
e.setCancelled(true); e.setCancelled(true);
e.getPlayer().playSound(Objects.requireNonNull(e.getClickedBlock()).getLocation(), Sound.ENTITY_ENDER_EYE_DEATH, 2f, 1.97f); e.getPlayer().playSound(Objects.requireNonNull(e.getClickedBlock()).getLocation(), Sound.ENTITY_ENDER_EYE_DEATH, 2f, 1.97f);
DustRevealer.spawn(e.getClickedBlock(), new MortarSender(e.getPlayer(), Iris.instance.getTag())); DustRevealer.spawn(e.getClickedBlock(), new MortarSender(e.getPlayer(), Iris.instance.getTag()));
} }
} }
} } catch (Throwable ignored) {
catch(Throwable ignored)
{
} }
} }
public static void pasteSchematic(IrisObject s, Location at) public static void pasteSchematic(IrisObject s, Location at) {
{
s.place(at); s.place(at);
} }
public static IrisObject createSchematic(ItemStack wand) public static IrisObject createSchematic(ItemStack wand) {
{ if (!isWand(wand)) {
if(!isWand(wand))
{
return null; return null;
} }
try try {
{
Location[] f = getCuboid(wand); Location[] f = getCuboid(wand);
Cuboid c = new Cuboid(f[0], f[1]); Cuboid c = new Cuboid(f[0], f[1]);
IrisObject s = new IrisObject(c.getSizeX(), c.getSizeY(), c.getSizeZ()); IrisObject s = new IrisObject(c.getSizeX(), c.getSizeY(), c.getSizeZ());
@@ -213,48 +174,36 @@ public class WandManager implements Listener {
} }
return s; return s;
} } catch (Throwable e) {
catch(Throwable e)
{
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
public static Location stringToLocation(String s) public static Location stringToLocation(String s) {
{ try {
try
{
String[] f = s.split("\\Q in \\E"); String[] f = s.split("\\Q in \\E");
String[] g = f[0].split("\\Q,\\E"); String[] g = f[0].split("\\Q,\\E");
return new Location(Bukkit.getWorld(f[1]), Integer.parseInt(g[0]), Integer.parseInt(g[1]), Integer.parseInt(g[2])); return new Location(Bukkit.getWorld(f[1]), Integer.parseInt(g[0]), Integer.parseInt(g[1]), Integer.parseInt(g[2]));
} } catch (Throwable e) {
catch(Throwable e)
{
return null; return null;
} }
} }
public static String locationToString(Location s) public static String locationToString(Location s) {
{ if (s == null) {
if(s == null)
{
return "<#>"; return "<#>";
} }
return s.getBlockX() + "," + s.getBlockY() + "," + s.getBlockZ() + " in " + s.getWorld().getName(); return s.getBlockX() + "," + s.getBlockY() + "," + s.getBlockZ() + " in " + s.getWorld().getName();
} }
public static ItemStack createWand() public static ItemStack createWand() {
{
return createWand(null, null); return createWand(null, null);
} }
public static ItemStack createDust() public static ItemStack createDust() {
{
ItemStack is = new ItemStack(Material.GLOWSTONE_DUST); ItemStack is = new ItemStack(Material.GLOWSTONE_DUST);
is.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1); is.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
ItemMeta im = is.getItemMeta(); ItemMeta im = is.getItemMeta();
@@ -267,37 +216,31 @@ public class WandManager implements Listener {
return is; return is;
} }
public boolean isDust(Player p) public boolean isDust(Player p) {
{
ItemStack is = p.getInventory().getItemInMainHand(); ItemStack is = p.getInventory().getItemInMainHand();
return is != null && isDust(is); return is != null && isDust(is);
} }
public boolean isDust(ItemStack is) public boolean isDust(ItemStack is) {
{
return is.equals(dust); return is.equals(dust);
} }
public ItemStack update(boolean left, Location a, ItemStack item) public ItemStack update(boolean left, Location a, ItemStack item) {
{ if (!isWand(item)) {
if(!isWand(item))
{
return item; return item;
} }
Location[] f = getCuboid(item); Location[] f = getCuboid(item);
Location other = left ? f[1] : f[0]; Location other = left ? f[1] : f[0];
if(other != null && !other.getWorld().getName().equals(a.getWorld().getName())) if (other != null && !other.getWorld().getName().equals(a.getWorld().getName())) {
{
other = null; other = null;
} }
return createWand(left ? a : other, left ? other : a); return createWand(left ? a : other, left ? other : a);
} }
public static ItemStack createWand(Location a, Location b) public static ItemStack createWand(Location a, Location b) {
{
ItemStack is = new ItemStack(Material.BLAZE_ROD); ItemStack is = new ItemStack(Material.BLAZE_ROD);
is.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1); is.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
ItemMeta im = is.getItemMeta(); ItemMeta im = is.getItemMeta();
@@ -310,20 +253,17 @@ public class WandManager implements Listener {
return is; return is;
} }
public static Location[] getCuboid(ItemStack is) public static Location[] getCuboid(ItemStack is) {
{
ItemMeta im = is.getItemMeta(); ItemMeta im = is.getItemMeta();
return new Location[]{stringToLocation(im.getLore().get(0)), stringToLocation(im.getLore().get(1))}; return new Location[]{stringToLocation(im.getLore().get(0)), stringToLocation(im.getLore().get(1))};
} }
public static boolean isWand(Player p) public static boolean isWand(Player p) {
{
ItemStack is = p.getInventory().getItemInMainHand(); ItemStack is = p.getInventory().getItemInMainHand();
return is != null && isWand(is); return is != null && isWand(is);
} }
public static boolean isWand(ItemStack is) public static boolean isWand(ItemStack is) {
{
ItemStack wand = createWand(); ItemStack wand = createWand();
if (is.getItemMeta() == null) return false; if (is.getItemMeta() == null) return false;
return is.getType().equals(wand.getType()) && return is.getType().equals(wand.getType()) &&
@@ -11,8 +11,7 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIris extends MortarCommand public class CommandIris extends MortarCommand {
{
@Command @Command
private CommandIrisCreate create; private CommandIrisCreate create;
@@ -52,15 +51,13 @@ public class CommandIris extends MortarCommand
@Command @Command
private CommandIrisReload reload; private CommandIrisReload reload;
public CommandIris() public CommandIris() {
{
super("iris", "ir", "irs"); super("iris", "ir", "irs");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{
sender.sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software"); sender.sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
printHelp(sender); printHelp(sender);
return true; return true;
@@ -72,8 +69,7 @@ public class CommandIris extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -3,10 +3,8 @@ package com.volmit.iris.manager.command;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.util.*; import com.volmit.iris.util.*;
public class CommandIrisDownload extends MortarCommand public class CommandIrisDownload extends MortarCommand {
{ public CommandIrisDownload() {
public CommandIrisDownload()
{
super("download", "down", "dl"); super("download", "down", "dl");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Download a project."); setDescription("Download a project.");
@@ -18,21 +16,18 @@ public class CommandIrisDownload extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (args.length < 1) {
if(args.length < 1)
{
sender.sendMessage("/iris dl " + C.BOLD + "<NAME>"); sender.sendMessage("/iris dl " + C.BOLD + "<NAME>");
return true; return true;
} }
boolean trim = false; boolean trim = false;
for(String i : args) for (String i : args) {
{ if (i.equals("-t") || i.equals("--trim")) {
if(i.equals("-t") || i.equals("--trim"))
{
trim = true; trim = true;
} }
} }
@@ -45,8 +40,7 @@ public class CommandIrisDownload extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "<name> [-t/--trim]"; return "<name> [-t/--trim]";
} }
} }
@@ -3,14 +3,14 @@ package com.volmit.iris.manager.command;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.scaffold.IrisWorlds; import com.volmit.iris.scaffold.IrisWorlds;
import com.volmit.iris.scaffold.engine.IrisAccess; import com.volmit.iris.scaffold.engine.IrisAccess;
import com.volmit.iris.util.*; import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class CommandIrisMetrics extends MortarCommand public class CommandIrisMetrics extends MortarCommand {
{ public CommandIrisMetrics() {
public CommandIrisMetrics()
{
super("metrics", "stats", "mt"); super("metrics", "stats", "mt");
setDescription("Get timings for this world"); setDescription("Get timings for this world");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -22,36 +22,27 @@ public class CommandIrisMetrics extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (sender.isPlayer()) {
if(sender.isPlayer())
{
Player p = sender.player(); Player p = sender.player();
World world = p.getWorld(); World world = p.getWorld();
if(!IrisWorlds.isIrisWorld(world)) if (!IrisWorlds.isIrisWorld(world)) {
{
sender.sendMessage("You must be in an iris world."); sender.sendMessage("You must be in an iris world.");
return true; return true;
} }
IrisAccess g = IrisWorlds.access(world); IrisAccess g = IrisWorlds.access(world);
try try {
{
g.printMetrics(sender); g.printMetrics(sender);
} } catch (Throwable e) {
catch(Throwable e)
{
sender.sendMessage("You must be in an iris world."); sender.sendMessage("You must be in an iris world.");
} }
return true; return true;
} } else {
else
{
sender.sendMessage("Players only."); sender.sendMessage("Players only.");
} }
@@ -59,8 +50,7 @@ public class CommandIrisMetrics extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -6,10 +6,8 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisReload extends MortarCommand public class CommandIrisReload extends MortarCommand {
{ public CommandIrisReload() {
public CommandIrisReload()
{
super("reload", "rld"); super("reload", "rld");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Reload configs"); setDescription("Reload configs");
@@ -22,8 +20,7 @@ public class CommandIrisReload extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{
IrisSettings.invalidate(); IrisSettings.invalidate();
IrisSettings.get(); IrisSettings.get();
sender.sendMessage("settings.json Reloaded"); sender.sendMessage("settings.json Reloaded");
@@ -31,8 +28,7 @@ public class CommandIrisReload extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "<name> [-t/--trim]"; return "<name> [-t/--trim]";
} }
} }
@@ -3,10 +3,8 @@ package com.volmit.iris.manager.command;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.util.*; import com.volmit.iris.util.*;
public class CommandIrisUpdateProject extends MortarCommand public class CommandIrisUpdateProject extends MortarCommand {
{ public CommandIrisUpdateProject() {
public CommandIrisUpdateProject()
{
super("update-project", "^project"); super("update-project", "^project");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Update a project from git."); setDescription("Update a project from git.");
@@ -19,10 +17,8 @@ public class CommandIrisUpdateProject extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (args.length < 1) {
if(args.length < 1)
{
sender.sendMessage("/iris update-project " + C.BOLD + "<PROJECT>"); sender.sendMessage("/iris update-project " + C.BOLD + "<PROJECT>");
return true; return true;
} }
@@ -33,8 +29,7 @@ public class CommandIrisUpdateProject extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "<project>"; return "<project>";
} }
} }
@@ -3,31 +3,26 @@ package com.volmit.iris.manager.command;
import com.volmit.iris.util.MortarPermission; import com.volmit.iris.util.MortarPermission;
import com.volmit.iris.util.Permission; import com.volmit.iris.util.Permission;
public class PermissionIris extends MortarPermission public class PermissionIris extends MortarPermission {
{
@Permission @Permission
public PermissionIrisStudio studio; public PermissionIrisStudio studio;
public PermissionIris() public PermissionIris() {
{
super(); super();
} }
@Override @Override
protected String getNode() protected String getNode() {
{
return "iris"; return "iris";
} }
@Override @Override
public String getDescription() public String getDescription() {
{
return "Iris Permissions"; return "Iris Permissions";
} }
@Override @Override
public boolean isDefault() public boolean isDefault() {
{
return false; return false;
} }
} }
@@ -2,28 +2,23 @@ package com.volmit.iris.manager.command;
import com.volmit.iris.util.MortarPermission; import com.volmit.iris.util.MortarPermission;
public class PermissionIrisStudio extends MortarPermission public class PermissionIrisStudio extends MortarPermission {
{ public PermissionIrisStudio() {
public PermissionIrisStudio()
{
super(); super();
} }
@Override @Override
protected String getNode() protected String getNode() {
{
return "studio"; return "studio";
} }
@Override @Override
public String getDescription() public String getDescription() {
{
return "Iris Studio Permissions"; return "Iris Studio Permissions";
} }
@Override @Override
public boolean isDefault() public boolean isDefault() {
{
return false; return false;
} }
} }
@@ -7,8 +7,7 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisJigsaw extends MortarCommand public class CommandIrisJigsaw extends MortarCommand {
{
@Command @Command
private CommandIrisJigsawNew create; private CommandIrisJigsawNew create;
@@ -21,8 +20,7 @@ public class CommandIrisJigsaw extends MortarCommand
@Command @Command
private CommandIrisJigsawPlace place; private CommandIrisJigsawPlace place;
public CommandIrisJigsaw() public CommandIrisJigsaw() {
{
super("jigsaw", "jig", "jsw", "j"); super("jigsaw", "jig", "jsw", "j");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Jigsaw"); setCategory("Jigsaw");
@@ -35,16 +33,13 @@ public class CommandIrisJigsaw extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("Ingame only"); sender.sendMessage("Ingame only");
return true; return true;
} }
@@ -55,8 +50,7 @@ public class CommandIrisJigsaw extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -11,10 +11,8 @@ import com.volmit.iris.util.MortarSender;
import java.io.File; import java.io.File;
public class CommandIrisJigsawEdit extends MortarCommand public class CommandIrisJigsawEdit extends MortarCommand {
{ public CommandIrisJigsawEdit() {
public CommandIrisJigsawEdit()
{
super("edit", "e", "*"); super("edit", "e", "*");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Jigsaw"); setCategory("Jigsaw");
@@ -27,30 +25,25 @@ public class CommandIrisJigsawEdit extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("Ingame only"); sender.sendMessage("Ingame only");
return true; return true;
} }
if(args.length < 1) if (args.length < 1) {
{
sender.sendMessage(getArgsUsage()); sender.sendMessage(getArgsUsage());
return true; return true;
} }
IrisJigsawPiece piece = IrisDataManager.loadAnyJigsawPiece(args[0]); IrisJigsawPiece piece = IrisDataManager.loadAnyJigsawPiece(args[0]);
if(piece != null) if (piece != null) {
{
File dest = piece.getLoadFile(); File dest = piece.getLoadFile();
new JigsawEditor(sender.player(), piece, IrisDataManager.loadAnyObject(piece.getObject()), dest); new JigsawEditor(sender.player(), piece, IrisDataManager.loadAnyObject(piece.getObject()), dest);
return true; return true;
@@ -62,8 +55,7 @@ public class CommandIrisJigsawEdit extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "<name>"; return "<name>";
} }
} }
@@ -7,12 +7,8 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
import java.io.File; public class CommandIrisJigsawExit extends MortarCommand {
public CommandIrisJigsawExit() {
public class CommandIrisJigsawExit extends MortarCommand
{
public CommandIrisJigsawExit()
{
super("exit", "x", "close", "stop"); super("exit", "x", "close", "stop");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Jigsaw"); setCategory("Jigsaw");
@@ -25,24 +21,20 @@ public class CommandIrisJigsawExit extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("Ingame only"); sender.sendMessage("Ingame only");
return true; return true;
} }
JigsawEditor editor = JigsawEditor.editors.get(sender.player()); JigsawEditor editor = JigsawEditor.editors.get(sender.player());
if(editor == null) if (editor == null) {
{
sender.sendMessage("You don't have any pieces open to close!"); sender.sendMessage("You don't have any pieces open to close!");
return true; return true;
} }
@@ -52,8 +44,7 @@ public class CommandIrisJigsawExit extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -11,10 +11,8 @@ import com.volmit.iris.util.MortarSender;
import java.io.File; import java.io.File;
public class CommandIrisJigsawNew extends MortarCommand public class CommandIrisJigsawNew extends MortarCommand {
{ public CommandIrisJigsawNew() {
public CommandIrisJigsawNew()
{
super("create", "new", "+", "n"); super("create", "new", "+", "n");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Jigsaw"); setCategory("Jigsaw");
@@ -27,22 +25,18 @@ public class CommandIrisJigsawNew extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("Ingame only"); sender.sendMessage("Ingame only");
return true; return true;
} }
if(args.length != 3) if (args.length != 3) {
{
sender.sendMessage(getArgsUsage()); sender.sendMessage(getArgsUsage());
return true; return true;
} }
@@ -64,8 +58,7 @@ public class CommandIrisJigsawNew extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "<name> <project> <object>"; return "<name> <project> <object>";
} }
} }
@@ -8,10 +8,8 @@ import com.volmit.iris.object.IrisPosition;
import com.volmit.iris.scaffold.jigsaw.PlannedStructure; import com.volmit.iris.scaffold.jigsaw.PlannedStructure;
import com.volmit.iris.util.*; import com.volmit.iris.util.*;
public class CommandIrisJigsawPlace extends MortarCommand public class CommandIrisJigsawPlace extends MortarCommand {
{ public CommandIrisJigsawPlace() {
public CommandIrisJigsawPlace()
{
super("place", "paste", "p"); super("place", "paste", "p");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Jigsaw"); setCategory("Jigsaw");
@@ -24,16 +22,13 @@ public class CommandIrisJigsawPlace extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("Ingame only"); sender.sendMessage("Ingame only");
return true; return true;
} }
@@ -45,8 +40,7 @@ public class CommandIrisJigsawPlace extends MortarCommand
IrisJigsawStructure str = IrisDataManager.loadAnyJigsawStructure(args[0]); IrisJigsawStructure str = IrisDataManager.loadAnyJigsawStructure(args[0]);
if(str != null) if (str != null) {
{
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
PlannedStructure ps = new PlannedStructure(str, new IrisPosition(sender.player().getLocation()), new RNG()); PlannedStructure ps = new PlannedStructure(str, new IrisPosition(sender.player().getLocation()), new RNG());
sender.sendMessage("Generated " + ps.getPieces().size() + " pieces in " + Form.duration(p.getMilliseconds(), 2)); sender.sendMessage("Generated " + ps.getPieces().size() + " pieces in " + Form.duration(p.getMilliseconds(), 2));
@@ -57,8 +51,7 @@ public class CommandIrisJigsawPlace extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "<name>"; return "<name>";
} }
} }
@@ -7,10 +7,8 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisJigsawSave extends MortarCommand public class CommandIrisJigsawSave extends MortarCommand {
{ public CommandIrisJigsawSave() {
public CommandIrisJigsawSave()
{
super("save", "s"); super("save", "s");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Jigsaw"); setCategory("Jigsaw");
@@ -23,24 +21,20 @@ public class CommandIrisJigsawSave extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("Ingame only"); sender.sendMessage("Ingame only");
return true; return true;
} }
JigsawEditor editor = JigsawEditor.editors.get(sender.player()); JigsawEditor editor = JigsawEditor.editors.get(sender.player());
if(editor == null) if (editor == null) {
{
sender.sendMessage("You don't have any pieces open to save!"); sender.sendMessage("You don't have any pieces open to save!");
return true; return true;
} }
@@ -50,8 +44,7 @@ public class CommandIrisJigsawSave extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -7,8 +7,7 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisObject extends MortarCommand public class CommandIrisObject extends MortarCommand {
{
@Command @Command
private CommandIrisObjectWand wand; private CommandIrisObjectWand wand;
@@ -42,8 +41,7 @@ public class CommandIrisObject extends MortarCommand
@Command @Command
private CommandIrisObjectPaste paste; private CommandIrisObjectPaste paste;
public CommandIrisObject() public CommandIrisObject() {
{
super("object", "iob", "o", "obj"); super("object", "iob", "o", "obj");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -56,10 +54,8 @@ public class CommandIrisObject extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
@@ -70,8 +66,7 @@ public class CommandIrisObject extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[subcommand]"; return "[subcommand]";
} }
} }
@@ -1,18 +1,15 @@
package com.volmit.iris.manager.command.object; package com.volmit.iris.manager.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.*; import com.volmit.iris.util.*;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.volmit.iris.Iris; public class CommandIrisObjectContract extends MortarCommand {
import com.volmit.iris.IrisSettings; public CommandIrisObjectContract() {
import com.volmit.iris.manager.WandManager;
public class CommandIrisObjectContract extends MortarCommand
{
public CommandIrisObjectContract()
{
super("-"); super("-");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -24,25 +21,22 @@ public class CommandIrisObjectContract extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("You don't have a wand"); sender.sendMessage("You don't have a wand");
return true; return true;
} }
Player p = sender.player(); Player p = sender.player();
if(!WandManager.isWand(p)) if (!WandManager.isWand(p)) {
{
sender.sendMessage("Ready your Wand."); sender.sendMessage("Ready your Wand.");
return true; return true;
} }
@@ -64,8 +58,7 @@ public class CommandIrisObjectContract extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[amt]"; return "[amt]";
} }
} }
@@ -8,10 +8,8 @@ import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
import org.bukkit.Sound; import org.bukkit.Sound;
public class CommandIrisObjectDust extends MortarCommand public class CommandIrisObjectDust extends MortarCommand {
{ public CommandIrisObjectDust() {
public CommandIrisObjectDust()
{
super("dust", "dst", "d"); super("dust", "dst", "d");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -24,16 +22,13 @@ public class CommandIrisObjectDust extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("You don't have an inventory"); sender.sendMessage("You don't have an inventory");
return true; return true;
} }
@@ -45,8 +40,7 @@ public class CommandIrisObjectDust extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[subcommand]"; return "[subcommand]";
} }
} }
@@ -1,18 +1,15 @@
package com.volmit.iris.manager.command.object; package com.volmit.iris.manager.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.*; import com.volmit.iris.util.*;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.volmit.iris.Iris; public class CommandIrisObjectExpand extends MortarCommand {
import com.volmit.iris.IrisSettings; public CommandIrisObjectExpand() {
import com.volmit.iris.manager.WandManager;
public class CommandIrisObjectExpand extends MortarCommand
{
public CommandIrisObjectExpand()
{
super("+"); super("+");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -24,25 +21,22 @@ public class CommandIrisObjectExpand extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("You don't have a wand"); sender.sendMessage("You don't have a wand");
return true; return true;
} }
Player p = sender.player(); Player p = sender.player();
if(!WandManager.isWand(p)) if (!WandManager.isWand(p)) {
{
sender.sendMessage("Ready your Wand."); sender.sendMessage("Ready your Wand.");
return true; return true;
} }
@@ -64,8 +58,7 @@ public class CommandIrisObjectExpand extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[amt]"; return "[amt]";
} }
} }
@@ -1,23 +1,20 @@
package com.volmit.iris.manager.command.object; package com.volmit.iris.manager.command.object;
import java.util.Set; import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.volmit.iris.Iris; import java.util.Set;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
public class CommandIrisObjectP1 extends MortarCommand public class CommandIrisObjectP1 extends MortarCommand {
{ public CommandIrisObjectP1() {
public CommandIrisObjectP1()
{
super("p1"); super("p1");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -29,41 +26,36 @@ public class CommandIrisObjectP1 extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("You don't have a wand"); sender.sendMessage("You don't have a wand");
return true; return true;
} }
Player p = sender.player(); Player p = sender.player();
if(!WandManager.isWand(p)) if (!WandManager.isWand(p)) {
{
sender.sendMessage("Ready your Wand."); sender.sendMessage("Ready your Wand.");
return true; return true;
} }
ItemStack wand = p.getInventory().getItemInMainHand(); ItemStack wand = p.getInventory().getItemInMainHand();
if(WandManager.isWand(wand)) if (WandManager.isWand(wand)) {
{
Location[] g = WandManager.getCuboid(wand); Location[] g = WandManager.getCuboid(wand);
g[0] = p.getLocation().getBlock().getLocation().clone().add(0, -1, 0); g[0] = p.getLocation().getBlock().getLocation().clone().add(0, -1, 0);
if(args.length == 1 && args[0].equals("-l")) if (args.length == 1 && args[0].equals("-l")) {
{
// TODO: WARNING HEIGHT // TODO: WARNING HEIGHT
g[0] = p.getTargetBlock((Set<Material>) null, 256).getLocation().clone(); g[0] = p.getTargetBlock(null, 256).getLocation().clone();
} }
p.setItemInHand(WandManager.createWand(g[0], g[1])); p.setItemInHand(WandManager.createWand(g[0], g[1]));
@@ -73,8 +65,7 @@ public class CommandIrisObjectP1 extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[-l]"; return "[-l]";
} }
} }
@@ -1,23 +1,20 @@
package com.volmit.iris.manager.command.object; package com.volmit.iris.manager.command.object;
import java.util.Set; import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.volmit.iris.Iris; import java.util.Set;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
public class CommandIrisObjectP2 extends MortarCommand public class CommandIrisObjectP2 extends MortarCommand {
{ public CommandIrisObjectP2() {
public CommandIrisObjectP2()
{
super("p2"); super("p2");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -29,41 +26,36 @@ public class CommandIrisObjectP2 extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("You don't have a wand"); sender.sendMessage("You don't have a wand");
return true; return true;
} }
Player p = sender.player(); Player p = sender.player();
if(!WandManager.isWand(p)) if (!WandManager.isWand(p)) {
{
sender.sendMessage("Ready your Wand."); sender.sendMessage("Ready your Wand.");
return true; return true;
} }
ItemStack wand = p.getInventory().getItemInMainHand(); ItemStack wand = p.getInventory().getItemInMainHand();
if(WandManager.isWand(wand)) if (WandManager.isWand(wand)) {
{
Location[] g = WandManager.getCuboid(wand); Location[] g = WandManager.getCuboid(wand);
g[1] = p.getLocation().getBlock().getLocation().clone().add(0, -1, 0); g[1] = p.getLocation().getBlock().getLocation().clone().add(0, -1, 0);
if(args.length == 1 && args[0].equals("-l")) if (args.length == 1 && args[0].equals("-l")) {
{
// TODO: WARNING HEIGHT // TODO: WARNING HEIGHT
g[1] = p.getTargetBlock((Set<Material>) null, 256).getLocation().clone(); g[1] = p.getTargetBlock(null, 256).getLocation().clone();
} }
p.setItemInHand(WandManager.createWand(g[0], g[1])); p.setItemInHand(WandManager.createWand(g[0], g[1]));
@@ -73,8 +65,7 @@ public class CommandIrisObjectP2 extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[-l]"; return "[-l]";
} }
} }
@@ -18,10 +18,8 @@ import org.bukkit.inventory.ItemStack;
import java.io.File; import java.io.File;
import java.util.Set; import java.util.Set;
public class CommandIrisObjectPaste extends MortarCommand public class CommandIrisObjectPaste extends MortarCommand {
{ public CommandIrisObjectPaste() {
public CommandIrisObjectPaste()
{
super("paste", "pasta", "place", "p"); super("paste", "pasta", "place", "p");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -32,17 +30,15 @@ public class CommandIrisObjectPaste extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("You don't have a wand"); sender.sendMessage("You don't have a wand");
return true; return true;
} }
@@ -55,8 +51,7 @@ public class CommandIrisObjectPaste extends MortarCommand
Player p = sender.player(); Player p = sender.player();
IrisObject obj = IrisDataManager.loadAnyObject(args[0]); IrisObject obj = IrisDataManager.loadAnyObject(args[0]);
if(obj == null) if (obj == null) {
{
sender.sendMessage("Can't find " + args[0] + " in the " + ProjectManager.WORKSPACE_NAME + " folder"); sender.sendMessage("Can't find " + args[0] + " in the " + ProjectManager.WORKSPACE_NAME + " folder");
return true; return true;
@@ -65,16 +60,13 @@ public class CommandIrisObjectPaste extends MortarCommand
File file = obj.getLoadFile(); File file = obj.getLoadFile();
boolean intoWand = false; boolean intoWand = false;
for(String i : args) for (String i : args) {
{ if (i.equalsIgnoreCase("-edit")) {
if(i.equalsIgnoreCase("-edit"))
{
intoWand = true; intoWand = true;
} }
} }
if(file == null || !file.exists()) if (file == null || !file.exists()) {
{
sender.sendMessage("Can't find " + args[0] + " in the " + ProjectManager.WORKSPACE_NAME + " folder"); sender.sendMessage("Can't find " + args[0] + " in the " + ProjectManager.WORKSPACE_NAME + " folder");
return true; return true;
} }
@@ -82,18 +74,16 @@ public class CommandIrisObjectPaste extends MortarCommand
ItemStack wand = sender.player().getInventory().getItemInMainHand(); ItemStack wand = sender.player().getInventory().getItemInMainHand();
IrisObject o = IrisDataManager.loadAnyObject(args[0]); IrisObject o = IrisDataManager.loadAnyObject(args[0]);
if(o == null) if (o == null) {
{
sender.sendMessage("Error, cant find"); sender.sendMessage("Error, cant find");
return true; return true;
} }
sender.sendMessage("Loaded " + "objects/" + args[0] + ".iob"); sender.sendMessage("Loaded " + "objects/" + args[0] + ".iob");
sender.player().getWorld().playSound(sender.player().getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f); sender.player().getWorld().playSound(sender.player().getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f);
Location block = sender.player().getTargetBlock((Set<Material>) null, 256).getLocation().clone().add(0, 1, 0); Location block = sender.player().getTargetBlock(null, 256).getLocation().clone().add(0, 1, 0);
if(intoWand && WandManager.isWand(wand)) if (intoWand && WandManager.isWand(wand)) {
{
wand = WandManager.createWand(block.clone().subtract(o.getCenter()).add(o.getW() - 1, o.getH(), o.getD() - 1), block.clone().subtract(o.getCenter())); wand = WandManager.createWand(block.clone().subtract(o.getCenter()).add(o.getW() - 1, o.getH(), o.getD() - 1), block.clone().subtract(o.getCenter()));
p.getInventory().setItemInMainHand(wand); p.getInventory().setItemInMainHand(wand);
sender.sendMessage("Updated wand for " + "objects/" + args[0] + ".iob"); sender.sendMessage("Updated wand for " + "objects/" + args[0] + ".iob");
@@ -106,8 +96,7 @@ public class CommandIrisObjectPaste extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[name] [-edit]"; return "[name] [-edit]";
} }
} }
@@ -1,23 +1,20 @@
package com.volmit.iris.manager.command.object; package com.volmit.iris.manager.command.object;
import java.io.File;
import com.volmit.iris.util.KList;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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.WandManager; import com.volmit.iris.manager.WandManager;
import com.volmit.iris.object.IrisObject; import com.volmit.iris.object.IrisObject;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class CommandIrisObjectSave extends MortarCommand import java.io.File;
{
public CommandIrisObjectSave() public class CommandIrisObjectSave extends MortarCommand {
{ public CommandIrisObjectSave() {
super("save", "s"); super("save", "s");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -29,36 +26,30 @@ public class CommandIrisObjectSave extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("You don't have a wand"); sender.sendMessage("You don't have a wand");
return true; return true;
} }
if(args.length < 2) if (args.length < 2) {
{
sender.sendMessage("/iris o save <project> <object>"); sender.sendMessage("/iris o save <project> <object>");
sender.sendMessage("I.e. /iris o save overworld some-tree/tree1"); sender.sendMessage("I.e. /iris o save overworld some-tree/tree1");
return true; return true;
} }
try try {
{
boolean overwrite = false; boolean overwrite = false;
for(String i : args) for (String i : args) {
{ if (i.equals("-o")) {
if(i.equals("-o"))
{
overwrite = true; overwrite = true;
} }
} }
@@ -68,10 +59,8 @@ public class CommandIrisObjectSave extends MortarCommand
IrisObject o = WandManager.createSchematic(wand); IrisObject o = WandManager.createSchematic(wand);
File file = Iris.proj.getWorkspaceFile(args[0], "objects", args[1] + ".iob"); File file = Iris.proj.getWorkspaceFile(args[0], "objects", args[1] + ".iob");
if(file.exists()) if (file.exists()) {
{ if (!overwrite) {
if(!overwrite)
{
sender.sendMessage("File Exists. Overwrite by adding -o"); sender.sendMessage("File Exists. Overwrite by adding -o");
return true; return true;
} }
@@ -80,10 +69,7 @@ public class CommandIrisObjectSave extends MortarCommand
o.write(file); o.write(file);
sender.sendMessage("Saved " + args[1]); sender.sendMessage("Saved " + args[1]);
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f); p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f);
} } catch (Throwable e) {
catch(Throwable e)
{
sender.sendMessage("Failed to save " + args[1] + ". Are you holding your wand?"); sender.sendMessage("Failed to save " + args[1] + ". Are you holding your wand?");
e.printStackTrace(); e.printStackTrace();
@@ -93,8 +79,7 @@ public class CommandIrisObjectSave extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[project] [name]"; return "[project] [name]";
} }
} }
@@ -1,18 +1,15 @@
package com.volmit.iris.manager.command.object; package com.volmit.iris.manager.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.*; import com.volmit.iris.util.*;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.volmit.iris.Iris; public class CommandIrisObjectShift extends MortarCommand {
import com.volmit.iris.IrisSettings; public CommandIrisObjectShift() {
import com.volmit.iris.manager.WandManager;
public class CommandIrisObjectShift extends MortarCommand
{
public CommandIrisObjectShift()
{
super(">"); super(">");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -24,25 +21,22 @@ public class CommandIrisObjectShift extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("You don't have a wand"); sender.sendMessage("You don't have a wand");
return true; return true;
} }
Player p = sender.player(); Player p = sender.player();
if(!WandManager.isWand(p)) if (!WandManager.isWand(p)) {
{
sender.sendMessage("Ready your Wand."); sender.sendMessage("Ready your Wand.");
return true; return true;
} }
@@ -65,8 +59,7 @@ public class CommandIrisObjectShift extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[amt]"; return "[amt]";
} }
} }
@@ -1,18 +1,15 @@
package com.volmit.iris.manager.command.object; package com.volmit.iris.manager.command.object;
import com.volmit.iris.util.KList;
import org.bukkit.Sound;
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.WandManager; import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
import org.bukkit.Sound;
public class CommandIrisObjectWand extends MortarCommand public class CommandIrisObjectWand extends MortarCommand {
{ public CommandIrisObjectWand() {
public CommandIrisObjectWand()
{
super("wand", "w"); super("wand", "w");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -24,17 +21,15 @@ public class CommandIrisObjectWand extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("You don't have an inventory"); sender.sendMessage("You don't have an inventory");
return true; return true;
} }
@@ -46,8 +41,7 @@ public class CommandIrisObjectWand extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[subcommand]"; return "[subcommand]";
} }
} }
@@ -1,24 +1,21 @@
package com.volmit.iris.manager.command.object; package com.volmit.iris.manager.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.Cuboid;
import com.volmit.iris.util.Cuboid.CuboidDirection;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.volmit.iris.Iris; public class CommandIrisObjectXAY extends MortarCommand {
import com.volmit.iris.IrisSettings; public CommandIrisObjectXAY() {
import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.Cuboid;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import com.volmit.iris.util.Cuboid.CuboidDirection;
public class CommandIrisObjectXAY extends MortarCommand
{
public CommandIrisObjectXAY()
{
super("x&y"); super("x&y");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -30,25 +27,22 @@ public class CommandIrisObjectXAY extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("You don't have a wand"); sender.sendMessage("You don't have a wand");
return true; return true;
} }
Player p = sender.player(); Player p = sender.player();
if(!WandManager.isWand(p)) if (!WandManager.isWand(p)) {
{
sender.sendMessage("Ready your Wand."); sender.sendMessage("Ready your Wand.");
return true; return true;
} }
@@ -61,8 +55,7 @@ public class CommandIrisObjectXAY extends MortarCommand
Cuboid cursor = new Cuboid(a1, a2); Cuboid cursor = new Cuboid(a1, a2);
Cuboid cursorx = new Cuboid(a1, a2); Cuboid cursorx = new Cuboid(a1, a2);
while(!cursor.containsOnly(Material.AIR)) while (!cursor.containsOnly(Material.AIR)) {
{
a1.add(new Vector(0, 1, 0)); a1.add(new Vector(0, 1, 0));
a2.add(new Vector(0, 1, 0)); a2.add(new Vector(0, 1, 0));
cursor = new Cuboid(a1, a2); cursor = new Cuboid(a1, a2);
@@ -71,8 +64,7 @@ public class CommandIrisObjectXAY extends MortarCommand
a1.add(new Vector(0, -1, 0)); a1.add(new Vector(0, -1, 0));
a2.add(new Vector(0, -1, 0)); a2.add(new Vector(0, -1, 0));
while(!cursorx.containsOnly(Material.AIR)) while (!cursorx.containsOnly(Material.AIR)) {
{
a1x.add(new Vector(0, -1, 0)); a1x.add(new Vector(0, -1, 0));
a2x.add(new Vector(0, -1, 0)); a2x.add(new Vector(0, -1, 0));
cursorx = new Cuboid(a1x, a2x); cursorx = new Cuboid(a1x, a2x);
@@ -97,8 +89,7 @@ public class CommandIrisObjectXAY extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[subcommand]"; return "[subcommand]";
} }
} }
@@ -1,24 +1,21 @@
package com.volmit.iris.manager.command.object; package com.volmit.iris.manager.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.Cuboid;
import com.volmit.iris.util.Cuboid.CuboidDirection;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.volmit.iris.Iris; public class CommandIrisObjectXPY extends MortarCommand {
import com.volmit.iris.IrisSettings; public CommandIrisObjectXPY() {
import com.volmit.iris.manager.WandManager;
import com.volmit.iris.util.Cuboid;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import com.volmit.iris.util.Cuboid.CuboidDirection;
public class CommandIrisObjectXPY extends MortarCommand
{
public CommandIrisObjectXPY()
{
super("x+y"); super("x+y");
requiresPermission(Iris.perm); requiresPermission(Iris.perm);
setCategory("Object"); setCategory("Object");
@@ -31,24 +28,20 @@ public class CommandIrisObjectXPY extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!sender.isPlayer()) if (!sender.isPlayer()) {
{
sender.sendMessage("You don't have a wand"); sender.sendMessage("You don't have a wand");
return true; return true;
} }
Player p = sender.player(); Player p = sender.player();
if(!WandManager.isWand(p)) if (!WandManager.isWand(p)) {
{
sender.sendMessage("Ready your Wand."); sender.sendMessage("Ready your Wand.");
return true; return true;
} }
@@ -59,8 +52,7 @@ public class CommandIrisObjectXPY extends MortarCommand
Location a2 = b[1].clone(); Location a2 = b[1].clone();
Cuboid cursor = new Cuboid(a1, a2); Cuboid cursor = new Cuboid(a1, a2);
while(!cursor.containsOnly(Material.AIR)) while (!cursor.containsOnly(Material.AIR)) {
{
a1.add(new Vector(0, 1, 0)); a1.add(new Vector(0, 1, 0));
a2.add(new Vector(0, 1, 0)); a2.add(new Vector(0, 1, 0));
cursor = new Cuboid(a1, a2); cursor = new Cuboid(a1, a2);
@@ -85,8 +77,7 @@ public class CommandIrisObjectXPY extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[subcommand]"; return "[subcommand]";
} }
} }
@@ -7,8 +7,7 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisStudio extends MortarCommand public class CommandIrisStudio extends MortarCommand {
{
@Command @Command
private CommandIrisStudioCreate create; private CommandIrisStudioCreate create;
@@ -60,8 +59,7 @@ public class CommandIrisStudio extends MortarCommand
@Command @Command
private CommandIrisStudioMap map; private CommandIrisStudioMap map;
public CommandIrisStudio() public CommandIrisStudio() {
{
super("studio", "std", "s"); super("studio", "std", "s");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setCategory("Studio"); setCategory("Studio");
@@ -73,10 +71,8 @@ public class CommandIrisStudio extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
@@ -87,8 +83,7 @@ public class CommandIrisStudio extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[subcommand]"; return "[subcommand]";
} }
} }
@@ -3,18 +3,11 @@ 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.util.*; import com.volmit.iris.util.*;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.io.IOException;
public class CommandIrisStudioBeautify extends MortarCommand public class CommandIrisStudioBeautify extends MortarCommand {
{ public CommandIrisStudioBeautify() {
public CommandIrisStudioBeautify()
{
super("beautify", "prettify"); super("beautify", "prettify");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Prettify the project by cleaning up json."); setDescription("Prettify the project by cleaning up json.");
@@ -27,33 +20,25 @@ public class CommandIrisStudioBeautify extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
File clean = null; File clean = null;
if(args.length == 0) if (args.length == 0) {
{ if (!Iris.proj.isProjectOpen()) {
if(!Iris.proj.isProjectOpen())
{
sender.sendMessage("No open project. Either use /iris std beautify <project> or have a project open."); sender.sendMessage("No open project. Either use /iris std beautify <project> or have a project open.");
return true; return true;
} }
clean = Iris.proj.getActiveProject().getPath(); clean = Iris.proj.getActiveProject().getPath();
} } else {
else
{
clean = Iris.instance.getDataFolder("packs", args[0]); clean = Iris.instance.getDataFolder("packs", args[0]);
if(!clean.exists()) if (!clean.exists()) {
{
sender.sendMessage("Not a valid project."); sender.sendMessage("Not a valid project.");
return true; return true;
} }
@@ -66,16 +51,11 @@ public class CommandIrisStudioBeautify extends MortarCommand
private int clean(MortarSender s, File clean) { private int clean(MortarSender s, File clean) {
int c = 0; int c = 0;
if(clean.isDirectory()) if (clean.isDirectory()) {
{ for (File i : clean.listFiles()) {
for(File i : clean.listFiles())
{
c += clean(s, i); c += clean(s, i);
} }
} } else if (clean.getName().endsWith(".json")) {
else if(clean.getName().endsWith(".json"))
{
try { try {
IO.writeAll(clean, new JSONObject(IO.readAll(clean)).toString(4)); IO.writeAll(clean, new JSONObject(IO.readAll(clean)).toString(4));
} catch (Throwable e) { } catch (Throwable e) {
@@ -89,8 +69,7 @@ public class CommandIrisStudioBeautify extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[project]"; return "[project]";
} }
} }
@@ -1,19 +1,16 @@
package com.volmit.iris.manager.command.studio; package com.volmit.iris.manager.command.studio;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.volmit.iris.Iris; public class CommandIrisStudioClose extends MortarCommand {
import com.volmit.iris.IrisSettings; public CommandIrisStudioClose() {
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
public class CommandIrisStudioClose extends MortarCommand
{
public CommandIrisStudioClose()
{
super("close", "x"); super("close", "x");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Close the existing dimension"); setDescription("Close the existing dimension");
@@ -26,28 +23,22 @@ public class CommandIrisStudioClose extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!Iris.proj.isProjectOpen()) if (!Iris.proj.isProjectOpen()) {
{
sender.sendMessage("No open projects."); sender.sendMessage("No open projects.");
return true; return true;
} }
if(sender.isPlayer()) if (sender.isPlayer()) {
{
World f = null; World f = null;
for(World i : Bukkit.getWorlds()) for (World i : Bukkit.getWorlds()) {
{ if (i.getWorldFolder().getAbsolutePath().equals(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getWorldFolder().getAbsolutePath())) {
if(i.getWorldFolder().getAbsolutePath().equals(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getWorldFolder().getAbsolutePath()))
{
continue; continue;
} }
@@ -55,18 +46,12 @@ public class CommandIrisStudioClose extends MortarCommand
break; break;
} }
if(f == null) if (f == null) {
{ for (Player i : Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getPlayers()) {
for(Player i : Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getPlayers())
{
i.kickPlayer("Project Closing, No other world to put you in. Rejoin Please!"); i.kickPlayer("Project Closing, No other world to put you in. Rejoin Please!");
} }
} } else {
for (Player i : Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getPlayers()) {
else
{
for(Player i : Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getPlayers())
{
i.teleport(f.getSpawnLocation()); i.teleport(f.getSpawnLocation());
} }
} }
@@ -78,8 +63,7 @@ public class CommandIrisStudioClose extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -6,10 +6,8 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisStudioConvert extends MortarCommand public class CommandIrisStudioConvert extends MortarCommand {
{ public CommandIrisStudioConvert() {
public CommandIrisStudioConvert()
{
super("convert", "cvt"); super("convert", "cvt");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Convert .ewg schematics into Iris (.iob) files"); setDescription("Convert .ewg schematics into Iris (.iob) files");
@@ -22,10 +20,8 @@ public class CommandIrisStudioConvert extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
@@ -35,8 +31,7 @@ public class CommandIrisStudioConvert extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -7,10 +7,8 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisStudioCreate extends MortarCommand public class CommandIrisStudioCreate extends MortarCommand {
{ public CommandIrisStudioCreate() {
public CommandIrisStudioCreate()
{
super("create", "new", "+"); super("create", "new", "+");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Create a new project & open it."); setDescription("Create a new project & open it.");
@@ -23,16 +21,13 @@ public class CommandIrisStudioCreate extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(args.length < 1) if (args.length < 1) {
{
sender.sendMessage("Please use a lowercase name with hyphens (-) for spaces."); sender.sendMessage("Please use a lowercase name with hyphens (-) for spaces.");
sender.sendMessage("I.e. /iris std new " + C.BOLD + "aether"); sender.sendMessage("I.e. /iris std new " + C.BOLD + "aether");
return true; return true;
@@ -40,21 +35,15 @@ public class CommandIrisStudioCreate extends MortarCommand
String template = null; String template = null;
for(String i : args) for (String i : args) {
{ if (i.startsWith("template=")) {
if(i.startsWith("template="))
{
template = i.split("\\Q=\\E")[1]; template = i.split("\\Q=\\E")[1];
} }
} }
if(template != null) if (template != null) {
{
Iris.proj.create(sender, args[0], template); Iris.proj.create(sender, args[0], template);
} } else {
else
{
Iris.proj.create(sender, args[0]); Iris.proj.create(sender, args[0]);
} }
@@ -62,8 +51,7 @@ public class CommandIrisStudioCreate extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[dimension] [template=<project>]"; return "[dimension] [template=<project>]";
} }
} }
@@ -10,10 +10,8 @@ import org.bukkit.entity.Player;
import java.awt.*; import java.awt.*;
import java.io.File; import java.io.File;
public class CommandIrisStudioEditBiome extends MortarCommand public class CommandIrisStudioEditBiome extends MortarCommand {
{ public CommandIrisStudioEditBiome() {
public CommandIrisStudioEditBiome()
{
super("editbiome", "ebiome", "eb"); super("editbiome", "ebiome", "eb");
setDescription("Open this biome file in vscode"); setDescription("Open this biome file in vscode");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -26,40 +24,29 @@ public class CommandIrisStudioEditBiome extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!Iris.proj.isProjectOpen()) if (!Iris.proj.isProjectOpen()) {
{
sender.sendMessage("There is not a studio currently loaded."); sender.sendMessage("There is not a studio currently loaded.");
return true; return true;
} }
if(sender.isPlayer()) if (sender.isPlayer()) {
{
Player p = sender.player(); Player p = sender.player();
try try {
{
File f = Iris.proj.getActiveProject().getActiveProvider().getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ()).getLoadFile(); File f = Iris.proj.getActiveProject().getActiveProvider().getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ()).getLoadFile();
Desktop.getDesktop().open(f); Desktop.getDesktop().open(f);
} } catch (Throwable e) {
catch(Throwable e)
{
sender.sendMessage("Cant find the file. Are you in an Iris Studio world?"); sender.sendMessage("Cant find the file. Are you in an Iris Studio world?");
} }
return true; return true;
} } else {
else
{
sender.sendMessage("Players only."); sender.sendMessage("Players only.");
} }
@@ -67,8 +54,7 @@ public class CommandIrisStudioEditBiome extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[width]"; return "[width]";
} }
} }
@@ -8,13 +8,11 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisStudioExplorer extends MortarCommand public class CommandIrisStudioExplorer extends MortarCommand {
{
@Command @Command
private CommandIrisStudioExplorerGenerator generator; private CommandIrisStudioExplorerGenerator generator;
public CommandIrisStudioExplorer() public CommandIrisStudioExplorer() {
{
super("noise", "nmap"); super("noise", "nmap");
setDescription("Explore different noise generators visually"); setDescription("Explore different noise generators visually");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -27,23 +25,16 @@ public class CommandIrisStudioExplorer extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (args.length != 0) {
if(args.length != 0)
{
printHelp(sender); printHelp(sender);
} } else {
if (!IrisSettings.get().isStudio()) {
else
{
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!IrisSettings.get().isUseServerLaunchedGuis()) if (!IrisSettings.get().isUseServerLaunchedGuis()) {
{
sender.sendMessage("To use Iris Guis, please enable serverLaunchedGuis in Iris/settings.json"); sender.sendMessage("To use Iris Guis, please enable serverLaunchedGuis in Iris/settings.json");
return true; return true;
} }
@@ -55,8 +46,7 @@ public class CommandIrisStudioExplorer extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -10,10 +10,8 @@ import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
public class CommandIrisStudioExplorerGenerator extends MortarCommand public class CommandIrisStudioExplorerGenerator extends MortarCommand {
{ public CommandIrisStudioExplorerGenerator() {
public CommandIrisStudioExplorerGenerator()
{
super("generator", "gen", "g"); super("generator", "gen", "g");
setDescription("Preview created noise noises generators"); setDescription("Preview created noise noises generators");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -26,22 +24,18 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!IrisSettings.get().isUseServerLaunchedGuis()) if (!IrisSettings.get().isUseServerLaunchedGuis()) {
{
sender.sendMessage("To use Iris Guis, please enable serverLaunchedGuis in Iris/settings.json"); sender.sendMessage("To use Iris Guis, please enable serverLaunchedGuis in Iris/settings.json");
return true; return true;
} }
if (args.length == 0) if (args.length == 0) {
{
sender.sendMessage("Specify a generator to preview"); sender.sendMessage("Specify a generator to preview");
return true; return true;
} }
@@ -49,27 +43,21 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
IrisGenerator generator; IrisGenerator generator;
long seed = 12345; long seed = 12345;
if (Iris.proj.isProjectOpen()) if (Iris.proj.isProjectOpen()) {
{
generator = Iris.proj.getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(args[0]); generator = Iris.proj.getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(args[0]);
seed = Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSeed(); seed = Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSeed();
} } else {
else
{
generator = IrisDataManager.loadAnyGenerator(args[0]); generator = IrisDataManager.loadAnyGenerator(args[0]);
} }
if (generator != null) if (generator != null) {
{
long finalSeed = seed; long finalSeed = seed;
NoiseExplorer.launch((x, z) -> NoiseExplorer.launch((x, z) ->
generator.getHeight(x, z, new RNG(finalSeed).nextParallelRNG(3245).lmax()), "Gen: " + generator.getLoadKey()); generator.getHeight(x, z, new RNG(finalSeed).nextParallelRNG(3245).lmax()), "Gen: " + generator.getLoadKey());
sender.sendMessage("Opening Noise Explorer for gen " + generator.getLoadKey() + " (" + generator.getLoader().getDataFolder().getName() + ")"); 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");
} }
@@ -77,8 +65,7 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[generator]"; return "[generator]";
} }
} }
@@ -16,10 +16,8 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class CommandIrisStudioGoto extends MortarCommand public class CommandIrisStudioGoto extends MortarCommand {
{ public CommandIrisStudioGoto() {
public CommandIrisStudioGoto()
{
super("goto", "find", "g", "tp"); super("goto", "find", "g", "tp");
setDescription("Find any region or biome"); setDescription("Find any region or biome");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -28,8 +26,7 @@ public class CommandIrisStudioGoto extends MortarCommand
@Override @Override
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
if(args.length == 0 && sender.isPlayer() && IrisWorlds.isIrisWorld(sender.player().getWorld())) if (args.length == 0 && sender.isPlayer() && IrisWorlds.isIrisWorld(sender.player().getWorld())) {
{
IrisDataManager data = IrisWorlds.access(sender.player().getWorld()).getData(); IrisDataManager data = IrisWorlds.access(sender.player().getWorld()).getData();
if (data == null) { if (data == null) {
sender.sendMessage("Issue when loading tab completions. No data found (?)"); sender.sendMessage("Issue when loading tab completions. No data found (?)");
@@ -42,23 +39,18 @@ public class CommandIrisStudioGoto extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ try {
try if (args.length < 1) {
{
if(args.length < 1)
{
sender.sendMessage("/iris std goto " + getArgsUsage()); sender.sendMessage("/iris std goto " + getArgsUsage());
return true; return true;
} }
if(sender.isPlayer()) if (sender.isPlayer()) {
{
Player p = sender.player(); Player p = sender.player();
World world = p.getWorld(); World world = p.getWorld();
if(!IrisWorlds.isIrisWorld(world)) if (!IrisWorlds.isIrisWorld(world)) {
{
sender.sendMessage("You must be in an iris world."); sender.sendMessage("You must be in an iris world.");
return true; return true;
} }
@@ -68,36 +60,24 @@ public class CommandIrisStudioGoto extends MortarCommand
IrisRegion r = IrisDataManager.loadAnyRegion(args[0]); IrisRegion r = IrisDataManager.loadAnyRegion(args[0]);
IrisObject o = IrisDataManager.loadAnyObject(args[0]); IrisObject o = IrisDataManager.loadAnyObject(args[0]);
if(b != null) if (b != null) {
{
J.a(() -> { J.a(() -> {
Location l = g.lookForBiome(b, 10000, (v) -> sender.sendMessage("Looking for " + C.BOLD + C.WHITE + b.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); Location l = g.lookForBiome(b, 10000, (v) -> sender.sendMessage("Looking for " + C.BOLD + C.WHITE + b.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places"));
if(l == null) if (l == null) {
{
sender.sendMessage("Couldn't find " + b.getName() + "."); sender.sendMessage("Couldn't find " + b.getName() + ".");
} } else {
else
{
sender.sendMessage("Found " + b.getName() + "!"); sender.sendMessage("Found " + b.getName() + "!");
J.s(() -> sender.player().teleport(l)); J.s(() -> sender.player().teleport(l));
} }
}); });
} } else if (r != null) {
else if(r != null)
{
J.a(() -> { J.a(() -> {
Location l = g.lookForRegion(r, 60000, (v) -> sender.sendMessage(C.BOLD + "" + C.WHITE + r.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); Location l = g.lookForRegion(r, 60000, (v) -> sender.sendMessage(C.BOLD + "" + C.WHITE + r.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places"));
if(l == null) if (l == null) {
{
sender.sendMessage("Couldn't find " + r.getName() + "."); sender.sendMessage("Couldn't find " + r.getName() + ".");
} } else {
else
{
sender.sendMessage("Found " + r.getName() + "!"); sender.sendMessage("Found " + r.getName() + "!");
J.s(() -> sender.player().teleport(l)); J.s(() -> sender.player().teleport(l));
} }
@@ -126,22 +106,15 @@ public class CommandIrisStudioGoto extends MortarCommand
}); });
}*/ }*/
else else {
{
sender.sendMessage(args[0] + " is not a biome or region in this dimension. (Biome teleportation works best!"); sender.sendMessage(args[0] + " is not a biome or region in this dimension. (Biome teleportation works best!");
} }
return true; return true;
} } else {
else
{
sender.sendMessage("Players only."); sender.sendMessage("Players only.");
} }
} } catch (Throwable e) {
catch(Throwable e)
{
Iris.error("Failed goto!"); Iris.error("Failed goto!");
e.printStackTrace(); e.printStackTrace();
sender.sendMessage("We cant seem to aquire a lock on the biome cache. Please report the error in the console to our github. Thanks!"); sender.sendMessage("We cant seem to aquire a lock on the biome cache. Please report the error in the console to our github. Thanks!");
@@ -151,8 +124,7 @@ public class CommandIrisStudioGoto extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[biome/region]"; return "[biome/region]";
} }
@@ -9,10 +9,8 @@ import com.volmit.iris.util.MortarSender;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class CommandIrisStudioHotload extends MortarCommand public class CommandIrisStudioHotload extends MortarCommand {
{ public CommandIrisStudioHotload() {
public CommandIrisStudioHotload()
{
super("hotload", "hot", "h", "reload"); super("hotload", "hot", "h", "reload");
setDescription("Force a hotload"); setDescription("Force a hotload");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -24,21 +22,18 @@ public class CommandIrisStudioHotload extends MortarCommand
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) { public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(sender.isPlayer()) if (sender.isPlayer()) {
{
Player p = sender.player(); Player p = sender.player();
World world = p.getWorld(); World world = p.getWorld();
if(!IrisWorlds.isIrisWorld(world)) if (!IrisWorlds.isIrisWorld(world)) {
{
sender.sendMessage("You must be in an iris world."); sender.sendMessage("You must be in an iris world.");
return true; return true;
} }
@@ -46,10 +41,7 @@ public class CommandIrisStudioHotload extends MortarCommand
IrisWorlds.access(world).hotload(); IrisWorlds.access(world).hotload();
sender.sendMessage("Hotloaded!"); sender.sendMessage("Hotloaded!");
return true; return true;
} } else {
else
{
sender.sendMessage("Players only."); sender.sendMessage("Players only.");
} }
@@ -57,8 +49,7 @@ public class CommandIrisStudioHotload extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -2,7 +2,6 @@ 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.object.InventorySlotType; import com.volmit.iris.object.InventorySlotType;
import com.volmit.iris.object.IrisLootTable; import com.volmit.iris.object.IrisLootTable;
import com.volmit.iris.scaffold.IrisWorlds; import com.volmit.iris.scaffold.IrisWorlds;
@@ -13,10 +12,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
public class CommandIrisStudioLoot extends MortarCommand public class CommandIrisStudioLoot extends MortarCommand {
{ public CommandIrisStudioLoot() {
public CommandIrisStudioLoot()
{
super("loot"); super("loot");
setDescription("Show loot if a chest were right here"); setDescription("Show loot if a chest were right here");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -29,21 +26,17 @@ public class CommandIrisStudioLoot extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(sender.isPlayer()) if (sender.isPlayer()) {
{
Player p = sender.player(); Player p = sender.player();
IrisAccess prov = IrisWorlds.access(sender.player().getWorld()); IrisAccess prov = IrisWorlds.access(sender.player().getWorld());
if (!Iris.proj.isProjectOpen()) if (!Iris.proj.isProjectOpen()) {
{
sender.sendMessage("You can only use /iris studio loot in a studio world of iris."); sender.sendMessage("You can only use /iris studio loot in a studio world of iris.");
return true; return true;
} }
@@ -51,36 +44,28 @@ public class CommandIrisStudioLoot extends MortarCommand
KList<IrisLootTable> tables = prov.getCompound().getEngine(p.getLocation().getBlockY()).getLootTables(RNG.r, p.getLocation().getBlock()); KList<IrisLootTable> tables = prov.getCompound().getEngine(p.getLocation().getBlockY()).getLootTables(RNG.r, p.getLocation().getBlock());
Inventory inv = Bukkit.createInventory(null, 27 * 2); Inventory inv = Bukkit.createInventory(null, 27 * 2);
try try {
{
Iris.proj.getActiveProject().getActiveProvider().getCompound().getEngine(p.getLocation().getBlockY()).addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ(), 1); Iris.proj.getActiveProject().getActiveProvider().getCompound().getEngine(p.getLocation().getBlockY()).addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ(), 1);
} } catch (Throwable e) {
catch(Throwable e)
{
sender.sendMessage("You can only use /iris loot in a studio world of iris."); sender.sendMessage("You can only use /iris loot in a studio world of iris.");
return true; return true;
} }
p.openInventory(inv); p.openInventory(inv);
for(IrisLootTable i : tables) for (IrisLootTable i : tables) {
{
sender.sendMessage("- " + i.getName()); sender.sendMessage("- " + i.getName());
} }
boolean ffast = false; boolean ffast = false;
boolean fadd = false; boolean fadd = false;
for(String i : args) for (String i : args) {
{ if (i.equals("--fast")) {
if(i.equals("--fast"))
{
ffast = true; ffast = true;
} }
if(i.equals("--add")) if (i.equals("--add")) {
{
fadd = true; fadd = true;
} }
} }
@@ -92,14 +77,12 @@ public class CommandIrisStudioLoot extends MortarCommand
ta.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () -> ta.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () ->
{ {
if(!p.getOpenInventory().getType().equals(InventoryType.CHEST)) if (!p.getOpenInventory().getType().equals(InventoryType.CHEST)) {
{
Bukkit.getScheduler().cancelTask(ta.get()); Bukkit.getScheduler().cancelTask(ta.get());
return; return;
} }
if(!add) if (!add) {
{
inv.clear(); inv.clear();
} }
@@ -107,10 +90,7 @@ public class CommandIrisStudioLoot extends MortarCommand
}, 0, fast ? 5 : 35)); }, 0, fast ? 5 : 35));
return true; return true;
} } else {
else
{
sender.sendMessage("Players only."); sender.sendMessage("Players only.");
} }
@@ -118,8 +98,7 @@ public class CommandIrisStudioLoot extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[width]"; return "[width]";
} }
} }
@@ -9,10 +9,8 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisStudioMap extends MortarCommand public class CommandIrisStudioMap extends MortarCommand {
{ public CommandIrisStudioMap() {
public CommandIrisStudioMap()
{
super("map", "render"); super("map", "render");
setDescription("Render a map (gui outside of mc)"); setDescription("Render a map (gui outside of mc)");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -25,30 +23,23 @@ public class CommandIrisStudioMap extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(!IrisSettings.get().isUseServerLaunchedGuis()) if (!IrisSettings.get().isUseServerLaunchedGuis()) {
{
sender.sendMessage("To use Iris Guis, please enable serverLaunchedGuis in Iris/settings.json"); sender.sendMessage("To use Iris Guis, please enable serverLaunchedGuis in Iris/settings.json");
return true; return true;
} }
try try {
{
IrisAccess g = Iris.proj.getActiveProject().getActiveProvider(); IrisAccess g = Iris.proj.getActiveProject().getActiveProvider();
IrisVision.launch(g, 0); IrisVision.launch(g, 0);
sender.sendMessage("Opening Map!"); sender.sendMessage("Opening Map!");
} } catch (Throwable e) {
catch(Throwable e)
{
IrisAccess g = IrisWorlds.access(sender.player().getWorld()); IrisAccess g = IrisWorlds.access(sender.player().getWorld());
IrisVision.launch(g, 0); IrisVision.launch(g, 0);
sender.sendMessage("Opening Map!"); sender.sendMessage("Opening Map!");
@@ -58,8 +49,7 @@ public class CommandIrisStudioMap extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -6,10 +6,8 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisStudioOpen extends MortarCommand public class CommandIrisStudioOpen extends MortarCommand {
{ public CommandIrisStudioOpen() {
public CommandIrisStudioOpen()
{
super("open", "o"); super("open", "o");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Create a new temporary world to design a dimension."); setDescription("Create a new temporary world to design a dimension.");
@@ -22,16 +20,13 @@ public class CommandIrisStudioOpen extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(args.length < 1) if (args.length < 1) {
{
sender.sendMessage("/iris std open <DIMENSION> (file name without .json)"); sender.sendMessage("/iris std open <DIMENSION> (file name without .json)");
return true; return true;
} }
@@ -41,8 +36,7 @@ public class CommandIrisStudioOpen extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[dimension]"; return "[dimension]";
} }
} }
@@ -7,10 +7,8 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisStudioPackage extends MortarCommand public class CommandIrisStudioPackage extends MortarCommand {
{ public CommandIrisStudioPackage() {
public CommandIrisStudioPackage()
{
super("package", "pkg"); super("package", "pkg");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Package your dimension into a compressed format."); setDescription("Package your dimension into a compressed format.");
@@ -23,16 +21,13 @@ public class CommandIrisStudioPackage extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(args.length == 0) if (args.length == 0) {
{
sender.sendMessage("/iris std package <DIMENSION> [-o] [-m]"); sender.sendMessage("/iris std package <DIMENSION> [-o] [-m]");
return true; return true;
} }
@@ -42,10 +37,8 @@ public class CommandIrisStudioPackage extends MortarCommand
boolean o = false; boolean o = false;
boolean m = true; boolean m = true;
for(String i : args) for (String i : args) {
{ if (i.equalsIgnoreCase("-o")) {
if(i.equalsIgnoreCase("-o"))
{
o = true; o = true;
} }
} }
@@ -58,8 +51,7 @@ public class CommandIrisStudioPackage extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[dimension] [-o] [-m]"; return "[dimension] [-o] [-m]";
} }
} }
@@ -11,10 +11,8 @@ import com.volmit.iris.util.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
public class CommandIrisStudioProfile extends MortarCommand public class CommandIrisStudioProfile extends MortarCommand {
{ public CommandIrisStudioProfile() {
public CommandIrisStudioProfile()
{
super("profile", "blame"); super("profile", "blame");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Profile the specified project"); setDescription("Profile the specified project");
@@ -27,10 +25,8 @@ public class CommandIrisStudioProfile extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
@@ -39,23 +35,17 @@ public class CommandIrisStudioProfile extends MortarCommand
File f = null; File f = null;
File report = Iris.instance.getDataFile("profile.txt"); File report = Iris.instance.getDataFile("profile.txt");
KList<String> v = new KList<>(); KList<String> v = new KList<>();
if(args.length == 0) if (args.length == 0) {
{ if (!Iris.proj.isProjectOpen()) {
if(!Iris.proj.isProjectOpen())
{
sender.sendMessage("No open project. Either use /iris std beautify <project> or have a project open."); sender.sendMessage("No open project. Either use /iris std beautify <project> or have a project open.");
return; return;
} }
f = Iris.proj.getActiveProject().getPath(); f = Iris.proj.getActiveProject().getPath();
} } else {
else
{
f = Iris.instance.getDataFolder("packs", args[0]); f = Iris.instance.getDataFolder("packs", args[0]);
if(!f.exists()) if (!f.exists()) {
{
sender.sendMessage("Not a valid project."); sender.sendMessage("Not a valid project.");
return; return;
} }
@@ -72,20 +62,17 @@ public class CommandIrisStudioProfile extends MortarCommand
sender.sendMessage("Calculating Performance Metrics for Noise Generators..."); sender.sendMessage("Calculating Performance Metrics for Noise Generators...");
for(NoiseStyle i : NoiseStyle.values()) for (NoiseStyle i : NoiseStyle.values()) {
{
CNG c = i.create(new RNG(i.hashCode())); CNG c = i.create(new RNG(i.hashCode()));
for(int j = 0; j < 30000; j++) for (int j = 0; j < 30000; j++) {
{
c.noise(j, j + 1000, j * j); c.noise(j, j + 1000, j * j);
c.noise(j, -j); c.noise(j, -j);
} }
PrecisionStopwatch px = PrecisionStopwatch.start(); PrecisionStopwatch px = PrecisionStopwatch.start();
for(int j = 0; j < 1000000; j++) for (int j = 0; j < 1000000; j++) {
{
c.noise(j, j + 1000, j * j); c.noise(j, j + 1000, j * j);
c.noise(j, -j); c.noise(j, -j);
} }
@@ -95,8 +82,7 @@ public class CommandIrisStudioProfile extends MortarCommand
v.add("Noise Style Performance Impacts: "); v.add("Noise Style Performance Impacts: ");
for(NoiseStyle i : styleTimings.sortKNumber()) for (NoiseStyle i : styleTimings.sortKNumber()) {
{
v.add(i.name() + ": " + styleTimings.get(i)); v.add(i.name() + ": " + styleTimings.get(i));
} }
@@ -104,8 +90,7 @@ public class CommandIrisStudioProfile extends MortarCommand
sender.sendMessage("Calculating Interpolator Timings..."); sender.sendMessage("Calculating Interpolator Timings...");
for(InterpolationMethod i : InterpolationMethod.values()) for (InterpolationMethod i : InterpolationMethod.values()) {
{
IrisInterpolator in = new IrisInterpolator(); IrisInterpolator in = new IrisInterpolator();
in.setFunction(i); in.setFunction(i);
in.setHorizontalScale(8); in.setHorizontalScale(8);
@@ -117,15 +102,13 @@ public class CommandIrisStudioProfile extends MortarCommand
} }
}; };
for(int j = 0; j < 3000; j++) for (int j = 0; j < 3000; j++) {
{
in.interpolate(j, -j, np); in.interpolate(j, -j, np);
} }
PrecisionStopwatch px = PrecisionStopwatch.start(); PrecisionStopwatch px = PrecisionStopwatch.start();
for(int j = 0; j < 100000; j++) for (int j = 0; j < 100000; j++) {
{
in.interpolate(j + 10000, -j - 100000, np); in.interpolate(j + 10000, -j - 100000, np);
} }
@@ -134,8 +117,7 @@ public class CommandIrisStudioProfile extends MortarCommand
v.add("Noise Interpolator Performance Impacts: "); v.add("Noise Interpolator Performance Impacts: ");
for(InterpolationMethod i : interpolatorTimings.sortKNumber()) for (InterpolationMethod i : interpolatorTimings.sortKNumber()) {
{
v.add(i.name() + ": " + interpolatorTimings.get(i)); v.add(i.name() + ": " + interpolatorTimings.get(i));
} }
@@ -145,15 +127,13 @@ public class CommandIrisStudioProfile extends MortarCommand
KMap<String, KList<String>> btx = new KMap<>(); KMap<String, KList<String>> btx = new KMap<>();
for(String i : data.getGeneratorLoader().getPossibleKeys()) for (String i : data.getGeneratorLoader().getPossibleKeys()) {
{
KList<String> vv = new KList<>(); KList<String> vv = new KList<>();
IrisGenerator g = data.getGeneratorLoader().load(i); IrisGenerator g = data.getGeneratorLoader().load(i);
KList<IrisNoiseGenerator> composites = g.getAllComposites(); KList<IrisNoiseGenerator> composites = g.getAllComposites();
double score = 0; double score = 0;
int m = 0; int m = 0;
for(IrisNoiseGenerator j : composites) for (IrisNoiseGenerator j : composites) {
{
m++; m++;
score += styleTimings.get(j.getStyle().getStyle()); score += styleTimings.get(j.getStyle().getStyle());
vv.add("Composite Noise Style " + m + " " + j.getStyle().getStyle().name() + ": " + styleTimings.get(j.getStyle().getStyle())); vv.add("Composite Noise Style " + m + " " + j.getStyle().getStyle().name() + ": " + styleTimings.get(j.getStyle().getStyle()));
@@ -167,8 +147,7 @@ public class CommandIrisStudioProfile extends MortarCommand
v.add("Project Generator Performance Impacts: "); v.add("Project Generator Performance Impacts: ");
for(String i : generatorTimings.sortKNumber()) for (String i : generatorTimings.sortKNumber()) {
{
v.add(i + ": " + generatorTimings.get(i)); v.add(i + ": " + generatorTimings.get(i));
btx.get(i).forEach((ii) -> v.add(" " + ii)); btx.get(i).forEach((ii) -> v.add(" " + ii));
@@ -178,15 +157,13 @@ public class CommandIrisStudioProfile extends MortarCommand
KMap<String, KList<String>> bt = new KMap<>(); KMap<String, KList<String>> bt = new KMap<>();
for(String i : data.getBiomeLoader().getPossibleKeys()) for (String i : data.getBiomeLoader().getPossibleKeys()) {
{
KList<String> vv = new KList<>(); KList<String> vv = new KList<>();
IrisBiome b = data.getBiomeLoader().load(i); IrisBiome b = data.getBiomeLoader().load(i);
double score = 0; double score = 0;
int m = 0; int m = 0;
for(IrisBiomePaletteLayer j : b.getLayers()) for (IrisBiomePaletteLayer j : b.getLayers()) {
{
m++; m++;
score += styleTimings.get(j.getStyle().getStyle()); score += styleTimings.get(j.getStyle().getStyle());
vv.add("Palette Layer " + m + ": " + styleTimings.get(j.getStyle().getStyle())); vv.add("Palette Layer " + m + ": " + styleTimings.get(j.getStyle().getStyle()));
@@ -202,8 +179,7 @@ public class CommandIrisStudioProfile extends MortarCommand
v.add("Project Biome Performance Impacts: "); v.add("Project Biome Performance Impacts: ");
for(String i : biomeTimings.sortKNumber()) for (String i : biomeTimings.sortKNumber()) {
{
v.add(i + ": " + biomeTimings.get(i)); v.add(i + ": " + biomeTimings.get(i));
bt.get(i).forEach((ff) -> v.add(" " + ff)); bt.get(i).forEach((ff) -> v.add(" " + ff));
@@ -211,8 +187,7 @@ public class CommandIrisStudioProfile extends MortarCommand
v.add(""); v.add("");
for(String i : data.getRegionLoader().getPossibleKeys()) for (String i : data.getRegionLoader().getPossibleKeys()) {
{
IrisRegion b = data.getRegionLoader().load(i); IrisRegion b = data.getRegionLoader().load(i);
double score = 0; double score = 0;
@@ -223,29 +198,25 @@ public class CommandIrisStudioProfile extends MortarCommand
v.add("Project Region Performance Impacts: "); v.add("Project Region Performance Impacts: ");
for(String i : regionTimings.sortKNumber()) for (String i : regionTimings.sortKNumber()) {
{
v.add(i + ": " + regionTimings.get(i)); v.add(i + ": " + regionTimings.get(i));
} }
v.add(""); v.add("");
double m = 0; double m = 0;
for(double i : biomeTimings.v()) for (double i : biomeTimings.v()) {
{
m += i; m += i;
} }
m /= biomeTimings.size(); m /= biomeTimings.size();
double mm = 0; double mm = 0;
for(double i : generatorTimings.v()) for (double i : generatorTimings.v()) {
{
mm += i; mm += i;
} }
mm /= generatorTimings.size(); mm /= generatorTimings.size();
m += mm; m += mm;
double mmm = 0; double mmm = 0;
for(double i : regionTimings.v()) for (double i : regionTimings.v()) {
{
mmm += i; mmm += i;
} }
mmm /= regionTimings.size(); mmm /= regionTimings.size();
@@ -264,13 +235,11 @@ public class CommandIrisStudioProfile extends MortarCommand
}); });
return true; return true;
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[project]"; return "[project]";
} }
} }
@@ -13,10 +13,8 @@ import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class CommandIrisStudioSummon extends MortarCommand public class CommandIrisStudioSummon extends MortarCommand {
{ public CommandIrisStudioSummon() {
public CommandIrisStudioSummon()
{
super("summon", "spawnmob"); super("summon", "spawnmob");
setDescription("Spawn an Iris entity"); setDescription("Spawn an Iris entity");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -29,39 +27,29 @@ public class CommandIrisStudioSummon extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(sender.isPlayer()) if (sender.isPlayer()) {
{
Player p = sender.player(); Player p = sender.player();
World world = p.getWorld(); World world = p.getWorld();
if(!IrisWorlds.isIrisWorld(world)) if (!IrisWorlds.isIrisWorld(world)) {
{
sender.sendMessage("You must be in an iris world."); sender.sendMessage("You must be in an iris world.");
return true; return true;
} }
IrisAccess g = IrisWorlds.access(world); IrisAccess g = IrisWorlds.access(world);
if(args.length == 0) if (args.length == 0) {
{ for (String i : g.getData().getEntityLoader().getPossibleKeys()) {
for(String i : g.getData().getEntityLoader().getPossibleKeys())
{
sender.sendMessage("- " + i); sender.sendMessage("- " + i);
} }
} } else {
else
{
IrisEntity e = g.getData().getEntityLoader().load(args[0]); IrisEntity e = g.getData().getEntityLoader().load(args[0]);
if(e == null) if (e == null) {
{
sender.sendMessage("Couldnt find entity " + args[0] + ". Use '/iris std summon' to see a list of iris entities."); sender.sendMessage("Couldnt find entity " + args[0] + ". Use '/iris std summon' to see a list of iris entities.");
return true; return true;
} }
@@ -69,10 +57,7 @@ public class CommandIrisStudioSummon extends MortarCommand
Location vl = sender.player().getLocation().clone().add(0, 3, 0); Location vl = sender.player().getLocation().clone().add(0, 3, 0);
e.spawn((Engine) g.getEngineAccess(vl.getBlockY()), vl); e.spawn((Engine) g.getEngineAccess(vl.getBlockY()), vl);
} }
} } else {
else
{
sender.sendMessage("Players only."); sender.sendMessage("Players only.");
} }
@@ -80,8 +65,7 @@ public class CommandIrisStudioSummon extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -7,10 +7,8 @@ import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
import org.bukkit.GameMode; import org.bukkit.GameMode;
public class CommandIrisStudioTPStudio extends MortarCommand public class CommandIrisStudioTPStudio extends MortarCommand {
{ public CommandIrisStudioTPStudio() {
public CommandIrisStudioTPStudio()
{
super("tps", "stp", "tpstudio"); super("tps", "stp", "tpstudio");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Go to the spawn of the currently open studio world."); setDescription("Go to the spawn of the currently open studio world.");
@@ -23,10 +21,8 @@ public class CommandIrisStudioTPStudio extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
@@ -36,21 +32,16 @@ public class CommandIrisStudioTPStudio extends MortarCommand
return true; return true;
} }
if(!Iris.proj.isProjectOpen()) if (!Iris.proj.isProjectOpen()) {
{
sender.sendMessage("There is not a studio currently loaded."); sender.sendMessage("There is not a studio currently loaded.");
return true; return true;
} }
try try {
{
sender.sendMessage("Teleporting you to the active studio world."); sender.sendMessage("Teleporting you to the active studio world.");
sender.player().teleport(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSpawnLocation()); sender.player().teleport(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSpawnLocation());
sender.player().setGameMode(GameMode.SPECTATOR); sender.player().setGameMode(GameMode.SPECTATOR);
} } catch (Throwable e) {
catch(Throwable e)
{
sender.sendMessage("Failed to teleport to the studio world. Try re-opening the project."); sender.sendMessage("Failed to teleport to the studio world. Try re-opening the project.");
} }
@@ -58,8 +49,7 @@ public class CommandIrisStudioTPStudio extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -7,10 +7,8 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisStudioUpdate extends MortarCommand public class CommandIrisStudioUpdate extends MortarCommand {
{ public CommandIrisStudioUpdate() {
public CommandIrisStudioUpdate()
{
super("update", "upd", "u"); super("update", "upd", "u");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
setDescription("Update your dimension project."); setDescription("Update your dimension project.");
@@ -23,27 +21,20 @@ public class CommandIrisStudioUpdate extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (!IrisSettings.get().isStudio()) {
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json"); sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
return true; return true;
} }
if(args.length == 0) if (args.length == 0) {
{
sender.sendMessage("/iris std package <DIMENSION>"); sender.sendMessage("/iris std package <DIMENSION>");
return true; return true;
} }
if(new IrisProject(Iris.proj.getWorkspaceFolder(args[0])).updateWorkspace()) if (new IrisProject(Iris.proj.getWorkspaceFolder(args[0])).updateWorkspace()) {
{
sender.sendMessage("Updated Code Workspace for " + args[0]); sender.sendMessage("Updated Code Workspace for " + args[0]);
} } else {
else
{
sender.sendMessage("Invalid project: " + args[0] + ". Try deleting the code-workspace file and try again."); sender.sendMessage("Invalid project: " + args[0] + ". Try deleting the code-workspace file and try again.");
} }
@@ -51,8 +42,7 @@ public class CommandIrisStudioUpdate extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return "[dimension]"; return "[dimension]";
} }
} }
@@ -6,8 +6,7 @@ import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
public class CommandIrisWhat extends MortarCommand public class CommandIrisWhat extends MortarCommand {
{
@Command @Command
private CommandIrisWhatBlock block; private CommandIrisWhatBlock block;
@@ -20,8 +19,7 @@ public class CommandIrisWhat extends MortarCommand
@Command @Command
private CommandIrisWhatObjects objects; private CommandIrisWhatObjects objects;
public CommandIrisWhat() public CommandIrisWhat() {
{
super("what", "w", "?"); super("what", "w", "?");
setDescription("Get timings for this world"); setDescription("Get timings for this world");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -35,16 +33,14 @@ public class CommandIrisWhat extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{
sender.sendMessage("Iris 'What' Commands:"); sender.sendMessage("Iris 'What' Commands:");
printHelp(sender); printHelp(sender);
return true; return true;
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -8,31 +8,12 @@ import com.volmit.iris.scaffold.engine.IrisAccess;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistry;
import net.minecraft.core.IRegistryCustom;
import net.minecraft.core.IRegistryWritable;
import net.minecraft.data.RegistryGeneration;
import net.minecraft.data.worldgen.biome.BiomeRegistry;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.commands.CommandLocateBiome;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.level.biome.BiomeBase;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.Field; public class CommandIrisWhatBiome extends MortarCommand {
import java.util.Map; public CommandIrisWhatBiome() {
public class CommandIrisWhatBiome extends MortarCommand
{
public CommandIrisWhatBiome()
{
super("biome", "bi", "b"); super("biome", "bi", "b");
setDescription("Get the biome data you are in."); setDescription("Get the biome data you are in.");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -46,44 +27,30 @@ public class CommandIrisWhatBiome extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (sender.isPlayer()) {
if(sender.isPlayer())
{
Player p = sender.player(); Player p = sender.player();
World w = p.getWorld(); World w = p.getWorld();
try try {
{
IrisAccess g = IrisWorlds.access(w); IrisAccess g = IrisWorlds.access(w);
assert g != null; assert g != null;
IrisBiome b = g.getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ()); IrisBiome b = g.getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ());
sender.sendMessage("IBiome: " + b.getLoadKey() + " (" + b.getDerivative().name() + ")"); sender.sendMessage("IBiome: " + b.getLoadKey() + " (" + b.getDerivative().name() + ")");
} } catch (Throwable e) {
catch(Throwable e)
{
sender.sendMessage("Non-Iris Biome: " + p.getLocation().getBlock().getBiome().name()); sender.sendMessage("Non-Iris Biome: " + p.getLocation().getBlock().getBiome().name());
if(p.getLocation().getBlock().getBiome().equals(Biome.CUSTOM)) if (p.getLocation().getBlock().getBiome().equals(Biome.CUSTOM)) {
{ try {
try
{
sender.sendMessage("Data Pack Biome: " + INMS.get().getTrueBiomeBaseKey(p.getLocation()) + " (ID: " + INMS.get().getTrueBiomeBaseId(INMS.get().getTrueBiomeBase(p.getLocation())) + ")"); sender.sendMessage("Data Pack Biome: " + INMS.get().getTrueBiomeBaseKey(p.getLocation()) + " (ID: " + INMS.get().getTrueBiomeBaseId(INMS.get().getTrueBiomeBase(p.getLocation())) + ")");
} } catch (Throwable ex) {
catch(Throwable ex)
{
} }
} }
} }
} } else {
else
{
sender.sendMessage("Players only."); sender.sendMessage("Players only.");
} }
@@ -91,8 +58,7 @@ public class CommandIrisWhatBiome extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }
@@ -1,16 +1,13 @@
package com.volmit.iris.manager.command.what; package com.volmit.iris.manager.command.what;
import com.volmit.iris.Iris;
import com.volmit.iris.util.*; import com.volmit.iris.util.*;
import org.bukkit.FluidCollisionMode; import org.bukkit.FluidCollisionMode;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.volmit.iris.Iris; public class CommandIrisWhatBlock extends MortarCommand {
public CommandIrisWhatBlock() {
public class CommandIrisWhatBlock extends MortarCommand
{
public CommandIrisWhatBlock()
{
super("block", "l", "bl"); super("block", "l", "bl");
setDescription("Get the block data for looking."); setDescription("Get the block data for looking.");
requiresPermission(Iris.perm.studio); requiresPermission(Iris.perm.studio);
@@ -24,18 +21,13 @@ public class CommandIrisWhatBlock extends MortarCommand
} }
@Override @Override
public boolean handle(MortarSender sender, String[] args) public boolean handle(MortarSender sender, String[] args) {
{ if (sender.isPlayer()) {
if(sender.isPlayer())
{
BlockData bd; BlockData bd;
Player p = sender.player(); Player p = sender.player();
try try {
{
bd = p.getTargetBlockExact(128, FluidCollisionMode.NEVER).getBlockData(); bd = p.getTargetBlockExact(128, FluidCollisionMode.NEVER).getBlockData();
} } catch (NullPointerException e) {
catch (NullPointerException e)
{
sender.sendMessage("Please look at any block, not at the sky"); sender.sendMessage("Please look at any block, not at the sky");
bd = null; bd = null;
} }
@@ -72,10 +64,7 @@ public class CommandIrisWhatBlock extends MortarCommand
sender.sendMessage(C.YELLOW + "* Solid Block"); sender.sendMessage(C.YELLOW + "* Solid Block");
} }
} }
} } else {
else
{
sender.sendMessage("Players only."); sender.sendMessage("Players only.");
} }
@@ -83,8 +72,7 @@ public class CommandIrisWhatBlock extends MortarCommand
} }
@Override @Override
protected String getArgsUsage() protected String getArgsUsage() {
{
return ""; return "";
} }
} }

Some files were not shown because too many files have changed in this diff Show More