Yatopia/patches/server/0007-Add-option-for-only-players-to-have-collisions-with.patch
budgidiere ff560e687c
[WIP] Better Patch System (#18)
* Update build.yml

* Remove 3rd party patches

* Add Upsteam Submodules

* Fix patches

* ?

* Fix patches

* Add Fast Init script

* Lots of stuff

also it's broke

* more broken

* fixes

* mor stuff

* gfhfgh

hg

* fix patch

* fix up script

* update submodule

* add papercut

* update tuinity

* update gitmodules

* fix var name

* fix more var stuff

* some how it's not deleting shit anymore

* should now use the branch it just made

why are we doing this again?

* now it does thing thing

* return previous so YAPFA can use it

* ok now it really does the thing

* for REAL it does the thing

* don't do the thing because it causes too many problems

* fix api

* work

* use better patching for YAPFA patches

* fix better patching

* more fixes

* new patches stuff

* remove old 3rd parry patches add removed akarin patches

* make new branch for making patches

* hopefully build patches correctly

* fix gitignore and add config patches

* remove papercut files

* fix some weirdness

* fix bug

* time to do some fixin' 👀

* New Patch System Rebased Patches

* fix full build

* exit 1

* fix

* Remove patch

* Hopefully fix compile errors

* fixes

* this might work

* don't use rej for our patches

* tmp disable cache

* some times case sensitivity is dumb

* my sanity is at an all time low :)

* dfg

* readd cahce

* fix?

* Update Upstream

* fix perms

* fix

* fix api

* Redo API

* rm folders

* fix villager brain patch

* emc explosion pref

* fixed aikar's shit

* betterfix

* fix lagggg

* Origami

* Origami Fixes

* Update readme

* test async path finding

* WIP Async Path Finding

* WIP fix async path finding

* same as bellow

* same

* update to newer funcs

* fix newer funcs

* fix author

* Updates, Fixes, and new patches

* fixes

* possibly async flying path finding

* minor asnyc pathfinding fix

* test remove non asnyc path finder

* WIP make all path finding async

* Rename everything

* Exec flag

* Rebuild hashes

* remove dupe patch

* fix?

* Fix packages, redirect config

* old nav class is now async and back

* add getchatcolor.getbyid and handle patches with a . in them better

Co-authored-by: tr7zw <tr7zw@live.de>
Co-authored-by: Unknown <unknown@example.com>
Co-authored-by: Ovydux <68059159+Ovydux@users.noreply.github.com>
2020-08-03 11:48:42 -05:00

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 9e79187d29957204194b0543f7346cf3a51ed5ce..1ee23408b493eb707791bd23b474e03510993fb3 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2835,40 +2835,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