mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-26 02:29:14 +00:00
Compare commits
6 Commits
feat/stati
...
3.5.4-1.19
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8df15c0c2d | ||
|
|
24e1c578c8 | ||
|
|
1c3bff7559 | ||
|
|
a09657b4d0 | ||
|
|
910220d3ca | ||
|
|
fc05c24e3a |
@@ -32,7 +32,7 @@ plugins {
|
||||
id "de.undercouch.download" version "5.0.1"
|
||||
}
|
||||
|
||||
version '3.5.2-1.19.2-1.21.3'
|
||||
version '3.5.4-1.19.2-1.21.3'
|
||||
|
||||
// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
|
||||
// ======================== WINDOWS =============================
|
||||
|
||||
@@ -672,10 +672,12 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
metrics.addCustomChart(new DrilldownPie("used_packs", () -> Bukkit.getWorlds().stream()
|
||||
.map(IrisToolbelt::access)
|
||||
.filter(Objects::nonNull)
|
||||
.map(PlatformChunkGenerator::getTarget)
|
||||
.collect(Collectors.toMap(target -> target.getDimension().getLoadKey(), target -> {
|
||||
int version = target.getDimension().getVersion();
|
||||
String checksum = IO.hashRecursive(target.getData().getDataFolder());
|
||||
.map(PlatformChunkGenerator::getEngine)
|
||||
.collect(Collectors.toMap(engine -> engine.getDimension().getLoadKey(), engine -> {
|
||||
var hash32 = engine.getHash32().getNow(null);
|
||||
if (hash32 == null) return Map.of();
|
||||
int version = engine.getDimension().getVersion();
|
||||
String checksum = Long.toHexString(hash32);
|
||||
|
||||
return Map.of("v" + version + " (" + checksum + ")", 1);
|
||||
}, (a, b) -> {
|
||||
|
||||
@@ -21,10 +21,10 @@ package com.volmit.iris.engine;
|
||||
import com.google.common.util.concurrent.AtomicDouble;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.ServerConfigurator;
|
||||
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
|
||||
import com.volmit.iris.core.gui.PregeneratorJob;
|
||||
import com.volmit.iris.core.loader.ResourceLoader;
|
||||
import com.volmit.iris.core.nms.container.BlockPos;
|
||||
import com.volmit.iris.core.nms.container.Pair;
|
||||
import com.volmit.iris.core.project.IrisProject;
|
||||
@@ -53,7 +53,6 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@@ -63,11 +62,10 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(exclude = "context")
|
||||
@@ -92,6 +90,7 @@ public class IrisEngine implements Engine {
|
||||
private final AtomicBoolean cleaning;
|
||||
private final ChronoLatch cleanLatch;
|
||||
private final SeedManager seedManager;
|
||||
private CompletableFuture<Long> hash32;
|
||||
private EngineMode mode;
|
||||
private EngineEffects effects;
|
||||
private EngineExecutionEnvironment execution;
|
||||
@@ -174,8 +173,17 @@ public class IrisEngine implements Engine {
|
||||
complex = new IrisComplex(this);
|
||||
execution = new IrisExecutionEnvironment(this);
|
||||
effects = new IrisEngineEffects(this);
|
||||
hash32 = new CompletableFuture<>();
|
||||
setupMode();
|
||||
J.a(this::computeBiomeMaxes);
|
||||
J.a(() -> {
|
||||
File[] roots = getData().getLoaders()
|
||||
.values()
|
||||
.stream()
|
||||
.map(ResourceLoader::getRoot)
|
||||
.toArray(File[]::new);
|
||||
hash32.complete(IO.hashRecursive(roots));
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
Iris.error("FAILED TO SETUP ENGINE!");
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -23,11 +23,12 @@ import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||
import com.volmit.iris.engine.mantle.MantleComponent;
|
||||
import com.volmit.iris.engine.mantle.components.*;
|
||||
import com.volmit.iris.engine.mantle.components.MantleCarvingComponent;
|
||||
import com.volmit.iris.engine.mantle.components.MantleFluidBodyComponent;
|
||||
import com.volmit.iris.engine.mantle.components.MantleJigsawComponent;
|
||||
import com.volmit.iris.engine.mantle.components.MantleObjectComponent;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import lombok.*;
|
||||
|
||||
@@ -57,7 +58,6 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
registerComponent(jigsaw);
|
||||
object = new MantleObjectComponent(this);
|
||||
registerComponent(object);
|
||||
registerComponent(new MantleStaticComponent(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,13 +23,11 @@ import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisDecorationPart;
|
||||
import com.volmit.iris.engine.object.IrisDecorator;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
import org.bukkit.block.data.type.PointedDripstone;
|
||||
|
||||
public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
@@ -43,7 +41,7 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
data.set(x, height, z, fixFaces(decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()), realX, height, realZ));
|
||||
data.set(x, height, z, fixFaces(decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()), data, x, z, realX, height, realZ));
|
||||
} else {
|
||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||
if (decorator.isScaleStack()) {
|
||||
@@ -97,24 +95,4 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BlockData fixFaces(BlockData b, int x, int y, int z) {
|
||||
if (B.isVineBlock(b)) {
|
||||
MultipleFacing data = (MultipleFacing) b.clone();
|
||||
boolean found = false;
|
||||
for (BlockFace f : BlockFace.values()) {
|
||||
if (!f.isCartesian())
|
||||
continue;
|
||||
Material m = getEngine().getMantle().get(x + f.getModX(), y + f.getModY(), z + f.getModZ()).getMaterial();
|
||||
if (m.isSolid()) {
|
||||
found = true;
|
||||
data.setFace(f, m.isSolid());
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
data.setFace(BlockFace.UP, true);
|
||||
return data;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,14 @@ import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisDecorationPart;
|
||||
import com.volmit.iris.engine.object.IrisDecorator;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockSupport;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
|
||||
public abstract class IrisEngineDecorator extends EngineAssignedComponent implements EngineDecorator {
|
||||
|
||||
@@ -65,4 +71,40 @@ public abstract class IrisEngineDecorator extends EngineAssignedComponent implem
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected BlockData fixFaces(BlockData b, Hunk<BlockData> hunk, int rX, int rZ, int x, int y, int z) {
|
||||
if (B.isVineBlock(b)) {
|
||||
MultipleFacing data = (MultipleFacing) b.clone();
|
||||
data.getFaces().forEach(f -> data.setFace(f, false));
|
||||
|
||||
boolean found = false;
|
||||
for (BlockFace f : BlockFace.values()) {
|
||||
if (!f.isCartesian())
|
||||
continue;
|
||||
int yy = y + f.getModY();
|
||||
|
||||
BlockData r = getEngine().getMantle().get(x + f.getModX(), yy, z + f.getModZ());
|
||||
if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) {
|
||||
found = true;
|
||||
data.setFace(f, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
int xx = rX + f.getModX();
|
||||
int zz = rZ + f.getModZ();
|
||||
if (xx < 0 || xx > 15 || zz < 0 || zz > 15 || yy < 0 || yy > hunk.getHeight())
|
||||
continue;
|
||||
|
||||
r = hunk.get(xx, yy, zz);
|
||||
if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) {
|
||||
found = true;
|
||||
data.setFace(f, true);
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
data.setFace(BlockFace.DOWN, true);
|
||||
return data;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
import org.bukkit.block.data.type.PointedDripstone;
|
||||
|
||||
public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
@@ -68,7 +67,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
if (decorator.getForceBlock() != null) {
|
||||
data.set(x, height, z, fixFaces(decorator.getForceBlock().getBlockData(getData()), x, height, z));
|
||||
data.set(x, height, z, fixFaces(decorator.getForceBlock().getBlockData(getData()), data, x, z, realX, height, realZ));
|
||||
} else if (!decorator.isForcePlace()) {
|
||||
if (decorator.getWhitelist() != null && decorator.getWhitelist().stream().noneMatch(d -> d.getBlockData(getData()).equals(bdx))) {
|
||||
return;
|
||||
@@ -91,7 +90,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
if (B.isAir(data.get(x, height + 1, z))) {
|
||||
data.set(x, height + 1, z, fixFaces(bd, x, height + 1, z));
|
||||
data.set(x, height + 1, z, fixFaces(bd, data, x, z, realX, height + 1, realZ));
|
||||
}
|
||||
} else {
|
||||
if (height < getDimension().getFluidHeight()) {
|
||||
@@ -158,24 +157,4 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BlockData fixFaces(BlockData b, int x, int y, int z) {
|
||||
if (B.isVineBlock(b)) {
|
||||
MultipleFacing data = (MultipleFacing) b.clone();
|
||||
boolean found = false;
|
||||
for (BlockFace f : BlockFace.values()) {
|
||||
if (!f.isCartesian())
|
||||
continue;
|
||||
Material m = getEngine().getMantle().get(x + f.getModX(), y + f.getModY(), z + f.getModZ()).getMaterial();
|
||||
if (m.isSolid()) {
|
||||
found = true;
|
||||
data.setFace(f, m.isSolid());
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
data.setFace(BlockFace.UP, true);
|
||||
return data;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ import java.awt.Color;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@@ -611,6 +612,8 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
int getGenerated();
|
||||
|
||||
CompletableFuture<Long> getHash32();
|
||||
|
||||
default <T> IrisPosition lookForStreamResult(T find, ProceduralStream<T> stream, Function2<T, T, Boolean> matcher, long timeout) {
|
||||
AtomicInteger checked = new AtomicInteger();
|
||||
AtomicLong time = new AtomicLong(M.ms());
|
||||
@@ -826,13 +829,6 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
return new PlacedObject(piece.getPlacementOptions(), getData().getObjectLoader().load(object), id, x, z);
|
||||
}
|
||||
|
||||
for (var staticPlacement : getDimension().getStaticPlacements().getObjects()) {
|
||||
IrisObjectPlacement i = staticPlacement.placement();
|
||||
if (i.getPlace().contains(object)) {
|
||||
return new PlacedObject(i, getData().getObjectLoader().load(object), id, x, z);
|
||||
}
|
||||
}
|
||||
|
||||
IrisRegion region = getRegion(x, z);
|
||||
|
||||
for (IrisObjectPlacement i : region.getObjects()) {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package com.volmit.iris.engine.mantle.components;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||
import com.volmit.iris.engine.mantle.IrisMantleComponent;
|
||||
@@ -40,13 +39,11 @@ import com.volmit.iris.util.matter.MatterStructurePOI;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
import com.volmit.iris.util.noise.NoiseType;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -165,67 +162,99 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
private int computeRadius() {
|
||||
var dimension = getDimension();
|
||||
|
||||
AtomicInteger xg = new AtomicInteger();
|
||||
AtomicInteger zg = new AtomicInteger();
|
||||
|
||||
KSet<String> objects = new KSet<>();
|
||||
KMap<IrisObjectScale, KList<String>> scalars = new KMap<>();
|
||||
for (var region : dimension.getAllRegions(this::getData)) {
|
||||
for (var placement : region.getObjects()) {
|
||||
if (placement.getScale().canScaleBeyond()) {
|
||||
scalars.put(placement.getScale(), placement.getPlace());
|
||||
for (var j : region.getObjects()) {
|
||||
if (j.getScale().canScaleBeyond()) {
|
||||
scalars.put(j.getScale(), j.getPlace());
|
||||
} else {
|
||||
objects.addAll(placement.getPlace());
|
||||
objects.addAll(j.getPlace());
|
||||
}
|
||||
}
|
||||
|
||||
for (var biome : region.getAllBiomes(this::getData)) {
|
||||
for (var placement : biome.getObjects()) {
|
||||
if (placement.getScale().canScaleBeyond()) {
|
||||
scalars.put(placement.getScale(), placement.getPlace());
|
||||
} else {
|
||||
objects.addAll(placement.getPlace());
|
||||
}
|
||||
}
|
||||
for (var biome : dimension.getAllBiomes(this::getData)) {
|
||||
for (var j : biome.getObjects()) {
|
||||
if (j.getScale().canScaleBeyond()) {
|
||||
scalars.put(j.getScale(), j.getPlace());
|
||||
} else {
|
||||
objects.addAll(j.getPlace());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return computeObjectRadius(objects, scalars, getEngineMantle().getTarget().getBurster(), getData());
|
||||
}
|
||||
|
||||
static int computeObjectRadius(KSet<String> objects, KMap<IrisObjectScale, KList<String>> scalars, MultiBurst burst, IrisData data) {
|
||||
AtomicInteger x = new AtomicInteger();
|
||||
AtomicInteger z = new AtomicInteger();
|
||||
|
||||
BurstExecutor e = burst.burst(objects.size());
|
||||
BurstExecutor e = getEngineMantle().getTarget().getBurster().burst(objects.size());
|
||||
KMap<String, BlockVector> sizeCache = new KMap<>();
|
||||
for (String loadKey : objects) {
|
||||
for (String i : objects) {
|
||||
e.queue(() -> {
|
||||
try {
|
||||
BlockVector bv = sampleSize(sizeCache, data, loadKey);
|
||||
BlockVector bv = sizeCache.computeIfAbsent(i, (k) -> {
|
||||
try {
|
||||
return IrisObject.sampleSize(getData().getObjectLoader().findFile(i));
|
||||
} catch (IOException ex) {
|
||||
Iris.reportError(ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
if (Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) {
|
||||
Iris.warn("Object " + loadKey + " has a large size (" + bv + ") and may increase memory usage!");
|
||||
return null;
|
||||
});
|
||||
|
||||
if (bv == null) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
x.getAndUpdate(i -> Math.max(bv.getBlockX(), i));
|
||||
z.getAndUpdate(i -> Math.max(bv.getBlockZ(), i));
|
||||
if (Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) {
|
||||
Iris.warn("Object " + i + " has a large size (" + bv + ") and may increase memory usage!");
|
||||
}
|
||||
|
||||
synchronized (xg) {
|
||||
xg.getAndSet(Math.max(bv.getBlockX(), xg.get()));
|
||||
}
|
||||
|
||||
synchronized (zg) {
|
||||
zg.getAndSet(Math.max(bv.getBlockZ(), zg.get()));
|
||||
}
|
||||
} catch (Throwable ed) {
|
||||
Iris.reportError(ed);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (Map.Entry<IrisObjectScale, KList<String>> entry : scalars.entrySet()) {
|
||||
double ms = entry.getKey().getMaximumScale();
|
||||
for (String loadKey : entry.getValue()) {
|
||||
for (String j : entry.getValue()) {
|
||||
e.queue(() -> {
|
||||
try {
|
||||
BlockVector bv = sampleSize(sizeCache, data, loadKey);
|
||||
BlockVector bv = sizeCache.computeIfAbsent(j, (k) -> {
|
||||
try {
|
||||
return IrisObject.sampleSize(getData().getObjectLoader().findFile(j));
|
||||
} catch (IOException ioException) {
|
||||
Iris.reportError(ioException);
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
|
||||
if (Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) {
|
||||
Iris.warn("Object " + loadKey + " has a large size (" + bv + ") and may increase memory usage! (Object scaled up to " + Form.pc(ms, 2) + ")");
|
||||
return null;
|
||||
});
|
||||
|
||||
if (bv == null) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
x.getAndUpdate(i -> (int) Math.max(Math.ceil(bv.getBlockX() * ms), i));
|
||||
x.getAndUpdate(i -> (int) Math.max(Math.ceil(bv.getBlockZ() * ms), i));
|
||||
if (Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) {
|
||||
Iris.warn("Object " + j + " has a large size (" + bv + ") and may increase memory usage! (Object scaled up to " + Form.pc(ms, 2) + ")");
|
||||
}
|
||||
|
||||
synchronized (xg) {
|
||||
xg.getAndSet((int) Math.max(Math.ceil(bv.getBlockX() * ms), xg.get()));
|
||||
}
|
||||
|
||||
synchronized (zg) {
|
||||
zg.getAndSet((int) Math.max(Math.ceil(bv.getBlockZ() * ms), zg.get()));
|
||||
}
|
||||
} catch (Throwable ee) {
|
||||
Iris.reportError(ee);
|
||||
|
||||
@@ -235,20 +264,6 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
}
|
||||
|
||||
e.complete();
|
||||
return Math.max(x.get(), z.get());
|
||||
}
|
||||
|
||||
private static BlockVector sampleSize(KMap<String, BlockVector> sizeCache, IrisData data, String loadKey) {
|
||||
BlockVector bv = sizeCache.computeIfAbsent(loadKey, (k) -> {
|
||||
try {
|
||||
return IrisObject.sampleSize(data.getObjectLoader().findFile(loadKey));
|
||||
} catch (IOException ioException) {
|
||||
Iris.reportError(ioException);
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
return Objects.requireNonNull(bv, "sampleSize returned a null block vector");
|
||||
return Math.max(xg.get(), zg.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.volmit.iris.engine.mantle.components;
|
||||
|
||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||
import com.volmit.iris.engine.mantle.IrisMantleComponent;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.engine.object.IrisObjectScale;
|
||||
import com.volmit.iris.engine.object.IrisStaticPlacement;
|
||||
import com.volmit.iris.engine.object.NoiseStyle;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
import lombok.Getter;
|
||||
|
||||
public class MantleStaticComponent extends IrisMantleComponent {
|
||||
private final CNG cng;
|
||||
@Getter
|
||||
private final int radius = computeRadius();
|
||||
|
||||
public MantleStaticComponent(EngineMantle engineMantle) {
|
||||
super(engineMantle, MantleFlag.STATIC, 1);
|
||||
cng = NoiseStyle.STATIC.create(new RNG(seed()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||
RNG rng = new RNG(cng.fit(Integer.MIN_VALUE, Integer.MAX_VALUE, x, z));
|
||||
for (IrisStaticPlacement placement : getDimension().getStaticPlacements().getAll(x, z)) {
|
||||
placement.place(writer, rng, getData());
|
||||
}
|
||||
}
|
||||
|
||||
private int computeRadius() {
|
||||
var placements = getDimension().getStaticPlacements();
|
||||
|
||||
KSet<String> objects = new KSet<>();
|
||||
KMap<IrisObjectScale, KList<String>> scalars = new KMap<>();
|
||||
for (var staticPlacement : placements.getObjects()) {
|
||||
var placement = staticPlacement.placement();
|
||||
if (placement.getScale().canScaleBeyond()) {
|
||||
scalars.put(placement.getScale(), placement.getPlace());
|
||||
} else {
|
||||
objects.addAll(placement.getPlace());
|
||||
}
|
||||
}
|
||||
|
||||
int jigsaw = placements.getStructures()
|
||||
.stream()
|
||||
.mapToInt(staticPlacement -> staticPlacement.maxDimension(getData()))
|
||||
.max()
|
||||
.orElse(0);
|
||||
int object = MantleObjectComponent.computeObjectRadius(objects, scalars, getEngineMantle().getTarget().getBurster(), getData());
|
||||
|
||||
return Math.max(jigsaw, object);
|
||||
}
|
||||
}
|
||||
@@ -211,14 +211,6 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
|
||||
biome.setInferredType(InferredType.CAVE);
|
||||
|
||||
for (IrisDecorator i : biome.getDecorators()) {
|
||||
if (i.getPartOf().equals(IrisDecorationPart.NONE) && B.isSolid(output.get(rx, zone.getFloor() - 1, rz))) {
|
||||
decorant.getSurfaceDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getFloor() - 1, zone.airThickness());
|
||||
} else if (i.getPartOf().equals(IrisDecorationPart.CEILING) && B.isSolid(output.get(rx, zone.getCeiling() + 1, rz))) {
|
||||
decorant.getCeilingDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getCeiling(), zone.airThickness());
|
||||
}
|
||||
}
|
||||
|
||||
KList<BlockData> blocks = biome.generateLayers(getDimension(), xx, zz, rng, 3, zone.floor, getData(), getComplex());
|
||||
|
||||
for (int i = 0; i < zone.floor - 1; i++) {
|
||||
@@ -260,6 +252,14 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
output.set(rx, zone.ceiling + i + 1, rz, b);
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisDecorator i : biome.getDecorators()) {
|
||||
if (i.getPartOf().equals(IrisDecorationPart.NONE) && B.isSolid(output.get(rx, zone.getFloor() - 1, rz))) {
|
||||
decorant.getSurfaceDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getFloor() - 1, zone.airThickness());
|
||||
} else if (i.getPartOf().equals(IrisDecorationPart.CEILING) && B.isSolid(output.get(rx, zone.getCeiling() + 1, rz))) {
|
||||
decorant.getCeilingDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getCeiling(), zone.airThickness());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -310,8 +310,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@MaxNumber(318)
|
||||
@Desc("The Subterrain Fluid Layer Height")
|
||||
private int caveLavaHeight = 8;
|
||||
@Desc("Static Placements for objects and structures")
|
||||
private IrisStaticPlacements staticPlacements = new IrisStaticPlacements();
|
||||
|
||||
public int getMaxHeight() {
|
||||
return (int) getDimensionHeight().getMax();
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.data.IrisBlockData;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterStructurePOI;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Desc("Static Object Placement")
|
||||
@Accessors(chain = true, fluent = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class IrisStaticObjectPlacement implements IrisStaticPlacement {
|
||||
@Required
|
||||
@Desc("The X coordinate to spawn the object at")
|
||||
private int x = 0;
|
||||
@Required
|
||||
@Desc("The Y coordinate to spawn the object at\nuse a value <0 to allow the placement modes to function")
|
||||
private int y = 0;
|
||||
@Required
|
||||
@Desc("The Z coordinate to spawn the object at")
|
||||
private int z = 0;
|
||||
@Required
|
||||
@Desc("The object placement to use")
|
||||
private IrisObjectPlacement placement;
|
||||
|
||||
@Override
|
||||
public void place(MantleWriter writer, RNG rng, IrisData irisData) {
|
||||
IrisObject v = placement.getScale().get(rng, placement.getObject(() -> irisData, rng));
|
||||
if (v == null) return;
|
||||
|
||||
v.place(x, y, z, writer, placement, rng, irisData);
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
v.place(x, y, z, writer, placement, rng, (b, data) -> {
|
||||
writer.setData(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id);
|
||||
if (placement.isDolphinTarget() && placement.isUnderwater() && B.isStorageChest(data)) {
|
||||
writer.setData(b.getX(), b.getY(), b.getZ(), MatterStructurePOI.BURIED_TREASURE);
|
||||
}
|
||||
if (data instanceof IrisBlockData d) {
|
||||
writer.setData(b.getX(), b.getY(), b.getZ(), d.getCustom());
|
||||
}
|
||||
}, null, irisData);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
|
||||
public interface IrisStaticPlacement {
|
||||
int x();
|
||||
int y();
|
||||
int z();
|
||||
|
||||
@ChunkCoordinates
|
||||
default boolean shouldPlace(int chunkX, int chunkZ) {
|
||||
return x() >> 4 == chunkX && z() >> 4 == chunkZ;
|
||||
}
|
||||
|
||||
void place(MantleWriter writer, RNG rng, IrisData data);
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Static Placements")
|
||||
@Data
|
||||
public class IrisStaticPlacements {
|
||||
@Desc("List of static jigsaw structures")
|
||||
@ArrayType(type = IrisStaticStructurePlacement.class)
|
||||
private KList<IrisStaticStructurePlacement> structures = new KList<>();
|
||||
|
||||
@Desc("List of static objects")
|
||||
@ArrayType(type = IrisStaticObjectPlacement.class)
|
||||
private KList<IrisStaticObjectPlacement> objects = new KList<>();
|
||||
|
||||
@ChunkCoordinates
|
||||
public KList<IrisStaticStructurePlacement> getStructures(int chunkX, int chunkZ) {
|
||||
return filter(structures.stream(), chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
public KList<IrisStaticObjectPlacement> getObjects(int chunkX, int chunkZ) {
|
||||
return filter(objects.stream(), chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
public KList<IrisStaticPlacement> getAll(int chunkX, int chunkZ) {
|
||||
return filter(Stream.concat(structures.stream(), objects.stream()), chunkX, chunkZ);
|
||||
}
|
||||
|
||||
private <T extends IrisStaticPlacement> KList<T> filter(Stream<T> stream, int chunkX, int chunkZ) {
|
||||
return stream.filter(p -> p.shouldPlace(chunkX, chunkZ))
|
||||
.collect(Collectors.toCollection(KList::new));
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.jigsaw.PlannedStructure;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Desc("Static Jigsaw Structure Placement")
|
||||
@Accessors(chain = true, fluent = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class IrisStaticStructurePlacement implements IrisStaticPlacement {
|
||||
@Required
|
||||
@Desc("The X coordinate to spawn the structure at")
|
||||
private int x = 0;
|
||||
@Required
|
||||
@Desc("The Y coordinate to spawn the structure at")
|
||||
private int y = 0;
|
||||
@Required
|
||||
@Desc("The Z coordinate to spawn the structure at")
|
||||
private int z = 0;
|
||||
@Required
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@RegistryListResource(IrisJigsawStructure.class)
|
||||
@Desc("The structures to place")
|
||||
private KList<String> structures;
|
||||
|
||||
public int maxDimension(IrisData data) {
|
||||
return data.getJigsawStructureLoader().loadAll(structures)
|
||||
.stream()
|
||||
.mapToInt(IrisJigsawStructure::getMaxDimension)
|
||||
.max()
|
||||
.orElse(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(MantleWriter writer, RNG rng, IrisData data) {
|
||||
IrisJigsawStructure jigsaw = null;
|
||||
while (jigsaw == null && !structures.isEmpty()) {
|
||||
String loadKey = structures.popRandom(rng);
|
||||
jigsaw = data.getJigsawStructureLoader().load(loadKey);
|
||||
|
||||
if (jigsaw == null)
|
||||
Iris.error("Jigsaw structure not found " + loadKey);
|
||||
}
|
||||
if (jigsaw == null) {
|
||||
Iris.error("No jigsaw structure found for " + structures);
|
||||
return;
|
||||
}
|
||||
|
||||
new PlannedStructure(jigsaw, new IrisPosition(x, y, z), rng, false)
|
||||
.place(writer, writer.getMantle(), writer.getEngine());
|
||||
}
|
||||
}
|
||||
@@ -487,7 +487,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
return pop();
|
||||
}
|
||||
|
||||
return remove(rng.i(0, size()));
|
||||
return remove(rng.i(0, last()));
|
||||
}
|
||||
|
||||
public KList<T> sub(int f, int t) {
|
||||
|
||||
@@ -111,10 +111,12 @@ public class IO {
|
||||
return "¯\\_(ツ)_/¯";
|
||||
}
|
||||
|
||||
public static String hashRecursive(File base) {
|
||||
public static long hashRecursive(File... bases) {
|
||||
LinkedList<File> files = new LinkedList<>();
|
||||
Set<File> processed = new HashSet<>();
|
||||
files.add(base);
|
||||
Arrays.parallelSort(bases, Comparator.comparing(File::getName));
|
||||
files.addAll(Arrays.asList(bases));
|
||||
|
||||
try {
|
||||
CRC32 crc = new CRC32();
|
||||
while (!files.isEmpty()) {
|
||||
@@ -141,13 +143,13 @@ public class IO {
|
||||
}
|
||||
}
|
||||
|
||||
return Long.toHexString(crc.getValue());
|
||||
return crc.getValue();
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "";
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static String hash(File b) {
|
||||
|
||||
@@ -35,8 +35,7 @@ public enum MantleFlag {
|
||||
ETCHED,
|
||||
TILE,
|
||||
CUSTOM,
|
||||
DISCOVERED,
|
||||
STATIC;
|
||||
DISCOVERED;
|
||||
|
||||
static StateList getStateList() {
|
||||
return new StateList(MantleFlag.values());
|
||||
|
||||
Reference in New Issue
Block a user