9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 19:49:06 +00:00

Mid changes - SYNC

This commit is contained in:
RePixelatedMC
2024-09-30 08:19:00 +02:00
parent 7c6df58c15
commit ff0a68c4f6
3 changed files with 106 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
@@ -11,6 +12,7 @@ import com.volmit.iris.util.math.RollingSequence;
import com.volmit.iris.util.scheduling.ChronoLatch;
import org.bukkit.World;
import org.bukkit.plugin.Plugin;
import org.bukkit.block.Biome;
import java.io.File;
import java.util.concurrent.*;
@@ -117,7 +119,6 @@ public class IrisBiomeFixer {
for (int x = 0; x < 16; x += 4) {
for (int z = 0; z < 16; z += 4) {
for (int y = minY; y < maxY; y += 4) {
// Calculate the biome once per 4x4x4 block
int realX = chunkX * 16 + x;
int realZ = chunkZ * 16 + z;
int realY = y;
@@ -129,8 +130,13 @@ public class IrisBiomeFixer {
biomeHolder = INMS.get().getCustomBiomeBaseHolderFor(
engine.getDimension().getLoadKey() + ":" + biome.getCustomBiome(rng, realX, realY, realZ).getId());
} else {
// Handle non-custom biome if necessary
// biomeHolder = INMS.get().getCustomBiomeBaseHolderFor(biome.getDerivative().getKey().getKey());
Biome bukkitBiome = biome.getDerivative();
if (bukkitBiome != null) {
biomeHolder = INMS.get().getBiomeBase(world, bukkitBiome);
}
}
if (biomeHolder == null) {
Iris.warn("Biomeholder null! Unsure what to do.");
}
// Now fill the 4x4x4 block in the hunk
@@ -147,6 +153,7 @@ public class IrisBiomeFixer {
}
}
// Set biomes to the chunk using NMS
INMS.get().setBiomes(cx, cz, engine.getWorld().realWorld(), biomes);
generated.incrementAndGet();
@@ -158,7 +165,6 @@ public class IrisBiomeFixer {
progressUpdater.shutdown();
try {
// Wait for the progress updater to finish
if (!progressUpdater.awaitTermination(1, TimeUnit.MINUTES)) {
Iris.warn("Progress updater did not terminate in time.");
progressUpdater.shutdownNow();
@@ -169,7 +175,6 @@ public class IrisBiomeFixer {
Thread.currentThread().interrupt();
}
// Final Progress Update
Iris.info("Biome Fixing Completed: " + generated.get() + "/" + totalChunks.get() + " chunks processed.");
}
@@ -193,7 +198,7 @@ public class IrisBiomeFixer {
if (progressLatch.flip()) {
Iris.info("Biome Fixer Progress: " + currentGenerated + "/" + totalChunks.get() +
" chunks (" + percentage + "%%) - " +
" chunks (" + Form.f(percentage) + "%%) - " +
chunksPerSecond.getAverage() + " chunks/s ETA: " + formatETA(eta));
}
}

View File

@@ -0,0 +1,73 @@
package com.volmit.iris.core.tools;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.math.Spiraler;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
public class IrisWorldMerger {
private Engine engine;
private World world;
private World selectedWorld;
/**
* @param world > The selected world to get the caves from
* @param engine > The engine of the iris world
*/
public IrisWorldMerger(Engine engine, World world) {
this.engine = engine;
this.world = this.engine.getWorld().realWorld();
this.selectedWorld = world;
}
/**
* Merges caves from a selected chunk into the corresponding chunk in the outcome world.
*
* @param selectedChunk The chunk from the selected world.
* @param targetChunk The corresponding chunk in the outcome world.
*/
private void mergeCavesInChunk(Chunk selectedChunk, Chunk targetChunk) {
int baseX = selectedChunk.getX() << 4;
int baseZ = selectedChunk.getZ() << 4;
for (int x = 0; x < 16; x++) {
int worldX = baseX + x;
for (int z = 0; z < 16; z++) {
int worldZ = baseZ + z;
int surfaceY = engine.getHeight(worldX, worldZ);
for (int y = 0; y <= surfaceY; y++) {
Block selectedBlock = selectedChunk.getBlock(x, y, z);
if (selectedBlock.getType() == Material.AIR) {
Block targetBlock = targetChunk.getBlock(x, y, z);
targetBlock.setType(Material.AIR);
}
}
}
}
}
/**
* Irritates (merges) caves in a spiral pattern around the specified center chunk coordinates.
*
* @param centerX The X coordinate of the center chunk.
* @param centerZ The Z coordinate of the center chunk.
* @param radius The radius (in chunks) to merge caves around.
*/
public void irritateSpiral(int centerX, int centerZ, int radius) {
Spiraler spiraler = new Spiraler(radius * 2, radius * 2, (x, z) -> {
int chunkX = centerX + x;
int chunkZ = centerZ + z;
Chunk selectedChunk = selectedWorld.getChunkAt(chunkX, chunkZ);
Chunk targetChunk = world.getChunkAt(chunkX, chunkZ);
mergeCavesInChunk(selectedChunk, targetChunk);
});
// Execute the spiral iteration
while (spiraler.hasNext()) {
spiraler.next(); // The spiraler itself runs the callback defined in its constructor
}
}
}

View File

@@ -29,7 +29,9 @@ import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Getter;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData> {
@@ -155,6 +157,26 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
}
}
}
}
}
/**
* Merges caves from a selected chunk into the corresponding chunk in the outcome world.
* This is calling 1/16th of a chunk x/z slice. It is a plane from sky to bedrock 1 thick in the x direction.
*
* @param x the chunk x in blocks
* @param z the chunk z in blocks
* @param xf the current x slice
* @param h the blockdata
*/
@BlockCoordinates
private void terrainMergeSliver(int x, int z, int xf, Hunk<BlockData> h, ChunkContext context) {
int zf, realX, realZ, hf, he;
for (zf = 0; zf < h.getDepth(); zf++) {
}
}
}