mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Cave spawning & markers
This commit is contained in:
parent
569c34bca0
commit
b2aff55160
@ -2,6 +2,7 @@ package com.volmit.iris.core.commands;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.edit.BlockSignal;
|
||||
import com.volmit.iris.core.nms.INMS;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
@ -10,14 +11,19 @@ import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.decree.DecreeExecutor;
|
||||
import com.volmit.iris.util.decree.DecreeOrigin;
|
||||
import com.volmit.iris.util.decree.annotations.Decree;
|
||||
import com.volmit.iris.util.decree.annotations.Param;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.matter.MatterMarker;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Decree(name = "what", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris What?")
|
||||
public class CommandWhat implements DecreeExecutor {
|
||||
@Decree(description = "What is in my hand?", origin = DecreeOrigin.PLAYER)
|
||||
@ -119,4 +125,32 @@ public class CommandWhat implements DecreeExecutor {
|
||||
sender().sendMessage("Iris worlds only.");
|
||||
}
|
||||
}
|
||||
|
||||
@Decree(description = "Show markers in chunk", origin = DecreeOrigin.PLAYER)
|
||||
public void markers(@Param(description = "Marker name such as cave_floor or cave_ceiling") String marker) {
|
||||
Chunk c = player().getLocation().getChunk();
|
||||
|
||||
if (IrisToolbelt.isIrisWorld(c.getWorld())) {
|
||||
int m = 1;
|
||||
AtomicInteger v = new AtomicInteger(0);
|
||||
|
||||
for(int xxx = c.getX() - 4; xxx <= c.getX() + 4; xxx++)
|
||||
{
|
||||
for(int zzz = c.getZ() - 4; zzz <= c.getZ() + 4; zzz++)
|
||||
{
|
||||
IrisToolbelt.access(c.getWorld()).getEngine().getMantle().findMarkers(xxx, zzz, new MatterMarker(marker))
|
||||
.convert((i) -> i.toLocation(c.getWorld())).forEach((i) -> {
|
||||
J.s(() -> {
|
||||
BlockSignal.of(i.getBlock(), 100);
|
||||
});
|
||||
v.incrementAndGet();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
sender().sendMessage("Found " + v.get() + " Nearby Markers (" + marker + ")");
|
||||
} else {
|
||||
sender().sendMessage("Iris worlds only.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -275,8 +275,6 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}
|
||||
});
|
||||
|
||||
getMantle().getMantle().deleteChunkSlice(c.getX(), c.getZ(), MatterCavern.class);
|
||||
getMantle().getMantle().deleteChunkSlice(c.getX(), c.getZ(), MatterUpdate.class);
|
||||
getMetrics().getUpdates().put(p.getMilliseconds());
|
||||
}, RNG.r.i(0, 20)));
|
||||
}
|
||||
|
@ -23,10 +23,7 @@ import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineTarget;
|
||||
import com.volmit.iris.engine.object.IObjectPlacer;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.IrisFeaturePositional;
|
||||
import com.volmit.iris.engine.object.TileData;
|
||||
import com.volmit.iris.engine.object.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
@ -37,6 +34,8 @@ import com.volmit.iris.util.mantle.MantleChunk;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.matter.Matter;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.MatterMarker;
|
||||
import com.volmit.iris.util.matter.slices.MarkerMatter;
|
||||
import com.volmit.iris.util.matter.slices.UpdateMatter;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
@ -65,6 +64,20 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
return getHighest(x, z, getData());
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default KList<IrisPosition> findMarkers(int x, int z, MatterMarker marker)
|
||||
{
|
||||
KList<IrisPosition> p = new KList<>();
|
||||
getMantle().iterateChunk(x, z, MatterMarker.class, (xx, yy, zz, mm) -> {
|
||||
if(marker.equals(mm))
|
||||
{
|
||||
p.add(new IrisPosition(xx + (x << 4), yy, zz + (z << 4)));
|
||||
}
|
||||
});
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
default int getHighest(int x, int z, boolean ignoreFluid) {
|
||||
return getHighest(x, z, getData(), ignoreFluid);
|
||||
}
|
||||
@ -229,7 +242,6 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
}
|
||||
|
||||
getMantle().iterateChunk(x, z, t, blocks::set);
|
||||
getMantle().deleteChunkSlice(x, z, BlockData.class);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
|
@ -35,8 +35,10 @@ import com.volmit.iris.util.function.Consumer4;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.mantle.MantleChunk;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.slices.MarkerMatter;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Material;
|
||||
@ -152,7 +154,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
buf = i;
|
||||
zone.ceiling = buf;
|
||||
} else if (zone.isValid()) {
|
||||
processZone(output, mc, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
||||
processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
||||
zone = new CaveZone();
|
||||
zone.setFloor(i);
|
||||
buf = i;
|
||||
@ -160,20 +162,30 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
if (zone.isValid()) {
|
||||
processZone(output, mc, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
||||
processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
||||
}
|
||||
});
|
||||
|
||||
getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
private void processZone(Hunk<BlockData> output, MantleChunk mc, CaveZone zone, int rx, int rz, int xx, int zz) {
|
||||
private void processZone(Hunk<BlockData> output, MantleChunk mc, Mantle mantle, CaveZone zone, int rx, int rz, int xx, int zz) {
|
||||
boolean decFloor = B.isSolid(output.get(rx, zone.floor - 1, rz));
|
||||
boolean decCeiling = B.isSolid(output.get(rx, zone.ceiling + 1, rz));
|
||||
int center = (zone.floor + zone.ceiling) / 2;
|
||||
int thickness = zone.airThickness();
|
||||
String customBiome = "";
|
||||
|
||||
if(M.r(1D/16D))
|
||||
{
|
||||
mantle.set(xx, zone.ceiling, zz, MarkerMatter.CAVE_CEILING);
|
||||
}
|
||||
|
||||
if(M.r(1D/16D))
|
||||
{
|
||||
mantle.set(xx, zone.floor, zz, MarkerMatter.CAVE_FLOOR);
|
||||
}
|
||||
|
||||
for (int i = zone.floor; i <= zone.ceiling; i++) {
|
||||
MatterCavern cavernData = (MatterCavern) mc.getOrCreate(i >> 4).slice(MatterCavern.class)
|
||||
.get(rx, i & 15, rz);
|
||||
|
@ -26,6 +26,8 @@ import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterMarker;
|
||||
import com.volmit.iris.util.matter.slices.MarkerMatter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -77,15 +79,8 @@ public class IrisEntitySpawn implements IRare {
|
||||
int hf = gen.getHeight(x, z, false);
|
||||
Location l = switch (getReferenceSpawner().getGroup()) {
|
||||
case NORMAL -> new Location(c.getWorld(), x, hf + 1, z);
|
||||
case CAVE -> {
|
||||
IrisComplex comp = gen.getComplex();
|
||||
IrisBiome cave = comp.getCaveBiomeStream().get(x, z);
|
||||
KList<Location> r = new KList<>();
|
||||
r.add(new Location(c.getWorld(), x, hf + 1, z)); // TODO CAVE HEIGHT
|
||||
|
||||
yield r.getRandom(rng);
|
||||
}
|
||||
|
||||
case CAVE -> gen.getMantle().findMarkers(c.getX(), c.getZ(), MarkerMatter.CAVE_FLOOR)
|
||||
.convert((i) -> i.toLocation(c.getWorld()).add(0, 1, 0)).getRandom(rng);
|
||||
case UNDERWATER, BEACH -> new Location(c.getWorld(), x, rng.i(h + 1, hf), z);
|
||||
};
|
||||
|
||||
|
29
src/main/java/com/volmit/iris/util/matter/MatterMarker.java
Normal file
29
src/main/java/com/volmit/iris/util/matter/MatterMarker.java
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.matter;
|
||||
|
||||
import com.volmit.iris.util.matter.slices.MarkerMatter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class MatterMarker {
|
||||
private final String tag;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.matter.slices;
|
||||
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.matter.MatterMarker;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@Sliced
|
||||
public class MarkerMatter extends RawMatter<MatterMarker> {
|
||||
private static final KMap<String, MatterMarker> markers = new KMap<>();
|
||||
public static final MatterMarker CAVE_FLOOR = new MatterMarker("cave_floor");
|
||||
public static final MatterMarker CAVE_CEILING = new MatterMarker("cave_ceiling");
|
||||
|
||||
public MarkerMatter() {
|
||||
this(1, 1, 1);
|
||||
}
|
||||
|
||||
public MarkerMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, MatterMarker.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNode(MatterMarker b, DataOutputStream dos) throws IOException {
|
||||
dos.writeUTF(b.getTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatterMarker readNode(DataInputStream din) throws IOException {
|
||||
return markers.computeIfAbsent(din.readUTF(), MatterMarker::new);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user