Eradicate the old structure system

This commit is contained in:
Daniel Mills 2021-01-12 06:05:37 -05:00
parent 93508d7514
commit dd7a8bae16
32 changed files with 3 additions and 2574 deletions

View File

@ -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();

View File

@ -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++)
{

View File

@ -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());
}
}

View File

@ -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);
}
}

View File

@ -116,6 +116,6 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
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();
}
}

View File

@ -18,7 +18,6 @@ public class IrisDataManager
private ResourceLoader<IrisRegion> regionLoader;
private ResourceLoader<IrisDimension> dimensionLoader;
private ResourceLoader<IrisGenerator> generatorLoader;
private ResourceLoader<IrisStructure> structureLoader;
private ResourceLoader<IrisJigsawPiece> jigsawPieceLoader;
private ResourceLoader<IrisJigsawPool> jigsawPoolLoader;
private ResourceLoader<IrisJigsawStructure> 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));

View File

@ -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<IrisRegion> regions = new KSet<>();
KSet<IrisBiome> biomes = new KSet<>();
KSet<IrisEntity> entities = new KSet<>();
KSet<IrisStructure> structures = new KSet<>();
KSet<IrisGenerator> generators = new KSet<>();
KSet<IrisLootTable> loot = new KSet<>();
KSet<IrisBlockData> 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<String> 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);

View File

@ -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";

View File

@ -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<StructureTemplate> 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;
}
}

View File

@ -20,9 +20,6 @@ public class CommandIris extends MortarCommand
@Command
private CommandIrisJigsaw jigsaw;
@Command
private CommandIrisStructure structure;
@Command
private CommandIrisObject object;

View File

@ -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<String> 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]";
}
}

View File

@ -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<String> 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 "";
}
}

View File

@ -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<String> 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 "<name> <dimension> <tile-width> <tile-height> [-3d]";
}
}

View File

@ -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<String> 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 "";
}
}

View File

@ -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<String> 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 "";
}
}

View File

@ -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<String> 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 "<structure>";
}
}

View File

@ -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<String> 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 "";
}
}

View File

@ -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<String> 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 "";
}
}

View File

@ -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;
}

View File

@ -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<IrisEntitySpawnOverride> entitySpawnOverrides = new KList<>();
@DontObfuscate
@Desc("Entity spawns during generation")
@ArrayType(min = 1, type = IrisEntityInitialSpawn.class)
private KList<IrisEntityInitialSpawn> 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<IrisStructureTile> tiles = new KList<>();
private final transient AtomicCache<CNG> wallGenerator = new AtomicCache<>();
public TileResult getTile(RNG rng, double x, double y, double z)
{
KList<StructureTileFace> 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<StructureTileFace> 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);
});
}
}

View File

@ -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<CellGenerator> chanceCell = new AtomicCache<>();
private final transient AtomicCache<IrisStructure> structure = new AtomicCache<>();
private final transient AtomicCache<IrisObjectPlacement> 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;
});
}
}

View File

@ -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<IrisEntitySpawnOverride> entitySpawnOverrides = new KList<>();
@DontObfuscate
@Desc("Entity spawns during generation")
@ArrayType(min = 1, type = IrisEntityInitialSpawn.class)
private KList<IrisEntityInitialSpawn> 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<String> 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<IrisRareObject> rareObjects = new KList<>();
private final transient KMap<Integer, IrisObject> forceObjects = new KMap<>();
private final transient AtomicCache<Integer> minFaces = new AtomicCache<>();
private final transient AtomicCache<Integer> 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<StructureTileFace> 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<StructureTileFace> 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;
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}

View File

@ -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");
}
}

View File

@ -548,16 +548,8 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
@Override
public boolean shouldGenerateStructures() {
try
{
return getComposite().getDefaultEngine().getDimension().isVanillaStructures();
}
catch(Throwable e)
{
return false;
}
}
public static EngineCompositeGenerator newStudioWorld(String dimension) {
return new EngineCompositeGenerator(dimension, false);

View File

@ -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<Runnable> generateParallaxJigsaw(RNG rng, int x, int z, IrisBiome biome) {
KList<Runnable> placeAfter = new KList<>();

View File

@ -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<ChunkPosition> 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<PlacedObject> 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<ChunkPosition> 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<PlacedObject> 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;
}
}

View File

@ -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;
}
}

View File

@ -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
{
}