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 69e91a732a497b2ffa906088a636947ce9a9ec36..d455406df1f3a4c3d1bd016d50d1d7025366ae80 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -3631,7 +3631,7 @@ public abstract class LivingEntity extends Entity implements Attackable, net.caf 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()) { @@ -3769,7 +3769,14 @@ public abstract class LivingEntity extends Entity implements Attackable, net.caf return; } // Paper end - don't run getEntities if we're not going to use its result - List entities = this.level().getEntities(this, this.getBoundingBox(), EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - Climbing should not bypass cramming gamerule + // Leaf start - Only player pushable + final AABB box = this.getBoundingBox(); + final Predicate conditions = EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule); + + List entities = org.dreeam.leaf.config.modules.gameplay.OnlyPlayerPushable.enabled + ? getNearbyPushablePlayers(this, box, conditions) + : this.level().getEntities(this, box, conditions); // Paper - Climbing should not bypass cramming gamerule + // Leaf end - Only player pushable if (!entities.isEmpty()) { // Paper - don't run getEntities if we're not going to use its result; moved up if (_int > 0 && entities.size() > _int - 1 && this.random.nextInt(4) == 0) { @@ -3802,6 +3809,44 @@ public abstract class LivingEntity extends Entity implements Attackable, net.caf } } + // Leaf start - Only player pushable + public List getNearbyPushablePlayers(Entity entity, AABB box, Predicate 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 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 ArrayList<>(); + } + + List 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 ArrayList<>(len - i); + ret.add(player); + } else { + ret.add(player); + } + } + } + + return ret == null ? new ArrayList<>() : ret; + } + // Leaf end - Only player pushable + protected void checkAutoSpinAttack(AABB boundingBoxBeforeSpin, AABB boundingBoxAfterSpin) { AABB aabb = boundingBoxBeforeSpin.minmax(boundingBoxAfterSpin); List 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 21153f37c169e987d7876d1b914105223ac10ee7..a8bd9f027b5ce360b9e720a7734451bcf9f701d4 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java @@ -326,7 +326,7 @@ public class ArmorStand extends LivingEntity implements net.caffeinemc.mods.lith @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);