mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-18 14:50:57 +00:00
Cleanup SRC
This commit is contained in:
@@ -1,18 +1,15 @@
|
||||
package com.volmit.iris;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.manager.*;
|
||||
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.world.CommandLocate;
|
||||
import com.volmit.iris.manager.link.BKLink;
|
||||
import com.volmit.iris.manager.link.CitizensLink;
|
||||
import com.volmit.iris.manager.link.MultiverseCoreLink;
|
||||
import com.volmit.iris.manager.link.MythicMobsLink;
|
||||
import com.volmit.iris.nms.INMS;
|
||||
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.engine.EngineCompositeGenerator;
|
||||
import com.volmit.iris.util.*;
|
||||
@@ -21,20 +18,19 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
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.util.List;
|
||||
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 Iris instance;
|
||||
public static ProjectManager proj;
|
||||
@@ -60,20 +56,17 @@ public class Iris extends VolmitPlugin implements Listener
|
||||
@com.volmit.iris.util.Command
|
||||
public CommandIris commandIris;
|
||||
|
||||
public Iris()
|
||||
{
|
||||
public Iris() {
|
||||
instance = this;
|
||||
INMS.get();
|
||||
IO.delete(new File("iris"));
|
||||
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4;
|
||||
}
|
||||
|
||||
public static int getThreadCount()
|
||||
{
|
||||
public static int getThreadCount() {
|
||||
int tc = IrisSettings.get().getConcurrency().getThreadCount();
|
||||
|
||||
if(tc <= 0)
|
||||
{
|
||||
if (tc <= 0) {
|
||||
int p = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
return p > 16 ? 16 : p < 4 ? 4 : p;
|
||||
@@ -82,51 +75,36 @@ public class Iris extends VolmitPlugin implements Listener
|
||||
return tc;
|
||||
}
|
||||
|
||||
private static boolean doesSupport3DBiomes()
|
||||
{
|
||||
try
|
||||
{
|
||||
private static boolean doesSupport3DBiomes() {
|
||||
try {
|
||||
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
|
||||
|
||||
return v >= 15;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean doesSupportCustomModels()
|
||||
{
|
||||
try
|
||||
{
|
||||
private static boolean doesSupportCustomModels() {
|
||||
try {
|
||||
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
|
||||
|
||||
return v >= 14;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean doesSupportAwareness()
|
||||
{
|
||||
try
|
||||
{
|
||||
private static boolean doesSupportAwareness() {
|
||||
try {
|
||||
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
|
||||
|
||||
return v >= 15;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -134,25 +112,21 @@ public class Iris extends VolmitPlugin implements Listener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
@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 + ": ";
|
||||
}
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
try {
|
||||
compat = IrisCompat.configured(getDataFile("compat.json"));
|
||||
@@ -181,8 +155,7 @@ public class Iris extends VolmitPlugin implements Listener
|
||||
}
|
||||
|
||||
private void checkConfigHotload() {
|
||||
if(configWatcher.checkModified())
|
||||
{
|
||||
if (configWatcher.checkModified()) {
|
||||
IrisSettings.invalidate();
|
||||
IrisSettings.get();
|
||||
configWatcher.checkModified();
|
||||
@@ -190,22 +163,17 @@ public class Iris extends VolmitPlugin implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
if(IrisSettings.get().isStudio())
|
||||
{
|
||||
public void onDisable() {
|
||||
if (IrisSettings.get().isStudio()) {
|
||||
proj.close();
|
||||
|
||||
for(World i : Bukkit.getWorlds())
|
||||
{
|
||||
if(IrisWorlds.isIrisWorld(i))
|
||||
{
|
||||
for (World i : Bukkit.getWorlds()) {
|
||||
if (IrisWorlds.isIrisWorld(i)) {
|
||||
IrisWorlds.access(i).close();
|
||||
}
|
||||
}
|
||||
|
||||
for(GroupedExecutor i : executors)
|
||||
{
|
||||
for (GroupedExecutor i : executors) {
|
||||
i.close();
|
||||
}
|
||||
}
|
||||
@@ -217,44 +185,32 @@ public class Iris extends VolmitPlugin implements Listener
|
||||
super.onDisable();
|
||||
}
|
||||
|
||||
public static void sq(Runnable r)
|
||||
{
|
||||
synchronized(syncJobs)
|
||||
{
|
||||
public static void sq(Runnable r) {
|
||||
synchronized (syncJobs) {
|
||||
syncJobs.queue(r);
|
||||
}
|
||||
}
|
||||
|
||||
private void tickQueue()
|
||||
{
|
||||
synchronized(Iris.syncJobs)
|
||||
{
|
||||
if(!Iris.syncJobs.hasNext())
|
||||
{
|
||||
private void tickQueue() {
|
||||
synchronized (Iris.syncJobs) {
|
||||
if (!Iris.syncJobs.hasNext()) {
|
||||
return;
|
||||
}
|
||||
|
||||
long ms = M.ms();
|
||||
|
||||
while(Iris.syncJobs.hasNext() && M.ms() - ms < 25)
|
||||
{
|
||||
try
|
||||
{
|
||||
while (Iris.syncJobs.hasNext() && M.ms() - ms < 25) {
|
||||
try {
|
||||
Iris.syncJobs.next().run();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void bstats()
|
||||
{
|
||||
if(IrisSettings.get().getGeneral().isPluginMetrics())
|
||||
{
|
||||
private void bstats() {
|
||||
if (IrisSettings.get().getGeneral().isPluginMetrics()) {
|
||||
J.s(() -> {
|
||||
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");
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
|
||||
{
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||
String dimension = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||
|
||||
if(id != null && !id.isEmpty())
|
||||
{
|
||||
if (id != null && !id.isEmpty()) {
|
||||
dimension = 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);
|
||||
}
|
||||
|
||||
public static void msg(String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(instance == null)
|
||||
{
|
||||
public static void msg(String string) {
|
||||
try {
|
||||
if (instance == null) {
|
||||
System.out.println("[Iris]: " + string);
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = C.GRAY + "[" + C.GREEN + "Iris" + C.GRAY + "]: " + string;
|
||||
Bukkit.getConsoleSender().sendMessage(msg);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
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);
|
||||
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
|
||||
|
||||
if(!f.exists())
|
||||
{
|
||||
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f))
|
||||
{
|
||||
if (!f.exists()) {
|
||||
try (BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) {
|
||||
byte[] dataBuffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1)
|
||||
{
|
||||
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
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;
|
||||
}
|
||||
|
||||
public static String getNonCached(String name, String url)
|
||||
{
|
||||
public static String getNonCached(String name, String url) {
|
||||
String h = IO.hash(name + "*" + url);
|
||||
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];
|
||||
int bytesRead;
|
||||
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1)
|
||||
{
|
||||
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
|
||||
catch(IOException ignored)
|
||||
{
|
||||
} catch (IOException ignored) {
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
return IO.readAll(f);
|
||||
}
|
||||
|
||||
catch(IOException ignored)
|
||||
{
|
||||
} catch (IOException ignored) {
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static File getNonCachedFile(String name, String url)
|
||||
{
|
||||
public static File getNonCachedFile(String name, String url) {
|
||||
String h = IO.hash(name + "*" + url);
|
||||
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
|
||||
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];
|
||||
int bytesRead;
|
||||
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1)
|
||||
{
|
||||
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
public static void warn(String string)
|
||||
{
|
||||
public static void warn(String string) {
|
||||
msg(C.YELLOW + string);
|
||||
}
|
||||
|
||||
public static void error(String string)
|
||||
{
|
||||
public static void error(String string) {
|
||||
msg(C.RED + string);
|
||||
}
|
||||
|
||||
public static void verbose(String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(IrisSettings.get().getGeneral().isVerbose())
|
||||
{
|
||||
public static void verbose(String string) {
|
||||
try {
|
||||
if (IrisSettings.get().getGeneral().isVerbose()) {
|
||||
msg(C.GRAY + string);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
msg(C.GRAY + string);
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
msg(C.GRAY + string);
|
||||
}
|
||||
}
|
||||
|
||||
public static void success(String string)
|
||||
{
|
||||
public static void success(String string) {
|
||||
msg(C.GREEN + string);
|
||||
}
|
||||
|
||||
public static void info(String string)
|
||||
{
|
||||
public static void info(String string) {
|
||||
msg(C.WHITE + string);
|
||||
}
|
||||
|
||||
public void hit(long hits2)
|
||||
{
|
||||
public void hit(long hits2) {
|
||||
board.hits.put(hits2);
|
||||
}
|
||||
|
||||
public void splash()
|
||||
{
|
||||
if(!IrisSettings.get().getGeneral().isSplashLogoStartup())
|
||||
{
|
||||
public void splash() {
|
||||
if (!IrisSettings.get().getGeneral().isSplashLogoStartup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -469,60 +377,47 @@ public class Iris extends VolmitPlugin implements Listener
|
||||
Iris.info("Server type & version: " + Bukkit.getVersion());
|
||||
Iris.info("Bukkit version: " + Bukkit.getBukkitVersion());
|
||||
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];
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
if(!doesSupportAwareness())
|
||||
{
|
||||
if (!doesSupportAwareness()) {
|
||||
Iris.verbose("* This version of minecraft does not support entity awareness.");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void later(NastyRunnable object)
|
||||
{
|
||||
public static void later(NastyRunnable object) {
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () ->
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
object.run();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, RNG.r.i(100, 1200));
|
||||
}
|
||||
|
||||
public static int jobCount()
|
||||
{
|
||||
public static int jobCount() {
|
||||
return syncJobs.size();
|
||||
}
|
||||
|
||||
public static void clearQueues()
|
||||
{
|
||||
synchronized(syncJobs)
|
||||
{
|
||||
public static void clearQueues() {
|
||||
synchronized (syncJobs) {
|
||||
syncJobs.clear();
|
||||
}
|
||||
}
|
||||
@@ -533,8 +428,11 @@ public class Iris extends VolmitPlugin implements Listener
|
||||
version = version.substring(2, 3);
|
||||
} else {
|
||||
int dot = version.indexOf(".");
|
||||
if(dot != -1) { version = version.substring(0, dot); }
|
||||
} return Integer.parseInt(version);
|
||||
if (dot != -1) {
|
||||
version = version.substring(0, dot);
|
||||
}
|
||||
}
|
||||
return Integer.parseInt(version);
|
||||
}
|
||||
|
||||
public boolean isMCA() {
|
||||
|
||||
@@ -8,8 +8,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@Data
|
||||
public class IrisSettings
|
||||
{
|
||||
public class IrisSettings {
|
||||
public static transient IrisSettings settings;
|
||||
private IrisSettingsCache cache = new IrisSettingsCache();
|
||||
private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency();
|
||||
@@ -35,22 +34,19 @@ public class IrisSettings
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsCache
|
||||
{
|
||||
public static class IrisSettingsCache {
|
||||
@DontObfuscate
|
||||
public int streamingCacheSize = 8192;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsConcurrency
|
||||
{
|
||||
public static class IrisSettingsConcurrency {
|
||||
@DontObfuscate
|
||||
public int threadCount = -1;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsParallax
|
||||
{
|
||||
public static class IrisSettingsParallax {
|
||||
@DontObfuscate
|
||||
public int parallaxRegionEvictionMS = 15000;
|
||||
|
||||
@@ -59,8 +55,7 @@ public class IrisSettings
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsGeneral
|
||||
{
|
||||
public static class IrisSettingsGeneral {
|
||||
|
||||
@DontObfuscate
|
||||
public boolean commandSounds = true;
|
||||
@@ -82,8 +77,7 @@ public class IrisSettings
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsGUI
|
||||
{
|
||||
public static class IrisSettingsGUI {
|
||||
@DontObfuscate
|
||||
public boolean useServerLaunchedGuis = true;
|
||||
|
||||
@@ -95,8 +89,7 @@ public class IrisSettings
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsGenerator
|
||||
{
|
||||
public static class IrisSettingsGenerator {
|
||||
@DontObfuscate
|
||||
public String defaultWorldType = "overworld";
|
||||
|
||||
@@ -118,8 +111,7 @@ public class IrisSettings
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsStudio
|
||||
{
|
||||
public static class IrisSettingsStudio {
|
||||
|
||||
@DontObfuscate
|
||||
public boolean studio = true;
|
||||
@@ -131,84 +123,59 @@ public class IrisSettings
|
||||
public boolean disableTimeAndWeather = true;
|
||||
}
|
||||
|
||||
public static IrisSettings get()
|
||||
{
|
||||
if(settings != null)
|
||||
{
|
||||
public static IrisSettings get() {
|
||||
if (settings != null) {
|
||||
return settings;
|
||||
}
|
||||
|
||||
IrisSettings defaults = new IrisSettings();
|
||||
JSONObject def = new JSONObject(new Gson().toJson(defaults));
|
||||
if(settings == null)
|
||||
{
|
||||
if (settings == null) {
|
||||
settings = new IrisSettings();
|
||||
|
||||
File s = Iris.instance.getDataFile("settings.json");
|
||||
|
||||
if(!s.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!s.exists()) {
|
||||
try {
|
||||
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
} catch (JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
} else {
|
||||
try {
|
||||
String ss = IO.readAll(s);
|
||||
settings = new Gson().fromJson(ss, IrisSettings.class);
|
||||
|
||||
J.a(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
JSONObject j = new JSONObject(ss);
|
||||
boolean u = false;
|
||||
for(String i : def.keySet())
|
||||
{
|
||||
if(!j.has(i))
|
||||
{
|
||||
for (String i : def.keySet()) {
|
||||
if (!j.has(i)) {
|
||||
u = true;
|
||||
j.put(i, def.get(i));
|
||||
Iris.warn("Adding new config key: " + i);
|
||||
}
|
||||
}
|
||||
|
||||
for(String i : new KSet<>(j.keySet()))
|
||||
{
|
||||
if(!def.has(i))
|
||||
{
|
||||
for (String i : new KSet<>(j.keySet())) {
|
||||
if (!def.has(i)) {
|
||||
u = true;
|
||||
j.remove(i);
|
||||
Iris.warn("Removing unused config key: " + i);
|
||||
}
|
||||
}
|
||||
|
||||
if(u)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (u) {
|
||||
try {
|
||||
IO.writeAll(s, j.toString(4));
|
||||
Iris.info("Updated Configuration Files");
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ee)
|
||||
{
|
||||
} catch (Throwable ee) {
|
||||
Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage());
|
||||
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.warn("Attempting to fix configuration while retaining valid in-memory settings...");
|
||||
|
||||
@@ -238,15 +202,10 @@ public class IrisSettings
|
||||
}
|
||||
}
|
||||
|
||||
if(!s.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!s.exists()) {
|
||||
try {
|
||||
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
} catch (JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -255,10 +214,8 @@ public class IrisSettings
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static void invalidate()
|
||||
{
|
||||
synchronized(settings)
|
||||
{
|
||||
public static void invalidate() {
|
||||
synchronized (settings) {
|
||||
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.stream.ProceduralStream;
|
||||
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 org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@Data
|
||||
public class IrisComplex implements DataProvider
|
||||
{
|
||||
public class IrisComplex implements DataProvider {
|
||||
private RNG rng;
|
||||
private double fluidHeight;
|
||||
private IrisDataManager data;
|
||||
@@ -55,10 +57,8 @@ public class IrisComplex implements DataProvider
|
||||
private ProceduralStream<BlockData> fluidStream;
|
||||
private IrisBiome focus;
|
||||
|
||||
public ProceduralStream<IrisBiome> getBiomeStream(InferredType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
public ProceduralStream<IrisBiome> getBiomeStream(InferredType type) {
|
||||
switch (type) {
|
||||
case CAVE:
|
||||
return caveBiomeStream;
|
||||
case LAND:
|
||||
@@ -77,8 +77,7 @@ public class IrisComplex implements DataProvider
|
||||
return null;
|
||||
}
|
||||
|
||||
public IrisComplex(Engine engine)
|
||||
{
|
||||
public IrisComplex(Engine engine) {
|
||||
int cacheSize = IrisSettings.get().getCache().getStreamingCacheSize();
|
||||
this.rng = new RNG(engine.getWorld().getSeed());
|
||||
this.data = engine.getData();
|
||||
@@ -115,8 +114,7 @@ public class IrisComplex implements DataProvider
|
||||
.selectRarity(r.getCaveBiomes())
|
||||
.onNull("")
|
||||
.convertCached((s) -> {
|
||||
if(s.isEmpty())
|
||||
{
|
||||
if (s.isEmpty()) {
|
||||
return new IrisBiome();
|
||||
}
|
||||
|
||||
@@ -197,31 +195,24 @@ public class IrisComplex implements DataProvider
|
||||
int heightf = (int) Math.round(getHeightStream().get(rx, rz));
|
||||
int m = heightf;
|
||||
|
||||
if(engine.getDimension().isCarving())
|
||||
{
|
||||
if(engine.getDimension().isCarved(rx, m, rz, ((IrisTerrainActuator)engine.getFramework().getTerrainActuator()).getRng(), heightf))
|
||||
{
|
||||
if (engine.getDimension().isCarving()) {
|
||||
if (engine.getDimension().isCarved(rx, m, rz, ((IrisTerrainActuator) engine.getFramework().getTerrainActuator()).getRng(), heightf)) {
|
||||
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--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(engine.getDimension().isCaves())
|
||||
{
|
||||
if (engine.getDimension().isCaves()) {
|
||||
KList<CaveResult> caves = ((IrisCaveModifier) engine.getFramework().getCaveModifier()).genCaves(rx, rz, 0, 0, null);
|
||||
boolean again = true;
|
||||
|
||||
while(again)
|
||||
{
|
||||
while (again) {
|
||||
again = false;
|
||||
for(CaveResult i : caves)
|
||||
{
|
||||
if(i.getCeiling() > m && i.getFloor() < m)
|
||||
{
|
||||
for (CaveResult i : caves) {
|
||||
if (i.getCeiling() > m && i.getFloor() < m) {
|
||||
m = i.getFloor();
|
||||
again = true;
|
||||
}
|
||||
@@ -233,11 +224,10 @@ public class IrisComplex implements DataProvider
|
||||
}, Interpolated.INT).cache2D(cacheSize);
|
||||
//@done
|
||||
}
|
||||
|
||||
private IrisRegion findRegion(IrisBiome focus, Engine engine) {
|
||||
for(IrisRegion i : engine.getDimension().getAllRegions(engine))
|
||||
{
|
||||
if(i.getAllBiomeIds().contains(focus.getLoadKey()))
|
||||
{
|
||||
for (IrisRegion i : engine.getDimension().getAllRegions(engine)) {
|
||||
if (i.getAllBiomeIds().contains(focus.getLoadKey())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -245,21 +235,17 @@ public class IrisComplex implements DataProvider
|
||||
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);
|
||||
|
||||
for(IrisDecorator i : b.getDecorators())
|
||||
{
|
||||
if(!i.getPartOf().equals(part))
|
||||
{
|
||||
for (IrisDecorator i : b.getDecorators()) {
|
||||
if (!i.getPartOf().equals(part)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData block = i.getBlockData(b, rngc, x, z, data);
|
||||
|
||||
if(block != null)
|
||||
{
|
||||
if (block != null) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -267,25 +253,20 @@ public class IrisComplex implements DataProvider
|
||||
return null;
|
||||
}
|
||||
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z)
|
||||
{
|
||||
if(b.getChildren().isEmpty())
|
||||
{
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z) {
|
||||
if (b.getChildren().isEmpty()) {
|
||||
return b;
|
||||
}
|
||||
|
||||
return implode(b, x, z, 3);
|
||||
}
|
||||
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z, int max)
|
||||
{
|
||||
if(max < 0)
|
||||
{
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z, int max) {
|
||||
if (max < 0) {
|
||||
return b;
|
||||
}
|
||||
|
||||
if(b.getChildren().isEmpty())
|
||||
{
|
||||
if (b.getChildren().isEmpty()) {
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -297,50 +278,39 @@ public class IrisComplex implements DataProvider
|
||||
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);
|
||||
|
||||
if(height >= fluidHeight-1 && height <= fluidHeight + sh && !biome.isShore())
|
||||
{
|
||||
if (height >= fluidHeight - 1 && height <= fluidHeight + sh && !biome.isShore()) {
|
||||
return shoreBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
if(height > fluidHeight + sh && !biome.isLand())
|
||||
{
|
||||
if (height > fluidHeight + sh && !biome.isLand()) {
|
||||
return landBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
if(height < fluidHeight && !biome.isAquatic())
|
||||
{
|
||||
if (height < fluidHeight && !biome.isAquatic()) {
|
||||
return seaBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
if(height == fluidHeight && !biome.isShore())
|
||||
{
|
||||
if (height == fluidHeight && !biome.isShore()) {
|
||||
return shoreBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
for(IrisGenerator gen : generators)
|
||||
{
|
||||
for (IrisGenerator gen : generators) {
|
||||
double hi = gen.getInterpolator().interpolate(x, z, (xx, zz) ->
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
IrisBiome bx = baseBiomeStream.get(xx, zz);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -349,15 +319,11 @@ public class IrisComplex implements DataProvider
|
||||
|
||||
double lo = gen.getInterpolator().interpolate(x, z, (xx, zz) ->
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
IrisBiome bx = baseBiomeStream.get(xx, zz);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -373,12 +339,9 @@ public class IrisComplex implements DataProvider
|
||||
return Math.min(engine.getHeight(), Math.max(noise.get(), 0));
|
||||
}
|
||||
|
||||
private void registerGenerator(IrisGenerator cachedGenerator)
|
||||
{
|
||||
for(IrisGenerator i : generators)
|
||||
{
|
||||
if(i.getLoadKey().equals(cachedGenerator.getLoadKey()))
|
||||
{
|
||||
private void registerGenerator(IrisGenerator cachedGenerator) {
|
||||
for (IrisGenerator i : generators) {
|
||||
if (i.getLoadKey().equals(cachedGenerator.getLoadKey())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.volmit.iris.generator;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.scaffold.cache.AtomicCache;
|
||||
import com.volmit.iris.scaffold.engine.*;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.J;
|
||||
@@ -19,8 +18,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class IrisEngine extends BlockPopulator implements Engine
|
||||
{
|
||||
public class IrisEngine extends BlockPopulator implements Engine {
|
||||
@Getter
|
||||
private final EngineCompound compound;
|
||||
|
||||
@@ -54,8 +52,7 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
private int cacheId;
|
||||
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)");
|
||||
metrics = new EngineMetrics(32);
|
||||
this.target = target;
|
||||
@@ -72,8 +69,7 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
public void close() {
|
||||
J.car(art);
|
||||
closed = true;
|
||||
getWorldManager().close();
|
||||
@@ -102,8 +98,7 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
|
||||
@Override
|
||||
public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<Biome> vbiomes) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
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);
|
||||
@@ -116,18 +111,14 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
getFramework().getEngineParallax().insertParallax(x, z, blocks);
|
||||
getFramework().getDepositModifier().modify(x, z, blocks);
|
||||
getMetrics().getTotal().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
fail("Failed to generate " + x + ", " + z, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisBiome getFocus() {
|
||||
if(getDimension().getFocus() == null || getDimension().getFocus().trim().isEmpty())
|
||||
{
|
||||
if (getDimension().getFocus() == null || getDimension().getFocus().trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -135,8 +126,7 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
}
|
||||
|
||||
@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);
|
||||
updateChunk(c);
|
||||
placeTiles(c);
|
||||
|
||||
@@ -14,10 +14,6 @@ import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.*;
|
||||
import lombok.Getter;
|
||||
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.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@@ -27,14 +23,7 @@ import org.bukkit.event.world.WorldSaveEvent;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
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.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class IrisEngineCompound implements EngineCompound {
|
||||
@Getter
|
||||
@@ -65,8 +54,7 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
@Setter
|
||||
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);
|
||||
this.rootDimension = rootDimension;
|
||||
Iris.info("Initializing Engine Composite for " + world.getName());
|
||||
@@ -78,35 +66,28 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
saveEngineMetadata();
|
||||
populators = new KList<>();
|
||||
|
||||
if(rootDimension.getDimensionalComposite().isEmpty())
|
||||
{
|
||||
if (rootDimension.getDimensionalComposite().isEmpty()) {
|
||||
burster = null;
|
||||
// TODO: WARNING HEIGHT
|
||||
engines = new Engine[]{new IrisEngine(new EngineTarget(world, rootDimension, data, 256, maximumThreads), this, 0)};
|
||||
defaultEngine = engines[0];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
double totalWeight = 0D;
|
||||
engines = new Engine[rootDimension.getDimensionalComposite().size()];
|
||||
burster = engines.length > 1 ? new MultiBurst(engines.length) : null;
|
||||
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!");
|
||||
}
|
||||
|
||||
for(IrisDimensionIndex i : rootDimension.getDimensionalComposite())
|
||||
{
|
||||
for (IrisDimensionIndex i : rootDimension.getDimensionalComposite()) {
|
||||
totalWeight += i.getWeight();
|
||||
}
|
||||
|
||||
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);
|
||||
IrisDimension dimension = data.getDimensionLoader().load(index.getDimension());
|
||||
// TODO: WARNING HEIGHT
|
||||
@@ -114,22 +95,18 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
engines[i].setMinHeight(buf);
|
||||
buf += engines[i].getHeight();
|
||||
|
||||
if(index.isPrimary())
|
||||
{
|
||||
if (index.isPrimary()) {
|
||||
defaultEngine = engines[i];
|
||||
}
|
||||
}
|
||||
|
||||
if(defaultEngine == null)
|
||||
{
|
||||
if (defaultEngine == null) {
|
||||
defaultEngine = engines[0];
|
||||
}
|
||||
}
|
||||
|
||||
for(Engine i : engines)
|
||||
{
|
||||
if(i instanceof BlockPopulator)
|
||||
{
|
||||
for (Engine i : engines) {
|
||||
if (i instanceof BlockPopulator) {
|
||||
populators.add((BlockPopulator) i);
|
||||
}
|
||||
}
|
||||
@@ -137,40 +114,33 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
Iris.instance.registerListener(this);
|
||||
}
|
||||
|
||||
public List<IrisPosition> getStrongholdPositions()
|
||||
{
|
||||
public List<IrisPosition> getStrongholdPositions() {
|
||||
return engineMetadata.getStrongholdPositions();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(WorldSaveEvent e)
|
||||
{
|
||||
if(world != null &&e.getWorld().equals(world))
|
||||
{
|
||||
public void on(WorldSaveEvent e) {
|
||||
if (world != null && e.getWorld().equals(world)) {
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
public void printMetrics(CommandSender sender)
|
||||
{
|
||||
public void printMetrics(CommandSender sender) {
|
||||
KMap<String, Double> totals = new KMap<>();
|
||||
KMap<String, Double> weights = new KMap<>();
|
||||
double masterWallClock = wallClock.getAverage();
|
||||
|
||||
for(int i = 0; i < getSize(); i++)
|
||||
{
|
||||
for (int i = 0; i < getSize(); i++) {
|
||||
Engine e = getEngine(i);
|
||||
KMap<String, Double> timings = e.getMetrics().pull();
|
||||
double totalWeight = 0;
|
||||
double wallClock = e.getMetrics().getTotal().getAverage();
|
||||
|
||||
for(double j : timings.values())
|
||||
{
|
||||
for (double j : timings.values()) {
|
||||
totalWeight += j;
|
||||
}
|
||||
|
||||
for(String j : timings.k())
|
||||
{
|
||||
for (String j : timings.k()) {
|
||||
weights.put(e.getName() + "[" + e.getIndex() + "]." + j, (wallClock / totalWeight) * timings.get(j));
|
||||
}
|
||||
|
||||
@@ -179,39 +149,33 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
|
||||
double mtotals = 0;
|
||||
|
||||
for(double i : totals.values())
|
||||
{
|
||||
for (double i : totals.values()) {
|
||||
mtotals += i;
|
||||
}
|
||||
|
||||
for(String i : totals.k())
|
||||
{
|
||||
for (String i : totals.k()) {
|
||||
totals.put(i, (masterWallClock / mtotals) * totals.get(i));
|
||||
}
|
||||
|
||||
double v = 0;
|
||||
|
||||
for(double i : weights.values())
|
||||
{
|
||||
for (double i : weights.values()) {
|
||||
v += i;
|
||||
}
|
||||
|
||||
for(String i : weights.k())
|
||||
{
|
||||
for (String i : weights.k()) {
|
||||
weights.put(i, weights.get(i) / v);
|
||||
}
|
||||
|
||||
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("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 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;
|
||||
@@ -225,30 +189,23 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
}
|
||||
|
||||
@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();
|
||||
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);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
for(i = 0; i < engines.length; i++)
|
||||
{
|
||||
for (i = 0; i < engines.length; i++) {
|
||||
Engine engine = engines[i];
|
||||
int doffset = offset;
|
||||
int height = engine.getTarget().getHeight();
|
||||
Hunk<BlockData> cblock = Hunk.newArrayHunk(16, height, 16);
|
||||
Hunk<Biome> cbiome = Hunk.newArrayHunk(16, height, 16);
|
||||
|
||||
if(engine.getTarget().isInverted())
|
||||
{
|
||||
if (engine.getTarget().isInverted()) {
|
||||
cblock = cblock.invertY();
|
||||
cbiome = cbiome.invertY();
|
||||
}
|
||||
@@ -301,8 +258,7 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
|
||||
@Override
|
||||
public void hotload() {
|
||||
for(int i = 0; i < getSize(); i++)
|
||||
{
|
||||
for (int i = 0; i < getSize(); i++) {
|
||||
getEngine(i).hotload();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ import java.util.UUID;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
public class IrisEngineEffects extends EngineAssignedComponent implements EngineEffects {
|
||||
private KMap<UUID, EnginePlayer> players;
|
||||
private Semaphore limit;
|
||||
private final KMap<UUID, EnginePlayer> players;
|
||||
private final Semaphore limit;
|
||||
|
||||
public IrisEngineEffects(Engine engine) {
|
||||
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
|
||||
|
||||
for(Player i : pr)
|
||||
{
|
||||
for (Player i : pr) {
|
||||
Location l = i.getLocation();
|
||||
boolean pcc = players.containsKey(i.getUniqueId());
|
||||
if(getEngine().contains(l))
|
||||
{
|
||||
if(!pcc)
|
||||
{
|
||||
if (getEngine().contains(l)) {
|
||||
if (!pcc) {
|
||||
players.put(i.getUniqueId(), new EnginePlayer(getEngine(), i));
|
||||
}
|
||||
}
|
||||
|
||||
else if(pcc)
|
||||
{
|
||||
} else if (pcc) {
|
||||
players.remove(i.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
for(UUID i : players.k())
|
||||
{
|
||||
if(!pr.contains(players.get(i).getPlayer()))
|
||||
{
|
||||
for (UUID i : players.k()) {
|
||||
if (!pr.contains(players.get(i).getPlayer())) {
|
||||
players.remove(i);
|
||||
}
|
||||
}
|
||||
@@ -59,17 +51,14 @@ public class IrisEngineEffects extends EngineAssignedComponent implements Engine
|
||||
|
||||
@Override
|
||||
public void tickRandomPlayer() {
|
||||
if(limit.tryAcquire())
|
||||
{
|
||||
if(M.r(0.02))
|
||||
{
|
||||
if (limit.tryAcquire()) {
|
||||
if (M.r(0.02)) {
|
||||
updatePlayerMap();
|
||||
limit.release();
|
||||
return;
|
||||
}
|
||||
|
||||
if(players.isEmpty())
|
||||
{
|
||||
if (players.isEmpty()) {
|
||||
limit.release();
|
||||
return;
|
||||
}
|
||||
@@ -78,8 +67,7 @@ public class IrisEngineEffects extends EngineAssignedComponent implements Engine
|
||||
int max = players.size();
|
||||
PrecisionStopwatch p = new PrecisionStopwatch();
|
||||
|
||||
while(max-- > 0 && M.ms() - p.getMilliseconds() < limitms)
|
||||
{
|
||||
while (max-- > 0 && M.ms() - p.getMilliseconds() < limitms) {
|
||||
players.v().getRandom().tick();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,7 @@ public class IrisEngineFramework implements EngineFramework {
|
||||
private final AtomicBoolean cleaning;
|
||||
private final ChronoLatch cleanLatch;
|
||||
|
||||
public IrisEngineFramework(Engine engine)
|
||||
{
|
||||
public IrisEngineFramework(Engine engine) {
|
||||
this.engine = engine;
|
||||
this.complex = new IrisComplex(getEngine());
|
||||
this.engineParallax = new IrisEngineParallax(getEngine());
|
||||
@@ -70,27 +69,21 @@ public class IrisEngineFramework implements EngineFramework {
|
||||
|
||||
@Override
|
||||
public synchronized void recycle() {
|
||||
if(!cleanLatch.flip())
|
||||
{
|
||||
if (!cleanLatch.flip()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cleaning.get())
|
||||
{
|
||||
if (cleaning.get()) {
|
||||
cleanLatch.flipDown();
|
||||
return;
|
||||
}
|
||||
|
||||
cleaning.set(true);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
getEngine().getParallax().cleanup();
|
||||
getData().getObjectLoader().clean();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
Iris.error("Cleanup failed!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -99,8 +92,7 @@ public class IrisEngineFramework implements EngineFramework {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
public void close() {
|
||||
getEngineParallax().close();
|
||||
getTerrainActuator().close();
|
||||
getDecorantActuator().close();
|
||||
|
||||
@@ -11,8 +11,7 @@ public class IrisEngineParallax implements EngineParallaxManager {
|
||||
@Getter
|
||||
private final int parallaxSize;
|
||||
|
||||
public IrisEngineParallax(Engine engine)
|
||||
{
|
||||
public IrisEngineParallax(Engine engine) {
|
||||
this.engine = engine;
|
||||
parallaxSize = computeParallaxSize();
|
||||
}
|
||||
|
||||
@@ -37,8 +37,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
RNG rng = new RNG(Cache.key(c));
|
||||
|
||||
getEngine().getParallaxAccess().getEntitiesR(c.getX(), c.getZ()).iterateSync((x, y, z, e) -> {
|
||||
if(e != null)
|
||||
{
|
||||
if (e != null) {
|
||||
IrisEntity en = getData().getEntityLoader().load(e);
|
||||
|
||||
if (en != null) {
|
||||
@@ -61,17 +60,13 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntitySpawn(EntitySpawnEvent e)
|
||||
{
|
||||
if(getTarget().getWorld() == null || !getTarget().getWorld().equals(e.getEntity().getWorld()))
|
||||
{
|
||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||
if (getTarget().getWorld() == null || !getTarget().getWorld().equals(e.getEntity().getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if(!IrisSettings.get().getGenerator().isSystemEntitySpawnOverrides())
|
||||
{
|
||||
try {
|
||||
if (!IrisSettings.get().getGenerator().isSystemEntitySpawnOverrides()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,14 +76,12 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
J.a(() ->
|
||||
{
|
||||
if(spawnable)
|
||||
{
|
||||
if (spawnable) {
|
||||
IrisDimension dim = getDimension();
|
||||
IrisRegion region = getEngine().getRegion(x, z);
|
||||
IrisBiome above = getEngine().getSurfaceBiome(x, z);
|
||||
IrisBiome bbelow = getEngine().getBiome(x, y, z);
|
||||
if(above.getLoadKey().equals(bbelow.getLoadKey()))
|
||||
{
|
||||
if (above.getLoadKey().equals(bbelow.getLoadKey())) {
|
||||
bbelow = null;
|
||||
}
|
||||
|
||||
@@ -96,54 +89,40 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
J.s(() ->
|
||||
{
|
||||
if(below != null)
|
||||
{
|
||||
if(trySpawn(below.getEntitySpawnOverrides(), e))
|
||||
{
|
||||
if (below != null) {
|
||||
if (trySpawn(below.getEntitySpawnOverrides(), e)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(trySpawn(above.getEntitySpawnOverrides(), e))
|
||||
{
|
||||
if (trySpawn(above.getEntitySpawnOverrides(), e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(trySpawn(region.getEntitySpawnOverrides(), e))
|
||||
{
|
||||
if (trySpawn(region.getEntitySpawnOverrides(), e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(trySpawn(dim.getEntitySpawnOverrides(), e))
|
||||
{
|
||||
if (trySpawn(dim.getEntitySpawnOverrides(), e)) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
catch(Throwable xe)
|
||||
{
|
||||
} catch (Throwable xe) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private boolean trySpawn(KList<IrisEntitySpawnOverride> s, EntitySpawnEvent e)
|
||||
{
|
||||
for(IrisEntitySpawnOverride i : s)
|
||||
{
|
||||
private boolean trySpawn(KList<IrisEntitySpawnOverride> s, EntitySpawnEvent e) {
|
||||
for (IrisEntitySpawnOverride i : s) {
|
||||
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.getEntity().remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
spawnable = true;
|
||||
}
|
||||
}
|
||||
@@ -151,10 +130,8 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void trySpawn(KList<IrisEntityInitialSpawn> s, Chunk c, RNG rng)
|
||||
{
|
||||
for(IrisEntityInitialSpawn i : s)
|
||||
{
|
||||
private void trySpawn(KList<IrisEntityInitialSpawn> s, Chunk c, RNG rng) {
|
||||
for (IrisEntityInitialSpawn i : s) {
|
||||
i.spawn(getEngine(), c, rng);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
public class IrisBiomeActuator extends EngineAssignedActuator<Biome>
|
||||
{
|
||||
public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
|
||||
public IrisBiomeActuator(Engine engine) {
|
||||
super(engine, "Biome");
|
||||
}
|
||||
@@ -21,17 +20,14 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome>
|
||||
int zf, hh;
|
||||
BurstExecutor burst = MultiBurst.burst.burst(h.getWidth() * h.getDepth());
|
||||
|
||||
for(int xf = 0; xf < h.getWidth(); xf++)
|
||||
{
|
||||
for(zf = 0; zf < h.getDepth(); zf++)
|
||||
{
|
||||
for (int xf = 0; xf < h.getWidth(); xf++) {
|
||||
for (zf = 0; zf < h.getDepth(); zf++) {
|
||||
int xxf = xf;
|
||||
int zzf = zf;
|
||||
|
||||
burst.queue(() -> {
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
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.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.EngineAssignedActuator;
|
||||
import com.volmit.iris.scaffold.engine.EngineDecorator;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
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 final RNG rng;
|
||||
@Getter
|
||||
@@ -47,8 +42,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
|
||||
|
||||
@Override
|
||||
public void onActuate(int x, int z, Hunk<BlockData> output) {
|
||||
if(!getEngine().getDimension().isDecorate())
|
||||
{
|
||||
if (!getEngine().getDimension().isDecorate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -57,10 +51,8 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
|
||||
int j, realX, realZ, height;
|
||||
IrisBiome biome, cave;
|
||||
|
||||
for(int i = 0; i < output.getWidth(); i++)
|
||||
{
|
||||
for(j = 0; j < output.getDepth(); j++)
|
||||
{
|
||||
for (int i = 0; i < output.getWidth(); i++) {
|
||||
for (j = 0; j < output.getDepth(); j++) {
|
||||
boolean solid;
|
||||
int emptyFor = 0;
|
||||
int lastSolid = 0;
|
||||
@@ -70,49 +62,38 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
|
||||
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
|
||||
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;
|
||||
}
|
||||
|
||||
if(height == getDimension().getFluidHeight())
|
||||
{
|
||||
if (height == getDimension().getFluidHeight()) {
|
||||
getShoreLineDecorator().decorate(i, j,
|
||||
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)),
|
||||
output, biome, height, getEngine().getHeight() - height);
|
||||
}
|
||||
else if (height == getDimension().getFluidHeight() + 1)
|
||||
{
|
||||
} else if (height == getDimension().getFluidHeight() + 1) {
|
||||
getSeaSurfaceDecorator().decorate(i, j,
|
||||
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)),
|
||||
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());
|
||||
}
|
||||
|
||||
getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height);
|
||||
|
||||
if(cave != null && cave.getDecorators().isNotEmpty())
|
||||
{
|
||||
for(int k = height; k > 0; k--)
|
||||
{
|
||||
if (cave != null && cave.getDecorators().isNotEmpty()) {
|
||||
for (int k = height; k > 0; k--) {
|
||||
solid = PREDICATE_SOLID.test(output.get(i, k, j));
|
||||
|
||||
if(solid)
|
||||
{
|
||||
if (solid) {
|
||||
if (emptyFor > 0) {
|
||||
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor);
|
||||
getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor);
|
||||
emptyFor = 0;
|
||||
}
|
||||
lastSolid = k;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
emptyFor++;
|
||||
}
|
||||
}
|
||||
@@ -123,8 +104,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
|
||||
getEngine().getMetrics().getDecoration().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
private boolean shouldRayDecorate()
|
||||
{
|
||||
private boolean shouldRayDecorate() {
|
||||
return getEngine().getDimension().isCarving() || getEngine().getDimension().isCaves() || getEngine().getDimension().isRavines();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.volmit.iris.generator.actuator;
|
||||
|
||||
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.EngineAssignedActuator;
|
||||
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 org.bukkit.Material;
|
||||
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 BEDROCK = Material.BEDROCK.createBlockData();
|
||||
private static final BlockData CAVE_AIR = Material.CAVE_AIR.createBlockData();
|
||||
@@ -37,56 +36,46 @@ public class IrisTerrainActuator extends EngineAssignedActuator<BlockData>
|
||||
IrisBiome biome;
|
||||
KList<BlockData> blocks, fblocks;
|
||||
|
||||
for(int xf = 0; xf < h.getWidth(); xf++)
|
||||
{
|
||||
for(zf = 0; zf < h.getDepth(); zf++)
|
||||
{
|
||||
for (int xf = 0; xf < h.getWidth(); xf++) {
|
||||
for (zf = 0; zf < h.getDepth(); zf++) {
|
||||
realX = (int) modX(xf + x);
|
||||
realZ = (int) modZ(zf + z);
|
||||
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)));
|
||||
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);
|
||||
blocks = null;
|
||||
fblocks = null;
|
||||
|
||||
if(hf < b)
|
||||
{
|
||||
if (hf < b) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i = hf; i >= b; i--) {
|
||||
if (i >= h.getHeight())
|
||||
{
|
||||
if (i >= h.getHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i == b)
|
||||
{
|
||||
if(getDimension().isBedrock())
|
||||
{
|
||||
if (i == b) {
|
||||
if (getDimension().isBedrock()) {
|
||||
h.set(xf, i, zf, BEDROCK);
|
||||
lastBedrock = i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(carving && getDimension().isCarved(realX, i, realZ, rng, he))
|
||||
{
|
||||
if (carving && getDimension().isCarved(realX, i, realZ, rng, he)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i > he && i <= hf)
|
||||
{
|
||||
if (i > he && i <= hf) {
|
||||
fdepth = hf - i;
|
||||
|
||||
if(fblocks == null)
|
||||
{
|
||||
if (fblocks == null) {
|
||||
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));
|
||||
continue;
|
||||
}
|
||||
@@ -95,16 +84,13 @@ public class IrisTerrainActuator extends EngineAssignedActuator<BlockData>
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i <= he)
|
||||
{
|
||||
if (i <= he) {
|
||||
depth = he - i;
|
||||
if(blocks == null)
|
||||
{
|
||||
blocks = biome.generateLayers(realX, realZ, rng, (int)he, (int)he, getData(), getComplex());
|
||||
if (blocks == null) {
|
||||
blocks = biome.generateLayers(realX, realZ, rng, he, he, getData(), getComplex());
|
||||
}
|
||||
|
||||
if(blocks.hasIndex(depth))
|
||||
{
|
||||
if (blocks.hasIndex(depth)) {
|
||||
h.set(xf, i, zf, blocks.get(depth));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@ import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class IrisCeilingDecorator extends IrisEngineDecorator
|
||||
{
|
||||
public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
public IrisCeilingDecorator(Engine engine) {
|
||||
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) {
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
if(decorator != null)
|
||||
{
|
||||
if(!decorator.isStacking())
|
||||
{
|
||||
if(height >= 0 || height < getEngine().getHeight())
|
||||
{
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (height >= 0 || height < getEngine().getHeight()) {
|
||||
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());
|
||||
stack = Math.min(max + 1, stack);
|
||||
|
||||
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
|
||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
||||
|
||||
for(int i = 0; i < stack; i++)
|
||||
{
|
||||
if(height - i < 0 || height - i > getEngine().getHeight())
|
||||
{
|
||||
for (int i = 0; i < stack; i++) {
|
||||
if (height - i < 0 || height - i > getEngine().getHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import com.volmit.iris.object.DecorationPart;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisDecorator;
|
||||
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.EngineAssignedComponent;
|
||||
import com.volmit.iris.scaffold.engine.EngineDecorator;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import lombok.Getter;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
protected IrisDecorator getDecorator(IrisBiome biome, double realX, double realZ)
|
||||
{
|
||||
protected IrisDecorator getDecorator(IrisBiome biome, double realX, double realZ) {
|
||||
KList<IrisDecorator> v = new KList<>();
|
||||
RNG rng = new RNG(Cache.key((int) realX, (int) realZ));
|
||||
|
||||
for(IrisDecorator i : biome.getDecorators())
|
||||
{
|
||||
try
|
||||
{
|
||||
if(i.getPartOf().equals(part) && i.getBlockData(biome, this.rng, realX, realZ, getData()) != null)
|
||||
{
|
||||
for (IrisDecorator i : biome.getDecorators()) {
|
||||
try {
|
||||
if (i.getPartOf().equals(part) && i.getBlockData(biome, this.rng, realX, realZ, getData()) != null) {
|
||||
v.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
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 org.bukkit.block.data.BlockData;
|
||||
|
||||
public class IrisSeaFloorDecorator extends IrisEngineDecorator
|
||||
{
|
||||
public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
public IrisSeaFloorDecorator(Engine engine) {
|
||||
super(engine, "Sea Floor", DecorationPart.SEA_FLOOR);
|
||||
}
|
||||
@@ -20,32 +19,24 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator
|
||||
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
if(decorator != null)
|
||||
{
|
||||
if(!decorator.isStacking())
|
||||
{
|
||||
if(height >= 0 || height < getEngine().getHeight())
|
||||
{
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (height >= 0 || height < getEngine().getHeight()) {
|
||||
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());
|
||||
stack = Math.min(stack, getDimension().getFluidHeight() - height + 2);
|
||||
|
||||
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
|
||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
||||
|
||||
for(int i = 0; i < stack; i++)
|
||||
{
|
||||
if(height - i < 0 || height - i > getEngine().getHeight())
|
||||
{
|
||||
for (int i = 0; i < stack; i++) {
|
||||
if (height - i < 0 || height - i > getEngine().getHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(height+i > getDimension().getFluidHeight())
|
||||
{
|
||||
if (height + i > getDimension().getFluidHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,7 @@ import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class IrisSeaSurfaceDecorator extends IrisEngineDecorator
|
||||
{
|
||||
public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
public IrisSeaSurfaceDecorator(Engine engine) {
|
||||
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) {
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
if(decorator != null)
|
||||
{
|
||||
if(!decorator.isStacking())
|
||||
{
|
||||
if(height >= 0 || height < getEngine().getHeight())
|
||||
{
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (height >= 0 || height < getEngine().getHeight()) {
|
||||
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());
|
||||
|
||||
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
|
||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
||||
for(int i = 0; i < stack; i++)
|
||||
{
|
||||
if(height - i < 0 || height - i > getEngine().getHeight())
|
||||
{
|
||||
for (int i = 0; i < stack; i++) {
|
||||
if (height - i < 0 || height - i > getEngine().getHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,7 @@ import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class IrisShoreLineDecorator extends IrisEngineDecorator
|
||||
{
|
||||
public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
public IrisShoreLineDecorator(Engine engine) {
|
||||
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, realZ1)) < getComplex().getFluidHeight() ||
|
||||
Math.round(getComplex().getHeightStream().get(realX, realZ_1)) < getComplex().getFluidHeight()
|
||||
)
|
||||
{
|
||||
) {
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
if(decorator != null)
|
||||
{
|
||||
if(!decorator.isStacking())
|
||||
{
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
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());
|
||||
|
||||
BlockData top = decorator.getBlockDataForTop(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);
|
||||
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.BlockData;
|
||||
|
||||
public class IrisSurfaceDecorator extends IrisEngineDecorator
|
||||
{
|
||||
public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
public IrisSurfaceDecorator(Engine engine) {
|
||||
super(engine, "Surface", DecorationPart.NONE);
|
||||
}
|
||||
|
||||
@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) {
|
||||
if(biome.getInferredType().equals(InferredType.SHORE) && height < getDimension().getFluidHeight())
|
||||
{
|
||||
if (biome.getInferredType().equals(InferredType.SHORE) && height < getDimension().getFluidHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,31 +26,22 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator
|
||||
bdx = data.get(x, height, z);
|
||||
boolean underwater = height < getDimension().getFluidHeight();
|
||||
|
||||
if(decorator != null)
|
||||
{
|
||||
if(!decorator.isStacking())
|
||||
{
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
bd = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
||||
|
||||
if(!underwater)
|
||||
{
|
||||
if(!canGoOn(bd, bdx))
|
||||
{
|
||||
if (!underwater) {
|
||||
if (!canGoOn(bd, bdx)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(bd instanceof Bisected)
|
||||
{
|
||||
if (bd instanceof Bisected) {
|
||||
bd = bd.clone();
|
||||
((Bisected) bd).setHalf(Bisected.Half.TOP);
|
||||
try
|
||||
{
|
||||
try {
|
||||
data.set(x, height + 2, z, bd);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
|
||||
}
|
||||
bd = bd.clone();
|
||||
@@ -61,11 +50,8 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator
|
||||
|
||||
data.set(x, height + 1, z, bd);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (height < getDimension().getFluidHeight())
|
||||
{
|
||||
} else {
|
||||
if (height < getDimension().getFluidHeight()) {
|
||||
max = getDimension().getFluidHeight() - height;
|
||||
}
|
||||
|
||||
@@ -73,23 +59,19 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator
|
||||
BlockData top = decorator.getBlockDataForTop(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);
|
||||
bd = threshold >= decorator.getTopThreshold() ? top : fill;
|
||||
|
||||
if(bd == null)
|
||||
{
|
||||
if (bd == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(i == 0 && !underwater && !canGoOn(bd, bdx))
|
||||
{
|
||||
if (i == 0 && !underwater && !canGoOn(bd, bdx)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(underwater && height + 1 + i > getDimension().getFluidHeight())
|
||||
{
|
||||
if (underwater && height + 1 + i > getDimension().getFluidHeight()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ import org.bukkit.block.data.BlockData;
|
||||
|
||||
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 AIR = B.get("AIR");
|
||||
private static final KList<CaveResult> EMPTY = new KList<>();
|
||||
@@ -28,31 +27,24 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> a) {
|
||||
if(!getDimension().isCaves())
|
||||
{
|
||||
if (!getDimension().isCaves()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
for(int i = 0; i < a.getWidth(); i++)
|
||||
{
|
||||
for(int j = 0; j < a.getDepth(); j++)
|
||||
{
|
||||
for (int i = 0; i < a.getWidth(); i++) {
|
||||
for (int j = 0; j < a.getDepth(); j++) {
|
||||
KList<CaveResult> caves = genCaves(x + i, z + j, i, j, a);
|
||||
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);
|
||||
|
||||
if(cave == null)
|
||||
{
|
||||
if (cave == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for(CaveResult cl : caves)
|
||||
{
|
||||
if(cl.getFloor() < 0 || cl.getFloor() > getEngine().getHeight() || cl.getCeiling() > getEngine().getHeight() || cl.getCeiling() < 0)
|
||||
{
|
||||
for (CaveResult cl : caves) {
|
||||
if (cl.getFloor() < 0 || cl.getFloor() > getEngine().getHeight() || cl.getCeiling() > getEngine().getHeight() || cl.getCeiling() < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -61,13 +53,11 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
|
||||
he - cl.getCeiling(),
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -78,10 +68,8 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
|
||||
getEngine().getMetrics().getCave().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, Hunk<BlockData> data)
|
||||
{
|
||||
if(!getDimension().isCaves())
|
||||
{
|
||||
public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, Hunk<BlockData> data) {
|
||||
if (!getDimension().isCaves()) {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
@@ -90,8 +78,7 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
|
||||
gg.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
|
||||
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);
|
||||
generateCave(result, wxx, wzz, x, z, data, layer, i);
|
||||
}
|
||||
@@ -99,23 +86,17 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
|
||||
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();
|
||||
Function<Integer, BlockData> fluid = (height) ->
|
||||
{
|
||||
if(!layer.getFluid().hasFluid(getData()))
|
||||
{
|
||||
if (!layer.getFluid().hasFluid(getData())) {
|
||||
return CAVE_AIR;
|
||||
}
|
||||
|
||||
if(layer.getFluid().isInverseHeight() && height >= layer.getFluid().getFluidHeight())
|
||||
{
|
||||
if (layer.getFluid().isInverseHeight() && height >= layer.getFluid().getFluidHeight()) {
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -130,8 +111,7 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
|
||||
double distanceTake = 0.0022 * baseWidth;
|
||||
double caveHeightNoise = layer.getVerticalSlope().get(rng, wxx, wzz);
|
||||
|
||||
if(caveHeightNoise > 259 || caveHeightNoise < -1)
|
||||
{
|
||||
if (caveHeightNoise > 259 || caveHeightNoise < -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,62 +119,48 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
|
||||
int ceiling = -256;
|
||||
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;
|
||||
if(distance < distanceCheck - (tunnelHeight * distanceTake))
|
||||
{
|
||||
if (distance < distanceCheck - (tunnelHeight * distanceTake)) {
|
||||
int caveHeight = (int) Math.round(caveHeightNoise);
|
||||
int pu = (int) (caveHeight + tunnelHeight);
|
||||
int pd = (int) (caveHeight - tunnelHeight);
|
||||
|
||||
if(pd > surface + 1)
|
||||
{
|
||||
if (pd > surface + 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!layer.isCanBreakSurface() && pu > surface - 3)
|
||||
{
|
||||
if (!layer.isCanBreakSurface() && pu > surface - 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if((pu > 255 && pd > 255) || (pu < 0 && pd < 0))
|
||||
{
|
||||
if ((pu > 255 && pd > 255) || (pu < 0 && pd < 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(data == null)
|
||||
{
|
||||
if (data == null) {
|
||||
ceiling = Math.max(pu, ceiling);
|
||||
floor = Math.min(pu, floor);
|
||||
ceiling = Math.max(pd, ceiling);
|
||||
floor = Math.min(pd, floor);
|
||||
|
||||
if(tunnelHeight == 1)
|
||||
{
|
||||
if (tunnelHeight == 1) {
|
||||
ceiling = Math.max(caveHeight, ceiling);
|
||||
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);
|
||||
floor = Math.min(pu, floor);
|
||||
}
|
||||
|
||||
if(dig(x, pd, z, data, fluid))
|
||||
{
|
||||
if (dig(x, pd, z, data, fluid)) {
|
||||
ceiling = Math.max(pd, ceiling);
|
||||
floor = Math.min(pd, floor);
|
||||
}
|
||||
|
||||
if(tunnelHeight == 1)
|
||||
{
|
||||
if(dig(x, caveHeight, z, data, fluid))
|
||||
{
|
||||
if (tunnelHeight == 1) {
|
||||
if (dig(x, caveHeight, z, data, fluid)) {
|
||||
ceiling = Math.max(caveHeight, ceiling);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
if (d != null) {
|
||||
return d.getMaterial();
|
||||
}
|
||||
|
||||
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 c = mat(x, y + 1, 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 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 + 1, z, b2);
|
||||
return true;
|
||||
@@ -241,8 +202,7 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canAir(Material m, BlockData caveFluid)
|
||||
{
|
||||
public boolean canAir(Material m, BlockData caveFluid) {
|
||||
return (B.isSolid(m) ||
|
||||
(B.isDecorant(m.createBlockData())) || m.equals(Material.AIR)
|
||||
|| m.equals(caveFluid.getMaterial()) ||
|
||||
@@ -250,13 +210,11 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
|
||||
&& !m.equals(Material.BEDROCK);
|
||||
}
|
||||
|
||||
public boolean canWater(Material m)
|
||||
{
|
||||
public boolean canWater(Material m) {
|
||||
return !m.equals(Material.WATER);
|
||||
}
|
||||
|
||||
public boolean can(Material m)
|
||||
{
|
||||
public boolean can(Material m) {
|
||||
return B.isSolid(m) && !m.equals(Material.BEDROCK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.bukkit.util.BlockVector;
|
||||
|
||||
public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
private final RNG rng;
|
||||
|
||||
public IrisDepositModifier(Engine engine) {
|
||||
super(engine, "Deposit");
|
||||
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());
|
||||
}
|
||||
|
||||
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);
|
||||
IrisRegion region = getComplex().getRegionStream().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);
|
||||
}
|
||||
|
||||
for(IrisDepositGenerator k : region.getDeposits())
|
||||
{
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
|
||||
{
|
||||
for (IrisDepositGenerator k : region.getDeposits()) {
|
||||
for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
||||
generate(k, terrain, ro, x, z, false);
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisDepositGenerator k : biome.getDeposits())
|
||||
{
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
|
||||
{
|
||||
for (IrisDepositGenerator k : biome.getDeposits()) {
|
||||
for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
||||
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);
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
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++) {
|
||||
IrisObject clump = k.getClump(rng, getData());
|
||||
|
||||
int af = (int) Math.ceil(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;
|
||||
bf = 9;
|
||||
}
|
||||
@@ -81,8 +72,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
getComplex().getHeightStream().get((cx << 4) + x, (cz << 4) + z)
|
||||
))) - 7;
|
||||
|
||||
if(height <= 0)
|
||||
{
|
||||
if (height <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,26 +80,22 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
// TODO: WARNING HEIGHT
|
||||
int a = Math.min(height, Math.min(256, k.getMaxHeight()));
|
||||
|
||||
if(i >= a)
|
||||
{
|
||||
if (i >= a) {
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
for(BlockVector j : clump.getBlocks().keySet())
|
||||
{
|
||||
for (BlockVector j : clump.getBlocks().keySet()) {
|
||||
int nx = j.getBlockX() + x;
|
||||
int ny = j.getBlockY() + h;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -125,8 +111,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
}
|
||||
|
||||
if(allow)
|
||||
{
|
||||
if (allow) {
|
||||
data.set(nx, ny, nz, clump.getBlocks().get(j));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,9 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
BurstExecutor b = MultiBurst.burst.burst(output.getWidth() * output.getDepth());
|
||||
int i, j;
|
||||
for(i = 0; i < output.getWidth(); i++)
|
||||
{
|
||||
for (i = 0; i < output.getWidth(); i++) {
|
||||
int ii = i;
|
||||
for(j = 0; j < output.getDepth(); j++)
|
||||
{
|
||||
for (j = 0; j < output.getDepth(); j++) {
|
||||
int jj = j;
|
||||
b.queue(() -> post(ii, jj, output, ii + x, jj + z));
|
||||
}
|
||||
@@ -55,8 +53,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
// Floating Nibs
|
||||
int g = 0;
|
||||
|
||||
if(h < 1)
|
||||
{
|
||||
if (h < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,14 +62,11 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
g += hc < 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);
|
||||
|
||||
for(int i = h - 1; i > 0; i--)
|
||||
{
|
||||
if(!isAir(x, i, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
for (int i = h - 1; i > 0; i--) {
|
||||
if (!isAir(x, i, z, currentPostX, currentPostZ, currentData)) {
|
||||
h = i;
|
||||
break;
|
||||
}
|
||||
@@ -86,24 +80,18 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
g += hc == 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 b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData);
|
||||
Material m = bc.getMaterial();
|
||||
|
||||
if((b.getMaterial().isOccluding() && b.getMaterial().isSolid()))
|
||||
{
|
||||
if(m.isSolid())
|
||||
{
|
||||
if ((b.getMaterial().isOccluding() && b.getMaterial().isSolid())) {
|
||||
if (m.isSolid()) {
|
||||
setPostBlock(x, h, z, b, currentPostX, currentPostZ, currentData);
|
||||
h--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Potholes
|
||||
g = 0;
|
||||
g += ha == h + 1 ? 1 : 0;
|
||||
@@ -111,8 +99,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
g += hc == 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 bb = getPostBlock(x, hb, 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(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);
|
||||
h++;
|
||||
}
|
||||
@@ -134,25 +120,18 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
// Wall Patcher
|
||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(x, z);
|
||||
|
||||
if(getDimension().isPostProcessingWalls())
|
||||
{
|
||||
if(!biome.getWall().getPalette().isEmpty())
|
||||
{
|
||||
if(ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2)
|
||||
{
|
||||
if (getDimension().isPostProcessingWalls()) {
|
||||
if (!biome.getWall().getPalette().isEmpty()) {
|
||||
if (ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2) {
|
||||
boolean brokeGround = false;
|
||||
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());
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
if(isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
if(brokeGround)
|
||||
{
|
||||
if (d != null) {
|
||||
if (isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData)) {
|
||||
if (brokeGround) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -168,8 +147,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
// Slab
|
||||
if(getDimension().isPostProcessingSlabs())
|
||||
{
|
||||
if (getDimension().isPostProcessingSlabs()) {
|
||||
//@builder
|
||||
if ((ha == h + 1 && isSolidNonSlab(x + 1, ha, z, 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());
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
boolean cancel = false;
|
||||
if (d != null) {
|
||||
boolean cancel = B.isAir(d);
|
||||
|
||||
if(B.isAir(d))
|
||||
{
|
||||
if (d.getMaterial().equals(Material.SNOW) && h + 1 <= getDimension().getFluidHeight()) {
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(d.getMaterial().equals(Material.SNOW) && h + 1 <= getDimension().getFluidHeight())
|
||||
{
|
||||
if (isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData)) {
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(!cancel && isAirOrWater(x, h + 1, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
if (!cancel && isAirOrWater(x, h + 1, z, currentPostX, currentPostZ, currentData)) {
|
||||
setPostBlock(x, h + 1, z, d, currentPostX, currentPostZ, currentData);
|
||||
h++;
|
||||
}
|
||||
@@ -210,34 +179,24 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
// Waterlogging
|
||||
BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
|
||||
|
||||
if(b instanceof Waterlogged)
|
||||
{
|
||||
if (b instanceof Waterlogged) {
|
||||
Waterlogged ww = (Waterlogged) b.clone();
|
||||
boolean w = false;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if(w != ww.isWaterlogged())
|
||||
{
|
||||
if (w != ww.isWaterlogged()) {
|
||||
ww.setWaterlogged(w);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -245,26 +204,20 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
// Foliage
|
||||
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();
|
||||
|
||||
if(!B.canPlaceOnto(b.getMaterial(), onto))
|
||||
{
|
||||
if (!B.canPlaceOnto(b.getMaterial(), onto)) {
|
||||
setPostBlock(x, h + 1, z, AIR, currentPostX, currentPostZ, currentData);
|
||||
}
|
||||
}
|
||||
|
||||
if(getDimension().isPostProcessCaves())
|
||||
{
|
||||
if (getDimension().isPostProcessCaves()) {
|
||||
IrisBiome cave = getComplex().getCaveBiomeStream().get(x, z);
|
||||
|
||||
if(cave != null)
|
||||
{
|
||||
for(CaveResult i : ((IrisCaveModifier)getFramework().getCaveModifier()).genCaves(x, z, 0, 0, null))
|
||||
{
|
||||
if(i.getCeiling() >= currentData.getMax2DParallelism() || i.getFloor() < 0)
|
||||
{
|
||||
if (cave != null) {
|
||||
for (CaveResult i : ((IrisCaveModifier) getFramework().getCaveModifier()).genCaves(x, z, 0, 0, null)) {
|
||||
if (i.getCeiling() >= currentData.getMax2DParallelism() || i.getFloor() < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -286,21 +239,16 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
g += fc == 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);
|
||||
b = getPostBlock(x, f + 1, z, currentPostX, currentPostZ, currentData);
|
||||
Material m = bc.getMaterial();
|
||||
|
||||
if(m.isSolid())
|
||||
{
|
||||
if (m.isSolid()) {
|
||||
setPostBlock(x, f, z, b, currentPostX, currentPostZ, currentData);
|
||||
h--;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Cave Potholes
|
||||
g = 0;
|
||||
g += fa == f + 1 ? 1 : 0;
|
||||
@@ -308,8 +256,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
g += fc == 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 bb = getPostBlock(x, fb, 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(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);
|
||||
h++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(getDimension().isPostProcessingSlabs())
|
||||
{
|
||||
if (getDimension().isPostProcessingSlabs()) {
|
||||
//@builder
|
||||
if ((fa == f + 1 && isSolidNonSlab(x + 1, fa, z, 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());
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
boolean cancel = false;
|
||||
if (d != null) {
|
||||
boolean cancel = B.isAir(d);
|
||||
|
||||
if(B.isAir(d))
|
||||
{
|
||||
if (d.getMaterial().equals(Material.SNOW) && f + 1 <= getDimension().getFluidHeight()) {
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(d.getMaterial().equals(Material.SNOW) && f + 1 <= getDimension().getFluidHeight())
|
||||
{
|
||||
if (isSnowLayer(x, f, z, currentPostX, currentPostZ, currentData)) {
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(isSnowLayer(x, f, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(!cancel && isAirOrWater(x, f + 1, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
if (!cancel && isAirOrWater(x, f + 1, z, 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());
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
boolean cancel = false;
|
||||
if (d != null) {
|
||||
boolean cancel = B.isAir(d);
|
||||
|
||||
if(B.isAir(d))
|
||||
{
|
||||
if (!(d instanceof Slab)) {
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(!(d instanceof Slab))
|
||||
{
|
||||
if (isSnowLayer(x, c, z, currentPostX, currentPostZ, currentData)) {
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(isSnowLayer(x, c, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(!cancel && isAirOrWater(x, c, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
if (!cancel && isAirOrWater(x, c, z, currentPostX, currentPostZ, currentData)) {
|
||||
Slab slab = (Slab) d.clone();
|
||||
slab.setType(Slab.Type.TOP);
|
||||
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)
|
||||
{
|
||||
if(floor >= currentData.getHeight())
|
||||
{
|
||||
private int nearestCaveFloor(int floor, int x, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
|
||||
if (floor >= currentData.getHeight()) {
|
||||
return currentData.getHeight() - 1;
|
||||
}
|
||||
|
||||
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, z, currentPostX, currentPostZ, currentData))) {
|
||||
if (B.isAir(getPostBlock(x, floor - 1, z, currentPostX, currentPostZ, currentData))) {
|
||||
return floor - 2;
|
||||
}
|
||||
|
||||
return floor - 1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if(!B.isAir(getPostBlock(x, floor + 1, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
if(!B.isAir(getPostBlock(x, floor + 2, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
if(ceiling >= currentData.getHeight())
|
||||
{
|
||||
private int nearestCaveCeiling(int ceiling, int x, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
|
||||
if (ceiling >= currentData.getHeight()) {
|
||||
return currentData.getHeight() - 1;
|
||||
}
|
||||
|
||||
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, z, currentPostX, currentPostZ, currentData))) {
|
||||
if (B.isAir(getPostBlock(x, ceiling + 1, z, currentPostX, currentPostZ, currentData))) {
|
||||
return ceiling + 2;
|
||||
}
|
||||
|
||||
return ceiling + 1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if(!B.isAir(getPostBlock(x, ceiling - 1, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
if(!B.isAir(getPostBlock(x, ceiling - 2, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
return d instanceof Levelled;
|
||||
}
|
||||
|
||||
|
||||
public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
if(y < currentData.getHeight())
|
||||
{
|
||||
public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
|
||||
if (y < currentData.getHeight()) {
|
||||
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);
|
||||
|
||||
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.object.NoiseStyle;
|
||||
import com.volmit.iris.util.*;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedModifier;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.*;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
private static final BlockData CAVE_AIR = B.get("CAVE_AIR");
|
||||
private static final BlockData LAVA = B.get("LAVA");
|
||||
private CNG cng;
|
||||
private RNG rng;
|
||||
private final CNG cng;
|
||||
private final RNG rng;
|
||||
|
||||
public IrisRavineModifier(Engine engine) {
|
||||
super(engine, "Ravine");
|
||||
@@ -23,8 +23,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> output) {
|
||||
if(!getDimension().isRavines())
|
||||
{
|
||||
if (!getDimension().isRavines()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,61 +32,51 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if(bb == null)
|
||||
{
|
||||
if (bb == null) {
|
||||
bb = CAVE_AIR;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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;
|
||||
RNG random = new RNG(seed);
|
||||
double x = tx * 16 + 8;
|
||||
double z = tz * 16 + 8;
|
||||
float f4 = 0.0f;
|
||||
float f5 = 0.0f;
|
||||
if(n4 <= 0)
|
||||
{
|
||||
if (n4 <= 0) {
|
||||
n5 = 8 * 16 - 16;
|
||||
n4 = n5 - random.nextInt(n5 / 4);
|
||||
}
|
||||
n5 = 0;
|
||||
if(n3 == -1)
|
||||
{
|
||||
if (n3 == -1) {
|
||||
n3 = n4 / 2;
|
||||
n5 = 1;
|
||||
}
|
||||
float f6 = 1.0f;
|
||||
// TODO: WARNING HEIGHT
|
||||
for(int i = 0; i < 256; ++i)
|
||||
{
|
||||
if(i == 0 || random.nextInt(getDimension().getRavineRibRarity()) == 0)
|
||||
{
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
if (i == 0 || random.nextInt(getDimension().getRavineRibRarity()) == 0) {
|
||||
f6 = 1.0f + random.nextFloat() * random.nextFloat() * 1.0f;
|
||||
}
|
||||
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 d8 = d7 * d4;
|
||||
d7 *= (double) random.nextFloat() * 0.25 + 0.75;
|
||||
@@ -104,18 +93,15 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
f4 *= 0.5f;
|
||||
f5 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.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 d10 = sz - z;
|
||||
double d11 = n4 - n3;
|
||||
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;
|
||||
}
|
||||
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 n7 = 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 n11 = MathHelper.floor(sz - d7) - tz * 16 - 1;
|
||||
int n12 = MathHelper.floor(sz + d7) - tz * 16 + 1;
|
||||
if(n7 < 0)
|
||||
{
|
||||
if (n7 < 0) {
|
||||
n7 = 0;
|
||||
}
|
||||
if(n8 > 16)
|
||||
{
|
||||
if (n8 > 16) {
|
||||
n8 = 16;
|
||||
}
|
||||
if(n9 < 1)
|
||||
{
|
||||
if (n9 < 1) {
|
||||
n9 = 1;
|
||||
}
|
||||
if(n10 > 248)
|
||||
{
|
||||
if (n10 > 248) {
|
||||
n10 = 248;
|
||||
}
|
||||
if(n11 < 0)
|
||||
{
|
||||
if (n11 < 0) {
|
||||
n11 = 0;
|
||||
}
|
||||
if(n12 > 16)
|
||||
{
|
||||
if (n12 > 16) {
|
||||
n12 = 16;
|
||||
}
|
||||
boolean bl = false;
|
||||
for(int i = n7; !bl && i < n8; ++i)
|
||||
{
|
||||
for(n6 = n11; !bl && n6 < n12; ++n6)
|
||||
{
|
||||
for(int j = n10 + 1; !bl && j >= n9 - 1; --j)
|
||||
{
|
||||
for (int i = n7; !bl && i < n8; ++i) {
|
||||
for (n6 = n11; !bl && n6 < n12; ++n6) {
|
||||
for (int j = n10 + 1; !bl && j >= n9 - 1; --j) {
|
||||
// TODO: WARNING HEIGHT
|
||||
if(j < 0 || j >= 256)
|
||||
{
|
||||
if (j < 0 || j >= 256) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData bb = get(terrain, i, j, n6);
|
||||
|
||||
if(B.isWater(bb))
|
||||
{
|
||||
if (B.isWater(bb)) {
|
||||
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;
|
||||
}
|
||||
j = n9;
|
||||
@@ -212,8 +186,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (n5 != 0)
|
||||
{
|
||||
if (n5 != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -223,17 +196,15 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
}
|
||||
|
||||
private BlockPosition cSet(BlockPosition bb, double var0, double var2, double var4)
|
||||
{
|
||||
bb.setX(MathHelper.floor((double) var0));
|
||||
bb.setY(MathHelper.floor((double) var2));
|
||||
bb.setZ(MathHelper.floor((double) var4));
|
||||
private BlockPosition cSet(BlockPosition bb, double var0, double var2, double var4) {
|
||||
bb.setX(MathHelper.floor(var0));
|
||||
bb.setY(MathHelper.floor(var2));
|
||||
bb.setZ(MathHelper.floor(var4));
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
private boolean isDirt(BlockData d)
|
||||
{
|
||||
private boolean isDirt(BlockData d) {
|
||||
//@builder
|
||||
Material m = d.getMaterial();
|
||||
return m.equals(Material.DIRT) ||
|
||||
@@ -242,8 +213,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
//@done
|
||||
}
|
||||
|
||||
private boolean isSurface(BlockData d)
|
||||
{
|
||||
private boolean isSurface(BlockData d) {
|
||||
//@builder
|
||||
Material m = d.getMaterial();
|
||||
return m.equals(Material.GRASS_BLOCK) ||
|
||||
@@ -254,16 +224,13 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
//@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 bx = this.rng.nextParallelRNG(6676121);
|
||||
long l = b.nextLong();
|
||||
long l2 = b.nextLong();
|
||||
for(int i = n - 8; i <= n + 8; ++i)
|
||||
{
|
||||
for(int j = n2 - 8; j <= n2 + 8; ++j)
|
||||
{
|
||||
for (int i = n - 8; i <= n + 8; ++i) {
|
||||
for (int j = n2 - 8; j <= n2 + 8; ++j) {
|
||||
long l3 = (long) i * l;
|
||||
long l4 = (long) j * l2;
|
||||
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)
|
||||
{
|
||||
if(b.nextInt(getDimension().getRavineRarity()) != 0)
|
||||
{
|
||||
private void doRavines(int tx, int tz, int sx, int sz, ChunkPosition chunkSnapshot, RNG b, Hunk<BlockData> terrain) {
|
||||
if (b.nextInt(getDimension().getRavineRarity()) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -283,8 +248,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
double d2 = b.nextInt(b.nextInt(40) + 8) + 20;
|
||||
double z = tz * 16 + b.nextInt(16);
|
||||
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 f2 = (b.nextFloat() - 0.5f) * 2.0f / 8.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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CNG
|
||||
{
|
||||
public class CNG {
|
||||
public static long hits = 0;
|
||||
public static long creates = 0;
|
||||
public static final NoiseInjector ADD = (s, v) -> new double[]{s + v, 1};
|
||||
@@ -40,67 +39,55 @@ public class CNG
|
||||
private double down;
|
||||
private double power;
|
||||
|
||||
public NoiseGenerator getGen()
|
||||
{
|
||||
public NoiseGenerator getGen() {
|
||||
return generator;
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> stream()
|
||||
{
|
||||
public ProceduralStream<Double> stream() {
|
||||
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);
|
||||
}
|
||||
|
||||
public static CNG signature(RNG rng)
|
||||
{
|
||||
public static CNG signature(RNG rng) {
|
||||
return signature(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signatureHalf(RNG rng)
|
||||
{
|
||||
public static CNG signatureHalf(RNG rng) {
|
||||
return signatureHalf(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signatureThick(RNG rng)
|
||||
{
|
||||
public static CNG signatureThick(RNG rng) {
|
||||
return signatureThick(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signatureDouble(RNG rng)
|
||||
{
|
||||
public static CNG signatureDouble(RNG rng) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
.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
|
||||
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
|
||||
}
|
||||
|
||||
public static CNG signaturePerlin(RNG rng)
|
||||
{
|
||||
public static CNG signaturePerlin(RNG rng) {
|
||||
return signaturePerlin(rng, NoiseType.PERLIN);
|
||||
}
|
||||
|
||||
public static CNG signaturePerlin(RNG rng, NoiseType t)
|
||||
{
|
||||
public static CNG signaturePerlin(RNG rng, NoiseType t) {
|
||||
// @NoArgsConstructor
|
||||
return new CNG(rng.nextParallelRNG(124996), t, 1D, 1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(18), NoiseType.PERLIN, 1, 1).scale(1.25), 250)
|
||||
@@ -108,8 +95,7 @@ public class CNG
|
||||
// @done
|
||||
}
|
||||
|
||||
public static CNG signatureFast(RNG rng, NoiseType t, NoiseType f)
|
||||
{
|
||||
public static CNG signatureFast(RNG rng, NoiseType t, NoiseType f) {
|
||||
// @NoArgsConstructor
|
||||
return new CNG(rng.nextParallelRNG(17), t, 1D, 1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1)
|
||||
@@ -121,15 +107,13 @@ public class CNG
|
||||
// @done
|
||||
}
|
||||
|
||||
public static CNG signatureThick(RNG rng, NoiseType t)
|
||||
{
|
||||
public static CNG signatureThick(RNG rng, NoiseType t) {
|
||||
// @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();
|
||||
// @done
|
||||
}
|
||||
|
||||
public static CNG signatureThickFast(RNG rng, NoiseType t, NoiseType f)
|
||||
{
|
||||
public static CNG signatureThickFast(RNG rng, NoiseType t, NoiseType f) {
|
||||
// @NoArgsConstructor
|
||||
return new CNG(rng.nextParallelRNG(133), t, 1D, 1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1)
|
||||
@@ -139,15 +123,13 @@ public class CNG
|
||||
// @done
|
||||
}
|
||||
|
||||
public static CNG signatureHalf(RNG rng, NoiseType t)
|
||||
{
|
||||
public static CNG signatureHalf(RNG rng, NoiseType t) {
|
||||
// @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();
|
||||
// @done
|
||||
}
|
||||
|
||||
public static CNG signatureHalfFast(RNG rng, NoiseType t, NoiseType f)
|
||||
{
|
||||
public static CNG signatureHalfFast(RNG rng, NoiseType t, NoiseType f) {
|
||||
// @NoArgsConstructor
|
||||
return new CNG(rng.nextParallelRNG(127), t, 1D, 1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1).scale(0.9)
|
||||
@@ -156,23 +138,19 @@ public class CNG
|
||||
// @done
|
||||
}
|
||||
|
||||
public CNG(RNG random)
|
||||
{
|
||||
public CNG(RNG random) {
|
||||
this(random, 1);
|
||||
}
|
||||
|
||||
public CNG(RNG random, int octaves)
|
||||
{
|
||||
public CNG(RNG random, int 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);
|
||||
}
|
||||
|
||||
public CNG(RNG random, NoiseType t, double opacity, int octaves)
|
||||
{
|
||||
public CNG(RNG random, NoiseType t, double opacity, int octaves) {
|
||||
creates++;
|
||||
noscale = t.equals(NoiseType.WHITE);
|
||||
this.oct = octaves;
|
||||
@@ -189,23 +167,19 @@ public class CNG
|
||||
this.opacity = opacity;
|
||||
this.injector = ADD;
|
||||
|
||||
if(generator instanceof OctaveNoise)
|
||||
{
|
||||
if (generator instanceof OctaveNoise) {
|
||||
((OctaveNoise) generator).setOctaves(octaves);
|
||||
}
|
||||
}
|
||||
|
||||
public CNG bake()
|
||||
{
|
||||
public CNG bake() {
|
||||
bakedScale *= scale;
|
||||
scale = 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG child(CNG c)
|
||||
{
|
||||
if(children == null)
|
||||
{
|
||||
public CNG child(CNG c) {
|
||||
if (children == null) {
|
||||
children = new KList<>();
|
||||
}
|
||||
|
||||
@@ -213,146 +187,114 @@ public class CNG
|
||||
return this;
|
||||
}
|
||||
|
||||
public RNG getRNG()
|
||||
{
|
||||
public RNG getRNG() {
|
||||
return rng;
|
||||
}
|
||||
|
||||
public CNG fractureWith(CNG c, double scale)
|
||||
{
|
||||
public CNG fractureWith(CNG c, double scale) {
|
||||
fracture = c;
|
||||
fscale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG scale(double c)
|
||||
{
|
||||
public CNG scale(double c) {
|
||||
scale = c;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG patch(double c)
|
||||
{
|
||||
public CNG patch(double c) {
|
||||
patch = c;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG up(double c)
|
||||
{
|
||||
public CNG up(double c) {
|
||||
up = c;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG down(double c)
|
||||
{
|
||||
public CNG down(double c) {
|
||||
down = c;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG injectWith(NoiseInjector i)
|
||||
{
|
||||
public CNG injectWith(NoiseInjector i) {
|
||||
injector = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T extends IRare> T fitRarity(KList<T> b, double... dim)
|
||||
{
|
||||
if(b.size() == 0)
|
||||
{
|
||||
public <T extends IRare> T fitRarity(KList<T> b, double... dim) {
|
||||
if (b.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(b.size() == 1)
|
||||
{
|
||||
if (b.size() == 1) {
|
||||
return b.get(0);
|
||||
}
|
||||
|
||||
KList<T> rarityMapped = new KList<>();
|
||||
boolean o = false;
|
||||
int max = 1;
|
||||
for(T i : b)
|
||||
{
|
||||
if(i.getRarity() > max)
|
||||
{
|
||||
for (T i : b) {
|
||||
if (i.getRarity() > max) {
|
||||
max = i.getRarity();
|
||||
}
|
||||
}
|
||||
|
||||
max++;
|
||||
|
||||
for(T i : b)
|
||||
{
|
||||
for(int j = 0; j < max - i.getRarity(); j++)
|
||||
{
|
||||
if(o = !o)
|
||||
{
|
||||
for (T i : b) {
|
||||
for (int j = 0; j < max - i.getRarity(); j++) {
|
||||
if (o = !o) {
|
||||
rarityMapped.add(i);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rarityMapped.add(0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rarityMapped.size() == 1)
|
||||
{
|
||||
if (rarityMapped.size() == 1) {
|
||||
return rarityMapped.get(0);
|
||||
}
|
||||
|
||||
if(rarityMapped.isEmpty())
|
||||
{
|
||||
if (rarityMapped.isEmpty()) {
|
||||
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
|
||||
}
|
||||
|
||||
return fit(rarityMapped, dim);
|
||||
}
|
||||
|
||||
public <T> T fit(T[] v, double... dim)
|
||||
{
|
||||
if(v.length == 0)
|
||||
{
|
||||
public <T> T fit(T[] v, double... dim) {
|
||||
if (v.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(v.length == 1)
|
||||
{
|
||||
if (v.length == 1) {
|
||||
return v[0];
|
||||
}
|
||||
|
||||
return v[fit(0, v.length - 1, dim)];
|
||||
}
|
||||
|
||||
public <T> T fit(List<T> v, double... dim)
|
||||
{
|
||||
if(v.size() == 0)
|
||||
{
|
||||
public <T> T fit(List<T> v, double... dim) {
|
||||
if (v.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(v.size() == 1)
|
||||
{
|
||||
if (v.size() == 1) {
|
||||
return v.get(0);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
return v.get(fit(0, v.size() - 1, dim));
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
return v.get(0);
|
||||
}
|
||||
|
||||
public int fit(int min, int max, double... dim)
|
||||
{
|
||||
if(min == max)
|
||||
{
|
||||
public int fit(int min, int max, double... dim) {
|
||||
if (min == max) {
|
||||
return min;
|
||||
}
|
||||
|
||||
@@ -361,10 +303,8 @@ public class CNG
|
||||
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
||||
}
|
||||
|
||||
public int fit(double min, double max, double... dim)
|
||||
{
|
||||
if(min == max)
|
||||
{
|
||||
public int fit(double min, double max, double... dim) {
|
||||
if (min == max) {
|
||||
return (int) Math.round(min);
|
||||
}
|
||||
|
||||
@@ -373,10 +313,8 @@ public class CNG
|
||||
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
||||
}
|
||||
|
||||
public double fitDouble(double min, double max, double... dim)
|
||||
{
|
||||
if(min == max)
|
||||
{
|
||||
public double fitDouble(double min, double max, double... dim) {
|
||||
if (min == max) {
|
||||
return min;
|
||||
}
|
||||
|
||||
@@ -385,12 +323,9 @@ public class CNG
|
||||
return IrisInterpolation.lerp(min, max, noise);
|
||||
}
|
||||
|
||||
private double getNoise(double... dim)
|
||||
{
|
||||
if(isTrueFracturing())
|
||||
{
|
||||
if(dim.length == 2)
|
||||
{
|
||||
private double getNoise(double... dim) {
|
||||
if (isTrueFracturing()) {
|
||||
if (dim.length == 2) {
|
||||
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 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 z = 0D;
|
||||
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 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);
|
||||
@@ -421,19 +353,16 @@ public class CNG
|
||||
return generator.noise(x * scale, y * scale, z * scale) * opacity;
|
||||
}
|
||||
|
||||
public double noise(double... dim)
|
||||
{
|
||||
public double noise(double... dim) {
|
||||
double n = getNoise(dim);
|
||||
n = power != 1D ? (n < 0 ? -Math.pow(Math.abs(n), power) : Math.pow(n, power)) : n;
|
||||
double m = 1;
|
||||
hits += oct;
|
||||
if(children == null)
|
||||
{
|
||||
if (children == null) {
|
||||
return (n - down + up) * patch;
|
||||
}
|
||||
|
||||
for(CNG i : children)
|
||||
{
|
||||
for (CNG i : children) {
|
||||
double[] r = injector.combine(n, i.noise(dim));
|
||||
n = r[0];
|
||||
m += r[1];
|
||||
@@ -442,20 +371,17 @@ public class CNG
|
||||
return ((n / m) - down + up) * patch;
|
||||
}
|
||||
|
||||
public CNG pow(double power)
|
||||
{
|
||||
public CNG pow(double power) {
|
||||
this.power = power;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG oct(int octaves)
|
||||
{
|
||||
public CNG oct(int octaves) {
|
||||
oct = octaves;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getScale()
|
||||
{
|
||||
public double getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.volmit.iris.generator.noise;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface CNGFactory
|
||||
{
|
||||
public interface CNGFactory {
|
||||
CNG create(RNG seed);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class CellGenerator
|
||||
{
|
||||
private FastNoiseDouble fn;
|
||||
private FastNoiseDouble fd;
|
||||
private CNG cng;
|
||||
public class CellGenerator {
|
||||
private final FastNoiseDouble fn;
|
||||
private final FastNoiseDouble fd;
|
||||
private final CNG cng;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -19,8 +17,7 @@ public class CellGenerator
|
||||
@Setter
|
||||
private double shuffle;
|
||||
|
||||
public CellGenerator(RNG rng)
|
||||
{
|
||||
public CellGenerator(RNG rng) {
|
||||
shuffle = 128;
|
||||
cellScale = 0.73;
|
||||
cng = CNG.signature(rng.nextParallelRNG(3204));
|
||||
@@ -36,50 +33,40 @@ public class CellGenerator
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public double getValue(double x, double z, int possibilities)
|
||||
{
|
||||
if(possibilities == 1)
|
||||
{
|
||||
public double getValue(double x, double z, int possibilities) {
|
||||
if (possibilities == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if(possibilities == 1)
|
||||
{
|
||||
public double getValue(double x, double y, double z, int possibilities) {
|
||||
if (possibilities == 1) {
|
||||
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);
|
||||
}
|
||||
|
||||
public int getIndex(double x, double z, int possibilities)
|
||||
{
|
||||
if(possibilities == 1)
|
||||
{
|
||||
public int getIndex(double x, double z, int possibilities) {
|
||||
if (possibilities == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) Math.round(getValue(x, z, possibilities));
|
||||
}
|
||||
|
||||
public int getIndex(double x, double y, double z, int possibilities)
|
||||
{
|
||||
if(possibilities == 1)
|
||||
{
|
||||
public int getIndex(double x, double y, double z, int possibilities) {
|
||||
if (possibilities == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,38 +3,32 @@ package com.volmit.iris.generator.noise;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class CellHeightNoise implements NoiseGenerator
|
||||
{
|
||||
public class CellHeightNoise implements NoiseGenerator {
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public CellHeightNoise(long seed)
|
||||
{
|
||||
public CellHeightNoise(long seed) {
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
|
||||
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return filter(n.GetCellular(x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
return filter(n.GetCellular(x, z));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,10 @@ package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class CellularNoise implements NoiseGenerator
|
||||
{
|
||||
public class CellularNoise implements NoiseGenerator {
|
||||
private final FastNoise n;
|
||||
|
||||
public CellularNoise(long seed)
|
||||
{
|
||||
public CellularNoise(long seed) {
|
||||
this.n = new FastNoise(new RNG(seed).imax());
|
||||
n.SetNoiseType(FastNoise.NoiseType.Cellular);
|
||||
n.SetCellularReturnType(FastNoise.CellularReturnType.CellValue);
|
||||
@@ -15,20 +13,17 @@ public class CellularNoise implements NoiseGenerator
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return (n.GetCellular((float) x, 0) / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,35 +2,29 @@ package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class CubicNoise implements NoiseGenerator
|
||||
{
|
||||
public class CubicNoise implements NoiseGenerator {
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public CubicNoise(long seed)
|
||||
{
|
||||
public CubicNoise(long seed) {
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
}
|
||||
|
||||
private double f(double n)
|
||||
{
|
||||
private double f(double n) {
|
||||
return (n / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return f(n.GetCubic(x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetCubic(x, z));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
public class FlatNoise implements NoiseGenerator
|
||||
{
|
||||
public FlatNoise(long seed)
|
||||
{
|
||||
public class FlatNoise implements NoiseGenerator {
|
||||
public FlatNoise(long seed) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return 1D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
return 1D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
public double noise(double x, double y, double z) {
|
||||
return 1D;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,43 +3,36 @@ package com.volmit.iris.generator.noise;
|
||||
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class FractalBillowPerlinNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
public class FractalBillowPerlinNoise implements NoiseGenerator, OctaveNoise {
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public FractalBillowPerlinNoise(long seed)
|
||||
{
|
||||
public FractalBillowPerlinNoise(long seed) {
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setFractalOctaves(1);
|
||||
n.setFractalType(FractalType.Billow);
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
public double f(double v) {
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return f(n.GetPerlinFractal(x, 0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetPerlinFractal(x, z));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
public void setOctaves(int 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.util.RNG;
|
||||
|
||||
public class FractalBillowSimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
public class FractalBillowSimplexNoise implements NoiseGenerator, OctaveNoise {
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public FractalBillowSimplexNoise(long seed)
|
||||
{
|
||||
public FractalBillowSimplexNoise(long seed) {
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setFractalOctaves(1);
|
||||
n.setFractalType(FractalType.Billow);
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
public double f(double v) {
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return f(n.GetSimplexFractal(x, 0d));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetSimplexFractal(x, z));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
public void setOctaves(int 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.util.RNG;
|
||||
|
||||
public class FractalCubicNoise implements NoiseGenerator
|
||||
{
|
||||
public class FractalCubicNoise implements NoiseGenerator {
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public FractalCubicNoise(long seed)
|
||||
{
|
||||
public FractalCubicNoise(long seed) {
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setFractalType(FractalType.Billow);
|
||||
}
|
||||
|
||||
private double f(double n)
|
||||
{
|
||||
private double f(double n) {
|
||||
return (n / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return f(n.GetCubicFractal(x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetCubicFractal(x, z));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,43 +3,36 @@ package com.volmit.iris.generator.noise;
|
||||
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class FractalFBMSimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
public class FractalFBMSimplexNoise implements NoiseGenerator, OctaveNoise {
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public FractalFBMSimplexNoise(long seed)
|
||||
{
|
||||
public FractalFBMSimplexNoise(long seed) {
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setFractalOctaves(1);
|
||||
n.setFractalType(FractalType.FBM);
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
public double f(double v) {
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return f(n.GetSimplexFractal(x, 0d));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetSimplexFractal(x, z));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
public void setOctaves(int 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.util.RNG;
|
||||
|
||||
public class FractalRigidMultiSimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
public class FractalRigidMultiSimplexNoise implements NoiseGenerator, OctaveNoise {
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public FractalRigidMultiSimplexNoise(long seed)
|
||||
{
|
||||
public FractalRigidMultiSimplexNoise(long seed) {
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setFractalOctaves(1);
|
||||
n.setFractalType(FractalType.RigidMulti);
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
public double f(double v) {
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return f(n.GetSimplexFractal(x, 0d));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetSimplexFractal(x, z));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
public void setOctaves(int o) {
|
||||
n.setFractalOctaves(o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,38 +2,32 @@ package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class GlobNoise implements NoiseGenerator
|
||||
{
|
||||
public class GlobNoise implements NoiseGenerator {
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public GlobNoise(long seed)
|
||||
{
|
||||
public GlobNoise(long seed) {
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
|
||||
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Div);
|
||||
n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
|
||||
}
|
||||
|
||||
private double f(double n)
|
||||
{
|
||||
private double f(double n) {
|
||||
return n + 1D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return f(n.GetCellular(x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetCellular(x, z));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface NoiseFactory
|
||||
{
|
||||
public interface NoiseFactory {
|
||||
NoiseGenerator create(long seed);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
public interface NoiseGenerator
|
||||
{
|
||||
public double noise(double x);
|
||||
public interface NoiseGenerator {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public enum NoiseType {
|
||||
|
||||
private final NoiseFactory f;
|
||||
|
||||
private NoiseType(NoiseFactory f) {
|
||||
NoiseType(NoiseFactory f) {
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
public interface OctaveNoise
|
||||
{
|
||||
public void setOctaves(int o);
|
||||
public interface OctaveNoise {
|
||||
void setOctaves(int o);
|
||||
}
|
||||
|
||||
@@ -2,27 +2,22 @@ package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class PerlinNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
public class PerlinNoise implements NoiseGenerator, OctaveNoise {
|
||||
private final FastNoiseDouble n;
|
||||
private int octaves;
|
||||
|
||||
public PerlinNoise(long seed)
|
||||
{
|
||||
public PerlinNoise(long seed) {
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
octaves = 1;
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
public double f(double v) {
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
public double noise(double x) {
|
||||
if (octaves <= 1) {
|
||||
return f(n.GetPerlin(x, 0));
|
||||
}
|
||||
|
||||
@@ -30,8 +25,7 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise
|
||||
double m = 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;
|
||||
m += f;
|
||||
}
|
||||
@@ -40,18 +34,15 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
if (octaves <= 1) {
|
||||
return f(n.GetPerlin(x, z));
|
||||
}
|
||||
double f = 1;
|
||||
double m = 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;
|
||||
v += n.GetPerlin((x * f), (z * f)) * f;
|
||||
m += f;
|
||||
@@ -61,18 +52,15 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
public double noise(double x, double y, double z) {
|
||||
if (octaves <= 1) {
|
||||
return f(n.GetPerlin(x, y, z));
|
||||
}
|
||||
double f = 1;
|
||||
double m = 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;
|
||||
v += n.GetPerlin((x * f), (y * f), (z * f)) * f;
|
||||
m += f;
|
||||
@@ -82,8 +70,7 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
public void setOctaves(int o) {
|
||||
octaves = o;
|
||||
}
|
||||
|
||||
@@ -91,6 +78,7 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise
|
||||
n.m_longerp = FastNoiseDouble.Longerp.Hermite;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NoiseGenerator quad() {
|
||||
n.m_longerp = FastNoiseDouble.Longerp.Qulongic;
|
||||
return this;
|
||||
|
||||
@@ -4,61 +4,46 @@ import com.volmit.iris.util.IRare;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class RarityCellGenerator<T extends IRare> extends CellGenerator
|
||||
{
|
||||
public RarityCellGenerator(RNG rng)
|
||||
{
|
||||
public class RarityCellGenerator<T extends IRare> extends CellGenerator {
|
||||
public RarityCellGenerator(RNG rng) {
|
||||
super(rng);
|
||||
}
|
||||
|
||||
public T get(double x, double z, KList<T> b)
|
||||
{
|
||||
if(b.size() == 0)
|
||||
{
|
||||
public T get(double x, double z, KList<T> b) {
|
||||
if (b.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(b.size() == 1)
|
||||
{
|
||||
if (b.size() == 1) {
|
||||
return b.get(0);
|
||||
}
|
||||
|
||||
KList<T> rarityMapped = new KList<>();
|
||||
boolean o = false;
|
||||
int max = 1;
|
||||
for(T i : b)
|
||||
{
|
||||
if(i.getRarity() > max)
|
||||
{
|
||||
for (T i : b) {
|
||||
if (i.getRarity() > max) {
|
||||
max = i.getRarity();
|
||||
}
|
||||
}
|
||||
|
||||
max++;
|
||||
|
||||
for(T i : b)
|
||||
{
|
||||
for(int j = 0; j < max - i.getRarity(); j++)
|
||||
{
|
||||
if(o = !o)
|
||||
{
|
||||
for (T i : b) {
|
||||
for (int j = 0; j < max - i.getRarity(); j++) {
|
||||
if (o = !o) {
|
||||
rarityMapped.add(i);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rarityMapped.add(0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rarityMapped.size() == 1)
|
||||
{
|
||||
if (rarityMapped.size() == 1) {
|
||||
return rarityMapped.get(0);
|
||||
}
|
||||
|
||||
if(rarityMapped.isEmpty())
|
||||
{
|
||||
if (rarityMapped.isEmpty()) {
|
||||
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;
|
||||
|
||||
public class SimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
public class SimplexNoise implements NoiseGenerator, OctaveNoise {
|
||||
private final FastNoiseDouble n;
|
||||
private int octaves;
|
||||
|
||||
public SimplexNoise(long seed)
|
||||
{
|
||||
public SimplexNoise(long seed) {
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
octaves = 1;
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
public double f(double v) {
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
public double noise(double x) {
|
||||
if (octaves <= 1) {
|
||||
return f(n.GetSimplex(x, 0d));
|
||||
}
|
||||
|
||||
@@ -30,8 +25,7 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
double m = 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;
|
||||
m += f;
|
||||
}
|
||||
@@ -40,18 +34,15 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
if (octaves <= 1) {
|
||||
return f(n.GetSimplex(x, z));
|
||||
}
|
||||
double f = 1;
|
||||
double m = 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;
|
||||
v += n.GetSimplex((x * f), (z * f)) * f;
|
||||
m += f;
|
||||
@@ -61,18 +52,15 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
public double noise(double x, double y, double z) {
|
||||
if (octaves <= 1) {
|
||||
return f(n.GetSimplex(x, y, z));
|
||||
}
|
||||
double f = 1;
|
||||
double m = 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;
|
||||
v += n.GetSimplex((x * f), (y * f), (z * f)) * f;
|
||||
m += f;
|
||||
@@ -82,8 +70,7 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
public void setOctaves(int o) {
|
||||
octaves = o;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,38 +3,32 @@ package com.volmit.iris.generator.noise;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class VascularNoise implements NoiseGenerator
|
||||
{
|
||||
public class VascularNoise implements NoiseGenerator {
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public VascularNoise(long seed)
|
||||
{
|
||||
public VascularNoise(long seed) {
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
|
||||
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
|
||||
n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
|
||||
}
|
||||
|
||||
private double filter(double noise)
|
||||
{
|
||||
private double filter(double noise) {
|
||||
return M.clip((noise / 2D) + 0.5D, 0D, 1D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return filter(n.GetCellular(x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
public double noise(double x, double z) {
|
||||
return filter(n.GetCellular(x, z));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,40 +2,33 @@ package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class WhiteNoise implements NoiseGenerator
|
||||
{
|
||||
public class WhiteNoise implements NoiseGenerator {
|
||||
private final FastNoise n;
|
||||
|
||||
public WhiteNoise(long seed)
|
||||
{
|
||||
public WhiteNoise(long seed) {
|
||||
n = new FastNoise(new RNG(seed).imax());
|
||||
}
|
||||
|
||||
public boolean isStatic()
|
||||
{
|
||||
public boolean isStatic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private double f(double m)
|
||||
{
|
||||
private double f(double m) {
|
||||
return (m % 8192) * 1024;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
public double noise(double x) {
|
||||
return (n.GetWhiteNoise(f(x), 0d) / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.object.*;
|
||||
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.NamedTag;
|
||||
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.ListTag;
|
||||
import com.volmit.iris.util.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@@ -19,13 +19,11 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ConversionManager
|
||||
{
|
||||
private KList<Converter> converters;
|
||||
private File folder;
|
||||
public class ConversionManager {
|
||||
private final KList<Converter> converters;
|
||||
private final File folder;
|
||||
|
||||
public ConversionManager()
|
||||
{
|
||||
public ConversionManager() {
|
||||
folder = Iris.instance.getDataFolder("convert");
|
||||
converters = new KList<>();
|
||||
|
||||
@@ -33,46 +31,37 @@ public class ConversionManager
|
||||
{
|
||||
J.attemptAsync(() ->
|
||||
{
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("WorldEdit"))
|
||||
{
|
||||
converters.add(new Converter()
|
||||
{
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) {
|
||||
converters.add(new Converter() {
|
||||
@Override
|
||||
public String getOutExtension()
|
||||
{
|
||||
public String getOutExtension() {
|
||||
return "iob";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInExtension()
|
||||
{
|
||||
public String getInExtension() {
|
||||
return "schem";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(File in, File out)
|
||||
{
|
||||
public void convert(File in, File out) {
|
||||
SKConversion.convertSchematic(in, out);
|
||||
}
|
||||
});
|
||||
|
||||
converters.add(new Converter()
|
||||
{
|
||||
converters.add(new Converter() {
|
||||
@Override
|
||||
public String getOutExtension()
|
||||
{
|
||||
public String getOutExtension() {
|
||||
return "iob";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInExtension()
|
||||
{
|
||||
public String getInExtension() {
|
||||
return "schematic";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(File in, File out)
|
||||
{
|
||||
public void convert(File in, File out) {
|
||||
SKConversion.convertSchematic(in, out);
|
||||
}
|
||||
});
|
||||
@@ -81,13 +70,11 @@ public class ConversionManager
|
||||
}, 5);
|
||||
}
|
||||
|
||||
private String toPoolName(String poolReference)
|
||||
{
|
||||
private String toPoolName(String poolReference) {
|
||||
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<>();
|
||||
KList<File> roots = new KList<>();
|
||||
AtomicInteger total = new AtomicInteger(0);
|
||||
@@ -96,16 +83,13 @@ public class ConversionManager
|
||||
destPools.mkdirs();
|
||||
findAllNBT(in, (folder, file) -> {
|
||||
total.getAndIncrement();
|
||||
if(roots.addIfMissing(folder))
|
||||
{
|
||||
if (roots.addIfMissing(folder)) {
|
||||
String b = in.toURI().relativize(folder.toURI()).getPath();
|
||||
if(b.startsWith("/"))
|
||||
{
|
||||
if (b.startsWith("/")) {
|
||||
b = b.substring(1);
|
||||
}
|
||||
|
||||
if(b.endsWith("/"))
|
||||
{
|
||||
if (b.endsWith("/")) {
|
||||
b = b.substring(0, b.length() - 1);
|
||||
}
|
||||
|
||||
@@ -115,13 +99,11 @@ public class ConversionManager
|
||||
findAllNBT(in, (folder, file) -> {
|
||||
at.getAndIncrement();
|
||||
String b = in.toURI().relativize(folder.toURI()).getPath();
|
||||
if(b.startsWith("/"))
|
||||
{
|
||||
if (b.startsWith("/")) {
|
||||
b = b.substring(1);
|
||||
}
|
||||
|
||||
if(b.endsWith("/"))
|
||||
{
|
||||
if (b.endsWith("/")) {
|
||||
b = b.substring(0, b.length() - 1);
|
||||
}
|
||||
IrisJigsawPool jpool = pools.get(b);
|
||||
@@ -134,8 +116,7 @@ public class ConversionManager
|
||||
NamedTag tag = NBTUtil.read(file);
|
||||
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];
|
||||
ListTag<IntTag> size = (ListTag<IntTag>) compound.getListTag("size");
|
||||
int w = size.get(0).asInt();
|
||||
@@ -143,16 +124,14 @@ public class ConversionManager
|
||||
int d = size.get(2).asInt();
|
||||
KList<BlockData> palette = new KList<>();
|
||||
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);
|
||||
palette.add(DirectWorldWriter.getBlockData(cp));
|
||||
}
|
||||
IrisJigsawPiece piece = new IrisJigsawPiece();
|
||||
IrisObject object = new IrisObject(w, h, d);
|
||||
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);
|
||||
ListTag<IntTag> pos = (ListTag<IntTag>) cp.getListTag("pos");
|
||||
int x = pos.get(0).asInt();
|
||||
@@ -160,8 +139,7 @@ public class ConversionManager
|
||||
int z = pos.get(2).asInt();
|
||||
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]);
|
||||
IrisPosition spos = new IrisPosition(object.getSigned(x, y, z));
|
||||
CompoundTag nbt = cp.getCompoundTag("nbt");
|
||||
@@ -183,16 +161,14 @@ public class ConversionManager
|
||||
connector.getPools().add(poolId);
|
||||
connector.setDirection(IrisDirection.getDirection(((Jigsaw) jd).getOrientation()));
|
||||
|
||||
if(target.equals("minecraft:building_entrance"))
|
||||
{
|
||||
if (target.equals("minecraft:building_entrance")) {
|
||||
connector.setInnerConnector(true);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -207,8 +183,7 @@ public class ConversionManager
|
||||
}
|
||||
});
|
||||
|
||||
for(String i : pools.k())
|
||||
{
|
||||
for (String i : pools.k()) {
|
||||
try {
|
||||
IO.writeAll(new File(destPools, i + ".json"), new JSONObject(new Gson().toJson(pools.get(i))).toString(4));
|
||||
} catch (IOException e) {
|
||||
@@ -219,44 +194,32 @@ public class ConversionManager
|
||||
Iris.info("Done! Exported " + Form.f((total.get() * 2) + pools.size()) + " Files!");
|
||||
}
|
||||
|
||||
public void findAllNBT(File path, Consumer2<File, File> inFile)
|
||||
{
|
||||
if(path == null)
|
||||
{
|
||||
public void findAllNBT(File path, Consumer2<File, File> inFile) {
|
||||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(path.isFile() && path.getName().endsWith(".nbt"))
|
||||
{
|
||||
if (path.isFile() && path.getName().endsWith(".nbt")) {
|
||||
inFile.accept(path.getParentFile(), path);
|
||||
return;
|
||||
}
|
||||
|
||||
for(File i : path.listFiles())
|
||||
{
|
||||
if(i.isDirectory())
|
||||
{
|
||||
for (File i : path.listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
findAllNBT(i, inFile);
|
||||
}
|
||||
|
||||
else if(i.isFile() && i.getName().endsWith(".nbt"))
|
||||
{
|
||||
} else if (i.isFile() && i.getName().endsWith(".nbt")) {
|
||||
inFile.accept(path, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void check(MortarSender s)
|
||||
{
|
||||
public void check(MortarSender s) {
|
||||
int m = 0;
|
||||
Iris.instance.getDataFolder("convert");
|
||||
|
||||
for(File i : folder.listFiles())
|
||||
{
|
||||
for(Converter j : converters)
|
||||
{
|
||||
if(i.getName().endsWith("." + j.getInExtension()))
|
||||
{
|
||||
for (File i : folder.listFiles()) {
|
||||
for (Converter j : converters) {
|
||||
if (i.getName().endsWith("." + j.getInExtension())) {
|
||||
File out = new File(folder, i.getName().replaceAll("\\Q." + j.getInExtension() + "\\E", "." + j.getOutExtension()));
|
||||
m++;
|
||||
j.convert(i, out);
|
||||
@@ -267,8 +230,7 @@ public class ConversionManager
|
||||
if (i.isDirectory() && i.getName().equals("structures")) {
|
||||
File f = new File(folder, "jigsaw");
|
||||
|
||||
if (!f.exists())
|
||||
{
|
||||
if (!f.exists()) {
|
||||
s.sendMessage("Converting NBT Structures into Iris Jigsaw Structures...");
|
||||
f.mkdirs();
|
||||
J.a(() -> convertStructures(i, f, s));
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
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.IrisSettings;
|
||||
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.util.KMap;
|
||||
import com.volmit.iris.util.M;
|
||||
|
||||
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
|
||||
{
|
||||
private KMap<World, BlockEditor> editors;
|
||||
public class EditManager implements Listener {
|
||||
private final KMap<World, BlockEditor> editors;
|
||||
|
||||
public EditManager()
|
||||
{
|
||||
public EditManager() {
|
||||
this.editors = new KMap<>();
|
||||
Iris.instance.registerListener(this);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public Biome getBiome(World world, int x, int z)
|
||||
{
|
||||
public Biome getBiome(World world, int x, int z) {
|
||||
return open(world).getBiome(x, z);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(WorldUnloadEvent e)
|
||||
{
|
||||
if(editors.containsKey(e.getWorld()))
|
||||
{
|
||||
public void on(WorldUnloadEvent e) {
|
||||
if (editors.containsKey(e.getWorld())) {
|
||||
editors.remove(e.getWorld()).close();
|
||||
}
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
for(World i : editors.k())
|
||||
{
|
||||
if(M.ms() - editors.get(i).last() > 1000)
|
||||
{
|
||||
public void update() {
|
||||
for (World i : editors.k()) {
|
||||
if (M.ms() - editors.get(i).last() > 1000) {
|
||||
editors.remove(i).close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void flushNow()
|
||||
{
|
||||
for(World i : editors.k())
|
||||
{
|
||||
public void flushNow() {
|
||||
for (World i : editors.k()) {
|
||||
editors.remove(i).close();
|
||||
}
|
||||
}
|
||||
|
||||
public BlockEditor open(World world)
|
||||
{
|
||||
if(editors.containsKey(world))
|
||||
{
|
||||
public BlockEditor open(World world) {
|
||||
if (editors.containsKey(world)) {
|
||||
return editors.get(world);
|
||||
}
|
||||
|
||||
BlockEditor e = null;
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("WorldEdit") && !PaperLib.isPaper() && !IrisSettings.get().getGeneral().isIgnoreWorldEdit())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit") && !PaperLib.isPaper() && !IrisSettings.get().getGeneral().isIgnoreWorldEdit()) {
|
||||
try {
|
||||
e = new WEBlockEditor(world);
|
||||
}
|
||||
|
||||
catch(Throwable ex)
|
||||
{
|
||||
} catch (Throwable ex) {
|
||||
e = new BukkitBlockEditor(world);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
e = new BukkitBlockEditor(world);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,18 +13,16 @@ import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IrisBoardManager implements BoardProvider, Listener
|
||||
{
|
||||
public class IrisBoardManager implements BoardProvider, Listener {
|
||||
@DontObfuscate
|
||||
private BoardManager manager;
|
||||
private final BoardManager manager;
|
||||
private String mem = "...";
|
||||
public RollingSequence hits = new RollingSequence(20);
|
||||
public RollingSequence tp = new RollingSequence(100);
|
||||
private ChronoLatch cl = new ChronoLatch(1000);
|
||||
private final ChronoLatch cl = new ChronoLatch(1000);
|
||||
|
||||
@DontObfuscate
|
||||
public IrisBoardManager()
|
||||
{
|
||||
public IrisBoardManager() {
|
||||
Iris.instance.registerListener(this);
|
||||
//@builder
|
||||
manager = new BoardManager(Iris.instance, BoardSettings.builder()
|
||||
@@ -35,52 +33,41 @@ public class IrisBoardManager implements BoardProvider, Listener
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(PlayerChangedWorldEvent e)
|
||||
{
|
||||
public void on(PlayerChangedWorldEvent e) {
|
||||
J.s(() -> updatePlayer(e.getPlayer()));
|
||||
}
|
||||
|
||||
@DontObfuscate
|
||||
private boolean isIrisWorld(World w)
|
||||
{
|
||||
private boolean isIrisWorld(World w) {
|
||||
return IrisWorlds.isIrisWorld(w) && IrisWorlds.access(w).isStudio();
|
||||
}
|
||||
|
||||
public void updatePlayer(Player p)
|
||||
{
|
||||
if(isIrisWorld(p.getWorld()))
|
||||
{
|
||||
public void updatePlayer(Player p) {
|
||||
if (isIrisWorld(p.getWorld())) {
|
||||
manager.remove(p);
|
||||
manager.setup(p);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
manager.remove(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(Player player)
|
||||
{
|
||||
public String getTitle(Player player) {
|
||||
return C.GREEN + "Iris";
|
||||
}
|
||||
|
||||
@DontObfuscate
|
||||
@Override
|
||||
public List<String> getLines(Player player)
|
||||
{
|
||||
public List<String> getLines(Player player) {
|
||||
KList<String> v = new KList<>();
|
||||
|
||||
if(!isIrisWorld(player.getWorld()))
|
||||
{
|
||||
if (!isIrisWorld(player.getWorld())) {
|
||||
return v;
|
||||
}
|
||||
|
||||
IrisAccess g = IrisWorlds.access(player.getWorld());
|
||||
|
||||
if(cl.flip())
|
||||
{
|
||||
if (cl.flip()) {
|
||||
// TODO MEMORY
|
||||
mem = Form.memSize(0, 2);
|
||||
}
|
||||
@@ -96,8 +83,7 @@ public class IrisBoardManager implements BoardProvider, Listener
|
||||
long memoryGuess = 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();
|
||||
parallaxChunks += g.getCompound().getEngine(i).getParallax().getChunkCount();
|
||||
loadedObjects += g.getCompound().getData().getObjectLoader().getSize();
|
||||
@@ -109,13 +95,11 @@ public class IrisBoardManager implements BoardProvider, Listener
|
||||
tp.put(0); // TODO: CHUNK SPEED
|
||||
|
||||
|
||||
|
||||
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 + "Memory Use" + C.GRAY + ": ~" + Form.memSize(memoryGuess, 0));
|
||||
|
||||
if(engine != null)
|
||||
{
|
||||
if (engine != null) {
|
||||
v.add("&7&m------------------");
|
||||
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());
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
if(Iris.jobCount() > 0)
|
||||
{
|
||||
if (Iris.jobCount() > 0) {
|
||||
v.add("&7&m------------------");
|
||||
v.add(C.LIGHT_PURPLE + "Tasks" + C.GRAY + ": " + Iris.jobCount());
|
||||
}
|
||||
@@ -136,8 +119,7 @@ public class IrisBoardManager implements BoardProvider, Listener
|
||||
}
|
||||
|
||||
@DontObfuscate
|
||||
public void disable()
|
||||
{
|
||||
public void disable() {
|
||||
manager.onDisable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,7 @@ import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Data
|
||||
public class IrisDataManager
|
||||
{
|
||||
public class IrisDataManager {
|
||||
private ResourceLoader<IrisBiome> biomeLoader;
|
||||
private ResourceLoader<IrisLootTable> lootLoader;
|
||||
private ResourceLoader<IrisRegion> regionLoader;
|
||||
@@ -29,21 +28,18 @@ public class IrisDataManager
|
||||
private final File dataFolder;
|
||||
private final int id;
|
||||
|
||||
public IrisDataManager(File dataFolder)
|
||||
{
|
||||
public IrisDataManager(File dataFolder) {
|
||||
this(dataFolder, false);
|
||||
}
|
||||
|
||||
public IrisDataManager(File dataFolder, boolean oneshot)
|
||||
{
|
||||
public IrisDataManager(File dataFolder, boolean oneshot) {
|
||||
this.dataFolder = dataFolder;
|
||||
this.id = RNG.r.imax();
|
||||
closed = false;
|
||||
hotloaded();
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
public void close() {
|
||||
closed = true;
|
||||
dump();
|
||||
this.lootLoader = null;
|
||||
@@ -59,8 +55,7 @@ public class IrisDataManager
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -68,10 +63,8 @@ public class IrisDataManager
|
||||
return new IrisDataManager(dataFolder);
|
||||
}
|
||||
|
||||
public void hotloaded()
|
||||
{
|
||||
if(closed)
|
||||
{
|
||||
public void hotloaded() {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,10 +83,8 @@ public class IrisDataManager
|
||||
this.objectLoader = new ObjectResourceLoader(packs, this, "objects", "Object");
|
||||
}
|
||||
|
||||
public void dump()
|
||||
{
|
||||
if(closed)
|
||||
{
|
||||
public void dump() {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
biomeLoader.clearCache();
|
||||
@@ -109,10 +100,8 @@ public class IrisDataManager
|
||||
generatorLoader.clearCache();
|
||||
}
|
||||
|
||||
public void clearLists()
|
||||
{
|
||||
if(closed)
|
||||
{
|
||||
public void clearLists() {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -129,81 +118,63 @@ public class IrisDataManager
|
||||
objectLoader.clearList();
|
||||
}
|
||||
|
||||
public static IrisObject loadAnyObject(String key)
|
||||
{
|
||||
public static IrisObject loadAnyObject(String key) {
|
||||
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));
|
||||
}
|
||||
|
||||
public static IrisJigsawPiece loadAnyJigsawPiece(String key)
|
||||
{
|
||||
public static IrisJigsawPiece loadAnyJigsawPiece(String key) {
|
||||
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));
|
||||
}
|
||||
|
||||
public static IrisEntity loadAnyEntity(String key)
|
||||
{
|
||||
public static IrisEntity loadAnyEntity(String key) {
|
||||
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));
|
||||
}
|
||||
|
||||
public static IrisBlockData loadAnyBlock(String key)
|
||||
{
|
||||
public static IrisBlockData loadAnyBlock(String key) {
|
||||
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));
|
||||
}
|
||||
|
||||
public static IrisDimension loadAnyDimension(String key)
|
||||
{
|
||||
public static IrisDimension loadAnyDimension(String key) {
|
||||
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));
|
||||
}
|
||||
|
||||
public static IrisGenerator loadAnyGenerator(String key)
|
||||
{
|
||||
public static IrisGenerator loadAnyGenerator(String key) {
|
||||
return loadAny(key, (dm) -> dm.getGeneratorLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static <T extends IrisRegistrant> T loadAny(String key, Function<IrisDataManager, T> v) {
|
||||
try
|
||||
{
|
||||
for(File i : Objects.requireNonNull(Iris.instance.getDataFolder("packs").listFiles()))
|
||||
{
|
||||
if(i.isDirectory())
|
||||
{
|
||||
try {
|
||||
for (File i : Objects.requireNonNull(Iris.instance.getDataFolder("packs").listFiles())) {
|
||||
if (i.isDirectory()) {
|
||||
IrisDataManager dm = new IrisDataManager(i, true);
|
||||
T t = v.apply(dm);
|
||||
|
||||
if(t != null)
|
||||
{
|
||||
if (t != null) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,25 +24,21 @@ import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class IrisProject
|
||||
{
|
||||
public class IrisProject {
|
||||
private File path;
|
||||
private String name;
|
||||
private IrisAccess activeProvider;
|
||||
|
||||
public IrisProject(File path)
|
||||
{
|
||||
public IrisProject(File path) {
|
||||
this.path = path;
|
||||
this.name = path.getName();
|
||||
}
|
||||
|
||||
public KList<Report> scanForErrors()
|
||||
{
|
||||
public KList<Report> scanForErrors() {
|
||||
KList<Report> reports = new KList<>();
|
||||
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);
|
||||
IrisDimension dim = e.getDimension();
|
||||
reports.add(scanForErrors(dim));
|
||||
@@ -54,8 +50,7 @@ public class IrisProject
|
||||
private KList<Report> scanForErrors(IrisDimension dim) {
|
||||
KList<Report> reports = new KList<>();
|
||||
|
||||
if(dim.getFocus() != null && !dim.getFocus().isEmpty())
|
||||
{
|
||||
if (dim.getFocus() != null && !dim.getFocus().isEmpty()) {
|
||||
reports.add(Report.builder()
|
||||
.type(ReportType.NOTICE)
|
||||
.title("Focus Mode is Enabled")
|
||||
@@ -64,8 +59,7 @@ public class IrisProject
|
||||
.build());
|
||||
}
|
||||
|
||||
for(IrisRegion i : dim.getAllRegions(getActiveProvider()))
|
||||
{
|
||||
for (IrisRegion i : dim.getAllRegions(getActiveProvider())) {
|
||||
scanForErrors(i);
|
||||
}
|
||||
|
||||
@@ -75,8 +69,7 @@ public class IrisProject
|
||||
private KList<Report> scanForErrors(IrisRegion region) {
|
||||
KList<Report> reports = new KList<>();
|
||||
|
||||
if(region.getRarity() > 60)
|
||||
{
|
||||
if (region.getRarity() > 60) {
|
||||
reports.add(Report.builder()
|
||||
.type(ReportType.WARNING)
|
||||
.title("Region " + region.getName() + " has a rarity of " + region.getRarity())
|
||||
@@ -85,8 +78,7 @@ public class IrisProject
|
||||
.build());
|
||||
}
|
||||
|
||||
for(IrisBiome i : region.getAllBiomes(getActiveProvider()))
|
||||
{
|
||||
for (IrisBiome i : region.getAllBiomes(getActiveProvider())) {
|
||||
reports.add(scanForErrors(i));
|
||||
}
|
||||
|
||||
@@ -96,18 +88,15 @@ public class IrisProject
|
||||
private KList<Report> scanForErrors(IrisBiome biome) {
|
||||
KList<Report> reports = new KList<>();
|
||||
|
||||
for(IrisObjectPlacement i : biome.getObjects())
|
||||
{
|
||||
for (IrisObjectPlacement i : biome.getObjects()) {
|
||||
reports.add(scanForErrors(biome, i));
|
||||
}
|
||||
|
||||
for(IrisBiomePaletteLayer i : biome.getLayers())
|
||||
{
|
||||
for (IrisBiomePaletteLayer i : biome.getLayers()) {
|
||||
reports.add(scanForErrors(biome, i));
|
||||
}
|
||||
|
||||
for(IrisBiomePaletteLayer i : biome.getSeaLayers())
|
||||
{
|
||||
for (IrisBiomePaletteLayer i : biome.getSeaLayers()) {
|
||||
reports.add(scanForErrorsSeaLayers(biome, i));
|
||||
}
|
||||
|
||||
@@ -132,25 +121,18 @@ public class IrisProject
|
||||
return reports;
|
||||
}
|
||||
|
||||
public boolean isOpen()
|
||||
{
|
||||
public boolean isOpen() {
|
||||
return activeProvider != null;
|
||||
}
|
||||
|
||||
public KList<File> collectFiles(File f, String json)
|
||||
{
|
||||
public KList<File> collectFiles(File f, String json) {
|
||||
KList<File> l = new KList<>();
|
||||
|
||||
if(f.isDirectory())
|
||||
{
|
||||
for(File i : f.listFiles())
|
||||
{
|
||||
if (f.isDirectory()) {
|
||||
for (File i : f.listFiles()) {
|
||||
l.addAll(collectFiles(i, json));
|
||||
}
|
||||
}
|
||||
|
||||
else if(f.getName().endsWith("."+json))
|
||||
{
|
||||
} else if (f.getName().endsWith("." + json)) {
|
||||
l.add(f);
|
||||
}
|
||||
|
||||
@@ -161,23 +143,19 @@ public class IrisProject
|
||||
return collectFiles(path, json);
|
||||
}
|
||||
|
||||
public void open(MortarSender sender)
|
||||
{
|
||||
public void open(MortarSender sender) {
|
||||
open(sender, () ->
|
||||
{
|
||||
});
|
||||
}
|
||||
|
||||
public void open(MortarSender sender, Runnable onDone)
|
||||
{
|
||||
if(isOpen())
|
||||
{
|
||||
public void open(MortarSender sender, Runnable onDone) {
|
||||
if (isOpen()) {
|
||||
close();
|
||||
}
|
||||
|
||||
IrisDimension d = IrisDataManager.loadAnyDimension(getName());
|
||||
if(d == null)
|
||||
{
|
||||
if (d == null) {
|
||||
sender.sendMessage("Can't find dimension: " + getName());
|
||||
return;
|
||||
} else if (sender.isPlayer()) {
|
||||
@@ -187,18 +165,15 @@ public class IrisProject
|
||||
|
||||
J.attemptAsync(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
if (d.getLoader() == null) {
|
||||
sender.sendMessage("Could not get dimension loader");
|
||||
return;
|
||||
}
|
||||
File f = d.getLoader().getDataFolder();
|
||||
boolean foundWork = false;
|
||||
for(File i : Objects.requireNonNull(f.listFiles()))
|
||||
{
|
||||
if(i.getName().endsWith(".code-workspace"))
|
||||
{
|
||||
for (File i : Objects.requireNonNull(f.listFiles())) {
|
||||
if (i.getName().endsWith(".code-workspace")) {
|
||||
foundWork = true;
|
||||
sender.sendMessage("Updating Workspace...");
|
||||
J.a(() ->
|
||||
@@ -207,8 +182,7 @@ public class IrisProject
|
||||
sender.sendMessage("Workspace Updated");
|
||||
});
|
||||
|
||||
if(IrisSettings.get().getStudio().isOpenVSCode())
|
||||
{
|
||||
if (IrisSettings.get().getStudio().isOpenVSCode()) {
|
||||
if (!GraphicsEnvironment.isHeadless()) {
|
||||
Iris.msg("Opening VSCode. You may see the output from VSCode.");
|
||||
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");
|
||||
Iris.warn("Project missing code-workspace: " + ff.getAbsolutePath() + " Re-creating code workspace.");
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
IO.writeAll(ff, createCodeWorkspaceConfig());
|
||||
}
|
||||
|
||||
catch(IOException e1)
|
||||
{
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
sender.sendMessage("Updating Workspace...");
|
||||
updateWorkspace();
|
||||
sender.sendMessage("Workspace Updated");
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
@@ -267,8 +233,7 @@ public class IrisProject
|
||||
double lpc = 0;
|
||||
boolean fc;
|
||||
|
||||
while(!done.get())
|
||||
{
|
||||
while (!done.get()) {
|
||||
boolean derp = false;
|
||||
|
||||
assert gx != null;
|
||||
@@ -276,19 +241,14 @@ public class IrisProject
|
||||
fc = lpc != v;
|
||||
lpc = v;
|
||||
|
||||
if(last > v || v > 1)
|
||||
{
|
||||
if (last > v || v > 1) {
|
||||
derp = true;
|
||||
v = last;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
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)")));
|
||||
}
|
||||
|
||||
@@ -298,8 +258,7 @@ public class IrisProject
|
||||
|
||||
J.sleep(1500);
|
||||
|
||||
if(gx.isFailing())
|
||||
{
|
||||
if (gx.isFailing()) {
|
||||
|
||||
sender.sendMessage("Generation Failed!");
|
||||
return;
|
||||
@@ -319,8 +278,7 @@ public class IrisProject
|
||||
done.set(true);
|
||||
sender.sendMessage(C.WHITE + "Generating Complete!");
|
||||
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
if (sender.isPlayer()) {
|
||||
assert world != null;
|
||||
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!");
|
||||
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
if (sender.isPlayer()) {
|
||||
sender.player().setGameMode(GameMode.SPECTATOR);
|
||||
}
|
||||
|
||||
@@ -338,8 +295,7 @@ public class IrisProject
|
||||
}, 0);
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
public void close() {
|
||||
activeProvider.close();
|
||||
File folder = activeProvider.getTarget().getWorld().getWorldFolder();
|
||||
Iris.linkMultiverseCore.removeFromConfig(activeProvider.getTarget().getWorld().getName());
|
||||
@@ -348,18 +304,15 @@ public class IrisProject
|
||||
activeProvider = null;
|
||||
}
|
||||
|
||||
public File getCodeWorkspaceFile()
|
||||
{
|
||||
public File getCodeWorkspaceFile() {
|
||||
return new File(path, getName() + ".code-workspace");
|
||||
}
|
||||
|
||||
public boolean updateWorkspace()
|
||||
{
|
||||
public boolean updateWorkspace() {
|
||||
getPath().mkdirs();
|
||||
File ws = getCodeWorkspaceFile();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Iris.info("Building Workspace: " + ws.getPath());
|
||||
JSONObject j = createCodeWorkspaceConfig();
|
||||
@@ -367,19 +320,12 @@ public class IrisProject
|
||||
p.end();
|
||||
Iris.info("Building Workspace: " + ws.getPath() + " took " + Form.duration(p.getMilliseconds(), 2));
|
||||
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!");
|
||||
ws.delete();
|
||||
try
|
||||
{
|
||||
try {
|
||||
IO.writeAll(ws, createCodeWorkspaceConfig());
|
||||
}
|
||||
|
||||
catch(IOException e1)
|
||||
{
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -387,8 +333,7 @@ public class IrisProject
|
||||
return false;
|
||||
}
|
||||
|
||||
public JSONObject createCodeWorkspaceConfig()
|
||||
{
|
||||
public JSONObject createCodeWorkspaceConfig() {
|
||||
JSONObject ws = new JSONObject();
|
||||
JSONArray folders = new JSONArray();
|
||||
JSONObject folder = new JSONObject();
|
||||
@@ -436,8 +381,7 @@ public class IrisProject
|
||||
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]);
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("fileMatch", new JSONArray(fileMatch));
|
||||
@@ -446,8 +390,7 @@ public class IrisProject
|
||||
return o;
|
||||
}
|
||||
|
||||
public File compilePackage(MortarSender sender, boolean obfuscate, boolean minify)
|
||||
{
|
||||
public File compilePackage(MortarSender sender, boolean obfuscate, boolean minify) {
|
||||
String dimm = getName();
|
||||
IrisDataManager dm = new IrisDataManager(path);
|
||||
IrisDimension dimension = dm.getDimensionLoader().load(dimm);
|
||||
@@ -461,8 +404,7 @@ public class IrisProject
|
||||
KSet<IrisLootTable> loot = 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));
|
||||
}
|
||||
|
||||
@@ -485,17 +427,13 @@ public class IrisProject
|
||||
StringBuilder c = new StringBuilder();
|
||||
sender.sendMessage("Serializing Objects");
|
||||
|
||||
for(IrisBiome i : biomes)
|
||||
{
|
||||
for(IrisObjectPlacement j : i.getObjects())
|
||||
{
|
||||
for (IrisBiome i : biomes) {
|
||||
for (IrisObjectPlacement j : i.getObjects()) {
|
||||
b.append(j.hashCode());
|
||||
KList<String> newNames = new KList<>();
|
||||
|
||||
for(String k : j.getPlace())
|
||||
{
|
||||
if(renameObjects.containsKey(k))
|
||||
{
|
||||
for (String k : j.getPlace()) {
|
||||
if (renameObjects.containsKey(k)) {
|
||||
newNames.add(renameObjects.get(k));
|
||||
continue;
|
||||
}
|
||||
@@ -510,17 +448,13 @@ public class IrisProject
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisBiomeMutation i : dimension.getMutations())
|
||||
{
|
||||
for(IrisObjectPlacement j : i.getObjects())
|
||||
{
|
||||
for (IrisBiomeMutation i : dimension.getMutations()) {
|
||||
for (IrisObjectPlacement j : i.getObjects()) {
|
||||
b.append(j.hashCode());
|
||||
KList<String> newNames = new KList<>();
|
||||
|
||||
for(String k : j.getPlace())
|
||||
{
|
||||
if(renameObjects.containsKey(k))
|
||||
{
|
||||
for (String k : j.getPlace()) {
|
||||
if (renameObjects.containsKey(k)) {
|
||||
newNames.add(renameObjects.get(k));
|
||||
continue;
|
||||
}
|
||||
@@ -542,46 +476,36 @@ public class IrisProject
|
||||
ggg.set(0);
|
||||
biomes.forEach((i) -> i.getObjects().forEach((j) -> j.getPlace().forEach((k) ->
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
File f = dm.getObjectLoader().findFile(lookupObjects.get(k).get(0));
|
||||
IO.copyFile(f, new File(folder, "objects/" + k + ".iob"));
|
||||
gb.append(IO.hash(f));
|
||||
ggg.set(ggg.get() + 1);
|
||||
|
||||
if(cl.flip())
|
||||
{
|
||||
if (cl.flip()) {
|
||||
int g = ggg.get();
|
||||
ggg.set(0);
|
||||
sender.sendMessage("Wrote another " + g + " Objects");
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
})));
|
||||
|
||||
dimension.getMutations().forEach((i) -> i.getObjects().forEach((j) -> j.getPlace().forEach((k) ->
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
File f = dm.getObjectLoader().findFile(lookupObjects.get(k).get(0));
|
||||
IO.copyFile(f, new File(folder, "objects/" + k + ".iob"));
|
||||
gb.append(IO.hash(f));
|
||||
ggg.set(ggg.get() + 1);
|
||||
|
||||
if(cl.flip())
|
||||
{
|
||||
if (cl.flip()) {
|
||||
int g = ggg.get();
|
||||
ggg.set(0);
|
||||
sender.sendMessage("Wrote another " + g + " Objects");
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
})));
|
||||
@@ -592,14 +516,12 @@ public class IrisProject
|
||||
|
||||
Iris.info("Writing Dimensional Scaffold");
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
a = new JSONObject(new Gson().toJson(dimension)).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "dimensions/" + dimension.getLoadKey() + ".json"), 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);
|
||||
IO.writeAll(new File(folder, "generators/" + i.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
@@ -608,36 +530,31 @@ public class IrisProject
|
||||
c.append(IO.hash(b.toString()));
|
||||
b = new StringBuilder();
|
||||
|
||||
for(IrisRegion i : regions)
|
||||
{
|
||||
for (IrisRegion i : regions) {
|
||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "regions/" + i.getLoadKey() + ".json"), 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);
|
||||
IO.writeAll(new File(folder, "blocks/" + i.getLoadKey() + ".json"), 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);
|
||||
IO.writeAll(new File(folder, "biomes/" + i.getLoadKey() + ".json"), 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);
|
||||
IO.writeAll(new File(folder, "entities/" + i.getLoadKey() + ".json"), 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);
|
||||
IO.writeAll(new File(folder, "loot/" + i.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
@@ -657,10 +574,7 @@ public class IrisProject
|
||||
|
||||
sender.sendMessage("Package Compiled!");
|
||||
return p;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
sender.sendMessage("Failed!");
|
||||
|
||||
@@ -8,47 +8,34 @@ import com.volmit.iris.object.IrisDimension;
|
||||
import com.volmit.iris.scaffold.cache.AtomicCache;
|
||||
import com.volmit.iris.util.*;
|
||||
import lombok.Data;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
import org.zeroturnaround.zip.commons.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@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 WORKSPACE_NAME = "packs";
|
||||
private KMap<String, String> cacheListing = null;
|
||||
private IrisProject activeProject;
|
||||
private static final AtomicCache<Integer> counter = new AtomicCache<>();
|
||||
|
||||
public ProjectManager()
|
||||
{
|
||||
if(IrisSettings.get().isStudio())
|
||||
{
|
||||
public ProjectManager() {
|
||||
if (IrisSettings.get().isStudio()) {
|
||||
J.a(() ->
|
||||
{
|
||||
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");
|
||||
if(m != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m != null) {
|
||||
try {
|
||||
IO.copyFile(m, ignore);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -61,27 +48,17 @@ public class ProjectManager
|
||||
int vv = counter.aquire(() -> {
|
||||
int v = 0;
|
||||
|
||||
try
|
||||
{
|
||||
for(File i : Iris.instance.getDataFolder(WORKSPACE_NAME).listFiles())
|
||||
{
|
||||
try
|
||||
{
|
||||
if(i.isDirectory() && i.list().length > 0 && !Iris.proj.getListing(true).keySet().contains(i.getName()))
|
||||
{
|
||||
try {
|
||||
for (File i : Iris.instance.getDataFolder(WORKSPACE_NAME).listFiles()) {
|
||||
try {
|
||||
if (i.isDirectory() && i.list().length > 0 && !Iris.proj.getListing(true).containsKey(i.getName())) {
|
||||
v++;
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
@@ -91,73 +68,48 @@ public class ProjectManager
|
||||
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);
|
||||
File iris = new File(folder, "iris");
|
||||
File irispack = new File(folder, "iris/pack");
|
||||
IrisDimension dim = IrisDataManager.loadAnyDimension(type);
|
||||
|
||||
if(dim == null)
|
||||
{
|
||||
for(File i : Iris.proj.getWorkspaceFolder().listFiles())
|
||||
{
|
||||
if(i.isFile() && i.getName().equals(type + ".iris"))
|
||||
{
|
||||
if (dim == null) {
|
||||
for (File i : Iris.proj.getWorkspaceFolder().listFiles()) {
|
||||
if (i.isFile() && i.getName().equals(type + ".iris")) {
|
||||
sender.sendMessage("Found " + type + ".iris in " + ProjectManager.WORKSPACE_NAME + " folder");
|
||||
ZipUtil.unpack(i, irispack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sender.sendMessage("Found " + type + " dimension in " + ProjectManager.WORKSPACE_NAME + " folder. Repackaging");
|
||||
File f = new IrisProject(new File(getWorkspaceFolder(), type)).getPath();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
FileUtils.copyDirectory(f, irispack);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File dimf = new File(irispack, "dimensions/" + type + ".json");
|
||||
|
||||
if(!dimf.exists() || !dimf.isFile())
|
||||
{
|
||||
if (!dimf.exists() || !dimf.isFile()) {
|
||||
Iris.proj.downloadSearch(sender, type, false);
|
||||
File downloaded = Iris.proj.getWorkspaceFolder(type);
|
||||
|
||||
for(File i : downloaded.listFiles())
|
||||
{
|
||||
if(i.isFile())
|
||||
{
|
||||
try
|
||||
{
|
||||
for (File i : downloaded.listFiles()) {
|
||||
if (i.isFile()) {
|
||||
try {
|
||||
FileUtils.copyFile(i, new File(irispack, i.getName()));
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
} else {
|
||||
try {
|
||||
FileUtils.copyDirectory(i, new File(irispack, i.getName()));
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -166,8 +118,7 @@ public class ProjectManager
|
||||
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!");
|
||||
return null;
|
||||
}
|
||||
@@ -175,8 +126,7 @@ public class ProjectManager
|
||||
IrisDataManager dm = new IrisDataManager(irispack);
|
||||
dim = dm.getDimensionLoader().load(type);
|
||||
|
||||
if(dim == null)
|
||||
{
|
||||
if (dim == null) {
|
||||
sender.sendMessage("Can't load the dimension! Failed!");
|
||||
return null;
|
||||
}
|
||||
@@ -185,17 +135,14 @@ public class ProjectManager
|
||||
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);
|
||||
}
|
||||
|
||||
public void downloadSearch(MortarSender sender, String key, boolean trim, boolean forceOverwrite)
|
||||
{
|
||||
public void downloadSearch(MortarSender sender, String key, boolean trim, boolean forceOverwrite) {
|
||||
String url = "?";
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
url = getListing(false).get(key);
|
||||
url = url == null ? key : url;
|
||||
Iris.info("Assuming URL " + url);
|
||||
@@ -204,22 +151,17 @@ public class ProjectManager
|
||||
String repo = nodes[0] + "/" + nodes[1];
|
||||
branch = nodes.length > 2 ? nodes[2] : branch;
|
||||
download(sender, repo, branch, trim, forceOverwrite);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
sender.sendMessage("Downloading " + url);
|
||||
File zip = Iris.getNonCachedFile("pack-" + trim + "-" + repo, url);
|
||||
@@ -255,16 +197,14 @@ public class ProjectManager
|
||||
return;
|
||||
}
|
||||
|
||||
if(dir == null)
|
||||
{
|
||||
if (dir == null) {
|
||||
sender.sendMessage("Invalid Format. Missing root folder or too many folders!");
|
||||
return;
|
||||
}
|
||||
|
||||
File dimensions = new File(dir, "dimensions");
|
||||
|
||||
if(!(dimensions.exists() && dimensions.isDirectory()))
|
||||
{
|
||||
if (!(dimensions.exists() && dimensions.isDirectory())) {
|
||||
sender.sendMessage("Invalid Format. Missing dimensions folder");
|
||||
return;
|
||||
}
|
||||
@@ -272,17 +212,14 @@ public class ProjectManager
|
||||
if (dimensions.listFiles() == null) {
|
||||
sender.sendMessage("No dimension file found in the extracted zip file.");
|
||||
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");
|
||||
return;
|
||||
}
|
||||
|
||||
File dim = dimensions.listFiles()[0];
|
||||
|
||||
if(!dim.isFile())
|
||||
{
|
||||
if (!dim.isFile()) {
|
||||
sender.sendMessage("Invalid dimension (folder) in dimensions folder");
|
||||
return;
|
||||
}
|
||||
@@ -292,27 +229,23 @@ public class ProjectManager
|
||||
sender.sendMessage("Importing " + d.getName() + " (" + key + ")");
|
||||
File packEntry = new File(packs, key);
|
||||
|
||||
if(forceOverwrite)
|
||||
{
|
||||
if (forceOverwrite) {
|
||||
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!");
|
||||
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!");
|
||||
return;
|
||||
}
|
||||
|
||||
FileUtils.copyDirectory(dir, packEntry);
|
||||
|
||||
if(trim)
|
||||
{
|
||||
if (trim) {
|
||||
sender.sendMessage("Trimming " + key);
|
||||
File cp = compilePackage(sender, key, false, false);
|
||||
IO.delete(packEntry);
|
||||
@@ -323,42 +256,33 @@ public class ProjectManager
|
||||
sender.sendMessage("Successfully Aquired " + d.getName());
|
||||
}
|
||||
|
||||
public KMap<String, String> getListing(boolean cached)
|
||||
{
|
||||
if(cached && cacheListing != null)
|
||||
{
|
||||
public KMap<String, String> getListing(boolean cached) {
|
||||
if (cached && cacheListing != null) {
|
||||
return cacheListing;
|
||||
}
|
||||
|
||||
JSONObject a;
|
||||
|
||||
if(cached)
|
||||
{
|
||||
if (cached) {
|
||||
a = new JSONObject(Iris.getCached("cachedlisting", LISTING));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
a = new JSONObject(Iris.getNonCached(true + "listing", LISTING));
|
||||
}
|
||||
|
||||
KMap<String, String> l = new KMap<>();
|
||||
|
||||
for(String i : a.keySet())
|
||||
{
|
||||
for (String i : a.keySet()) {
|
||||
l.put(i, a.getString(i));
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
public boolean isProjectOpen()
|
||||
{
|
||||
public boolean isProjectOpen() {
|
||||
return activeProject != null && activeProject.isOpen();
|
||||
}
|
||||
|
||||
public void open(MortarSender sender, String dimm)
|
||||
{
|
||||
public void open(MortarSender sender, String dimm) {
|
||||
try {
|
||||
open(sender, dimm, () ->
|
||||
{
|
||||
@@ -371,10 +295,8 @@ public class ProjectManager
|
||||
}
|
||||
}
|
||||
|
||||
public void open(MortarSender sender, String dimm, Runnable onDone)
|
||||
{
|
||||
if(isProjectOpen())
|
||||
{
|
||||
public void open(MortarSender sender, String dimm, Runnable onDone) {
|
||||
if (isProjectOpen()) {
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -383,55 +305,42 @@ public class ProjectManager
|
||||
project.open(sender, onDone);
|
||||
}
|
||||
|
||||
public File getWorkspaceFolder(String... sub)
|
||||
{
|
||||
public File getWorkspaceFolder(String... 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);
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
if(isProjectOpen())
|
||||
{
|
||||
public void close() {
|
||||
if (isProjectOpen()) {
|
||||
activeProject.close();
|
||||
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);
|
||||
}
|
||||
|
||||
public void createFrom(String existingPack, String newName)
|
||||
{
|
||||
public void createFrom(String existingPack, String newName) {
|
||||
File importPack = getWorkspaceFolder(existingPack);
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
FileUtils.copyDirectory(importPack, newPack, new FileFilter()
|
||||
{
|
||||
try {
|
||||
FileUtils.copyDirectory(importPack, newPack, new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname)
|
||||
{
|
||||
public boolean accept(File pathname) {
|
||||
return !pathname.getAbsolutePath().contains(".git");
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -439,94 +348,72 @@ public class ProjectManager
|
||||
File dimFile = new File(importPack, "dimensions/" + existingPack + ".json");
|
||||
File newDimFile = new File(newPack, "dimensions/" + newName + ".json");
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
FileUtils.copyFile(dimFile, newDimFile);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
new File(newPack, "dimensions/" + existingPack + ".json").delete();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
JSONObject json = new JSONObject(IO.readAll(newDimFile));
|
||||
|
||||
if(json.has("name"))
|
||||
{
|
||||
if (json.has("name")) {
|
||||
json.put("name", Form.capitalizeWords(newName.replaceAll("\\Q-\\E", " ")));
|
||||
IO.writeAll(newDimFile, json.toString(4));
|
||||
}
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
} catch (JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
IrisProject p = new IrisProject(getWorkspaceFolder(newName));
|
||||
JSONObject ws = p.createCodeWorkspaceConfig();
|
||||
IO.writeAll(getWorkspaceFile(newName, newName + ".code-workspace"), ws.toString(0));
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
} catch (JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void create(MortarSender sender, String s, String downloadable)
|
||||
{
|
||||
public void create(MortarSender sender, String s, String downloadable) {
|
||||
boolean shouldDelete = false;
|
||||
File importPack = getWorkspaceFolder(downloadable);
|
||||
|
||||
if(importPack.listFiles().length == 0)
|
||||
{
|
||||
if (importPack.listFiles().length == 0) {
|
||||
downloadSearch(sender, downloadable, false);
|
||||
|
||||
if(importPack.listFiles().length > 0)
|
||||
{
|
||||
if (importPack.listFiles().length > 0) {
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
|
||||
File importDimensionFile = new File(importPack, "dimensions/" + downloadable + ".json");
|
||||
|
||||
if(!importDimensionFile.exists())
|
||||
{
|
||||
if (!importDimensionFile.exists()) {
|
||||
sender.sendMessage("Missing Imported Dimension File");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage("Importing " + downloadable + " into new Project " + s);
|
||||
createFrom(downloadable, s);
|
||||
if(shouldDelete)
|
||||
{
|
||||
if (shouldDelete) {
|
||||
importPack.delete();
|
||||
}
|
||||
open(sender, s);
|
||||
}
|
||||
|
||||
public void create(MortarSender sender, String s)
|
||||
{
|
||||
public void create(MortarSender sender, String s) {
|
||||
create(sender, s, "example");
|
||||
}
|
||||
|
||||
public void updateWorkspace()
|
||||
{
|
||||
if(isProjectOpen())
|
||||
{
|
||||
public void updateWorkspace() {
|
||||
if (isProjectOpen()) {
|
||||
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 dust;
|
||||
|
||||
public WandManager()
|
||||
{
|
||||
public WandManager() {
|
||||
wand = createWand();
|
||||
dust = createDust();
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () ->
|
||||
{
|
||||
for(Player i : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
for (Player i : Bukkit.getOnlinePlayers()) {
|
||||
tick(i);
|
||||
}
|
||||
}, 0, 5);
|
||||
}
|
||||
|
||||
public void tick(Player p)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(isWand(p.getInventory().getItemInMainHand()))
|
||||
{
|
||||
public void tick(Player p) {
|
||||
try {
|
||||
if (isWand(p.getInventory().getItemInMainHand())) {
|
||||
Location[] d = getCuboid(p.getInventory().getItemInMainHand());
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
if(d[0].distanceSquared(d[1]) > 64 * 64)
|
||||
{
|
||||
if (d[0].distanceSquared(d[1]) > 64 * 64) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,49 +73,38 @@ public class WandManager implements Listener {
|
||||
int maxy = Math.max(d[0].getBlockY(), d[1].getBlockY());
|
||||
int maxz = Math.max(d[0].getBlockZ(), d[1].getBlockZ());
|
||||
|
||||
for(double j = minx - 1; j < maxx + 1; j += 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 j = minx - 1; j < maxx + 1; j += 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)) {
|
||||
boolean jj = j == minx || j == maxx;
|
||||
boolean kk = k == miny || k == maxy;
|
||||
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);
|
||||
|
||||
if(j == minx)
|
||||
{
|
||||
if (j == minx) {
|
||||
push.add(new Vector(-0.55, 0, 0));
|
||||
}
|
||||
|
||||
if(k == miny)
|
||||
{
|
||||
if (k == miny) {
|
||||
push.add(new Vector(0, -0.55, 0));
|
||||
}
|
||||
|
||||
if(l == minz)
|
||||
{
|
||||
if (l == minz) {
|
||||
push.add(new Vector(0, 0, -0.55));
|
||||
}
|
||||
|
||||
if(j == maxx)
|
||||
{
|
||||
if (j == maxx) {
|
||||
push.add(new Vector(0.55, 0, 0));
|
||||
}
|
||||
|
||||
if(k == maxy)
|
||||
{
|
||||
if (k == maxy) {
|
||||
push.add(new Vector(0, 0.55, 0));
|
||||
}
|
||||
|
||||
if(l == maxz)
|
||||
{
|
||||
if (l == maxz) {
|
||||
push.add(new Vector(0, 0, 0.55));
|
||||
}
|
||||
|
||||
@@ -145,22 +122,15 @@ public class WandManager implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(PlayerInteractEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(isWand(e.getPlayer()))
|
||||
{
|
||||
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK))
|
||||
{
|
||||
public void on(PlayerInteractEvent e) {
|
||||
try {
|
||||
if (isWand(e.getPlayer())) {
|
||||
if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
|
||||
e.setCancelled(true);
|
||||
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().updateInventory();
|
||||
}
|
||||
|
||||
else if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
|
||||
{
|
||||
} else if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
e.setCancelled(true);
|
||||
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);
|
||||
@@ -168,38 +138,29 @@ public class WandManager implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if(isDust(e.getPlayer()))
|
||||
{
|
||||
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
|
||||
{
|
||||
if (isDust(e.getPlayer())) {
|
||||
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
e.setCancelled(true);
|
||||
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()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static IrisObject createSchematic(ItemStack wand)
|
||||
{
|
||||
if(!isWand(wand))
|
||||
{
|
||||
public static IrisObject createSchematic(ItemStack wand) {
|
||||
if (!isWand(wand)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
Location[] f = getCuboid(wand);
|
||||
Cuboid c = new Cuboid(f[0], f[1]);
|
||||
IrisObject s = new IrisObject(c.getSizeX(), c.getSizeY(), c.getSizeZ());
|
||||
@@ -213,48 +174,36 @@ public class WandManager implements Listener {
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Location stringToLocation(String s)
|
||||
{
|
||||
try
|
||||
{
|
||||
public static Location stringToLocation(String s) {
|
||||
try {
|
||||
String[] f = s.split("\\Q in \\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]));
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String locationToString(Location s)
|
||||
{
|
||||
if(s == null)
|
||||
{
|
||||
public static String locationToString(Location s) {
|
||||
if (s == null) {
|
||||
return "<#>";
|
||||
}
|
||||
|
||||
return s.getBlockX() + "," + s.getBlockY() + "," + s.getBlockZ() + " in " + s.getWorld().getName();
|
||||
}
|
||||
|
||||
public static ItemStack createWand()
|
||||
{
|
||||
public static ItemStack createWand() {
|
||||
return createWand(null, null);
|
||||
}
|
||||
|
||||
public static ItemStack createDust()
|
||||
{
|
||||
public static ItemStack createDust() {
|
||||
ItemStack is = new ItemStack(Material.GLOWSTONE_DUST);
|
||||
is.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
@@ -267,37 +216,31 @@ public class WandManager implements Listener {
|
||||
return is;
|
||||
}
|
||||
|
||||
public boolean isDust(Player p)
|
||||
{
|
||||
public boolean isDust(Player p) {
|
||||
ItemStack is = p.getInventory().getItemInMainHand();
|
||||
return is != null && isDust(is);
|
||||
}
|
||||
|
||||
public boolean isDust(ItemStack is)
|
||||
{
|
||||
public boolean isDust(ItemStack is) {
|
||||
return is.equals(dust);
|
||||
}
|
||||
|
||||
public ItemStack update(boolean left, Location a, ItemStack item)
|
||||
{
|
||||
if(!isWand(item))
|
||||
{
|
||||
public ItemStack update(boolean left, Location a, ItemStack item) {
|
||||
if (!isWand(item)) {
|
||||
return item;
|
||||
}
|
||||
|
||||
Location[] f = getCuboid(item);
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
is.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
@@ -310,20 +253,17 @@ public class WandManager implements Listener {
|
||||
return is;
|
||||
}
|
||||
|
||||
public static Location[] getCuboid(ItemStack is)
|
||||
{
|
||||
public static Location[] getCuboid(ItemStack is) {
|
||||
ItemMeta im = is.getItemMeta();
|
||||
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();
|
||||
return is != null && isWand(is);
|
||||
}
|
||||
|
||||
public static boolean isWand(ItemStack is)
|
||||
{
|
||||
public static boolean isWand(ItemStack is) {
|
||||
ItemStack wand = createWand();
|
||||
if (is.getItemMeta() == null) return false;
|
||||
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.MortarSender;
|
||||
|
||||
public class CommandIris extends MortarCommand
|
||||
{
|
||||
public class CommandIris extends MortarCommand {
|
||||
@Command
|
||||
private CommandIrisCreate create;
|
||||
|
||||
@@ -52,15 +51,13 @@ public class CommandIris extends MortarCommand
|
||||
@Command
|
||||
private CommandIrisReload reload;
|
||||
|
||||
public CommandIris()
|
||||
{
|
||||
public CommandIris() {
|
||||
super("iris", "ir", "irs");
|
||||
requiresPermission(Iris.perm);
|
||||
}
|
||||
|
||||
@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");
|
||||
printHelp(sender);
|
||||
return true;
|
||||
@@ -72,8 +69,7 @@ public class CommandIris extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,8 @@ package com.volmit.iris.manager.command;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.*;
|
||||
|
||||
public class CommandIrisDownload extends MortarCommand
|
||||
{
|
||||
public CommandIrisDownload()
|
||||
{
|
||||
public class CommandIrisDownload extends MortarCommand {
|
||||
public CommandIrisDownload() {
|
||||
super("download", "down", "dl");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Download a project.");
|
||||
@@ -18,21 +16,18 @@ public class CommandIrisDownload extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(args.length < 1)
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage("/iris dl " + C.BOLD + "<NAME>");
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean trim = false;
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equals("-t") || i.equals("--trim"))
|
||||
{
|
||||
for (String i : args) {
|
||||
if (i.equals("-t") || i.equals("--trim")) {
|
||||
trim = true;
|
||||
}
|
||||
}
|
||||
@@ -45,8 +40,7 @@ public class CommandIrisDownload extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "<name> [-t/--trim]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ package com.volmit.iris.manager.command;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.scaffold.IrisWorlds;
|
||||
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.entity.Player;
|
||||
|
||||
public class CommandIrisMetrics extends MortarCommand
|
||||
{
|
||||
public CommandIrisMetrics()
|
||||
{
|
||||
public class CommandIrisMetrics extends MortarCommand {
|
||||
public CommandIrisMetrics() {
|
||||
super("metrics", "stats", "mt");
|
||||
setDescription("Get timings for this world");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -22,36 +22,27 @@ public class CommandIrisMetrics extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (sender.isPlayer()) {
|
||||
Player p = sender.player();
|
||||
World world = p.getWorld();
|
||||
if(!IrisWorlds.isIrisWorld(world))
|
||||
{
|
||||
if (!IrisWorlds.isIrisWorld(world)) {
|
||||
sender.sendMessage("You must be in an iris world.");
|
||||
return true;
|
||||
}
|
||||
|
||||
IrisAccess g = IrisWorlds.access(world);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
g.printMetrics(sender);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
sender.sendMessage("You must be in an iris world.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sender.sendMessage("Players only.");
|
||||
}
|
||||
|
||||
@@ -59,8 +50,7 @@ public class CommandIrisMetrics extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,8 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisReload extends MortarCommand
|
||||
{
|
||||
public CommandIrisReload()
|
||||
{
|
||||
public class CommandIrisReload extends MortarCommand {
|
||||
public CommandIrisReload() {
|
||||
super("reload", "rld");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Reload configs");
|
||||
@@ -22,8 +20,7 @@ public class CommandIrisReload extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
IrisSettings.invalidate();
|
||||
IrisSettings.get();
|
||||
sender.sendMessage("settings.json Reloaded");
|
||||
@@ -31,8 +28,7 @@ public class CommandIrisReload extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "<name> [-t/--trim]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,8 @@ package com.volmit.iris.manager.command;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.*;
|
||||
|
||||
public class CommandIrisUpdateProject extends MortarCommand
|
||||
{
|
||||
public CommandIrisUpdateProject()
|
||||
{
|
||||
public class CommandIrisUpdateProject extends MortarCommand {
|
||||
public CommandIrisUpdateProject() {
|
||||
super("update-project", "^project");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Update a project from git.");
|
||||
@@ -19,10 +17,8 @@ public class CommandIrisUpdateProject extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(args.length < 1)
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage("/iris update-project " + C.BOLD + "<PROJECT>");
|
||||
return true;
|
||||
}
|
||||
@@ -33,8 +29,7 @@ public class CommandIrisUpdateProject extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "<project>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,31 +3,26 @@ package com.volmit.iris.manager.command;
|
||||
import com.volmit.iris.util.MortarPermission;
|
||||
import com.volmit.iris.util.Permission;
|
||||
|
||||
public class PermissionIris extends MortarPermission
|
||||
{
|
||||
public class PermissionIris extends MortarPermission {
|
||||
@Permission
|
||||
public PermissionIrisStudio studio;
|
||||
|
||||
public PermissionIris()
|
||||
{
|
||||
public PermissionIris() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNode()
|
||||
{
|
||||
protected String getNode() {
|
||||
return "iris";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
public String getDescription() {
|
||||
return "Iris Permissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault()
|
||||
{
|
||||
public boolean isDefault() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,28 +2,23 @@ package com.volmit.iris.manager.command;
|
||||
|
||||
import com.volmit.iris.util.MortarPermission;
|
||||
|
||||
public class PermissionIrisStudio extends MortarPermission
|
||||
{
|
||||
public PermissionIrisStudio()
|
||||
{
|
||||
public class PermissionIrisStudio extends MortarPermission {
|
||||
public PermissionIrisStudio() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNode()
|
||||
{
|
||||
protected String getNode() {
|
||||
return "studio";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
public String getDescription() {
|
||||
return "Iris Studio Permissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault()
|
||||
{
|
||||
public boolean isDefault() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisJigsaw extends MortarCommand
|
||||
{
|
||||
public class CommandIrisJigsaw extends MortarCommand {
|
||||
@Command
|
||||
private CommandIrisJigsawNew create;
|
||||
|
||||
@@ -21,8 +20,7 @@ public class CommandIrisJigsaw extends MortarCommand
|
||||
@Command
|
||||
private CommandIrisJigsawPlace place;
|
||||
|
||||
public CommandIrisJigsaw()
|
||||
{
|
||||
public CommandIrisJigsaw() {
|
||||
super("jigsaw", "jig", "jsw", "j");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Jigsaw");
|
||||
@@ -35,16 +33,13 @@ public class CommandIrisJigsaw extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("Ingame only");
|
||||
return true;
|
||||
}
|
||||
@@ -55,8 +50,7 @@ public class CommandIrisJigsaw extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,8 @@ import com.volmit.iris.util.MortarSender;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CommandIrisJigsawEdit extends MortarCommand
|
||||
{
|
||||
public CommandIrisJigsawEdit()
|
||||
{
|
||||
public class CommandIrisJigsawEdit extends MortarCommand {
|
||||
public CommandIrisJigsawEdit() {
|
||||
super("edit", "e", "*");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Jigsaw");
|
||||
@@ -27,30 +25,25 @@ public class CommandIrisJigsawEdit extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("Ingame only");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length < 1)
|
||||
{
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage(getArgsUsage());
|
||||
return true;
|
||||
}
|
||||
|
||||
IrisJigsawPiece piece = IrisDataManager.loadAnyJigsawPiece(args[0]);
|
||||
|
||||
if(piece != null)
|
||||
{
|
||||
if (piece != null) {
|
||||
File dest = piece.getLoadFile();
|
||||
new JigsawEditor(sender.player(), piece, IrisDataManager.loadAnyObject(piece.getObject()), dest);
|
||||
return true;
|
||||
@@ -62,8 +55,7 @@ public class CommandIrisJigsawEdit extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "<name>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,8 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
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");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Jigsaw");
|
||||
@@ -25,24 +21,20 @@ public class CommandIrisJigsawExit extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("Ingame only");
|
||||
return true;
|
||||
}
|
||||
|
||||
JigsawEditor editor = JigsawEditor.editors.get(sender.player());
|
||||
|
||||
if(editor == null)
|
||||
{
|
||||
if (editor == null) {
|
||||
sender.sendMessage("You don't have any pieces open to close!");
|
||||
return true;
|
||||
}
|
||||
@@ -52,8 +44,7 @@ public class CommandIrisJigsawExit extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,8 @@ import com.volmit.iris.util.MortarSender;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CommandIrisJigsawNew extends MortarCommand
|
||||
{
|
||||
public CommandIrisJigsawNew()
|
||||
{
|
||||
public class CommandIrisJigsawNew extends MortarCommand {
|
||||
public CommandIrisJigsawNew() {
|
||||
super("create", "new", "+", "n");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Jigsaw");
|
||||
@@ -27,22 +25,18 @@ public class CommandIrisJigsawNew extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("Ingame only");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length != 3)
|
||||
{
|
||||
if (args.length != 3) {
|
||||
sender.sendMessage(getArgsUsage());
|
||||
return true;
|
||||
}
|
||||
@@ -64,8 +58,7 @@ public class CommandIrisJigsawNew extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
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.util.*;
|
||||
|
||||
public class CommandIrisJigsawPlace extends MortarCommand
|
||||
{
|
||||
public CommandIrisJigsawPlace()
|
||||
{
|
||||
public class CommandIrisJigsawPlace extends MortarCommand {
|
||||
public CommandIrisJigsawPlace() {
|
||||
super("place", "paste", "p");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Jigsaw");
|
||||
@@ -24,16 +22,13 @@ public class CommandIrisJigsawPlace extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("Ingame only");
|
||||
return true;
|
||||
}
|
||||
@@ -45,8 +40,7 @@ public class CommandIrisJigsawPlace extends MortarCommand
|
||||
|
||||
IrisJigsawStructure str = IrisDataManager.loadAnyJigsawStructure(args[0]);
|
||||
|
||||
if(str != null)
|
||||
{
|
||||
if (str != null) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
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));
|
||||
@@ -57,8 +51,7 @@ public class CommandIrisJigsawPlace extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "<name>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,8 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisJigsawSave extends MortarCommand
|
||||
{
|
||||
public CommandIrisJigsawSave()
|
||||
{
|
||||
public class CommandIrisJigsawSave extends MortarCommand {
|
||||
public CommandIrisJigsawSave() {
|
||||
super("save", "s");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Jigsaw");
|
||||
@@ -23,24 +21,20 @@ public class CommandIrisJigsawSave extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("Ingame only");
|
||||
return true;
|
||||
}
|
||||
|
||||
JigsawEditor editor = JigsawEditor.editors.get(sender.player());
|
||||
|
||||
if(editor == null)
|
||||
{
|
||||
if (editor == null) {
|
||||
sender.sendMessage("You don't have any pieces open to save!");
|
||||
return true;
|
||||
}
|
||||
@@ -50,8 +44,7 @@ public class CommandIrisJigsawSave extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisObject extends MortarCommand
|
||||
{
|
||||
public class CommandIrisObject extends MortarCommand {
|
||||
@Command
|
||||
private CommandIrisObjectWand wand;
|
||||
|
||||
@@ -42,8 +41,7 @@ public class CommandIrisObject extends MortarCommand
|
||||
@Command
|
||||
private CommandIrisObjectPaste paste;
|
||||
|
||||
public CommandIrisObject()
|
||||
{
|
||||
public CommandIrisObject() {
|
||||
super("object", "iob", "o", "obj");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -56,10 +54,8 @@ public class CommandIrisObject extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
@@ -70,8 +66,7 @@ public class CommandIrisObject extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[subcommand]";
|
||||
}
|
||||
}
|
||||
|
||||
+11
-18
@@ -1,18 +1,15 @@
|
||||
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 org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.WandManager;
|
||||
|
||||
public class CommandIrisObjectContract extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectContract()
|
||||
{
|
||||
public class CommandIrisObjectContract extends MortarCommand {
|
||||
public CommandIrisObjectContract() {
|
||||
super("-");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -24,25 +21,22 @@ public class CommandIrisObjectContract extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("You don't have a wand");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p = sender.player();
|
||||
|
||||
if(!WandManager.isWand(p))
|
||||
{
|
||||
if (!WandManager.isWand(p)) {
|
||||
sender.sendMessage("Ready your Wand.");
|
||||
return true;
|
||||
}
|
||||
@@ -64,8 +58,7 @@ public class CommandIrisObjectContract extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[amt]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,8 @@ import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
public class CommandIrisObjectDust extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectDust()
|
||||
{
|
||||
public class CommandIrisObjectDust extends MortarCommand {
|
||||
public CommandIrisObjectDust() {
|
||||
super("dust", "dst", "d");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -24,16 +22,13 @@ public class CommandIrisObjectDust extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("You don't have an inventory");
|
||||
return true;
|
||||
}
|
||||
@@ -45,8 +40,7 @@ public class CommandIrisObjectDust extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[subcommand]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
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 org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.WandManager;
|
||||
|
||||
public class CommandIrisObjectExpand extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectExpand()
|
||||
{
|
||||
public class CommandIrisObjectExpand extends MortarCommand {
|
||||
public CommandIrisObjectExpand() {
|
||||
super("+");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -24,25 +21,22 @@ public class CommandIrisObjectExpand extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("You don't have a wand");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p = sender.player();
|
||||
|
||||
if(!WandManager.isWand(p))
|
||||
{
|
||||
if (!WandManager.isWand(p)) {
|
||||
sender.sendMessage("Ready your Wand.");
|
||||
return true;
|
||||
}
|
||||
@@ -64,8 +58,7 @@ public class CommandIrisObjectExpand extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[amt]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
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.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.WandManager;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import java.util.Set;
|
||||
|
||||
public class CommandIrisObjectP1 extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectP1()
|
||||
{
|
||||
public class CommandIrisObjectP1 extends MortarCommand {
|
||||
public CommandIrisObjectP1() {
|
||||
super("p1");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -29,41 +26,36 @@ public class CommandIrisObjectP1 extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("You don't have a wand");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p = sender.player();
|
||||
|
||||
if(!WandManager.isWand(p))
|
||||
{
|
||||
if (!WandManager.isWand(p)) {
|
||||
sender.sendMessage("Ready your Wand.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack wand = p.getInventory().getItemInMainHand();
|
||||
|
||||
if(WandManager.isWand(wand))
|
||||
{
|
||||
if (WandManager.isWand(wand)) {
|
||||
Location[] g = WandManager.getCuboid(wand);
|
||||
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
|
||||
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]));
|
||||
@@ -73,8 +65,7 @@ public class CommandIrisObjectP1 extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[-l]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
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.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.WandManager;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import java.util.Set;
|
||||
|
||||
public class CommandIrisObjectP2 extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectP2()
|
||||
{
|
||||
public class CommandIrisObjectP2 extends MortarCommand {
|
||||
public CommandIrisObjectP2() {
|
||||
super("p2");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -29,41 +26,36 @@ public class CommandIrisObjectP2 extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("You don't have a wand");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p = sender.player();
|
||||
|
||||
if(!WandManager.isWand(p))
|
||||
{
|
||||
if (!WandManager.isWand(p)) {
|
||||
sender.sendMessage("Ready your Wand.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack wand = p.getInventory().getItemInMainHand();
|
||||
|
||||
if(WandManager.isWand(wand))
|
||||
{
|
||||
if (WandManager.isWand(wand)) {
|
||||
Location[] g = WandManager.getCuboid(wand);
|
||||
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
|
||||
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]));
|
||||
@@ -73,8 +65,7 @@ public class CommandIrisObjectP2 extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[-l]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
public class CommandIrisObjectPaste extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectPaste()
|
||||
{
|
||||
public class CommandIrisObjectPaste extends MortarCommand {
|
||||
public CommandIrisObjectPaste() {
|
||||
super("paste", "pasta", "place", "p");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -32,17 +30,15 @@ public class CommandIrisObjectPaste extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("You don't have a wand");
|
||||
return true;
|
||||
}
|
||||
@@ -55,8 +51,7 @@ public class CommandIrisObjectPaste extends MortarCommand
|
||||
Player p = sender.player();
|
||||
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");
|
||||
return true;
|
||||
@@ -65,16 +60,13 @@ public class CommandIrisObjectPaste extends MortarCommand
|
||||
File file = obj.getLoadFile();
|
||||
boolean intoWand = false;
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equalsIgnoreCase("-edit"))
|
||||
{
|
||||
for (String i : args) {
|
||||
if (i.equalsIgnoreCase("-edit")) {
|
||||
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");
|
||||
return true;
|
||||
}
|
||||
@@ -82,18 +74,16 @@ public class CommandIrisObjectPaste extends MortarCommand
|
||||
ItemStack wand = sender.player().getInventory().getItemInMainHand();
|
||||
|
||||
IrisObject o = IrisDataManager.loadAnyObject(args[0]);
|
||||
if(o == null)
|
||||
{
|
||||
if (o == null) {
|
||||
sender.sendMessage("Error, cant find");
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage("Loaded " + "objects/" + args[0] + ".iob");
|
||||
|
||||
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()));
|
||||
p.getInventory().setItemInMainHand(wand);
|
||||
sender.sendMessage("Updated wand for " + "objects/" + args[0] + ".iob");
|
||||
@@ -106,8 +96,7 @@ public class CommandIrisObjectPaste extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[name] [-edit]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
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.IrisSettings;
|
||||
import com.volmit.iris.manager.WandManager;
|
||||
import com.volmit.iris.object.IrisObject;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
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
|
||||
{
|
||||
public CommandIrisObjectSave()
|
||||
{
|
||||
import java.io.File;
|
||||
|
||||
public class CommandIrisObjectSave extends MortarCommand {
|
||||
public CommandIrisObjectSave() {
|
||||
super("save", "s");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -29,36 +26,30 @@ public class CommandIrisObjectSave extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("You don't have a wand");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length < 2)
|
||||
{
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage("/iris o save <project> <object>");
|
||||
sender.sendMessage("I.e. /iris o save overworld some-tree/tree1");
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
boolean overwrite = false;
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equals("-o"))
|
||||
{
|
||||
for (String i : args) {
|
||||
if (i.equals("-o")) {
|
||||
overwrite = true;
|
||||
}
|
||||
}
|
||||
@@ -68,10 +59,8 @@ public class CommandIrisObjectSave extends MortarCommand
|
||||
IrisObject o = WandManager.createSchematic(wand);
|
||||
File file = Iris.proj.getWorkspaceFile(args[0], "objects", args[1] + ".iob");
|
||||
|
||||
if(file.exists())
|
||||
{
|
||||
if(!overwrite)
|
||||
{
|
||||
if (file.exists()) {
|
||||
if (!overwrite) {
|
||||
sender.sendMessage("File Exists. Overwrite by adding -o");
|
||||
return true;
|
||||
}
|
||||
@@ -80,10 +69,7 @@ public class CommandIrisObjectSave extends MortarCommand
|
||||
o.write(file);
|
||||
sender.sendMessage("Saved " + args[1]);
|
||||
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?");
|
||||
|
||||
e.printStackTrace();
|
||||
@@ -93,8 +79,7 @@ public class CommandIrisObjectSave extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[project] [name]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
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 org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.WandManager;
|
||||
|
||||
public class CommandIrisObjectShift extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectShift()
|
||||
{
|
||||
public class CommandIrisObjectShift extends MortarCommand {
|
||||
public CommandIrisObjectShift() {
|
||||
super(">");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -24,25 +21,22 @@ public class CommandIrisObjectShift extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("You don't have a wand");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p = sender.player();
|
||||
|
||||
if(!WandManager.isWand(p))
|
||||
{
|
||||
if (!WandManager.isWand(p)) {
|
||||
sender.sendMessage("Ready your Wand.");
|
||||
return true;
|
||||
}
|
||||
@@ -65,8 +59,7 @@ public class CommandIrisObjectShift extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[amt]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
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.IrisSettings;
|
||||
import com.volmit.iris.manager.WandManager;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
public class CommandIrisObjectWand extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectWand()
|
||||
{
|
||||
public class CommandIrisObjectWand extends MortarCommand {
|
||||
public CommandIrisObjectWand() {
|
||||
super("wand", "w");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -24,17 +21,15 @@ public class CommandIrisObjectWand extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("You don't have an inventory");
|
||||
return true;
|
||||
}
|
||||
@@ -46,8 +41,7 @@ public class CommandIrisObjectWand extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[subcommand]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
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.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
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.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import com.volmit.iris.util.Cuboid.CuboidDirection;
|
||||
|
||||
public class CommandIrisObjectXAY extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectXAY()
|
||||
{
|
||||
public class CommandIrisObjectXAY extends MortarCommand {
|
||||
public CommandIrisObjectXAY() {
|
||||
super("x&y");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -30,25 +27,22 @@ public class CommandIrisObjectXAY extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("You don't have a wand");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p = sender.player();
|
||||
|
||||
if(!WandManager.isWand(p))
|
||||
{
|
||||
if (!WandManager.isWand(p)) {
|
||||
sender.sendMessage("Ready your Wand.");
|
||||
return true;
|
||||
}
|
||||
@@ -61,8 +55,7 @@ public class CommandIrisObjectXAY extends MortarCommand
|
||||
Cuboid cursor = 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));
|
||||
a2.add(new Vector(0, 1, 0));
|
||||
cursor = new Cuboid(a1, a2);
|
||||
@@ -71,8 +64,7 @@ public class CommandIrisObjectXAY extends MortarCommand
|
||||
a1.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));
|
||||
a2x.add(new Vector(0, -1, 0));
|
||||
cursorx = new Cuboid(a1x, a2x);
|
||||
@@ -97,8 +89,7 @@ public class CommandIrisObjectXAY extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[subcommand]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
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.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
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.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import com.volmit.iris.util.Cuboid.CuboidDirection;
|
||||
|
||||
public class CommandIrisObjectXPY extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectXPY()
|
||||
{
|
||||
public class CommandIrisObjectXPY extends MortarCommand {
|
||||
public CommandIrisObjectXPY() {
|
||||
super("x+y");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
@@ -31,24 +28,20 @@ public class CommandIrisObjectXPY extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
if (!sender.isPlayer()) {
|
||||
sender.sendMessage("You don't have a wand");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p = sender.player();
|
||||
|
||||
if(!WandManager.isWand(p))
|
||||
{
|
||||
if (!WandManager.isWand(p)) {
|
||||
sender.sendMessage("Ready your Wand.");
|
||||
return true;
|
||||
}
|
||||
@@ -59,8 +52,7 @@ public class CommandIrisObjectXPY extends MortarCommand
|
||||
Location a2 = b[1].clone();
|
||||
Cuboid cursor = new Cuboid(a1, a2);
|
||||
|
||||
while(!cursor.containsOnly(Material.AIR))
|
||||
{
|
||||
while (!cursor.containsOnly(Material.AIR)) {
|
||||
a1.add(new Vector(0, 1, 0));
|
||||
a2.add(new Vector(0, 1, 0));
|
||||
cursor = new Cuboid(a1, a2);
|
||||
@@ -85,8 +77,7 @@ public class CommandIrisObjectXPY extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[subcommand]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisStudio extends MortarCommand
|
||||
{
|
||||
public class CommandIrisStudio extends MortarCommand {
|
||||
@Command
|
||||
private CommandIrisStudioCreate create;
|
||||
|
||||
@@ -60,8 +59,7 @@ public class CommandIrisStudio extends MortarCommand
|
||||
@Command
|
||||
private CommandIrisStudioMap map;
|
||||
|
||||
public CommandIrisStudio()
|
||||
{
|
||||
public CommandIrisStudio() {
|
||||
super("studio", "std", "s");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setCategory("Studio");
|
||||
@@ -73,10 +71,8 @@ public class CommandIrisStudio extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
@@ -87,8 +83,7 @@ public class CommandIrisStudio extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[subcommand]";
|
||||
}
|
||||
}
|
||||
|
||||
+12
-33
@@ -3,18 +3,11 @@ package com.volmit.iris.manager.command.studio;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
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.IOException;
|
||||
|
||||
public class CommandIrisStudioBeautify extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioBeautify()
|
||||
{
|
||||
public class CommandIrisStudioBeautify extends MortarCommand {
|
||||
public CommandIrisStudioBeautify() {
|
||||
super("beautify", "prettify");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Prettify the project by cleaning up json.");
|
||||
@@ -27,33 +20,25 @@ public class CommandIrisStudioBeautify extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
File clean = null;
|
||||
|
||||
if(args.length == 0)
|
||||
{
|
||||
if(!Iris.proj.isProjectOpen())
|
||||
{
|
||||
if (args.length == 0) {
|
||||
if (!Iris.proj.isProjectOpen()) {
|
||||
sender.sendMessage("No open project. Either use /iris std beautify <project> or have a project open.");
|
||||
return true;
|
||||
}
|
||||
|
||||
clean = Iris.proj.getActiveProject().getPath();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
clean = Iris.instance.getDataFolder("packs", args[0]);
|
||||
|
||||
if(!clean.exists())
|
||||
{
|
||||
if (!clean.exists()) {
|
||||
sender.sendMessage("Not a valid project.");
|
||||
return true;
|
||||
}
|
||||
@@ -66,16 +51,11 @@ public class CommandIrisStudioBeautify extends MortarCommand
|
||||
|
||||
private int clean(MortarSender s, File clean) {
|
||||
int c = 0;
|
||||
if(clean.isDirectory())
|
||||
{
|
||||
for(File i : clean.listFiles())
|
||||
{
|
||||
if (clean.isDirectory()) {
|
||||
for (File i : clean.listFiles()) {
|
||||
c += clean(s, i);
|
||||
}
|
||||
}
|
||||
|
||||
else if(clean.getName().endsWith(".json"))
|
||||
{
|
||||
} else if (clean.getName().endsWith(".json")) {
|
||||
try {
|
||||
IO.writeAll(clean, new JSONObject(IO.readAll(clean)).toString(4));
|
||||
} catch (Throwable e) {
|
||||
@@ -89,8 +69,7 @@ public class CommandIrisStudioBeautify extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[project]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
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.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisStudioClose extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioClose()
|
||||
{
|
||||
public class CommandIrisStudioClose extends MortarCommand {
|
||||
public CommandIrisStudioClose() {
|
||||
super("close", "x");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Close the existing dimension");
|
||||
@@ -26,28 +23,22 @@ public class CommandIrisStudioClose extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!Iris.proj.isProjectOpen())
|
||||
{
|
||||
if (!Iris.proj.isProjectOpen()) {
|
||||
sender.sendMessage("No open projects.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
if (sender.isPlayer()) {
|
||||
World f = null;
|
||||
|
||||
for(World i : Bukkit.getWorlds())
|
||||
{
|
||||
if(i.getWorldFolder().getAbsolutePath().equals(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getWorldFolder().getAbsolutePath()))
|
||||
{
|
||||
for (World i : Bukkit.getWorlds()) {
|
||||
if (i.getWorldFolder().getAbsolutePath().equals(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getWorldFolder().getAbsolutePath())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -55,18 +46,12 @@ public class CommandIrisStudioClose extends MortarCommand
|
||||
break;
|
||||
}
|
||||
|
||||
if(f == null)
|
||||
{
|
||||
for(Player i : Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getPlayers())
|
||||
{
|
||||
if (f == null) {
|
||||
for (Player i : Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getPlayers()) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -78,8 +63,7 @@ public class CommandIrisStudioClose extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,8 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisStudioConvert extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioConvert()
|
||||
{
|
||||
public class CommandIrisStudioConvert extends MortarCommand {
|
||||
public CommandIrisStudioConvert() {
|
||||
super("convert", "cvt");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Convert .ewg schematics into Iris (.iob) files");
|
||||
@@ -22,10 +20,8 @@ public class CommandIrisStudioConvert extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
@@ -35,8 +31,7 @@ public class CommandIrisStudioConvert extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,8 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisStudioCreate extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioCreate()
|
||||
{
|
||||
public class CommandIrisStudioCreate extends MortarCommand {
|
||||
public CommandIrisStudioCreate() {
|
||||
super("create", "new", "+");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Create a new project & open it.");
|
||||
@@ -23,16 +21,13 @@ public class CommandIrisStudioCreate extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length < 1)
|
||||
{
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage("Please use a lowercase name with hyphens (-) for spaces.");
|
||||
sender.sendMessage("I.e. /iris std new " + C.BOLD + "aether");
|
||||
return true;
|
||||
@@ -40,21 +35,15 @@ public class CommandIrisStudioCreate extends MortarCommand
|
||||
|
||||
String template = null;
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.startsWith("template="))
|
||||
{
|
||||
for (String i : args) {
|
||||
if (i.startsWith("template=")) {
|
||||
template = i.split("\\Q=\\E")[1];
|
||||
}
|
||||
}
|
||||
|
||||
if(template != null)
|
||||
{
|
||||
if (template != null) {
|
||||
Iris.proj.create(sender, args[0], template);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Iris.proj.create(sender, args[0]);
|
||||
}
|
||||
|
||||
@@ -62,8 +51,7 @@ public class CommandIrisStudioCreate extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[dimension] [template=<project>]";
|
||||
}
|
||||
}
|
||||
|
||||
+10
-24
@@ -10,10 +10,8 @@ import org.bukkit.entity.Player;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
|
||||
public class CommandIrisStudioEditBiome extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioEditBiome()
|
||||
{
|
||||
public class CommandIrisStudioEditBiome extends MortarCommand {
|
||||
public CommandIrisStudioEditBiome() {
|
||||
super("editbiome", "ebiome", "eb");
|
||||
setDescription("Open this biome file in vscode");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -26,40 +24,29 @@ public class CommandIrisStudioEditBiome extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!Iris.proj.isProjectOpen())
|
||||
{
|
||||
if (!Iris.proj.isProjectOpen()) {
|
||||
sender.sendMessage("There is not a studio currently loaded.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
if (sender.isPlayer()) {
|
||||
Player p = sender.player();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
File f = Iris.proj.getActiveProject().getActiveProvider().getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ()).getLoadFile();
|
||||
Desktop.getDesktop().open(f);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
sender.sendMessage("Cant find the file. Are you in an Iris Studio world?");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sender.sendMessage("Players only.");
|
||||
}
|
||||
|
||||
@@ -67,8 +54,7 @@ public class CommandIrisStudioEditBiome extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[width]";
|
||||
}
|
||||
}
|
||||
|
||||
+8
-18
@@ -8,13 +8,11 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisStudioExplorer extends MortarCommand
|
||||
{
|
||||
public class CommandIrisStudioExplorer extends MortarCommand {
|
||||
@Command
|
||||
private CommandIrisStudioExplorerGenerator generator;
|
||||
|
||||
public CommandIrisStudioExplorer()
|
||||
{
|
||||
public CommandIrisStudioExplorer() {
|
||||
super("noise", "nmap");
|
||||
setDescription("Explore different noise generators visually");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -27,23 +25,16 @@ public class CommandIrisStudioExplorer extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(args.length != 0)
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (args.length != 0) {
|
||||
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");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!IrisSettings.get().isUseServerLaunchedGuis())
|
||||
{
|
||||
if (!IrisSettings.get().isUseServerLaunchedGuis()) {
|
||||
sender.sendMessage("To use Iris Guis, please enable serverLaunchedGuis in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
@@ -55,8 +46,7 @@ public class CommandIrisStudioExplorer extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
+11
-24
@@ -10,10 +10,8 @@ import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class CommandIrisStudioExplorerGenerator extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioExplorerGenerator()
|
||||
{
|
||||
public class CommandIrisStudioExplorerGenerator extends MortarCommand {
|
||||
public CommandIrisStudioExplorerGenerator() {
|
||||
super("generator", "gen", "g");
|
||||
setDescription("Preview created noise noises generators");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -26,22 +24,18 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!IrisSettings.get().isUseServerLaunchedGuis())
|
||||
{
|
||||
if (!IrisSettings.get().isUseServerLaunchedGuis()) {
|
||||
sender.sendMessage("To use Iris Guis, please enable serverLaunchedGuis in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("Specify a generator to preview");
|
||||
return true;
|
||||
}
|
||||
@@ -49,27 +43,21 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
|
||||
IrisGenerator generator;
|
||||
long seed = 12345;
|
||||
|
||||
if (Iris.proj.isProjectOpen())
|
||||
{
|
||||
if (Iris.proj.isProjectOpen()) {
|
||||
generator = Iris.proj.getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(args[0]);
|
||||
seed = Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSeed();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
generator = IrisDataManager.loadAnyGenerator(args[0]);
|
||||
}
|
||||
|
||||
if (generator != null)
|
||||
{
|
||||
if (generator != null) {
|
||||
long finalSeed = seed;
|
||||
NoiseExplorer.launch((x, z) ->
|
||||
generator.getHeight(x, z, new RNG(finalSeed).nextParallelRNG(3245).lmax()), "Gen: " + generator.getLoadKey());
|
||||
|
||||
sender.sendMessage("Opening Noise Explorer for gen " + generator.getLoadKey() + " (" + generator.getLoader().getDataFolder().getName() + ")");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sender.sendMessage("Invalid Generator");
|
||||
}
|
||||
|
||||
@@ -77,8 +65,7 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[generator]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,8 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandIrisStudioGoto extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioGoto()
|
||||
{
|
||||
public class CommandIrisStudioGoto extends MortarCommand {
|
||||
public CommandIrisStudioGoto() {
|
||||
super("goto", "find", "g", "tp");
|
||||
setDescription("Find any region or biome");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -28,8 +26,7 @@ public class CommandIrisStudioGoto extends MortarCommand
|
||||
|
||||
@Override
|
||||
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();
|
||||
if (data == null) {
|
||||
sender.sendMessage("Issue when loading tab completions. No data found (?)");
|
||||
@@ -42,23 +39,18 @@ public class CommandIrisStudioGoto extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(args.length < 1)
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
try {
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage("/iris std goto " + getArgsUsage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
if (sender.isPlayer()) {
|
||||
Player p = sender.player();
|
||||
World world = p.getWorld();
|
||||
|
||||
if(!IrisWorlds.isIrisWorld(world))
|
||||
{
|
||||
if (!IrisWorlds.isIrisWorld(world)) {
|
||||
sender.sendMessage("You must be in an iris world.");
|
||||
return true;
|
||||
}
|
||||
@@ -68,36 +60,24 @@ public class CommandIrisStudioGoto extends MortarCommand
|
||||
IrisRegion r = IrisDataManager.loadAnyRegion(args[0]);
|
||||
IrisObject o = IrisDataManager.loadAnyObject(args[0]);
|
||||
|
||||
if(b != null)
|
||||
{
|
||||
if (b != null) {
|
||||
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"));
|
||||
|
||||
if(l == null)
|
||||
{
|
||||
if (l == null) {
|
||||
sender.sendMessage("Couldn't find " + b.getName() + ".");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sender.sendMessage("Found " + b.getName() + "!");
|
||||
J.s(() -> sender.player().teleport(l));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
else if(r != null)
|
||||
{
|
||||
} else if (r != null) {
|
||||
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"));
|
||||
|
||||
if(l == null)
|
||||
{
|
||||
if (l == null) {
|
||||
sender.sendMessage("Couldn't find " + r.getName() + ".");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sender.sendMessage("Found " + r.getName() + "!");
|
||||
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!");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sender.sendMessage("Players only.");
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
Iris.error("Failed goto!");
|
||||
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!");
|
||||
@@ -151,8 +124,7 @@ public class CommandIrisStudioGoto extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[biome/region]";
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,8 @@ import com.volmit.iris.util.MortarSender;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandIrisStudioHotload extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioHotload()
|
||||
{
|
||||
public class CommandIrisStudioHotload extends MortarCommand {
|
||||
public CommandIrisStudioHotload() {
|
||||
super("hotload", "hot", "h", "reload");
|
||||
setDescription("Force a hotload");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -24,21 +22,18 @@ public class CommandIrisStudioHotload extends MortarCommand
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
if (sender.isPlayer()) {
|
||||
Player p = sender.player();
|
||||
World world = p.getWorld();
|
||||
if(!IrisWorlds.isIrisWorld(world))
|
||||
{
|
||||
if (!IrisWorlds.isIrisWorld(world)) {
|
||||
sender.sendMessage("You must be in an iris world.");
|
||||
return true;
|
||||
}
|
||||
@@ -46,10 +41,7 @@ public class CommandIrisStudioHotload extends MortarCommand
|
||||
IrisWorlds.access(world).hotload();
|
||||
sender.sendMessage("Hotloaded!");
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sender.sendMessage("Players only.");
|
||||
}
|
||||
|
||||
@@ -57,8 +49,7 @@ public class CommandIrisStudioHotload extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.volmit.iris.manager.command.studio;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.object.InventorySlotType;
|
||||
import com.volmit.iris.object.IrisLootTable;
|
||||
import com.volmit.iris.scaffold.IrisWorlds;
|
||||
@@ -13,10 +12,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CommandIrisStudioLoot extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioLoot()
|
||||
{
|
||||
public class CommandIrisStudioLoot extends MortarCommand {
|
||||
public CommandIrisStudioLoot() {
|
||||
super("loot");
|
||||
setDescription("Show loot if a chest were right here");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -29,21 +26,17 @@ public class CommandIrisStudioLoot extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
if (sender.isPlayer()) {
|
||||
Player p = sender.player();
|
||||
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.");
|
||||
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());
|
||||
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);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
sender.sendMessage("You can only use /iris loot in a studio world of iris.");
|
||||
return true;
|
||||
}
|
||||
|
||||
p.openInventory(inv);
|
||||
|
||||
for(IrisLootTable i : tables)
|
||||
{
|
||||
for (IrisLootTable i : tables) {
|
||||
sender.sendMessage("- " + i.getName());
|
||||
}
|
||||
|
||||
boolean ffast = false;
|
||||
boolean fadd = false;
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equals("--fast"))
|
||||
{
|
||||
for (String i : args) {
|
||||
if (i.equals("--fast")) {
|
||||
ffast = true;
|
||||
}
|
||||
|
||||
if(i.equals("--add"))
|
||||
{
|
||||
if (i.equals("--add")) {
|
||||
fadd = true;
|
||||
}
|
||||
}
|
||||
@@ -92,14 +77,12 @@ public class CommandIrisStudioLoot extends MortarCommand
|
||||
|
||||
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());
|
||||
return;
|
||||
}
|
||||
|
||||
if(!add)
|
||||
{
|
||||
if (!add) {
|
||||
inv.clear();
|
||||
}
|
||||
|
||||
@@ -107,10 +90,7 @@ public class CommandIrisStudioLoot extends MortarCommand
|
||||
}, 0, fast ? 5 : 35));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sender.sendMessage("Players only.");
|
||||
}
|
||||
|
||||
@@ -118,8 +98,7 @@ public class CommandIrisStudioLoot extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[width]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,8 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisStudioMap extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioMap()
|
||||
{
|
||||
public class CommandIrisStudioMap extends MortarCommand {
|
||||
public CommandIrisStudioMap() {
|
||||
super("map", "render");
|
||||
setDescription("Render a map (gui outside of mc)");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -25,30 +23,23 @@ public class CommandIrisStudioMap extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!IrisSettings.get().isUseServerLaunchedGuis())
|
||||
{
|
||||
if (!IrisSettings.get().isUseServerLaunchedGuis()) {
|
||||
sender.sendMessage("To use Iris Guis, please enable serverLaunchedGuis in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
IrisAccess g = Iris.proj.getActiveProject().getActiveProvider();
|
||||
IrisVision.launch(g, 0);
|
||||
sender.sendMessage("Opening Map!");
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
IrisAccess g = IrisWorlds.access(sender.player().getWorld());
|
||||
IrisVision.launch(g, 0);
|
||||
sender.sendMessage("Opening Map!");
|
||||
@@ -58,8 +49,7 @@ public class CommandIrisStudioMap extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,8 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisStudioOpen extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioOpen()
|
||||
{
|
||||
public class CommandIrisStudioOpen extends MortarCommand {
|
||||
public CommandIrisStudioOpen() {
|
||||
super("open", "o");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Create a new temporary world to design a dimension.");
|
||||
@@ -22,16 +20,13 @@ public class CommandIrisStudioOpen extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length < 1)
|
||||
{
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage("/iris std open <DIMENSION> (file name without .json)");
|
||||
return true;
|
||||
}
|
||||
@@ -41,8 +36,7 @@ public class CommandIrisStudioOpen extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[dimension]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,8 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisStudioPackage extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioPackage()
|
||||
{
|
||||
public class CommandIrisStudioPackage extends MortarCommand {
|
||||
public CommandIrisStudioPackage() {
|
||||
super("package", "pkg");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Package your dimension into a compressed format.");
|
||||
@@ -23,16 +21,13 @@ public class CommandIrisStudioPackage extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length == 0)
|
||||
{
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("/iris std package <DIMENSION> [-o] [-m]");
|
||||
return true;
|
||||
}
|
||||
@@ -42,10 +37,8 @@ public class CommandIrisStudioPackage extends MortarCommand
|
||||
boolean o = false;
|
||||
boolean m = true;
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equalsIgnoreCase("-o"))
|
||||
{
|
||||
for (String i : args) {
|
||||
if (i.equalsIgnoreCase("-o")) {
|
||||
o = true;
|
||||
}
|
||||
}
|
||||
@@ -58,8 +51,7 @@ public class CommandIrisStudioPackage extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[dimension] [-o] [-m]";
|
||||
}
|
||||
}
|
||||
|
||||
+28
-59
@@ -11,10 +11,8 @@ import com.volmit.iris.util.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CommandIrisStudioProfile extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioProfile()
|
||||
{
|
||||
public class CommandIrisStudioProfile extends MortarCommand {
|
||||
public CommandIrisStudioProfile() {
|
||||
super("profile", "blame");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Profile the specified project");
|
||||
@@ -27,10 +25,8 @@ public class CommandIrisStudioProfile extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
@@ -39,23 +35,17 @@ public class CommandIrisStudioProfile extends MortarCommand
|
||||
File f = null;
|
||||
File report = Iris.instance.getDataFile("profile.txt");
|
||||
KList<String> v = new KList<>();
|
||||
if(args.length == 0)
|
||||
{
|
||||
if(!Iris.proj.isProjectOpen())
|
||||
{
|
||||
if (args.length == 0) {
|
||||
if (!Iris.proj.isProjectOpen()) {
|
||||
sender.sendMessage("No open project. Either use /iris std beautify <project> or have a project open.");
|
||||
return;
|
||||
}
|
||||
|
||||
f = Iris.proj.getActiveProject().getPath();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
f = Iris.instance.getDataFolder("packs", args[0]);
|
||||
|
||||
if(!f.exists())
|
||||
{
|
||||
if (!f.exists()) {
|
||||
sender.sendMessage("Not a valid project.");
|
||||
return;
|
||||
}
|
||||
@@ -72,20 +62,17 @@ public class CommandIrisStudioProfile extends MortarCommand
|
||||
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()));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -95,8 +82,7 @@ public class CommandIrisStudioProfile extends MortarCommand
|
||||
|
||||
v.add("Noise Style Performance Impacts: ");
|
||||
|
||||
for(NoiseStyle i : styleTimings.sortKNumber())
|
||||
{
|
||||
for (NoiseStyle i : styleTimings.sortKNumber()) {
|
||||
v.add(i.name() + ": " + styleTimings.get(i));
|
||||
}
|
||||
|
||||
@@ -104,8 +90,7 @@ public class CommandIrisStudioProfile extends MortarCommand
|
||||
|
||||
sender.sendMessage("Calculating Interpolator Timings...");
|
||||
|
||||
for(InterpolationMethod i : InterpolationMethod.values())
|
||||
{
|
||||
for (InterpolationMethod i : InterpolationMethod.values()) {
|
||||
IrisInterpolator in = new IrisInterpolator();
|
||||
in.setFunction(i);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -134,8 +117,7 @@ public class CommandIrisStudioProfile extends MortarCommand
|
||||
|
||||
v.add("Noise Interpolator Performance Impacts: ");
|
||||
|
||||
for(InterpolationMethod i : interpolatorTimings.sortKNumber())
|
||||
{
|
||||
for (InterpolationMethod i : interpolatorTimings.sortKNumber()) {
|
||||
v.add(i.name() + ": " + interpolatorTimings.get(i));
|
||||
}
|
||||
|
||||
@@ -145,15 +127,13 @@ public class CommandIrisStudioProfile extends MortarCommand
|
||||
|
||||
KMap<String, KList<String>> btx = new KMap<>();
|
||||
|
||||
for(String i : data.getGeneratorLoader().getPossibleKeys())
|
||||
{
|
||||
for (String i : data.getGeneratorLoader().getPossibleKeys()) {
|
||||
KList<String> vv = new KList<>();
|
||||
IrisGenerator g = data.getGeneratorLoader().load(i);
|
||||
KList<IrisNoiseGenerator> composites = g.getAllComposites();
|
||||
double score = 0;
|
||||
int m = 0;
|
||||
for(IrisNoiseGenerator j : composites)
|
||||
{
|
||||
for (IrisNoiseGenerator j : composites) {
|
||||
m++;
|
||||
score += 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: ");
|
||||
|
||||
for(String i : generatorTimings.sortKNumber())
|
||||
{
|
||||
for (String i : generatorTimings.sortKNumber()) {
|
||||
v.add(i + ": " + generatorTimings.get(i));
|
||||
|
||||
btx.get(i).forEach((ii) -> v.add(" " + ii));
|
||||
@@ -178,15 +157,13 @@ public class CommandIrisStudioProfile extends MortarCommand
|
||||
|
||||
KMap<String, KList<String>> bt = new KMap<>();
|
||||
|
||||
for(String i : data.getBiomeLoader().getPossibleKeys())
|
||||
{
|
||||
for (String i : data.getBiomeLoader().getPossibleKeys()) {
|
||||
KList<String> vv = new KList<>();
|
||||
IrisBiome b = data.getBiomeLoader().load(i);
|
||||
double score = 0;
|
||||
|
||||
int m = 0;
|
||||
for(IrisBiomePaletteLayer j : b.getLayers())
|
||||
{
|
||||
for (IrisBiomePaletteLayer j : b.getLayers()) {
|
||||
m++;
|
||||
score += 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: ");
|
||||
|
||||
for(String i : biomeTimings.sortKNumber())
|
||||
{
|
||||
for (String i : biomeTimings.sortKNumber()) {
|
||||
v.add(i + ": " + biomeTimings.get(i));
|
||||
|
||||
bt.get(i).forEach((ff) -> v.add(" " + ff));
|
||||
@@ -211,8 +187,7 @@ public class CommandIrisStudioProfile extends MortarCommand
|
||||
|
||||
v.add("");
|
||||
|
||||
for(String i : data.getRegionLoader().getPossibleKeys())
|
||||
{
|
||||
for (String i : data.getRegionLoader().getPossibleKeys()) {
|
||||
IrisRegion b = data.getRegionLoader().load(i);
|
||||
double score = 0;
|
||||
|
||||
@@ -223,29 +198,25 @@ public class CommandIrisStudioProfile extends MortarCommand
|
||||
|
||||
v.add("Project Region Performance Impacts: ");
|
||||
|
||||
for(String i : regionTimings.sortKNumber())
|
||||
{
|
||||
for (String i : regionTimings.sortKNumber()) {
|
||||
v.add(i + ": " + regionTimings.get(i));
|
||||
}
|
||||
|
||||
v.add("");
|
||||
|
||||
double m = 0;
|
||||
for(double i : biomeTimings.v())
|
||||
{
|
||||
for (double i : biomeTimings.v()) {
|
||||
m += i;
|
||||
}
|
||||
m /= biomeTimings.size();
|
||||
double mm = 0;
|
||||
for(double i : generatorTimings.v())
|
||||
{
|
||||
for (double i : generatorTimings.v()) {
|
||||
mm += i;
|
||||
}
|
||||
mm /= generatorTimings.size();
|
||||
m += mm;
|
||||
double mmm = 0;
|
||||
for(double i : regionTimings.v())
|
||||
{
|
||||
for (double i : regionTimings.v()) {
|
||||
mmm += i;
|
||||
}
|
||||
mmm /= regionTimings.size();
|
||||
@@ -264,13 +235,11 @@ public class CommandIrisStudioProfile extends MortarCommand
|
||||
});
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[project]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandIrisStudioSummon extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioSummon()
|
||||
{
|
||||
public class CommandIrisStudioSummon extends MortarCommand {
|
||||
public CommandIrisStudioSummon() {
|
||||
super("summon", "spawnmob");
|
||||
setDescription("Spawn an Iris entity");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -29,39 +27,29 @@ public class CommandIrisStudioSummon extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
if (sender.isPlayer()) {
|
||||
Player p = sender.player();
|
||||
World world = p.getWorld();
|
||||
if(!IrisWorlds.isIrisWorld(world))
|
||||
{
|
||||
if (!IrisWorlds.isIrisWorld(world)) {
|
||||
sender.sendMessage("You must be in an iris world.");
|
||||
return true;
|
||||
}
|
||||
|
||||
IrisAccess g = IrisWorlds.access(world);
|
||||
if(args.length == 0)
|
||||
{
|
||||
for(String i : g.getData().getEntityLoader().getPossibleKeys())
|
||||
{
|
||||
if (args.length == 0) {
|
||||
for (String i : g.getData().getEntityLoader().getPossibleKeys()) {
|
||||
sender.sendMessage("- " + i);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
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.");
|
||||
return true;
|
||||
}
|
||||
@@ -69,10 +57,7 @@ public class CommandIrisStudioSummon extends MortarCommand
|
||||
Location vl = sender.player().getLocation().clone().add(0, 3, 0);
|
||||
e.spawn((Engine) g.getEngineAccess(vl.getBlockY()), vl);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sender.sendMessage("Players only.");
|
||||
}
|
||||
|
||||
@@ -80,8 +65,7 @@ public class CommandIrisStudioSummon extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
+8
-18
@@ -7,10 +7,8 @@ import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
public class CommandIrisStudioTPStudio extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioTPStudio()
|
||||
{
|
||||
public class CommandIrisStudioTPStudio extends MortarCommand {
|
||||
public CommandIrisStudioTPStudio() {
|
||||
super("tps", "stp", "tpstudio");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Go to the spawn of the currently open studio world.");
|
||||
@@ -23,10 +21,8 @@ public class CommandIrisStudioTPStudio extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
@@ -36,21 +32,16 @@ public class CommandIrisStudioTPStudio extends MortarCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!Iris.proj.isProjectOpen())
|
||||
{
|
||||
if (!Iris.proj.isProjectOpen()) {
|
||||
sender.sendMessage("There is not a studio currently loaded.");
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
sender.sendMessage("Teleporting you to the active studio world.");
|
||||
sender.player().teleport(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSpawnLocation());
|
||||
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.");
|
||||
}
|
||||
|
||||
@@ -58,8 +49,7 @@ public class CommandIrisStudioTPStudio extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,8 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisStudioUpdate extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioUpdate()
|
||||
{
|
||||
public class CommandIrisStudioUpdate extends MortarCommand {
|
||||
public CommandIrisStudioUpdate() {
|
||||
super("update", "upd", "u");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Update your dimension project.");
|
||||
@@ -23,27 +21,20 @@ public class CommandIrisStudioUpdate extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (!IrisSettings.get().isStudio()) {
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length == 0)
|
||||
{
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("/iris std package <DIMENSION>");
|
||||
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]);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
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
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "[dimension]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisWhat extends MortarCommand
|
||||
{
|
||||
public class CommandIrisWhat extends MortarCommand {
|
||||
@Command
|
||||
private CommandIrisWhatBlock block;
|
||||
|
||||
@@ -20,8 +19,7 @@ public class CommandIrisWhat extends MortarCommand
|
||||
@Command
|
||||
private CommandIrisWhatObjects objects;
|
||||
|
||||
public CommandIrisWhat()
|
||||
{
|
||||
public CommandIrisWhat() {
|
||||
super("what", "w", "?");
|
||||
setDescription("Get timings for this world");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -35,16 +33,14 @@ public class CommandIrisWhat extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
sender.sendMessage("Iris 'What' Commands:");
|
||||
printHelp(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,31 +8,12 @@ import com.volmit.iris.scaffold.engine.IrisAccess;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
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.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 java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommandIrisWhatBiome extends MortarCommand
|
||||
{
|
||||
public CommandIrisWhatBiome()
|
||||
{
|
||||
public class CommandIrisWhatBiome extends MortarCommand {
|
||||
public CommandIrisWhatBiome() {
|
||||
super("biome", "bi", "b");
|
||||
setDescription("Get the biome data you are in.");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -46,44 +27,30 @@ public class CommandIrisWhatBiome extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (sender.isPlayer()) {
|
||||
Player p = sender.player();
|
||||
World w = p.getWorld();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
|
||||
IrisAccess g = IrisWorlds.access(w);
|
||||
assert g != null;
|
||||
IrisBiome b = g.getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ());
|
||||
sender.sendMessage("IBiome: " + b.getLoadKey() + " (" + b.getDerivative().name() + ")");
|
||||
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
sender.sendMessage("Non-Iris Biome: " + p.getLocation().getBlock().getBiome().name());
|
||||
|
||||
if(p.getLocation().getBlock().getBiome().equals(Biome.CUSTOM))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (p.getLocation().getBlock().getBiome().equals(Biome.CUSTOM)) {
|
||||
try {
|
||||
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.");
|
||||
}
|
||||
|
||||
@@ -91,8 +58,7 @@ public class CommandIrisWhatBiome extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
package com.volmit.iris.manager.command.what;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.*;
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
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");
|
||||
setDescription("Get the block data for looking.");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@@ -24,18 +21,13 @@ public class CommandIrisWhatBlock extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
if (sender.isPlayer()) {
|
||||
BlockData bd;
|
||||
Player p = sender.player();
|
||||
try
|
||||
{
|
||||
try {
|
||||
bd = p.getTargetBlockExact(128, FluidCollisionMode.NEVER).getBlockData();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
} catch (NullPointerException e) {
|
||||
sender.sendMessage("Please look at any block, not at the sky");
|
||||
bd = null;
|
||||
}
|
||||
@@ -72,10 +64,7 @@ public class CommandIrisWhatBlock extends MortarCommand
|
||||
sender.sendMessage(C.YELLOW + "* Solid Block");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sender.sendMessage("Players only.");
|
||||
}
|
||||
|
||||
@@ -83,8 +72,7 @@ public class CommandIrisWhatBlock extends MortarCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
protected String getArgsUsage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user