Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 41 additions & 44 deletions core/src/main/java/com/volmit/iris/engine/object/IrisObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.core.nms.container.BlockPos;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.PlacedObject;
Expand Down Expand Up @@ -885,47 +886,8 @@ public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacemen
y += yrand;
readLock.lock();

KMap<BlockVector, String> markers = null;

try {
if (config.getMarkers().isNotEmpty() && placer.getEngine() != null) {
markers = new KMap<>();
var list = StreamSupport.stream(blocks.keys().spliterator(), false)
.collect(KList.collector());

for (IrisObjectMarker j : config.getMarkers()) {
IrisMarker marker = getLoader().getMarkerLoader().load(j.getMarker());

if (marker == null) {
continue;
}

int max = j.getMaximumMarkers();
for (BlockVector i : list.shuffle()) {
if (max <= 0) {
break;
}

BlockData data = blocks.get(i);

for (BlockData k : j.getMark(rdata)) {
if (max <= 0) {
break;
}

if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
boolean a = !blocks.containsKey((BlockVector) i.clone().add(new BlockVector(0, 1, 0)));
boolean fff = !blocks.containsKey((BlockVector) i.clone().add(new BlockVector(0, 2, 0)));

if (!marker.isEmptyAbove() || (a && fff)) {
markers.put(i, j.getMarker());
max--;
}
}
}
}
}
}
var markerCandidates = new HashMap<IrisObjectMarker, List<BlockPosition>>();

for (var entry : blocks) {
var g = entry.getKey();
Expand Down Expand Up @@ -1029,10 +991,6 @@ public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacemen
listener.accept(new BlockPosition(xx, yy, zz), data);
}

if (markers != null && markers.containsKey(g)) {
placer.getEngine().getMantle().getMantle().set(xx, yy, zz, new MatterMarker(markers.get(g)));
}

boolean wouldReplace = B.isSolid(placer.get(xx, yy, zz)) && B.isVineBlock(data);
boolean place = !data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR) && !wouldReplace;

Expand All @@ -1041,8 +999,47 @@ public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacemen
if (tile != null) {
placer.setTile(xx, yy, zz, tile);
}

if (config.getMarkers().isNotEmpty()) {
for (IrisObjectMarker j : config.getMarkers()) {
for (BlockData k : j.getMark(rdata)) {
if (j.isExact() ? k.matches(d) : k.getMaterial().equals(d.getMaterial())) {
markerCandidates.computeIfAbsent(j, kk -> new ArrayList<>()).add(new BlockPosition(xx, yy, zz));
}
}
}
}
}
}

if (config.getMarkers().isNotEmpty() && placer.getEngine() != null) {
for (IrisObjectMarker j : config.getMarkers()) {
IrisMarker marker = getLoader().getMarkerLoader().load(j.getMarker());

if (marker == null) {
continue;
}

var list = markerCandidates.getOrDefault(j, List.of());
Collections.shuffle(list);

int max = j.getMaximumMarkers();
for (BlockPosition i : list) {
if (max <= 0) {
break;
}

boolean a1 = placer.get(i.getX(), i.getY() + 1, i.getZ()).getMaterial().isAir();
boolean a2 = placer.get(i.getX(), i.getY() + 2, i.getZ()).getMaterial().isAir();

if (!marker.isEmptyAbove() || (a1 && a2)) {
placer.getEngine().getMantle().getMantle().set(i.getX(), i.getY(), i.getZ(), new MatterMarker(j.getMarker()));
max--;
}
}
}
}

} catch (Throwable e) {
e.printStackTrace();
Iris.reportError(e);
Expand Down