Paper/patches/server/0562-Climbing-should-not-bypass-cramming-gamerule.patch

174 lines
8.8 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
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
2021-06-17 10:37:27 +02:00
index 935bb237f8ecd63ca4cec64a7c7a341c9d3358e5..208690ceca2485b54acde5123ba494d71367791b 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2021-06-15 15:20:52 +02:00
@@ -74,6 +74,11 @@ public class PaperWorldConfig {
2021-06-11 14:02:28 +02:00
wanderingTraderSpawnChanceMax = getInt("wandering-trader.spawn-chance-max", wanderingTraderSpawnChanceMax);
}
2021-06-14 18:58:00 +02:00
2021-06-11 14:02:28 +02:00
+ public boolean fixClimbingBypassingCrammingRule = false;
+ private void fixClimbingBypassingCrammingRule() {
+ fixClimbingBypassingCrammingRule = getBoolean("fix-climbing-bypassing-cramming-rule", fixClimbingBypassingCrammingRule);
+ }
2021-06-14 18:58:00 +02:00
+
public short keepLoadedRange;
private void keepLoadedRange() {
keepLoadedRange = (short) (getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 10)) * 16);
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
2021-06-17 23:39:36 +02:00
index bf9813eee5865e7363fce3c015a3b8e3e637ce75..408d0f51353c745cbdc5c314dd25fa0c8a13441c 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
2021-06-17 23:39:36 +02:00
@@ -1723,6 +1723,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
2021-06-11 14:02:28 +02:00
}
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
2021-06-14 18:58:00 +02:00
index 8fb89326395a7e70982c0d757b506565e98b12a4..a060cca08631fb42041e3a79a9abc422fe7757af 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/EntitySelector.java
+++ b/src/main/java/net/minecraft/world/entity/EntitySelector.java
2021-06-14 18:58:00 +02:00
@@ -44,11 +44,17 @@ public final class EntitySelector {
2021-06-11 14:02:28 +02:00
}
public static Predicate<Entity> pushableBy(Entity entity) {
+ // Paper start - ignoreClimbing param
+ return pushable(entity, false);
+ }
+
+ public static Predicate<Entity> 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) -> {
2021-06-14 18:58:00 +02:00
- 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
2021-06-11 14:02:28 +02:00
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
2021-06-17 23:39:36 +02:00
index a524ea7ff8206036de07d24683adadee8bd41eac..34304fd25a73b3b7e4f078e85b6bee94ab2cc8c8 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
2021-06-16 22:17:53 +02:00
@@ -3271,7 +3271,7 @@ public abstract class LivingEntity extends Entity {
2021-06-11 14:02:28 +02:00
return;
}
2021-06-14 18:58:00 +02:00
// Paper end - don't run getEntities if we're not going to use its result
2021-06-11 14:02:28 +02:00
- List<Entity> list = this.level.getEntities(this, this.getBoundingBox(), EntitySelector.pushableBy(this));
+ List<Entity> list = this.level.getEntities(this, this.getBoundingBox(), EntitySelector.pushable(this, level.paperConfig.fixClimbingBypassingCrammingRule)); // Paper - fix climbing bypassing cramming rule
if (!list.isEmpty()) {
// Paper - move up
2021-06-16 22:17:53 +02:00
@@ -3438,9 +3438,16 @@ public abstract class LivingEntity extends Entity {
2021-06-14 18:58:00 +02:00
return !this.isRemoved() && this.collides; // CraftBukkit
2021-06-11 14:02:28 +02:00
}
+ // Paper start
@Override
public boolean isPushable() {
- return this.isAlive() && !this.isSpectator() && !this.onClimbable() && this.collides; // CraftBukkit
+ return this.isCollidable(level.paperConfig.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
2021-06-16 00:24:12 +02:00
index 9cd91a73ae1a6ad550b9482db1fb7d72d7247c6e..153194d937d210e2e4fd8864e4a3c000f85d7e2e 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
2021-06-14 18:58:00 +02:00
@@ -83,7 +83,7 @@ public class Bat extends AmbientCreature {
2021-06-11 14:02:28 +02:00
}
@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
2021-06-14 18:58:00 +02:00
index 23f87848b42d180c94b5659b184a768a756deed8..345fe87d5d6c3883c28d2c1b34d1020e18864d97 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/animal/Parrot.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Parrot.java
2021-06-14 18:58:00 +02:00
@@ -380,8 +380,8 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal {
2021-06-11 14:02:28 +02:00
}
@Override
- public boolean isPushable() {
- return super.isPushable(); // 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/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
2021-06-16 00:24:12 +02:00
index 6ce4c3938fb5331b4d439c6a42a7bb5fffb1d0a0..ba58e066cca533dfed7610a730c4dd7423fe124d 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
2021-06-14 18:58:00 +02:00
@@ -240,7 +240,7 @@ public abstract class AbstractHorse extends Animal implements ContainerListener,
2021-06-11 14:02:28 +02:00
}
@Override
- public boolean isPushable() {
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
return !this.isVehicle();
}
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
2021-06-16 00:24:12 +02:00
index 069cdfce085909991a69ebec3004d407526d469d..5fc66d7096afcfe63eba774e1dc330ac3263e4b0 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
2021-06-14 18:58:00 +02:00
@@ -345,7 +345,7 @@ public class ArmorStand extends LivingEntity {
2021-06-11 14:02:28 +02:00
}
@Override
- public boolean isPushable() {
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
return false;
}
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
2021-06-14 18:58:00 +02:00
index fa889f93a5c6782957bdbf803915cb5e80e05f3e..9653b142c199c068e4d6175bcd3cbecb6465853f 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
2021-06-14 18:58:00 +02:00
@@ -149,7 +149,7 @@ public abstract class AbstractMinecart extends Entity {
2021-06-11 14:02:28 +02:00
}
@Override
- public boolean isPushable() {
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
return true;
}
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
2021-06-14 18:58:00 +02:00
index 3f1059569da23bd02c00279050bf7bce7a160462..a1b93f2878e22fa1d0cad639416d2dc5b8339c73 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
2021-06-14 18:58:00 +02:00
@@ -158,7 +158,7 @@ public class Boat extends Entity {
2021-06-11 14:02:28 +02:00
}
@Override
- public boolean isPushable() {
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
return true;
}