mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 18:55:18 +00:00
Fix loader close bug
This commit is contained in:
parent
443aa0040c
commit
3eef5b2c02
@ -692,7 +692,7 @@ public class CommandStudio implements DecreeExecutor {
|
||||
@Param(description = "The dimension to update the workspace of", contextual = true, defaultValue = "overworld")
|
||||
IrisDimension dimension
|
||||
) {
|
||||
if (new IrisProject(dimension.getLoadFile().getParentFile().getParentFile()).updateWorkspace()) {
|
||||
if (new IrisProject(dimension.getLoader().getDataFolder()).updateWorkspace()) {
|
||||
sender().sendMessage(C.GREEN + "Updated Code Workspace for " + dimension.getName());
|
||||
} else {
|
||||
sender().sendMessage(C.RED + "Invalid project: " + dimension.getName() + ". Try deleting the code-workspace file and try again.");
|
||||
|
@ -68,7 +68,6 @@ public class IrisData {
|
||||
private ResourceLoader<IrisCave> caveLoader;
|
||||
private ResourceLoader<IrisRavine> ravineLoader;
|
||||
private KMap<Class<? extends IrisRegistrant>, ResourceLoader<? extends IrisRegistrant>> loaders = new KMap<>();
|
||||
private boolean closed;
|
||||
private final File dataFolder;
|
||||
private Engine engine;
|
||||
private final int id;
|
||||
@ -81,7 +80,6 @@ public class IrisData {
|
||||
this.engine = null;
|
||||
this.dataFolder = dataFolder;
|
||||
this.id = RNG.r.imax();
|
||||
closed = false;
|
||||
hotloaded();
|
||||
}
|
||||
|
||||
@ -156,9 +154,7 @@ public class IrisData {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
closed = true;
|
||||
dump();
|
||||
loaders.clear();
|
||||
}
|
||||
|
||||
private static void printData(ResourceLoader<?> rl) {
|
||||
@ -193,10 +189,6 @@ public class IrisData {
|
||||
}
|
||||
|
||||
public synchronized void hotloaded() {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
|
||||
loaders.clear();
|
||||
File packs = dataFolder;
|
||||
packs.mkdirs();
|
||||
@ -220,20 +212,12 @@ public class IrisData {
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ResourceLoader<?> i : loaders.values()) {
|
||||
i.clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearLists() {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ResourceLoader<?> i : loaders.values()) {
|
||||
i.clearList();
|
||||
}
|
||||
|
@ -52,15 +52,9 @@ public class IrisCave extends IrisRegistrant {
|
||||
@Desc("Define potential forking features")
|
||||
private IrisCarving fork = new IrisCarving();
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
@Desc("Limit the worm from ever getting higher or lower than this range")
|
||||
private IrisRange verticalRange = new IrisRange(3, 255);
|
||||
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "caves";
|
||||
@ -71,12 +65,12 @@ public class IrisCave extends IrisRegistrant {
|
||||
return "Cave";
|
||||
}
|
||||
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, MatterCavern biome) {
|
||||
|
||||
writer.setLine(getWorm().generate(rng, engine.getData(), writer, verticalRange, x, y, z,
|
||||
(at) -> fork.doCarving(writer, rng, engine, at.getX(), at.getY(), at.getZ())),
|
||||
getWorm().getGirth().get(rng, x, z, engine.getData()), true,
|
||||
matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
|
||||
biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,15 +23,19 @@ import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.engine.modifier.IrisCarveModifier;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.common.IRare;
|
||||
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import com.volmit.iris.engine.object.noise.IrisStyledRange;
|
||||
import com.volmit.iris.engine.object.noise.NoiseStyle;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.slices.CavernMatter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -62,6 +66,11 @@ public class IrisCavePlacer implements IRare {
|
||||
@Desc("The height range this cave can spawn at. If breakSurface is false, the output of this range will be clamped by the current world height to prevent surface breaking.")
|
||||
private IrisStyledRange caveStartHeight = new IrisStyledRange(13, 120, new IrisGeneratorStyle(NoiseStyle.STATIC));
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
private transient final AtomicCache<IrisCave> caveCache = new AtomicCache<>();
|
||||
private transient final AtomicBoolean fail = new AtomicBoolean(false);
|
||||
|
||||
@ -94,7 +103,8 @@ public class IrisCavePlacer implements IRare {
|
||||
}
|
||||
|
||||
try {
|
||||
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15));
|
||||
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15),
|
||||
matterNodeCache.aquire(() -> customBiome.isEmpty() ? CavernMatter.ON : CavernMatter.get(customBiome)));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
fail.set(true);
|
||||
|
@ -55,10 +55,6 @@ public class IrisRavine extends IrisRegistrant {
|
||||
@Desc("Define the shape of this ravine (2d, ignores Y)")
|
||||
private IrisWorm worm;
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
@Desc("Define potential forking features")
|
||||
private IrisCarving fork = new IrisCarving();
|
||||
|
||||
@ -86,8 +82,6 @@ public class IrisRavine extends IrisRegistrant {
|
||||
@Desc("The thickness of the ravine ribs")
|
||||
private double ribThickness = 3;
|
||||
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "ravines";
|
||||
@ -98,7 +92,7 @@ public class IrisRavine extends IrisRegistrant {
|
||||
return "Ravine";
|
||||
}
|
||||
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, MatterCavern biome) {
|
||||
|
||||
KList<IrisPosition> pos = getWorm().generate(rng, engine.getData(), writer, null, x, y, z, (at) -> {
|
||||
});
|
||||
@ -129,7 +123,7 @@ public class IrisRavine extends IrisRegistrant {
|
||||
break;
|
||||
}
|
||||
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, biome);
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +139,7 @@ public class IrisRavine extends IrisRegistrant {
|
||||
break;
|
||||
}
|
||||
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,11 @@ import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.common.IRare;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.slices.CavernMatter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -53,6 +56,11 @@ public class IrisRavinePlacer implements IRare {
|
||||
@RegistryListResource(IrisRavine.class)
|
||||
private String ravine;
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
private transient final AtomicCache<IrisRavine> ravineCache = new AtomicCache<>();
|
||||
private transient final AtomicBoolean fail = new AtomicBoolean(false);
|
||||
|
||||
@ -81,7 +89,8 @@ public class IrisRavinePlacer implements IRare {
|
||||
try {
|
||||
int xx = x + rng.nextInt(15);
|
||||
int zz = z + rng.nextInt(15);
|
||||
ravine.generate(mantle, rng, engine, xx, y, zz);
|
||||
ravine.generate(mantle, rng, engine, xx, y, zz,
|
||||
matterNodeCache.aquire(() -> customBiome.isEmpty() ? CavernMatter.ON : CavernMatter.get(customBiome)));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
fail.set(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user