Fix jigsaw save locations

This commit is contained in:
Daniel Mills 2020-12-29 05:05:08 -05:00
parent 56ae387f7b
commit 3dc7bd74fe
16 changed files with 212 additions and 62 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.volmit</groupId>
<artifactId>Iris</artifactId>
<version>1.1.9</version>
<version>1.1.10</version>
<name>Iris</name>
<properties>
<skip.copy>false</skip.copy>

View File

@ -19,8 +19,9 @@ public class IrisDataManager
private ResourceLoader<IrisDimension> dimensionLoader;
private ResourceLoader<IrisGenerator> generatorLoader;
private ResourceLoader<IrisStructure> structureLoader;
private ResourceLoader<IrisJigsawPiece> structurePieceLoader;
private ResourceLoader<IrisJigsawPool> structurePoolLoader;
private ResourceLoader<IrisJigsawPiece> jigsawPieceLoader;
private ResourceLoader<IrisJigsawPool> jigsawPoolLoader;
private ResourceLoader<IrisJigsawStructure> jigsawStructureLoader;
private ResourceLoader<IrisEntity> entityLoader;
private ResourceLoader<IrisBlockData> blockLoader;
private ObjectResourceLoader objectLoader;
@ -51,9 +52,10 @@ public class IrisDataManager
this.biomeLoader = null;
this.dimensionLoader = null;
this.structureLoader = null;
this.structurePoolLoader = null;
this.structurePieceLoader = null;
this.jigsawPoolLoader = null;
this.jigsawPieceLoader = null;
this.generatorLoader = null;
this.jigsawStructureLoader = null;
this.blockLoader = null;
this.objectLoader = null;
}
@ -82,8 +84,9 @@ public class IrisDataManager
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.structurePoolLoader = new ResourceLoader<>(packs, this, "jigsaw-pools", "Jigsaw Pool", IrisJigsawPool.class);
this.structurePieceLoader = new ResourceLoader<>(packs, this, "jigsaw-pieces", "Jigsaw Piece", IrisJigsawPiece.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);
this.generatorLoader = new ResourceLoader<>(packs, this, "generators", "Generator", IrisGenerator.class);
this.blockLoader = new ResourceLoader<>(packs,this, "blocks", "Block", IrisBlockData.class);
this.objectLoader = new ObjectResourceLoader(packs, this, "objects", "Object");
@ -99,8 +102,9 @@ public class IrisDataManager
blockLoader.clearCache();
lootLoader.clearCache();
objectLoader.clearCache();
structurePieceLoader.clearCache();
structurePoolLoader.clearCache();
jigsawPieceLoader.clearCache();
jigsawPoolLoader.clearCache();
jigsawStructureLoader.clearCache();
regionLoader.clearCache();
dimensionLoader.clearCache();
entityLoader.clearCache();
@ -122,9 +126,10 @@ public class IrisDataManager
regionLoader.clearList();
dimensionLoader.clearList();
generatorLoader.clearList();
jigsawStructureLoader.clearList();
structureLoader.clearList();
structurePoolLoader.clearList();
structurePieceLoader.clearList();
jigsawPoolLoader.clearList();
jigsawPieceLoader.clearList();
objectLoader.clearList();
}
@ -143,14 +148,14 @@ public class IrisDataManager
return loadAny(key, (dm) -> dm.getStructureLoader().load(key, false));
}
public static IrisJigsawPiece loadAnyStructurePiece(String key)
public static IrisJigsawPiece loadAnyJigsawPiece(String key)
{
return loadAny(key, (dm) -> dm.getStructurePieceLoader().load(key, false));
return loadAny(key, (dm) -> dm.getJigsawPieceLoader().load(key, false));
}
public static IrisJigsawPool loadAnyStructurePool(String key)
public static IrisJigsawPool loadAnyJigsawPool(String key)
{
return loadAny(key, (dm) -> dm.getStructurePoolLoader().load(key, false));
return loadAny(key, (dm) -> dm.getJigsawPoolLoader().load(key, false));
}
public static IrisEntity loadAnyEntity(String key)
@ -178,6 +183,11 @@ public class IrisDataManager
return loadAny(key, (dm) -> dm.getDimensionLoader().load(key, false));
}
public static IrisJigsawStructure loadAnyJigsawStructure(String key)
{
return loadAny(key, (dm) -> dm.getJigsawStructureLoader().load(key, false));
}
public static IrisGenerator loadAnyGenerator(String key)
{
return loadAny(key, (dm) -> dm.getGeneratorLoader().load(key, false));

View File

@ -285,6 +285,7 @@ public class IrisProject
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"));
schemas.put(getSchemaEntry(IrisBlockData.class, dm, "/blocks/*.json"));
schemas.put(getSchemaEntry(IrisLootTable.class, dm, "/loot/*.json"));
settings.put("json.schemas", schemas);
@ -325,7 +326,7 @@ public class IrisProject
blocks.add(dm.getBlockLoader().load(i));
}
//TODO: EXPORT STRUCTURE PIECES FROM STRUCTURES
//TODO: EXPORT JIGSAW PIECES FROM STRUCTURES
dimension.getRegions().forEach((i) -> regions.add(dm.getRegionLoader().load(i)));
dimension.getLoot().getTables().forEach((i) -> loot.add(dm.getLootLoader().load(i)));
regions.forEach((i) -> biomes.addAll(i.getAllBiomes(null)));

View File

@ -382,14 +382,14 @@ public class SchemaBuilder
description.add(SYMBOL_TYPE__N + " Must be a valid Structure Tileset (use ctrl+space for auto complete!)");
}
else if(k.isAnnotationPresent(RegistryListStructurePiece.class))
else if(k.isAnnotationPresent(RegistryListJigsawPiece.class))
{
String key = "enum-reg-structure-piece";
if(!definitions.containsKey(key))
{
JSONObject j = new JSONObject();
j.put("enum", new JSONArray(data.getStructurePieceLoader().getPossibleKeys()));
j.put("enum", new JSONArray(data.getJigsawPieceLoader().getPossibleKeys()));
definitions.put(key, j);
}
@ -398,14 +398,30 @@ public class SchemaBuilder
description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw Piece (use ctrl+space for auto complete!)");
}
else if(k.isAnnotationPresent(RegistryListStructurePool.class))
else if(k.isAnnotationPresent(RegistryListJigsaw.class))
{
String key = "enum-reg-jigsaw";
if(!definitions.containsKey(key))
{
JSONObject j = new JSONObject();
j.put("enum", new JSONArray(data.getJigsawStructureLoader().getPossibleKeys()));
definitions.put(key, j);
}
fancyType = "Iris Jigsaw";
prop.put("$ref", "#/definitions/" + key);
description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw (use ctrl+space for auto complete!)");
}
else if(k.isAnnotationPresent(RegistryListJigsawPool.class))
{
String key = "enum-reg-structure-pool";
if(!definitions.containsKey(key))
{
JSONObject j = new JSONObject();
j.put("enum", new JSONArray(data.getStructurePoolLoader().getPossibleKeys()));
j.put("enum", new JSONArray(data.getJigsawPoolLoader().getPossibleKeys()));
definitions.put(key, j);
}
@ -797,7 +813,7 @@ public class SchemaBuilder
description.add(SYMBOL_TYPE__N + " Must be a valid Structure Tileset (use ctrl+space for auto complete!)");
}
else if(k.isAnnotationPresent(RegistryListStructurePiece.class))
else if(k.isAnnotationPresent(RegistryListJigsawPiece.class))
{
fancyType = "List of Iris Jigsaw Pieces";
String key = "enum-reg-structure-piece";
@ -805,7 +821,7 @@ public class SchemaBuilder
if(!definitions.containsKey(key))
{
JSONObject j = new JSONObject();
j.put("enum", new JSONArray(data.getStructurePieceLoader().getPossibleKeys()));
j.put("enum", new JSONArray(data.getJigsawPieceLoader().getPossibleKeys()));
definitions.put(key, j);
}
@ -815,7 +831,7 @@ public class SchemaBuilder
description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw Piece (use ctrl+space for auto complete!)");
}
else if(k.isAnnotationPresent(RegistryListStructurePool.class))
else if(k.isAnnotationPresent(RegistryListJigsawPool.class))
{
fancyType = "List of Iris Jigsaw Pools";
String key = "enum-reg-structure-pool";
@ -823,7 +839,7 @@ public class SchemaBuilder
if(!definitions.containsKey(key))
{
JSONObject j = new JSONObject();
j.put("enum", new JSONArray(data.getStructurePoolLoader().getPossibleKeys()));
j.put("enum", new JSONArray(data.getJigsawPoolLoader().getPossibleKeys()));
definitions.put(key, j);
}
@ -833,6 +849,24 @@ public class SchemaBuilder
description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw Pool (use ctrl+space for auto complete!)");
}
else if(k.isAnnotationPresent(RegistryListJigsaw.class))
{
fancyType = "List of Iris Jigsaw Structures";
String key = "enum-reg-jigsaw";
if(!definitions.containsKey(key))
{
JSONObject j = new JSONObject();
j.put("enum", new JSONArray(data.getJigsawStructureLoader().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 Jigsaw (use ctrl+space for auto complete!)");
}
else if(t.type().equals(Enchantment.class))
{
fancyType = "List of Enchantment Types";

View File

@ -42,7 +42,7 @@ public class CommandIrisJigsawEdit extends MortarCommand
}
IrisJigsawPiece piece = IrisDataManager.loadAnyStructurePiece(args[0]);
IrisJigsawPiece piece = IrisDataManager.loadAnyJigsawPiece(args[0]);
if(piece != null)
{

View File

@ -48,7 +48,7 @@ public class CommandIrisJigsawNew extends MortarCommand
}
IrisObject object = IrisDataManager.loadAnyObject(args[2]);
File dest = Iris.instance.getDataFile("packs", args[1], "structure-pieces", args[0] + ".json");
File dest = Iris.instance.getDataFile("packs", args[1], "jigsaw-pieces", args[0] + ".json");
new JigsawEditor(sender.player(), null, object, dest);
sender.sendMessage("* Right Click blocks to make them connectors");
sender.sendMessage("* Right Click connectors to orient them");

View File

@ -29,7 +29,7 @@ public class IrisJigsawPieceConnector
@Desc("If set to true, this connector is allowed to place pieces inside of it's own piece. For example if you are adding a light post, or house on top of a path piece, you would set this to true to allow the piece to collide with the path bounding box.")
private boolean innerConnector = false;
@RegistryListStructurePool
@RegistryListJigsawPool
@Desc("Pick piece pools to place onto this connector")
@ArrayType(type = String.class, min = 1)
@Required

View File

@ -0,0 +1,27 @@
package com.volmit.iris.object;
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 jigsaw placement")
@Data
public class IrisJigsawPlacement
{
@RegistryListJigsaw
@Required
@DontObfuscate
@Desc("The jigsaw structure to use")
private String structure = "";
@Required
@MinNumber(1)
@DontObfuscate
@Desc("The rarity for this jigsaw structure to place on a per chunk basis")
private int rarity = 29;
}

View File

@ -16,7 +16,7 @@ import lombok.experimental.Accessors;
@EqualsAndHashCode(callSuper = false)
public class IrisJigsawPool extends IrisRegistrant
{
@RegistryListStructurePiece
@RegistryListJigsawPiece
@Required
@DontObfuscate
@ArrayType(min = 1,type = String.class)

View File

@ -0,0 +1,31 @@
package com.volmit.iris.object;
import com.volmit.iris.util.*;
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 jigsaw structure")
@Data
@EqualsAndHashCode(callSuper = false)
public class IrisJigsawStructure extends IrisRegistrant
{
@RegistryListJigsawPiece
@Required
@DontObfuscate
@ArrayType(min = 1,type = String.class)
@Desc("The starting pieces. Randomly chooses a starting piece, then connects pieces using the pools define in the starting piece.")
private KList<String> pieces = new KList<>();
@MaxNumber(32)
@MinNumber(1)
@DontObfuscate
@Desc("The maximum pieces that can step out from the center piece")
private int maxDepth = 9;
}

View File

@ -42,7 +42,7 @@ public class DirectWorldWriter {
for(Long i : new KList<>(writeBuffer.keySet()))
{
if(M.ms() - lastUse.get(i) < 5000)
if(M.ms() - lastUse.get(i) < 10000)
{
continue;
}
@ -239,6 +239,7 @@ public class DirectWorldWriter {
if(f.exists())
{
try {
Iris.warn("HAD TO LOAD MCA REGION FILE " + x + " " + z + " which is EXPENSIVE!");
mca = MCAUtil.read(f);
try
{

View File

@ -202,6 +202,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer
RNG rng = new RNG(Cache.key(x, z)).nextParallelRNG(getEngine().getTarget().getWorld().getSeed());
IrisRegion region = getComplex().getRegionStream().get(x+8, z+8);
IrisBiome biome = getComplex().getTrueBiomeStream().get(x+8, z+8);
// generateParallaxJigsaw(rng, x, z, biome, placedObjects);
generateParallaxSurface(rng, x, z, biome, placedObjects);
generateParallaxMutations(rng, x, z, placedObjects);
generateStructures(rng, x>>4, z>>4, region, biome, placedObjects);
@ -270,7 +271,6 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer
default void generateParallaxSurface(RNG rng, int x, int z, IrisBiome biome, KList<PlacedObject> objects) {
for (IrisObjectPlacement i : biome.getSurfaceObjects())
{
Iris.info("Found Placement: " + i.getPlace());
if(rng.chance(i.getChance()))
{
place(rng, x, z, i, objects);

View File

@ -89,12 +89,12 @@ public class PregenJob implements Listener
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
{
writer = new DirectWorldWriter(world.getWorldFolder());
gleaming = (IrisSettings.get().isUseGleamPregenerator());
g.set(0);
burst = new MultiBurst(gleaming ? IrisSettings.get().getMaxAsyncChunkPregenThreads() : tc());
instance = this;
working = new Semaphore(gleaming ? IrisSettings.get().getMaxAsyncChunkPregenThreads() : tc());
writer =IrisSettings.get().isUseExperimentalGleamMCADirectWriteMode() ? new DirectWorldWriter(world.getWorldFolder()) : null;
this.s = PrecisionStopwatch.start();
Iris.instance.registerListener(this);
this.world = world;
@ -130,6 +130,10 @@ public class PregenJob implements Listener
mcaX = x;
mcaZ = z;
chunkSpiraler.retarget(cubeSize, cubeSize);
if(writer != null)
{
writer.flush();
}
ticks++;
});
@ -168,8 +172,12 @@ public class PregenJob implements Listener
public static void stop()
{
try
{
if(instance.writer != null)
{
instance.writer.flush();
}
Bukkit.getScheduler().cancelTask(task);
if(consumer != null)
@ -195,8 +203,12 @@ public class PregenJob implements Listener
instance.pms = instance.s.getMilliseconds();
instance.paused = true;
instance.pausedAt = M.ms();
if(instance.writer != null)
{
instance.writer.flush();
}
}
public static void resume()
{
@ -461,15 +473,23 @@ public class PregenJob implements Listener
}
};
if(IrisSettings.get().isUseExperimentalGleamMCADirectWriteMode())
{
e.execute(g);
}
else
{
J.a(g);
}
}
else
{if(consumer != null)
{
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.magenta.darker().darker().darker());
}
e.execute(() ->
Runnable rr = () ->
{
try
{
@ -495,7 +515,16 @@ public class PregenJob implements Listener
{
e.printStackTrace();
}
});
};
if(IrisSettings.get().isUseExperimentalGleamMCADirectWriteMode())
{
e.execute(rr);
}
else
{
J.a(rr);
}
}
}
@ -609,7 +638,10 @@ public class PregenJob implements Listener
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-all");
}
writer.flush();
if(instance.writer != null)
{
instance.writer.flush();
}
}
public int max()

View File

@ -8,7 +8,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListStructurePool
public @interface RegistryListJigsaw
{
}

View File

@ -8,7 +8,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListStructurePiece
public @interface RegistryListJigsawPiece
{
}

View File

@ -0,0 +1,14 @@
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListJigsawPool
{
}