mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Marker exhaustion & auto-removal in invalid positions
This commit is contained in:
parent
0b1d59e398
commit
d0175f9c39
@ -39,6 +39,7 @@ import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.math.BlockPosition;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterMarker;
|
||||
@ -58,7 +59,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -487,7 +491,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
public Map<IrisPosition, KSet<IrisSpawner>> getSpawnersFromMarkers(Chunk c) {
|
||||
Map<IrisPosition, KSet<IrisSpawner>> p = new KMap<>();
|
||||
|
||||
Set<IrisPosition> b = new KSet<>();
|
||||
getMantle().iterateChunk(c.getX(), c.getZ(), MatterMarker.class, (x, y, z, t) -> {
|
||||
if(t.getTag().equals("cave_floor") || t.getTag().equals("cave_ceiling"))
|
||||
{
|
||||
@ -496,16 +500,46 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
IrisMarker mark = getData().getMarkerLoader().load(t.getTag());
|
||||
IrisPosition pos = new IrisPosition((c.getX() << 4) + x, y, (c.getZ() << 4) + z);
|
||||
|
||||
if(mark.isEmptyAbove())
|
||||
{
|
||||
AtomicBoolean remove = new AtomicBoolean(false);
|
||||
|
||||
try {
|
||||
J.sfut(() -> {
|
||||
if(c.getBlock(x, y+1, z).getBlockData().getMaterial().isSolid() || c.getBlock(x, y+2, z).getBlockData().getMaterial().isSolid())
|
||||
{
|
||||
remove.set(true);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(remove.get())
|
||||
{
|
||||
b.add(pos);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (String i : mark.getSpawners()) {
|
||||
IrisSpawner m = getData().getSpawnerLoader().load(i);
|
||||
m.setReferenceMarker(mark);
|
||||
|
||||
// This is so fucking incorrect its a joke
|
||||
//noinspection ConstantConditions
|
||||
if (m != null) {
|
||||
p.computeIfAbsent(pos, (k) -> new KSet<>()).add(m);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for(IrisPosition i : b)
|
||||
{
|
||||
getEngine().getMantle().getMantle().remove(i.getX(), i.getY(), i.getZ(), MatterMarker.class);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,9 @@ public class IrisMarker extends IrisRegistrant {
|
||||
@Desc("Remove this marker when the block it's assigned to is changed.")
|
||||
private boolean removeOnChange = true;
|
||||
|
||||
@Desc("If true, markers will only be placed here if there is 2 air blocks above it.")
|
||||
private boolean emptyAbove = 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;
|
||||
|
||||
|
@ -663,6 +663,13 @@ public class IrisObject extends IrisRegistrant {
|
||||
markers = new KMap<>();
|
||||
for(IrisObjectMarker j : config.getMarkers())
|
||||
{
|
||||
IrisMarker marker = getLoader().getMarkerLoader().load(j.getMarker());
|
||||
|
||||
if(marker == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int max = j.getMaximumMarkers();
|
||||
|
||||
for(BlockVector i : getBlocks().k().shuffle())
|
||||
@ -684,7 +691,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
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))));
|
||||
|
||||
if((j.isEmptyAbove() && a && fff) || !j.isEmptyAbove())
|
||||
if((marker.isEmptyAbove() && a && fff) || !marker.isEmptyAbove())
|
||||
{
|
||||
markers.put(i, j.getMarker());
|
||||
max--;
|
||||
|
@ -51,9 +51,6 @@ public class IrisObjectMarker {
|
||||
@Desc("The maximum amount of markers to place. Use these sparingly!")
|
||||
private int maximumMarkers = 8;
|
||||
|
||||
@Desc("If true, markers will only be placed here if there is 2 air blocks above it.")
|
||||
private boolean emptyAbove = true;
|
||||
|
||||
@Desc("If true, markers will only be placed if the block matches the mark list perfectly.")
|
||||
private boolean exact = false;
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
package com.volmit.iris.util.function;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Consumer4<A, B, C, D> {
|
||||
void accept(A a, B b, C c, D d);
|
||||
|
Loading…
x
Reference in New Issue
Block a user