mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-26 18:49:06 +00:00
ChunkPosition -> Position2
This commit is contained in:
@@ -20,7 +20,7 @@ package com.volmit.iris.core.command.studio;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.gui.IrisExplorer;
|
||||
import com.volmit.iris.core.gui.NoiseExplorerGUI;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.plugin.Command;
|
||||
import com.volmit.iris.util.plugin.MortarCommand;
|
||||
@@ -57,7 +57,7 @@ public class CommandIrisStudioExplorer extends MortarCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
IrisExplorer.launch();
|
||||
NoiseExplorerGUI.launch();
|
||||
sender.sendMessage("Opening Noise Explorer!");
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -21,7 +21,7 @@ package com.volmit.iris.core.command.studio;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisDataManager;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.gui.IrisExplorer;
|
||||
import com.volmit.iris.core.gui.NoiseExplorerGUI;
|
||||
import com.volmit.iris.engine.object.IrisGenerator;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
@@ -70,7 +70,7 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand {
|
||||
|
||||
if (generator != null) {
|
||||
long finalSeed = seed;
|
||||
IrisExplorer.launch((x, z) ->
|
||||
NoiseExplorerGUI.launch((x, z) ->
|
||||
generator.getHeight(x, z, new RNG(finalSeed).nextParallelRNG(3245).lmax()), "Gen: " + generator.getLoadKey());
|
||||
|
||||
sender.sendMessage("Opening Noise Explorer for gen " + generator.getLoadKey() + " (" + generator.getLoader().getDataFolder().getName() + ")");
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.volmit.iris.core.command.studio;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.gui.IrisVision;
|
||||
import com.volmit.iris.core.gui.VisionGUI;
|
||||
import com.volmit.iris.engine.IrisWorlds;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.IrisAccess;
|
||||
@@ -57,12 +57,12 @@ public class CommandIrisStudioMap extends MortarCommand {
|
||||
|
||||
try {
|
||||
IrisAccess g = Iris.proj.getActiveProject().getActiveProvider();
|
||||
IrisVision.launch(g, 0);
|
||||
VisionGUI.launch(g, 0);
|
||||
sender.sendMessage("Opening Map!");
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
IrisAccess g = IrisWorlds.access(sender.player().getWorld());
|
||||
IrisVision.launch(g, 0);
|
||||
VisionGUI.launch(g, 0);
|
||||
sender.sendMessage("Opening Map!");
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -29,12 +29,11 @@ import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.function.Function2;
|
||||
import com.volmit.iris.util.function.Function3;
|
||||
import com.volmit.iris.util.math.ChunkPosition;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.oldnbt.ByteArrayTag;
|
||||
import com.volmit.iris.util.oldnbt.CompoundTag;
|
||||
import com.volmit.iris.util.oldnbt.Tag;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@@ -51,9 +50,9 @@ public class HunkRegionSlice<T> {
|
||||
private final HunkIOAdapter<T> adapter;
|
||||
private final CompoundTag compound;
|
||||
private final String key;
|
||||
private final KMap<ChunkPosition, Hunk<T>> loadedChunks;
|
||||
private final KMap<ChunkPosition, Long> lastUse;
|
||||
private final KSet<ChunkPosition> save;
|
||||
private final KMap<Position2, Hunk<T>> loadedChunks;
|
||||
private final KMap<Position2, Long> lastUse;
|
||||
private final KSet<Position2> save;
|
||||
private final int height;
|
||||
|
||||
public HunkRegionSlice(int height, Function3<Integer, Integer, Integer, Hunk<T>> factory, HunkIOAdapter<T> adapter, CompoundTag compound, String key) {
|
||||
@@ -73,14 +72,14 @@ public class HunkRegionSlice<T> {
|
||||
if (loadedChunks.size() != lastUse.size()) {
|
||||
Iris.warn("Incorrect chunk use counts in " + key);
|
||||
|
||||
for (ChunkPosition i : lastUse.k()) {
|
||||
for (Position2 i : lastUse.k()) {
|
||||
if (!loadedChunks.containsKey(i)) {
|
||||
Iris.warn(" Missing LoadChunkKey " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ChunkPosition i : lastUse.k()) {
|
||||
for (Position2 i : lastUse.k()) {
|
||||
Long l = lastUse.get(i);
|
||||
if (l == null || M.ms() - l > t) {
|
||||
v++;
|
||||
@@ -104,7 +103,7 @@ public class HunkRegionSlice<T> {
|
||||
|
||||
try
|
||||
{
|
||||
for (ChunkPosition i : save.copy()) {
|
||||
for (Position2 i : save.copy()) {
|
||||
if (i == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -172,7 +171,7 @@ public class HunkRegionSlice<T> {
|
||||
|
||||
public synchronized int unloadAll() {
|
||||
int v = 0;
|
||||
for (ChunkPosition i : loadedChunks.k()) {
|
||||
for (Position2 i : loadedChunks.k()) {
|
||||
unload(i.getX(), i.getZ());
|
||||
v++;
|
||||
}
|
||||
@@ -193,7 +192,7 @@ public class HunkRegionSlice<T> {
|
||||
}
|
||||
|
||||
public boolean isLoaded(int x, int z) {
|
||||
return lock.withResult(x, z, () -> loadedChunks.containsKey(new ChunkPosition(x, z)));
|
||||
return lock.withResult(x, z, () -> loadedChunks.containsKey(new Position2(x, z)));
|
||||
}
|
||||
|
||||
public void save(int x, int z) {
|
||||
@@ -206,7 +205,7 @@ public class HunkRegionSlice<T> {
|
||||
|
||||
public void unload(int x, int z) {
|
||||
lock.with(x, z, () -> {
|
||||
ChunkPosition key = new ChunkPosition(x, z);
|
||||
Position2 key = new Position2(x, z);
|
||||
if (isLoaded(x, z)) {
|
||||
if (save.contains(key)) {
|
||||
save(x, z);
|
||||
@@ -222,7 +221,7 @@ public class HunkRegionSlice<T> {
|
||||
public Hunk<T> load(int x, int z) {
|
||||
return lock.withResult(x, z, () -> {
|
||||
if (isLoaded(x, z)) {
|
||||
return loadedChunks.get(new ChunkPosition(x, z));
|
||||
return loadedChunks.get(new Position2(x, z));
|
||||
}
|
||||
|
||||
Hunk<T> v = null;
|
||||
@@ -240,7 +239,7 @@ public class HunkRegionSlice<T> {
|
||||
v = factory.apply(16, height, 16);
|
||||
}
|
||||
|
||||
loadedChunks.put(new ChunkPosition(x, z), v);
|
||||
loadedChunks.put(new Position2(x, z), v);
|
||||
|
||||
return v;
|
||||
});
|
||||
@@ -248,7 +247,7 @@ public class HunkRegionSlice<T> {
|
||||
|
||||
public Hunk<T> get(int x, int z) {
|
||||
return lock.withResult(x, z, () -> {
|
||||
ChunkPosition key = new ChunkPosition(x, z);
|
||||
Position2 key = new Position2(x, z);
|
||||
|
||||
Hunk<T> c = loadedChunks.get(key);
|
||||
|
||||
@@ -256,7 +255,7 @@ public class HunkRegionSlice<T> {
|
||||
c = load(x, z);
|
||||
}
|
||||
|
||||
lastUse.put(new ChunkPosition(x, z), M.ms());
|
||||
lastUse.put(new Position2(x, z), M.ms());
|
||||
|
||||
return c;
|
||||
});
|
||||
@@ -268,7 +267,7 @@ public class HunkRegionSlice<T> {
|
||||
|
||||
public Hunk<T> getRW(int x, int z) {
|
||||
return lock.withResult(x, z, () -> {
|
||||
save.add(new ChunkPosition(x, z));
|
||||
save.add(new Position2(x, z));
|
||||
return get(x, z);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.volmit.iris.engine.hunk.Hunk;
|
||||
import com.volmit.iris.engine.noise.CNG;
|
||||
import com.volmit.iris.engine.object.NoiseStyle;
|
||||
import com.volmit.iris.util.math.BlockPosition;
|
||||
import com.volmit.iris.util.math.ChunkPosition;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.math.MathHelper;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
@@ -76,7 +76,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
|
||||
private final float[] ravineCache = new float[1024];
|
||||
|
||||
private void doRavine(long seed, int tx, int tz, ChunkPosition pos, double sx, double sy, double sz, float f, float f2, float f3, @SuppressWarnings("SameParameterValue") int n3, @SuppressWarnings("SameParameterValue") int n4, @SuppressWarnings("SameParameterValue") double d4, RNG bbx, Hunk<BlockData> terrain) {
|
||||
private void doRavine(long seed, int tx, int tz, Position2 pos, double sx, double sy, double sz, float f, float f2, float f3, @SuppressWarnings("SameParameterValue") int n3, @SuppressWarnings("SameParameterValue") int n4, @SuppressWarnings("SameParameterValue") double d4, RNG bbx, Hunk<BlockData> terrain) {
|
||||
int n5;
|
||||
RNG random = new RNG(seed);
|
||||
double x = tx * 16 + 8;
|
||||
@@ -248,7 +248,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
//@done
|
||||
}
|
||||
|
||||
public void genRavines(int n, int n2, ChunkPosition chunkSnapshot, RNG bbb, Hunk<BlockData> terrain) {
|
||||
public void genRavines(int n, int n2, Position2 chunkSnapshot, RNG bbb, Hunk<BlockData> terrain) {
|
||||
RNG b = this.rng.nextParallelRNG(21949666);
|
||||
RNG bx = this.rng.nextParallelRNG(6676121);
|
||||
long l = b.nextLong();
|
||||
@@ -263,7 +263,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
}
|
||||
|
||||
private void doRavines(int tx, int tz, int sx, int sz, ChunkPosition chunkSnapshot, RNG b, Hunk<BlockData> terrain) {
|
||||
private void doRavines(int tx, int tz, int sx, int sz, Position2 chunkSnapshot, RNG b, Hunk<BlockData> terrain) {
|
||||
if (b.nextInt(getDimension().getRavineRarity()) != 0) {
|
||||
return;
|
||||
}
|
||||
@@ -281,6 +281,6 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
public void generateRavines(RNG nextParallelRNG, int x, int z, Hunk<BlockData> terrain) {
|
||||
genRavines(x, z, new ChunkPosition(x, z), nextParallelRNG.nextParallelRNG(x).nextParallelRNG(z), terrain);
|
||||
genRavines(x, z, new Position2(x, z), nextParallelRNG.nextParallelRNG(x).nextParallelRNG(z), terrain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.volmit.iris.engine.noise.CNG;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.math.ChunkPosition;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -336,7 +336,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@Desc("Define biome mutations for this dimension")
|
||||
private KList<IrisBiomeMutation> mutations = new KList<>();
|
||||
|
||||
private final transient AtomicCache<ChunkPosition> parallaxSize = new AtomicCache<>();
|
||||
private final transient AtomicCache<Position2> parallaxSize = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> rockLayerGenerator = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> fluidLayerGenerator = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> coordFracture = new AtomicCache<>();
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.math.AxisAlignedBB;
|
||||
import com.volmit.iris.util.math.BlockPosition;
|
||||
import com.volmit.iris.util.math.ChunkPosition;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.scheduling.IrisLock;
|
||||
import lombok.Data;
|
||||
@@ -466,7 +466,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
boolean warped = !config.getWarp().isFlat();
|
||||
boolean stilting = (config.getMode().equals(ObjectPlaceMode.STILT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT));
|
||||
KMap<ChunkPosition, Integer> heightmap = config.getSnow() > 0 ? new KMap<>() : null;
|
||||
KMap<Position2, Integer> heightmap = config.getSnow() > 0 ? new KMap<>() : null;
|
||||
int spinx = rng.imax() / 1000;
|
||||
int spiny = rng.imax() / 1000;
|
||||
int spinz = rng.imax() / 1000;
|
||||
@@ -638,7 +638,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
if (heightmap != null) {
|
||||
ChunkPosition pos = new ChunkPosition(xx, zz);
|
||||
Position2 pos = new Position2(xx, zz);
|
||||
|
||||
if (!heightmap.containsKey(pos)) {
|
||||
heightmap.put(pos, yy);
|
||||
@@ -727,7 +727,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
if (heightmap != null) {
|
||||
RNG rngx = rng.nextParallelRNG(3468854);
|
||||
|
||||
for (ChunkPosition i : heightmap.k()) {
|
||||
for (Position2 i : heightmap.k()) {
|
||||
int vx = i.getX();
|
||||
int vy = heightmap.get(i);
|
||||
int vz = i.getZ();
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
package com.volmit.iris.util.math;
|
||||
|
||||
public class ChunkPosition {
|
||||
public class Position2 {
|
||||
private int x;
|
||||
private int z;
|
||||
|
||||
public ChunkPosition(int x, int z) {
|
||||
public Position2(int x, int z) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
@@ -57,13 +57,13 @@ public class ChunkPosition {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ChunkPosition other)) {
|
||||
if (!(obj instanceof Position2 other)) {
|
||||
return false;
|
||||
}
|
||||
return x == other.x && z == other.z;
|
||||
}
|
||||
|
||||
public double distance(ChunkPosition center) {
|
||||
public double distance(Position2 center) {
|
||||
return Math.pow(center.getX() - x, 2) + Math.pow(center.getZ() - z, 2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user