mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-26 20:55:30 +01:00
05691646ca
* add second origami fork * Add Origmai2 * Move configs, exclude purpur again * Add missing config entry * Update README.md * Create LICENSE * fix lithium license * fix fix lithium license Co-authored-by: tr7zw <tr7zw@live.de>
103 lines
4.5 KiB
Diff
103 lines
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: tr7zw <tr7zw@live.de>
|
|
Date: Fri, 31 Jul 2020 21:25:13 -0500
|
|
Subject: [PATCH] Add option for only players to have collisions with
|
|
|
|
|
|
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
|
|
index 19bea6ee83d8b25da022662253328fb6384f40d9..2cee6e02a7dcbacb5f002f9c5917a2e26bcf2c82 100644
|
|
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
|
|
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
|
|
@@ -206,4 +206,8 @@ public class YatopiaConfig {
|
|
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 9f2aab1cb100cb6f9048d840db6fc15947a26847..ac029aed60e90072d214399d1f8901957af46ba3 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -2843,40 +2843,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
|
|
+ // Yatopia 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(dev.tr7zw.yatopia.YatopiaConfig.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
|
|
+ // Yatopia 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
|