9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-archived-patches/unapplied/mcserver/0191-Only-player-pushable.patch
Dreeam 8bffdef317 More patches
Shallou - Habitat
Genre: Progressive House (maybe)
2025-09-29 14:23:25 -04:00

93 lines
5.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Wed, 27 Nov 2024 23:13:12 -0500
Subject: [PATCH] Only player pushable
Useful for extreme cases like massive entities collide together in a small area
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index 600e107371507b081c151af26a7d3ff85c59d418..5aec9481b3b9e59911a948c876e4e2a5b0876357 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -3694,7 +3694,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
this.checkAutoSpinAttack(boundingBox, this.getBoundingBox());
}
- this.pushEntities();
+ if (!org.dreeam.leaf.config.modules.gameplay.OnlyPlayerPushable.enabled) this.pushEntities(); // Leaf - Only player pushable
// Paper start - Add EntityMoveEvent
// Purpur start - Ridables
if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) {
@@ -3841,7 +3841,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
return;
}
// Paper end - don't run getEntities if we're not going to use its result
- List<Entity> pushableEntities = this.level().getPushableEntities(this, this.getBoundingBox());
+ // Leaf start - Only player pushable
+ final AABB box = this.getBoundingBox();
+ List<Entity> pushableEntities = org.dreeam.leaf.config.modules.gameplay.OnlyPlayerPushable.enabled
+ ? getNearbyPushablePlayers(this, box, EntitySelector.pushableBy(this))
+ : this.level().getPushableEntities(this, box);
+ // Leaf end - Only player pushable
if (!pushableEntities.isEmpty()) {
if (this.level() instanceof ServerLevel serverLevel) {
// Paper - don't run getEntities if we're not going to use its result; moved up
@@ -3875,6 +3880,44 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
}
}
+ // Leaf start - Only player pushable
+ public List<Entity> getNearbyPushablePlayers(Entity entity, AABB box, Predicate<Entity> conditions) {
+ final Vec3 vec = entity.position;
+ final net.minecraft.core.BlockPos.MutableBlockPos mutablePos = new net.minecraft.core.BlockPos.MutableBlockPos();
+
+ mutablePos.set(vec.x, vec.y, vec.z);
+
+ final ca.spottedleaf.moonrise.common.list.ReferenceList<ServerPlayer> players = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel) this.level()).moonrise$getNearbyPlayers().getPlayers(
+ mutablePos, ca.spottedleaf.moonrise.common.misc.NearbyPlayers.NearbyMapType.SPAWN_RANGE
+ );
+
+ if (players == null) {
+ return new java.util.ArrayList<>();
+ }
+
+ List<Entity> ret = null;
+
+ final ServerPlayer[] raw = players.getRawDataUnchecked();
+ final int len = players.size();
+
+ java.util.Objects.checkFromIndexSize(0, len, raw.length);
+
+ for (int i = 0; i < len; ++i) {
+ final ServerPlayer player = raw[i];
+ if (player != entity && box.intersects(player.getBoundingBox()) && conditions.test(player)) {
+ if (ret == null) {
+ ret = new java.util.ArrayList<>(len - i);
+ ret.add(player);
+ } else {
+ ret.add(player);
+ }
+ }
+ }
+
+ return ret == null ? new java.util.ArrayList<>() : ret;
+ }
+ // Leaf end - Only player pushable
+
protected void checkAutoSpinAttack(AABB boundingBoxBeforeSpin, AABB boundingBoxAfterSpin) {
AABB aabb = boundingBoxBeforeSpin.minmax(boundingBoxAfterSpin);
List<Entity> entities = this.level().getEntities(this, aabb);
diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java
index 95d835ce4c733cbea457427a0d065c05a59704d9..98a1795be167d4ecde25a89ba031827ccbd14483 100644
--- a/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -205,7 +205,7 @@ public class ArmorStand extends LivingEntity {
@Override
protected void pushEntities() {
- if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper - Option to prevent armor stands from doing entity lookups
+ if (org.dreeam.leaf.config.modules.gameplay.OnlyPlayerPushable.enabled || !this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper - Option to prevent armor stands from doing entity lookups // Leaf - Only player pushable
for (Entity entity : this.level().getEntitiesOfClass(AbstractMinecart.class, this.getBoundingBox(), RIDABLE_MINECARTS)) { // Paper - optimise collisions
if (this.distanceToSqr(entity) <= 0.2) {
entity.push(this);