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

158 lines
7.9 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/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
2022-12-23 20:59:11 +01:00
index 6ba3e91c2a937d288b67ec32c818bebf38b04d5c..d8dfd84a8e97e0e852362e1424e50c2f00fe6458 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
2022-12-23 20:59:11 +01:00
@@ -1920,6 +1920,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
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
index 302676ef78ed5b3b7fc1b04851447ca72eed10c0..a00c3d96f2fc7131d1f4afa7af4e41ace3cfce89 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
@@ -45,11 +45,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
index 2ce769b00798f35095f50380083c7cbf4de462ef..beaf3b3bf4a4373d563b5b75238f79299a304db5 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
2022-12-07 21:16:54 +01:00
@@ -3392,7 +3392,7 @@ public abstract class LivingEntity extends Entity {
return;
}
// Paper end - don't run getEntities if we're not going to use its result
- List<Entity> list = this.level.getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushableBy(this));
+ List<Entity> 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
@@ -3556,9 +3556,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().collisions.fixClimbingBypassingCrammingRule);
2021-06-11 14:02:28 +02:00
+ }
+
+ @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
2022-12-07 21:16:54 +01:00
index 4d3a88277e8a68c2d92df6ca46214898eee2a878..320c558bbe80d4bbc641e895ec43cfa2b45e8d70 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
2022-12-07 21:16:54 +01:00
@@ -85,7 +85,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
2022-12-07 21:16:54 +01:00
index a985241b9d80e1f99227adbaf4a2b221ff840a38..2d9aa961df034eab21ecfdb6e6d0ce7cf013505d 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
2022-12-07 21:16:54 +01:00
@@ -386,8 +386,8 @@ public class Parrot extends ShoulderRidingEntity implements VariantHolder<Parrot
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
2022-12-07 21:16:54 +01:00
index eb777842e158e10e81cae505bebc6601f8dae7ef..3a06f48e9aed59d429ef4142785b393898b96f60 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
2022-12-07 21:16:54 +01:00
@@ -259,7 +259,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
index 7ff1e7e4d493770bfdbc0ad5e8f10387cefc42d2..b136cdc13d94bc34c998a1986e0c93525356ac5c 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
2022-06-08 08:25:32 +02:00
@@ -342,7 +342,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
2022-12-07 21:16:54 +01:00
index 39a51f97001ef08f5d2d2eefb25908a3296eec96..8485a1a7d43a20d1326ff3a167fbb398f34efd87 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
2022-12-07 21:16:54 +01:00
@@ -146,7 +146,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
2022-12-07 21:16:54 +01:00
index 9e0c13c50beba36986f9df36933365b14546dcc2..e9d968013c1d8bd00a8014384ef7164b57548fbd 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
2022-12-07 21:16:54 +01:00
@@ -159,7 +159,7 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
2021-06-11 14:02:28 +02:00
}
@Override
- public boolean isPushable() {
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
return true;
}