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

174 Zeilen
8.8 KiB
Diff

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-15 15:20:52 +02:00
index d76b292cdfa2ae4d84a449da7f66faba494f6b03..0ec093e5d8865e909d0d105e27b81b31bdb5c192 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-15 07:38:36 +02:00
index c3b05e73f9f42bdc2ab5d43fa905dd4cf5e39440..3ca07887bc67587cd820556d160037ca62c32c10 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-14 18:58:00 +02:00
@@ -1704,6 +1704,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-14 18:58:00 +02:00
index 8781b3ac40f214974ebb3e06c789f1717735d3a6..19ef1b2814270b9385ea15a89dac8c2613a672ee 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-14 18:58:00 +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-14 18:58:00 +02:00
@@ -3438,9 +3438,16 @@ public abstract class LivingEntity extends Entity {
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-14 18:58:00 +02:00
index 7a7b566d781560a85e184a0e67977ba75e6262c5..4716ece9bd1db50c87ccadc44d9ea3c43e741338 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-14 18:58:00 +02:00
index c9e0d66443387f3f3e3999ee84d523550f48f573..d9699a422164c30a8386a8042202e1a8bc0ab2b0 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-14 18:58:00 +02:00
index 5bfec185e15a54ee5fe6eab1aa59d1963d046262..d098d9f9280d2e08596491264a46a8978aaeaca7 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;
}