9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-24 01:29:16 +00:00

Merge pull request #1083 from VolmitDev/fix_object_collision_check

fix object collision check
This commit is contained in:
Brian Fopiano
2024-03-30 17:51:40 -04:00
committed by GitHub

View File

@@ -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);