From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sun, 23 Aug 2020 20:59:00 +0200 Subject: [PATCH] Climbing should not bypass cramming gamerule diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index f0158217eceeaf73555a741957324ce0258fa6b2..90621d3dfe8660f9b389ed292a3582a5dbb726bd 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -2062,6 +2062,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } public boolean isPushable() { + // Paper start + return isCollidable(false); + } + + public boolean isCollidable(boolean ignoreClimbing) { + // Paper end return false; } diff --git a/src/main/java/net/minecraft/world/entity/EntitySelector.java b/src/main/java/net/minecraft/world/entity/EntitySelector.java index 68e4440765636295a74ea942862d772d47282ad6..93a41156a01a1638f3ef469b1518a07e7961f378 100644 --- a/src/main/java/net/minecraft/world/entity/EntitySelector.java +++ b/src/main/java/net/minecraft/world/entity/EntitySelector.java @@ -46,11 +46,16 @@ public final class EntitySelector { } public static Predicate pushableBy(Entity entity) { + // Paper start - ignoreClimbing param + return pushable(entity, false); + } + public static Predicate pushable(Entity entity, boolean ignoreClimbing) { + // Paper end PlayerTeam scoreboardteam = entity.getTeam(); Team.CollisionRule scoreboardteambase_enumteampush = scoreboardteam == null ? Team.CollisionRule.ALWAYS : scoreboardteam.getCollisionRule(); return (Predicate) (scoreboardteambase_enumteampush == Team.CollisionRule.NEVER ? Predicates.alwaysFalse() : EntitySelector.NO_SPECTATORS.and((entity1) -> { - if (!entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API + if (!entity1.isCollidable(ignoreClimbing) || !entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API // Paper - isCollidable return false; } else if (entity.level().isClientSide && (!(entity1 instanceof Player) || !((Player) entity1).isLocalPlayer())) { return false; diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index 90c66f87e721ef34bf3f47b601456fece3064225..bf617621c88c68198709d1ed238622c3fcec89bd 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3426,7 +3426,7 @@ public abstract class LivingEntity extends Entity implements Attackable { return; } // Paper end - don't run getEntities if we're not going to use its result - List list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushableBy(this)); + List list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - fix climbing bypassing cramming rule if (!list.isEmpty()) { // Paper - moved up @@ -3616,9 +3616,16 @@ public abstract class LivingEntity extends Entity implements Attackable { return !this.isRemoved() && this.collides; // CraftBukkit } + // Paper start @Override public boolean isPushable() { - return this.isAlive() && !this.isSpectator() && !this.onClimbable() && this.collides; // CraftBukkit + return this.isCollidable(this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule); + } + + @Override + public boolean isCollidable(boolean ignoreClimbing) { + return this.isAlive() && !this.isSpectator() && (ignoreClimbing || !this.onClimbable()) && this.collides; // CraftBukkit + // Paper end } // CraftBukkit start - collidable API diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java index bc9a710a92662b1f69b0f5b289780fe0a0d5ed32..6b614818b14ecfc8fc82b523eeb7e21fdf9bf1ba 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java @@ -90,7 +90,7 @@ public class Bat extends AmbientCreature { } @Override - public boolean isPushable() { + public boolean isCollidable(boolean ignoreClimbing) { // Paper return false; } diff --git a/src/main/java/net/minecraft/world/entity/animal/Parrot.java b/src/main/java/net/minecraft/world/entity/animal/Parrot.java index fbad0e512b990c3d6885ecf92766ba6fd851cc20..4c34edc55fa0e136ccf49a3aef001f413274dfac 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Parrot.java +++ b/src/main/java/net/minecraft/world/entity/animal/Parrot.java @@ -383,8 +383,8 @@ public class Parrot extends ShoulderRidingEntity implements VariantHolder { } @Override - public boolean isPushable() { + public boolean isCollidable(boolean ignoreClimbing) { // Paper return true; }