mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Marker destruction
This commit is contained in:
parent
93bcb8994f
commit
0b1d59e398
@ -398,6 +398,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
private Stream<IrisEntitySpawn> stream(IrisSpawner s, boolean initial) {
|
private Stream<IrisEntitySpawn> stream(IrisSpawner s, boolean initial) {
|
||||||
for (IrisEntitySpawn i : initial ? s.getInitialSpawns() : s.getSpawns()) {
|
for (IrisEntitySpawn i : initial ? s.getInitialSpawns() : s.getSpawns()) {
|
||||||
i.setReferenceSpawner(s);
|
i.setReferenceSpawner(s);
|
||||||
|
i.setReferenceMarker(s.getReferenceMarker());
|
||||||
}
|
}
|
||||||
|
|
||||||
return (initial ? s.getInitialSpawns() : s.getSpawns()).stream();
|
return (initial ? s.getInitialSpawns() : s.getSpawns()).stream();
|
||||||
@ -471,6 +472,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
IrisEntitySpawn ss = spawnRandomly(s).getRandom();
|
IrisEntitySpawn ss = spawnRandomly(s).getRandom();
|
||||||
ss.setReferenceSpawner(spawner);
|
ss.setReferenceSpawner(spawner);
|
||||||
|
ss.setReferenceMarker(spawner.getReferenceMarker());
|
||||||
spawn(block, ss);
|
spawn(block, ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,6 +498,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
IrisPosition pos = new IrisPosition((c.getX() << 4) + x, y, (c.getZ() << 4) + z);
|
IrisPosition pos = new IrisPosition((c.getX() << 4) + x, y, (c.getZ() << 4) + z);
|
||||||
for (String i : mark.getSpawners()) {
|
for (String i : mark.getSpawners()) {
|
||||||
IrisSpawner m = getData().getSpawnerLoader().load(i);
|
IrisSpawner m = getData().getSpawnerLoader().load(i);
|
||||||
|
m.setReferenceMarker(mark);
|
||||||
|
|
||||||
if (m != null) {
|
if (m != null) {
|
||||||
p.computeIfAbsent(pos, (k) -> new KSet<>()).add(m);
|
p.computeIfAbsent(pos, (k) -> new KSet<>()).add(m);
|
||||||
|
@ -243,6 +243,11 @@ public class PlannedPiece {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Engine getEngine() {
|
public Engine getEngine() {
|
||||||
|
if(IrisToolbelt.isIrisWorld(world))
|
||||||
|
{
|
||||||
|
return IrisToolbelt.access(world).getEngine();
|
||||||
|
}
|
||||||
|
|
||||||
return IrisContext.get().getEngine();
|
return IrisContext.get().getEngine();
|
||||||
}
|
}
|
||||||
}, piece.getPlacementOptions(), rng, getData());
|
}, piece.getPlacementOptions(), rng, getData());
|
||||||
|
@ -28,6 +28,7 @@ import com.volmit.iris.engine.object.annotations.Required;
|
|||||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
|
import com.volmit.iris.util.matter.MatterMarker;
|
||||||
import com.volmit.iris.util.matter.slices.MarkerMatter;
|
import com.volmit.iris.util.matter.slices.MarkerMatter;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -63,6 +64,7 @@ public class IrisEntitySpawn implements IRare {
|
|||||||
@Desc("The max of this entity to spawn")
|
@Desc("The max of this entity to spawn")
|
||||||
private int maxSpawns = 1;
|
private int maxSpawns = 1;
|
||||||
private transient IrisSpawner referenceSpawner;
|
private transient IrisSpawner referenceSpawner;
|
||||||
|
private transient IrisMarker referenceMarker;
|
||||||
|
|
||||||
public int spawn(Engine gen, Chunk c, RNG rng) {
|
public int spawn(Engine gen, Chunk c, RNG rng) {
|
||||||
int spawns = minSpawns == maxSpawns ? minSpawns : rng.i(Math.min(minSpawns, maxSpawns), Math.max(minSpawns, maxSpawns));
|
int spawns = minSpawns == maxSpawns ? minSpawns : rng.i(Math.min(minSpawns, maxSpawns), Math.max(minSpawns, maxSpawns));
|
||||||
@ -110,6 +112,12 @@ public class IrisEntitySpawn implements IRare {
|
|||||||
|
|
||||||
World world = gen.getWorld().realWorld();
|
World world = gen.getWorld().realWorld();
|
||||||
if (spawns > 0) {
|
if (spawns > 0) {
|
||||||
|
|
||||||
|
if(referenceMarker != null)
|
||||||
|
{
|
||||||
|
gen.getMantle().getMantle().remove(c.getX(), c.getY(), c.getZ(), MatterMarker.class);
|
||||||
|
}
|
||||||
|
|
||||||
for (int id = 0; id < spawns; id++) {
|
for (int id = 0; id < spawns; id++) {
|
||||||
Location l = c.toLocation(world).add(0, 1, 0);
|
Location l = c.toLocation(world).add(0, 1, 0);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import com.volmit.iris.engine.object.annotations.Desc;
|
|||||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.json.JSONObject;
|
import com.volmit.iris.util.json.JSONObject;
|
||||||
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -46,6 +47,14 @@ public class IrisMarker extends IrisRegistrant {
|
|||||||
@Desc("Remove this marker when the block it's assigned to is changed.")
|
@Desc("Remove this marker when the block it's assigned to is changed.")
|
||||||
private boolean removeOnChange = true;
|
private boolean removeOnChange = true;
|
||||||
|
|
||||||
|
@Desc("If this marker is used, what is the chance it removes itself. For example 25% (0.25) would mean that on average 4 uses will remove a specific marker. Set this below 0 (-1) to never exhaust & set this to 1 or higher to always exhaust on first use.")
|
||||||
|
private double exhaustionChance = 0.33;
|
||||||
|
|
||||||
|
public boolean shouldExhaust()
|
||||||
|
{
|
||||||
|
return RNG.r.chance(exhaustionChance);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFolderName() {
|
public String getFolderName() {
|
||||||
return "markers";
|
return "markers";
|
||||||
|
@ -504,7 +504,7 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener, CarveResult c, IrisData rdata) {
|
public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener, CarveResult c, IrisData rdata) {
|
||||||
IObjectPlacer placer = (config.getHeightmap() != null) ? new HeightmapObjectPlacer(IrisContext.get().getEngine(), rng, x, yv, z, config, oplacer) : oplacer;
|
IObjectPlacer placer = (config.getHeightmap() != null) ? new HeightmapObjectPlacer(oplacer.getEngine() == null ? IrisContext.get().getEngine() : oplacer.getEngine(), rng, x, yv, z, config, oplacer) : oplacer;
|
||||||
|
|
||||||
if (config.isSmartBore()) {
|
if (config.isSmartBore()) {
|
||||||
ensureSmartBored(placer.isDebugSmartBore());
|
ensureSmartBored(placer.isDebugSmartBore());
|
||||||
@ -667,9 +667,19 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
|
|
||||||
for(BlockVector i : getBlocks().k().shuffle())
|
for(BlockVector i : getBlocks().k().shuffle())
|
||||||
{
|
{
|
||||||
|
if(max <= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
BlockData data = getBlocks().get(i);
|
BlockData data = getBlocks().get(i);
|
||||||
|
|
||||||
for (BlockData k : j.getMark(rdata)) {
|
for (BlockData k : j.getMark(rdata)) {
|
||||||
|
if(max <= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
|
if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
|
||||||
boolean a = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 1, 0))));
|
boolean a = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 1, 0))));
|
||||||
boolean fff = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 2, 0))));
|
boolean fff = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 2, 0))));
|
||||||
@ -677,6 +687,7 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
if((j.isEmptyAbove() && a && fff) || !j.isEmptyAbove())
|
if((j.isEmptyAbove() && a && fff) || !j.isEmptyAbove())
|
||||||
{
|
{
|
||||||
markers.put(i, j.getMarker());
|
markers.put(i, j.getMarker());
|
||||||
|
max--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,9 @@ import org.bukkit.World;
|
|||||||
@Desc("Represents an entity spawn during initial chunk generation")
|
@Desc("Represents an entity spawn during initial chunk generation")
|
||||||
@Data
|
@Data
|
||||||
public class IrisSpawner extends IrisRegistrant {
|
public class IrisSpawner extends IrisRegistrant {
|
||||||
|
|
||||||
|
private transient IrisMarker referenceMarker;
|
||||||
|
|
||||||
@ArrayType(min = 1, type = IrisEntitySpawn.class)
|
@ArrayType(min = 1, type = IrisEntitySpawn.class)
|
||||||
@Desc("The entity spawns to add")
|
@Desc("The entity spawns to add")
|
||||||
private KList<IrisEntitySpawn> spawns = new KList<>();
|
private KList<IrisEntitySpawn> spawns = new KList<>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user