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 a0718a0cc2ed15a5350b1ee77747d93c6a92048d..57b85654c5af2e3c3681e3a03c11d5a02703749d 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -2049,6 +2049,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } 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 d15e62da0307728a7c2be191a27f87da1bb29f49..de06ae3e8757c923a6f3f475a34885d2f15af46e 100644 --- a/src/main/java/net/minecraft/world/entity/EntitySelector.java +++ b/src/main/java/net/minecraft/world/entity/EntitySelector.java @@ -45,11 +45,17 @@ 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 Team scoreboardteambase = entity.getTeam(); Team.CollisionRule scoreboardteambase_enumteampush = scoreboardteambase == null ? Team.CollisionRule.ALWAYS : scoreboardteambase.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 5ea6ffe3a2c250ea3f6f7bdd1d17645500d1795f..b9162e3d7ad429b0c18dde43e449e4716da2c4bd 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3398,7 +3398,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 @@ -3558,9 +3558,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 867717f130b6fcd48f39d40b10b3f514dbb8798c..5beaa849a250ea005733250ad3edfa8382224667 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java @@ -87,7 +87,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 2f5056b00e4475906ffb1f1938cacb191169809d..e1874aaa0065a6e8e6ae043713c22f08b58b5e21 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Parrot.java +++ b/src/main/java/net/minecraft/world/entity/animal/Parrot.java @@ -381,8 +381,8 @@ public class Parrot extends ShoulderRidingEntity implements VariantHolder { } @Override - public boolean isPushable() { + public boolean isCollidable(boolean ignoreClimbing) { // Paper return true; }