mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-01 23:47:21 +00:00
fixes to deposit clump generation and placement
This commit is contained in:
parent
c78ffab948
commit
23a0ab23aa
@ -40,6 +40,7 @@ import org.bukkit.event.player.PlayerChangedWorldEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
public class BoardSVC implements IrisService, BoardProvider {
|
public class BoardSVC implements IrisService, BoardProvider {
|
||||||
private final KMap<Player, PlayerBoard> boards = new KMap<>();
|
private final KMap<Player, PlayerBoard> boards = new KMap<>();
|
||||||
@ -104,11 +105,11 @@ public class BoardSVC implements IrisService, BoardProvider {
|
|||||||
@Data
|
@Data
|
||||||
public static class PlayerBoard {
|
public static class PlayerBoard {
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final KList<String> lines;
|
private final CopyOnWriteArrayList<String> lines;
|
||||||
|
|
||||||
public PlayerBoard(Player player) {
|
public PlayerBoard(Player player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.lines = new KList<>();
|
this.lines = new CopyOnWriteArrayList<>();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,10 +20,7 @@ package com.volmit.iris.engine.modifier;
|
|||||||
|
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.EngineAssignedModifier;
|
import com.volmit.iris.engine.framework.EngineAssignedModifier;
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.*;
|
||||||
import com.volmit.iris.engine.object.IrisDepositGenerator;
|
|
||||||
import com.volmit.iris.engine.object.IrisObject;
|
|
||||||
import com.volmit.iris.engine.object.IrisRegion;
|
|
||||||
import com.volmit.iris.util.context.ChunkContext;
|
import com.volmit.iris.util.context.ChunkContext;
|
||||||
import com.volmit.iris.util.data.B;
|
import com.volmit.iris.util.data.B;
|
||||||
import com.volmit.iris.util.data.HeightMap;
|
import com.volmit.iris.util.data.HeightMap;
|
||||||
@ -45,26 +42,26 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
@Override
|
@Override
|
||||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
|
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
generateDeposits(rng, output, Math.floorDiv(x, 16), Math.floorDiv(z, 16), multicore, context);
|
generateDeposits(output, Math.floorDiv(x, 16), Math.floorDiv(z, 16), multicore, context);
|
||||||
getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
|
getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateDeposits(RNG rx, Hunk<BlockData> terrain, int x, int z, boolean multicore, ChunkContext context) {
|
public void generateDeposits(Hunk<BlockData> terrain, int x, int z, boolean multicore, ChunkContext context) {
|
||||||
RNG ro = rx.nextParallelRNG(x * x).nextParallelRNG(z * z);
|
|
||||||
IrisRegion region = context.getRegion().get(7, 7);
|
IrisRegion region = context.getRegion().get(7, 7);
|
||||||
IrisBiome biome = context.getBiome().get(7, 7);
|
IrisBiome biome = context.getBiome().get(7, 7);
|
||||||
BurstExecutor burst = burst().burst(multicore);
|
BurstExecutor burst = burst().burst(multicore);
|
||||||
|
|
||||||
|
long seed = x * 341873128712L + z * 132897987541L;
|
||||||
for (IrisDepositGenerator k : getDimension().getDeposits()) {
|
for (IrisDepositGenerator k : getDimension().getDeposits()) {
|
||||||
burst.queue(() -> generate(k, terrain, ro, x, z, false, context));
|
burst.queue(() -> generate(k, terrain, rng.nextParallelRNG(seed), x, z, false, context));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IrisDepositGenerator k : region.getDeposits()) {
|
for (IrisDepositGenerator k : region.getDeposits()) {
|
||||||
burst.queue(() -> generate(k, terrain, ro, x, z, false, context));
|
burst.queue(() -> generate(k, terrain, rng.nextParallelRNG(seed), x, z, false, context));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IrisDepositGenerator k : biome.getDeposits()) {
|
for (IrisDepositGenerator k : biome.getDeposits()) {
|
||||||
burst.queue(() -> generate(k, terrain, ro, x, z, false, context));
|
burst.queue(() -> generate(k, terrain, rng.nextParallelRNG(seed), x, z, false, context));
|
||||||
}
|
}
|
||||||
burst.complete();
|
burst.complete();
|
||||||
}
|
}
|
||||||
@ -74,45 +71,42 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, HeightMap he, ChunkContext context) {
|
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, HeightMap he, ChunkContext context) {
|
||||||
for (int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
for (int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk() + 1); l++) {
|
||||||
IrisObject clump = k.getClump(rng, getData());
|
IrisObject clump = k.getClump(rng, getData());
|
||||||
|
|
||||||
int af = (int) Math.floor(clump.getW() / 2D);
|
int dim = clump.getW();
|
||||||
int bf = (int) Math.floor(16D - (clump.getW() / 2D));
|
int min = dim / 2;
|
||||||
|
int max = (int) (16D - dim / 2D);
|
||||||
|
|
||||||
if (af > bf || af < 0 || bf > 15) {
|
if (min > max || min < 0 || max > 15) {
|
||||||
af = 6;
|
min = 6;
|
||||||
bf = 9;
|
max = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
af = Math.max(af - 1, 0);
|
int x = rng.i(min, max + 1);
|
||||||
int x = rng.i(af, bf);
|
int z = rng.i(min, max + 1);
|
||||||
int z = rng.i(af, bf);
|
|
||||||
int height = (he != null ? he.getHeight((cx << 4) + x, (cz << 4) + z) : (int) (Math.round(
|
int height = (he != null ? he.getHeight((cx << 4) + x, (cz << 4) + z) : (int) (Math.round(
|
||||||
context.getHeight().get(x, z)
|
context.getHeight().get(x, z)
|
||||||
))) - 7;
|
))) - 7;
|
||||||
|
|
||||||
if (height <= 0) {
|
if (height <= 0)
|
||||||
return;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
int i = Math.max(0, k.getMinHeight());
|
int minY = Math.max(0, k.getMinHeight());
|
||||||
// TODO: WARNING HEIGHT
|
// TODO: WARNING HEIGHT
|
||||||
int a = Math.min(height, Math.min(getEngine().getHeight(), k.getMaxHeight()));
|
int maxY = Math.min(height, Math.min(getEngine().getHeight(), k.getMaxHeight()));
|
||||||
|
|
||||||
if (i >= a) {
|
if (minY >= maxY)
|
||||||
return;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
int h = rng.i(i, a);
|
int y = rng.i(minY, maxY + 1);
|
||||||
|
|
||||||
if (h > k.getMaxHeight() || h < k.getMinHeight() || h > height - 2) {
|
if (y > k.getMaxHeight() || y < k.getMinHeight() || y > height - 2)
|
||||||
return;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
for (BlockVector j : clump.getBlocks().keySet()) {
|
for (BlockVector j : clump.getBlocks().keySet()) {
|
||||||
int nx = j.getBlockX() + x;
|
int nx = j.getBlockX() + x;
|
||||||
int ny = j.getBlockY() + h;
|
int ny = j.getBlockY() + y;
|
||||||
int nz = j.getBlockZ() + z;
|
int nz = j.getBlockZ() + z;
|
||||||
|
|
||||||
if (ny > height || nx > 15 || nx < 0 || ny > getEngine().getHeight() || ny < 0 || nz < 0 || nz > 15) {
|
if (ny > height || nx > 15 || nx < 0 || ny > getEngine().getHeight() || ny < 0 || nz < 0 || nz > 15) {
|
||||||
|
@ -22,13 +22,14 @@ 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.object.annotations.*;
|
import com.volmit.iris.engine.object.annotations.*;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.collection.KSet;
|
||||||
|
import com.volmit.iris.util.math.BlockPosition;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.util.BlockVector;
|
|
||||||
|
|
||||||
@Snippet("deposit")
|
@Snippet("deposit")
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@ -90,15 +91,15 @@ public class IrisDepositGenerator {
|
|||||||
|
|
||||||
return objectsf;
|
return objectsf;
|
||||||
});
|
});
|
||||||
return objects.get(rng.i(0, objects.size() - 1));
|
return objects.get(rng.i(0, objects.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxDimension() {
|
public int getMaxDimension() {
|
||||||
return Math.min(11, (int) Math.round(Math.pow(maxSize, 1D / 3D)));
|
return Math.min(11, (int) Math.ceil(Math.cbrt(maxSize)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisObject generateClumpObject(RNG rngv, IrisData rdata) {
|
private IrisObject generateClumpObject(RNG rngv, IrisData rdata) {
|
||||||
int s = rngv.i(minSize, maxSize);
|
int s = rngv.i(minSize, maxSize + 1);
|
||||||
if (s == 1) {
|
if (s == 1) {
|
||||||
IrisObject o = new IrisObject(1, 1, 1);
|
IrisObject o = new IrisObject(1, 1, 1);
|
||||||
o.getBlocks().put(o.getCenter(), nextBlock(rngv, rdata));
|
o.getBlocks().put(o.getCenter(), nextBlock(rngv, rdata));
|
||||||
@ -145,7 +146,7 @@ public class IrisDepositGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BlockData nextBlock(RNG rngv, IrisData rdata) {
|
private BlockData nextBlock(RNG rngv, IrisData rdata) {
|
||||||
return getBlockData(rdata).get(rngv.i(0, getBlockData(rdata).size() - 1));
|
return getBlockData(rdata).get(rngv.i(0, getBlockData(rdata).size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> getBlockData(IrisData rdata) {
|
public KList<BlockData> getBlockData(IrisData rdata) {
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.volmit.iris.util.documentation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This Argument is exclusive
|
||||||
|
*/
|
||||||
|
public @interface Exclusive {
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.volmit.iris.util.documentation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This Argument is inclusive
|
||||||
|
*/
|
||||||
|
public @interface Inclusive {
|
||||||
|
}
|
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.math;
|
package com.volmit.iris.util.math;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.documentation.Exclusive;
|
||||||
|
import com.volmit.iris.util.documentation.Inclusive;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -89,11 +92,11 @@ public class RNG extends Random {
|
|||||||
return d() > percent;
|
return d() > percent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public short si(int lowerBound, int upperBound) {
|
public short si(@Inclusive int lowerBound, @Inclusive int upperBound) {
|
||||||
return (short) (lowerBound + (nextFloat() * ((upperBound - lowerBound) + 1)));
|
return (short) (lowerBound + (nextFloat() * ((upperBound - lowerBound) + 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public short si(int upperBound) {
|
public short si(@Inclusive int upperBound) {
|
||||||
return si(0, upperBound);
|
return si(0, upperBound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,11 +104,11 @@ public class RNG extends Random {
|
|||||||
return si(1);
|
return si(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float f(float lowerBound, float upperBound) {
|
public float f(@Inclusive float lowerBound, @Exclusive float upperBound) {
|
||||||
return lowerBound + (nextFloat() * ((upperBound - lowerBound)));
|
return lowerBound + (nextFloat() * ((upperBound - lowerBound)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public float f(float upperBound) {
|
public float f(@Exclusive float upperBound) {
|
||||||
return f(0, upperBound);
|
return f(0, upperBound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +116,7 @@ public class RNG extends Random {
|
|||||||
return f(1);
|
return f(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double d(double lowerBound, double upperBound) {
|
public double d(@Inclusive double lowerBound, @Exclusive double upperBound) {
|
||||||
if (lowerBound > upperBound) {
|
if (lowerBound > upperBound) {
|
||||||
return M.lerp(upperBound, lowerBound, nextDouble());
|
return M.lerp(upperBound, lowerBound, nextDouble());
|
||||||
}
|
}
|
||||||
@ -121,7 +124,7 @@ public class RNG extends Random {
|
|||||||
return M.lerp(lowerBound, upperBound, nextDouble());
|
return M.lerp(lowerBound, upperBound, nextDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
public double d(double upperBound) {
|
public double d(@Exclusive double upperBound) {
|
||||||
return d(0, upperBound);
|
return d(0, upperBound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,19 +132,19 @@ public class RNG extends Random {
|
|||||||
return d(1);
|
return d(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int i(int lowerBound, int upperBound) {
|
public int i(@Inclusive int lowerBound, @Exclusive int upperBound) {
|
||||||
return (int) Math.floor(d(lowerBound, upperBound));
|
return (int) Math.floor(d(lowerBound, upperBound));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int i(int upperBound) {
|
public int i(@Exclusive int upperBound) {
|
||||||
return i(Math.min(upperBound, 0), Math.max(0, upperBound));
|
return i(Math.min(upperBound, 0), Math.max(0, upperBound));
|
||||||
}
|
}
|
||||||
|
|
||||||
public long l(long lowerBound, long upperBound) {
|
public long l(@Inclusive long lowerBound, @Exclusive long upperBound) {
|
||||||
return Math.round(d(lowerBound, upperBound));
|
return Math.round(d(lowerBound, upperBound));
|
||||||
}
|
}
|
||||||
|
|
||||||
public long l(long upperBound) {
|
public long l(@Exclusive long upperBound) {
|
||||||
return l(0, upperBound);
|
return l(0, upperBound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user