From dd7a8bae16311ff0469ecc4b15d84521e456dc67 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Tue, 12 Jan 2021 06:05:37 -0500 Subject: [PATCH] Eradicate the old structure system --- src/main/java/com/volmit/iris/Iris.java | 2 - .../iris/generator/IrisEngineCompound.java | 2 - .../iris/generator/IrisEngineParallax.java | 5 - .../iris/generator/IrisEngineStructure.java | 10 - .../actuator/IrisDecorantActuator.java | 2 +- .../volmit/iris/manager/IrisDataManager.java | 10 - .../com/volmit/iris/manager/IrisProject.java | 65 -- .../volmit/iris/manager/SchemaBuilder.java | 34 - .../volmit/iris/manager/StructureManager.java | 55 - .../iris/manager/command/CommandIris.java | 3 - .../manager/command/CommandIrisStructure.java | 67 -- .../command/CommandIrisStructureClose.java | 62 - .../command/CommandIrisStructureCreate.java | 104 -- .../command/CommandIrisStructureExpand.java | 62 - .../command/CommandIrisStructureMove.java | 62 - .../command/CommandIrisStructureOpen.java | 70 -- .../command/CommandIrisStructureSave.java | 62 - .../command/CommandIrisStructureVariants.java | 61 - .../iris/manager/link/MultiverseCoreLink.java | 2 +- .../manager/structure/StructureTemplate.java | 1002 ----------------- .../com/volmit/iris/object/IrisStructure.java | 196 ---- .../iris/object/IrisStructurePlacement.java | 99 -- .../volmit/iris/object/IrisStructureTile.java | 169 --- .../iris/object/StructureTileCondition.java | 30 - .../volmit/iris/object/StructureTileFace.java | 43 - .../com/volmit/iris/object/TileResult.java | 32 - .../EngineAssignedStructureManager.java | 7 - .../engine/EngineCompositeGenerator.java | 10 +- .../engine/EngineParallaxManager.java | 27 - .../engine/EngineStructureManager.java | 189 ---- .../volmit/iris/util/IrisStructureResult.java | 19 - .../iris/util/RegistryListStructure.java | 14 - 32 files changed, 3 insertions(+), 2574 deletions(-) delete mode 100644 src/main/java/com/volmit/iris/generator/IrisEngineStructure.java delete mode 100644 src/main/java/com/volmit/iris/manager/StructureManager.java delete mode 100644 src/main/java/com/volmit/iris/manager/command/CommandIrisStructure.java delete mode 100644 src/main/java/com/volmit/iris/manager/command/CommandIrisStructureClose.java delete mode 100644 src/main/java/com/volmit/iris/manager/command/CommandIrisStructureCreate.java delete mode 100644 src/main/java/com/volmit/iris/manager/command/CommandIrisStructureExpand.java delete mode 100644 src/main/java/com/volmit/iris/manager/command/CommandIrisStructureMove.java delete mode 100644 src/main/java/com/volmit/iris/manager/command/CommandIrisStructureOpen.java delete mode 100644 src/main/java/com/volmit/iris/manager/command/CommandIrisStructureSave.java delete mode 100644 src/main/java/com/volmit/iris/manager/command/CommandIrisStructureVariants.java delete mode 100644 src/main/java/com/volmit/iris/manager/structure/StructureTemplate.java delete mode 100644 src/main/java/com/volmit/iris/object/IrisStructure.java delete mode 100644 src/main/java/com/volmit/iris/object/IrisStructurePlacement.java delete mode 100644 src/main/java/com/volmit/iris/object/IrisStructureTile.java delete mode 100644 src/main/java/com/volmit/iris/object/StructureTileCondition.java delete mode 100644 src/main/java/com/volmit/iris/object/StructureTileFace.java delete mode 100644 src/main/java/com/volmit/iris/object/TileResult.java delete mode 100644 src/main/java/com/volmit/iris/scaffold/engine/EngineAssignedStructureManager.java delete mode 100644 src/main/java/com/volmit/iris/scaffold/engine/EngineStructureManager.java delete mode 100644 src/main/java/com/volmit/iris/util/IrisStructureResult.java delete mode 100644 src/main/java/com/volmit/iris/util/RegistryListStructure.java diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index 6e7a9eb72..528ad2e8a 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -35,7 +35,6 @@ public class Iris extends VolmitPlugin public static ProjectManager proj; public static ConversionManager convert; public static WandManager wand; - public static StructureManager struct; public static EditManager edit; public static IrisBoardManager board; public static BKLink linkBK; @@ -162,7 +161,6 @@ public class Iris extends VolmitPlugin proj = new ProjectManager(); convert = new ConversionManager(); wand = new WandManager(); - struct = new StructureManager(); board = new IrisBoardManager(); linkMultiverseCore = new MultiverseCoreLink(); linkBK = new BKLink(); diff --git a/src/main/java/com/volmit/iris/generator/IrisEngineCompound.java b/src/main/java/com/volmit/iris/generator/IrisEngineCompound.java index 958274a50..a39fbe263 100644 --- a/src/main/java/com/volmit/iris/generator/IrisEngineCompound.java +++ b/src/main/java/com/volmit/iris/generator/IrisEngineCompound.java @@ -1,7 +1,6 @@ package com.volmit.iris.generator; import com.volmit.iris.Iris; -import com.volmit.iris.IrisSettings; import com.volmit.iris.manager.IrisDataManager; import com.volmit.iris.object.IrisDimension; import com.volmit.iris.object.IrisDimensionIndex; @@ -221,7 +220,6 @@ public class IrisEngineCompound implements EngineCompound { int offset = 0; BurstExecutor e = burster.burst(); Runnable[] insert = new Runnable[engines.length]; - boolean structures = getDefaultEngine().getDimension().isVanillaStructures() && !IrisSettings.get().getGeneral().isDisableNMS(); for(i = 0; i < engines.length; i++) { diff --git a/src/main/java/com/volmit/iris/generator/IrisEngineParallax.java b/src/main/java/com/volmit/iris/generator/IrisEngineParallax.java index 7cbd08d36..5e72bf6c0 100644 --- a/src/main/java/com/volmit/iris/generator/IrisEngineParallax.java +++ b/src/main/java/com/volmit/iris/generator/IrisEngineParallax.java @@ -2,16 +2,12 @@ package com.volmit.iris.generator; import com.volmit.iris.scaffold.engine.Engine; import com.volmit.iris.scaffold.engine.EngineParallaxManager; -import com.volmit.iris.scaffold.engine.EngineStructureManager; import lombok.Getter; public class IrisEngineParallax implements EngineParallaxManager { @Getter private final Engine engine; - @Getter - private final EngineStructureManager structureManager; - @Getter private final int parallaxSize; @@ -19,6 +15,5 @@ public class IrisEngineParallax implements EngineParallaxManager { { this.engine = engine; parallaxSize = computeParallaxSize(); - structureManager = new IrisEngineStructure(getEngine()); } } diff --git a/src/main/java/com/volmit/iris/generator/IrisEngineStructure.java b/src/main/java/com/volmit/iris/generator/IrisEngineStructure.java deleted file mode 100644 index 95844d8bb..000000000 --- a/src/main/java/com/volmit/iris/generator/IrisEngineStructure.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.volmit.iris.generator; - -import com.volmit.iris.scaffold.engine.Engine; -import com.volmit.iris.scaffold.engine.EngineAssignedStructureManager; - -public class IrisEngineStructure extends EngineAssignedStructureManager { - public IrisEngineStructure(Engine engine) { - super(engine); - } -} diff --git a/src/main/java/com/volmit/iris/generator/actuator/IrisDecorantActuator.java b/src/main/java/com/volmit/iris/generator/actuator/IrisDecorantActuator.java index 3b9af576a..262141c4c 100644 --- a/src/main/java/com/volmit/iris/generator/actuator/IrisDecorantActuator.java +++ b/src/main/java/com/volmit/iris/generator/actuator/IrisDecorantActuator.java @@ -116,6 +116,6 @@ public class IrisDecorantActuator extends EngineAssignedActuator private boolean shouldRayDecorate() { - return getEngine().getDimension().isCarving() || getEngine().getDimension().isCaves() || getEngine().getDimension().isVanillaCaves() || getEngine().getDimension().isRavines(); + return getEngine().getDimension().isCarving() || getEngine().getDimension().isCaves() || getEngine().getDimension().isRavines(); } } diff --git a/src/main/java/com/volmit/iris/manager/IrisDataManager.java b/src/main/java/com/volmit/iris/manager/IrisDataManager.java index 3fff41b68..292954e00 100644 --- a/src/main/java/com/volmit/iris/manager/IrisDataManager.java +++ b/src/main/java/com/volmit/iris/manager/IrisDataManager.java @@ -18,7 +18,6 @@ public class IrisDataManager private ResourceLoader regionLoader; private ResourceLoader dimensionLoader; private ResourceLoader generatorLoader; - private ResourceLoader structureLoader; private ResourceLoader jigsawPieceLoader; private ResourceLoader jigsawPoolLoader; private ResourceLoader jigsawStructureLoader; @@ -51,7 +50,6 @@ public class IrisDataManager this.regionLoader = null; this.biomeLoader = null; this.dimensionLoader = null; - this.structureLoader = null; this.jigsawPoolLoader = null; this.jigsawPieceLoader = null; this.generatorLoader = null; @@ -83,7 +81,6 @@ public class IrisDataManager this.regionLoader = new ResourceLoader<>(packs, this, "regions", "Region", IrisRegion.class); this.biomeLoader = new ResourceLoader<>(packs, this, "biomes", "Biome", IrisBiome.class); this.dimensionLoader = new ResourceLoader<>(packs, this, "dimensions", "Dimension", IrisDimension.class); - this.structureLoader = new ResourceLoader<>(packs, this, "structures", "Structure", IrisStructure.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); this.jigsawPieceLoader = new ResourceLoader<>(packs, this, "jigsaw-pieces", "Jigsaw Piece", IrisJigsawPiece.class); @@ -109,7 +106,6 @@ public class IrisDataManager dimensionLoader.clearCache(); entityLoader.clearCache(); generatorLoader.clearCache(); - structureLoader.clearCache(); } public void clearLists() @@ -127,7 +123,6 @@ public class IrisDataManager dimensionLoader.clearList(); generatorLoader.clearList(); jigsawStructureLoader.clearList(); - structureLoader.clearList(); jigsawPoolLoader.clearList(); jigsawPieceLoader.clearList(); objectLoader.clearList(); @@ -143,11 +138,6 @@ public class IrisDataManager return loadAny(key, (dm) -> dm.getBiomeLoader().load(key, false)); } - public static IrisStructure loadAnyStructure(String key) - { - return loadAny(key, (dm) -> dm.getStructureLoader().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/manager/IrisProject.java b/src/main/java/com/volmit/iris/manager/IrisProject.java index c871ab691..863df97d2 100644 --- a/src/main/java/com/volmit/iris/manager/IrisProject.java +++ b/src/main/java/com/volmit/iris/manager/IrisProject.java @@ -281,7 +281,6 @@ public class IrisProject schemas.put(getSchemaEntry(IrisBiome.class, dm, "/biomes/*.json")); schemas.put(getSchemaEntry(IrisRegion.class, dm, "/regions/*.json")); schemas.put(getSchemaEntry(IrisGenerator.class,dm, "/generators/*.json")); - schemas.put(getSchemaEntry(IrisStructure.class, dm, "/structures/*.json")); schemas.put(getSchemaEntry(IrisJigsawPiece.class, dm, "/jigsaw-pieces/*.json")); schemas.put(getSchemaEntry(IrisJigsawPool.class, dm, "/jigsaw-pools/*.json")); schemas.put(getSchemaEntry(IrisJigsawStructure.class, dm, "/jigsaw-structures/*.json")); @@ -315,7 +314,6 @@ public class IrisProject KSet regions = new KSet<>(); KSet biomes = new KSet<>(); KSet entities = new KSet<>(); - KSet structures = new KSet<>(); KSet generators = new KSet<>(); KSet loot = new KSet<>(); KSet blocks = new KSet<>(); @@ -330,19 +328,11 @@ public class IrisProject 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)))); - regions.forEach((i) -> i.getStructures().forEach((j) -> structures.add(j.getStructure(null)))); - biomes.forEach((i) -> i.getStructures().forEach((j) -> structures.add(j.getStructure(null)))); regions.forEach((r) -> r.getLoot().getTables().forEach((i) -> loot.add(dm.getLootLoader().load(i)))); biomes.forEach((r) -> r.getLoot().getTables().forEach((i) -> loot.add(dm.getLootLoader().load(i)))); - structures.forEach((r) -> r.getLoot().getTables().forEach((i) -> loot.add(dm.getLootLoader().load(i)))); - structures.forEach((b) -> b.getTiles().forEach((r) -> r.getLoot().getTables().forEach((i) -> loot.add(dm.getLootLoader().load(i))))); - structures.forEach((r) -> r.getEntitySpawnOverrides().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity())))); - structures.forEach((s) -> s.getTiles().forEach((r) -> r.getEntitySpawnOverrides().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity()))))); biomes.forEach((r) -> r.getEntitySpawnOverrides().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity())))); 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()))); - structures.forEach((r) -> r.getEntityInitialSpawns().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity())))); - structures.forEach((s) -> s.getTiles().forEach((r) -> r.getEntityInitialSpawns().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity()))))); biomes.forEach((r) -> r.getEntityInitialSpawns().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity())))); 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()))); @@ -352,31 +342,6 @@ public class IrisProject StringBuilder c = new StringBuilder(); sender.sendMessage("Serializing Objects"); - for(IrisStructure i : structures) - { - for(IrisStructureTile j : i.getTiles()) - { - b.append(j.hashCode()); - KList newNames = new KList<>(); - - for(String k : j.getObjects()) - { - if(renameObjects.containsKey(k)) - { - newNames.add(renameObjects.get(k)); - continue; - } - - String name = !obfuscate ? k : UUID.randomUUID().toString().replaceAll("-", ""); - b.append(name); - newNames.add(name); - renameObjects.put(k, name); - } - - j.setObjects(newNames); - } - } - for(IrisBiome i : biomes) { for(IrisObjectPlacement j : i.getObjects()) @@ -455,29 +420,6 @@ public class IrisProject } }))); - structures.forEach((i) -> i.getTiles().forEach((j) -> j.getObjects().forEach((k) -> - { - try - { - File f = dm.getObjectLoader().findFile(lookupObjects.get(k).get(0)); - IO.copyFile(f, new File(folder, "objects/" + k + ".iob")); - gb.append(IO.hash(f)); - ggg.set(ggg.get() + 1); - - if(cl.flip()) - { - int g = ggg.get(); - ggg.set(0); - sender.sendMessage("Wrote another " + g + " Objects"); - } - } - - catch(Throwable e) - { - - } - }))); - dimension.getMutations().forEach((i) -> i.getObjects().forEach((j) -> j.getPlace().forEach((k) -> { try @@ -537,13 +479,6 @@ public class IrisProject b.append(IO.hash(a)); } - for(IrisStructure i : structures) - { - a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); - IO.writeAll(new File(folder, "structures/" + i.getLoadKey() + ".json"), a); - b.append(IO.hash(a)); - } - for(IrisBiome i : biomes) { a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); diff --git a/src/main/java/com/volmit/iris/manager/SchemaBuilder.java b/src/main/java/com/volmit/iris/manager/SchemaBuilder.java index 63239ad98..44be945d8 100644 --- a/src/main/java/com/volmit/iris/manager/SchemaBuilder.java +++ b/src/main/java/com/volmit/iris/manager/SchemaBuilder.java @@ -366,22 +366,6 @@ public class SchemaBuilder } - else if(k.isAnnotationPresent(RegistryListStructure.class)) - { - String key = "enum-reg-structure-tileset"; - - if(!definitions.containsKey(key)) - { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getStructureLoader().getPossibleKeys())); - definitions.put(key, j); - } - - fancyType = "Iris Structure Tileset"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Structure Tileset (use ctrl+space for auto complete!)"); - } - else if(k.isAnnotationPresent(RegistryListJigsawPiece.class)) { String key = "enum-reg-structure-piece"; @@ -795,24 +779,6 @@ public class SchemaBuilder description.add(SYMBOL_TYPE__N + " Must be a valid Region (use ctrl+space for auto complete!)"); } - else if(k.isAnnotationPresent(RegistryListStructure.class)) - { - fancyType = "List of Iris Structure Tilesets"; - String key = "enum-reg-structure-tileset"; - - if(!definitions.containsKey(key)) - { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getStructureLoader().getPossibleKeys())); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Structure Tileset (use ctrl+space for auto complete!)"); - } - else if(k.isAnnotationPresent(RegistryListJigsawPiece.class)) { fancyType = "List of Iris Jigsaw Pieces"; diff --git a/src/main/java/com/volmit/iris/manager/StructureManager.java b/src/main/java/com/volmit/iris/manager/StructureManager.java deleted file mode 100644 index 16cd3a8b1..000000000 --- a/src/main/java/com/volmit/iris/manager/StructureManager.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.volmit.iris.manager; - -import org.bukkit.entity.Player; - -import com.volmit.iris.manager.structure.StructureTemplate; -import com.volmit.iris.util.KList; - -public class StructureManager -{ - private KList openEditors; - - public StructureManager() - { - this.openEditors = new KList<>(); - } - - public void closeall() - { - for(StructureTemplate i : openEditors.copy()) - { - i.close(); - } - } - - public void open(StructureTemplate t) - { - for(StructureTemplate i : openEditors.copy()) - { - if(t.getWorker().equals(i.getWorker())) - { - i.close(); - } - } - - openEditors.add(t); - } - - public void remove(StructureTemplate s) - { - openEditors.remove(s); - } - - public StructureTemplate get(Player p) - { - for(StructureTemplate i : openEditors) - { - if(i.getWorker().equals(p)) - { - return i; - } - } - - return null; - } -} diff --git a/src/main/java/com/volmit/iris/manager/command/CommandIris.java b/src/main/java/com/volmit/iris/manager/command/CommandIris.java index b132d67e9..08af9100f 100644 --- a/src/main/java/com/volmit/iris/manager/command/CommandIris.java +++ b/src/main/java/com/volmit/iris/manager/command/CommandIris.java @@ -20,9 +20,6 @@ public class CommandIris extends MortarCommand @Command private CommandIrisJigsaw jigsaw; - @Command - private CommandIrisStructure structure; - @Command private CommandIrisObject object; diff --git a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructure.java b/src/main/java/com/volmit/iris/manager/command/CommandIrisStructure.java deleted file mode 100644 index 21843960b..000000000 --- a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructure.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.volmit.iris.manager.command; - -import com.volmit.iris.Iris; -import com.volmit.iris.IrisSettings; -import com.volmit.iris.util.Command; -import com.volmit.iris.util.KList; -import com.volmit.iris.util.MortarCommand; -import com.volmit.iris.util.MortarSender; - -public class CommandIrisStructure extends MortarCommand -{ - @Command - private CommandIrisStructureCreate create; - - @Command - private CommandIrisStructureOpen open; - - @Command - private CommandIrisStructureSave save; - - @Command - private CommandIrisStructureMove more; - - @Command - private CommandIrisStructureExpand expand; - - @Command - private CommandIrisStructureVariants variants; - - @Command - private CommandIrisStructureClose close; - - public CommandIrisStructure() - { - super("structure", "struct", "str"); - requiresPermission(Iris.perm); - setCategory("Structure"); - setDescription("Structure Commands"); - } - - @Override - public void addTabOptions(MortarSender sender, String[] args, KList list) { - - } - - @Override - public boolean handle(MortarSender sender, String[] args) - { - if(!IrisSettings.get().isStudio()) - { - sender.sendMessage("To use Iris Studio Structures, please enable studio in Iris/settings.json"); - return true; - } - - sender.sendMessage("Iris Structure Commands"); - printHelp(sender); - sender.sendMessage("Note: This is a Procedural Structure creator,"); - sender.sendMessage("not an object creator, see '/iris object'."); - return true; - } - - @Override - protected String getArgsUsage() - { - return "[subcommand]"; - } -} diff --git a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureClose.java b/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureClose.java deleted file mode 100644 index ff67ac11c..000000000 --- a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureClose.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.volmit.iris.manager.command; - -import com.volmit.iris.util.KList; -import org.bukkit.entity.Player; - -import com.volmit.iris.Iris; -import com.volmit.iris.IrisSettings; -import com.volmit.iris.manager.structure.StructureTemplate; -import com.volmit.iris.util.MortarCommand; -import com.volmit.iris.util.MortarSender; - -public class CommandIrisStructureClose extends MortarCommand -{ - public CommandIrisStructureClose() - { - super("close", "x"); - requiresPermission(Iris.perm); - setCategory("Structure"); - setDescription("Close a structure"); - } - - @Override - public void addTabOptions(MortarSender sender, String[] args, KList list) { - - } - - @Override - public boolean handle(MortarSender sender, String[] args) - { - if(!IrisSettings.get().isStudio()) - { - sender.sendMessage("To use Iris Studio Structures, please enable studio in Iris/settings.json"); - return true; - } - - if(!sender.isPlayer()) - { - sender.sendMessage("You don't have a wand"); - return true; - } - - Player p = sender.player(); - StructureTemplate m = Iris.struct.get(p); - - if(m == null) - { - sender.sendMessage("You do not have an open structure"); - return true; - } - - m.close(); - sender.sendMessage("Saved & Closed!"); - - return true; - } - - @Override - protected String getArgsUsage() - { - return ""; - } -} diff --git a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureCreate.java b/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureCreate.java deleted file mode 100644 index ef4f77e72..000000000 --- a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureCreate.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.volmit.iris.manager.command; - -import com.volmit.iris.util.KList; -import org.bukkit.entity.Player; - -import com.volmit.iris.Iris; -import com.volmit.iris.IrisSettings; -import com.volmit.iris.manager.structure.StructureTemplate; -import com.volmit.iris.util.MortarCommand; -import com.volmit.iris.util.MortarSender; - -public class CommandIrisStructureCreate extends MortarCommand -{ - public CommandIrisStructureCreate() - { - super("new", "create", "+"); - requiresPermission(Iris.perm); - setCategory("Structure"); - setDescription("Create a structure"); - } - - @Override - public void addTabOptions(MortarSender sender, String[] args, KList list) { - - } - - @Override - public boolean handle(MortarSender sender, String[] args) { - if (!IrisSettings.get().isStudio()) { - sender.sendMessage("To use Iris Studio Structures, please enable studio in Iris/settings.json"); - return true; - } - - if (!sender.isPlayer()) { - sender.sendMessage("You cannot run this from console"); - return true; - } - - Player p = sender.player(); - - boolean d3 = false; - int width; - int height; - - - if (args.length == 0){ - sender.sendMessage("Please specify the name of the object you wish to create"); - return true; - } else if (args.length == 1){ - sender.sendMessage("Please specify the name of the dimension you are in"); - return true; - } else if (args.length == 2){ - sender.sendMessage("No width and height specified. Taking defaults (5 and 5)"); - width = 5; - height = 5; - } else if (args.length == 3){ - if (args[2].equalsIgnoreCase("-3d")) - { - sender.sendMessage("No width and height specified. Taking defaults (5 and 5)"); - width = 5; - height = 5; - d3 = true; - } else { - sender.sendMessage("No height specified, taking width as height"); - width = Integer.parseInt(args[2]); - height = Integer.parseInt(args[2]); - } - } else if (args.length == 4){ - width = Integer.parseInt(args[2]); - - if (args[3].equalsIgnoreCase("-3d")) - { - sender.sendMessage("No height specified, taking width as height"); - height = Integer.parseInt(args[2]); - } else { - height = Integer.parseInt(args[3]); - } - } else { - for (String i : args){ - if (i.equalsIgnoreCase("-3d")){ - d3 = true; - } - } - width = Integer.parseInt(args[2]); - height = Integer.parseInt(args[3]); - } - - if (width % 2 == 0){ - sender.sendMessage("Width is an even number. Adding one"); - width += width % 2 == 0 ? 1 : 0; - } - - sender.sendMessage("Creating new Structure"); - new StructureTemplate(args[0], args[1], p, p.getLocation(), 5, width, height, d3); - - return true; - } - - @Override - protected String getArgsUsage() - { - return " [-3d]"; - } -} diff --git a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureExpand.java b/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureExpand.java deleted file mode 100644 index 48d95bddd..000000000 --- a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureExpand.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.volmit.iris.manager.command; - -import com.volmit.iris.util.KList; -import org.bukkit.entity.Player; - -import com.volmit.iris.Iris; -import com.volmit.iris.IrisSettings; -import com.volmit.iris.manager.structure.StructureTemplate; -import com.volmit.iris.util.MortarCommand; -import com.volmit.iris.util.MortarSender; - -public class CommandIrisStructureExpand extends MortarCommand -{ - public CommandIrisStructureExpand() - { - super("expand", "++"); - requiresPermission(Iris.perm); - setCategory("Structure"); - setDescription("Expand out more of the structure"); - } - - @Override - public void addTabOptions(MortarSender sender, String[] args, KList list) { - - } - - @Override - public boolean handle(MortarSender sender, String[] args) - { - if(!IrisSettings.get().isStudio()) - { - sender.sendMessage("To use Iris Studio Structures, please enable studio in Iris/settings.json"); - return true; - } - - if(!sender.isPlayer()) - { - sender.sendMessage("You don't have a wand"); - return true; - } - - Player p = sender.player(); - StructureTemplate m = Iris.struct.get(p); - - if(m == null) - { - sender.sendMessage("You do not have an open structure"); - return true; - } - - m.expand(); - sender.sendMessage("Loading More!"); - - return true; - } - - @Override - protected String getArgsUsage() - { - return ""; - } -} diff --git a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureMove.java b/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureMove.java deleted file mode 100644 index faea6f519..000000000 --- a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureMove.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.volmit.iris.manager.command; - -import com.volmit.iris.util.KList; -import org.bukkit.entity.Player; - -import com.volmit.iris.Iris; -import com.volmit.iris.IrisSettings; -import com.volmit.iris.manager.structure.StructureTemplate; -import com.volmit.iris.util.MortarCommand; -import com.volmit.iris.util.MortarSender; - -public class CommandIrisStructureMove extends MortarCommand -{ - public CommandIrisStructureMove() - { - super("move", "here"); - requiresPermission(Iris.perm); - setCategory("Structure"); - setDescription("Load more of the structure"); - } - - @Override - public void addTabOptions(MortarSender sender, String[] args, KList list) { - - } - - @Override - public boolean handle(MortarSender sender, String[] args) - { - if(!IrisSettings.get().isStudio()) - { - sender.sendMessage("To use Iris Studio Structures, please enable studio in Iris/settings.json"); - return true; - } - - if(!sender.isPlayer()) - { - sender.sendMessage("You don't have a wand"); - return true; - } - - Player p = sender.player(); - StructureTemplate m = Iris.struct.get(p); - - if(m == null) - { - sender.sendMessage("You do not have an open structure"); - return true; - } - - m.more(); - sender.sendMessage("Moving Structure Builder!"); - - return true; - } - - @Override - protected String getArgsUsage() - { - return ""; - } -} diff --git a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureOpen.java b/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureOpen.java deleted file mode 100644 index 991733410..000000000 --- a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureOpen.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.volmit.iris.manager.command; - -import com.volmit.iris.manager.IrisDataManager; -import com.volmit.iris.util.KList; -import org.bukkit.entity.Player; - -import com.volmit.iris.Iris; -import com.volmit.iris.IrisSettings; -import com.volmit.iris.object.IrisStructure; -import com.volmit.iris.manager.structure.StructureTemplate; -import com.volmit.iris.util.MortarCommand; -import com.volmit.iris.util.MortarSender; - -public class CommandIrisStructureOpen extends MortarCommand -{ - public CommandIrisStructureOpen() - { - super("load", "open", "o"); - requiresPermission(Iris.perm); - setCategory("Structure"); - setDescription("Open an existing structure"); - } - - @Override - public void addTabOptions(MortarSender sender, String[] args, KList list) { - - } - - @Override - public boolean handle(MortarSender sender, String[] args) - { - if(!IrisSettings.get().isStudio()) - { - sender.sendMessage("To use Iris Studio Structures, please enable studio in Iris/settings.json"); - return true; - } - - if(!sender.isPlayer()) - { - sender.sendMessage("You don't have a wand"); - return true; - } - - if(args.length == 0){ - sender.sendMessage("Please specify the structure you wish to load"); - return true; - } - - Player p = sender.player(); - - IrisStructure structure = IrisDataManager.loadAnyStructure(args[0]); - - if(structure == null) - { - sender.sendMessage("Can't find " + args[0]); - return true; - } - - String dimensionGuess = structure.getLoadFile().getParentFile().getParentFile().getName(); - new StructureTemplate(structure.getName(), dimensionGuess, p, p.getLocation(), 9, structure.getGridSize(), structure.getGridHeight(), structure.getMaxLayers() > 1).loadStructures(structure); - - return true; - } - - @Override - protected String getArgsUsage() - { - return ""; - } -} diff --git a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureSave.java b/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureSave.java deleted file mode 100644 index 89bc53ff6..000000000 --- a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureSave.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.volmit.iris.manager.command; - -import com.volmit.iris.util.KList; -import org.bukkit.entity.Player; - -import com.volmit.iris.Iris; -import com.volmit.iris.IrisSettings; -import com.volmit.iris.manager.structure.StructureTemplate; -import com.volmit.iris.util.MortarCommand; -import com.volmit.iris.util.MortarSender; - -public class CommandIrisStructureSave extends MortarCommand -{ - public CommandIrisStructureSave() - { - super("save", "s"); - requiresPermission(Iris.perm); - setCategory("Structure"); - setDescription("Save a structure"); - } - - @Override - public void addTabOptions(MortarSender sender, String[] args, KList list) { - - } - - @Override - public boolean handle(MortarSender sender, String[] args) - { - if(!IrisSettings.get().isStudio()) - { - sender.sendMessage("To use Iris Studio Structures, please enable studio in Iris/settings.json"); - return true; - } - - if(!sender.isPlayer()) - { - sender.sendMessage("You don't have a wand"); - return true; - } - - Player p = sender.player(); - StructureTemplate m = Iris.struct.get(p); - - if(m == null) - { - sender.sendMessage("You do not have an open structure"); - return true; - } - - m.saveStructure(); - sender.sendMessage("Saved!"); - - return true; - } - - @Override - protected String getArgsUsage() - { - return ""; - } -} diff --git a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureVariants.java b/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureVariants.java deleted file mode 100644 index 5cbaa10a5..000000000 --- a/src/main/java/com/volmit/iris/manager/command/CommandIrisStructureVariants.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.volmit.iris.manager.command; - -import com.volmit.iris.util.KList; -import org.bukkit.entity.Player; - -import com.volmit.iris.Iris; -import com.volmit.iris.IrisSettings; -import com.volmit.iris.util.MortarCommand; -import com.volmit.iris.util.MortarSender; - -public class CommandIrisStructureVariants extends MortarCommand -{ - public CommandIrisStructureVariants() - { - super("variants", "var", "v"); - requiresPermission(Iris.perm); - setCategory("Structure"); - setDescription("Change or add variants in tile looking at"); - } - - @Override - public void addTabOptions(MortarSender sender, String[] args, KList list) { - - } - - @Override - public boolean handle(MortarSender sender, String[] args) - { - if(!IrisSettings.get().isStudio()) - { - sender.sendMessage("To use Iris Studio Structures, please enable studio in Iris/settings.json"); - return true; - } - - if(!sender.isPlayer()) - { - sender.sendMessage("You don't have a wand"); - return true; - } - - Player p = sender.player(); - - try - { - Iris.struct.get(p).openVariants(); - } - - catch(Throwable e) - { - sender.sendMessage("You do not have an open structure"); - } - - return true; - } - - @Override - protected String getArgsUsage() - { - return ""; - } -} diff --git a/src/main/java/com/volmit/iris/manager/link/MultiverseCoreLink.java b/src/main/java/com/volmit/iris/manager/link/MultiverseCoreLink.java index 656f7f9b1..c0e714dab 100644 --- a/src/main/java/com/volmit/iris/manager/link/MultiverseCoreLink.java +++ b/src/main/java/com/volmit/iris/manager/link/MultiverseCoreLink.java @@ -34,7 +34,7 @@ public class MultiverseCoreLink Method m = mvWorldManager.getClass().getDeclaredMethod("addWorld", String.class, World.Environment.class, String.class, WorldType.class, Boolean.class, String.class, boolean.class); - boolean b = (boolean) m.invoke(mvWorldManager, worldName, dim.getEnvironment(), seed, WorldType.NORMAL, dim.isVanillaStructures(), "Iris", false); + boolean b = (boolean) m.invoke(mvWorldManager, worldName, dim.getEnvironment(), seed, WorldType.NORMAL, false, "Iris", false); saveConfig(); return b; } diff --git a/src/main/java/com/volmit/iris/manager/structure/StructureTemplate.java b/src/main/java/com/volmit/iris/manager/structure/StructureTemplate.java deleted file mode 100644 index a8b829f9f..000000000 --- a/src/main/java/com/volmit/iris/manager/structure/StructureTemplate.java +++ /dev/null @@ -1,1002 +0,0 @@ -package com.volmit.iris.manager.structure; - -import com.google.gson.Gson; -import com.volmit.iris.Iris; -import com.volmit.iris.generator.noise.CNG; -import com.volmit.iris.object.*; -import com.volmit.iris.util.*; -import lombok.Data; -import org.bukkit.*; -import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.*; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.util.BlockVector; - -import java.io.File; -import java.util.Iterator; - -@Data -public class StructureTemplate implements Listener, IObjectPlacer -{ - private int w; - private int h; - private boolean use3d; - private IrisStructure structure; - private RNG rng; - private int size; - private Location center; - private ChronoLatch u = new ChronoLatch(50); - private World world; - private static final BlockData STONE = B.get("STONE"); - private static final BlockData RED = B.get("RED_STAINED_GLASS"); - private static final BlockData GREEN = B.get("LIME_STAINED_GLASS"); - private int task; - private ChronoLatch dirtyLatch; - private ChronoLatch gLatch; - private Location focus; - private Player worker; - private KMap updates = new KMap<>(); - private File folder; - private CNG variants; - private boolean quiet = true; - private KMap forceVariant = new KMap<>(); - - public StructureTemplate(String name, String dimension, Player worker, Location c, int size, int w, int h, boolean use3d) - { - this.worker = worker; - rng = new RNG(); - variants = NoiseStyle.STATIC.create(rng.nextParallelRNG(397878)); - folder = Iris.proj.getWorkspaceFolder(dimension); - gLatch = new ChronoLatch(250); - focus = center; - dirtyLatch = new ChronoLatch(250); - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::tick, 0, 0); - this.world = c.getWorld(); - this.center = c.clone(); - this.size = size; - this.use3d = use3d; - this.w = w; - this.h = h; - Iris.instance.registerListener(this); - structure = new IrisStructure(); - structure.setGridSize(w); - structure.setGridHeight(h); - structure.setMaxLayers(use3d ? size : 1); - structure.setBore(true); - structure.setLoadKey(name); - structure.setName(Form.capitalizeWords(name.replaceAll("\\Q-\\E", " "))); - structure.setWallChance(0.35); - defineStructures(); - regenerate(); - Iris.struct.open(this); - } - - public void saveStructure() - { - try - { - File structureFile = new File(folder, "structures/" + structure.getLoadKey() + ".json"); - - for(IrisStructureTile i : structure.getTiles()) - { - for(IrisObject j : i.getForceObjects().v()) - { - File objectFile = new File(folder, "objects/structure/" + structure.getLoadKey() + "/" + j.getLoadKey() + ".iob"); - Iris.verbose("Saving " + objectFile.getPath()); - j.write(objectFile); - } - } - - Iris.verbose("Saving " + structureFile.getPath()); - IO.writeAll(structureFile, new JSONObject(new Gson().toJson(structure)).toString(4)); - } - - catch(Throwable e) - { - e.printStackTrace(); - } - } - - @EventHandler - public void on(PlayerMoveEvent e) - { - if(!e.getTo().getWorld().equals(getCenter().getWorld())) - { - e.getPlayer().sendMessage(Iris.instance.getTag() + " Saving open structure. Use /iris str load " + structure.getLoadKey() + " to re-open."); - close(); - return; - } - - if(e.getTo().distanceSquared(getCenter()) > Math.pow((size * w * 5), 2)) - { - e.getPlayer().sendMessage(Iris.instance.getTag() + " Saving open structure. Use /iris str load " + structure.getLoadKey() + " to re-open."); - close(); - } - } - - public void loadStructures(IrisStructure input) - { - Iris.info("Loading existing structure"); - - // TODO load input properties - - for(IrisStructureTile i : structure.getTiles().copy()) - { - String realType = i.getForceObjects().get(1).getLoadKey().replaceAll("\\Q-1\\E", ""); - - for(IrisStructureTile j : input.getTiles()) - { - if(j.hashFace() == i.hashFace()) - { - Iris.verbose("Found matching face configuration: " + j.hashFace()); - structure.getTiles().remove(i); - IrisStructureTile hijacked = new IrisStructureTile(); - hijacked.setCeiling(j.getCeiling()); - hijacked.setFloor(j.getFloor()); - hijacked.setNorth(j.getNorth()); - hijacked.setSouth(j.getSouth()); - hijacked.setEast(j.getEast()); - hijacked.setWest(j.getWest()); - - for(String k : j.getObjects()) - { - int v = hijacked.getForceObjects().size() + 1; - IrisObject o = input.getLoader().getObjectLoader().load(k).copy(); - String b = o.getLoadKey(); - o.setLoadKey(realType + "-" + v); - - if(b != null && !b.equals(o.getLoadKey())) - { - Iris.warn("Loading Object " + b + " as " + o.getLoadKey() + " (not deleting the old file)"); - } - - hijacked.getForceObjects().put(v, o); - hijacked.getObjects().add("structure/" + this.structure.getLoadKey() + "/" + o.getLoadKey()); - - } - - structure.getTiles().add(hijacked); - break; - } - } - } - - regenerate(); - } - - public void openVariants() - { - try - { - Location m = worker.getTargetBlockExact(64).getLocation(); - - if(isWithinBounds(m)) - { - focus = m.clone(); - Cuboid b = getTileBounds(m); - Location center = b.getCenter(); - TileResult r = structure.getTile(rng, center.getX(), center.getY(), center.getZ()); - openVariants(r.getTile(), b); - return; - } - } - - catch(Throwable ef) - { - ef.printStackTrace(); - } - - worker.sendMessage("Look at a tile to configure variants."); - } - - public void openVariants(IrisStructureTile t, Cuboid at) - { - int var = getVariant(at, t); - Window w = new UIWindow(worker); - w.setTitle("Variants"); - w.setDecorator(new UIStaticDecorator(new UIElement("dec").setMaterial(new MaterialBlock(Material.BLACK_STAINED_GLASS_PANE)))); - WindowResolution r = WindowResolution.W5_H1; - w.setResolution(r); - - if(t.getForceObjects().size() > 4) - { - r = WindowResolution.W3_H3; - w.setResolution(r); - } - - if(t.getForceObjects().size() > 8) - { - r = WindowResolution.W9_H6; - w.setResolution(r); - w.setViewportHeight((int) Math.ceil((double) (t.getForceObjects().size() + 1) / 9D)); - } - int m = 0; - - UIElement ea = new UIElement("add"); - ea.setEnchanted(true); - ea.setMaterial(new MaterialBlock(Material.EMERALD)); - ea.setName("New Variant from Current Tile"); - - ea.getLore().add("- Left Click to copy current variant into a new variant"); - ea.onLeftClick((ee) -> - { - w.close(); - createVariantCopy(t, at); - }); - - w.setElement(w.getLayoutPosition(m), w.getLayoutRow(m), ea); - m++; - - for(Integer i : t.getForceObjects().k()) - { - UIElement e = new UIElement("var-" + i); - e.setEnchanted(var == i); - e.setCount(i); - e.setMaterial(new MaterialBlock(var == i ? Material.ENDER_EYE : Material.ENDER_PEARL)); - e.setName(t.getForceObjects().get(i).getLoadKey()); - - if(var != i) - { - e.getLore().add("- Left Click to select this variant"); - e.onLeftClick((ee) -> - { - w.close(); - switchVariant(t, at, i); - }); - } - - w.setElement(w.getLayoutPosition(m), w.getLayoutRow(m), e); - m++; - } - - w.open(); - } - - public void deleteVariant(IrisStructureTile t, Cuboid at) - { - - } - - public void switchVariant(IrisStructureTile t, Cuboid at, int var) - { - forceVariant.put(at.getCenter(), var); - updateTile(at); - } - - public void createVariantCopy(IrisStructureTile t, Cuboid at) - { - int variant = getVariant(at, t); - IrisObject origin = t.getForceObjects().get(variant); - IrisObject object = new IrisObject(origin.getW(), origin.getH(), origin.getD()); - object.setCenter(origin.getCenter().clone()); - - for(BlockVector i : origin.getBlocks().keySet()) - { - object.getBlocks().put(i.clone(), origin.getBlocks().get(i).clone()); - } - - int nv = t.getForceObjects().size() + 1; - object.setLoadKey(origin.getLoadKey().replaceAll("\\Q-" + variant + "\\E", "-" + nv)); - t.getObjects().add("structure/" + this.structure.getLoadKey() + "/" + object.getLoadKey()); - t.getForceObjects().put(nv, object); - forceVariant.put(at.getCenter(), nv); - regenerate(); - } - - public void setWallChance(double w) - { - structure.setWallChance(w); - regenerate(); - } - - public void regenerate() - { - rng = new RNG(); - variants = NoiseStyle.STATIC.create(rng.nextParallelRNG(397878)); - updateTiles(center, null, null); - } - - public void queue(Location l, Runnable r) - { - if(updates.containsKey(l)) - { - return; - } - - updates.put(l, r); - } - - public void tick() - { - try - { - Location m = worker.getTargetBlockExact(64).getLocation(); - - if(isWithinBounds(m) && u.flip()) - { - focus = m.clone(); - Cuboid b = getTileBounds(m); - if(gLatch.flip()) - { - highlightTile(b); - } - } - } - - catch(Throwable ef) - { - - } - - if(dirtyLatch.couldFlip()) - { - updateAll(); - } - } - - public void updateAll() - { - while(updates.size() > 0) - { - runClosestTo(); - } - } - - private void runClosestTo() - { - if(focus == null) - { - focus = center; - } - - Location g = null; - double v = Double.MAX_VALUE; - - for(Location l : updates.keySet()) - { - double d = l.distanceSquared(focus); - if(d < v) - { - v = d; - g = l; - } - } - - updates.remove(g).run(); - } - - private void mod(Location l) - { - mod(l, true); - } - - private void mod(Location l, boolean u) - { - if(!isWithinBounds(l)) - { - return; - } - - focus = l.clone(); - Cuboid cuboid = getTileBounds(l); - Location center = cuboid.getCenter(); - TileResult r = structure.getTile(rng, center.getX(), center.getY(), center.getZ()); - - if(r == null) - { - return; - } - - IrisObject o = r.getTile().getForceObjects().get(getVariant(getTileBounds(l), r.getTile())); - double yrot = r.getPlacement().getRotation().getYAxis().getMax(); - double trot = -yrot; - r.getPlacement().getRotation().getYAxis().setMin(trot); - r.getPlacement().getRotation().getYAxis().setMax(trot); - - Location min = cuboid.getLowerNE(); - Iterator bit = cuboid.iterator(); - - while(bit.hasNext()) - { - Block b = bit.next(); - Location loc = new Location(world, b.getX(), b.getY(), b.getZ()); - BlockVector v = loc.clone().subtract(min).subtract(o.getCenter()).toVector().toBlockVector(); - v = r.getPlacement().getRotation().rotate(v, 0, 0, 0); - BlockData next = r.getPlacement().getRotation().rotate(b.getBlockData(), 0, 0, 0); - - o.getBlocks().put(v, next); - } - - r.getPlacement().getRotation().getYAxis().setMin(yrot); - r.getPlacement().getRotation().getYAxis().setMax(yrot); - dirtyLatch.flipDown(); - updateTiles(l, r.getTile(), getTileBounds(l)); - } - - public void highlightTile(Cuboid b) - { - Iris.wand.draw(b, worker); - Location center = b.getCenter(); - TileResult r = structure.getTile(rng, center.getX(), center.getY(), center.getZ()); - worker.sendTitle("", C.GRAY + r.getTile().getForceObjects().get(getVariant(b, r.getTile())).getLoadKey() + " " + C.DARK_GRAY + r.getPlacement().getRotation().getYAxis().getMax() + "°", 0, 20, 40); - } - - public void updateTiles(Location from, IrisStructureTile tileType, Cuboid ignore) - { - Cuboid bounds = getBounds(); - - for(int i = bounds.getLowerX(); i < bounds.getUpperX(); i += w) - { - for(int j = bounds.getLowerZ(); j < bounds.getUpperZ(); j += w) - { - for(int hh = bounds.getLowerY(); hh < bounds.getUpperY(); hh += h) - { - Location l = new Location(world, i, hh, j); - - if(ignore != null && ignore.contains(l)) - { - continue; - } - - if(tileType != null) - { - Location center = getTileBounds(l).getCenter(); - TileResult r = structure.getTile(rng, center.getX(), center.getY(), center.getZ()); - - try - { - int v1 = getVariant(getTileBounds(l), r.getTile()); - int v2 = getVariant(getTileBounds(l), tileType); - if(r == null || !r.getTile().getForceObjects().get(v1).getLoadKey().equals( - - tileType.getForceObjects().get(v2) - - .getLoadKey())) - { - continue; - } - } - - catch(Throwable e) - { - - } - } - - if(isWithinBounds(l)) - { - queue(l, () -> updateTile(getTileBounds(l))); - } - } - } - } - } - - public void deleteTiles() - { - Cuboid bounds = getBounds(); - - for(int i = bounds.getLowerX(); i < bounds.getUpperX(); i += w) - { - for(int j = bounds.getLowerZ(); j < bounds.getUpperZ(); j += w) - { - for(int hh = bounds.getLowerY(); hh < bounds.getUpperY(); hh += h) - { - Location l = new Location(world, i, hh, j); - - if(isWithinBounds(l)) - { - Cuboid d = getTileBounds(l); - J.s(() -> deleteTile(d), RNG.r.i(0, 100)); - } - } - } - } - } - - public void deleteTile(Cuboid from) - { - Location center = from.getCenter(); - from.iterator().forEachRemaining((b) -> b.setType(Material.AIR, false)); - center.getWorld().playSound(center, Sound.BLOCK_ANCIENT_DEBRIS_BREAK, 1f, 0.1f); - center.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, center.getX(), center.getY(), center.getZ(), 1); - } - - public int getVariant(Cuboid c, IrisStructureTile t) - { - if(t.getForceObjects().size() == 1) - { - return t.getForceObjects().keys().nextElement(); - } - - if(forceVariant.containsKey(c.getCenter())) - { - return forceVariant.get(c.getCenter()); - } - - Location ce = c.getCenter(); - return variants.fit(t.getForceObjects().keypair(), ce.getBlockX(), ce.getBlockY(), ce.getBlockZ()).getK(); - } - - public void updateTile(Cuboid c) - { - Location center = c.getCenter(); - Location bottomCenter = c.getCenter(); - bottomCenter.setY(c.getLowerY()); - TileResult r = structure.getTile(rng, center.getX(), center.getY(), center.getZ()); - - if(r == null) - { - return; - } - - r.getTile().getForceObjects().get(getVariant(c, r.getTile())).place(bottomCenter.getBlockX(), bottomCenter.getBlockY(), bottomCenter.getBlockZ(), this, r.getPlacement(), rng, r.getStructure().getLoader()); - if(!quiet) - { - center.getWorld().playSound(center, Sound.ENTITY_SHULKER_BULLET_HIT, 1f, 1.6f); - center.getWorld().spawnParticle(Particle.FLASH, center.getX(), center.getY(), center.getZ(), 1); - } - } - - public boolean isWithinBounds(Location l) - { - return getBounds().contains(l); - } - - public void close() - { - worker.sendMessage(Iris.instance.getTag() + "Saving Structure: " + getStructure().getName()); - Iris.instance.unregisterListener(this); - Bukkit.getScheduler().cancelTask(task); - saveStructure(); - Iris.struct.remove(this); - deleteTiles(); - } - - public TileResult getTile(int x, int y, int z) - { - return structure.getTile(rng, x, y, z); - } - - public Cuboid getBounds() - { - return getBounds(center); - } - - public Cuboid getBounds(Location center) - { - // @NoArgsConstructor - return new Cuboid(getTileBounds(center.clone().add(((size / 2) * w) + 1, !use3d ? 0 : (((size / 2) * h) + 1), ((size / 2) * w) + 1)).getUpperSW(), getTileBounds(center.clone().subtract(((size / 2) * w) + 1, !use3d ? 0 : (((size / 2) * h) + 1), ((size / 2) * w) + 1)).getLowerNE()); - //@done - } - - public Cuboid getTileBounds(Location l) - { - // @NoArgsConstructor - return new Cuboid(new Location(l.getWorld(), Math.floorDiv(l.getBlockX(), w) * w, Math.floorDiv(l.getBlockY(), h) * h, Math.floorDiv(l.getBlockZ(), w) * w), new Location(l.getWorld(), ((Math.floorDiv(l.getBlockX(), w) + 1) * w) - 1, ((Math.floorDiv(l.getBlockY(), h) + 1) * h) - 1, ((Math.floorDiv(l.getBlockZ(), w) + 1) * w) - 1)); - //@done - } - - public IrisStructureTile tileFor(String name, StructureTileCondition f, StructureTileCondition c, StructureTileCondition n, StructureTileCondition e, StructureTileCondition w, StructureTileCondition s) - { - return tileFor(name, f, c, n, e, w, s, 1); - } - - public IrisStructureTile tileFor(String name, StructureTileCondition f, StructureTileCondition c, StructureTileCondition n, StructureTileCondition e, StructureTileCondition w, StructureTileCondition s, int variant) - { - IrisObject o = new IrisObject(this.w, this.h, this.w); - o.setLoadKey(name.toLowerCase().replaceAll("\\Q \\E", "-").trim() + "-" + variant); - IrisStructureTile t = new IrisStructureTile(); - t.getForceObjects().put(variant, o); - t.getObjects().add("structure/" + this.structure.getLoadKey() + "/" + o.getLoadKey()); - t.setFloor(f); - t.setCeiling(c); - t.setNorth(n); - t.setEast(e); - t.setSouth(s); - t.setWest(w); - - int minX = 0; - int maxX = this.w - 1; - int minZ = 0; - int maxZ = this.w - 1; - int minY = 0; - int maxY = this.h - 1; - - if(use3d) - { - if(f.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minX; i <= maxX; i++) - { - for(int j = minZ; j <= maxZ; j++) - { - o.setUnsigned(i, minY, j, STONE); - } - } - } - - if(c.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minX; i <= maxX; i++) - { - for(int j = minZ; j <= maxZ; j++) - { - o.setUnsigned(i, maxY, j, STONE); - } - } - } - - if(n.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minX; i <= maxX; i++) - { - for(int j = minY; j <= maxY; j++) - { - o.setUnsigned(i, j, minZ, STONE); - } - } - } - - if(s.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minX; i <= maxX; i++) - { - for(int j = minY; j <= maxY; j++) - { - o.setUnsigned(i, j, maxZ, STONE); - } - } - } - - if(w.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minZ; i <= maxZ; i++) - { - for(int j = minY; j <= maxY; j++) - { - o.setUnsigned(minX, j, i, STONE); - } - } - } - - if(e.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minZ; i <= maxZ; i++) - { - for(int j = minY; j <= maxY; j++) - { - o.setUnsigned(maxX, j, i, STONE); - } - } - } - } - - else - { - if(f.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minX; i <= maxX; i++) - { - for(int j = minZ; j <= maxZ; j++) - { - o.setUnsigned(i, minY, j, GREEN); - } - } - } - - if(c.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minX; i <= maxX; i++) - { - for(int j = minZ; j <= maxZ; j++) - { - o.setUnsigned(i, maxY, j, GREEN); - } - } - } - - if(n.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minX; i <= maxX; i++) - { - o.setUnsigned(i, minY, minZ, RED); - } - } - - if(s.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minX; i <= maxX; i++) - { - o.setUnsigned(i, minY, maxZ, RED); - } - } - - if(w.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minZ; i <= maxZ; i++) - { - o.setUnsigned(minX, minY, i, RED); - } - } - - if(e.equals(StructureTileCondition.REQUIRED)) - { - for(int i = minZ; i <= maxZ; i++) - { - o.setUnsigned(maxX, minY, i, RED); - } - } - } - - return t; - } - - @Override - public int getHighest(int x, int z) - { - return 0; - } - - @Override - public int getHighest(int x, int z, boolean ignoreFluid) - { - return 0; - } - - @Override - public void set(int x, int y, int z, BlockData d) - { - if(get(x, y, z).equals(d)) - { - return; - } - - Iris.edit.set(world, x, y, z, d); - } - - @Override - public BlockData get(int x, int y, int z) - { - return world.getBlockAt(x, y, z).getBlockData(); - } - - @Override - public boolean isPreventingDecay() - { - return true; - } - - @Override - public boolean isSolid(int x, int y, int z) - { - return get(x, y, z).getMaterial().isSolid(); - } - - @Override - public boolean isUnderwater(int x, int z) - { - return false; - } - - @Override - public int getFluidHeight() - { - return 0; - } - - private void defineStructures() - { - if(use3d) - { - // @NoArgsConstructor - structure.getTiles().add(tileFor("Cross Floor", StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("T-Connect Floor", StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Hall Floor", StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED)); - structure.getTiles().add(tileFor("Corner Floor", StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Room Floor", StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Walled Room Floor", StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED)); - - structure.getTiles().add(tileFor("Cross Ceiling", StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("T-Connect Ceiling", StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Hall Ceiling", StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED)); - structure.getTiles().add(tileFor("Corner Ceiling", StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Room Ceiling", StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Walled Room Ceiling", StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED)); - - structure.getTiles().add(tileFor("Cross Opening", StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("T-Connect Opening", StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Hall Opening", StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED)); - structure.getTiles().add(tileFor("Corner Opening", StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Room Opening", StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Walled Room Opening", StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED)); - - structure.getTiles().add(tileFor("Cross Encased", StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("T-Connect Encased", StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Hall Encased", StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED)); - structure.getTiles().add(tileFor("Corner Encased", StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Room Encased", StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Walled Room Encased", StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED)); - //@done - } - - else - { - // @NoArgsConstructor - structure.getTiles().add(tileFor("Cross", StructureTileCondition.REQUIRED, StructureTileCondition.AGNOSTIC, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("T-Connect", StructureTileCondition.REQUIRED, StructureTileCondition.AGNOSTIC, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Hall", StructureTileCondition.REQUIRED, StructureTileCondition.AGNOSTIC, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER, StructureTileCondition.REQUIRED)); - structure.getTiles().add(tileFor("Corner", StructureTileCondition.REQUIRED, StructureTileCondition.AGNOSTIC, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Room", StructureTileCondition.REQUIRED, StructureTileCondition.AGNOSTIC, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.NEVER)); - structure.getTiles().add(tileFor("Walled Room", StructureTileCondition.REQUIRED, StructureTileCondition.AGNOSTIC, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED, StructureTileCondition.REQUIRED)); - //@done - } - } - - @EventHandler - public void on(BlockBreakEvent e) - { - quiet = false; - mod(e.getBlock().getLocation(), false); - updateAll(); - quiet = true; - } - - @EventHandler - public void on(BlockIgniteEvent e) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> mod(e.getBlock().getLocation()), 5); - } - - @EventHandler - public void on(BlockFormEvent e) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> mod(e.getBlock().getLocation()), 5); - } - - @EventHandler - public void on(BlockFromToEvent e) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> mod(e.getBlock().getLocation()), 5); - } - - @EventHandler - public void on(BlockFadeEvent e) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> mod(e.getBlock().getLocation()), 5); - } - - @EventHandler - public void on(BlockPhysicsEvent e) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> mod(e.getBlock().getLocation()), 5); - } - - @EventHandler - public void on(BlockFertilizeEvent e) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> mod(e.getBlock().getLocation()), 5); - } - - @EventHandler - public void on(BlockGrowEvent e) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> mod(e.getBlock().getLocation()), 5); - } - - @EventHandler - public void on(BlockSpreadEvent e) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> mod(e.getBlock().getLocation()), 5); - } - - @EventHandler - public void on(BlockBurnEvent e) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> mod(e.getBlock().getLocation()), 5); - } - - @EventHandler - public void on(BlockCookEvent e) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> mod(e.getBlock().getLocation()), 5); - } - - @EventHandler - public void on(BlockPlaceEvent e) - { - quiet = false; - mod(e.getBlock().getLocation(), false); - updateAll(); - quiet = true; - } - - public void more() - { - Location center = worker.getLocation().clone(); - - if(!use3d) - { - center.setY(this.center.getY()); - } - - Cuboid bounds = getBounds(); - Cuboid newBounds = getBounds(center); - Cuboid total = bounds.getBoundingCuboid(newBounds); - - for(int i = bounds.getLowerX(); i < bounds.getUpperX(); i += w) - { - for(int j = bounds.getLowerZ(); j < bounds.getUpperZ(); j += w) - { - for(int hh = bounds.getLowerY(); hh < bounds.getUpperY(); hh += h) - { - Location l = new Location(world, i, hh, j); - if(!total.contains(l)) - { - continue; - } - boolean o = bounds.contains(l); - boolean n = newBounds.contains(l); - - if(o && !n) - { - deleteTile(getTileBounds(l)); - } - } - } - } - - this.center = center; - updateTiles(focus, null, null); - } - - public void expand() - { - Location center = worker.getLocation().clone(); - - if(!use3d) - { - center.setY(this.center.getY()); - } - - Cuboid bounds = getBounds(); - Cuboid newBounds = getBounds(center); - Cuboid total = bounds.getBoundingCuboid(newBounds); - - for(int i = bounds.getLowerX(); i < bounds.getUpperX(); i += w) - { - for(int j = bounds.getLowerZ(); j < bounds.getUpperZ(); j += w) - { - for(int hh = bounds.getLowerY(); hh < bounds.getUpperY(); hh += h) - { - Location l = new Location(world, i, hh, j); - if(!total.contains(l)) - { - continue; - } - boolean o = bounds.contains(l); - boolean n = newBounds.contains(l); - - if(o && !n) - { - deleteTile(getTileBounds(l)); - } - } - } - } - - size += 2; - this.center = center; - updateTiles(focus, null, null); - } - - @Override - public boolean isDebugSmartBore() - { - return false; - } -} diff --git a/src/main/java/com/volmit/iris/object/IrisStructure.java b/src/main/java/com/volmit/iris/object/IrisStructure.java deleted file mode 100644 index 3ce74beeb..000000000 --- a/src/main/java/com/volmit/iris/object/IrisStructure.java +++ /dev/null @@ -1,196 +0,0 @@ -package com.volmit.iris.object; - -import com.volmit.iris.scaffold.cache.AtomicCache; -import com.volmit.iris.generator.noise.CNG; -import com.volmit.iris.util.ArrayType; -import com.volmit.iris.util.BlockPosition; -import com.volmit.iris.util.Desc; -import com.volmit.iris.util.DontObfuscate; -import com.volmit.iris.util.KList; -import com.volmit.iris.util.MaxNumber; -import com.volmit.iris.util.MinNumber; -import com.volmit.iris.util.RNG; -import com.volmit.iris.util.Required; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@DontObfuscate -@Desc("Represents a structure in iris.") -@Data -@EqualsAndHashCode(callSuper = false) -public class IrisStructure extends IrisRegistrant -{ - - @MinNumber(2) - @Required - @DontObfuscate - @Desc("This is the human readable name for this structure. Such as Red Dungeon or Tropical Village.") - private String name = "A Structure Type"; - - @DontObfuscate - @Desc("Entity spawns to override or add to this structure") - @ArrayType(min = 1, type = IrisEntitySpawnOverride.class) - private KList entitySpawnOverrides = new KList<>(); - - @DontObfuscate - @Desc("Entity spawns during generation") - @ArrayType(min = 1, type = IrisEntityInitialSpawn.class) - private KList entityInitialSpawns = new KList<>(); - - @DontObfuscate - @Desc("Wall style noise") - private IrisGeneratorStyle wallStyle = NoiseStyle.STATIC.style(); - - @Desc("Setting underwater to true will waterlog blocks") - @DontObfuscate - private boolean underwater = false; - - @Desc("The max & min height any part of this structure can place at") - @DontObfuscate - private IrisObjectLimit clamp = new IrisObjectLimit(); - - @Desc("Setting bore to true will dig out blocks before placing tiles") - @DontObfuscate - private boolean bore = false; - - @Required - @MinNumber(3) - @MaxNumber(64) - @DontObfuscate - @Desc("This is the x and z size of each grid cell") - private int gridSize = 11; - - @DontObfuscate - @Desc("Reference loot tables in this area") - private IrisLootReference loot = new IrisLootReference(); - - @Required - @MinNumber(1) - @MaxNumber(255) - @DontObfuscate - @Desc("This is the y size of each grid cell") - private int gridHeight = 5; - - @MinNumber(1) - @MaxNumber(82) - @DontObfuscate - @Desc("This is the maximum layers iris will generate for (height cells)") - private int maxLayers = 1; - - @Required - @MinNumber(0) - @MaxNumber(1) - @DontObfuscate - @Desc("This is the wall chance. Higher values makes more rooms and less open halls") - private double wallChance = 0.25; - - @DontObfuscate - @Desc("Edges of tiles replace each other instead of having their own.") - private boolean mergeEdges = false; - - @Required - @ArrayType(min = 1, type = IrisStructureTile.class) - @DontObfuscate - @Desc("The tiles") - private KList tiles = new KList<>(); - - private final transient AtomicCache wallGenerator = new AtomicCache<>(); - - public TileResult getTile(RNG rng, double x, double y, double z) - { - KList walls = new KList<>(); - boolean floor = isWall(rng, x, y, z, StructureTileFace.DOWN); - boolean ceiling = isWall(rng, x, y, z, StructureTileFace.UP); - - if(isWall(rng, x, y, z, StructureTileFace.NORTH)) - { - walls.add(StructureTileFace.NORTH); - } - - if(isWall(rng, x, y, z, StructureTileFace.SOUTH)) - { - walls.add(StructureTileFace.SOUTH); - } - - if(isWall(rng, x, y, z, StructureTileFace.EAST)) - { - walls.add(StructureTileFace.EAST); - } - - if(isWall(rng, x, y, z, StructureTileFace.WEST)) - { - walls.add(StructureTileFace.WEST); - } - - int faces = walls.size() + (floor ? 1 : 0) + (ceiling ? +1 : 0); - int openings = 6 - faces; - int rt = 0; - - for(int cx = 0; cx < 4; cx++) - { - for(IrisStructureTile i : tiles) - { - if(i.likeAGlove(floor, ceiling, walls, faces, openings)) - { - return new TileResult(this, i, rt); - } - } - - if(cx < 3) - { - rotate(walls); - rt += 90; - } - } - - return null; - } - - public void rotate(KList faces) - { - for(int i = 0; i < faces.size(); i++) - { - faces.set(i, faces.get(i).rotate90CW()); - } - } - - public boolean isWall(RNG rng, double x, double y, double z, StructureTileFace face) - { - if((face == StructureTileFace.DOWN || face == StructureTileFace.UP) && maxLayers == 1) - { - return true; - } - - BlockPosition p = asTileHorizon(new BlockPosition((int) x, (int) y, (int) z), face); - return (getWallGenerator(rng).fitDouble(0, 1, p.getX(), p.getY(), p.getZ()) < getWallChance()); - } - - public int getTileHorizon(double v) - { - return (int) Math.floor(v / gridSize); - } - - public BlockPosition asTileHorizon(BlockPosition b, StructureTileFace face) - { - b.setX((int) (Math.floor((b.getX() * 2) / (gridSize)) + face.x())); - b.setY((int) (Math.floor((b.getY() * 2) / (gridHeight)) + face.y())); - b.setZ((int) (Math.floor((b.getZ() * 2) / (gridSize)) + face.z())); - return b; - } - - public CNG getWallGenerator(RNG rng) - { - return wallGenerator.aquire(() -> - { - RNG rngx = new RNG(228385999).nextParallelRNG((int) (name.hashCode() + gridHeight - gridSize + maxLayers + tiles.size())); - return wallStyle.create(rngx).scale(0.8); - }); - } -} diff --git a/src/main/java/com/volmit/iris/object/IrisStructurePlacement.java b/src/main/java/com/volmit/iris/object/IrisStructurePlacement.java deleted file mode 100644 index 0bef6628b..000000000 --- a/src/main/java/com/volmit/iris/object/IrisStructurePlacement.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.volmit.iris.object; - -import com.volmit.iris.scaffold.cache.AtomicCache; -import com.volmit.iris.generator.noise.CellGenerator; -import com.volmit.iris.scaffold.data.DataProvider; -import com.volmit.iris.util.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@Desc("Represents a structure placement") -@Data -public class IrisStructurePlacement -{ - - @RegistryListStructure - @Required - @DontObfuscate - @Desc("The structure tileset to use") - private String tileset = ""; - - @Required - @MinNumber(0.0001) - @DontObfuscate - @Desc("The structure chance zoom. Higher = bigger cells, further away") - private double zoom = 1D; - - @MinNumber(-1) - @MaxNumber(1) - @DontObfuscate - @Desc("The ratio. Lower values means cells can get closer to other cells. Negative values means make veins of structures") - private double ratio = 0.25D; - - @Required - @MinNumber(1) - @DontObfuscate - @Desc("The rarity for this structure") - private int rarity = 4; - - @MinNumber(-1) - @MaxNumber(255) - @DontObfuscate - @Desc("The height or -1 for surface") - private int height = -1; - - @MinNumber(0) - @DontObfuscate - @Desc("The chance cell shuffle (rougher edges)") - private double shuffle = 22; - - private final transient AtomicCache chanceCell = new AtomicCache<>(); - private final transient AtomicCache structure = new AtomicCache<>(); - private final transient AtomicCache config = new AtomicCache<>(); - - private IrisObjectPlacement getConfig() - { - return config.aquire(() -> - { - IrisObjectPlacement p = new IrisObjectPlacement(); - p.setWaterloggable(false); - return p; - }); - } - - public IrisObject load(DataProvider g, String s) - { - return g.getData().getObjectLoader().load(s); - } - - public int gridSize(DataProvider g) - { - return getStructure(g).getGridSize(); - } - - public int gridHeight(DataProvider g) - { - return getStructure(g).getGridHeight(); - } - - public IrisStructure getStructure(DataProvider g) - { - return structure.aquire(() -> g.getData().getStructureLoader().load(getTileset())); - } - - public CellGenerator getChanceGenerator(RNG g) - { - return chanceCell.aquire(() -> - { - CellGenerator chanceCell = new CellGenerator(g.nextParallelRNG(-72346).nextParallelRNG((height + 10000) * rarity)); - chanceCell.setCellScale(1D); - chanceCell.setShuffle(getShuffle()); - return chanceCell; - }); - } -} diff --git a/src/main/java/com/volmit/iris/object/IrisStructureTile.java b/src/main/java/com/volmit/iris/object/IrisStructureTile.java deleted file mode 100644 index a21ee30cf..000000000 --- a/src/main/java/com/volmit/iris/object/IrisStructureTile.java +++ /dev/null @@ -1,169 +0,0 @@ -package com.volmit.iris.object; - -import java.util.Objects; - -import com.volmit.iris.scaffold.cache.AtomicCache; -import com.volmit.iris.util.ArrayType; -import com.volmit.iris.util.Desc; -import com.volmit.iris.util.DontObfuscate; -import com.volmit.iris.util.KList; -import com.volmit.iris.util.KMap; -import com.volmit.iris.util.RegistryListObject; -import com.volmit.iris.util.Required; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@DontObfuscate -@Desc("Represents a structure tile") -@Data -@EqualsAndHashCode(callSuper = false) -public class IrisStructureTile -{ - - @DontObfuscate - @Desc("Reference loot tables in this area") - private IrisLootReference loot = new IrisLootReference(); - - @DontObfuscate - @Desc("Entity spawns to override or add to this structure tile") - @ArrayType(min = 1, type = IrisEntitySpawnOverride.class) - private KList entitySpawnOverrides = new KList<>(); - - @DontObfuscate - @Desc("Entity spawns during generation") - @ArrayType(min = 1, type = IrisEntityInitialSpawn.class) - private KList entityInitialSpawns = new KList<>(); - - @DontObfuscate - @Desc("The place mode for this tile") - private ObjectPlaceMode placeMode = ObjectPlaceMode.CENTER_HEIGHT; - - @Required - @DontObfuscate - @Desc("Is this structure allowed to place if there is supposed to be a ceiling?") - private StructureTileCondition ceiling = StructureTileCondition.AGNOSTIC; - - @Required - @DontObfuscate - @Desc("Is this structure allowed to place if there is supposed to be a floor?") - private StructureTileCondition floor = StructureTileCondition.REQUIRED; - - @Required - @DontObfuscate - @Desc("Is this structure allowed to place if there is supposed to be a north wall?") - private StructureTileCondition north = StructureTileCondition.AGNOSTIC; - - @Required - @DontObfuscate - @Desc("Is this structure allowed to place if there is supposed to be a south wall?") - private StructureTileCondition south = StructureTileCondition.AGNOSTIC; - - @Required - @DontObfuscate - @Desc("Is this structure allowed to place if there is supposed to be a east wall?") - private StructureTileCondition east = StructureTileCondition.AGNOSTIC; - - @Required - @DontObfuscate - @Desc("Is this structure allowed to place if there is supposed to be a west wall?") - private StructureTileCondition west = StructureTileCondition.AGNOSTIC; - - @RegistryListObject - @Required - @ArrayType(min = 1, type = String.class) - @DontObfuscate - @Desc("List of objects to place centered in this tile") - private KList objects = new KList<>(); - - @DontObfuscate - @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; - - @RegistryListObject - @ArrayType(min = 1, type = IrisRareObject.class) - @DontObfuscate - @Desc("List of objects to place centered in this tile but with rarity. These items only place some of the time so specify objects for common stuff too.") - private KList rareObjects = new KList<>(); - - private final transient KMap forceObjects = new KMap<>(); - private final transient AtomicCache minFaces = new AtomicCache<>(); - private final transient AtomicCache maxFaces = new AtomicCache<>(); - - public int hashFace() - { - return Objects.hash(ceiling, floor, south, north, east, west); - } - - public String toString() - { - return (ceiling.required() ? "C" : "") + (floor.required() ? "F" : "") + "| " + (north.required() ? "X" : "-") + (south.required() ? "X" : "-") + (east.required() ? "X" : "-") + (west.required() ? "X" : "-") + " |"; - } - - public boolean likeAGlove(boolean floor, boolean ceiling, KList walls, int faces, int openings) - { - // @NoArgsConstructor - - if((getFloor().required() && !floor) || (getCeiling().required() && !ceiling)) - { - return false; - } - - if((!getFloor().supported() && floor) || (!getCeiling().supported() && ceiling)) - { - return false; - } - - if(!fitsWalls(walls, faces, openings)) - { - return false; - } - - //@done - - return faces >= minFaces.aquire(() -> - { - int m = 0; - m += this.ceiling.required() ? 1 : 0; - m += this.floor.required() ? 1 : 0; - m += this.north.required() ? 1 : 0; - m += this.south.required() ? 1 : 0; - m += this.east.required() ? 1 : 0; - m += this.west.required() ? 1 : 0; - return m; - }) && faces <= maxFaces.aquire(() -> - { - int m = 0; - m += this.ceiling.supported() ? 1 : 0; - m += this.floor.supported() ? 1 : 0; - m += this.north.supported() ? 1 : 0; - m += this.south.supported() ? 1 : 0; - m += this.east.supported() ? 1 : 0; - m += this.west.supported() ? 1 : 0; - return m; - }); - } - - private boolean fitsWalls(KList walls, int faces, int openings) - { - // @NoArgsConstructor - if((getNorth().required() && !walls.contains(StructureTileFace.NORTH)) || (getSouth().required() && !walls.contains(StructureTileFace.SOUTH)) || (getEast().required() && !walls.contains(StructureTileFace.EAST)) || (getWest().required() && !walls.contains(StructureTileFace.WEST))) - { - return false; - } - - if((!getNorth().supported() && walls.contains(StructureTileFace.NORTH)) || (!getSouth().supported() && walls.contains(StructureTileFace.SOUTH)) || (!getEast().supported() && walls.contains(StructureTileFace.EAST)) || (!getWest().supported() && walls.contains(StructureTileFace.WEST))) - { - return false; - } - //@done - - return true; - } -} diff --git a/src/main/java/com/volmit/iris/object/StructureTileCondition.java b/src/main/java/com/volmit/iris/object/StructureTileCondition.java deleted file mode 100644 index facfe81dd..000000000 --- a/src/main/java/com/volmit/iris/object/StructureTileCondition.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.volmit.iris.object; - -import com.volmit.iris.util.Desc; -import com.volmit.iris.util.DontObfuscate; - -@Desc("A structure tile condition is for a specific wall if a tile is allowed to place if a wall exists.") -public enum StructureTileCondition -{ - @Desc("This face REQUIRES a wall for this tile to place here") - @DontObfuscate - REQUIRED, - - @Desc("This face DOESNT CARE if a wall is here for this tile to place here") - @DontObfuscate - AGNOSTIC, - - @Desc("This face CANNOT HAVE a wall for this tile to place here") - @DontObfuscate - NEVER; - - public boolean supported() - { - return !this.equals(NEVER); - } - - public boolean required() - { - return this.equals(REQUIRED); - } -} diff --git a/src/main/java/com/volmit/iris/object/StructureTileFace.java b/src/main/java/com/volmit/iris/object/StructureTileFace.java deleted file mode 100644 index 538e201f2..000000000 --- a/src/main/java/com/volmit/iris/object/StructureTileFace.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.volmit.iris.object; - -public enum StructureTileFace -{ - UP, - DOWN, - NORTH, - SOUTH, - EAST, - WEST; - - public int x() - { - return this.equals(EAST) ? 1 : this.equals(WEST) ? -1 : 0; - } - - public int y() - { - return this.equals(UP) ? 1 : this.equals(DOWN) ? -1 : 0; - } - - public int z() - { - return this.equals(SOUTH) ? 1 : this.equals(NORTH) ? -1 : 0; - } - - public StructureTileFace rotate90CW() - { - switch(this) - { - case EAST: - return SOUTH; - case NORTH: - return EAST; - case SOUTH: - return WEST; - case WEST: - return NORTH; - default: - return this; - } - } -} diff --git a/src/main/java/com/volmit/iris/object/TileResult.java b/src/main/java/com/volmit/iris/object/TileResult.java deleted file mode 100644 index 3d82626b5..000000000 --- a/src/main/java/com/volmit/iris/object/TileResult.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.volmit.iris.object; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class TileResult -{ - private IrisStructure structure; - private IrisStructureTile tile; - private IrisObjectPlacement placement; - - public TileResult(IrisStructure structure, IrisStructureTile tile, int rot) - { - this.structure = structure; - this.tile = tile; - IrisObjectPlacement p = new IrisObjectPlacement(); - IrisObjectRotation rt = new IrisObjectRotation(); - rt.setYAxis(new IrisAxisRotationClamp(rot != 0, false, rot, rot, 0)); - p.setRotation(rt); - p.setBottom(true); - p.setBore(structure.isBore()); - p.setClamp(structure.getClamp()); - p.setSmartBore(tile.isSmartBore()); - p.setWaterloggable(structure.isUnderwater()); - p.setMode(tile.getPlaceMode()); - placement = p; - } -} diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EngineAssignedStructureManager.java b/src/main/java/com/volmit/iris/scaffold/engine/EngineAssignedStructureManager.java deleted file mode 100644 index a2706fb61..000000000 --- a/src/main/java/com/volmit/iris/scaffold/engine/EngineAssignedStructureManager.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.volmit.iris.scaffold.engine; - -public abstract class EngineAssignedStructureManager extends EngineAssignedComponent implements EngineStructureManager { - public EngineAssignedStructureManager(Engine engine) { - super(engine, "Structure"); - } -} diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EngineCompositeGenerator.java b/src/main/java/com/volmit/iris/scaffold/engine/EngineCompositeGenerator.java index cf5652451..6baa58812 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/EngineCompositeGenerator.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/EngineCompositeGenerator.java @@ -548,15 +548,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce @Override public boolean shouldGenerateStructures() { - try - { - return getComposite().getDefaultEngine().getDimension().isVanillaStructures(); - } - - catch(Throwable e) - { - return false; - } + return false; } public static EngineCompositeGenerator newStudioWorld(String dimension) { diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java b/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java index b660a18ad..4bafe90ab 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java @@ -29,8 +29,6 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer { public int getParallaxSize(); - public EngineStructureManager getStructureManager(); - default EngineFramework getFramework() { return getEngine().getFramework(); } @@ -275,7 +273,6 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer { IrisBiome biome = getComplex().getTrueBiomeStream().get(xx+8, zz+8); generateParallaxSurface(rng, x, z, biome, false); generateParallaxMutations(rng, x, z, false); - generateStructures(rng, x, z, region, biome); } default void generateParallaxFeatures(RNG rng, int cx, int cz, IrisRegion region, IrisBiome biome) @@ -309,30 +306,6 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer { generateParallaxLayer(x, z, false); } - default void generateStructures(RNG rng, int x, int z, IrisRegion region, IrisBiome biome) - { - int g = 30265; - for(IrisStructurePlacement k : region.getStructures()) - { - if(k == null) - { - continue; - } - - getStructureManager().placeStructure(k, rng.nextParallelRNG(2228 * 2 * g++), x, z); - } - - for(IrisStructurePlacement k : biome.getStructures()) - { - if(k == null) - { - continue; - } - - getStructureManager().placeStructure(k, rng.nextParallelRNG(-22228 * 4 * g++), x, z); - } - } - default KList generateParallaxJigsaw(RNG rng, int x, int z, IrisBiome biome) { KList placeAfter = new KList<>(); diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EngineStructureManager.java b/src/main/java/com/volmit/iris/scaffold/engine/EngineStructureManager.java deleted file mode 100644 index e28ddc848..000000000 --- a/src/main/java/com/volmit/iris/scaffold/engine/EngineStructureManager.java +++ /dev/null @@ -1,189 +0,0 @@ -package com.volmit.iris.scaffold.engine; - -import com.volmit.iris.object.IrisObject; -import com.volmit.iris.object.IrisRareObject; -import com.volmit.iris.object.IrisStructurePlacement; -import com.volmit.iris.object.TileResult; -import com.volmit.iris.scaffold.parallax.ParallaxChunkMeta; -import com.volmit.iris.util.ChunkPosition; -import com.volmit.iris.util.KList; -import com.volmit.iris.util.KSet; -import com.volmit.iris.util.RNG; - -public interface EngineStructureManager extends EngineComponent -{ - default void placeStructure(IrisStructurePlacement structure, RNG rngno, int cx, int cz) - { - RNG rng = new RNG(getEngine().getWorld().getSeed()).nextParallelRNG(-88738456 + rngno.nextInt()); - RNG rnp = rng.nextParallelRNG(cx - (cz * cz << 3) + rngno.nextInt()); - int s = structure.gridSize(getEngine()) - (structure.getStructure(getEngine()).isMergeEdges() ? 1 : 0); - int sh = structure.gridHeight(getEngine()) - (structure.getStructure(getEngine()).isMergeEdges() ? 1 : 0); - KSet m = new KSet<>(); - - for(int i = cx << 4; i <= (cx << 4) + 15; i += 1) - { - if(Math.floorDiv(i, s) * s >> 4 < cx) - { - continue; - } - - for(int j = cz << 4; j <= (cz << 4) + 15; j += 1) - { - if(Math.floorDiv(j, s) * s >> 4 < cz) - { - continue; - } - - ChunkPosition p = new ChunkPosition(Math.floorDiv(i, s) * s, Math.floorDiv(j, s) * s); - - if(m.contains(p)) - { - continue; - } - - m.add(p); - - if(structure.getStructure(getEngine()).getMaxLayers() <= 1) - { - placeLayer(structure, rng, rnp, i, 0, j, s, sh); - continue; - } - - for(int k = 0; k < s * structure.getStructure(getEngine()).getMaxLayers(); k += Math.max(sh, 1)) - { - placeLayer(structure, rng, rnp, i, k, j, s, sh); - } - } - } - } - - default void placeStructure(IrisStructurePlacement structure, RNG rngno, int cx, int cz, KList objects) - { - RNG rng = new RNG(getEngine().getWorld().getSeed()).nextParallelRNG(-88738456 + rngno.nextInt()); - RNG rnp = rng.nextParallelRNG(cx - (cz * cz << 3) + rngno.nextInt()); - int s = structure.gridSize(getEngine()) - (structure.getStructure(getEngine()).isMergeEdges() ? 1 : 0); - int sh = structure.gridHeight(getEngine()) - (structure.getStructure(getEngine()).isMergeEdges() ? 1 : 0); - KSet m = new KSet<>(); - - for(int i = cx << 4; i <= (cx << 4) + 15; i += 1) - { - if(Math.floorDiv(i, s) * s >> 4 < cx) - { - continue; - } - - for(int j = cz << 4; j <= (cz << 4) + 15; j += 1) - { - if(Math.floorDiv(j, s) * s >> 4 < cz) - { - continue; - } - - ChunkPosition p = new ChunkPosition(Math.floorDiv(i, s) * s, Math.floorDiv(j, s) * s); - - if(m.contains(p)) - { - continue; - } - - m.add(p); - - if(structure.getStructure(getEngine()).getMaxLayers() <= 1) - { - placeLayer(structure, rng, rnp, i, 0, j, s, sh, objects); - continue; - } - - for(int k = 0; k < s * structure.getStructure(getEngine()).getMaxLayers(); k += Math.max(sh, 1)) - { - placeLayer(structure, rng, rnp, i, k, j, s, sh, objects); - } - } - } - } - - default void placeLayer(IrisStructurePlacement structure, RNG rng, RNG rnp, int i, int k, int j, int s, int sh) - { - if(!hasStructure(structure, rng, i, k, j)) - { - return; - } - - int h = (structure.getHeight() == -1 ? 0 : structure.getHeight()) + (Math.floorDiv(k, sh) * sh); - TileResult t = structure.getStructure(getEngine()).getTile(rng, Math.floorDiv(i, s) * s, h, Math.floorDiv(j, s) * s); - - if(t != null) - { - IrisObject o = null; - - for(IrisRareObject l : t.getTile().getRareObjects()) - { - if(rnp.i(1, l.getRarity()) == 1) - { - o = structure.load(getEngine(), l.getObject()); - break; - } - } - - o = o != null ? o : structure.load(getEngine(), t.getTile().getObjects().get(rnp.nextInt(t.getTile().getObjects().size()))); - int id = rng.i(0, Integer.MAX_VALUE); - IrisObject oo = o; - o.place( - Math.floorDiv(i, s) * s, - structure.getHeight() == -1 ? -1 : h, - Math.floorDiv(j, s) * s, - getEngine().getFramework().getEngineParallax(), - t.getPlacement(), - rng, - (b) -> { - getEngine().getParallax().setObject(b.getX(), b.getY(), b.getZ(), oo.getLoadKey() + "@" + id); - ParallaxChunkMeta meta = getEngine().getParallax().getMetaRW(b.getX() >> 4, b.getZ() >> 4); - meta.setObjects(true); - meta.setMaxObject(Math.max(b.getY(), meta.getMaxObject())); - meta.setMinObject(Math.min(b.getY(), Math.max(meta.getMinObject(), 0))); - }, - null, - getData() - ); - } - } - - default void placeLayer(IrisStructurePlacement structure, RNG rng, RNG rnp, int i, int k, int j, int s, int sh, KList objects) - { - if(!hasStructure(structure, rng, i, k, j)) - { - return; - } - - int h = (structure.getHeight() == -1 ? 0 : structure.getHeight()) + (Math.floorDiv(k, sh) * sh); - TileResult t = structure.getStructure(getEngine()).getTile(rng, Math.floorDiv(i, s) * s, h, Math.floorDiv(j, s) * s); - - if(t != null) - { - IrisObject o = null; - - for(IrisRareObject l : t.getTile().getRareObjects()) - { - if(rnp.i(1, l.getRarity()) == 1) - { - o = structure.load(getEngine(), l.getObject()); - break; - } - } - - o = o != null ? o : structure.load(getEngine(), t.getTile().getObjects().get(rnp.nextInt(t.getTile().getObjects().size()))); - int id = rng.i(0, Integer.MAX_VALUE); - objects.add(new PlacedObject(null, o, id, Math.floorDiv(i, s) * s, Math.floorDiv(j, s) * s)); - } - } - - default boolean hasStructure(IrisStructurePlacement structure, RNG random, double x, double y, double z) - { - if(structure.getChanceGenerator(new RNG(getEngine().getWorld().getSeed())).getIndex(x / structure.getZoom(), y / structure.getZoom(), z / structure.getZoom(), structure.getRarity()) == structure.getRarity() / 2) - { - return structure.getRatio() > 0 ? structure.getChanceGenerator(new RNG(getEngine().getWorld().getSeed())).getDistance(x / structure.getZoom(), z / structure.getZoom()) > structure.getRatio() : structure.getChanceGenerator(new RNG(getEngine().getWorld().getSeed())).getDistance(x / structure.getZoom(), z / structure.getZoom()) < Math.abs(structure.getRatio()); - } - - return false; - } -} diff --git a/src/main/java/com/volmit/iris/util/IrisStructureResult.java b/src/main/java/com/volmit/iris/util/IrisStructureResult.java deleted file mode 100644 index ac600ba07..000000000 --- a/src/main/java/com/volmit/iris/util/IrisStructureResult.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.volmit.iris.util; - -import com.volmit.iris.object.IrisStructure; -import com.volmit.iris.object.IrisStructureTile; - -import lombok.Data; - -@Data -public class IrisStructureResult -{ - private IrisStructureTile tile; - private IrisStructure structure; - - public IrisStructureResult(IrisStructureTile tile, IrisStructure structure) - { - this.tile = tile; - this.structure = structure; - } -} diff --git a/src/main/java/com/volmit/iris/util/RegistryListStructure.java b/src/main/java/com/volmit/iris/util/RegistryListStructure.java deleted file mode 100644 index fdd7fed1f..000000000 --- a/src/main/java/com/volmit/iris/util/RegistryListStructure.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.volmit.iris.util; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Retention(RUNTIME) -@Target({PARAMETER, TYPE, FIELD}) -public @interface RegistryListStructure -{ - -}