mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Fix gen crash
This commit is contained in:
parent
5de5b6047a
commit
19dca8c5bb
@ -55,9 +55,10 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class EngineCompositeGenerator extends ChunkGenerator implements IrisAccess {
|
public class EngineCompositeGenerator extends ChunkGenerator implements IrisAccess {
|
||||||
private EngineCompound compound = null;
|
private final AtomicReference<EngineCompound> compound = new AtomicReference<>();
|
||||||
private final AtomicBoolean initialized;
|
private final AtomicBoolean initialized;
|
||||||
private final String dimensionQuery;
|
private final String dimensionQuery;
|
||||||
private final boolean production;
|
private final boolean production;
|
||||||
@ -91,7 +92,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||||
if (compound != null) {
|
if (compound != null) {
|
||||||
for (BlockPopulator i : compound.getPopulators()) {
|
for (BlockPopulator i : compound.get().getPopulators()) {
|
||||||
i.populate(world, random, chunk);
|
i.populate(world, random, chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,7 +108,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
try {
|
try {
|
||||||
for (Player i : getTarget().getWorld().getPlayers()) {
|
for (Player i : getTarget().getWorld().getPlayers()) {
|
||||||
new MortarSender(i, Iris.instance.getTag()).sendMessage("Dimension Hotloaded");
|
new MortarSender(i, Iris.instance.getTag()).sendMessage("Dimension Hotloaded");
|
||||||
i.playSound(i.getLocation(), Sound.BLOCK_BEACON_ACTIVATE, 1f, 1.25f);
|
i.playSound(i.getLocation(), Sound.BLOCK_BEACON_POWER_SELECT, 1f, 1.25f);
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {Iris.reportError(e);
|
} catch (Throwable e) {Iris.reportError(e);
|
||||||
|
|
||||||
@ -282,7 +283,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
public synchronized void initialize(World world) {
|
public synchronized void initialize(World world) {
|
||||||
if (!(world instanceof FakeWorld) && fake.get() && this.compound != null) {
|
if (!(world instanceof FakeWorld) && fake.get() && this.compound != null) {
|
||||||
fake.set(false);
|
fake.set(false);
|
||||||
this.compound.updateWorld(world);
|
this.compound.get().updateWorld(world);
|
||||||
getTarget().updateWorld(world);
|
getTarget().updateWorld(world);
|
||||||
placeStrongholds(world);
|
placeStrongholds(world);
|
||||||
|
|
||||||
@ -301,10 +302,10 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
initialized.set(true);
|
initialized.set(true);
|
||||||
IrisDimension dim = getDimension(world);
|
IrisDimension dim = getDimension(world);
|
||||||
IrisDataManager data = production ? new IrisDataManager(getDataFolder(world)) : dim.getLoader().copy();
|
IrisDataManager data = production ? new IrisDataManager(getDataFolder(world)) : dim.getLoader().copy();
|
||||||
compound = new IrisEngineCompound(world, dim, data, Iris.getThreadCount());
|
compound.set(new IrisEngineCompound(world, dim, data, Iris.getThreadCount()));
|
||||||
compound.setStudio(!production);
|
compound.get().setStudio(!production);
|
||||||
populators.clear();
|
populators.clear();
|
||||||
populators.addAll(compound.getPopulators());
|
populators.addAll(compound.get().getPopulators());
|
||||||
hotloader = new ReactiveFolder(data.getDataFolder(), (a, c, d) -> hotload());
|
hotloader = new ReactiveFolder(data.getDataFolder(), (a, c, d) -> hotload());
|
||||||
dim.installDataPack(() -> data, Iris.instance.getDatapacksFolder());
|
dim.installDataPack(() -> data, Iris.instance.getDatapacksFolder());
|
||||||
} catch (Throwable e) {Iris.reportError(e);
|
} catch (Throwable e) {Iris.reportError(e);
|
||||||
@ -438,9 +439,9 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) {
|
public ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) {
|
||||||
long key = Cache.key(x, z);
|
|
||||||
TerrainChunk tc = TerrainChunk.create(world, biome);
|
TerrainChunk tc = TerrainChunk.create(world, biome);
|
||||||
generateChunkRawData(world, x, z, tc).run();
|
generateChunkRawData(world, x, z, tc).run();
|
||||||
|
generated++;
|
||||||
return tc.getRaw();
|
return tc.getRaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,7 +609,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
}
|
}
|
||||||
|
|
||||||
PregeneratedData data = new PregeneratedData(getComposite().getHeight() - 1);
|
PregeneratedData data = new PregeneratedData(getComposite().getHeight() - 1);
|
||||||
compound.generate(x * 16, z * 16, data.getBlocks(), data.getPost(), data.getBiomes());
|
compound.get().generate(x * 16, z * 16, data.getBlocks(), data.getPost(), data.getBiomes());
|
||||||
synchronized (chunkCache) {
|
synchronized (chunkCache) {
|
||||||
chunkCache.put(Cache.key(x, z), data);
|
chunkCache.put(Cache.key(x, z), data);
|
||||||
}
|
}
|
||||||
@ -629,7 +630,6 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
synchronized (chunkCache) {
|
synchronized (chunkCache) {
|
||||||
long g = Cache.key(x, z);
|
long g = Cache.key(x, z);
|
||||||
if (chunkCache.containsKey(g)) {
|
if (chunkCache.containsKey(g)) {
|
||||||
generated++;
|
|
||||||
return chunkCache.remove(g).inject(tc);
|
return chunkCache.remove(g).inject(tc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -637,8 +637,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
||||||
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
||||||
Hunk<BlockData> post = Hunk.newAtomicHunk(biomes.getWidth(), biomes.getHeight(), biomes.getDepth());
|
Hunk<BlockData> post = Hunk.newAtomicHunk(biomes.getWidth(), biomes.getHeight(), biomes.getDepth());
|
||||||
compound.generate(x * 16, z * 16, blocks, post, biomes);
|
compound.get().generate(x * 16, z * 16, blocks, post, biomes);
|
||||||
generated++;
|
|
||||||
|
|
||||||
return () -> blocks.insertSoftly(0, 0, 0, post, (b) -> b == null || B.isAirOrFluid(b));
|
return () -> blocks.insertSoftly(0, 0, 0, post, (b) -> b == null || B.isAirOrFluid(b));
|
||||||
}
|
}
|
||||||
@ -698,7 +697,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EngineCompound getComposite() {
|
public EngineCompound getComposite() {
|
||||||
return compound;
|
return compound.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -822,14 +821,14 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
@Override
|
@Override
|
||||||
public void setBlock(int x, int y, int z, BlockData blockData) {
|
public void setBlock(int x, int y, int z, BlockData blockData) {
|
||||||
if (!getBlockData(x, y, z).matches(blockData)) {
|
if (!getBlockData(x, y, z).matches(blockData)) {
|
||||||
Iris.edit.set(compound.getWorld(), x + xx, y, z + zz, blockData);
|
Iris.edit.set(compound.get().getWorld(), x + xx, y, z + zz, blockData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public BlockData getBlockData(int x, int y, int z) {
|
public BlockData getBlockData(int x, int y, int z) {
|
||||||
return Iris.edit.get(compound.getWorld(), x + xx, y, z + zz);
|
return Iris.edit.get(compound.get().getWorld(), x + xx, y, z + zz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user