Do not limit the VoxelShape only to its AABB

Thanks leaf for taking my eyes onto it.
Additionally removed the sorting of Producer#fillList . Was causing unnecessary load
This commit is contained in:
Ivan Pekov 2020-09-29 13:36:29 +03:00
parent 0faeed74aa
commit 930a869426
No known key found for this signature in database
GPG Key ID: BC975C392D9CA3A3
2 changed files with 6 additions and 30 deletions

View File

@ -155,7 +155,7 @@ index 0000000000000000000000000000000000000000..20f80ae80de91615ea02f0771f7c020c
+}
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/entity/LithiumEntityCollisions.java b/src/main/java/me/jellysquid/mods/lithium/common/entity/LithiumEntityCollisions.java
new file mode 100644
index 0000000000000000000000000000000000000000..786cbf11f9699d8e2124a8c6196bc5cf202eb69b
index 0000000000000000000000000000000000000000..f2e08aafd31b3adbbbcc96df6aea7a647fb8bdf8
--- /dev/null
+++ b/src/main/java/me/jellysquid/mods/lithium/common/entity/LithiumEntityCollisions.java
@@ -0,0 +1,188 @@
@ -268,7 +268,7 @@ index 0000000000000000000000000000000000000000..786cbf11f9699d8e2124a8c6196bc5cf
+ Producer.fillList(
+ getEntityCollisionProducer(view, entity, box.grow(EPSILON), EntityFilter.getFilter(entity), loadChunks),
+ filled,
+ (voxelShape, axisAlignedBBS) -> axisAlignedBBS.add(voxelShape.getBoundingBox())
+ (voxelShape, axisAlignedBBS) -> VoxelShapes.addBoxesToIfIntersects(voxelShape, box, axisAlignedBBS)
+ );
+ }
+
@ -633,10 +633,10 @@ index 0000000000000000000000000000000000000000..7ed343cfb3130446c85dab2ca04d60f9
+}
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java b/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
new file mode 100644
index 0000000000000000000000000000000000000000..e563e35089f26a7d76858f99b32440cd2eceabf1
index 0000000000000000000000000000000000000000..f3224ea636fef95d368b934ed4b3e9060c4b10a2
--- /dev/null
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
@@ -0,0 +1,67 @@
@@ -0,0 +1,55 @@
+package me.jellysquid.mods.lithium.common.util;
+
+import java.util.List;
@ -683,18 +683,6 @@ index 0000000000000000000000000000000000000000..e563e35089f26a7d76858f99b32440cd
+ if (value == null) { continue; }
+ addFunction.accept(value, list);
+ }
+ if (!list.isEmpty()) {
+ boolean allComparable = true;
+ for (R value : list) {
+ if (!(value instanceof Comparable)) {
+ allComparable = false;
+ break;
+ }
+ }
+ if (allComparable) {
+ list.sort((o1, o2) -> ((Comparable<R>)o1).compareTo(o2));
+ }
+ }
+ }
+
+ Producer<?> EMPTY_PRODUCER = consumer -> false;

View File

@ -8,10 +8,10 @@ major release and reimplemented again if mojang changes stuff with
villagers again.
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java b/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
index e563e35089f26a7d76858f99b32440cd2eceabf1..343cb58abb3deaf8766ea9bc4e425d40249c5acc 100644
index f3224ea636fef95d368b934ed4b3e9060c4b10a2..f2d5878d235fdbfc11c74f87b95f029330c70309 100644
--- a/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
@@ -58,6 +58,28 @@ public interface Producer<T> {
@@ -46,6 +46,16 @@ public interface Producer<T> {
}
}
@ -23,18 +23,6 @@ index e563e35089f26a7d76858f99b32440cd2eceabf1..343cb58abb3deaf8766ea9bc4e425d40
+ if (value == null || list.contains(value)) { continue; }
+ list.add(value);
+ }
+ if (!list.isEmpty()) {
+ boolean allComparable = true;
+ for (T value : list) {
+ if (!(value instanceof Comparable)) {
+ allComparable = false;
+ break;
+ }
+ }
+ if (allComparable) {
+ list.sort((o1, o2) -> ((Comparable<T>)o1).compareTo(o2));
+ }
+ }
+ }
+
Producer<?> EMPTY_PRODUCER = consumer -> false;