testserver/patches/server/0558-Climbing-should-not-by...

174 lines
8.8 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00: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
index f4b533b8e8b6c4bb59d032e91a94353f4b201b69..5344d25e7bef34954aa058ec019b4ba8ab4de515 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2021-06-15 13:20:52 +00:00
@@ -74,6 +74,11 @@ public class PaperWorldConfig {
2021-06-11 12:02:28 +00:00
wanderingTraderSpawnChanceMax = getInt("wandering-trader.spawn-chance-max", wanderingTraderSpawnChanceMax);
}
2021-06-14 16:58:00 +00:00
2021-06-11 12:02:28 +00:00
+ public boolean fixClimbingBypassingCrammingRule = false;
+ private void fixClimbingBypassingCrammingRule() {
+ fixClimbingBypassingCrammingRule = getBoolean("fix-climbing-bypassing-cramming-rule", fixClimbingBypassingCrammingRule);
+ }
2021-06-14 16:58:00 +00:00
+
public short keepLoadedRange;
private void keepLoadedRange() {
keepLoadedRange = (short) (getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 10)) * 16);
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index e0d98ed993414f5834dcbd4c4b482209a5cb4188..143f4b9e7247d0d715a69aff69d5652bc9343fa0 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1724,6 +1724,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
2021-06-11 12:02:28 +00: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 16:58:00 +00:00
index 8fb89326395a7e70982c0d757b506565e98b12a4..a060cca08631fb42041e3a79a9abc422fe7757af 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/EntitySelector.java
+++ b/src/main/java/net/minecraft/world/entity/EntitySelector.java
2021-06-14 16:58:00 +00:00
@@ -44,11 +44,17 @@ public final class EntitySelector {
2021-06-11 12:02:28 +00: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 16:58:00 +00: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 12:02:28 +00: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
index d9f867b2d3688c3b5e5ed1d754e3d1d1567af383..df18c754e316335d246091169584419c3b3e2a5d 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
2021-06-15 22:24:12 +00:00
@@ -3270,7 +3270,7 @@ public abstract class LivingEntity extends Entity {
2021-06-11 12:02:28 +00:00
return;
}
2021-06-14 16:58:00 +00:00
// Paper end - don't run getEntities if we're not going to use its result
2021-06-11 12:02:28 +00: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-15 22:24:12 +00:00
@@ -3437,9 +3437,16 @@ public abstract class LivingEntity extends Entity {
2021-06-14 16:58:00 +00:00
return !this.isRemoved() && this.collides; // CraftBukkit
2021-06-11 12:02:28 +00: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-15 22:24:12 +00:00
index 9cd91a73ae1a6ad550b9482db1fb7d72d7247c6e..153194d937d210e2e4fd8864e4a3c000f85d7e2e 100644
2021-06-11 12:02:28 +00: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 16:58:00 +00:00
@@ -83,7 +83,7 @@ public class Bat extends AmbientCreature {
2021-06-11 12:02:28 +00: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 16:58:00 +00:00
index 23f87848b42d180c94b5659b184a768a756deed8..345fe87d5d6c3883c28d2c1b34d1020e18864d97 100644
2021-06-11 12:02:28 +00: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 16:58:00 +00:00
@@ -380,8 +380,8 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal {
2021-06-11 12:02:28 +00: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-15 22:24:12 +00:00
index 6ce4c3938fb5331b4d439c6a42a7bb5fffb1d0a0..ba58e066cca533dfed7610a730c4dd7423fe124d 100644
2021-06-11 12:02:28 +00: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 16:58:00 +00:00
@@ -240,7 +240,7 @@ public abstract class AbstractHorse extends Animal implements ContainerListener,
2021-06-11 12:02:28 +00: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-15 22:24:12 +00:00
index 069cdfce085909991a69ebec3004d407526d469d..5fc66d7096afcfe63eba774e1dc330ac3263e4b0 100644
2021-06-11 12:02:28 +00: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 16:58:00 +00:00
@@ -345,7 +345,7 @@ public class ArmorStand extends LivingEntity {
2021-06-11 12:02:28 +00: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 16:58:00 +00:00
index fa889f93a5c6782957bdbf803915cb5e80e05f3e..9653b142c199c068e4d6175bcd3cbecb6465853f 100644
2021-06-11 12:02:28 +00: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 16:58:00 +00:00
@@ -149,7 +149,7 @@ public abstract class AbstractMinecart extends Entity {
2021-06-11 12:02:28 +00: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 16:58:00 +00:00
index 3f1059569da23bd02c00279050bf7bce7a160462..a1b93f2878e22fa1d0cad639416d2dc5b8339c73 100644
2021-06-11 12:02:28 +00: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 16:58:00 +00:00
@@ -158,7 +158,7 @@ public class Boat extends Entity {
2021-06-11 12:02:28 +00:00
}
@Override
- public boolean isPushable() {
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
return true;
}