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 3d9447b976fbaedb55b526efba7e5d9e7110ade7..d5a5f499bbdc950b66de62370482f122e4a16511 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -1930,6 +1930,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 302676ef78ed5b3b7fc1b04851447ca72eed10c0..a00c3d96f2fc7131d1f4afa7af4e41ace3cfce89 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 450d6c28dcf8969902ab75d4a7b06aa9c3013fb4..fcd670d1371dca3bb644dfea79f98670d75a68a4 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3356,7 +3356,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, level.paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - fix climbing bypassing cramming rule if (!list.isEmpty()) { // Paper - moved up @@ -3516,9 +3516,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(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 eb53029868ceebe08281ae1012e5ae95d555fc93..f5efdf59617d43de18a2267351fa784c0be3ae83 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java @@ -85,7 +85,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 047f8cc00eb361eecc2cb93980b56d61d09a014c..e6e40770acf71b9079e8f6ac07025319dd8e2e4e 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; }