mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-08-24 14:52:50 +02:00
112 lines
4.5 KiB
Diff
112 lines
4.5 KiB
Diff
From 392f40cacbe54abdf40983ca6eba65a748d7989d Mon Sep 17 00:00:00 2001
|
|
From: tr7zw <tr7zw@live.de>
|
|
Date: Mon, 23 Mar 2020 23:11:10 +0100
|
|
Subject: [PATCH] Add option for only players to have collisions with Entities
|
|
|
|
---
|
|
src/main/java/de/tr7zw/yapfa/YapfaConfig.java | 6 ++
|
|
.../net/minecraft/server/EntityLiving.java | 68 ++++++++++---------
|
|
2 files changed, 43 insertions(+), 31 deletions(-)
|
|
|
|
diff --git a/src/main/java/de/tr7zw/yapfa/YapfaConfig.java b/src/main/java/de/tr7zw/yapfa/YapfaConfig.java
|
|
index 35ac0206c..071e9f9a5 100644
|
|
--- a/src/main/java/de/tr7zw/yapfa/YapfaConfig.java
|
|
+++ b/src/main/java/de/tr7zw/yapfa/YapfaConfig.java
|
|
@@ -206,4 +206,10 @@ public class YapfaConfig {
|
|
disableEntityCollisionboxes = getBoolean("settings.disableEntityCollisionboxes", false);
|
|
}
|
|
|
|
+ public static boolean onlyPlayerCollisions = false;
|
|
+ private static void onlyPlayerCollisions() {
|
|
+ onlyPlayerCollisions = getBoolean("settings.onlyPlayerCollisions", false);
|
|
+ }
|
|
+
|
|
+
|
|
}
|
|
\ No newline at end of file
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index 0b92fda23..3b4d2ae5a 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -2836,40 +2836,46 @@ public abstract class EntityLiving extends Entity {
|
|
if (i <= 0 && world.paperConfig.maxCollisionsPerEntity <= 0) {
|
|
return;
|
|
}
|
|
- // Paper - end don't run getEntities if we're not going to use its result
|
|
+ // Tuinity - end don't run getEntities if we're not going to use its result
|
|
+ // YAPFA start
|
|
// Tuinity start - reduce memory allocation from collideNearby
|
|
List<Entity> list = com.tuinity.tuinity.util.CachedLists.getTempGetEntitiesList();
|
|
- this.world.getEntities(this, this.getBoundingBox(), IEntitySelector.a(this), list);
|
|
try {
|
|
- // Tuinity end - reduce memory allocation from collideNearby
|
|
-
|
|
- if (!list.isEmpty()) {
|
|
- // Paper - move up
|
|
- int j;
|
|
-
|
|
- if (i > 0 && list.size() > i - 1 && this.random.nextInt(4) == 0) {
|
|
- j = 0;
|
|
-
|
|
- for (int k = 0; k < list.size(); ++k) {
|
|
- if (!((Entity) list.get(k)).isPassenger()) {
|
|
- ++j;
|
|
- }
|
|
- }
|
|
-
|
|
- if (j > i - 1) {
|
|
- this.damageEntity(DamageSource.CRAMMING, 6.0F);
|
|
- }
|
|
- }
|
|
-
|
|
- numCollisions = Math.max(0, numCollisions - world.paperConfig.maxCollisionsPerEntity); // Paper
|
|
- for (j = 0; j < list.size() && numCollisions < world.paperConfig.maxCollisionsPerEntity; ++j) { // Paper
|
|
- Entity entity = (Entity) list.get(j);
|
|
- entity.numCollisions++; // Paper
|
|
- numCollisions++; // Paper
|
|
-
|
|
- this.C(entity);
|
|
- }
|
|
- }
|
|
+ if(de.tr7zw.yapfa.YapfaConfig.onlyPlayerCollisions) {
|
|
+ this.world.getEntities(this, this.getBoundingBox(), entity -> entity.getEntityType() == EntityTypes.PLAYER, list);
|
|
+ } else {
|
|
+ this.world.getEntities(this, this.getBoundingBox(), IEntitySelector.a(this), list);
|
|
+ }
|
|
+ // Tuinity end - reduce memory allocation from collideNearby
|
|
+ // YAPFA end
|
|
+
|
|
+ if (!list.isEmpty()) {
|
|
+ // Paper - move up
|
|
+ int j;
|
|
+
|
|
+ if (i > 0 && list.size() > i - 1 && this.random.nextInt(4) == 0) {
|
|
+ j = 0;
|
|
+
|
|
+ for (int k = 0; k < list.size(); ++k) {
|
|
+ if (!((Entity) list.get(k)).isPassenger()) {
|
|
+ ++j;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (j > i - 1) {
|
|
+ this.damageEntity(DamageSource.CRAMMING, 6.0F);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ numCollisions = Math.max(0, numCollisions - world.paperConfig.maxCollisionsPerEntity); // Paper
|
|
+ for (j = 0; j < list.size() && numCollisions < world.paperConfig.maxCollisionsPerEntity; ++j) { // Paper
|
|
+ Entity entity = (Entity) list.get(j);
|
|
+ entity.numCollisions++; // Paper
|
|
+ numCollisions++; // Paper
|
|
+
|
|
+ this.C(entity);
|
|
+ }
|
|
+ }
|
|
} finally { // Tuinity start - reduce memory allocation from collideNearby
|
|
com.tuinity.tuinity.util.CachedLists.returnTempGetEntitiesList(list);
|
|
} // Tuinity end - reduce memory allocation from collideNearby
|
|
--
|
|
2.25.1.windows.1
|
|
|