mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-20 03:04:08 +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")
|
@Param(description = "The dimension to update the workspace of", contextual = true, defaultValue = "overworld")
|
||||||
IrisDimension dimension
|
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());
|
sender().sendMessage(C.GREEN + "Updated Code Workspace for " + dimension.getName());
|
||||||
} else {
|
} else {
|
||||||
sender().sendMessage(C.RED + "Invalid project: " + dimension.getName() + ". Try deleting the code-workspace file and try again.");
|
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<IrisCave> caveLoader;
|
||||||
private ResourceLoader<IrisRavine> ravineLoader;
|
private ResourceLoader<IrisRavine> ravineLoader;
|
||||||
private KMap<Class<? extends IrisRegistrant>, ResourceLoader<? extends IrisRegistrant>> loaders = new KMap<>();
|
private KMap<Class<? extends IrisRegistrant>, ResourceLoader<? extends IrisRegistrant>> loaders = new KMap<>();
|
||||||
private boolean closed;
|
|
||||||
private final File dataFolder;
|
private final File dataFolder;
|
||||||
private Engine engine;
|
private Engine engine;
|
||||||
private final int id;
|
private final int id;
|
||||||
@ -81,7 +80,6 @@ public class IrisData {
|
|||||||
this.engine = null;
|
this.engine = null;
|
||||||
this.dataFolder = dataFolder;
|
this.dataFolder = dataFolder;
|
||||||
this.id = RNG.r.imax();
|
this.id = RNG.r.imax();
|
||||||
closed = false;
|
|
||||||
hotloaded();
|
hotloaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,9 +154,7 @@ public class IrisData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
closed = true;
|
|
||||||
dump();
|
dump();
|
||||||
loaders.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printData(ResourceLoader<?> rl) {
|
private static void printData(ResourceLoader<?> rl) {
|
||||||
@ -193,10 +189,6 @@ public class IrisData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void hotloaded() {
|
public synchronized void hotloaded() {
|
||||||
if (closed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
loaders.clear();
|
loaders.clear();
|
||||||
File packs = dataFolder;
|
File packs = dataFolder;
|
||||||
packs.mkdirs();
|
packs.mkdirs();
|
||||||
@ -220,20 +212,12 @@ public class IrisData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void dump() {
|
public void dump() {
|
||||||
if (closed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ResourceLoader<?> i : loaders.values()) {
|
for (ResourceLoader<?> i : loaders.values()) {
|
||||||
i.clearCache();
|
i.clearCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearLists() {
|
public void clearLists() {
|
||||||
if (closed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ResourceLoader<?> i : loaders.values()) {
|
for (ResourceLoader<?> i : loaders.values()) {
|
||||||
i.clearList();
|
i.clearList();
|
||||||
}
|
}
|
||||||
|
@ -52,15 +52,9 @@ public class IrisCave extends IrisRegistrant {
|
|||||||
@Desc("Define potential forking features")
|
@Desc("Define potential forking features")
|
||||||
private IrisCarving fork = new IrisCarving();
|
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")
|
@Desc("Limit the worm from ever getting higher or lower than this range")
|
||||||
private IrisRange verticalRange = new IrisRange(3, 255);
|
private IrisRange verticalRange = new IrisRange(3, 255);
|
||||||
|
|
||||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFolderName() {
|
public String getFolderName() {
|
||||||
return "caves";
|
return "caves";
|
||||||
@ -71,12 +65,12 @@ public class IrisCave extends IrisRegistrant {
|
|||||||
return "Cave";
|
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,
|
writer.setLine(getWorm().generate(rng, engine.getData(), writer, verticalRange, x, y, z,
|
||||||
(at) -> fork.doCarving(writer, rng, engine, at.getX(), at.getY(), at.getZ())),
|
(at) -> fork.doCarving(writer, rng, engine, at.getX(), at.getY(), at.getZ())),
|
||||||
getWorm().getGirth().get(rng, x, z, engine.getData()), true,
|
getWorm().getGirth().get(rng, x, z, engine.getData()), true,
|
||||||
matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
|
biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.data.cache.AtomicCache;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
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.Desc;
|
||||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||||
import com.volmit.iris.engine.object.annotations.Required;
|
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.common.IRare;
|
||||||
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
|
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
|
||||||
import com.volmit.iris.engine.object.noise.IrisStyledRange;
|
import com.volmit.iris.engine.object.noise.IrisStyledRange;
|
||||||
import com.volmit.iris.engine.object.noise.NoiseStyle;
|
import com.volmit.iris.engine.object.noise.NoiseStyle;
|
||||||
import com.volmit.iris.util.math.RNG;
|
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.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
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.")
|
@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));
|
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 AtomicCache<IrisCave> caveCache = new AtomicCache<>();
|
||||||
private transient final AtomicBoolean fail = new AtomicBoolean(false);
|
private transient final AtomicBoolean fail = new AtomicBoolean(false);
|
||||||
|
|
||||||
@ -94,7 +103,8 @@ public class IrisCavePlacer implements IRare {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
fail.set(true);
|
fail.set(true);
|
||||||
|
@ -55,10 +55,6 @@ public class IrisRavine extends IrisRegistrant {
|
|||||||
@Desc("Define the shape of this ravine (2d, ignores Y)")
|
@Desc("Define the shape of this ravine (2d, ignores Y)")
|
||||||
private IrisWorm worm;
|
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")
|
@Desc("Define potential forking features")
|
||||||
private IrisCarving fork = new IrisCarving();
|
private IrisCarving fork = new IrisCarving();
|
||||||
|
|
||||||
@ -86,8 +82,6 @@ public class IrisRavine extends IrisRegistrant {
|
|||||||
@Desc("The thickness of the ravine ribs")
|
@Desc("The thickness of the ravine ribs")
|
||||||
private double ribThickness = 3;
|
private double ribThickness = 3;
|
||||||
|
|
||||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFolderName() {
|
public String getFolderName() {
|
||||||
return "ravines";
|
return "ravines";
|
||||||
@ -98,7 +92,7 @@ public class IrisRavine extends IrisRegistrant {
|
|||||||
return "Ravine";
|
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) -> {
|
KList<IrisPosition> pos = getWorm().generate(rng, engine.getData(), writer, null, x, y, z, (at) -> {
|
||||||
});
|
});
|
||||||
@ -129,7 +123,7 @@ public class IrisRavine extends IrisRegistrant {
|
|||||||
break;
|
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;
|
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.MinNumber;
|
||||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||||
import com.volmit.iris.engine.object.annotations.Required;
|
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.common.IRare;
|
||||||
import com.volmit.iris.util.math.RNG;
|
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.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -53,6 +56,11 @@ public class IrisRavinePlacer implements IRare {
|
|||||||
@RegistryListResource(IrisRavine.class)
|
@RegistryListResource(IrisRavine.class)
|
||||||
private String ravine;
|
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 AtomicCache<IrisRavine> ravineCache = new AtomicCache<>();
|
||||||
private transient final AtomicBoolean fail = new AtomicBoolean(false);
|
private transient final AtomicBoolean fail = new AtomicBoolean(false);
|
||||||
|
|
||||||
@ -81,7 +89,8 @@ public class IrisRavinePlacer implements IRare {
|
|||||||
try {
|
try {
|
||||||
int xx = x + rng.nextInt(15);
|
int xx = x + rng.nextInt(15);
|
||||||
int zz = z + 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) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
fail.set(true);
|
fail.set(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user