mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
Insert tile entity support
This commit is contained in:
parent
c290dba3bb
commit
d561348c4f
@ -442,6 +442,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}).run();
|
}).run();
|
||||||
|
|
||||||
writer.optimizeChunk(x, z);
|
writer.optimizeChunk(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +120,24 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
return queue.size();
|
return queue.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default void insertTileEntities(int x, int z, Consumer4<Integer, Integer, Integer, TileData<? extends TileState>> consumer)
|
||||||
|
{
|
||||||
|
ParallaxChunkMeta meta = getParallaxAccess().getMetaRW(x >> 4, z >> 4);
|
||||||
|
|
||||||
|
if (meta.isTilesGenerated()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
meta.setTilesGenerated(true);
|
||||||
|
|
||||||
|
getParallaxAccess().getTilesRW(x>>4, z>>4).iterateSync((a,b,c,d) -> {
|
||||||
|
if(d != null)
|
||||||
|
{
|
||||||
|
consumer.accept(a,b,c,d);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
default void insertParallax(int x, int z, Hunk<BlockData> data) {
|
default void insertParallax(int x, int z, Hunk<BlockData> data) {
|
||||||
try {
|
try {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
@ -135,17 +153,12 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = x; i < x + data.getWidth(); i++) {
|
getParallaxAccess().getBlocksR(x>>4,z>>4).iterateSync((a,b,c,d) -> {
|
||||||
for (int j = z; j < z + data.getDepth(); j++) {
|
if(d != null)
|
||||||
for (int k = Math.max(0, meta.getMinObject() - 16); k < Math.min(getEngine().getHeight(), meta.getMaxObject() + 16); k++) {
|
{
|
||||||
BlockData d = getParallaxAccess().getBlock(i, k, j);
|
data.set(a, b, c, d);
|
||||||
|
|
||||||
if (d != null) {
|
|
||||||
data.set(i - x, k, j - z, d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
getEngine().getMetrics().getParallaxInsert().put(p.getMilliseconds());
|
getEngine().getMetrics().getParallaxInsert().put(p.getMilliseconds());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
@ -170,21 +183,23 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
for (j = -s; j <= s; j++) {
|
for (j = -s; j <= s; j++) {
|
||||||
ParallaxChunkMeta m = getParallaxAccess().getMetaR(i + cx, j + cz);
|
ParallaxChunkMeta m = getParallaxAccess().getMetaR(i + cx, j + cz);
|
||||||
|
|
||||||
synchronized (m.getFeatures())
|
try
|
||||||
{
|
{
|
||||||
try
|
synchronized (m.getFeatures())
|
||||||
{
|
{
|
||||||
for (IrisFeaturePositional k : m.getFeatures()) {
|
for(IrisFeaturePositional k : m.getFeatures())
|
||||||
|
{
|
||||||
if (k.shouldFilter(x, z)) {
|
if (k.shouldFilter(x, z)) {
|
||||||
f.accept(k);
|
f.accept(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
{
|
{
|
||||||
Iris.warn("Failed to read positional features in chunk " + (i + cx) + " " + (j + cz) + "(" + e.getClass().getSimpleName() + ")");
|
e.printStackTrace();
|
||||||
}
|
Iris.warn("Failed to read positional features in chunk " + (i + cx) + " " + (j + cz) + "(" + e.getClass().getSimpleName() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,36 +214,56 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
int s = (int) Math.ceil(getParallaxSize() / 2D);
|
int s = (int) Math.ceil(getParallaxSize() / 2D);
|
||||||
int i,j;
|
int i,j;
|
||||||
KList<Runnable> after = new KList<>();
|
KList<Runnable> after = new KList<>();
|
||||||
|
int bs = (int) Math.pow((s * 2) + 1, 2);
|
||||||
|
BurstExecutor burst = MultiBurst.burst.burst(bs);
|
||||||
for (i = -s; i <= s; i++) {
|
for (i = -s; i <= s; i++) {
|
||||||
for (j = -s; j <= s; j++) {
|
for (j = -s; j <= s; j++) {
|
||||||
int xx = i +x;
|
int xx = i +x;
|
||||||
int zz = j +z;
|
int zz = j +z;
|
||||||
int xxx = xx << 4;
|
int xxx = xx << 4;
|
||||||
int zzz = zz << 4;
|
int zzz = zz << 4;
|
||||||
|
|
||||||
if (!getParallaxAccess().isFeatureGenerated(xx, zz)){
|
if (!getParallaxAccess().isFeatureGenerated(xx, zz)){
|
||||||
getParallaxAccess().setFeatureGenerated(xx, zz);
|
burst.queue(() -> {
|
||||||
RNG rng = new RNG(Cache.key(xx, zz)).nextParallelRNG(getEngine().getTarget().getWorld().getSeed());
|
getParallaxAccess().setFeatureGenerated(xx, zz);
|
||||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
RNG rng = new RNG(Cache.key(xx, zz)).nextParallelRNG(getEngine().getTarget().getWorld().getSeed());
|
||||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||||
generateParallaxFeatures(rng, xx, zz, region, biome);
|
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
||||||
|
generateParallaxFeatures(rng, xx, zz, region, biome);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
burst.complete();
|
||||||
|
burst = MultiBurst.burst.burst(bs);
|
||||||
|
|
||||||
for (i = -s; i <= s; i++) {
|
for (i = -s; i <= s; i++) {
|
||||||
|
int ii = i;
|
||||||
for (j = -s; j <= s; j++) {
|
for (j = -s; j <= s; j++) {
|
||||||
after.addAll(generateParallaxVacuumLayer(i +x, j +z));
|
int jj = j;
|
||||||
|
burst.queue(() -> {
|
||||||
|
KList<Runnable> a = generateParallaxVacuumLayer(ii +x, jj +z);
|
||||||
|
synchronized (a)
|
||||||
|
{
|
||||||
|
after.addAll(a);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
burst.complete();
|
||||||
|
burst = MultiBurst.burst.burst(bs);
|
||||||
|
|
||||||
for (i = -s; i <= s; i++) {
|
for (i = -s; i <= s; i++) {
|
||||||
|
int ii = i;
|
||||||
for (j = -s; j <= s; j++) {
|
for (j = -s; j <= s; j++) {
|
||||||
generateParallaxLayer(i +x, j +z);
|
int jj = j;
|
||||||
|
burst.queue(() -> generateParallaxLayer(ii +x, jj +z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
after.forEach(Runnable::run);
|
burst.complete();
|
||||||
|
MultiBurst.burst.burst(after);
|
||||||
getParallaxAccess().setChunkGenerated(x, z);
|
getParallaxAccess().setChunkGenerated(x, z);
|
||||||
p.end();
|
p.end();
|
||||||
getEngine().getMetrics().getParallax().put(p.getMilliseconds());
|
getEngine().getMetrics().getParallax().put(p.getMilliseconds());
|
||||||
@ -470,9 +505,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
f.setInterpolationRadius(a/4);
|
f.setInterpolationRadius(a/4);
|
||||||
f.setInterpolator(InterpolationMethod.BILINEAR_STARCAST_9);
|
f.setInterpolator(InterpolationMethod.BILINEAR_STARCAST_9);
|
||||||
f.setStrength(1D);
|
f.setStrength(1D);
|
||||||
getParallaxAccess().getMetaRW(xx>>4, zz>>4)
|
getParallaxAccess().getMetaRW(xx>>4, zz>>4).getFeatures().add(new IrisFeaturePositional(xx, zz, f));
|
||||||
.getFeatures()
|
|
||||||
.add(new IrisFeaturePositional(xx, zz, f));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,9 +544,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
f.setInterpolationRadius(a/4);
|
f.setInterpolationRadius(a/4);
|
||||||
f.setInterpolator(InterpolationMethod.BILINEAR_STARCAST_9);
|
f.setInterpolator(InterpolationMethod.BILINEAR_STARCAST_9);
|
||||||
f.setStrength(1D);
|
f.setStrength(1D);
|
||||||
getParallaxAccess().getMetaRW(xx>>4, zz>>4)
|
getParallaxAccess().getMetaRW(xx>>4, zz>>4).getFeatures().add(new IrisFeaturePositional(xx, zz, f));
|
||||||
.getFeatures()
|
|
||||||
.add(new IrisFeaturePositional(xx, zz, f));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -533,8 +564,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
meta.setMinObject(Math.min(minY, Math.max(meta.getMinObject(), 0)));
|
meta.setMinObject(Math.min(minY, Math.max(meta.getMinObject(), 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
default int computeParallaxSize()
|
default int computeParallaxSize() {
|
||||||
{
|
|
||||||
Iris.verbose("Calculating the Parallax Size in Parallel");
|
Iris.verbose("Calculating the Parallax Size in Parallel");
|
||||||
AtomicInteger xg = new AtomicInteger(0);
|
AtomicInteger xg = new AtomicInteger(0);
|
||||||
AtomicInteger zg = new AtomicInteger();
|
AtomicInteger zg = new AtomicInteger();
|
||||||
@ -545,17 +575,39 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
KList<IrisRegion> r = getAllRegions();
|
KList<IrisRegion> r = getAllRegions();
|
||||||
KList<IrisBiome> b = getAllBiomes();
|
KList<IrisBiome> b = getAllBiomes();
|
||||||
|
|
||||||
for(IrisBiome i : b)
|
for (IrisBiome i : b) {
|
||||||
{
|
for (IrisObjectPlacement j : i.getObjects()) {
|
||||||
for(IrisObjectPlacement j : i.getObjects())
|
|
||||||
{
|
|
||||||
objects.addAll(j.getPlace());
|
objects.addAll(j.getPlace());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (IrisJigsawStructurePlacement j : i.getJigsawStructures()) {
|
||||||
|
jig = Math.max(jig, getData().getJigsawStructureLoader().load(j.getStructure()).getMaxDimension());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (IrisRegion i : r)
|
||||||
|
{
|
||||||
for(IrisJigsawStructurePlacement j : i.getJigsawStructures())
|
for(IrisJigsawStructurePlacement j : i.getJigsawStructures())
|
||||||
{
|
{
|
||||||
jig = Math.max(jig, getData().getJigsawStructureLoader().load(j.getStructure()).getMaxDimension());
|
jig = Math.max(jig, getData().getJigsawStructureLoader().load(j.getStructure()).getMaxDimension());
|
||||||
Iris.info("Jig -> " + jig);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(IrisJigsawStructurePlacement j : getEngine().getDimension().getJigsawStructures())
|
||||||
|
{
|
||||||
|
jig = Math.max(jig, getData().getJigsawStructureLoader().load(j.getStructure()).getMaxDimension());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(getEngine().getDimension().getStronghold() != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jig = Math.max(jig, getData().getJigsawStructureLoader().load(getEngine().getDimension().getStronghold()).getMaxDimension());
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user