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/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index b4d76494851601d61a69e2f060727a68f4461267..6262246c4018c660705fbad028f297fc44e7197f 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -710,4 +710,9 @@ public class PaperWorldConfig { wanderingTraderSpawnChanceMin = getInt("wandering-trader.spawn-chance-min", wanderingTraderSpawnChanceMin); wanderingTraderSpawnChanceMax = getInt("wandering-trader.spawn-chance-max", wanderingTraderSpawnChanceMax); } + + public boolean fixClimbingBypassingCrammingRule = false; + private void fixClimbingBypassingCrammingRule() { + fixClimbingBypassingCrammingRule = getBoolean("fix-climbing-bypassing-cramming-rule", fixClimbingBypassingCrammingRule); + } } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 2a3025793db52a18e58f832c9da78c6c3b39d33c..d801486565865cf3b56e9d80b7c1643e9b0f4597 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -1575,6 +1575,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne } public boolean isCollidable() { + // Paper start + return isCollidable(false); + } + + public boolean isCollidable(boolean ignoreClimbing) { + // Paper end return false; } diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java index a5b731bab16bf05351fee7e64ab6ae4d830309f7..358bb6244b7b9e785c7dcc3725ee00cfbb917cec 100644 --- a/src/main/java/net/minecraft/world/entity/EntityLiving.java +++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java @@ -137,7 +137,6 @@ import org.bukkit.event.entity.EntityTeleportEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; // CraftBukkit end -import co.aikar.timings.MinecraftTimings; // Paper public abstract class EntityLiving extends Entity { @@ -2959,7 +2958,7 @@ public abstract class EntityLiving extends Entity { return; } // Paper - end don't run getEntities if we're not going to use its result - List list = this.world.getEntities(this, this.getBoundingBox(), IEntitySelector.a(this)); + List list = this.world.getEntities(this, this.getBoundingBox(), IEntitySelector.pushable(this, world.paperConfig.fixClimbingBypassingCrammingRule)); // Paper - fix climbing bypassing cramming rule if (!list.isEmpty()) { // Paper - move up @@ -3097,9 +3096,16 @@ public abstract class EntityLiving extends Entity { return !this.dead && this.collides; // CraftBukkit } + // Paper start @Override public boolean isCollidable() { - return this.isAlive() && !this.isSpectator() && !this.isClimbing() && this.collides; // CraftBukkit + return this.isCollidable(world.paperConfig.fixClimbingBypassingCrammingRule); + } + + @Override + public boolean isCollidable(boolean ignoreClimbing) { + return this.isAlive() && !this.isSpectator() && (ignoreClimbing || !this.isClimbing()) && this.collides; // CraftBukkit + // Paper end } // CraftBukkit start - collidable API diff --git a/src/main/java/net/minecraft/world/entity/IEntitySelector.java b/src/main/java/net/minecraft/world/entity/IEntitySelector.java index c8d7ea8cfa4945af4a6675172b931a4cc3ca2801..f5e32faeb6d937cf90b1f3ea251b5cfc91f2338d 100644 --- a/src/main/java/net/minecraft/world/entity/IEntitySelector.java +++ b/src/main/java/net/minecraft/world/entity/IEntitySelector.java @@ -51,11 +51,17 @@ public final class IEntitySelector { } public static Predicate a(Entity entity) { + // Paper start - ignoreClimbing param + return pushable(entity, false); + } + + public static Predicate pushable(Entity entity, boolean ignoreClimbing) { + // Paper end ScoreboardTeamBase scoreboardteambase = entity.getScoreboardTeam(); ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteambase == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteambase.getCollisionRule(); return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.g.and((entity1) -> { - if (!entity1.canCollideWith(entity) || !entity.canCollideWith(entity1)) { // CraftBukkit - collidable API + if (!entity1.isCollidable(ignoreClimbing) || !entity1.canCollideWith(entity) || !entity.canCollideWith(entity1)) { // CraftBukkit - collidable API // Paper - isCollidable return false; } else if (entity.world.isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).ez())) { return false; diff --git a/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java b/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java index 2167590677c68d261b804a16853bd943f16a76dd..61ebb278cf4ef57ae7a86c6c6ef1fa14559f21e2 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java @@ -76,7 +76,7 @@ public class EntityBat extends EntityAmbient { } @Override - public boolean isCollidable() { + public boolean isCollidable(boolean ignoreClimbing) { // Paper return false; } diff --git a/src/main/java/net/minecraft/world/entity/animal/EntityParrot.java b/src/main/java/net/minecraft/world/entity/animal/EntityParrot.java index e93375171462b95e270230f5f72f7eb5c6b0ff58..699dd0ac1f8d0d340ab1a560106336fc7cc95d5b 100644 --- a/src/main/java/net/minecraft/world/entity/animal/EntityParrot.java +++ b/src/main/java/net/minecraft/world/entity/animal/EntityParrot.java @@ -368,8 +368,8 @@ public class EntityParrot extends EntityPerchable implements EntityBird { } @Override - public boolean isCollidable() { - return super.isCollidable(); // CraftBukkit - collidable API + public boolean isCollidable(boolean ignoreClimbing) { // Paper + return super.isCollidable(ignoreClimbing); // CraftBukkit - collidable API // Paper } @Override diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java b/src/main/java/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java index d05391290dc11440aae5f38328a0530c500ac601..d678e3164ecdb7f0c600597bcb39d1054dfbc4b2 100644 --- a/src/main/java/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java +++ b/src/main/java/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java @@ -227,7 +227,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInven } @Override - public boolean isCollidable() { + public boolean isCollidable(boolean ignoreClimbing) { // Paper return !this.isVehicle(); } diff --git a/src/main/java/net/minecraft/world/entity/decoration/EntityArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/EntityArmorStand.java index 5eb900619951083b9a777b1645cb5495b99968ec..c0e0750adef0ae6aff7635c84f6585f06c5fc38d 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/EntityArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/EntityArmorStand.java @@ -362,7 +362,7 @@ public class EntityArmorStand extends EntityLiving { } @Override - public boolean isCollidable() { + public boolean isCollidable(boolean ignoreClimbing) { // Paper return false; } diff --git a/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java index 25a6f53888293994a50128bcbcbb88ff141c5395..add2aef0192a3b3767c1e477145978b9702c0fb4 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java @@ -150,7 +150,7 @@ public class EntityBoat extends Entity { } @Override - public boolean isCollidable() { + public boolean isCollidable(boolean ignoreClimbing) { // Paper return true; } diff --git a/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java b/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java index 7d91e6b75a8a827853b0ca8e53b8ec19e2cf1092..2e3ceab3e34f7756764b3471b13d48d1263ecba9 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java @@ -145,7 +145,7 @@ public abstract class EntityMinecartAbstract extends Entity { } @Override - public boolean isCollidable() { + public boolean isCollidable(boolean ignoreClimbing) { // Paper return true; }