diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index b9104754f..78210752e 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -17,7 +17,6 @@ body: 2. Do this... 3. Do that... 4. Observe the error... - render: txt validations: required: true - type: textarea diff --git a/build.gradle b/build.gradle index ab94995d0..d0e3e6aa9 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group 'com.volmit.iris' -version '1.5.6' +version '1.5.10' def apiVersion = '1.17' def name = 'Iris' def main = 'com.volmit.iris.Iris' @@ -76,8 +76,8 @@ shadowJar minimize() dependencies { include(dependency('org.zeroturnaround:zt-zip:1.14')) - include(dependency('io.papermc:paperlib:1.0.5')) include(dependency('com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2')) + include(dependency('io.papermc:paperlib:1.0.5')) } } @@ -92,6 +92,9 @@ dependencies { implementation 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT' implementation 'org.bukkit.craftbukkit:1.17:1.17' implementation 'org.bukkit.craftbukkit:1.17.1:1.17.1' + implementation 'org.bukkit.craftbukkit:1.16.5:1.16.5' + implementation 'org.bukkit.craftbukkit:1.16.3:1.16.3' + implementation 'org.bukkit.craftbukkit:1.16.1:1.16.1' implementation 'com.bergerkiller.bukkit:BKCommonLib:1.16.4-v2' implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT' implementation 'io.lumine.xikage:MythicMobs:4.9.1' diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index dd59cf35c..15d64ee5a 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -560,7 +560,25 @@ public class Iris extends VolmitPlugin implements Listener { } public boolean isMCA() { - return IrisSettings.get().getGenerator().isMcaPregenerator(); + return !IrisSettings.get().getGenerator().isDisableMCA(); + } + + public static void reportErrorChunk(int x, int z, Throwable e, String extra) { + if (IrisSettings.get().getGeneral().isDebug()) { + File f = instance.getDataFile("debug", "chunk-errors", "chunk."+ x + "." + z + ".txt"); + + if (!f.exists()) { + J.attempt(() -> { + PrintWriter pw = new PrintWriter(f); + pw.println("Thread: " + Thread.currentThread().getName()); + pw.println("First: " + new Date(M.ms())); + e.printStackTrace(pw); + pw.close(); + }); + } + + Iris.debug("Chunk " + x + "," + z + " Exception Logged: " + e.getClass().getSimpleName() + ": " + C.RESET + "" + C.LIGHT_PURPLE + e.getMessage()); + } } public static synchronized void reportError(Throwable e) { diff --git a/src/main/java/com/volmit/iris/core/IrisBoardManager.java b/src/main/java/com/volmit/iris/core/IrisBoardManager.java index 7d0bec2e5..59d9f3f90 100644 --- a/src/main/java/com/volmit/iris/core/IrisBoardManager.java +++ b/src/main/java/com/volmit/iris/core/IrisBoardManager.java @@ -21,7 +21,9 @@ package com.volmit.iris.core; import com.volmit.iris.Iris; import com.volmit.iris.core.tools.IrisWorlds; import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.framework.EngineParallaxManager; import com.volmit.iris.engine.framework.IrisAccess; +import com.volmit.iris.engine.object.IrisFeaturePositional; import com.volmit.iris.util.board.BoardManager; import com.volmit.iris.util.board.BoardProvider; import com.volmit.iris.util.board.BoardSettings; @@ -29,6 +31,7 @@ import com.volmit.iris.util.board.ScoreDirection; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.Form; +import com.volmit.iris.util.math.Position2; import com.volmit.iris.util.math.RollingSequence; import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.J; @@ -103,6 +106,12 @@ public class IrisBoardManager implements BoardProvider, Listener { int y = player.getLocation().getBlockY(); int z = player.getLocation().getBlockZ(); + if(g.getCompound() == null) + { + v.add("Loading..."); + return v; + } + Engine engine = g.getCompound().getEngineForHeight(y); int parallaxChunks = 0; @@ -128,11 +137,15 @@ public class IrisBoardManager implements BoardProvider, Listener { if (engine != null) { v.add("&7&m------------------"); + KList f = new KList<>(); + engine.getFramework().getEngineParallax().forEachFeature(x, z, f::add); + v.add(C.AQUA + "Engine" + C.GRAY + ": " + engine.getName() + " " + engine.getMinHeight() + "-" + engine.getMaxHeight()); v.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName()); v.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiome(x, y, z).getName()); v.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z))); v.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getFramework().getComplex().getSlopeStream().get(x, z), 2)); + v.add(C.AQUA + "Features " + C.GRAY + ": " + Form.f(f.size())); } if (Iris.jobCount() > 0) { diff --git a/src/main/java/com/volmit/iris/core/IrisDataManager.java b/src/main/java/com/volmit/iris/core/IrisDataManager.java index 849ee9459..0007d6e53 100644 --- a/src/main/java/com/volmit/iris/core/IrisDataManager.java +++ b/src/main/java/com/volmit/iris/core/IrisDataManager.java @@ -40,6 +40,7 @@ public class IrisDataManager { private ResourceLoader jigsawPoolLoader; private ResourceLoader jigsawStructureLoader; private ResourceLoader entityLoader; + private ResourceLoader modLoader; private ResourceLoader blockLoader; private ObjectResourceLoader objectLoader; private boolean closed; @@ -64,6 +65,7 @@ public class IrisDataManager { this.entityLoader = null; this.regionLoader = null; this.biomeLoader = null; + this.modLoader = null; this.dimensionLoader = null; this.jigsawPoolLoader = null; this.jigsawPieceLoader = null; @@ -92,6 +94,7 @@ public class IrisDataManager { this.entityLoader = new ResourceLoader<>(packs, this, "entities", "Entity", IrisEntity.class); this.regionLoader = new ResourceLoader<>(packs, this, "regions", "Region", IrisRegion.class); this.biomeLoader = new ResourceLoader<>(packs, this, "biomes", "Biome", IrisBiome.class); + this.modLoader = new ResourceLoader<>(packs, this, "mods", "Mod", IrisMod.class); this.dimensionLoader = new ResourceLoader<>(packs, this, "dimensions", "Dimension", IrisDimension.class); this.jigsawPoolLoader = new ResourceLoader<>(packs, this, "jigsaw-pools", "Jigsaw Pool", IrisJigsawPool.class); this.jigsawStructureLoader = new ResourceLoader<>(packs, this, "jigsaw-structures", "Jigsaw Structure", IrisJigsawStructure.class); @@ -111,6 +114,7 @@ public class IrisDataManager { objectLoader.clearCache(); jigsawPieceLoader.clearCache(); jigsawPoolLoader.clearCache(); + modLoader.clearCache(); jigsawStructureLoader.clearCache(); regionLoader.clearCache(); dimensionLoader.clearCache(); @@ -127,6 +131,7 @@ public class IrisDataManager { blockLoader.clearList(); entityLoader.clearList(); biomeLoader.clearList(); + modLoader.clearList(); regionLoader.clearList(); dimensionLoader.clearList(); generatorLoader.clearList(); @@ -144,6 +149,10 @@ public class IrisDataManager { return loadAny(key, (dm) -> dm.getBiomeLoader().load(key, false)); } + public static IrisMod loadAnyMod(String key) { + return loadAny(key, (dm) -> dm.getModLoader().load(key, false)); + } + public static IrisJigsawPiece loadAnyJigsawPiece(String key) { return loadAny(key, (dm) -> dm.getJigsawPieceLoader().load(key, false)); } diff --git a/src/main/java/com/volmit/iris/core/IrisProject.java b/src/main/java/com/volmit/iris/core/IrisProject.java index 446bb3013..e49fd16c1 100644 --- a/src/main/java/com/volmit/iris/core/IrisProject.java +++ b/src/main/java/com/volmit/iris/core/IrisProject.java @@ -21,15 +21,19 @@ package com.volmit.iris.core; import com.google.gson.Gson; import com.volmit.iris.Iris; import com.volmit.iris.core.nms.INMS; +import com.volmit.iris.core.pregenerator.PregenTask; import com.volmit.iris.core.report.Report; import com.volmit.iris.core.report.ReportType; +import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisWorldCreator; import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.IrisAccess; import com.volmit.iris.engine.object.*; +import com.volmit.iris.engine.parallel.MultiBurst; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KSet; +import com.volmit.iris.util.exceptions.IrisException; import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.Form; import com.volmit.iris.util.io.IO; @@ -171,13 +175,13 @@ public class IrisProject { return collectFiles(path, json); } - public void open(VolmitSender sender) { + public void open(VolmitSender sender) throws IrisException { open(sender, () -> { }); } - public void open(VolmitSender sender, Runnable onDone) { + public void open(VolmitSender sender, Runnable onDone) throws IrisException { if (isOpen()) { close(); } @@ -381,6 +385,7 @@ public class IrisProject { schemas.put(getSchemaEntry(IrisDimension.class, dm, "/dimensions/*.json", "/dimensions/*/*.json", "/dimensions/*/*/*.json")); schemas.put(getSchemaEntry(IrisEntity.class, dm, "/entities/*.json", "/entities/*/*.json", "/entities/*/*/*.json")); schemas.put(getSchemaEntry(IrisBiome.class, dm, "/biomes/*.json", "/biomes/*/*.json", "/biomes/*/*/*.json")); + schemas.put(getSchemaEntry(IrisMod.class, dm, "/mods/*.json", "/mods/*/*.json", "/mods/*/*/*.json")); schemas.put(getSchemaEntry(IrisRegion.class, dm, "/regions/*.json", "/regions/*/*.json", "/regions/*/*/*.json")); schemas.put(getSchemaEntry(IrisGenerator.class, dm, "/generators/*.json", "/generators/*/*.json", "/generators/*/*/*.json")); schemas.put(getSchemaEntry(IrisJigsawPiece.class, dm, "/jigsaw-pieces/*.json", "/jigsaw-pieces/*/*.json", "/jigsaw-pieces/*/*/*.json")); @@ -422,7 +427,27 @@ public class IrisProject { } //TODO: EXPORT JIGSAW PIECES FROM STRUCTURES + dimension.getFeatures().forEach((i) -> { + if (i.getZone().getCustomBiome() != null) + { + biomes.add(dm.getBiomeLoader().load(i.getZone().getCustomBiome())); + } + }); + dimension.getSpecificFeatures().forEach((i) -> { + if (i.getFeature().getCustomBiome() != null) + { + biomes.add(dm.getBiomeLoader().load(i.getFeature().getCustomBiome())); + } + }); dimension.getRegions().forEach((i) -> regions.add(dm.getRegionLoader().load(i))); + regions.forEach((r) -> { + r.getFeatures().forEach((i) -> { + if (i.getZone().getCustomBiome() != null) + { + biomes.add(dm.getBiomeLoader().load(i.getZone().getCustomBiome())); + } + }); + }); dimension.getLoot().getTables().forEach((i) -> loot.add(dm.getLootLoader().load(i))); regions.forEach((i) -> biomes.addAll(i.getAllBiomes(null))); biomes.forEach((i) -> i.getGenerators().forEach((j) -> generators.add(j.getCachedGenerator(null)))); @@ -432,6 +457,19 @@ public class IrisProject { regions.forEach((r) -> r.getEntitySpawnOverrides().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity())))); dimension.getEntitySpawnOverrides().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity()))); biomes.forEach((r) -> r.getEntityInitialSpawns().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity())))); + + for(int f = 0; f < IrisSettings.get().getGenerator().getMaxBiomeChildDepth(); f++) + { + biomes.copy().forEach((r) -> { + r.getFeatures().forEach((i) -> { + if (i.getZone().getCustomBiome() != null) + { + biomes.add(dm.getBiomeLoader().load(i.getZone().getCustomBiome())); + } + }); + }); + } + regions.forEach((r) -> r.getEntityInitialSpawns().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity())))); dimension.getEntityInitialSpawns().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity()))); KMap renameObjects = new KMap<>(); diff --git a/src/main/java/com/volmit/iris/core/IrisSettings.java b/src/main/java/com/volmit/iris/core/IrisSettings.java index 84c583a9f..b9df38381 100644 --- a/src/main/java/com/volmit/iris/core/IrisSettings.java +++ b/src/main/java/com/volmit/iris/core/IrisSettings.java @@ -64,6 +64,17 @@ public class IrisSettings { return Math.max(2, c < 0 ? Runtime.getRuntime().availableProcessors() / -c : c); } + public void forceSave() { + File s = Iris.instance.getDataFile("settings.json"); + + try { + IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4)); + } catch (JSONException | IOException e) { + e.printStackTrace(); + Iris.reportError(e); + } + } + @Data public static class IrisSettingsCache { public int complexCacheSize = 131072; @@ -108,7 +119,7 @@ public class IrisSettings { public static class IrisSettingsGenerator { public String defaultWorldType = "overworld"; - public boolean mcaPregenerator = false; + public boolean disableMCA = false; public boolean systemEffects = true; public boolean systemEntitySpawnOverrides = true; public boolean systemEntityInitialSpawns = true; diff --git a/src/main/java/com/volmit/iris/core/ProjectManager.java b/src/main/java/com/volmit/iris/core/ProjectManager.java index 50b2d59f2..371099b2b 100644 --- a/src/main/java/com/volmit/iris/core/ProjectManager.java +++ b/src/main/java/com/volmit/iris/core/ProjectManager.java @@ -24,6 +24,7 @@ import com.volmit.iris.Iris; import com.volmit.iris.engine.cache.AtomicCache; import com.volmit.iris.engine.object.IrisDimension; import com.volmit.iris.util.collection.KMap; +import com.volmit.iris.util.exceptions.IrisException; import com.volmit.iris.util.format.Form; import com.volmit.iris.util.io.IO; import com.volmit.iris.util.json.JSONException; @@ -171,7 +172,7 @@ public class ProjectManager { Iris.info("Assuming URL " + url); String branch = "master"; String[] nodes = url.split("\\Q/\\E"); - String repo = nodes[0] + "/" + nodes[1]; + String repo = nodes.length == 1 ? "IrisDimensions/" + nodes[0] : nodes[0] + "/" + nodes[1]; branch = nodes.length > 2 ? nodes[2] : branch; download(sender, repo, branch, trim, forceOverwrite); } catch (Throwable e) { @@ -192,6 +193,13 @@ public class ProjectManager { File temp = Iris.getTemp(); File work = new File(temp, "dl-" + UUID.randomUUID()); File packs = getWorkspaceFolder(); + + if (zip == null || !zip.exists()) { + sender.sendMessage("Failed to find pack at " + url); + sender.sendMessage("Make sure you specified the correct repo and branch!"); + sender.sendMessage("For example: /iris download IrisDimensions/overworld branch=master"); + return; + } sender.sendMessage("Unpacking " + repo); try { ZipUtil.unpack(zip, work); @@ -326,7 +334,7 @@ public class ProjectManager { } } - public void open(VolmitSender sender, String dimm, Runnable onDone) { + public void open(VolmitSender sender, String dimm, Runnable onDone) throws IrisException { if (isProjectOpen()) { close(); } diff --git a/src/main/java/com/volmit/iris/core/command/CommandIris.java b/src/main/java/com/volmit/iris/core/command/CommandIris.java index d69aa10e3..8ee4fb1f8 100644 --- a/src/main/java/com/volmit/iris/core/command/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/command/CommandIris.java @@ -36,6 +36,9 @@ public class CommandIris extends MortarCommand { @Command private CommandIrisVerify verify; + @Command + private CommandIrisDebug debug; + @Command private CommandIrisFix fix; @@ -48,9 +51,6 @@ public class CommandIris extends MortarCommand { @Command private CommandIrisObject object; - @Command - private CommandIrisRegen regen; - @Command private CommandIrisDownload download; @@ -60,6 +60,9 @@ public class CommandIris extends MortarCommand { @Command private CommandIrisUpdateWorld updateWorld; + @Command + private CommandIrisBitwise bitwise; + @Command private CommandIrisWhat what; diff --git a/src/main/java/com/volmit/iris/core/command/CommandIrisBitwise.java b/src/main/java/com/volmit/iris/core/command/CommandIrisBitwise.java new file mode 100644 index 000000000..dff392894 --- /dev/null +++ b/src/main/java/com/volmit/iris/core/command/CommandIrisBitwise.java @@ -0,0 +1,124 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.core.command; + +import com.volmit.iris.Iris; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.format.C; +import com.volmit.iris.util.plugin.MortarCommand; +import com.volmit.iris.util.plugin.VolmitSender; +import com.volmit.iris.util.scheduling.J; + +import java.util.Arrays; + +public class CommandIrisBitwise extends MortarCommand { + public CommandIrisBitwise() { + super("bitwise", "bits", "bw"); + requiresPermission(Iris.perm.studio); + setDescription("Run bitwise calculations"); + setCategory("Studio"); + } + + + @Override + public void addTabOptions(VolmitSender sender, String[] args, KList list) { + + } + + @Override + public boolean handle(VolmitSender sender, String[] args) { + if(args.length != 3) + { + sender.sendMessage("/iris bw " + getArgsUsage()); + } + + try + { + if(args[0].contains(",")) + { + KList r = new KList<>(); + + for(String i : args[0].split("\\Q,\\E")) + { + int a = Integer.parseInt(i); + String op = args[1]; + int b = Integer.parseInt(args[2]); + int v = 0; + + switch (op) { + case "|" -> v = a | b; + case "&" -> v = a & b; + case "^" -> v = a ^ b; + case "%" -> v = a % b; + case ">>" -> v = a >> b; + case "<<" -> v = a << b; + default -> { + { + sender.sendMessage("Error Invalid operation"); + return true; + } + } + } + ; + + r.add(v); + sender.sendMessage("Result: " + r.toString(",")); + } + } + + else + { + int a = Integer.parseInt(args[0]); + String op = args[1]; + int b = Integer.parseInt(args[2]); + int v = 0; + + switch (op) { + case "|" -> v = a | b; + case "&" -> v = a & b; + case "^" -> v = a ^ b; + case "%" -> v = a % b; + case ">>" -> v = a >> b; + case "<<" -> v = a << b; + default -> { + { + sender.sendMessage("Error Invalid operation"); + return true; + } + } + } + ; + + sender.sendMessage("Result: " + v); + } + } + + catch(Throwable ignored) + { + + } + + return true; + } + + @Override + protected String getArgsUsage() { + return " [|,&,^,>>,<<,%] "; + } +} diff --git a/src/main/java/com/volmit/iris/core/command/CommandIrisDebug.java b/src/main/java/com/volmit/iris/core/command/CommandIrisDebug.java new file mode 100644 index 000000000..184948e03 --- /dev/null +++ b/src/main/java/com/volmit/iris/core/command/CommandIrisDebug.java @@ -0,0 +1,54 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.core.command; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.IrisSettings; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.plugin.MortarCommand; +import com.volmit.iris.util.plugin.VolmitSender; + +public class CommandIrisDebug extends MortarCommand { + public CommandIrisDebug() { + super("debug", "dbg"); + requiresPermission(Iris.perm.studio); + setDescription("Toggle debug mode"); + setCategory("Studio"); + } + + + @Override + public void addTabOptions(VolmitSender sender, String[] args, KList list) { + + } + + @Override + public boolean handle(VolmitSender sender, String[] args) { + IrisSettings.get().getGeneral().setDebug(!IrisSettings.get().getGeneral().isDebug()); + IrisSettings.get().forceSave(); + sender.sendMessage("Debug Mode: " + (IrisSettings.get().getGeneral().isDebug() ? "Enabled" : "Disabled")); + + return true; + } + + @Override + protected String getArgsUsage() { + return " [|,&,^,>>,<<,%] "; + } +} diff --git a/src/main/java/com/volmit/iris/core/command/CommandIrisDownload.java b/src/main/java/com/volmit/iris/core/command/CommandIrisDownload.java index d73edd739..824be4a52 100644 --- a/src/main/java/com/volmit/iris/core/command/CommandIrisDownload.java +++ b/src/main/java/com/volmit/iris/core/command/CommandIrisDownload.java @@ -25,6 +25,8 @@ import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.scheduling.J; +import java.util.Arrays; + public class CommandIrisDownload extends MortarCommand { public CommandIrisDownload() { super("download", "down", "dl"); @@ -42,28 +44,44 @@ public class CommandIrisDownload extends MortarCommand { @Override public boolean handle(VolmitSender sender, String[] args) { if (args.length < 1) { - sender.sendMessage("/iris dl " + C.BOLD + ""); + sender.sendMessage("/iris dl " + C.BOLD + " [BRANCH=master]"); return true; } boolean trim = false; + String branch = "master"; - for (String i : args) { + for (String i : Arrays.copyOfRange(args, 1, args.length)) { if (i.equals("-t") || i.equals("--trim")) { trim = true; break; + } else if (i.startsWith("-")) { + sender.sendMessage("Invalid parameter."); + sender.sendMessage("/iris dl " + C.BOLD + " [BRANCH=master]"); + return true; + } else { + branch = i; + if (branch.toLowerCase().startsWith("branch=")) branch = branch.substring(7); } } boolean btrim = trim; - J.a(() -> Iris.proj.downloadSearch(sender, args[0], btrim)); + String pack = args[0]; + + if (!pack.contains("/")) { + pack = "IrisDimensions/" + pack; + } + + final String finalPack = pack + "/" + branch; + + J.a(() -> Iris.proj.downloadSearch(sender, finalPack, btrim)); return true; } @Override protected String getArgsUsage() { - return " [-t/--trim]"; + return " [branch=master] [-t/--trim]"; } } diff --git a/src/main/java/com/volmit/iris/core/command/jigsaw/CommandIrisJigsawPlace.java b/src/main/java/com/volmit/iris/core/command/jigsaw/CommandIrisJigsawPlace.java index c9e216a50..301c3adbc 100644 --- a/src/main/java/com/volmit/iris/core/command/jigsaw/CommandIrisJigsawPlace.java +++ b/src/main/java/com/volmit/iris/core/command/jigsaw/CommandIrisJigsawPlace.java @@ -21,6 +21,7 @@ package com.volmit.iris.core.command.jigsaw; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisDataManager; import com.volmit.iris.core.IrisSettings; +import com.volmit.iris.core.tools.IrisWorlds; import com.volmit.iris.engine.jigsaw.PlannedStructure; import com.volmit.iris.engine.object.IrisJigsawStructure; import com.volmit.iris.engine.object.IrisPosition; @@ -41,7 +42,16 @@ public class CommandIrisJigsawPlace extends MortarCommand { @Override public void addTabOptions(VolmitSender sender, String[] args, KList list) { - + if ((args.length == 0 || args.length == 1) && sender.isPlayer() && IrisWorlds.isIrisWorld(sender.player().getWorld())) { + IrisDataManager data = IrisWorlds.access(sender.player().getWorld()).getData(); + if (data == null) { + sender.sendMessage("Tab complete options only work for jigsaw structures while in an Iris world."); + } else if(args.length == 0) { + list.add(data.getJigsawStructureLoader().getPossibleKeys()); + }else if(args.length == 1) { + list.add(data.getJigsawStructureLoader().getPossibleKeys(args[0])); + } + } } @Override diff --git a/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectPaste.java b/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectPaste.java index 65507966e..542456f5d 100644 --- a/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectPaste.java +++ b/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectPaste.java @@ -23,6 +23,7 @@ import com.volmit.iris.core.IrisDataManager; import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.ProjectManager; import com.volmit.iris.core.WandManager; +import com.volmit.iris.core.tools.IrisWorlds; import com.volmit.iris.engine.object.IrisObject; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.plugin.MortarCommand; @@ -44,7 +45,16 @@ public class CommandIrisObjectPaste extends MortarCommand { @Override public void addTabOptions(VolmitSender sender, String[] args, KList list) { - + if ((args.length == 0 || args.length == 1) && sender.isPlayer() && IrisWorlds.isIrisWorld(sender.player().getWorld())) { + IrisDataManager data = IrisWorlds.access(sender.player().getWorld()).getData(); + if (data == null) { + sender.sendMessage("Tab complete options only work for objects while in an Iris world."); + } else if(args.length == 0) { + list.add(data.getObjectLoader().getPossibleKeys()); + }else if(args.length == 1) { + list.add(data.getObjectLoader().getPossibleKeys(args[0])); + } + } } @Override diff --git a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExplorer.java b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExplorer.java index 1967762af..9d738ba07 100644 --- a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExplorer.java +++ b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExplorer.java @@ -19,8 +19,10 @@ package com.volmit.iris.core.command.studio; import com.volmit.iris.Iris; +import com.volmit.iris.core.IrisDataManager; import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.gui.NoiseExplorerGUI; +import com.volmit.iris.core.tools.IrisWorlds; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.plugin.Command; import com.volmit.iris.util.plugin.MortarCommand; diff --git a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExplorerGenerator.java b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExplorerGenerator.java index 943b400cd..e7402bf52 100644 --- a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExplorerGenerator.java +++ b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExplorerGenerator.java @@ -22,6 +22,7 @@ import com.volmit.iris.Iris; import com.volmit.iris.core.IrisDataManager; import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.gui.NoiseExplorerGUI; +import com.volmit.iris.core.tools.IrisWorlds; import com.volmit.iris.engine.object.IrisGenerator; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.math.RNG; @@ -38,7 +39,16 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand { @Override public void addTabOptions(VolmitSender sender, String[] args, KList list) { - + if ((args.length == 0 || args.length == 1) && 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 (?)"); + } else if(args.length == 0) { + list.add(data.getGeneratorLoader().getPossibleKeys()); + }else if(args.length == 1) { + list.add(data.getGeneratorLoader().getPossibleKeys(args[0])); + } + } } @Override diff --git a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioGoto.java b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioGoto.java index 1fc66fcd5..238a8e389 100644 --- a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioGoto.java +++ b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioGoto.java @@ -40,8 +40,6 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; public class CommandIrisStudioGoto extends MortarCommand { - private static final AtomicBoolean looking = new AtomicBoolean(false); - public CommandIrisStudioGoto() { super("goto", "find", "g"); setDescription("Find any region or biome"); @@ -51,14 +49,16 @@ public class CommandIrisStudioGoto extends MortarCommand { @Override public void addTabOptions(VolmitSender sender, String[] args, KList list) { - if (args.length == 0 && sender.isPlayer() && IrisWorlds.isIrisWorld(sender.player().getWorld())) { + if ((args.length == 0 || args.length == 1) && 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 (?)"); - } else { + } else if(args.length == 0) { list.add(data.getBiomeLoader().getPossibleKeys()); list.add(data.getRegionLoader().getPossibleKeys()); - //TODO: Remove comment here -> list.add(data.getObjectLoader().getPossibleKeys()); + }else if(args.length == 1) { + list.add(data.getBiomeLoader().getPossibleKeys(args[0])); + list.add(data.getRegionLoader().getPossibleKeys(args[0])); } } } @@ -72,10 +72,6 @@ public class CommandIrisStudioGoto extends MortarCommand { } if (sender.isPlayer()) { - if (looking.get()) { - sender.sendMessage("A Search is already running, please wait!"); - } - Player p = sender.player(); World world = p.getWorld(); @@ -88,12 +84,10 @@ public class CommandIrisStudioGoto extends MortarCommand { IrisBiome b = IrisDataManager.loadAnyBiome(args[0]); IrisRegion r = IrisDataManager.loadAnyRegion(args[0]); - looking.set(true); 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")); - looking.set(false); if (l == null) { sender.sendMessage("Couldn't find " + b.getName() + "."); } else { @@ -105,7 +99,6 @@ public class CommandIrisStudioGoto extends MortarCommand { 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")); - looking.set(false); if (l == null) { sender.sendMessage("Couldn't find " + r.getName() + "."); } else { diff --git a/src/main/java/com/volmit/iris/core/command/world/CommandIrisVerify.java b/src/main/java/com/volmit/iris/core/command/world/CommandIrisVerify.java index ab0f56e02..89dcddb2b 100644 --- a/src/main/java/com/volmit/iris/core/command/world/CommandIrisVerify.java +++ b/src/main/java/com/volmit/iris/core/command/world/CommandIrisVerify.java @@ -27,13 +27,8 @@ import com.volmit.iris.engine.framework.IrisAccess; import com.volmit.iris.engine.parallel.BurstExecutor; import com.volmit.iris.engine.parallel.MultiBurst; import com.volmit.iris.util.collection.KList; -import com.volmit.iris.util.collection.KSet; -import com.volmit.iris.util.format.Form; -import com.volmit.iris.util.math.Position2; -import com.volmit.iris.util.math.Spiraler; import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.VolmitSender; -import com.volmit.iris.util.scheduling.J; import java.io.File; import java.io.IOException; @@ -78,6 +73,11 @@ public class CommandIrisVerify extends MortarCommand { { sender.sendMessage("Found Missing Chunk " + i.getName() + ", chunk #" + j + "," + k + " (see " + (((rx << 5)<<4)+(j<<4)) + "," + (((rz << 5)<<4)+(k<<4))); } + + else if(c.sectionCount() == 0) + { + sender.sendMessage("Found Missing Chunk (valid, but 0 sections) " + i.getName() + ", chunk #" + j + "," + k + " (see " + (((rx << 5)<<4)+(j<<4)) + "," + (((rz << 5)<<4)+(k<<4))); + } } } } catch (IOException ioException) { diff --git a/src/main/java/com/volmit/iris/core/gui/NoiseExplorerGUI.java b/src/main/java/com/volmit/iris/core/gui/NoiseExplorerGUI.java index ddc23e332..741122427 100644 --- a/src/main/java/com/volmit/iris/core/gui/NoiseExplorerGUI.java +++ b/src/main/java/com/volmit/iris/core/gui/NoiseExplorerGUI.java @@ -19,8 +19,12 @@ package com.volmit.iris.core.gui; import com.volmit.iris.Iris; +import com.volmit.iris.engine.hunk.Hunk; +import com.volmit.iris.engine.hunk.storage.ArrayHunk; import com.volmit.iris.engine.noise.CNG; import com.volmit.iris.engine.object.NoiseStyle; +import com.volmit.iris.engine.parallel.BurstExecutor; +import com.volmit.iris.engine.parallel.MultiBurst; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.function.Function2; import com.volmit.iris.util.math.M; @@ -34,6 +38,7 @@ import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.awt.event.*; +import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.concurrent.locks.ReentrantLock; @@ -44,7 +49,7 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener { static JComboBox combo; @SuppressWarnings("CanBeFinal") - RollingSequence r = new RollingSequence(90); + RollingSequence r = new RollingSequence(290); @SuppressWarnings("CanBeFinal") boolean colorMode = true; double scale = 1; @@ -53,9 +58,9 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener { static double ascale = 10; CNG cng = NoiseStyle.STATIC.create(new RNG(RNG.r.nextLong())); @SuppressWarnings("CanBeFinal") - GroupedExecutor gx = new GroupedExecutor(Runtime.getRuntime().availableProcessors(), Thread.MAX_PRIORITY, "Iris Renderer"); + MultiBurst gx = new MultiBurst("Iris Noise Renderer", Thread.MAX_PRIORITY, Runtime.getRuntime().availableProcessors()); ReentrantLock l = new ReentrantLock(); - int[][] co; + BufferedImage img; int w = 0; int h = 0; Function2 generator; @@ -161,7 +166,7 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener { } PrecisionStopwatch p = PrecisionStopwatch.start(); - int accuracy = hd ? 1 : M.clip((r.getAverage() / 6D), 1D, 128D).intValue(); + int accuracy = hd ? 1 : M.clip((r.getAverage() / 12D), 2D, 128D).intValue(); accuracy = down ? accuracy * 4 : accuracy; int v = 1000; @@ -170,45 +175,41 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener { if (getParent().getWidth() != w || getParent().getHeight() != h) { w = getParent().getWidth(); h = getParent().getHeight(); - co = null; + img = null; } - if (co == null) { - co = new int[w][h]; + if (img == null) { + img = new BufferedImage(w/accuracy, h/accuracy, BufferedImage.TYPE_INT_RGB); } - for (int x = 0; x < w; x += accuracy) { + BurstExecutor e = gx.burst(w); + + for (int x = 0; x < w/accuracy; x ++) { int xx = x; - for (int z = 0; z < h; z += accuracy) { - int zz = z; - gx.queue("a", () -> - { - double n = generator != null ? generator.apply((xx * ascale) + oxp, (zz * ascale) + ozp) : cng.noise((xx * ascale) + oxp, tz, (zz * ascale) + ozp); + int finalAccuracy = accuracy; + e.queue(() -> { + for (int z = 0; z < h/finalAccuracy; z++) { + double n = generator != null ? generator.apply(((xx*finalAccuracy) * ascale) + oxp, ((z*finalAccuracy) * ascale) + ozp) : cng.noise(((xx*finalAccuracy) * ascale) + oxp, tz, ((z*finalAccuracy) * ascale) + ozp); + n = n > 1 ? 1 : n < 0 ? 0 : n; - if (n > 1 || n < 0) { - return; + try + { + Color color = colorMode ? Color.getHSBColor((float) (n), 1f - (float) (n * n * n * n * n * n), 1f - (float) n) : Color.getHSBColor(0f, 0f, (float) n); + int rgb = color.getRGB(); + img.setRGB(xx, z, rgb); } - Color color = colorMode ? Color.getHSBColor((float) (n), 1f - (float) (n * n * n * n * n * n), 1f - (float) n) : Color.getHSBColor(0f, 0f, (float) n); - int rgb = color.getRGB(); - co[xx][zz] = rgb; - }); - } + catch(Throwable xxx) + { - gx.waitFor("a"); - - if (hd && p.getMilliseconds() > v) { - break; - } + } + } + }); } - for (int x = 0; x < getParent().getWidth(); x += accuracy) { - for (int z = 0; z < getParent().getHeight(); z += accuracy) { - gg.setColor(new Color(co[x][z])); - gg.fillRect(x, z, accuracy, accuracy); - } - } + e.complete(); + gg.drawImage(img, 0, 0, getParent().getWidth()*accuracy, getParent().getHeight()*accuracy, (img, infoflags, x, y, width, height) -> true); } p.end(); diff --git a/src/main/java/com/volmit/iris/core/nms/INMS.java b/src/main/java/com/volmit/iris/core/nms/INMS.java index f624fa418..86de92172 100644 --- a/src/main/java/com/volmit/iris/core/nms/INMS.java +++ b/src/main/java/com/volmit/iris/core/nms/INMS.java @@ -20,6 +20,9 @@ package com.volmit.iris.core.nms; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisSettings; +import com.volmit.iris.core.nms.v16_1.NMSBinding16_1; +import com.volmit.iris.core.nms.v16_2.NMSBinding16_2; +import com.volmit.iris.core.nms.v16_3.NMSBinding16_3; import com.volmit.iris.core.nms.v17_1.NMSBinding17_1; import com.volmit.iris.core.nms.v1X.NMSBinding1X; import com.volmit.iris.util.collection.KMap; @@ -28,7 +31,11 @@ import org.bukkit.Bukkit; public class INMS { //@builder private static final KMap> bindings = new KMap>() - .qput("v1_17_R1", NMSBinding17_1.class); + .qput("v1_17_R1", NMSBinding17_1.class) + .qput("v1_16_R3", NMSBinding16_3 .class) + .qput("v1_16_R2", NMSBinding16_2.class) + .qput("v1_16_R1", NMSBinding16_1.class) + ; //@done private static final INMSBinding binding = bind(); diff --git a/src/main/java/com/volmit/iris/core/nms/INMSBinding.java b/src/main/java/com/volmit/iris/core/nms/INMSBinding.java index 5935699fc..d501ab80a 100644 --- a/src/main/java/com/volmit/iris/core/nms/INMSBinding.java +++ b/src/main/java/com/volmit/iris/core/nms/INMSBinding.java @@ -25,8 +25,14 @@ import org.bukkit.block.Biome; import org.bukkit.generator.ChunkGenerator; public interface INMSBinding { + boolean supportsCustomHeight(); + Object getBiomeBaseFromId(int id); + int getMinHeight(World world); + + boolean supportsCustomBiomes(); + int getTrueBiomeBaseId(Object biomeBase); Object getTrueBiomeBase(Location location); diff --git a/src/main/java/com/volmit/iris/core/nms/v16_1/NMSBinding16_1.java b/src/main/java/com/volmit/iris/core/nms/v16_1/NMSBinding16_1.java new file mode 100644 index 000000000..703c5ee4a --- /dev/null +++ b/src/main/java/com/volmit/iris/core/nms/v16_1/NMSBinding16_1.java @@ -0,0 +1,161 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.core.nms.v16_1; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.nms.INMSBinding; +import com.volmit.iris.util.collection.KMap; +import net.minecraft.server.v1_16_R1.*; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Biome; +import org.bukkit.craftbukkit.v1_16_R1.CraftWorld; +import org.bukkit.generator.ChunkGenerator; + +import java.lang.reflect.Field; + +public class NMSBinding16_1 implements INMSBinding { + private final KMap baseBiomeCache = new KMap<>(); + private Field biomeStorageCache = null; + + public boolean supportsDataPacks() { + return true; + } + + private Field getFieldForBiomeStorage(Object storage) { + Field f = biomeStorageCache; + + if (f != null) { + return f; + } + try { + + f = storage.getClass().getDeclaredField("biome"); + f.setAccessible(true); + return f; + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + Iris.error(storage.getClass().getCanonicalName()); + } + + biomeStorageCache = f; + return null; + } + + private IRegistryWritable getCustomBiomeRegistry() { + return null; + } + + @Override + public Object getBiomeBaseFromId(int id) { + return null; + } + + @Override + public int getMinHeight(World world) { + return 0; + } + + @Override + public boolean supportsCustomHeight() { + return false; + } + + @Override + public boolean supportsCustomBiomes() { + return false; + } + + @Override + public int getTrueBiomeBaseId(Object biomeBase) { + return -1; + } + + @Override + public Object getTrueBiomeBase(Location location) { + return ((CraftWorld) location.getWorld()).getHandle().getBiome(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + } + + @Override + public String getTrueBiomeBaseKey(Location location) { + return getKeyForBiomeBase(getTrueBiomeBase(location)); + } + + @Override + public Object getCustomBiomeBaseFor(String mckey) { + try { + return null; + } catch (Throwable e) { + Iris.reportError(e); + } + + return null; + } + + @SuppressWarnings("OptionalGetWithoutIsPresent") + @Override + public String getKeyForBiomeBase(Object biomeBase) { + return getCustomBiomeRegistry().c((BiomeBase) biomeBase).get().a().toString(); + } + + @Override + public Object getBiomeBase(World world, Biome biome) { + return null; // Can't find IRegistryCustom in 16_R1 + } + + @Override + public Object getBiomeBase(Object registry, Biome biome) { + Object v = baseBiomeCache.get(biome); + + if (v != null) { + return v; + } + //noinspection unchecked + v = org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock.biomeToBiomeBase(biome); + if (v == null) { + // Ok so there is this new biome name called "CUSTOM" in Paper's new releases. + // But, this does NOT exist within CraftBukkit which makes it return an error. + // So, we will just return the ID that the plains biome returns instead. + return org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock.biomeToBiomeBase(Biome.PLAINS); + } + baseBiomeCache.put(biome, v); + return v; + } + + @Override + public int getBiomeId(Biome biome) { + return -1; + } + + @Override + public int countCustomBiomes() { + return 0; + } + + @Override + public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) { + + } + + @Override + public boolean isBukkit() { + return false; + } +} diff --git a/src/main/java/com/volmit/iris/core/nms/v16_2/NMSBinding16_2.java b/src/main/java/com/volmit/iris/core/nms/v16_2/NMSBinding16_2.java new file mode 100644 index 000000000..68e89f37e --- /dev/null +++ b/src/main/java/com/volmit/iris/core/nms/v16_2/NMSBinding16_2.java @@ -0,0 +1,267 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.core.nms.v16_2; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.nms.INMSBinding; +import com.volmit.iris.util.collection.KMap; +import net.minecraft.server.v1_16_R2.*; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Biome; +import org.bukkit.craftbukkit.v1_16_R2.CraftServer; +import org.bukkit.craftbukkit.v1_16_R2.CraftWorld; +import org.bukkit.generator.ChunkGenerator; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.concurrent.atomic.AtomicInteger; + +public class NMSBinding16_2 implements INMSBinding { + private final KMap baseBiomeCache = new KMap<>(); + private Field biomeStorageCache = null; + + public boolean supportsDataPacks() { + return true; + } + + private Object getBiomeStorage(ChunkGenerator.BiomeGrid g) { + try { + return getFieldForBiomeStorage(g).get(g); + } catch (IllegalAccessException e) { + Iris.reportError(e); + e.printStackTrace(); + } + + return null; + } + + private Field getFieldForBiomeStorage(Object storage) { + Field f = biomeStorageCache; + + if (f != null) { + return f; + } + try { + + f = storage.getClass().getDeclaredField("biome"); + f.setAccessible(true); + return f; + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + Iris.error(storage.getClass().getCanonicalName()); + } + + biomeStorageCache = f; + return null; + } + + private IRegistryWritable getCustomBiomeRegistry() { + return ((CraftServer) Bukkit.getServer()).getHandle().getServer().getCustomRegistry().b(IRegistry.ay); + } + + @Override + public Object getBiomeBaseFromId(int id) { + return getCustomBiomeRegistry().fromId(id); + } + + @Override + public int getTrueBiomeBaseId(Object biomeBase) { + return getCustomBiomeRegistry().a((BiomeBase) biomeBase); + } + + @Override + public Object getTrueBiomeBase(Location location) { + return ((CraftWorld) location.getWorld()).getHandle().getBiome(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + } + + @Override + public String getTrueBiomeBaseKey(Location location) { + return getKeyForBiomeBase(getTrueBiomeBase(location)); + } + + @Override + public Object getCustomBiomeBaseFor(String mckey) { + try { + return getCustomBiomeRegistry().d(ResourceKey.a(IRegistry.ay, new MinecraftKey(mckey))); + } catch (Throwable e) { + Iris.reportError(e); + } + + return null; + } + + @SuppressWarnings("OptionalGetWithoutIsPresent") + @Override + public String getKeyForBiomeBase(Object biomeBase) { + return getCustomBiomeRegistry().c((BiomeBase) biomeBase).get().a().toString(); + } + + @Override + public Object getBiomeBase(World world, Biome biome) { + return getBiomeBase(((CraftWorld) world).getHandle().r().b(IRegistry.ay), biome); + } + + @Override + public boolean supportsCustomBiomes() { + return false; + } + + @Override + public int getMinHeight(World world) { + return 0; + } + + @Override + public boolean supportsCustomHeight() { + return false; + } + + private Class[] classify(Object... par) { + Class[] g = new Class[par.length]; + for (int i = 0; i < g.length; i++) { + g[i] = par[i].getClass(); + } + + return g; + } + + private T invoke(Object from, String name, Object... par) { + try { + Method f = from.getClass().getDeclaredMethod(name, classify(par)); + f.setAccessible(true); + //noinspection unchecked + return (T) f.invoke(from, par); + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + } + + return null; + } + + private T invokeStatic(Class from, String name, Object... par) { + try { + Method f = from.getDeclaredMethod(name, classify(par)); + f.setAccessible(true); + //noinspection unchecked + return (T) f.invoke(null, par); + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + } + + return null; + } + + private T getField(Object from, String name) { + try { + Field f = from.getClass().getDeclaredField(name); + f.setAccessible(true); + //noinspection unchecked + return (T) f.get(from); + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + } + + return null; + } + + private T getStaticField(Class t, String name) { + try { + Field f = t.getDeclaredField(name); + f.setAccessible(true); + //noinspection unchecked + return (T) f.get(null); + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + } + + return null; + } + + @Override + public Object getBiomeBase(Object registry, Biome biome) { + Object v = baseBiomeCache.get(biome); + + if (v != null) { + return v; + } + //noinspection unchecked + v = org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, biome); + if (v == null) { + // Ok so there is this new biome name called "CUSTOM" in Paper's new releases. + // But, this does NOT exist within CraftBukkit which makes it return an error. + // So, we will just return the ID that the plains biome returns instead. + //noinspection unchecked + return org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, Biome.PLAINS); + } + baseBiomeCache.put(biome, v); + return v; + } + + @Override + public int getBiomeId(Biome biome) { + for (World i : Bukkit.getWorlds()) { + if (i.getEnvironment().equals(World.Environment.NORMAL)) { + IRegistry registry = ((CraftWorld) i).getHandle().r().b(IRegistry.ay); + return registry.a((BiomeBase) getBiomeBase(registry, biome)); + } + } + + return biome.ordinal(); + } + + @Override + public int countCustomBiomes() { + AtomicInteger a = new AtomicInteger(0); + getCustomBiomeRegistry().d().forEach((i) -> { + MinecraftKey k = i.getKey().a(); + + if (k.getNamespace().equals("minecraft")) { + return; + } + + a.incrementAndGet(); + Iris.debug("Custom Biome: " + k); + }); + + return a.get(); + } + + @Override + public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) { + try { + BiomeStorage s = (BiomeStorage) getFieldForBiomeStorage(chunk).get(chunk); + s.setBiome(x, y, z, (BiomeBase) somethingVeryDirty); + } catch (IllegalAccessException e) { + Iris.reportError(e); + e.printStackTrace(); + } + } + + @Override + public boolean isBukkit() { + return false; + } +} diff --git a/src/main/java/com/volmit/iris/core/nms/v16_3/NMSBinding16_3.java b/src/main/java/com/volmit/iris/core/nms/v16_3/NMSBinding16_3.java new file mode 100644 index 000000000..c65f5fa31 --- /dev/null +++ b/src/main/java/com/volmit/iris/core/nms/v16_3/NMSBinding16_3.java @@ -0,0 +1,267 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.core.nms.v16_3; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.nms.INMSBinding; +import com.volmit.iris.util.collection.KMap; +import net.minecraft.server.v1_16_R3.*; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Biome; +import org.bukkit.craftbukkit.v1_16_R3.CraftServer; +import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; +import org.bukkit.generator.ChunkGenerator; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.concurrent.atomic.AtomicInteger; + +public class NMSBinding16_3 implements INMSBinding { + private final KMap baseBiomeCache = new KMap<>(); + private Field biomeStorageCache = null; + + public boolean supportsDataPacks() { + return true; + } + + private Object getBiomeStorage(ChunkGenerator.BiomeGrid g) { + try { + return getFieldForBiomeStorage(g).get(g); + } catch (IllegalAccessException e) { + Iris.reportError(e); + e.printStackTrace(); + } + + return null; + } + + @Override + public boolean supportsCustomHeight() { + return false; + } + + @Override + public int getMinHeight(World world) { + return 0; + } + + @Override + public boolean supportsCustomBiomes() { + return false; + } + + private Field getFieldForBiomeStorage(Object storage) { + Field f = biomeStorageCache; + + if (f != null) { + return f; + } + try { + + f = storage.getClass().getDeclaredField("biome"); + f.setAccessible(true); + return f; + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + Iris.error(storage.getClass().getCanonicalName()); + } + + biomeStorageCache = f; + return null; + } + + private IRegistryWritable getCustomBiomeRegistry() { + return ((CraftServer) Bukkit.getServer()).getHandle().getServer().getCustomRegistry().b(IRegistry.ay); + } + + @Override + public Object getBiomeBaseFromId(int id) { + return getCustomBiomeRegistry().fromId(id); + } + + @Override + public int getTrueBiomeBaseId(Object biomeBase) { + return getCustomBiomeRegistry().a((BiomeBase) biomeBase); + } + + @Override + public Object getTrueBiomeBase(Location location) { + return ((CraftWorld) location.getWorld()).getHandle().getBiome(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + } + + @Override + public String getTrueBiomeBaseKey(Location location) { + return getKeyForBiomeBase(getTrueBiomeBase(location)); + } + + @Override + public Object getCustomBiomeBaseFor(String mckey) { + try { + return getCustomBiomeRegistry().d(ResourceKey.a(IRegistry.ay, new MinecraftKey(mckey))); + } catch (Throwable e) { + Iris.reportError(e); + } + + return null; + } + + @SuppressWarnings("OptionalGetWithoutIsPresent") + @Override + public String getKeyForBiomeBase(Object biomeBase) { + return getCustomBiomeRegistry().c((BiomeBase) biomeBase).get().a().toString(); + } + + @Override + public Object getBiomeBase(World world, Biome biome) { + return getBiomeBase(((CraftWorld) world).getHandle().r().b(IRegistry.ay), biome); + } + + private Class[] classify(Object... par) { + Class[] g = new Class[par.length]; + for (int i = 0; i < g.length; i++) { + g[i] = par[i].getClass(); + } + + return g; + } + + private T invoke(Object from, String name, Object... par) { + try { + Method f = from.getClass().getDeclaredMethod(name, classify(par)); + f.setAccessible(true); + //noinspection unchecked + return (T) f.invoke(from, par); + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + } + + return null; + } + + private T invokeStatic(Class from, String name, Object... par) { + try { + Method f = from.getDeclaredMethod(name, classify(par)); + f.setAccessible(true); + //noinspection unchecked + return (T) f.invoke(null, par); + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + } + + return null; + } + + private T getField(Object from, String name) { + try { + Field f = from.getClass().getDeclaredField(name); + f.setAccessible(true); + //noinspection unchecked + return (T) f.get(from); + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + } + + return null; + } + + private T getStaticField(Class t, String name) { + try { + Field f = t.getDeclaredField(name); + f.setAccessible(true); + //noinspection unchecked + return (T) f.get(null); + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + } + + return null; + } + + @Override + public Object getBiomeBase(Object registry, Biome biome) { + Object v = baseBiomeCache.get(biome); + + if (v != null) { + return v; + } + //noinspection unchecked + v = org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, biome); + if (v == null) { + // Ok so there is this new biome name called "CUSTOM" in Paper's new releases. + // But, this does NOT exist within CraftBukkit which makes it return an error. + // So, we will just return the ID that the plains biome returns instead. + //noinspection unchecked + return org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, Biome.PLAINS); + } + baseBiomeCache.put(biome, v); + return v; + } + + @Override + public int getBiomeId(Biome biome) { + for (World i : Bukkit.getWorlds()) { + if (i.getEnvironment().equals(World.Environment.NORMAL)) { + IRegistry registry = ((CraftWorld) i).getHandle().r().b(IRegistry.ay); + return registry.a((BiomeBase) getBiomeBase(registry, biome)); + } + } + + return biome.ordinal(); + } + + @Override + public int countCustomBiomes() { + AtomicInteger a = new AtomicInteger(0); + getCustomBiomeRegistry().d().forEach((i) -> { + MinecraftKey k = i.getKey().a(); + + if (k.getNamespace().equals("minecraft")) { + return; + } + + a.incrementAndGet(); + Iris.debug("Custom Biome: " + k); + }); + + return a.get(); + } + + @Override + public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) { + try { + BiomeStorage s = (BiomeStorage) getFieldForBiomeStorage(chunk).get(chunk); + s.setBiome(x, y, z, (BiomeBase) somethingVeryDirty); + } catch (IllegalAccessException e) { + Iris.reportError(e); + e.printStackTrace(); + } + } + + @Override + public boolean isBukkit() { + return false; + } +} diff --git a/src/main/java/com/volmit/iris/core/nms/v17_1/NMSBinding17_1.java b/src/main/java/com/volmit/iris/core/nms/v17_1/NMSBinding17_1.java index fcd0910b3..bab80640d 100644 --- a/src/main/java/com/volmit/iris/core/nms/v17_1/NMSBinding17_1.java +++ b/src/main/java/com/volmit/iris/core/nms/v17_1/NMSBinding17_1.java @@ -58,6 +58,11 @@ public class NMSBinding17_1 implements INMSBinding { return null; } + @Override + public boolean supportsCustomHeight() { + return false; + } + private Field getFieldForBiomeStorage(Object storage) { Field f = biomeStorageCache; @@ -103,6 +108,16 @@ public class NMSBinding17_1 implements INMSBinding { return getKeyForBiomeBase(getTrueBiomeBase(location)); } + @Override + public boolean supportsCustomBiomes() { + return true; + } + + @Override + public int getMinHeight(World world) { + return world.getMinHeight(); + } + @Override public Object getCustomBiomeBaseFor(String mckey) { try { diff --git a/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java b/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java index ee18ed059..f72c2b0a2 100644 --- a/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java +++ b/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java @@ -24,12 +24,49 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.generator.ChunkGenerator; +import java.lang.reflect.Method; + public class NMSBinding1X implements INMSBinding { + private static final boolean supportsCustomHeight = testCustomHeight(); + + @SuppressWarnings("ConstantConditions") + private static boolean testCustomHeight() { + try + { + if(World.class.getDeclaredMethod("getMaxHeight") != null && World.class.getDeclaredMethod("getMinHeight") != null); + { + return true; + } + } + + catch(Throwable ignored) + { + + } + + return false; + } + + @Override + public boolean supportsCustomHeight() { + return supportsCustomHeight; + } + @Override public Object getBiomeBaseFromId(int id) { return null; } + @Override + public int getMinHeight(World world) { + return supportsCustomHeight ? world.getMinHeight() : 0; + } + + @Override + public boolean supportsCustomBiomes() { + return false; + } + @Override public int getTrueBiomeBaseId(Object biomeBase) { return 0; diff --git a/src/main/java/com/volmit/iris/core/pregenerator/methods/AsyncPregenMethod.java b/src/main/java/com/volmit/iris/core/pregenerator/methods/AsyncPregenMethod.java index ffedcaa5b..ff2551caf 100644 --- a/src/main/java/com/volmit/iris/core/pregenerator/methods/AsyncPregenMethod.java +++ b/src/main/java/com/volmit/iris/core/pregenerator/methods/AsyncPregenMethod.java @@ -63,20 +63,20 @@ public class AsyncPregenMethod implements PregeneratorMethod { PaperLib.getChunkAtAsync(world, x, z, true).get(); listener.onChunkGenerated(x, z); } catch (Throwable e) { - e.printStackTrace(); + J.sleep(5); + future.add(burst.complete(() -> completeChunk(x, z, listener))); } } private void waitForChunks() { - for (CompletableFuture i : future) { + for (CompletableFuture i : future.copy()) { try { i.get(); + future.remove(i); } catch (Throwable e) { e.printStackTrace(); } } - - future.clear(); } @Override diff --git a/src/main/java/com/volmit/iris/core/pregenerator/methods/HybridPregenMethod.java b/src/main/java/com/volmit/iris/core/pregenerator/methods/HybridPregenMethod.java index bd843feb5..3aa88638f 100644 --- a/src/main/java/com/volmit/iris/core/pregenerator/methods/HybridPregenMethod.java +++ b/src/main/java/com/volmit/iris/core/pregenerator/methods/HybridPregenMethod.java @@ -42,7 +42,7 @@ public class HybridPregenMethod implements PregeneratorMethod { } private boolean supportsHeadless(World world) { - return IrisWorlds.access(world) != null && IrisSettings.get().getGenerator().isMcaPregenerator(); + return IrisWorlds.access(world) != null && !IrisSettings.get().getGenerator().isDisableMCA(); } @Override diff --git a/src/main/java/com/volmit/iris/core/tools/IrisCreator.java b/src/main/java/com/volmit/iris/core/tools/IrisCreator.java index 8f4cb4622..a02a56834 100644 --- a/src/main/java/com/volmit/iris/core/tools/IrisCreator.java +++ b/src/main/java/com/volmit/iris/core/tools/IrisCreator.java @@ -37,6 +37,8 @@ import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.WorldCreator; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.function.Consumer; /** @@ -95,7 +97,7 @@ public class IrisCreator { IrisDimension d = IrisToolbelt.getDimension(dimension()); IrisAccess access = null; Consumer prog = (pxx) -> { - double px = (headless && pregen != null) ? pxx / 2 : pxx; + double px = pxx; if (pregen != null && !headless) { px = (px / 2) + 0.5; @@ -158,61 +160,72 @@ public class IrisCreator { sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generation Complete")); }); - wc.createWorld(); - done.set(true); + try { + J.sfut(wc::createWorld).get(); + } catch (Throwable e) { + e.printStackTrace(); + } } if (access == null) { throw new IrisException("Access is null. Something bad happened."); } - IrisAccess finalAccess = access; - Runnable loadup = () -> { + CompletableFuture ff = new CompletableFuture<>(); + + if (pregen != null) { + IrisToolbelt.pregenerate(pregen, access) + .onProgress(prog) + .whenDone(() -> ff.complete(true)); + try { - J.sfut(() -> { - if (headless) { - O done = new O<>(); - done.set(false); - - J.a(() -> - { - int req = 400; - - while (finalAccess.getGenerated() < req && !done.get()) { - double v = (double) finalAccess.getGenerated() / (double) req; - v = (v / 2) + 0.5; - - if (sender.isPlayer()) { - sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generating " + Form.pc(v) + ((C.GRAY + " (" + (req - finalAccess.getGenerated()) + " Left)")))); - J.sleep(50); - } else { - sender.sendMessage(C.WHITE + "Generating " + Form.pc(v) + ((C.GRAY + " (" + (req - finalAccess.getGenerated()) + " Left)"))); - J.sleep(1000); - } - - if (finalAccess.isFailing()) { - - sender.sendMessage("Generation Failed!"); - break; - } - } - - sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generation Complete")); - }); - - finalAccess.getHeadlessGenerator().getWorld().load(); - done.set(true); - } - }).get(); + ff.get(); } catch (Throwable e) { e.printStackTrace(); } - }; + } - if (pregen != null) { - IrisToolbelt.pregenerate(pregen, access).onProgress(prog).whenDone(loadup); - } else { - loadup.run(); + try { + + IrisAccess finalAccess = access; + J.sfut(() -> { + if (headless) { + O done = new O<>(); + done.set(false); + + J.a(() -> + { + int req = 400; + + while (finalAccess.getGenerated() < req && !done.get()) { + double v = (double) finalAccess.getGenerated() / (double) req; + v = (v / 2) + 0.5; + + if (sender.isPlayer()) { + sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generating " + Form.pc(v) + ((C.GRAY + " (" + (req - finalAccess.getGenerated()) + " Left)")))); + J.sleep(50); + } else { + sender.sendMessage(C.WHITE + "Generating " + Form.pc(v) + ((C.GRAY + " (" + (req - finalAccess.getGenerated()) + " Left)"))); + J.sleep(1000); + } + + if (finalAccess.isFailing()) { + + sender.sendMessage("Generation Failed!"); + break; + } + } + + sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generation Complete")); + }); + + finalAccess.getHeadlessGenerator().getWorld().load(); + done.set(true); + } + }).get(); + + } catch (Throwable e) { + e.printStackTrace(); } return access; diff --git a/src/main/java/com/volmit/iris/engine/IrisComplex.java b/src/main/java/com/volmit/iris/engine/IrisComplex.java index d5b838920..af60f2f53 100644 --- a/src/main/java/com/volmit/iris/engine/IrisComplex.java +++ b/src/main/java/com/volmit/iris/engine/IrisComplex.java @@ -39,6 +39,7 @@ import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; @Data public class IrisComplex implements DataProvider { @@ -115,6 +116,12 @@ public class IrisComplex implements DataProvider { fluidHeight = engine.getDimension().getFluidHeight(); generators = new KList<>(); focus = engine.getFocus(); + + if(focus != null) + { + focus.setInferredType(InferredType.LAND); + } + IrisRegion focusRegion = focus != null ? findRegion(focus, engine) : null; RNG rng = new RNG(engine.getWorld().seed()); //@builder @@ -195,13 +202,13 @@ public class IrisComplex implements DataProvider { heightStream = ProceduralStream.of((x, z) -> { IrisBiome b = focus != null ? focus : baseBiomeStream.get(x, z); return getHeight(engine, b, x, z, engine.getWorld().seed()); - }, Interpolated.DOUBLE).cache2D(cacheSize); + }, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D(cacheSize); slopeStream = heightStream.slope(3).cache2D(cacheSize); objectChanceStream = ProceduralStream.ofDouble((x, z) -> { if (engine.getDimension().hasFeatures(engine)) { AtomicDouble str = new AtomicDouble(1D); engine.getFramework().getEngineParallax().forEachFeature(x, z, (i) - -> str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z)))); + -> str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z, rng)))); return str.get(); } @@ -209,10 +216,39 @@ public class IrisComplex implements DataProvider { }); trueBiomeStream = focus != null ? ProceduralStream.of((x, y) -> focus, Interpolated.of(a -> 0D, - b -> focus)) : heightStream + b -> focus)).convertAware2D((b, x,z) -> { + for(IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z)) + { + IrisBiome bx = i.filter(x, z, b, rng); + + if(bx != null) + { + bx.setInferredType(b.getInferredType()); + return bx; + } + } + + return b; + }) + .cache2D(cacheSize) : heightStream .convertAware2D((h, x, z) -> fixBiomeType(h, baseBiomeStream.get(x, z), - regionStream.get(x, z), x, z, fluidHeight)).cache2D(cacheSize); + regionStream.get(x, z), x, z, fluidHeight)) + .convertAware2D((b, x,z) -> { + for(IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z)) + { + IrisBiome bx = i.filter(x, z, b, rng); + + if(bx != null) + { + bx.setInferredType(b.getInferredType()); + return bx; + } + } + + return b; + }) + .cache2D(cacheSize); trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D(cacheSize); heightFluidStream = heightStream.max(fluidHeight).cache2D(cacheSize); maxHeightStream = ProceduralStream.ofDouble((x, z) -> height); @@ -380,7 +416,7 @@ public class IrisComplex implements DataProvider { AtomicDouble noise = new AtomicDouble(h + fluidHeight + overlayStream.get(x, z)); engine.getFramework().getEngineParallax().forEachFeature(x, z, (i) - -> noise.set(i.filter(x, z, noise.get()))); + -> noise.set(i.filter(x, z, noise.get(), rng))); return Math.min(engine.getHeight(), Math.max(noise.get(), 0)); } diff --git a/src/main/java/com/volmit/iris/engine/IrisEngine.java b/src/main/java/com/volmit/iris/engine/IrisEngine.java index f495cf5e7..7b3ab99cd 100644 --- a/src/main/java/com/volmit/iris/engine/IrisEngine.java +++ b/src/main/java/com/volmit/iris/engine/IrisEngine.java @@ -163,6 +163,7 @@ public class IrisEngine extends BlockPopulator implements Engine { try { PrecisionStopwatch p = PrecisionStopwatch.start(); BurstExecutor b = burst().burst(16); + Hunk blocks = vblocks.listen((xx, y, zz, t) -> catchBlockUpdates(x + xx, y + getMinHeight(), z + zz, t)); // This is a very weird optimization, but it works // Basically we precache multicore the biome stream which effectivley @@ -188,9 +189,9 @@ public class IrisEngine extends BlockPopulator implements Engine { getFramework().getCaveModifier().modify(x, z, vblocks); getFramework().getRavineModifier().modify(x, z, vblocks); getFramework().getPostModifier().modify(x, z, vblocks); - getFramework().getDecorantActuator().actuate(x, z, vblocks); - getFramework().getEngineParallax().insertParallax(x >> 4, z >> 4, vblocks); - getFramework().getDepositModifier().modify(x, z, vblocks); + getFramework().getDecorantActuator().actuate(x, z, blocks); + getFramework().getEngineParallax().insertParallax(x >> 4, z >> 4, blocks); + getFramework().getDepositModifier().modify(x, z, blocks); } case ISLANDS -> { getFramework().getTerrainActuator().actuate(x, z, vblocks); diff --git a/src/main/java/com/volmit/iris/engine/IrisWorldManager.java b/src/main/java/com/volmit/iris/engine/IrisWorldManager.java index 861c5935c..fb258d404 100644 --- a/src/main/java/com/volmit/iris/engine/IrisWorldManager.java +++ b/src/main/java/com/volmit/iris/engine/IrisWorldManager.java @@ -74,13 +74,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager { trySpawn(above.getEntityInitialSpawns(), c, rng); trySpawn(region.getEntityInitialSpawns(), c, rng); trySpawn(dim.getEntityInitialSpawns(), c, rng); - - } @Override public void onEntitySpawn(EntitySpawnEvent e) { - if (getTarget().getWorld() == null || !getTarget().getWorld().equals(e.getEntity().getWorld())) { + if (getTarget().getWorld() == null || !e.getEntity().getWorld().equals(getTarget().getWorld().realWorld())) { return; } diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java index 4d93858ed..796eaaf9b 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java @@ -70,7 +70,6 @@ public class IrisBiomeActuator extends EngineAssignedActuator { for (int xf = 0; xf < h.getWidth(); xf++) { for (zf = 0; zf < h.getDepth(); zf++) { - ib = getComplex().getTrueBiomeStream().get(modX(xf + x), modZ(zf + z)); maxHeight = (int) (getComplex().getFluidHeight() + ib.getMaxWithObjectHeight(getData())); if (ib.isCustom()) { @@ -78,7 +77,7 @@ public class IrisBiomeActuator extends EngineAssignedActuator { IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z); Object biomeBase = INMS.get().getCustomBiomeBaseFor(getDimension().getLoadKey() + ":" + custom.getId()); - if (!injectBiome(h, x, 0, z, biomeBase)) { + if (biomeBase == null || !injectBiome(h, x, 0, z, biomeBase)) { throw new RuntimeException("Cant inject biome!"); } @@ -87,7 +86,6 @@ public class IrisBiomeActuator extends EngineAssignedActuator { } } catch (Throwable e) { Iris.reportError(e); - e.printStackTrace(); Biome v = ib.getSkyBiome(rng, x, 0, z); for (int i = 0; i < maxHeight; i++) { h.set(xf, i, zf, v); diff --git a/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java b/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java new file mode 100644 index 000000000..7cc9684db --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java @@ -0,0 +1,163 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.engine.data.chunk; + +import com.volmit.iris.core.nms.BiomeBaseInjector; +import com.volmit.iris.engine.data.mca.Chunk; +import com.volmit.iris.engine.data.mca.NBTWorld; +import lombok.AllArgsConstructor; +import lombok.Builder; +import org.bukkit.Material; +import org.bukkit.block.Biome; +import org.bukkit.block.data.BlockData; +import org.bukkit.generator.ChunkGenerator; +import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.NotNull; + +@Builder +@AllArgsConstructor +public class MCATerrainChunk implements TerrainChunk { + private NBTWorld writer; + private BiomeBaseInjector injector; + private int ox; + private int oz; + private int minHeight; + private int maxHeight; + private Chunk mcaChunk; + + @Override + public BiomeBaseInjector getBiomeBaseInjector() { + return injector; + } + + @Override + public void setRaw(ChunkGenerator.ChunkData data) { + + } + + @NotNull + @Override + public Biome getBiome(int x, int z) { + return Biome.THE_VOID; + } + + @NotNull + @Override + public Biome getBiome(int x, int y, int z) { + return Biome.THE_VOID; + } + + @Override + public void setBiome(int x, int z, Biome bio) { + setBiome(ox + x, 0, oz + z, bio); + } + + @Override + public void setBiome(int x, int y, int z, Biome bio) { + writer.setBiome(ox + x, y, oz + z, bio); + } + + @Override + public int getMinHeight() { + return minHeight; + } + + @Override + public int getMaxHeight() { + return maxHeight; + } + + @Override + public void setBlock(int x, int y, int z, BlockData blockData) { + int xx = (x + ox) & 15; + int zz = (z + oz) & 15; + + if (y > 255 || y < 0) { + return; + } + + mcaChunk.setBlockStateAt(xx, y, zz, NBTWorld.getCompound(blockData), false); + } + + @NotNull + @Override + public org.bukkit.block.data.BlockData getBlockData(int x, int y, int z) { + if (y > getMaxHeight()) { + y = getMaxHeight(); + } + + if (y < 0) { + y = 0; + } + + return NBTWorld.getBlockData(mcaChunk.getBlockStateAt((x + ox) & 15, y, (z + oz) & 15)); + } + + @Override + public ChunkGenerator.ChunkData getRaw() { + return null; + } + + @Override + public void inject(ChunkGenerator.BiomeGrid biome) { + + } + + @Override + public void setBlock(int x, int y, int z, @NotNull Material material) { + + } + + @Override + public void setBlock(int x, int y, int z, @NotNull MaterialData material) { + + } + + @Override + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull Material material) { + + } + + @Override + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull MaterialData material) { + + } + + @Override + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull BlockData blockData) { + + } + + @NotNull + @Override + public Material getType(int x, int y, int z) { + return null; + } + + @NotNull + @Override + public MaterialData getTypeAndData(int x, int y, int z) { + return null; + } + + @Override + public byte getData(int x, int y, int z) { + return 0; + } +} diff --git a/src/main/java/com/volmit/iris/engine/data/loader/ResourceLoader.java b/src/main/java/com/volmit/iris/engine/data/loader/ResourceLoader.java index ac01a2c3b..12a955512 100644 --- a/src/main/java/com/volmit/iris/engine/data/loader/ResourceLoader.java +++ b/src/main/java/com/volmit/iris/engine/data/loader/ResourceLoader.java @@ -36,7 +36,9 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch; import lombok.Data; import java.io.File; +import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Predicate; @Data public class ResourceLoader { @@ -91,6 +93,32 @@ public class ResourceLoader { J.a(() -> Iris.warn("Couldn't Load " + resourceTypeName + " file: " + path.getPath() + ": " + e.getMessage())); } + private KList matchAllFiles(File root, Predicate f) + { + KList fx = new KList<>(); + matchFiles(root, fx, f); + return fx; + } + + private void matchFiles(File at, KList files, Predicate f) + { + if(at.isDirectory()) + { + for(File i : at.listFiles()) + { + matchFiles(i, files, f); + } + } + + else + { + if(f.test(at)) + { + files.add(at); + } + } + } + public String[] getPossibleKeys() { if (possibleKeys != null) { return possibleKeys; @@ -99,17 +127,11 @@ public class ResourceLoader { Iris.info("Building " + resourceTypeName + " Registry Lists"); KSet m = new KSet<>(); - for (File i : getFolders()) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".json")) { - m.add(j.getName().replaceAll("\\Q.json\\E", "")); - } else if (j.isDirectory()) { - for (File k : j.listFiles()) { - if (k.isFile() && k.getName().endsWith(".json")) { - m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.json\\E", "")); - } - } - } + for(File i : getFolders()) + { + for(File j : matchAllFiles(i, (f) -> f.getName().endsWith(".json"))) + { + m.add(i.toURI().relativize(j.toURI()).getPath().replaceAll("\\Q.json\\E", "")); } } @@ -156,6 +178,20 @@ public class ResourceLoader { return m; } + public KList loadAll(String[] s) { + KList m = new KList<>(); + + for (String i : s) { + T t = load(i); + + if (t != null) { + m.add(t); + } + } + + return m; + } + public T load(String name) { return load(name, true); } @@ -268,4 +304,18 @@ public class ResourceLoader { possibleKeys = null; lock.unlock(); } + + public KList getPossibleKeys(String arg) { + KList f = new KList<>(); + + for(String i : getPossibleKeys()) + { + if(i.equalsIgnoreCase(arg) || i.toLowerCase(Locale.ROOT).startsWith(arg.toLowerCase(Locale.ROOT)) || i.toLowerCase(Locale.ROOT).contains(arg.toLowerCase(Locale.ROOT)) || arg.toLowerCase(Locale.ROOT).contains(i.toLowerCase(Locale.ROOT))) + { + f.add(i); + } + } + + return f; + } } diff --git a/src/main/java/com/volmit/iris/engine/data/mca/Chunk.java b/src/main/java/com/volmit/iris/engine/data/mca/Chunk.java index 060a169a7..37b65f4e4 100644 --- a/src/main/java/com/volmit/iris/engine/data/mca/Chunk.java +++ b/src/main/java/com/volmit/iris/engine/data/mca/Chunk.java @@ -26,6 +26,7 @@ import com.volmit.iris.engine.data.nbt.tag.ListTag; import java.io.*; import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReferenceArray; import static com.volmit.iris.engine.data.mca.LoadFlags.*; @@ -45,7 +46,7 @@ public class Chunk { private int[] biomes; private CompoundTag heightMaps; private CompoundTag carvingMasks; - private final Section[] sections = new Section[16]; + private final AtomicReferenceArray
sections = new AtomicReferenceArray<>(16); private ListTag entities; private ListTag tileEntities; private ListTag tileTicks; @@ -129,7 +130,7 @@ public class Chunk { if (newSection.isEmpty()) { continue; } - sections[sectionIndex] = newSection; + sections.set(sectionIndex, newSection); } } @@ -299,7 +300,7 @@ public class Chunk { } public CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) { - Section section = sections[MCAUtil.blockToChunk(blockY)]; + Section section = sections.get(MCAUtil.blockToChunk(blockY)); if (section == null) { return null; } @@ -320,9 +321,10 @@ public class Chunk { */ public void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) { int sectionIndex = MCAUtil.blockToChunk(blockY); - Section section = sections[sectionIndex]; + Section section = sections.get(sectionIndex); if (section == null) { - section = sections[sectionIndex] = Section.newSection(); + section = Section.newSection(); + sections.set(sectionIndex, section); } section.setBlockStateAt(blockX, blockY, blockZ, state, cleanup); } @@ -383,7 +385,7 @@ public class Chunk { * @return The Section. */ public Section getSection(int sectionY) { - return sections[sectionY]; + return sections.get(sectionY); } /** @@ -393,7 +395,7 @@ public class Chunk { * @param section The section to be set. */ public void setSection(int sectionY, Section section) { - sections[sectionY] = section; + sections.set(sectionY, section); } /** @@ -632,7 +634,9 @@ public class Chunk { } public void cleanupPalettesAndBlockStates() { - for (Section section : sections) { + for (int i = 0; i < sections.length(); i++) + { + Section section = sections.get(i); if (section != null) { section.cleanupPaletteAndBlockStates(); } @@ -673,12 +677,28 @@ public class Chunk { level.putString("Status", status); if (structures != null) level.put("Structures", structures); ListTag sections = new ListTag<>(CompoundTag.class); - for (int i = 0; i < this.sections.length; i++) { - if (this.sections[i] != null) { - sections.add(this.sections[i].updateHandle(i)); + for (int i = 0; i < this.sections.length(); i++) { + if (this.sections.get(i) != null) { + sections.add(this.sections.get(i).updateHandle(i)); } } level.put("Sections", sections); return data; } + + public int sectionCount() { + return sections.length(); + } + + public void runLighting() { + for(int s = 15; s >= 0; s--) + { + Section section = getSection(s); + + if(section != null) + { + section.runLighting(); + } + } + } } diff --git a/src/main/java/com/volmit/iris/engine/data/mca/MCAUtil.java b/src/main/java/com/volmit/iris/engine/data/mca/MCAUtil.java index 68a23e4b8..25351fef5 100644 --- a/src/main/java/com/volmit/iris/engine/data/mca/MCAUtil.java +++ b/src/main/java/com/volmit/iris/engine/data/mca/MCAUtil.java @@ -160,6 +160,7 @@ public final class MCAUtil { if (chunks > 0 && to != file) { Files.move(to.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING); } + return chunks; } diff --git a/src/main/java/com/volmit/iris/engine/data/mca/NBTWorld.java b/src/main/java/com/volmit/iris/engine/data/mca/NBTWorld.java index 7b1206844..24a2a2cc1 100644 --- a/src/main/java/com/volmit/iris/engine/data/mca/NBTWorld.java +++ b/src/main/java/com/volmit/iris/engine/data/mca/NBTWorld.java @@ -265,7 +265,7 @@ public class NBTWorld { return s; } - public Chunk getChunk(int x, int z) { + public synchronized Chunk getChunk(int x, int z) { MCAFile mca = getMCA(x >> 5, z >> 5); Chunk c = mca.getChunk(x & 31, z & 31); diff --git a/src/main/java/com/volmit/iris/engine/data/mca/Section.java b/src/main/java/com/volmit/iris/engine/data/mca/Section.java index 16ab5ea79..b8c4924e0 100644 --- a/src/main/java/com/volmit/iris/engine/data/mca/Section.java +++ b/src/main/java/com/volmit/iris/engine/data/mca/Section.java @@ -25,18 +25,19 @@ import com.volmit.iris.engine.data.nbt.tag.ListTag; import com.volmit.iris.engine.data.nbt.tag.LongArrayTag; import com.volmit.iris.util.collection.KMap; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicLongArray; public class Section { - private CompoundTag data; private Map> valueIndexedPalette = new KMap<>(); private ListTag palette; private byte[] blockLight; - private long[] blockStates; + private AtomicLongArray blockStates; private byte[] skyLight; private int dataVersion; @@ -65,7 +66,7 @@ public class Section { this.blockLight = blockLight != null ? blockLight.getValue() : null; } if ((loadFlags & LoadFlags.BLOCK_STATES) != 0) { - this.blockStates = blockStates != null ? blockStates.getValue() : null; + this.blockStates = blockStates != null ? new AtomicLongArray(blockStates.getValue()) : null; } if ((loadFlags & LoadFlags.SKY_LIGHT) != 0) { this.skyLight = skyLight != null ? skyLight.getValue() : null; @@ -106,6 +107,19 @@ public class Section { return null; } + public void runLighting() { + for(int x = 1; x < 14; x++) + { + for(int z = 1; z < 14; z++) + { + for(int y = 0; y < 16; y++) + { + + } + } + } + } + @SuppressWarnings("ClassCanBeRecord") private static class PaletteIndex { @@ -185,24 +199,24 @@ public class Section { * @return The index of the block data in the palette. */ public int getPaletteIndex(int blockStateIndex) { - int bits = blockStates.length >> 6; + int bits = blockStates.length() >> 6; if (dataVersion < 2527) { - double blockStatesIndex = blockStateIndex / (4096D / blockStates.length); + double blockStatesIndex = blockStateIndex / (4096D / blockStates.length()); int longIndex = (int) blockStatesIndex; int startBit = (int) ((blockStatesIndex - Math.floor(blockStatesIndex)) * 64D); if (startBit + bits > 64) { - long prev = bitRange(blockStates[longIndex], startBit, 64); - long next = bitRange(blockStates[longIndex + 1], 0, startBit + bits - 64); + long prev = bitRange(blockStates.get(longIndex), startBit, 64); + long next = bitRange(blockStates.get(longIndex + 1), 0, startBit + bits - 64); return (int) ((next << 64 - startBit) + prev); } else { - return (int) bitRange(blockStates[longIndex], startBit, startBit + bits); + return (int) bitRange(blockStates.get(longIndex), startBit, startBit + bits); } } else { int indicesPerLong = (int) (64D / bits); int blockStatesIndex = blockStateIndex / indicesPerLong; int startBit = (blockStateIndex % indicesPerLong) * bits; - return (int) bitRange(blockStates[blockStatesIndex], startBit, startBit + bits); + return (int) bitRange(blockStates.get(blockStatesIndex), startBit, startBit + bits); } } @@ -213,24 +227,24 @@ public class Section { * @param paletteIndex The block state to be set (index of block data in the palette). * @param blockStates The block states to be updated. */ - public void setPaletteIndex(int blockIndex, int paletteIndex, long[] blockStates) { - int bits = blockStates.length >> 6; + public void setPaletteIndex(int blockIndex, int paletteIndex, AtomicLongArray blockStates) { + int bits = blockStates.length() >> 6; if (dataVersion < 2527) { - double blockStatesIndex = blockIndex / (4096D / blockStates.length); + double blockStatesIndex = blockIndex / (4096D / blockStates.length()); int longIndex = (int) blockStatesIndex; int startBit = (int) ((blockStatesIndex - Math.floor(longIndex)) * 64D); if (startBit + bits > 64) { - blockStates[longIndex] = updateBits(blockStates[longIndex], paletteIndex, startBit, 64); - blockStates[longIndex + 1] = updateBits(blockStates[longIndex + 1], paletteIndex, startBit - 64, startBit + bits - 64); + blockStates.set(longIndex, updateBits(blockStates.get(longIndex), paletteIndex, startBit, 64)); + blockStates.set(longIndex + 1, updateBits(blockStates.get(longIndex + 1), paletteIndex, startBit - 64, startBit + bits - 64)); } else { - blockStates[longIndex] = updateBits(blockStates[longIndex], paletteIndex, startBit, startBit + bits); + blockStates.set(longIndex, updateBits(blockStates.get(longIndex), paletteIndex, startBit, startBit + bits)); } } else { int indicesPerLong = (int) (64D / bits); int blockStatesIndex = blockIndex / indicesPerLong; int startBit = (blockIndex % indicesPerLong) * bits; - blockStates[blockStatesIndex] = updateBits(blockStates[blockStatesIndex], paletteIndex, startBit, startBit + bits); + blockStates.set(blockStatesIndex, updateBits(blockStates.get(blockStatesIndex), paletteIndex, startBit, startBit + bits)); } } @@ -304,7 +318,7 @@ public class Section { return allIndices; } - void adjustBlockStateBits(Map oldToNewMapping, long[] blockStates) { + void adjustBlockStateBits(Map oldToNewMapping, AtomicLongArray blockStates) { //increases or decreases the amount of bits used per BlockState //based on the size of the palette. oldToNewMapping can be used to update indices //if the palette had been cleaned up before using MCAFile#cleanupPalette(). @@ -312,13 +326,13 @@ public class Section { int newBits = 32 - Integer.numberOfLeadingZeros(palette.size() - 1); newBits = Math.max(newBits, 4); - long[] newBlockStates; + AtomicLongArray newBlockStates; if (dataVersion < 2527) { - newBlockStates = newBits == blockStates.length / 64 ? blockStates : new long[newBits * 64]; + newBlockStates = newBits == blockStates.length() / 64 ? blockStates : new AtomicLongArray(newBits * 64); } else { int newLength = (int) Math.ceil(4096D / (64D / newBits)); - newBlockStates = newBits == blockStates.length / 64 ? blockStates : new long[newLength]; + newBlockStates = newBits == blockStates.length() / 64 ? blockStates : new AtomicLongArray(newLength); } if (oldToNewMapping != null) { for (int i = 0; i < 4096; i++) { @@ -355,7 +369,7 @@ public class Section { /** * @return The indices of the block states of this Section. */ - public long[] getBlockStates() { + public AtomicLongArray getBlockStates() { return blockStates; } @@ -366,10 +380,10 @@ public class Section { * @throws NullPointerException If blockStates is null * @throws IllegalArgumentException When blockStates' length is < 256 or > 4096 and is not a multiple of 64 */ - public void setBlockStates(long[] blockStates) { + public void setBlockStates(AtomicLongArray blockStates) { if (blockStates == null) { throw new NullPointerException("BlockStates cannot be null"); - } else if (blockStates.length % 64 != 0 || blockStates.length < 256 || blockStates.length > 4096) { + } else if (blockStates.length() % 64 != 0 || blockStates.length() < 256 || blockStates.length() > 4096) { throw new IllegalArgumentException("BlockStates must have a length > 255 and < 4097 and must be divisible by 64"); } this.blockStates = blockStates; @@ -402,7 +416,7 @@ public class Section { */ public static Section newSection() { Section s = new Section(); - s.blockStates = new long[256]; + s.blockStates = new AtomicLongArray(256); s.palette = new ListTag<>(CompoundTag.class); CompoundTag air = new CompoundTag(); air.putString("Name", "minecraft:air"); @@ -428,7 +442,14 @@ public class Section { data.putByteArray("BlockLight", blockLight); } if (blockStates != null) { - data.putLongArray("BlockStates", blockStates); + long[] c = new long[blockStates.length()]; + + for(int i = 0; i < c.length; i++) + { + c[i] = blockStates.get(i); + } + + data.putLongArray("BlockStates", c); } if (skyLight != null) { data.putByteArray("SkyLight", skyLight); diff --git a/src/main/java/com/volmit/iris/engine/framework/Engine.java b/src/main/java/com/volmit/iris/engine/framework/Engine.java index 6f3a00435..14a7e95d3 100644 --- a/src/main/java/com/volmit/iris/engine/framework/Engine.java +++ b/src/main/java/com/volmit/iris/engine/framework/Engine.java @@ -38,15 +38,23 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.block.Biome; import org.bukkit.block.Block; +import org.bukkit.block.Chest; import org.bukkit.block.data.BlockData; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import org.bukkit.loot.LootContext; +import org.bukkit.loot.LootTable; +import org.bukkit.loot.Lootable; +import org.jetbrains.annotations.NotNull; import java.awt.*; import java.util.Arrays; +import java.util.Collection; +import java.util.Random; public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootProvider, BlockUpdater, Renderer, Hotloadable { void close(); @@ -163,10 +171,8 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro } if (B.isUpdatable(data)) { - synchronized (getParallax()) { - getParallax().updateBlock(x, y, z); - getParallax().getMetaRW(x >> 4, z >> 4).setUpdates(true); - } + getParallax().updateBlock(x, y, z); + getParallax().getMetaRW(x >> 4, z >> 4).setUpdates(true); } } @@ -233,7 +239,6 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro addItems(false, m.getInventory(), rx, tables, slot, x, y, z, 15); } catch (Throwable e) { Iris.reportError(e); - } } } diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineAssignedWorldManager.java b/src/main/java/com/volmit/iris/engine/framework/EngineAssignedWorldManager.java index ebd0794f4..353268453 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineAssignedWorldManager.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineAssignedWorldManager.java @@ -39,35 +39,35 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent @EventHandler public void on(WorldSaveEvent e) { - if (e.getWorld().equals(getTarget().getWorld())) { + if (e.getWorld().equals(getTarget().getWorld().realWorld())) { onSave(); } } @EventHandler public void on(WorldUnloadEvent e) { - if (e.getWorld().equals(getTarget().getWorld())) { + if (e.getWorld().equals(getTarget().getWorld().realWorld())) { getEngine().close(); } } @EventHandler public void on(EntitySpawnEvent e) { - if (e.getEntity().getWorld().equals(getTarget().getWorld())) { + if (e.getEntity().getWorld().equals(getTarget().getWorld().realWorld())) { onEntitySpawn(e); } } @EventHandler public void on(BlockBreakEvent e) { - if (e.getPlayer().getWorld().equals(getTarget().getWorld())) { + if (e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) { onBlockBreak(e); } } @EventHandler public void on(BlockPlaceEvent e) { - if (e.getPlayer().getWorld().equals(getTarget().getWorld())) { + if (e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) { onBlockPlace(e); } } diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineCompositeGenerator.java b/src/main/java/com/volmit/iris/engine/framework/EngineCompositeGenerator.java index 677000a5b..b324d6134 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineCompositeGenerator.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineCompositeGenerator.java @@ -27,10 +27,14 @@ import com.volmit.iris.core.pregenerator.PregenListener; import com.volmit.iris.core.pregenerator.PregenTask; import com.volmit.iris.engine.IrisEngineCompound; import com.volmit.iris.engine.data.B; +import com.volmit.iris.engine.data.chunk.MCATerrainChunk; import com.volmit.iris.engine.data.chunk.TerrainChunk; +import com.volmit.iris.engine.data.mca.MCAUtil; import com.volmit.iris.engine.data.mca.NBTWorld; +import com.volmit.iris.engine.data.nbt.tag.CompoundTag; import com.volmit.iris.engine.headless.HeadlessGenerator; import com.volmit.iris.engine.hunk.Hunk; +import com.volmit.iris.engine.lighting.LightingChunk; import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisDimension; import com.volmit.iris.engine.object.IrisPosition; @@ -71,6 +75,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; public class EngineCompositeGenerator extends ChunkGenerator implements IrisAccess { + private static final BlockData ERROR_BLOCK = Material.RED_GLAZED_TERRACOTTA.createBlockData(); private final AtomicReference compound = new AtomicReference<>(); private final AtomicBoolean initialized; private final String dimensionQuery; @@ -310,6 +315,11 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce populators.addAll(compound.get().getPopulators()); hotloader = new ReactiveFolder(data.getDataFolder(), (a, c, d) -> hotload()); +// if(world.hasRealWorld()) +// { +// placeStrongholds(world.realWorld()); +// } + if(isStudio()) { dim.installDataPack(() -> data, Iris.instance.getDatapacksFolder()); @@ -448,23 +458,46 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce @NotNull @Override public ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) { - PrecisionStopwatch ps = PrecisionStopwatch.start(); - TerrainChunk tc = TerrainChunk.create(world, biome); - IrisWorld ww = (getComposite() == null || getComposite().getWorld() == null) ? IrisWorld.fromWorld(world) : getComposite().getWorld(); - generateChunkRawData(ww, x, z, tc).run(); + try + { + PrecisionStopwatch ps = PrecisionStopwatch.start(); + TerrainChunk tc = TerrainChunk.create(world, biome); + IrisWorld ww = (getComposite() == null || getComposite().getWorld() == null) ? IrisWorld.fromWorld(world) : getComposite().getWorld(); + generateChunkRawData(ww, x, z, tc).run(); - if (!getComposite().getWorld().hasRealWorld()) { - getComposite().getWorld().bind(world); + if (!getComposite().getWorld().hasRealWorld()) { + getComposite().getWorld().bind(world); + } + + generated++; + ps.end(); + + if (IrisSettings.get().getGeneral().isDebug()) { + Iris.debug("Chunk " + C.GREEN + x + "," + z + C.LIGHT_PURPLE + " in " + C.YELLOW + Form.duration(ps.getMillis(), 2) + C.LIGHT_PURPLE + " Rate: " + C.BLUE + Form.f(getGeneratedPerSecond(), 0) + "/s"); + } + + return tc.getRaw(); } - generated++; - ps.end(); + catch(Throwable e) + { + Iris.error("======================================"); + e.printStackTrace(); + Iris.reportErrorChunk(x, z, e, "CHUNK"); + Iris.error("======================================"); - if (IrisSettings.get().getGeneral().isDebug()) { - Iris.debug("Chunk " + C.GREEN + x + "," + z + C.LIGHT_PURPLE + " in " + C.YELLOW + Form.duration(ps.getMillis(), 2) + C.LIGHT_PURPLE + " Rate: " + C.BLUE + Form.f(getGeneratedPerSecond(), 0) + "/s"); + ChunkData d = Bukkit.createChunkData(world); + + for(int i = 0; i < 16; i++) + { + for(int j = 0; j < 16; j++) + { + d.setBlock(i, 0, j, ERROR_BLOCK); + } + } + + return d; } - - return tc.getRaw(); } public void assignHeadlessGenerator(HeadlessGenerator headlessGenerator) { @@ -509,132 +542,34 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce @Override public void directWriteChunk(IrisWorld w, int x, int z, NBTWorld writer) { - int ox = x << 4; - int oz = z << 4; - com.volmit.iris.engine.data.mca.Chunk cc = writer.getChunk(x, z); - BiomeBaseInjector injector = (xx, yy, zz, biomeBase) -> cc.setBiomeAt(ox + xx, yy, oz + zz, INMS.get().getTrueBiomeBaseId(biomeBase)); - //noinspection deprecation - generateChunkRawData(w, x, z, new TerrainChunk() { - @Override - public BiomeBaseInjector getBiomeBaseInjector() { - return injector; - } + try + {int ox = x << 4; + int oz = z << 4; + com.volmit.iris.engine.data.mca.Chunk chunk = writer.getChunk(x, z); + generateChunkRawData(w, x, z, MCATerrainChunk.builder() + .writer(writer).ox(ox).oz(oz).mcaChunk(chunk) + .minHeight(w.minHeight()).maxHeight(w.maxHeight()) + .injector((xx, yy, zz, biomeBase) -> chunk.setBiomeAt(ox + xx, yy, oz + zz, + INMS.get().getTrueBiomeBaseId(biomeBase))) + .build()).run(); + } - @Override - public void setRaw(ChunkData data) { - - } - - @NotNull - @Override - public Biome getBiome(int x, int z) { - return Biome.THE_VOID; - } - - @NotNull - @Override - public Biome getBiome(int x, int y, int z) { - return Biome.THE_VOID; - } - - @Override - public void setBiome(int x, int z, Biome bio) { - setBiome(ox + x, 0, oz + z, bio); - } - - @Override - public void setBiome(int x, int y, int z, Biome bio) { - writer.setBiome(ox + x, y, oz + z, bio); - } - - @Override - public int getMinHeight() { - return w.minHeight(); - } - - @Override - public int getMaxHeight() { - return w.maxHeight(); - } - - @Override - public void setBlock(int x, int y, int z, BlockData blockData) { - int xx = (x + ox) & 15; - int zz = (z + oz) & 15; - - if (y > 255 || y < 0) { - return; + catch(Throwable e) + { + Iris.error("======================================"); + e.printStackTrace(); + Iris.reportErrorChunk(x, z, e, "MCA"); + Iris.error("======================================"); + com.volmit.iris.engine.data.mca.Chunk chunk = writer.getChunk(x, z); + CompoundTag c = NBTWorld.getCompound(ERROR_BLOCK); + for(int i = 0; i < 16; i++) + { + for(int j = 0; j < 16; j++) + { + chunk.setBlockStateAt(i, 0, j, c, false); } - - cc.setBlockStateAt(xx, y, zz, NBTWorld.getCompound(blockData), false); } - - @NotNull - @Override - public BlockData getBlockData(int x, int y, int z) { - if (y > getMaxHeight()) { - y = getMaxHeight(); - } - - if (y < 0) { - y = 0; - } - - return NBTWorld.getBlockData(cc.getBlockStateAt((x + ox) & 15, y, (z + oz) & 15)); - } - - @Override - public ChunkData getRaw() { - return null; - } - - @Override - public void inject(BiomeGrid biome) { - - } - - @Override - public void setBlock(int x, int y, int z, @NotNull Material material) { - - } - - @Override - public void setBlock(int x, int y, int z, @NotNull MaterialData material) { - - } - - @Override - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull Material material) { - - } - - @Override - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull MaterialData material) { - - } - - @Override - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull BlockData blockData) { - - } - - @NotNull - @Override - public Material getType(int x, int y, int z) { - return null; - } - - @NotNull - @Override - public MaterialData getTypeAndData(int x, int y, int z) { - return null; - } - - @Override - public byte getData(int x, int y, int z) { - return 0; - } - }).run(); + } } public Runnable generateChunkRawData(IrisWorld world, int x, int z, TerrainChunk tc) { diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineParallaxManager.java b/src/main/java/com/volmit/iris/engine/framework/EngineParallaxManager.java index f9f8ef5f5..bc2ba5c9c 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineParallaxManager.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineParallaxManager.java @@ -37,13 +37,16 @@ import com.volmit.iris.engine.parallel.BurstExecutor; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KSet; +import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.ChunkCoordinates; import com.volmit.iris.util.format.Form; import com.volmit.iris.util.function.Consumer4; +import com.volmit.iris.util.math.Position2; import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.scheduling.IrisLock; import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.PrecisionStopwatch; +import io.lumine.xikage.mythicmobs.utils.serialize.ChunkPosition; import org.bukkit.Chunk; import org.bukkit.ChunkSnapshot; import org.bukkit.block.TileState; @@ -203,59 +206,57 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer { IrisLock getFeatureLock(); + @BlockCoordinates default void forEachFeature(double x, double z, Consumer f) { if (!getEngine().getDimension().hasFeatures(getEngine())) { return; } - long key = Cache.key(((int) x) >> 4, ((int) z) >> 4); - - for (IrisFeaturePositional ipf : getFeatureCache().compute(key, (ke, v) -> { - if (v != null) { - return v; - } - - getFeatureLock().lock(); - KList pos = new KList<>(); - - for (IrisFeaturePositional i : getEngine().getDimension().getSpecificFeatures()) { - if (i.shouldFilter(x, z)) { - pos.add(i); - } - } - - int s = (int) Math.ceil(getParallaxSize() / 2D); - int i, j; - int cx = (int) x >> 4; - int cz = (int) z >> 4; - - for (i = -s; i <= s; i++) { - for (j = -s; j <= s; j++) { - ParallaxChunkMeta m = getParallaxAccess().getMetaR(i + cx, j + cz); - - synchronized (m) { - try { - for (IrisFeaturePositional k : m.getFeatures()) { - if (k.shouldFilter(x, z)) { - pos.add(k); - } - } - } catch (Throwable e) { - Iris.error("FILTER ERROR" + " AT " + (cx + i) + " " + (j + cz)); - e.printStackTrace(); - Iris.reportError(e); - } - } - } - } - getFeatureLock().unlock(); - - return pos; - })) { + for (IrisFeaturePositional ipf : forEachFeature(x, z)) { f.accept(ipf); } } + @BlockCoordinates + default KList forEachFeature(double x, double z) { + KList pos = new KList<>(); + + if (!getEngine().getDimension().hasFeatures(getEngine())) { + return pos; + } + + for (IrisFeaturePositional i : getEngine().getDimension().getSpecificFeatures()) { + if (i.shouldFilter(x, z, getEngine().getFramework().getComplex().getRng())) { + pos.add(i); + } + } + + int s = (int) Math.ceil(getParallaxSize() / 2D); + int i, j; + int cx = (int) x >> 4; + int cz = (int) z >> 4; + + for (i = -s; i <= s; i++) { + for (j = -s; j <= s; j++) { + ParallaxChunkMeta m = getParallaxAccess().getMetaR(i + cx, j + cz); + + try { + for (IrisFeaturePositional k : m.getFeatures()) { + if (k.shouldFilter(x, z, getEngine().getFramework().getComplex().getRng())) { + pos.add(k); + } + } + } catch (Throwable e) { + Iris.error("FILTER ERROR" + " AT " + (cx + i) + " " + (j + cz)); + e.printStackTrace(); + Iris.reportError(e); + } + } + } + + return pos; + } + @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") default void generateParallaxArea(int x, int z) { if (!getEngine().getDimension().isPlaceObjects()) { @@ -277,8 +278,8 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer { int xxx = xx << 4; int zzz = zz << 4; if (!getParallaxAccess().isFeatureGenerated(xx, zz)) { + getParallaxAccess().setFeatureGenerated(xx, zz); burst.queue(() -> { - getParallaxAccess().setFeatureGenerated(xx, zz); RNG rng = new RNG(Cache.key(xx, zz)).nextParallelRNG(getEngine().getTarget().getWorld().seed()); IrisRegion region = getComplex().getRegionStream().get(xxx, zzz); IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz); @@ -497,7 +498,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer { place(rng, x << 4, z << 4, i); } catch (Throwable e) { Iris.reportError(e); - Iris.error("Failed to place objects in the following biome: " + biome.getName()); + Iris.error("Failed to place objects in the following region: " + region.getName()); Iris.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")."); Iris.error("Are these objects missing?"); e.printStackTrace(); diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineTarget.java b/src/main/java/com/volmit/iris/engine/framework/EngineTarget.java index 50c565c93..be0b53661 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineTarget.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineTarget.java @@ -30,6 +30,7 @@ import java.io.File; @Data public class EngineTarget { + private final MultiBurst parallaxBurster; private final MultiBurst burster; private final IrisDimension dimension; private IrisWorld world; @@ -45,7 +46,8 @@ public class EngineTarget { this.data = data; this.inverted = inverted; this.burster = new MultiBurst("Iris Engine " + dimension.getName(), IrisSettings.get().getConcurrency().getEngineThreadPriority(), threads); - this.parallaxWorld = new ParallaxWorld(burster, 256, new File(world.worldFolder(), "iris/" + dimension.getLoadKey() + "/parallax")); + this.parallaxBurster = new MultiBurst("Iris Parallax Engine " + dimension.getName(), 3, 4); + this.parallaxWorld = new ParallaxWorld(parallaxBurster, 256, new File(world.worldFolder(), "iris/" + dimension.getLoadKey() + "/parallax")); } public EngineTarget(IrisWorld world, IrisDimension dimension, IrisDataManager data, int height, int threads) { @@ -53,6 +55,7 @@ public class EngineTarget { } public void close() { + parallaxBurster.shutdownAndAwait(); burster.shutdownAndAwait(); } } diff --git a/src/main/java/com/volmit/iris/engine/headless/HeadlessWorld.java b/src/main/java/com/volmit/iris/engine/headless/HeadlessWorld.java index 90e7cb2a4..f931ae8ef 100644 --- a/src/main/java/com/volmit/iris/engine/headless/HeadlessWorld.java +++ b/src/main/java/com/volmit/iris/engine/headless/HeadlessWorld.java @@ -69,11 +69,13 @@ public class HeadlessWorld { } public World load() { - return new WorldCreator(worldName) + World w = new WorldCreator(worldName) .environment(dimension.getEnvironment()) .seed(world.seed()) .generator(new EngineCompositeGenerator(dimension.getLoadKey(), !studio)) .createWorld(); + world.realWorld(w); + return w; } public static HeadlessWorld from(World world) { diff --git a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java index 55c6af355..a147a281c 100644 --- a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java +++ b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java @@ -377,7 +377,7 @@ public class PlannedStructure { return false; } - public synchronized IrisObject rotated(IrisJigsawPiece piece, IrisObjectRotation rotation) { + public IrisObject rotated(IrisJigsawPiece piece, IrisObjectRotation rotation) { String key = piece.getObject() + "-" + rotation.hashCode(); if (objectRotationCache.containsKey(key)) { diff --git a/src/main/java/com/volmit/iris/engine/lighting/LightingCube.java b/src/main/java/com/volmit/iris/engine/lighting/LightingCube.java index 5dc25d054..7434baf78 100644 --- a/src/main/java/com/volmit/iris/engine/lighting/LightingCube.java +++ b/src/main/java/com/volmit/iris/engine/lighting/LightingCube.java @@ -24,6 +24,7 @@ import com.bergerkiller.bukkit.common.wrappers.BlockData; import com.bergerkiller.bukkit.common.wrappers.ChunkSection; import com.bergerkiller.generated.net.minecraft.server.NibbleArrayHandle; import com.volmit.iris.Iris; +import com.volmit.iris.util.data.NibbleArray; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/com/volmit/iris/engine/object/CarvingMode.java b/src/main/java/com/volmit/iris/engine/object/CarvingMode.java index 02c335e91..22cb3248c 100644 --- a/src/main/java/com/volmit/iris/engine/object/CarvingMode.java +++ b/src/main/java/com/volmit/iris/engine/object/CarvingMode.java @@ -23,15 +23,12 @@ import com.volmit.iris.engine.object.annotations.Desc; @Desc("Defines if an object is allowed to place in carvings, surfaces or both.") public enum CarvingMode { @Desc("Only place this object on surfaces (NOT under carvings)") - SURFACE_ONLY, @Desc("Only place this object under carvings (NOT on the surface)") - CARVING_ONLY, @Desc("This object can place anywhere") - ANYWHERE; @SuppressWarnings("BooleanMethodIsAlwaysInverted") diff --git a/src/main/java/com/volmit/iris/engine/object/DecorationPart.java b/src/main/java/com/volmit/iris/engine/object/DecorationPart.java index 14ff152fd..f06b8cbb3 100644 --- a/src/main/java/com/volmit/iris/engine/object/DecorationPart.java +++ b/src/main/java/com/volmit/iris/engine/object/DecorationPart.java @@ -23,22 +23,17 @@ import com.volmit.iris.engine.object.annotations.Desc; @Desc("Represents a location where decorations should go") public enum DecorationPart { @Desc("The default, decorate anywhere") - NONE, @Desc("Targets shore lines (typically for sugar cane)") - SHORE_LINE, @Desc("Target sea surfaces (typically for lilypads)") - SEA_SURFACE, @Desc("Targets the sea floor (entire placement must be bellow sea level)") - SEA_FLOOR, @Desc("Decorates on cave & carving ceilings or underside of overhangs") - CEILING, } diff --git a/src/main/java/com/volmit/iris/engine/object/FontStyle.java b/src/main/java/com/volmit/iris/engine/object/FontStyle.java index 2537fc39f..6b5638336 100644 --- a/src/main/java/com/volmit/iris/engine/object/FontStyle.java +++ b/src/main/java/com/volmit/iris/engine/object/FontStyle.java @@ -23,14 +23,11 @@ import com.volmit.iris.engine.object.annotations.Desc; @Desc("Represents a basic font style to apply to a font family") public enum FontStyle { @Desc("Plain old text") - PLAIN, @Desc("Italicized Text") - ITALIC, @Desc("Bold Text") - BOLD, } diff --git a/src/main/java/com/volmit/iris/engine/object/InferredType.java b/src/main/java/com/volmit/iris/engine/object/InferredType.java index 4c4cff0bc..4946f28f7 100644 --- a/src/main/java/com/volmit/iris/engine/object/InferredType.java +++ b/src/main/java/com/volmit/iris/engine/object/InferredType.java @@ -23,23 +23,18 @@ import com.volmit.iris.engine.object.annotations.Desc; @Desc("Represents a biome type") public enum InferredType { @Desc("Represents any shore biome type") - SHORE, @Desc("Represents any land biome type") - LAND, @Desc("Represents any sea biome type") - SEA, @Desc("Represents any cave biome type") - CAVE, @Desc("Represents any river biome type") - RIVER, @Desc("Represents any lake biome type") diff --git a/src/main/java/com/volmit/iris/engine/object/InventorySlotType.java b/src/main/java/com/volmit/iris/engine/object/InventorySlotType.java index 3853c70ed..40a7f6bf9 100644 --- a/src/main/java/com/volmit/iris/engine/object/InventorySlotType.java +++ b/src/main/java/com/volmit/iris/engine/object/InventorySlotType.java @@ -23,22 +23,16 @@ import com.volmit.iris.engine.object.annotations.Desc; @Desc("An inventory slot type is used to represent a type of slot for items to fit into in any given inventory.") public enum InventorySlotType { @Desc("Typically the one you want to go with. Storage represnents most slots in inventories.") - STORAGE, @Desc("Used for the fuel slot in Furnaces, Blast furnaces, smokers etc.") - FUEL, @Desc("Used for the cook slot in furnaces") - FURNACE, - @Desc("Used for the cook slot in blast furnaces") - BLAST_FURNACE, @Desc("Used for the cook slot in smokers") - SMOKER, } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisAttributeModifier.java b/src/main/java/com/volmit/iris/engine/object/IrisAttributeModifier.java index 84f800496..6cca1edea 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisAttributeModifier.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisAttributeModifier.java @@ -40,14 +40,11 @@ import org.bukkit.inventory.meta.ItemMeta; @Data public class IrisAttributeModifier { @Required - @Desc("The Attribute type. This type is pulled from the game attributes. Zombie & Horse attributes will not work on non-zombie/horse entities.\nUsing an attribute on an item will have affects when held, or worn. There is no way to specify further granularity as the game picks this depending on the item type.") private Attribute attribute = null; @MinNumber(2) @Required - - @Desc("The Attribute Name is used internally only for the game. This value should be unique to all other attributes applied to this item/entity. It is not shown in game.") private String name = ""; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisAxisRotationClamp.java b/src/main/java/com/volmit/iris/engine/object/IrisAxisRotationClamp.java index deb7c9062..36c494b90 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisAxisRotationClamp.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisAxisRotationClamp.java @@ -31,7 +31,6 @@ import lombok.experimental.Accessors; @Desc("Represents a rotation axis with intervals and maxes. The x and z axis values are defaulted to disabled. The Y axis defaults to on, rotating by 90 degree increments.") @Data public class IrisAxisRotationClamp { - @Desc("Should this axis be rotated at all?") private boolean enabled = false; private transient boolean forceLock = false; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBiome.java b/src/main/java/com/volmit/iris/engine/object/IrisBiome.java index 31b597924..42f0f3934 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBiome.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBiome.java @@ -57,26 +57,21 @@ import java.awt.*; public class IrisBiome extends IrisRegistrant implements IRare { @MinNumber(2) @Required - @Desc("This is the human readable name for this biome. This can and should be different than the file name. This is not used for loading biomes in other objects.") private String name = "A Biome"; - @ArrayType(min = 1, type = IrisBiomeCustom.class) @Desc("If the biome type custom is defined, specify this") private KList customDerivitives; - @Desc("Entity spawns to override or add to this biome. Anytime an entity spawns, it has a chance to be replaced as one of these overrides.") @ArrayType(min = 1, type = IrisEntitySpawnOverride.class) private KList entitySpawnOverrides = new KList<>(); - @Desc("Add random chances for terrain features") @ArrayType(min = 1, type = IrisFeaturePotential.class) private KList features = new KList<>(); - @Desc("Entity spawns during generation") @ArrayType(min = 1, type = IrisEntityInitialSpawn.class) private KList entityInitialSpawns = new KList<>(); @@ -85,7 +80,6 @@ public class IrisBiome extends IrisRegistrant implements IRare { @Desc("Effects are ambient effects such as potion effects, random sounds, or even particles around each player. All of these effects are played via packets so two players won't see/hear each others effects.\nDue to performance reasons, effects will play around the player even if where the effect was played is no longer in the biome the player is in.") private KList effects = new KList<>(); - @DependsOn({"biomeStyle", "biomeZoom", "biomeScatter"}) @Desc("This changes the dispersion of the biome colors if multiple derivatives are chosen.") private IrisGeneratorStyle biomeStyle = NoiseStyle.SIMPLEX.style(); @@ -94,21 +88,17 @@ public class IrisBiome extends IrisRegistrant implements IRare { @Desc("Define custom block drops for this biome") private KList blockDrops = new KList<>(); - @Desc("Reference loot tables in this area") private IrisLootReference loot = new IrisLootReference(); @MinNumber(0.0001) - @DependsOn({"biomeStyle", "biomeZoom", "biomeScatter"}) @Desc("This zooms in the biome colors if multiple derivatives are chosen") private double biomeZoom = 1; - @Desc("Layers no longer descend from the surface block, they descend from the max possible height the biome can produce (constant) creating mesa like layers.") private boolean lockLayers = false; - @Desc("The max layers to iterate below the surface for locked layer biomes (mesa).") private int lockLayersMax = 7; @@ -117,17 +107,14 @@ public class IrisBiome extends IrisRegistrant implements IRare { @Desc("The rarity of this biome (integer)") private int rarity = 1; - @Desc("A color for visualizing this biome with a color. I.e. #F13AF5. This will show up on the map.") private String color = null; @Required - @Desc("The raw derivative of this biome. This is required or the terrain will not properly generate. Use any vanilla biome type. Look in examples/biome-list.txt") private Biome derivative = Biome.THE_VOID; @Required - @Desc("Override the derivative when vanilla places structures to this derivative. This is useful for example if you have an ocean biome, but you have set the derivative to desert to get a brown-ish color. To prevent desert structures from spawning on top of your ocean, you can set your vanillaDerivative to ocean, to allow for vanilla structures. Not defining this value will simply select the derivative.") private Biome vanillaDerivative = null; @@ -139,12 +126,10 @@ public class IrisBiome extends IrisRegistrant implements IRare { @Desc("Since 1.13 supports 3D biomes, you can add different derivative colors for anything above the terrain. (Think swampy tree leaves with a desert looking grass surface)") private KList biomeSkyScatter = new KList<>(); - @DependsOn({"children"}) @Desc("If this biome has children biomes, and the gen layer chooses one of this biomes children, how much smaller will it be (inside of this biome). Higher values means a smaller biome relative to this biome's size. Set higher than 1.0 and below 3.0 for best results.") private double childShrinkFactor = 1.5; - @DependsOn({"children"}) @Desc("If this biome has children biomes, and the gen layer chooses one of this biomes children, How will it be shaped?") private IrisGeneratorStyle childStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); @@ -159,15 +144,12 @@ public class IrisBiome extends IrisRegistrant implements IRare { private KList jigsawStructures = new KList<>(); @RegistryListBiome - @Desc("The carving biome. If specified the biome will be used when under a carving instead of this current biome.") private String carvingBiome = ""; - @Desc("The default slab if iris decides to place a slab in this biome. Default is no slab.") private IrisBiomePaletteLayer slab = new IrisBiomePaletteLayer().zero(); - @Desc("The default wall if iris decides to place a wall higher than 2 blocks (steep hills or possibly cliffs)") private IrisBiomePaletteLayer wall = new IrisBiomePaletteLayer().zero(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustom.java b/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustom.java index 16a2776d3..7d631efa4 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustom.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustom.java @@ -63,6 +63,7 @@ public class IrisBiomeCustom { @Desc("Define an ambient particle to be rendered clientside (no server cost!)") private IrisBiomeCustomParticle ambientParticle = null; + @Required @Desc("The biome's category type") private IrisBiomeCustomCategory category = IrisBiomeCustomCategory.plains; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustomPrecipType.java b/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustomPrecipType.java index de004136b..43bc8e835 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustomPrecipType.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustomPrecipType.java @@ -23,14 +23,11 @@ import com.volmit.iris.engine.object.annotations.Desc; @Desc("Snow, rain, or nothing") public enum IrisBiomeCustomPrecipType { @Desc("No downfall") - none, @Desc("Rain downfall") - rain, @Desc("Snow downfall") - snow } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustomSpawnType.java b/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustomSpawnType.java index 243f1a602..21df61cd4 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustomSpawnType.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustomSpawnType.java @@ -22,11 +22,24 @@ import com.volmit.iris.engine.object.annotations.Desc; @Desc("The mob spawn group") public enum IrisBiomeCustomSpawnType { + @Desc("Typical monsters that spawn at night, like zombies and skeletons") MONSTER, + + @Desc("Typical creatures like sheep, pigs, cows") CREATURE, + + @Desc("Eg bats") AMBIENT, + + @Desc("Odd spawn group but ok") UNDERGROUND_WATER_CREATURE, + + @Desc("Water mobs like squid, dolphins") WATER_CREATURE, + + @Desc("Fish") WATER_AMBIENT, + + @Desc("Unknown") MISC } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBiomeGeneratorLink.java b/src/main/java/com/volmit/iris/engine/object/IrisBiomeGeneratorLink.java index f0518d978..f3db36f74 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBiomeGeneratorLink.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBiomeGeneratorLink.java @@ -35,7 +35,6 @@ import lombok.experimental.Accessors; public class IrisBiomeGeneratorLink { @RegistryListGenerator - @Desc("The generator id") private String generator = "default"; @@ -43,7 +42,6 @@ public class IrisBiomeGeneratorLink { @Required @MinNumber(-256) // TODO: WARNING HEIGHT @MaxNumber(256) // TODO: WARNING HEIGHT - @Desc("The min block value (value + fluidHeight)") private int min = 0; @@ -51,7 +49,6 @@ public class IrisBiomeGeneratorLink { @Required @MinNumber(-256) // TODO: WARNING HEIGHT @MaxNumber(256) // TODO: WARNING HEIGHT - @Desc("The max block value (value + fluidHeight)") private int max = 0; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBiomeMutation.java b/src/main/java/com/volmit/iris/engine/object/IrisBiomeMutation.java index 25dfd1dac..5b18ede33 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBiomeMutation.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBiomeMutation.java @@ -34,7 +34,6 @@ import lombok.experimental.Accessors; @Desc("A biome mutation if a condition is met") @Data public class IrisBiomeMutation { - @RegistryListBiome @Required @ArrayType(min = 1, type = String.class) diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBiomePaletteLayer.java b/src/main/java/com/volmit/iris/engine/object/IrisBiomePaletteLayer.java index a34813fd7..c506d403b 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBiomePaletteLayer.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBiomePaletteLayer.java @@ -36,7 +36,6 @@ import org.bukkit.block.data.BlockData; @Desc("A layer of surface / subsurface material in biomes") @Data public class IrisBiomePaletteLayer { - @Desc("The style of noise") private IrisGeneratorStyle style = NoiseStyle.STATIC.style(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBlockData.java b/src/main/java/com/volmit/iris/engine/object/IrisBlockData.java index b50e58a35..d353d746c 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBlockData.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBlockData.java @@ -44,15 +44,12 @@ import java.util.Map; public class IrisBlockData extends IrisRegistrant { @RegistryListBlockType @Required - @Desc("The block to use") private String block = "air"; - @Desc("Debug this block by printing it to the console when it's used") - + @Desc("Debug this block by printing it to the console when it's used. Must have debug turned on in settings.") private boolean debug = false; - @Desc("The resource key. Typically Minecraft") private String key = "minecraft"; @@ -61,11 +58,9 @@ public class IrisBlockData extends IrisRegistrant { @Desc("The weight is used when this block data is inside of a list of blockdata. A weight of two is just as if you placed two of the same block data values in the same list making it more common when randomly picked.") private int weight = 1; - @Desc("If the block cannot be created on this version, Iris will attempt to use this backup block data instead.") private IrisBlockData backup = null; - @Desc("Optional properties for this block data such as 'waterlogged': true") private KMap data = new KMap<>(); @@ -122,7 +117,7 @@ public class IrisBlockData extends IrisRegistrant { String sx = getKey() + ":" + st.split("\\Q:\\E")[1] + computeProperties(cdata); if (debug) { - Iris.warn("Debug block data " + sx + " (CUSTOM)"); + Iris.debug("Block Data used " + sx + " (CUSTOM)"); } BlockData bx = B.get(sx); @@ -141,7 +136,7 @@ public class IrisBlockData extends IrisRegistrant { b = B.get(ss); if (debug) { - Iris.warn("Debug block data " + ss); + Iris.debug("Block Data used " + ss); } if (b != null) { diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBlockDrops.java b/src/main/java/com/volmit/iris/engine/object/IrisBlockDrops.java index ae26bb322..f3e4277c2 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBlockDrops.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBlockDrops.java @@ -43,20 +43,16 @@ public class IrisBlockDrops { @Desc("The blocks that drop loot") private KList blocks = new KList<>(); - @Desc("If exact blocks is set to true, minecraft:barrel[axis=x] will only drop for that axis. When exact is false (default) any barrel will drop the defined drops.") private boolean exactBlocks = false; - @Desc("Add in specific items to drop") @ArrayType(min = 1, type = IrisLoot.class) private KList drops = new KList<>(); - @Desc("If this is in a biome, setting skipParents to true will ignore the drops in the region and dimension for this block type. The default (false) will allow all three nodes to fire and add to a list of drops.") private boolean skipParents = false; - @Desc("Removes the default vanilla block drops and only drops the given items & any parent loot tables specified for this block type.") private boolean replaceVanillaDrops = false; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCarveLayer.java b/src/main/java/com/volmit/iris/engine/object/IrisCarveLayer.java index 9d039bf4f..072efb680 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCarveLayer.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCarveLayer.java @@ -39,7 +39,6 @@ import lombok.experimental.Accessors; @Data public class IrisCarveLayer { @Required - @Desc("The 4d slope this carve layer follows") private IrisGeneratorStyle style = new IrisGeneratorStyle(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCaveFluid.java b/src/main/java/com/volmit/iris/engine/object/IrisCaveFluid.java index ac781064f..bee66b38f 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCaveFluid.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCaveFluid.java @@ -43,12 +43,10 @@ public class IrisCaveFluid { @Desc("The fluid height of the cave") private int fluidHeight = 35; - @Desc("Insead of fluidHeight & below being fluid, turning inverse height on will simply spawn fluid in this cave layer from min(max_height, cave_height) to the fluid height. Basically, fluid will spawn above the fluidHeight value instead of below the fluidHeight.") private boolean inverseHeight = false; @Required - @Desc("The fluid type that should spawn here") private IrisBlockData fluidType = new IrisBlockData("CAVE_AIR"); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCaveLayer.java b/src/main/java/com/volmit/iris/engine/object/IrisCaveLayer.java index f3d95aefd..0da98747d 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCaveLayer.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCaveLayer.java @@ -33,16 +33,13 @@ import lombok.experimental.Accessors; @Data public class IrisCaveLayer { @Required - @Desc("The vertical slope this cave layer follows") private IrisShapedGeneratorStyle verticalSlope = new IrisShapedGeneratorStyle(); @Required - @Desc("The horizontal slope this cave layer follows") private IrisShapedGeneratorStyle horizontalSlope = new IrisShapedGeneratorStyle(); - @Desc("If defined, a cave fluid will fill this cave below (or above) the specified fluidHeight in this object.") private IrisCaveFluid fluid = new IrisCaveFluid(); @@ -54,7 +51,6 @@ public class IrisCaveLayer { @Desc("The cave thickness.") private double caveThickness = 1D; - @Desc("If set to true, this cave layer can break the surface") private boolean canBreakSurface = false; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisColor.java b/src/main/java/com/volmit/iris/engine/object/IrisColor.java index ef137c5d4..5c8fbf16f 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisColor.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisColor.java @@ -29,31 +29,26 @@ import lombok.experimental.Accessors; import java.awt.*; -@Deprecated() @Accessors(chain = true) @NoArgsConstructor @Desc("Represents a color") @Data public class IrisColor { - @MaxNumber(7) @MinNumber(6) @Desc("Pass in a 6 digit hexadecimal color to fill R G and B values. You can also include the # symbol, but it's not required.") private String hex = null; - @MaxNumber(255) @MinNumber(0) @Desc("Represents the red channel. Only define this if you are not defining the hex value.") private int red = 0; - @MaxNumber(255) @MinNumber(0) @Desc("Represents the green channel. Only define this if you are not defining the hex value.") private int green = 0; - - + @MaxNumber(255) @MinNumber(0) @Desc("Represents the blue channel. Only define this if you are not defining the hex value.") diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityBlockFilter.java b/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityBlockFilter.java index 32caf83c6..67d489915 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityBlockFilter.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityBlockFilter.java @@ -36,16 +36,13 @@ import org.bukkit.block.data.BlockData; @Data public class IrisCompatabilityBlockFilter { @Required - @Desc("When iris sees this block, and it's not reconized") private String when = ""; @Required - @Desc("Replace it with this block. Dont worry if this block is also not reconized, iris repeat this compat check.") private String supplement = ""; - @Desc("If exact is true, it compares block data for example minecraft:some_log[axis=x]") private boolean exact = false; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityItemFilter.java b/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityItemFilter.java index 7c6b706b3..97a7c45d8 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityItemFilter.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityItemFilter.java @@ -34,12 +34,10 @@ import org.bukkit.Material; @Data public class IrisCompatabilityItemFilter { @Required - @Desc("When iris sees this block, and it's not reconized") private String when = ""; @Required - @Desc("Replace it with this block. Dont worry if this block is also not reconized, iris repeat this compat check.") private String supplement = ""; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java b/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java index 52d012605..6b08a5d67 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java @@ -37,15 +37,12 @@ import org.bukkit.block.data.BlockData; @Desc("A biome decorator is used for placing flowers, grass, cacti and so on") @Data public class IrisDecorator { - @Desc("The varience dispersion is used when multiple blocks are put in the palette. Scatter scrambles them, Wispy shows streak-looking varience") private IrisGeneratorStyle variance = NoiseStyle.STATIC.style(); - @Desc("Forcefully place this decorant anywhere it is supposed to go even if it should not go on a specific surface block. For example, you could force tallgrass to place on top of stone by using this.") private boolean forcePlace = false; - @Desc("Dispersion is used to pick places to spawn. Scatter randomly places them (vanilla) or Wispy for a streak like patch system.") private IrisGeneratorStyle style = NoiseStyle.STATIC.style(); @@ -53,7 +50,6 @@ public class IrisDecorator { @Desc("If this decorator has a height more than 1 this changes how it picks the height between your maxes. Scatter = random, Wispy = wavy heights") private IrisGeneratorStyle heightVariance = NoiseStyle.STATIC.style(); - @Desc("Tells iris where this decoration is a part of. I.e. SHORE_LINE or SEA_SURFACE") private DecorationPart partOf = DecorationPart.NONE; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDepositGenerator.java b/src/main/java/com/volmit/iris/engine/object/IrisDepositGenerator.java index 29ef5a82e..e17acd402 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDepositGenerator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDepositGenerator.java @@ -39,14 +39,12 @@ public class IrisDepositGenerator { @Required @MinNumber(0) @MaxNumber(256) // TODO: WARNING HEIGHT - @Desc("The minimum height this deposit can generate at") private int minHeight = 7; @Required @MinNumber(0) @MaxNumber(256) // TODO: WARNING HEIGHT - @Desc("The maximum height this deposit can generate at") private int maxHeight = 55; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDimension.java b/src/main/java/com/volmit/iris/engine/object/IrisDimension.java index a356b9bb9..cfff66894 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDimension.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDimension.java @@ -53,7 +53,6 @@ public class IrisDimension extends IrisRegistrant { @MinNumber(2) @Required - @Desc("The human readable name of this dimension") private String name = "A Dimension"; @@ -61,10 +60,6 @@ public class IrisDimension extends IrisRegistrant { @ArrayType(min = 1, type = IrisDimensionIndex.class) private KList dimensionalComposite = new KList<>(); - @ArrayType(min = 1, type = IrisObjectPlacement.class) - @Desc("Objects define what schematics (iob files) iris will place in this biome. ONLY FOR SAPLINGS UNTIL FURTHER NOTICE!") - private KList objects = new KList<>(); - @Desc("Create an inverted dimension in the sky (like the nether)") private IrisDimension sky = null; @@ -72,7 +67,6 @@ public class IrisDimension extends IrisRegistrant { @Desc("If defined, Iris will place the given jigsaw structure where minecraft should place the overworld stronghold.") private String stronghold; - @Desc("Improves the biome grid variation by shuffling the cell grid more depending on the seed. This makes biomes across multiple seeds look far different than before.") private boolean aggressiveBiomeReshuffle = false; @@ -83,31 +77,25 @@ public class IrisDimension extends IrisRegistrant { @Desc("Instead of a flat bottom, applies a clamp (using this noise style) to the bottom instead of a flat bottom. Useful for carving out center-dimensions in a dimension composite world.") private IrisShapedGeneratorStyle undercarriage = null; - @Desc("Upon joining this world, Iris will send a resource pack request to the client. If they have previously selected yes, it will auto-switch depending on which dimension they go to.") private String resourcePack = ""; - @Desc("Entity spawns to override or add to this dimension") @ArrayType(min = 1, type = IrisEntitySpawnOverride.class) private KList entitySpawnOverrides = new KList<>(); - @Desc("Add specific features in exact positions") @ArrayType(min = 1, type = IrisFeaturePositional.class) private KList specificFeatures = new KList<>(); - @Desc("Entity spawns during generation") @ArrayType(min = 1, type = IrisEntityInitialSpawn.class) private KList entityInitialSpawns = new KList<>(); - @Desc("Add random chances for terrain features") @ArrayType(min = 1, type = IrisFeaturePotential.class) private KList features = new KList<>(); - @Desc("Reference loot tables in this area") private IrisLootReference loot = new IrisLootReference(); @@ -119,7 +107,6 @@ public class IrisDimension extends IrisRegistrant { @Desc("Define custom block drops for this dimension") private KList blockDrops = new KList<>(); - @Desc("Should bedrock be generated or not.") private boolean bedrock = true; @@ -128,71 +115,54 @@ public class IrisDimension extends IrisRegistrant { @Desc("The land chance. Up to 1.0 for total land or 0.0 for total sea") private double landChance = 0.625; - @Desc("The placement style of regions") private IrisGeneratorStyle regionStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); - @Desc("The placement style of land/sea") private IrisGeneratorStyle continentalStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); - @Desc("The placement style of biomes") private IrisGeneratorStyle landBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); - @Desc("The placement style of biomes") private IrisGeneratorStyle shoreBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); - @Desc("The placement style of biomes") private IrisGeneratorStyle seaBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); - @Desc("The placement style of biomes") private IrisGeneratorStyle caveBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); - @Desc("The placement style of biomes") private IrisGeneratorStyle riverBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); - @Desc("The placement style of biomes") private IrisGeneratorStyle lakeBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); - @Desc("The placement style of biomes") private IrisGeneratorStyle islandBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); - @Desc("The placement style of biomes") private IrisGeneratorStyle islandBiomeChanceStyle = NoiseStyle.CELLULAR_HEIGHT_IRIS_DOUBLE.style(); - @Desc("The placement style of biomes") private IrisGeneratorStyle skylandBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); - @Desc("Generate caves or not.") private boolean caves = true; - @Desc("Instead of filling objects with air, fills them with cobweb so you can see them") private boolean debugSmartBore = false; - @Desc("Carve terrain or not") private boolean carving = true; - @Desc("If defined, If air is defined below the area, this fluid will always place") private IrisCaveFluid forceFluid = new IrisCaveFluid(); - @Desc("Generate decorations or not") private boolean decorate = true; - @Desc("Generate ravines or not") private boolean ravines = false; @@ -204,23 +174,18 @@ public class IrisDimension extends IrisRegistrant { @Desc("The rarity of ravines. Each chunk has a 1 in X chance") private int ravineRarity = 50; - @Desc("Use post processing or not") private boolean postProcessing = true; - @Desc("Add slabs in post processing") private boolean postProcessingSlabs = true; - @Desc("Add painted walls in post processing") private boolean postProcessingWalls = true; - @Desc("Use post processing for caves or not") private boolean postProcessCaves = true; - @Desc("The world environment") private Environment environment = Environment.NORMAL; @@ -241,12 +206,10 @@ public class IrisDimension extends IrisRegistrant { private int fluidHeight = 63; @RegistryListBiome - @Desc("Keep this either undefined or empty. Setting any biome name into this will force iris to only generate the specified biome. Great for testing.") private String focus = ""; @RegistryListBiome - @Desc("Keep this either undefined or empty. Setting any region name into this will force iris to only generate the specified region. Great for testing.") private String focusRegion = ""; @@ -304,7 +267,6 @@ public class IrisDimension extends IrisRegistrant { @Desc("Disable this to stop placing schematics in biomes") private boolean placeObjects = true; - @Desc("Prevent Leaf decay as if placed in creative mode") private boolean preventLeafDecay = false; @@ -329,11 +291,9 @@ public class IrisDimension extends IrisRegistrant { @Desc("The rock zoom mostly for zooming in on a wispy palette") private double rockZoom = 5; - @Desc("The palette of blocks for 'stone'") private IrisMaterialPalette rockPalette = new IrisMaterialPalette().qclear().qadd("stone"); - @Desc("The palette of blocks for 'water'") private IrisMaterialPalette fluidPalette = new IrisMaterialPalette().qclear().qadd("water"); @@ -420,17 +380,7 @@ public class IrisDimension extends IrisRegistrant { } public KList getAllBiomes(DataProvider g) { - KList r = new KList<>(); - - for (IrisRegion i : getAllRegions(g)) { - if (i == null) { - continue; - } - - r.addAll(i.getAllBiomes(g)); - } - - return r; + return g.getData().getBiomeLoader().loadAll(g.getData().getBiomeLoader().getPossibleKeys()); } public KList getAllAnyBiomes() { diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDimensionIndex.java b/src/main/java/com/volmit/iris/engine/object/IrisDimensionIndex.java index 8f43d8cfe..20c4de4ef 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDimensionIndex.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDimensionIndex.java @@ -37,19 +37,15 @@ import lombok.experimental.Accessors; @EqualsAndHashCode(callSuper = false) public class IrisDimensionIndex { @Required - @Desc("The weight of this dimension. If there are 2 dimensions, if the weight is the same on both, both dimensions will take up 128 blocks of height.") private double weight = 1D; - @Desc("If inverted is set to true, the dimension will be updide down in the world") private boolean inverted = false; - @Desc("Only one dimension layer should be set to primary. The primary dimension layer is where players spawn, and the biomes that the vanilla structure system uses to figure out what structures to place.") private boolean primary = false; - @Required @RegistryListDimension @MinNumber(1) diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDirection.java b/src/main/java/com/volmit/iris/engine/object/IrisDirection.java index b812c0a0d..d8ec7e9b5 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDirection.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDirection.java @@ -39,11 +39,17 @@ import java.util.Map; */ @Desc("A direction object") public enum IrisDirection { + @Desc("0, 1, 0") UP_POSITIVE_Y(0, 1, 0, CuboidDirection.Up), + @Desc("0, -1, 0") DOWN_NEGATIVE_Y(0, -1, 0, CuboidDirection.Down), + @Desc("0, 0, -1") NORTH_NEGATIVE_Z(0, 0, -1, CuboidDirection.North), + @Desc("0, 0, 1") SOUTH_POSITIVE_Z(0, 0, 1, CuboidDirection.South), + @Desc("1, 0, 0") EAST_POSITIVE_X(1, 0, 0, CuboidDirection.East), + @Desc("-1, 0, 0") WEST_NEGATIVE_X(-1, 0, 0, CuboidDirection.West); private static KMap, DOP> permute = null; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEffect.java b/src/main/java/com/volmit/iris/engine/object/IrisEffect.java index 9bbfdca00..015d7dace 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEffect.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEffect.java @@ -42,12 +42,9 @@ import org.bukkit.potion.PotionEffectType; @Desc("An iris effect") @Data public class IrisEffect { - - @Desc("The potion effect to apply in this area") private String potionEffect = ""; - @Desc("The particle effect to apply in the area") private Particle particleEffect = null; @@ -87,7 +84,6 @@ public class IrisEffect { @Desc("Randomize the altZ by -altZ to altZ") private boolean randomAltZ = true; - @Desc("The sound to play") private Sound sound = null; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEnchantment.java b/src/main/java/com/volmit/iris/engine/object/IrisEnchantment.java index de73bbcd1..241dd0279 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEnchantment.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEnchantment.java @@ -40,9 +40,7 @@ import java.lang.reflect.Field; @Desc("Represents an enchantment & level") @Data public class IrisEnchantment { - @Required - @Desc("The enchantment") private String enchantment = ""; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEntity.java b/src/main/java/com/volmit/iris/engine/object/IrisEntity.java index b12bddea6..9f8fadf1b 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEntity.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEntity.java @@ -60,106 +60,81 @@ import java.util.concurrent.atomic.AtomicReference; @EqualsAndHashCode(callSuper = false) public class IrisEntity extends IrisRegistrant { @Required - @Desc("The type of entity to spawn. To spawn a mythic mob, set this type to unknown and define mythic type.") private EntityType type = EntityType.UNKNOWN; @RegistryListMythical @Desc("The type of mythic mob (if mythic mobs is installed). If this is set, make sure to set 'type' to UNKNOWN") - private String mythicalType = ""; - @Desc("The custom name of this entity") private String customName = ""; - @Desc("Should the name on this entity be visible even if you arent looking at it.") private boolean customNameVisible = false; - @Desc("If this entity type is a mob, should it be aware of it's surroundings & interact with the world.") private boolean aware = true; - @Desc("If this entity type is a creature, should it have ai goals.") private boolean ai = true; - @Desc("Should this entity be glowing") private boolean glowing = false; - @Desc("Should gravity apply to this entity") private boolean gravity = true; - @Desc("When an entity is invulnerable it can only be damaged by players increative mode.") private boolean invulnerable = false; - @Desc("When an entity is silent it will not produce any sound.") private boolean silent = false; - @Desc("Should this entity be allowed to pickup items") private boolean pickupItems = false; - @Desc("Should this entity be removed when far away") private boolean removable = true; - @Desc("Entity helmet equipment") private IrisLoot helmet = null; - @Desc("Entity chestplate equipment") private IrisLoot chestplate = null; - @Desc("Entity boots equipment") private IrisLoot boots = null; - @Desc("Entity leggings equipment") private IrisLoot leggings = null; - @Desc("Entity main hand equipment") private IrisLoot mainHand = null; - @Desc("Entity off hand equipment") private IrisLoot offHand = null; - @Desc("Make other entities ride this entity") @ArrayType(min = 1, type = IrisEntity.class) private KList passengers = new KList<>(); - @Desc("Attribute modifiers for this entity") @ArrayType(min = 1, type = IrisAttributeModifier.class) private KList attributes = new KList<>(); - @Desc("Loot tables for drops") private IrisLootReference loot = new IrisLootReference(); - @Desc("If specified, this entity will be leashed by this entity. I.e. THIS ENTITY Leashed by SPECIFIED. This has no effect on EnderDragons, Withers, Players, or Bats.Non-living entities excluding leashes will not persist as leashholders.") private IrisEntity leashHolder = null; - @Desc("The main gene for a panda if the entity type is a panda") private Gene pandaMainGene = Gene.NORMAL; - @Desc("The hidden gene for a panda if the entity type is a panda") private Gene pandaHiddenGene = Gene.NORMAL; - @Desc("The this entity is ageable, set it's baby status") private boolean baby = false; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEntityInitialSpawn.java b/src/main/java/com/volmit/iris/engine/object/IrisEntityInitialSpawn.java index 1e72382a3..1874702c7 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEntityInitialSpawn.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEntityInitialSpawn.java @@ -41,7 +41,6 @@ import org.bukkit.entity.Entity; public class IrisEntityInitialSpawn { @RegistryListEntity @Required - @Desc("The entity") private String entity = ""; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEntitySpawnOverride.java b/src/main/java/com/volmit/iris/engine/object/IrisEntitySpawnOverride.java index 1cc0150f9..74d178f07 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEntitySpawnOverride.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEntitySpawnOverride.java @@ -40,24 +40,18 @@ import org.bukkit.event.entity.EntitySpawnEvent; @Desc("Represents an entity spawn") @Data public class IrisEntitySpawnOverride { - @RegistryListEntity @Required - @Desc("The entity") private String entity = ""; - @Required - @Desc("If the following entity type spawns, spawn this entity. Set to unknown for any entity spawn") private EntityType trigger = EntityType.UNKNOWN; - @Desc("If the source is triggered, cancel spawning the original entity instead of ADDING a new entity.") private boolean cancelSourceSpawn = false; - @MinNumber(1) @Desc("The 1 in RARITY chance for this entity to spawn") private int rarity = 1; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisFeature.java b/src/main/java/com/volmit/iris/engine/object/IrisFeature.java index 049fd4727..07ecdeed0 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisFeature.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisFeature.java @@ -22,10 +22,7 @@ import com.google.gson.Gson; import com.volmit.iris.engine.cache.AtomicCache; import com.volmit.iris.engine.interpolation.InterpolationMethod; import com.volmit.iris.engine.interpolation.IrisInterpolation; -import com.volmit.iris.engine.object.annotations.Desc; -import com.volmit.iris.engine.object.annotations.MaxNumber; -import com.volmit.iris.engine.object.annotations.MinNumber; -import com.volmit.iris.engine.object.annotations.Required; +import com.volmit.iris.engine.object.annotations.*; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -41,64 +38,62 @@ import java.io.IOException; @Desc("Represents an Iris zone") public class IrisFeature { @Required - @Desc("The block radius of this zone") private double blockRadius = 32; @MinNumber(0) @MaxNumber(1) - @Required - @Desc("The chance an object that should be place actually will place. Set to below 1 to affect objects in this zone") private double objectChance = 1; - @Required + @RegistryListBiome + @Desc("Apply a custom biome here") + private String customBiome = null; + + @MinNumber(0) + @MaxNumber(1) + @Desc("How much strength before the biome is applied.") + private double biomeStrengthThreshold = 0.75; @Desc("The interpolation radius of this zone") private double interpolationRadius = 7; - @Required - @MaxNumber(1) @MinNumber(0) @Desc("The strength of this effect") - private double strength = 0.75; - - @Required + private double strength = 1; @Desc("The interpolator to use for smoothing the strength") private InterpolationMethod interpolator = InterpolationMethod.BILINEAR_STARCAST_9; - @Required - @Desc("If set, this will shift the terrain height in blocks (up or down)") private double shiftHeight = 0; - @Required - @Desc("If set, this will force the terrain closer to the specified height.") private double convergeToHeight = -1; - @Required - @Desc("Multiplies the input noise") private double multiplyHeight = 1; - @Required - @Desc("Invert the zone so that anything outside this zone is affected.") private boolean invertZone = false; - @Required - - @Desc("Add additional noise to this spot") - private IrisGeneratorStyle addNoise = NoiseStyle.FLAT.style(); - + @Desc("Fracture the radius ring with additional noise") + private IrisGeneratorStyle fractureRadius = null; private transient AtomicCache actualRadius = new AtomicCache<>(); public double getActualRadius() { - return actualRadius.aquire(() -> IrisInterpolation.getRealRadius(getInterpolator(), getInterpolationRadius())); + return actualRadius.aquire(() -> { + double o = 0; + + if(fractureRadius != null) + { + o+=fractureRadius.getMaxFractureDistance(); + } + + return o + IrisInterpolation.getRealRadius(getInterpolator(), getInterpolationRadius()); + }); } public static IrisFeature read(DataInputStream s) throws IOException { diff --git a/src/main/java/com/volmit/iris/engine/object/IrisFeaturePositional.java b/src/main/java/com/volmit/iris/engine/object/IrisFeaturePositional.java index ac3bedbcf..1b31cf943 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisFeaturePositional.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisFeaturePositional.java @@ -22,9 +22,12 @@ import com.google.gson.Gson; import com.volmit.iris.engine.cache.AtomicCache; import com.volmit.iris.engine.interpolation.IrisInterpolation; import com.volmit.iris.engine.object.annotations.Desc; +import com.volmit.iris.engine.object.annotations.MaxNumber; +import com.volmit.iris.engine.object.annotations.MinNumber; import com.volmit.iris.engine.object.annotations.Required; import com.volmit.iris.util.function.NoiseProvider; import com.volmit.iris.util.math.M; +import com.volmit.iris.util.math.RNG; import lombok.Data; import lombok.NoArgsConstructor; @@ -44,17 +47,14 @@ public class IrisFeaturePositional { } @Required - @Desc("The x coordinate of this zone") private int x; @Required - @Desc("The z coordinate of this zone") private int z; @Required - @Desc("The Terrain Feature to apply") private IrisFeature feature; @@ -69,9 +69,9 @@ public class IrisFeaturePositional { s.writeUTF(new Gson().toJson(this)); } - public boolean shouldFilter(double x, double z) { + public boolean shouldFilter(double x, double z, RNG rng) { double actualRadius = getFeature().getActualRadius(); - double dist2 = distance2(x, z); + double dist2 = distance2(x, z, rng); if (getFeature().isInvertZone()) { if (dist2 < Math.pow(getFeature().getBlockRadius() - actualRadius, 2)) { @@ -82,16 +82,16 @@ public class IrisFeaturePositional { return !(dist2 > Math.pow(getFeature().getBlockRadius() + actualRadius, 2)); } - public double getStrength(double x, double z) { + public double getStrength(double x, double z, RNG rng) { double actualRadius = getFeature().getActualRadius(); - double dist2 = distance2(x, z); + double dist2 = distance2(x, z, rng); if (getFeature().isInvertZone()) { if (dist2 < Math.pow(getFeature().getBlockRadius() - actualRadius, 2)) { return 0; } - NoiseProvider d = provider.aquire(this::getNoiseProvider); + NoiseProvider d = provider.aquire(() -> getNoiseProvider(rng)); double s = IrisInterpolation.getNoise(getFeature().getInterpolator(), (int) x, (int) z, getFeature().getInterpolationRadius(), d); if (s <= 0) { @@ -104,7 +104,7 @@ public class IrisFeaturePositional { return 0; } - NoiseProvider d = provider.aquire(this::getNoiseProvider); + NoiseProvider d = provider.aquire(() -> getNoiseProvider(rng)); double s = IrisInterpolation.getNoise(getFeature().getInterpolator(), (int) x, (int) z, getFeature().getInterpolationRadius(), d); if (s <= 0) { @@ -115,16 +115,31 @@ public class IrisFeaturePositional { } } - public double getObjectChanceModifier(double x, double z) { + public double getObjectChanceModifier(double x, double z, RNG rng) { if (getFeature().getObjectChance() >= 1) { return getFeature().getObjectChance(); } - return M.lerp(1, getFeature().getObjectChance(), getStrength(x, z)); + return M.lerp(1, getFeature().getObjectChance(), getStrength(x, z, rng)); } - public double filter(double x, double z, double noise) { - double s = getStrength(x, z); + public IrisBiome filter(double x, double z, IrisBiome biome, RNG rng) + { + if(getFeature().getCustomBiome() != null) + { + if(getStrength(x, z, rng) >= getFeature().getBiomeStrengthThreshold()) + { + IrisBiome b = biome.getLoader().getBiomeLoader().load(getFeature().getCustomBiome()); + b.setInferredType(biome.getInferredType()); + return b; + } + } + + return null; + } + + public double filter(double x, double z, double noise, RNG rng) { + double s = getStrength(x, z, rng); if (s <= 0) { return noise; @@ -142,19 +157,24 @@ public class IrisFeaturePositional { return M.lerp(noise, fx, s); } - public double distance(double x, double z) { - return Math.sqrt(Math.pow(this.x - x, 2) + Math.pow(this.z - z, 2)); + public double distance(double x, double z, RNG rng) { + double mul = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().getMultiplier()/2 : 1; + double mod = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().create(rng).fitDouble(-mul, mul, x, z) : 0; + return Math.sqrt(Math.pow(this.x - (x + mod), 2) + Math.pow(this.z - (z + mod), 2)); } - public double distance2(double x, double z) { - return Math.pow(this.x - x, 2) + Math.pow(this.z - z, 2); + public double distance2(double x, double z, RNG rng) { + double mul = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().getMultiplier()/2 : 1; + double mod = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().create(rng).fitDouble(-mul, mul, x, z) : 0; + + return Math.pow(this.x - (x+mod), 2) + Math.pow(this.z - (z+mod), 2); } - private NoiseProvider getNoiseProvider() { + private NoiseProvider getNoiseProvider(RNG rng) { if (getFeature().isInvertZone()) { - return (x, z) -> distance(x, z) > getFeature().getBlockRadius() ? 1D : 0D; + return (x, z) -> distance(x, z, rng) > getFeature().getBlockRadius() ? 1D : 0D; } else { - return (x, z) -> distance(x, z) < getFeature().getBlockRadius() ? 1D : 0D; + return (x, z) -> distance(x, z, rng) < getFeature().getBlockRadius() ? 1D : 0D; } } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisFeaturePotential.java b/src/main/java/com/volmit/iris/engine/object/IrisFeaturePotential.java index ce7a2d34f..7402241b4 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisFeaturePotential.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisFeaturePotential.java @@ -28,15 +28,12 @@ import lombok.Data; @Desc("Represents a potential Iris zone") public class IrisFeaturePotential { - @MinNumber(0) @Required - @Desc("The rarity is 1 in X chance per chunk") private int rarity = 100; @Required - @Desc("") private IrisFeature zone = new IrisFeature(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisGenerator.java b/src/main/java/com/volmit/iris/engine/object/IrisGenerator.java index 9c7f5fc63..72af98ab7 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisGenerator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisGenerator.java @@ -50,7 +50,6 @@ public class IrisGenerator extends IrisRegistrant { @Desc("The opacity, essentially a multiplier on the output.") private double opacity = 1; - @Desc("Multiply the compsites instead of adding them") private boolean multiplicitive = false; @@ -62,7 +61,6 @@ public class IrisGenerator extends IrisRegistrant { @Desc("Cell Fracture Coordinate Shuffling") private double cellFractureShuffle = 12D; - @Desc("The height of fracture cells. Set to 0 to disable") private double cellFractureHeight = 0D; @@ -71,21 +69,17 @@ public class IrisGenerator extends IrisRegistrant { @Desc("How big are the cells (X,Z) relative to the veins that touch them. Between 0 and 1. 0.1 means thick veins, small cells.") private double cellPercentSize = 0.75D; - @Desc("The offset to shift this noise x") private double offsetX = 0; - @Desc("The offset to shift this noise z") private double offsetZ = 0; @Required - @Desc("The seed for this generator") private long seed = 1; @Required - @Desc("The interpolator to use when smoothing this generator into other regions & generators") private IrisInterpolator interpolator = new IrisInterpolator(); @@ -103,7 +97,6 @@ public class IrisGenerator extends IrisRegistrant { @Desc("The list of noise gens this gen contains.") private KList composite = new KList<>(); - @Desc("The noise gen for cliff height.") private IrisNoiseGenerator cliffHeightGenerator = new IrisNoiseGenerator(); @@ -227,12 +220,11 @@ public class IrisGenerator extends IrisRegistrant { } int hc = (int) ((cliffHeightMin * 10) + 10 + cliffHeightMax * seed + offsetX + offsetZ); - double h = 0; - double tp = multiplicitive ? 1 : 0; + double h = multiplicitive ? 1 : 0; + double tp = 0; for (IrisNoiseGenerator i : composite) { if (multiplicitive) { - tp *= i.getOpacity(); h *= i.getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom); } else { tp += i.getOpacity(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisGeneratorStyle.java b/src/main/java/com/volmit/iris/engine/object/IrisGeneratorStyle.java index 0cede5423..6e4005510 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisGeneratorStyle.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisGeneratorStyle.java @@ -36,7 +36,6 @@ import lombok.experimental.Accessors; @Desc("A gen style") @Data public class IrisGeneratorStyle { - @Required @Desc("The chance is 1 in CHANCE per interval") private NoiseStyle style = NoiseStyle.IRIS; @@ -89,4 +88,8 @@ public class IrisGeneratorStyle { public boolean isFlat() { return style.equals(NoiseStyle.FLAT); } + + public double getMaxFractureDistance() { + return multiplier; + } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisInterpolator.java b/src/main/java/com/volmit/iris/engine/object/IrisInterpolator.java index aa579e755..4081e11ae 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisInterpolator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisInterpolator.java @@ -36,9 +36,7 @@ import lombok.experimental.Accessors; @Desc("Configures rotation for iris") @Data public class IrisInterpolator { - @Required - @Desc("The interpolation method when two biomes use different heights but this same generator") private InterpolationMethod function = InterpolationMethod.BICUBIC; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisJigsawPiece.java b/src/main/java/com/volmit/iris/engine/object/IrisJigsawPiece.java index bac937ef7..8005783f3 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisJigsawPiece.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisJigsawPiece.java @@ -45,18 +45,15 @@ import java.io.IOException; public class IrisJigsawPiece extends IrisRegistrant { @RegistryListObject @Required - @Desc("The object this piece represents") private String object = ""; @Required - @ArrayType(type = IrisJigsawPieceConnector.class, min = 1) @Desc("The connectors this object contains") private KList connectors = new KList<>(); @Desc("Configure everything about the object placement. Please don't define this unless you actually need it as using this option will slow down the jigsaw deign stage. Use this where you need it, just avoid using it everywhere to keep things fast.") - private IrisObjectPlacement placementOptions = new IrisObjectPlacement().setMode(ObjectPlaceMode.FAST_MAX_HEIGHT); private transient AtomicCache max2dDim = new AtomicCache<>(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisJigsawPieceConnector.java b/src/main/java/com/volmit/iris/engine/object/IrisJigsawPieceConnector.java index 4903b0152..12c8b4c5b 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisJigsawPieceConnector.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisJigsawPieceConnector.java @@ -36,20 +36,16 @@ import lombok.experimental.Accessors; @EqualsAndHashCode(callSuper = false) public class IrisJigsawPieceConnector { @Required - @Desc("The name of this connector, such as entry, or table node. This is a name for organization. Other connectors can specifically use targetName to target a specific connector type. Multiple connectors can use the same name.") private String name = ""; @Required - @Desc("Target a piece's connector with the specified name. For any piece's connector, define * or don't define it.") private String targetName = "*"; - @Desc("Rotates the placed piece on this connector. If rotation is enabled, this connector will effectivley rotate, if this connector is facing the Z direction, then the connected piece would rotate in the X,Y direction in 90 degree segments.") private boolean rotateConnector = false; - @Desc("If set to true, this connector is allowed to place pieces inside of it's own piece. For example if you are adding a light post, or house on top of a path piece, you would set this to true to allow the piece to collide with the path bounding box.") private boolean innerConnector = false; @@ -60,31 +56,25 @@ public class IrisJigsawPieceConnector { private KList pools = new KList<>(); @RegistryListEntity - @Desc("Pick an entity to spawn on this connector") private String spawnEntity; - @Desc("Stop the entity from despawning") private boolean keepEntity; - @MaxNumber(50) @MinNumber(1) @Desc("The amount of entities to spawn (must be a whole number)") private int entityCount = 1; - @Desc("The relative position this connector is located at for connecting to other pieces") @Required private IrisPosition position = new IrisPosition(0, 0, 0); - @Desc("The relative position to this connector to place entities at") @DependsOn({"spawnEntity"}) private IrisPosition entityPosition = null; - @Desc("The direction this connector is facing. If the direction is set to UP, then pieces will place ABOVE the connector.") @Required private IrisDirection direction = IrisDirection.UP_POSITIVE_Y; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisJigsawPlacement.java b/src/main/java/com/volmit/iris/engine/object/IrisJigsawPlacement.java index 22aad349d..23d9064c2 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisJigsawPlacement.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisJigsawPlacement.java @@ -35,7 +35,6 @@ import lombok.experimental.Accessors; public class IrisJigsawPlacement { @RegistryListJigsaw @Required - @Desc("The jigsaw structure to use") private String structure = ""; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisJigsawPool.java b/src/main/java/com/volmit/iris/engine/object/IrisJigsawPool.java index 3b9d53a6f..c5a52e39c 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisJigsawPool.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisJigsawPool.java @@ -40,7 +40,6 @@ import lombok.experimental.Accessors; public class IrisJigsawPool extends IrisRegistrant { @RegistryListJigsawPiece @Required - @ArrayType(min = 1, type = String.class) @Desc("A list of structure piece pools") private KList pieces = new KList<>(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructure.java b/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructure.java index 9df8e9a07..381e595a3 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructure.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructure.java @@ -39,7 +39,6 @@ import lombok.experimental.Accessors; public class IrisJigsawStructure extends IrisRegistrant { @RegistryListJigsawPiece @Required - @ArrayType(min = 1, type = String.class) @Desc("The starting pieces. Randomly chooses a starting piece, then connects pieces using the pools define in the starting piece.") private KList pieces = new KList<>(); @@ -49,15 +48,12 @@ public class IrisJigsawStructure extends IrisRegistrant { @Desc("The maximum pieces that can step out from the center piece") private int maxDepth = 9; - @Desc("Jigsaw grows the parallax layer which slows iris down a bit. Since there are so many pieces, Iris takes the avg piece size and calculates the parallax radius from that. Unless your structures are using only the biggest pieces, your structure should fit in the chosen size fine. If you are seeing cut-off parts of your structures or broken terrain, turn this option on. This option will pick the biggest piece dimensions and multiply it by your (maxDepth+1) * 2 as the size to grow the parallax layer by. But typically keep this off.") private boolean useMaxPieceSizeForParallaxRadius = false; @Desc("Add a noise feature to this village") - private IrisFeature feature = null; - @Desc("If set to true, iris will look for any pieces with only one connector in valid pools for edge connectors and attach them to 'terminate' the paths/piece connectors. Essentially it caps off ends. For example in a village, Iris would add houses to the ends of roads where possible. For terminators to be selected, they can only have one connector or they wont be chosen.") private boolean terminate = true; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructurePlacement.java b/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructurePlacement.java index c55349beb..7c56ef4c6 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructurePlacement.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructurePlacement.java @@ -38,11 +38,9 @@ import lombok.experimental.Accessors; public class IrisJigsawStructurePlacement extends IrisRegistrant { @RegistryListJigsaw @Required - @Desc("The structure to place") private String structure; - @Required @Desc("The 1 in X chance rarity") private int rarity = 100; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisLoot.java b/src/main/java/com/volmit/iris/engine/object/IrisLoot.java index ea5dd7a1a..ccf7273ae 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisLoot.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisLoot.java @@ -48,7 +48,6 @@ import java.awt.*; @Desc("Represents a loot entry") @Data public class IrisLoot { - @Desc("The target inventory slot types to fill this loot with") private InventorySlotType slotTypes = InventorySlotType.STORAGE; @@ -78,11 +77,9 @@ public class IrisLoot { @Desc("Maximum durability percent") private double maxDurability = 1; - @Desc("Define a custom model identifier 1.14+ only") private Integer customModel = null; - @Desc("Set this to true to prevent it from being broken") private boolean unbreakable = false; @@ -90,12 +87,10 @@ public class IrisLoot { @Desc("The item flags to add") private KList itemFlags = new KList<>(); - @Desc("Apply enchantments to this item") @ArrayType(min = 1, type = IrisEnchantment.class) private KList enchantments = new KList<>(); - @Desc("Apply attribute modifiers to this item") @ArrayType(min = 1, type = IrisAttributeModifier.class) private KList attributes = new KList<>(); @@ -106,15 +101,12 @@ public class IrisLoot { @RegistryListItemType @Required - @Desc("This is the item or block type. Does not accept minecraft:*. Only materials such as DIAMOND_SWORD or DIRT.") private String type = ""; - @Desc("The dye color") private DyeColor dyeColor = null; - @Desc("The leather armor color") private String leatherColor = null; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisLootReference.java b/src/main/java/com/volmit/iris/engine/object/IrisLootReference.java index a471888a4..16fa9a80a 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisLootReference.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisLootReference.java @@ -36,12 +36,9 @@ import lombok.experimental.Accessors; @Desc("Represents a loot entry") @Data public class IrisLootReference { - - @Desc("Add = add on top of parent tables, Replace = clear first then add these. Clear = Remove all and dont add loot from this or parent.") private LootMode mode = LootMode.ADD; - @RegistryListLoot @ArrayType(min = 1, type = String.class) @Desc("Add loot table registries here") diff --git a/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java b/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java index 089927f80..8a55966cc 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java @@ -41,9 +41,7 @@ import org.bukkit.inventory.ItemStack; @EqualsAndHashCode(callSuper = false) public class IrisLootTable extends IrisRegistrant { @Required - @Desc("The name of this loot table") - @MinNumber(2) private String name = ""; @@ -59,7 +57,6 @@ public class IrisLootTable extends IrisRegistrant { @Desc("The minimum amount of loot that can be picked in this table at a time.") private int minPicked = 1; - @Desc("The loot in this table") @ArrayType(min = 1, type = IrisLoot.class) private KList loot = new KList<>(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisMaterialPalette.java b/src/main/java/com/volmit/iris/engine/object/IrisMaterialPalette.java index 3b2b9849f..8df3d62e1 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisMaterialPalette.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisMaterialPalette.java @@ -39,7 +39,6 @@ import org.bukkit.block.data.BlockData; @Desc("A palette of materials") @Data public class IrisMaterialPalette { - @Desc("The style of noise") private IrisGeneratorStyle style = NoiseStyle.STATIC.style(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisMod.java b/src/main/java/com/volmit/iris/engine/object/IrisMod.java new file mode 100644 index 000000000..ea1510ab1 --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/object/IrisMod.java @@ -0,0 +1,115 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.engine.object; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.IrisDataManager; +import com.volmit.iris.engine.cache.AtomicCache; +import com.volmit.iris.engine.data.DataProvider; +import com.volmit.iris.engine.noise.CNG; +import com.volmit.iris.engine.object.annotations.*; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.io.IO; +import com.volmit.iris.util.math.Position2; +import com.volmit.iris.util.math.RNG; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import org.bukkit.Material; +import org.bukkit.World.Environment; +import org.bukkit.block.data.BlockData; + +import java.io.File; +import java.io.IOException; + +@SuppressWarnings("DefaultAnnotationParam") +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +@Desc("Represents a dimension") +@Data +@EqualsAndHashCode(callSuper = false) +public class IrisMod extends IrisRegistrant { + @MinNumber(2) + @Required + @Desc("The human readable name of this dimension") + private String name = "A Dimension Mod"; + + @Desc("If this mod only works with a specific dimension, define it's load key here. Such as overworld, or flat. Otherwise iris will assume this mod works with anything.") + private String forDimension = ""; + + @MinNumber(-1) + @MaxNumber(512) + @Desc("Override the fluid height. Otherwise set it to -1") + private int overrideFluidHeight = -1; + + @Desc("A list of biomes to remove") + @RegistryListBiome + @ArrayType(type = String.class, min = 1) + private KList removeBiomes = new KList<>(); + + @Desc("A list of objects to remove") + @RegistryListObject + @ArrayType(type = String.class, min = 1) + private KList removeObjects = new KList<>(); + + @Desc("A list of regions to remove") + @RegistryListRegion + @ArrayType(type = String.class, min = 1) + private KList removeRegions = new KList<>(); + + @Desc("A list of regions to inject") + @RegistryListRegion + @ArrayType(type = String.class, min = 1) + private KList injectRegions = new KList<>(); + + @ArrayType(min = 1, type = IrisModBiomeInjector.class) + @Desc("Inject biomes into existing regions") + private KList biomeInjectors = new KList<>(); + + @ArrayType(min = 1, type = IrisModBiomeReplacer.class) + @Desc("Replace biomes with other biomes") + private KList biomeReplacers = new KList<>(); + + @ArrayType(min = 1, type = IrisModObjectReplacer.class) + @Desc("Replace objects with other objects") + private KList objectReplacers = new KList<>(); + + @ArrayType(min = 1, type = IrisModObjectPlacementBiomeInjector.class) + @Desc("Inject placers into existing biomes") + private KList biomeObjectPlacementInjectors = new KList<>(); + + @ArrayType(min = 1, type = IrisModObjectPlacementRegionInjector.class) + @Desc("Inject placers into existing regions") + private KList regionObjectPlacementInjectors = new KList<>(); + + @ArrayType(min = 1, type = IrisModRegionReplacer.class) + @Desc("Replace biomes with other biomes") + private KList regionReplacers = new KList<>(); + + @ArrayType(min = 1, type = IrisObjectReplace.class) + @Desc("Replace blocks with other blocks") + private KList blockReplacers = new KList<>(); + + @ArrayType(min = 1, type = IrisModNoiseStyleReplacer.class) + @Desc("Replace noise styles with other styles") + private KList styleReplacers = new KList<>(); +} diff --git a/src/main/java/com/volmit/iris/engine/object/IrisModBiomeInjector.java b/src/main/java/com/volmit/iris/engine/object/IrisModBiomeInjector.java new file mode 100644 index 000000000..6dfaf80fd --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/object/IrisModBiomeInjector.java @@ -0,0 +1,44 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.engine.object; + +import com.volmit.iris.engine.object.annotations.*; +import com.volmit.iris.util.collection.KList; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("A biome injector") +@Data +public class IrisModBiomeInjector { + @Required + @Desc("The region to find") + @RegistryListRegion + private String region = ""; + + @Required + @Desc("A biome to inject into the region") + @RegistryListBiome + @ArrayType(type = String.class, min = 1) + private KList inject = new KList<>(); +} diff --git a/src/main/java/com/volmit/iris/engine/object/IrisModBiomeReplacer.java b/src/main/java/com/volmit/iris/engine/object/IrisModBiomeReplacer.java new file mode 100644 index 000000000..4c9c227e5 --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/object/IrisModBiomeReplacer.java @@ -0,0 +1,48 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.engine.object; + +import com.volmit.iris.engine.cache.AtomicCache; +import com.volmit.iris.engine.interpolation.IrisInterpolation; +import com.volmit.iris.engine.noise.CNG; +import com.volmit.iris.engine.object.annotations.*; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.math.RNG; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("A biome replacer") +@Data +public class IrisModBiomeReplacer { + @Required + @Desc("A list of biomes to find") + @RegistryListBiome + @ArrayType(type = String.class, min = 1) + private KList find = new KList<>(); + + @Required + @Desc("A biome to replace it with") + @RegistryListBiome + private String replace = ""; +} diff --git a/src/main/java/com/volmit/iris/engine/object/IrisModNoiseStyleReplacer.java b/src/main/java/com/volmit/iris/engine/object/IrisModNoiseStyleReplacer.java new file mode 100644 index 000000000..94d38714b --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/object/IrisModNoiseStyleReplacer.java @@ -0,0 +1,47 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.engine.object; + +import com.volmit.iris.engine.object.annotations.*; +import com.volmit.iris.util.collection.KList; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("A noise style replacer") +@Data +public class IrisModNoiseStyleReplacer { + @Required + @Desc("A noise style to find") + @ArrayType(type = String.class, min = 1) + private NoiseStyle find = NoiseStyle.IRIS; + + @Required + @Desc("If replaceTypeOnly is set to true, Iris will keep the existing generator style and only replace the type itself. Otherwise it will use the replace tag for every style using the find type.") + private boolean replaceTypeOnly = false; + + @Required + @Desc("A noise style to replace it with") + @RegistryListBiome + private IrisGeneratorStyle replace = new IrisGeneratorStyle(); +} diff --git a/src/main/java/com/volmit/iris/engine/object/IrisModObjectPlacementBiomeInjector.java b/src/main/java/com/volmit/iris/engine/object/IrisModObjectPlacementBiomeInjector.java new file mode 100644 index 000000000..51c079c8d --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/object/IrisModObjectPlacementBiomeInjector.java @@ -0,0 +1,46 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.engine.object; + +import com.volmit.iris.engine.object.annotations.ArrayType; +import com.volmit.iris.engine.object.annotations.Desc; +import com.volmit.iris.engine.object.annotations.RegistryListBiome; +import com.volmit.iris.engine.object.annotations.Required; +import com.volmit.iris.util.collection.KList; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("An object placement injector") +@Data +public class IrisModObjectPlacementBiomeInjector { + @Required + @Desc("The biome to find") + @RegistryListBiome + private String biome = ""; + + @Required + @Desc("A biome to inject into the region") + @ArrayType(type = IrisObjectPlacement.class, min = 1) + private KList place = new KList<>(); +} diff --git a/src/main/java/com/volmit/iris/engine/object/IrisModObjectPlacementRegionInjector.java b/src/main/java/com/volmit/iris/engine/object/IrisModObjectPlacementRegionInjector.java new file mode 100644 index 000000000..91d8f3179 --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/object/IrisModObjectPlacementRegionInjector.java @@ -0,0 +1,43 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.engine.object; + +import com.volmit.iris.engine.object.annotations.*; +import com.volmit.iris.util.collection.KList; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("An object placement injector") +@Data +public class IrisModObjectPlacementRegionInjector { + @Required + @Desc("The biome to find") + @RegistryListRegion + private String biome = ""; + + @Required + @Desc("A biome to inject into the region") + @ArrayType(type = IrisObjectPlacement.class, min = 1) + private KList place = new KList<>(); +} diff --git a/src/main/java/com/volmit/iris/engine/object/IrisModObjectReplacer.java b/src/main/java/com/volmit/iris/engine/object/IrisModObjectReplacer.java new file mode 100644 index 000000000..70580c5fa --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/object/IrisModObjectReplacer.java @@ -0,0 +1,44 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.engine.object; + +import com.volmit.iris.engine.object.annotations.*; +import com.volmit.iris.util.collection.KList; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("A biome replacer") +@Data +public class IrisModObjectReplacer { + @Required + @Desc("A list of objects to find") + @RegistryListObject + @ArrayType(type = String.class, min = 1) + private KList find = new KList<>(); + + @Required + @Desc("An object to replace it with") + @RegistryListBiome + private String replace = ""; +} diff --git a/src/main/java/com/volmit/iris/engine/object/IrisModRegionReplacer.java b/src/main/java/com/volmit/iris/engine/object/IrisModRegionReplacer.java new file mode 100644 index 000000000..756faf12d --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/object/IrisModRegionReplacer.java @@ -0,0 +1,44 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.engine.object; + +import com.volmit.iris.engine.object.annotations.*; +import com.volmit.iris.util.collection.KList; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("A region replacer") +@Data +public class IrisModRegionReplacer { + @Required + @Desc("A list of regions to find") + @RegistryListRegion + @ArrayType(type = String.class, min = 1) + private KList find = new KList<>(); + + @Required + @Desc("A region to replace it with") + @RegistryListRegion + private String replace = ""; +} diff --git a/src/main/java/com/volmit/iris/engine/object/IrisNoiseGenerator.java b/src/main/java/com/volmit/iris/engine/object/IrisNoiseGenerator.java index f73d66fea..79617b5f0 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisNoiseGenerator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisNoiseGenerator.java @@ -23,6 +23,7 @@ import com.volmit.iris.engine.interpolation.IrisInterpolation; import com.volmit.iris.engine.noise.CNG; import com.volmit.iris.engine.object.annotations.ArrayType; import com.volmit.iris.engine.object.annotations.Desc; +import com.volmit.iris.engine.object.annotations.MaxNumber; import com.volmit.iris.engine.object.annotations.MinNumber; import com.volmit.iris.engine.object.annotations.Required; import com.volmit.iris.util.collection.KList; @@ -38,58 +39,47 @@ import lombok.experimental.Accessors; @Desc("A noise generator") @Data public class IrisNoiseGenerator { - @MinNumber(0.0001) @Desc("The coordinate input zoom") private double zoom = 1; - @Desc("Reverse the output. So that noise = -noise + opacity") private boolean negative = false; @MinNumber(0) + @MaxNumber(1) @Desc("The output multiplier") private double opacity = 1; - @Desc("Coordinate offset x") private double offsetX = 0; - - @Desc("Height output offset y") + @Desc("Height output offset y. Avoid using with terrain generation.") private double offsetY = 0; - @Desc("Coordinate offset z") private double offsetZ = 0; @Required - @Desc("The seed") private long seed = 0; - @Desc("Apply a parametric curve on the output") private boolean parametric = false; - @Desc("Apply a bezier curve on the output") private boolean bezier = false; - @Desc("Apply a sin-center curve on the output (0, and 1 = 0 and 0.5 = 1.0 using a sinoid shape.)") private boolean sinCentered = false; - @Desc("The exponent noise^EXPONENT") private double exponent = 1; - @Desc("Enable / disable. Outputs offsetY if disabled") private boolean enabled = true; @Required - @Desc("The Noise Style") private IrisGeneratorStyle style = NoiseStyle.IRIS.style(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectLimit.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectLimit.java index 516323a08..41bb7ac6e 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectLimit.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectLimit.java @@ -32,7 +32,6 @@ import lombok.experimental.Accessors; @Desc("Translate objects") @Data public class IrisObjectLimit { - @MinNumber(0) @MaxNumber(255) @Desc("The minimum height for placement (bottom of object)") diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectLoot.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectLoot.java index 303d717ec..85b6e43cb 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectLoot.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectLoot.java @@ -37,23 +37,18 @@ import org.bukkit.block.data.BlockData; @Desc("Represents loot within this object or jigsaw piece") @Data public class IrisObjectLoot { - - @ArrayType(min = 1, type = IrisBlockData.class) @Desc("The list of blocks this loot table should apply to") private KList filter = new KList<>(); @Desc("Exactly match the block data or not") - private boolean exact = false; - @Desc("The loot table name") @Required @RegistryListLoot private String name; - @Desc("The weight of this loot table being chosen") private int weight = 1; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java index 7ad941aa2..a74fdec38 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java @@ -53,7 +53,6 @@ public class IrisObjectPlacement { @Desc("Rotate this objects placement") private IrisObjectRotation rotation = new IrisObjectRotation(); - @Desc("Limit the max height or min height of placement.") private IrisObjectLimit clamp = new IrisObjectLimit(); @@ -86,51 +85,39 @@ public class IrisObjectPlacement { @Desc("When bore is enabled, lower min-y of the cuboid it removes") private int boreExtendMinY = 0; - @Desc("If set to true, objects will place on the terrain height, ignoring the water surface.") private boolean underwater = false; - @Desc("If set to true, objects will place in carvings (such as underground) or under an overhang.") private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY; - @Desc("If this is defined, this object wont place on the terrain heightmap, but instead on this virtual heightmap") private IrisNoiseGenerator heightmap; - @Desc("If set to true, Iris will try to fill the insides of 'rooms' and 'pockets' where air should fit based off of raytrace checks. This prevents a village house placing in an area where a tree already exists, and instead replaces the parts of the tree where the interior of the structure is. \n\nThis operation does not affect warmed-up generation speed however it does slow down loading objects.") private boolean smartBore = false; - @Desc("If set to true, Blocks placed underwater that could be waterlogged are waterlogged.") private boolean waterloggable = false; - @Desc("If set to true, objects will place on the fluid height level Such as boats.") private boolean onwater = false; - @Desc("If set to true, this object will only place parts of itself where blocks already exist. Warning: Melding is very performance intensive!") private boolean meld = false; - @Desc("If set to true, this object will place from the ground up instead of height checks when not y locked to the surface. This is not compatable with X and Z axis rotations (it may look off)") private boolean bottom = false; - @Desc("If set to true, air will be placed before the schematic places.") private boolean bore = false; - @Desc("Use a generator to warp the field of coordinates. Using simplex for example would make a square placement warp like a flag") private IrisGeneratorStyle warp = new IrisGeneratorStyle(NoiseStyle.FLAT); - @Desc("If the place mode is set to CENTER_HEIGHT_RIGID and you have an X/Z translation, Turning on translate center will also translate the center height check.") private boolean translateCenter = false; - @Desc("The placement mode") private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT; @@ -138,11 +125,9 @@ public class IrisObjectPlacement { @Desc("Find and replace blocks") private KList edit = new KList<>(); - @Desc("Translate this object's placement") private IrisObjectTranslate translate = new IrisObjectTranslate(); - @Desc("Scale Objects") private IrisObjectScale scale = new IrisObjectScale(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacementScaleInterpolator.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacementScaleInterpolator.java index e25242b47..9fd987db7 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacementScaleInterpolator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacementScaleInterpolator.java @@ -22,19 +22,12 @@ import com.volmit.iris.engine.object.annotations.Desc; @Desc("Use 3D Interpolation on scaled objects if they are larger than the origin.") public enum IrisObjectPlacementScaleInterpolator { - @Desc("Don't interpolate, big cubes") NONE, - - @Desc("Uses linear interpolation in 3 dimensions, generally pretty good, but slow") TRILINEAR, - - @Desc("Uses cubic spline interpolation in 3 dimensions, even better, but extreme slowdowns") TRICUBIC, - - @Desc("Uses hermite spline interpolation in 3 dimensions, even better, but extreme slowdowns") TRIHERMITE } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectReplace.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectReplace.java index 6e645fea3..19923c991 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectReplace.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectReplace.java @@ -39,22 +39,18 @@ public class IrisObjectReplace { @ArrayType(min = 1, type = IrisBlockData.class) @Required @Desc("Find this block") - private KList find = new KList<>(); @Required @Desc("Replace it with this block palette") - private IrisMaterialPalette replace = new IrisMaterialPalette(); @Desc("Exactly match the block data or not") - private boolean exact = false; @MinNumber(0) @MaxNumber(1) @Desc("Modifies the chance the block is replaced") - private float chance = 1; private final transient AtomicCache replaceGen = new AtomicCache<>(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectRotation.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectRotation.java index 8dfe7b381..5ba8e8d04 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectRotation.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectRotation.java @@ -39,19 +39,15 @@ import java.util.List; @Desc("Configures rotation for iris") @Data public class IrisObjectRotation { - @Desc("If this rotator is enabled or not") private boolean enabled = true; - @Desc("The x axis rotation") private IrisAxisRotationClamp xAxis = new IrisAxisRotationClamp(); - @Desc("The y axis rotation") private IrisAxisRotationClamp yAxis = new IrisAxisRotationClamp(true, false, 0, 0, 90); - @Desc("The z axis rotation") private IrisAxisRotationClamp zAxis = new IrisAxisRotationClamp(); @@ -68,6 +64,11 @@ public class IrisObjectRotation { } public IrisObject rotateCopy(IrisObject e) { + if(e == null) + { + return null; + } + return e.rotateCopy(this); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectScale.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectScale.java index 5f366478d..0140f8353 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectScale.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectScale.java @@ -50,7 +50,6 @@ public class IrisObjectScale { @Desc("The maximum height for placement (top of object)") private double maximumScale = 1; - @Desc("If this object is scaled up beyond its origin size, specify a 3D interpolator") private IrisObjectPlacementScaleInterpolator interpolation = IrisObjectPlacementScaleInterpolator.NONE; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectTranslate.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectTranslate.java index d2ab83395..f37977d66 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectTranslate.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectTranslate.java @@ -34,29 +34,24 @@ import org.bukkit.util.BlockVector; @Desc("Translate objects") @Data public class IrisObjectTranslate { - @MinNumber(-128) // TODO: WARNING HEIGHT @MaxNumber(128) // TODO: WARNING HEIGHT - @Desc("The x shift in blocks") private int x = 0; @Required @MinNumber(-256) // TODO: WARNING HEIGHT @MaxNumber(256) // TODO: WARNING HEIGHT - @Desc("The x shift in blocks") private int y = 0; @MinNumber(-128) // TODO: WARNING HEIGHT @MaxNumber(128) // TODO: WARNING HEIGHT - @Desc("Adds an additional amount of height randomly (translateY + rand(0 - yRandom))") private int yRandom = 0; @MinNumber(-128) // TODO: WARNING HEIGHT @MaxNumber(128) // TODO: WARNING HEIGHT - @Desc("The x shift in blocks") private int z = 0; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisPosition.java b/src/main/java/com/volmit/iris/engine/object/IrisPosition.java index ac6be37bf..ccff485d9 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisPosition.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisPosition.java @@ -34,15 +34,12 @@ import org.bukkit.util.Vector; @Desc("Represents a position") @Data public class IrisPosition { - @Desc("The x position") private int x = 0; - @Desc("The y position") private int y = 0; - @Desc("The z position") private int z = 0; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisPosition2D.java b/src/main/java/com/volmit/iris/engine/object/IrisPosition2D.java index a08e1021a..8fbb907e3 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisPosition2D.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisPosition2D.java @@ -30,11 +30,9 @@ import lombok.experimental.Accessors; @Desc("Represents a position") @Data public class IrisPosition2D { - @Desc("The x position") private int x = 0; - @Desc("The z position") private int z = 0; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisPotionEffect.java b/src/main/java/com/volmit/iris/engine/object/IrisPotionEffect.java index 966a56f1e..86334bf11 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisPotionEffect.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisPotionEffect.java @@ -39,9 +39,7 @@ import org.bukkit.potion.PotionEffectType; @Desc("An iris potion effect") @Data public class IrisPotionEffect { - @Required - @Desc("The potion effect to apply in this area") private String potionEffect = ""; @@ -56,11 +54,9 @@ public class IrisPotionEffect { @Desc("The time the potion will last for") private int ticks = 200; - @Desc("Is the effect ambient") private boolean ambient = false; - @Desc("Is the effect showing particles") private boolean particles = true; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisRange.java b/src/main/java/com/volmit/iris/engine/object/IrisRange.java index 5b35b3dcc..1f6f13e9e 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisRange.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisRange.java @@ -31,11 +31,9 @@ import lombok.experimental.Accessors; @Desc("Represents a range") @Data public class IrisRange { - @Desc("The minimum value") private double min = 16; - @Desc("The maximum value") private double max = 32; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisRareObject.java b/src/main/java/com/volmit/iris/engine/object/IrisRareObject.java index d2bdc0983..8ac49f10f 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisRareObject.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisRareObject.java @@ -37,16 +37,13 @@ import lombok.experimental.Accessors; @Data @EqualsAndHashCode(callSuper = false) public class IrisRareObject { - @Required @MinNumber(1) @Desc("The rarity is 1 in X") - private int rarity = 1; @RegistryListObject @Required @Desc("The object to place if rarity check passed") - private String object = ""; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisRegion.java b/src/main/java/com/volmit/iris/engine/object/IrisRegion.java index 4c391eb14..eaf4d34ae 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisRegion.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisRegion.java @@ -52,7 +52,6 @@ import java.util.Random; public class IrisRegion extends IrisRegistrant implements IRare { @MinNumber(2) @Required - @Desc("The name of the region") private String name = "A Region"; @@ -60,7 +59,6 @@ public class IrisRegion extends IrisRegistrant implements IRare { @Desc("Jigsaw structures") private KList jigsawStructures = new KList<>(); - @Desc("Add random chances for terrain features") @ArrayType(min = 1, type = IrisFeaturePotential.class) private KList features = new KList<>(); @@ -69,12 +67,10 @@ public class IrisRegion extends IrisRegistrant implements IRare { @Desc("Effects are ambient effects such as potion effects, random sounds, or even particles around each player. All of these effects are played via packets so two players won't see/hear each others effects.\nDue to performance reasons, effects will play arround the player even if where the effect was played is no longer in the biome the player is in.") private KList effects = new KList<>(); - @Desc("Entity spawns to override or add to this region") @ArrayType(min = 1, type = IrisEntitySpawnOverride.class) private KList entitySpawnOverrides = new KList<>(); - @Desc("Entity spawns during generation") @ArrayType(min = 1, type = IrisEntityInitialSpawn.class) private KList entityInitialSpawns = new KList<>(); @@ -101,7 +97,6 @@ public class IrisRegion extends IrisRegistrant implements IRare { @Desc("The min shore height") private double shoreHeightMin = 1.2; - @Desc("Reference loot tables in this area") private IrisLootReference loot = new IrisLootReference(); @@ -187,23 +182,18 @@ public class IrisRegion extends IrisRegistrant implements IRare { @Desc("Define regional deposit generators that add onto the global deposit generators") private KList deposits = new KList<>(); - @Desc("The style of rivers") private IrisGeneratorStyle riverStyle = NoiseStyle.VASCULAR_THIN.style().zoomed(7.77); - @Desc("The style of lakes") private IrisGeneratorStyle lakeStyle = NoiseStyle.CELLULAR_IRIS_THICK.style(); - @Desc("The style of river chances") private IrisGeneratorStyle riverChanceStyle = NoiseStyle.SIMPLEX.style().zoomed(4); - @Desc("Generate lakes in this region") private boolean lakes = true; - @Desc("Generate rivers in this region") private boolean rivers = true; @@ -220,7 +210,6 @@ public class IrisRegion extends IrisRegistrant implements IRare { @Desc("Generate rivers in this region") private double riverThickness = 0.1; - @Desc("A color for visualizing this region with a color. I.e. #F13AF5. This will show up on the map.") private String color = null; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisRegionRidge.java b/src/main/java/com/volmit/iris/engine/object/IrisRegionRidge.java index d749c5b60..49f7149e8 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisRegionRidge.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisRegionRidge.java @@ -33,66 +33,51 @@ import lombok.experimental.Accessors; @Desc("A ridge config") @Data public class IrisRegionRidge { - @RegistryListBiome @Required - @Desc("The biome name") private String biome = ""; - @Required - @Desc("The type this biome should override (land sea or shore)") private InferredType type = InferredType.LAND; - @Desc("What type this spot is (i.e. target SEA but as LAND) like an island. Default matches the target type") private InferredType as = InferredType.DEFER; - @Desc("Use the distance from cell value to add or remove noise value. (Forces depth or height)") private double noiseMultiplier = 0; - @Required @MinNumber(0) @MaxNumber(1) @Desc("The chance this biome will be placed in a given spot") private double chance = 0.75; - @MinNumber(0) @Desc("The scale of the biome ridge. Higher values = wider veins & bigger connected cells") private double scale = 5; - @Desc("The chance scale (cell chances)") private double chanceScale = 4; - @MinNumber(0) @Desc("The shuffle, how 'natural' this looks. Compared to pure polygons") private double shuffle = 16; - @MinNumber(0) @Desc("The chance shuffle (polygon cell chances)") private double chanceShuffle = 128; - @MinNumber(0) @Desc("The thickness of the vein") private double thickness = 0.125; - @Desc("If the noise multiplier is below zero, what should the air be filled with?") private IrisBiomePaletteLayer air = new IrisBiomePaletteLayer().zero(); - private final transient AtomicCache spot = new AtomicCache<>(); private final transient AtomicCache ridge = new AtomicCache<>(); - public CellGenerator getSpotGenerator(RNG rng) { return spot.aquire(() -> { diff --git a/src/main/java/com/volmit/iris/engine/object/IrisRegionSpot.java b/src/main/java/com/volmit/iris/engine/object/IrisRegionSpot.java index e0fe0d5c6..8fa9bffc2 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisRegionSpot.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisRegionSpot.java @@ -36,23 +36,18 @@ import lombok.experimental.Accessors; @Desc("A spot config") @Data public class IrisRegionSpot { - @RegistryListBiome @Required - @Desc("The biome to be placed") private String biome = ""; @Required - @Desc("Where this spot overrides. Land sea or shore") private InferredType type = InferredType.LAND; - @Desc("What type this spot is (i.e. target SEA but as LAND) like an island. Default matches the target type") private InferredType as = InferredType.DEFER; - @Desc("Use the distance from cell value to add or remove noise value. (Forces depth or height)") private double noiseMultiplier = 0; @@ -69,7 +64,6 @@ public class IrisRegionSpot { @Desc("The shuffle or how natural the splotch looks like (anti-polygon)") private double shuffle = 128; - @Desc("If the noise multiplier is below zero, what should the air be filled with?") private IrisBiomePaletteLayer air = new IrisBiomePaletteLayer().zero(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisShapedGeneratorStyle.java b/src/main/java/com/volmit/iris/engine/object/IrisShapedGeneratorStyle.java index f07e44351..63b11d198 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisShapedGeneratorStyle.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisShapedGeneratorStyle.java @@ -35,23 +35,18 @@ import lombok.experimental.Accessors; @Data public class IrisShapedGeneratorStyle { @Required - @Desc("The generator id") - private IrisGeneratorStyle generator = new IrisGeneratorStyle(NoiseStyle.IRIS); @Required @MinNumber(-256) // TODO: WARNING HEIGHT @MaxNumber(256) // TODO: WARNING HEIGHT - - @Desc("The min block value") private int min = 0; @Required @MinNumber(-256) // TODO: WARNING HEIGHT @MaxNumber(256) // TODO: WARNING HEIGHT - @Desc("The max block value") private int max = 0; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisStyledRange.java b/src/main/java/com/volmit/iris/engine/object/IrisStyledRange.java index 2e54238db..6565609ff 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisStyledRange.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisStyledRange.java @@ -34,7 +34,6 @@ import lombok.experimental.Accessors; @Desc("Represents a range styled with a custom generator") @Data public class IrisStyledRange { - @Desc("The minimum value") private double min = 16; diff --git a/src/main/java/com/volmit/iris/engine/object/LootMode.java b/src/main/java/com/volmit/iris/engine/object/LootMode.java index 36b48995a..3643ea1b2 100644 --- a/src/main/java/com/volmit/iris/engine/object/LootMode.java +++ b/src/main/java/com/volmit/iris/engine/object/LootMode.java @@ -23,14 +23,9 @@ import com.volmit.iris.engine.object.annotations.Desc; @Desc("A loot mode is used to describe what to do with the existing loot layers before adding this loot. Using ADD will simply add this table to the building list of tables (i.e. add dimension tables, region tables then biome tables). By using clear or replace, you remove the parent tables before and add just your tables.") public enum LootMode { @Desc("Add to the existing parent loot tables") - ADD, - @Desc("Clear all loot tables then add this table") - CLEAR, - @Desc("Replace all loot tables with this table (same as clear)") - REPLACE } diff --git a/src/main/java/com/volmit/iris/engine/object/NoiseStyle.java b/src/main/java/com/volmit/iris/engine/object/NoiseStyle.java index e74ee04fb..57f83a99d 100644 --- a/src/main/java/com/volmit/iris/engine/object/NoiseStyle.java +++ b/src/main/java/com/volmit/iris/engine/object/NoiseStyle.java @@ -29,423 +29,318 @@ import com.volmit.iris.util.math.RNG; public enum NoiseStyle { @Desc("White Noise is like static. Useful for block scattering but not terrain.") - STATIC(rng -> new CNG(rng, NoiseType.WHITE, 1D, 1)), @Desc("Wispy Perlin-looking simplex noise. The 'iris' style noise.") - IRIS(rng -> CNG.signature(rng).scale(1)), @Desc("Classic German Engineering") - NOWHERE(rng -> CNG.signaturePerlin(rng).scale(0.776).bake()), - @Desc("Classic German Engineering") NOWHERE_CELLULAR(rng -> CNG.signaturePerlin(rng, NoiseType.CELLULAR).scale(1).bake()), @Desc("Classic German Engineering") - NOWHERE_SIMPLEX(rng -> CNG.signaturePerlin(rng, NoiseType.SIMPLEX).scale(1).bake()), @Desc("Classic German Engineering") - NOWHERE_GLOB(rng -> CNG.signaturePerlin(rng, NoiseType.GLOB).scale(1).bake()), @Desc("Classic German Engineering") - NOWHERE_VASCULAR(rng -> CNG.signaturePerlin(rng, NoiseType.VASCULAR).scale(1).bake()), @Desc("Classic German Engineering") - NOWHERE_CUBIC(rng -> CNG.signaturePerlin(rng, NoiseType.CUBIC).scale(1).bake()), @Desc("Classic German Engineering") - NOWHERE_SUPERFRACTAL(rng -> CNG.signaturePerlin(rng, NoiseType.FRACTAL_RIGID_MULTI_SIMPLEX).scale(1).bake()), @Desc("Classic German Engineering") - NOWHERE_FRACTAL(rng -> CNG.signaturePerlin(rng, NoiseType.FRACTAL_BILLOW_PERLIN).scale(1).bake()), @Desc("Wispy Perlin-looking simplex noise. The 'iris' style noise.") - IRIS_DOUBLE(rng -> CNG.signatureDouble(rng).scale(1)), @Desc("Wispy Perlin-looking simplex noise. The 'iris' style noise.") - IRIS_THICK(rng -> CNG.signatureThick(rng).scale(1)), @Desc("Wispy Perlin-looking simplex noise. The 'iris' style noise.") - IRIS_HALF(rng -> CNG.signatureHalf(rng).scale(1)), @Desc("Basic, Smooth & Fast Simplex noise.") - SIMPLEX(rng -> new CNG(rng, 1D, 1).scale(1)), @Desc("Very Detailed smoke using simplex fractured with fractal billow simplex at high octaves.") - FRACTAL_SMOKE(rng -> new CNG(rng, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(1), NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 8).scale(0.2), 1000).scale(0.34)), @Desc("Thinner Veins.") - VASCULAR_THIN(rng -> new CNG(rng.nextParallelRNG(1), NoiseType.VASCULAR, 1D, 1).scale(1).pow(0.65)), @Desc("Cells of simplex noise") - SIMPLEX_CELLS(rng -> new CNG(rng.nextParallelRNG(1), NoiseType.SIMPLEX, 1D, 1).scale(1).fractureWith(new CNG(rng.nextParallelRNG(8), NoiseType.CELLULAR, 1D, 1).scale(1), 200)), @Desc("Veins of simplex noise") - SIMPLEX_VASCULAR(rng -> new CNG(rng.nextParallelRNG(1), NoiseType.SIMPLEX, 1D, 1).scale(1).fractureWith(new CNG(rng.nextParallelRNG(8), NoiseType.VASCULAR, 1D, 1).scale(1), 200)), @Desc("Very Detailed fluid using simplex fractured with fractal billow simplex at high octaves.") - FRACTAL_WATER(rng -> new CNG(rng, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(1), NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 9).scale(0.03), 9900).scale(1.14)), @Desc("Perlin. Like simplex but more natural") - PERLIN(rng -> new CNG(rng, NoiseType.PERLIN, 1D, 1).scale(1.15)), @Desc("Perlin. Like simplex but more natural") - PERLIN_IRIS(rng -> CNG.signature(rng, NoiseType.PERLIN).scale(1.47)), @Desc("Perlin. Like simplex but more natural") - PERLIN_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.PERLIN).scale(1.47)), @Desc("Perlin. Like simplex but more natural") - PERLIN_IRIS_DOUBLE(rng -> CNG.signatureDouble(rng, NoiseType.PERLIN).scale(1.47)), @Desc("Perlin. Like simplex but more natural") - PERLIN_IRIS_THICK(rng -> CNG.signatureThick(rng, NoiseType.PERLIN).scale(1.47)), @Desc("Billow Fractal Perlin Noise.") - FRACTAL_BILLOW_PERLIN(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_PERLIN, 1D, 1).scale(1.47)), @Desc("Billow Fractal Perlin Noise. 2 Octaves") - BIOCTAVE_FRACTAL_BILLOW_PERLIN(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_PERLIN, 1D, 2).scale(1.17)), @Desc("Billow Fractal Simplex Noise. Single octave.") - FRACTAL_BILLOW_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 1)), @Desc("FBM Fractal Simplex Noise. Single octave.") - FRACTAL_FBM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 1)), @Desc("Billow Fractal Iris Noise. Single octave.") - FRACTAL_BILLOW_IRIS(rng -> CNG.signature(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX)), @Desc("FBM Fractal Iris Noise. Single octave.") - FRACTAL_FBM_IRIS(rng -> CNG.signature(rng, NoiseType.FRACTAL_FBM_SIMPLEX)), @Desc("Billow Fractal Iris Noise. Single octave.") - FRACTAL_BILLOW_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX)), @Desc("FBM Fractal Iris Noise. Single octave.") - FRACTAL_FBM_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.FRACTAL_FBM_SIMPLEX)), @Desc("Billow Fractal Iris Noise. Single octave.") - FRACTAL_BILLOW_IRIS_THICK(rng -> CNG.signatureThick(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX)), @Desc("FBM Fractal Iris Noise. Single octave.") - FRACTAL_FBM_IRIS_THICK(rng -> CNG.signatureThick(rng, NoiseType.FRACTAL_FBM_SIMPLEX)), @Desc("Rigid Multi Fractal Simplex Noise. Single octave.") - FRACTAL_RM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_RIGID_MULTI_SIMPLEX, 1D, 1)), @Desc("Billow Fractal Simplex Noise. 2 octaves.") - BIOCTAVE_FRACTAL_BILLOW_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 2)), @Desc("FBM Fractal Simplex Noise. 2 octaves.") - BIOCTAVE_FRACTAL_FBM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 2)), @Desc("Rigid Multi Fractal Simplex Noise. 2 octaves.") - BIOCTAVE_FRACTAL_RM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_RIGID_MULTI_SIMPLEX, 1D, 2)), @Desc("Rigid Multi Fractal Simplex Noise. 3 octaves.") - TRIOCTAVE_FRACTAL_RM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_RIGID_MULTI_SIMPLEX, 1D, 3)), @Desc("Billow Fractal Simplex Noise. 3 octaves.") - TRIOCTAVE_FRACTAL_BILLOW_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 3)), @Desc("FBM Fractal Simplex Noise. 3 octaves.") - TRIOCTAVE_FRACTAL_FBM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 3)), @Desc("Rigid Multi Fractal Simplex Noise. 4 octaves.") - QUADOCTAVE_FRACTAL_RM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_RIGID_MULTI_SIMPLEX, 1D, 4)), @Desc("Billow Fractal Simplex Noise. 4 octaves.") - QUADOCTAVE_FRACTAL_BILLOW_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 4)), @Desc("FBM Fractal Simplex Noise. 4 octaves.") - QUADOCTAVE_FRACTAL_FBM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 4)), @Desc("Rigid Multi Fractal Simplex Noise. 5 octaves.") - QUINTOCTAVE_FRACTAL_RM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_RIGID_MULTI_SIMPLEX, 1D, 5)), @Desc("Billow Fractal Simplex Noise. 5 octaves.") - QUINTOCTAVE_FRACTAL_BILLOW_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 5)), @Desc("FBM Fractal Simplex Noise. 5 octaves.") - QUINTOCTAVE_FRACTAL_FBM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 5)), @Desc("Rigid Multi Fractal Simplex Noise. 6 octaves.") - SEXOCTAVE_FRACTAL_RM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_RIGID_MULTI_SIMPLEX, 1D, 6)), @Desc("Billow Fractal Simplex Noise. 6 octaves.") - SEXOCTAVE_FRACTAL_BILLOW_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 6)), @Desc("FBM Fractal Simplex Noise. 6 octaves.") - SEXOCTAVE_FRACTAL_FBM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 6)), @Desc("Rigid Multi Fractal Simplex Noise. 7 octaves.") - SEPTOCTAVE_FRACTAL_RM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_RIGID_MULTI_SIMPLEX, 1D, 7)), @Desc("Billow Fractal Simplex Noise. 7 octaves.") - SEPTOCTAVE_FRACTAL_BILLOW_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 7)), @Desc("FBM Fractal Simplex Noise. 7 octaves.") - SEPTOCTAVE_FRACTAL_FBM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 7)), @Desc("Rigid Multi Fractal Simplex Noise. 8 octaves.") - OCTOCTAVE_FRACTAL_RM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_RIGID_MULTI_SIMPLEX, 1D, 8)), @Desc("Billow Fractal Simplex Noise. 8 octaves.") - OCTOCTAVE_FRACTAL_BILLOW_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 8)), @Desc("FBM Fractal Simplex Noise. 8 octaves.") - OCTOCTAVE_FRACTAL_FBM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 8)), @Desc("Rigid Multi Fractal Simplex Noise. 9 octaves.") - NONOCTAVE_FRACTAL_RM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_RIGID_MULTI_SIMPLEX, 1D, 9)), @Desc("Billow Fractal Simplex Noise. 9 octaves.") - NONOCTAVE_FRACTAL_BILLOW_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 9)), @Desc("FBM Fractal Simplex Noise. 9 octaves.") - NONOCTAVE_FRACTAL_FBM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 9)), @Desc("Rigid Multi Fractal Simplex Noise. 10 octaves.") - VIGOCTAVE_FRACTAL_RM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_RIGID_MULTI_SIMPLEX, 1D, 10)), @Desc("Billow Fractal Simplex Noise. 10 octaves.") - VIGOCTAVE_FRACTAL_BILLOW_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 10)), @Desc("FBM Fractal Simplex Noise. 10 octaves.") - VIGOCTAVE_FRACTAL_FBM_SIMPLEX(rng -> new CNG(rng, NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 10)), @Desc("Basic, Smooth & Fast Simplex noise. Uses 2 octaves") - BIOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 2).scale(1D / 2D)), @Desc("Basic, Smooth & Fast Simplex noise. Uses 3 octaves") - TRIOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 3).scale(1D / 3D)), @Desc("Basic, Smooth & Fast Simplex noise. Uses 4 octaves") - QUADOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 4).scale(1D / 4D)), @Desc("Basic, Smooth & Fast Simplex noise. Uses 5 octaves") - QUINTOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 5).scale(1D / 5D)), @Desc("Basic, Smooth & Fast Simplex noise. Uses 6 octaves") - SEXOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 6).scale(1D / 6D)), @Desc("Basic, Smooth & Fast Simplex noise. Uses 7 octaves") - SEPTOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 7).scale(1D / 12D)), @Desc("Basic, Smooth & Fast Simplex noise. Uses 8 octaves") - OCTOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 8).scale(1D / 25D)), @Desc("Basic, Smooth & Fast Simplex noise. Uses 9 octaves") - NONOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 9).scale(1D / 50D)), @Desc("Basic, Smooth & Fast Simplex noise. Uses 10 octaves") - VIGOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 10).scale(1D / 100D)), @Desc("Glob noise is like cellular, but with globs...") - GLOB(rng -> new CNG(rng, NoiseType.GLOB, 1D, 1)), @Desc("Glob noise is like cellular, but with globs...") - GLOB_IRIS(rng -> CNG.signature(rng, NoiseType.GLOB)), @Desc("Glob noise is like cellular, but with globs...") - GLOB_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.GLOB)), @Desc("Glob noise is like cellular, but with globs...") - GLOB_IRIS_DOUBLE(rng -> CNG.signatureDouble(rng, NoiseType.GLOB)), @Desc("Glob noise is like cellular, but with globs...") - GLOB_IRIS_THICK(rng -> CNG.signatureThick(rng, NoiseType.GLOB)), @Desc("Cubic Noise") - CUBIC(rng -> new CNG(rng, NoiseType.CUBIC, 1D, 1).scale(256)), @Desc("Fractal Cubic Noise") - FRACTAL_CUBIC(rng -> new CNG(rng, NoiseType.FRACTAL_CUBIC, 1D, 1).scale(2)), @Desc("Fractal Cubic Noise With Iris Swirls") - FRACTAL_CUBIC_IRIS(rng -> CNG.signature(rng, NoiseType.FRACTAL_CUBIC).scale(2)), @Desc("Fractal Cubic Noise With Iris Swirls") - FRACTAL_CUBIC_IRIS_THICK(rng -> CNG.signatureThick(rng, NoiseType.FRACTAL_CUBIC).scale(2)), @Desc("Fractal Cubic Noise With Iris Swirls") - FRACTAL_CUBIC_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.FRACTAL_CUBIC).scale(2)), @Desc("Fractal Cubic Noise With Iris Swirls") - FRACTAL_CUBIC_IRIS_DOUBLE(rng -> CNG.signatureDouble(rng, NoiseType.FRACTAL_CUBIC).scale(2)), @Desc("Fractal Cubic Noise, 2 Octaves") - BIOCTAVE_FRACTAL_CUBIC(rng -> new CNG(rng, NoiseType.FRACTAL_CUBIC, 1D, 2).scale(2)), @Desc("Fractal Cubic Noise, 3 Octaves") - TRIOCTAVE_FRACTAL_CUBIC(rng -> new CNG(rng, NoiseType.FRACTAL_CUBIC, 1D, 3).scale(1.5)), @Desc("Fractal Cubic Noise, 4 Octaves") - QUADOCTAVE_FRACTAL_CUBIC(rng -> new CNG(rng, NoiseType.FRACTAL_CUBIC, 1D, 4).scale(1)), @Desc("Cubic Noise") - CUBIC_IRIS(rng -> CNG.signature(rng, NoiseType.CUBIC).scale(256)), @Desc("Cubic Noise") - CUBIC_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.CUBIC).scale(256)), @Desc("Cubic Noise") - CUBIC_IRIS_DOUBLE(rng -> CNG.signatureDouble(rng, NoiseType.CUBIC).scale(256)), @Desc("Cubic Noise") - CUBIC_IRIS_THICK(rng -> CNG.signatureThick(rng, NoiseType.CUBIC).scale(256)), @Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.") - CELLULAR(rng -> new CNG(rng, NoiseType.CELLULAR, 1D, 1)), @Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders. Cells are distorted using Iris styled wispy noise.") - CELLULAR_IRIS(rng -> CNG.signature(rng, NoiseType.CELLULAR)), @Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders. Cells are distorted using Iris styled wispy noise.") - CELLULAR_IRIS_THICK(rng -> CNG.signatureThick(rng, NoiseType.CELLULAR)), @Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders. Cells are distorted using Iris styled wispy noise.") - CELLULAR_IRIS_DOUBLE(rng -> CNG.signatureDouble(rng, NoiseType.CELLULAR)), @Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders. Cells are distorted using Iris styled wispy noise.") - CELLULAR_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.CELLULAR)), @Desc("Inverse of vascular, height gets to 1.0 as it approaches the center of a cell") - CELLULAR_HEIGHT(rng -> new CNG(rng, NoiseType.CELLULAR_HEIGHT, 1D, 1)), @Desc("Inverse of vascular, height gets to 1.0 as it approaches the center of a cell, using the iris style.") - CELLULAR_HEIGHT_IRIS(rng -> CNG.signature(rng, NoiseType.CELLULAR_HEIGHT)), @Desc("Inverse of vascular, height gets to 1.0 as it approaches the center of a cell, using the iris style.") - CELLULAR_HEIGHT_IRIS_DOUBLE(rng -> CNG.signatureDouble(rng, NoiseType.CELLULAR_HEIGHT)), @Desc("Inverse of vascular, height gets to 1.0 as it approaches the center of a cell, using the iris style.") - CELLULAR_HEIGHT_IRIS_THICK(rng -> CNG.signatureThick(rng, NoiseType.CELLULAR_HEIGHT)), @Desc("Inverse of vascular, height gets to 1.0 as it approaches the center of a cell, using the iris style.") - CELLULAR_HEIGHT_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.CELLULAR_HEIGHT)), @Desc("Vascular noise gets higher as the position nears a cell border.") - VASCULAR(rng -> new CNG(rng, NoiseType.VASCULAR, 1D, 1)), @Desc("It always returns 0.5") - FLAT(rng -> new CNG(rng, NoiseType.FLAT, 1D, 1)), @Desc("Vascular noise gets higher as the position nears a cell border. Cells are distorted using Iris styled wispy noise.") - VASCULAR_IRIS(rng -> CNG.signature(rng, NoiseType.VASCULAR)), @Desc("Vascular noise gets higher as the position nears a cell border. Cells are distorted using Iris styled wispy noise.") - VASCULAR_IRIS_DOUBLE(rng -> CNG.signatureDouble(rng, NoiseType.VASCULAR)), @Desc("Vascular noise gets higher as the position nears a cell border. Cells are distorted using Iris styled wispy noise.") - VASCULAR_IRIS_THICK(rng -> CNG.signatureThick(rng, NoiseType.VASCULAR)), @Desc("Vascular noise gets higher as the position nears a cell border. Cells are distorted using Iris styled wispy noise.") - VASCULAR_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.VASCULAR)), ; diff --git a/src/main/java/com/volmit/iris/engine/parallax/ParallaxRegion.java b/src/main/java/com/volmit/iris/engine/parallax/ParallaxRegion.java index d131a508b..8426737ec 100644 --- a/src/main/java/com/volmit/iris/engine/parallax/ParallaxRegion.java +++ b/src/main/java/com/volmit/iris/engine/parallax/ParallaxRegion.java @@ -121,7 +121,7 @@ public class ParallaxRegion extends HunkRegion { if ((t instanceof ByteArrayTag)) { try { - meta = metaAdapter.read((x, y, z) -> Hunk.newArrayHunk(32, 1, 32), (ByteArrayTag) t); + meta = metaAdapter.read((x, y, z) -> Hunk.newAtomicHunk(32, 1, 32), (ByteArrayTag) t); } catch (IOException e) { Iris.reportError(e); e.printStackTrace(); @@ -129,7 +129,7 @@ public class ParallaxRegion extends HunkRegion { } if (meta == null) { - meta = Hunk.newArrayHunk(32, 1, 32); + meta = Hunk.newAtomicHunk(32, 1, 32); } } diff --git a/src/main/java/com/volmit/iris/engine/parallel/MultiBurst.java b/src/main/java/com/volmit/iris/engine/parallel/MultiBurst.java index 180372615..d808b2dc5 100644 --- a/src/main/java/com/volmit/iris/engine/parallel/MultiBurst.java +++ b/src/main/java/com/volmit/iris/engine/parallel/MultiBurst.java @@ -35,11 +35,11 @@ public class MultiBurst { } public MultiBurst(String name, int priority, int tc) { - service = Executors.newFixedThreadPool(tc, r -> { + service = Executors.newFixedThreadPool(Math.max(tc, 1), r -> { tid++; Thread t = new Thread(r); t.setName(name + " " + tid); - t.setPriority(6); + t.setPriority(priority); t.setUncaughtExceptionHandler((et, e) -> { Iris.info("Exception encountered in " + et.getName()); diff --git a/src/main/java/com/volmit/iris/util/data/NibbleArray.java b/src/main/java/com/volmit/iris/util/data/NibbleArray.java index a33f80f1a..52da2e825 100644 --- a/src/main/java/com/volmit/iris/util/data/NibbleArray.java +++ b/src/main/java/com/volmit/iris/util/data/NibbleArray.java @@ -100,21 +100,22 @@ public class NibbleArray implements Writable { } } - public byte getAsync(int index) { - int bitIndex = index * depth; - int byteIndex = bitIndex >> 3; - int bitInByte = bitIndex & 7; - int value = data[byteIndex] >> bitInByte; + public byte get(int x, int y, int z) + { + return get(index(x,y,z)); + } - if (bitInByte + depth > 8) { - value |= data[byteIndex + 1] << bitInByte; - } - - return (byte) (value & mask); + public int index(int x, int y, int z) { + return y << 8 | z << 4 | x; } private transient int bitIndex, byteIndex, bitInByte; + public void set(int x, int y, int z, int nibble) + { + set(index(x,y,z), nibble); + } + public void set(int index, int nibble) { set(index, (byte) nibble); } diff --git a/src/main/java/com/volmit/iris/util/math/Position2.java b/src/main/java/com/volmit/iris/util/math/Position2.java index 835f1e448..96e2746a8 100644 --- a/src/main/java/com/volmit/iris/util/math/Position2.java +++ b/src/main/java/com/volmit/iris/util/math/Position2.java @@ -83,4 +83,8 @@ public class Position2 { public Position2 add(int x, int z) { return new Position2(this.x + x, this.z + z); } + + public Position2 blockToChunk() { + return new Position2(x >> 4, z >> 4); + } } diff --git a/src/main/java/com/volmit/iris/util/scheduling/J.java b/src/main/java/com/volmit/iris/util/scheduling/J.java index 614e4ebdf..cd85271a4 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/J.java +++ b/src/main/java/com/volmit/iris/util/scheduling/J.java @@ -219,6 +219,15 @@ public class J { return f; } + public static CompletableFuture afut(Runnable r) { + CompletableFuture f = new CompletableFuture(); + J.a(() -> { + r.run(); + f.complete(null); + }); + return f; + } + /** * Queue a sync task *