From b2934b0cc27b2949bbca6d9a22da238c1538380d Mon Sep 17 00:00:00 2001 From: CrazyDev22 Date: Wed, 27 Mar 2024 19:02:20 +0100 Subject: [PATCH] fix object collision check --- .../java/com/volmit/iris/engine/object/IrisObject.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisObject.java b/core/src/main/java/com/volmit/iris/engine/object/IrisObject.java index 03a306a1c..8b5924e41 100644 --- a/core/src/main/java/com/volmit/iris/engine/object/IrisObject.java +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisObject.java @@ -23,6 +23,7 @@ import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisRegistrant; import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.framework.PlacedObject; import com.volmit.iris.engine.framework.placer.HeightmapObjectPlacer; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KMap; @@ -698,12 +699,15 @@ public class IrisObject extends IrisRegistrant { if (!config.getAllowedCollisions().isEmpty() || !config.getForbiddenCollisions().isEmpty()) { Engine engine = rdata.getEngine(); - String key; BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ()); for (int i = x - Math.floorDiv(w, 2) + (int) offset.getX(); i <= x + Math.floorDiv(w, 2) - (w % 2 == 0 ? 1 : 0) + (int) offset.getX(); i++) { for (int j = y - Math.floorDiv(h, 2) + (int) offset.getY(); j <= y + Math.floorDiv(h, 2) - (h % 2 == 0 ? 1 : 0) + (int) offset.getY(); j++) { for (int k = z - Math.floorDiv(d, 2) + (int) offset.getZ(); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0) + (int) offset.getX(); k++) { - key = engine.getObjectPlacementKey(i, j, k); + PlacedObject p = engine.getObjectPlacement(i, j, k); + if (p == null) continue; + IrisObject o = p.getObject(); + if (o == null) continue; + String key = o.getLoadKey(); if (key != null) { if (config.getForbiddenCollisions().contains(key) && !config.getAllowedCollisions().contains(key)) { // Iris.debug("%s collides with %s (%s / %s / %s)", getLoadKey(), key, i, j, k);