PaperMC/Spigot-Server-Patches/0605-Climbing-should-not-bypass-cramming-gamerule.patch

180 lines
9.2 KiB
Diff
Raw Normal View History

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 5a451cc855de57f79a57670ba38e3af2343cb510..7d3207a9af8360ddad228281d6aa65e1a0d24157 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -712,4 +712,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 bb1a3fb7d0c0b770636971877bed045005787e64..f35afa4d8d087649f57020e4f89185cffcb1ed3a 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
2021-03-16 14:04:28 +01:00
@@ -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 60dfa764898b59b60aec2da9580a80634e624dbe..b56c801c02e4f206b72db7dd74672727104bf246 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
2021-03-16 14:04:28 +01:00
@@ -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 {
2021-03-16 14:04:28 +01:00
@@ -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<Entity> list = this.world.getEntities(this, this.getBoundingBox(), IEntitySelector.a(this));
+ List<Entity> 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
2021-03-16 14:04:28 +01:00
@@ -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
2021-03-16 16:50:45 +01:00
index c8d7ea8cfa4945af4a6675172b931a4cc3ca2801..f5e32faeb6d937cf90b1f3ea251b5cfc91f2338d 100644
--- a/src/main/java/net/minecraft/world/entity/IEntitySelector.java
+++ b/src/main/java/net/minecraft/world/entity/IEntitySelector.java
2021-03-16 16:50:45 +01:00
@@ -51,11 +51,17 @@ public final class IEntitySelector {
}
public static Predicate<Entity> a(Entity entity) {
+ // Paper start - ignoreClimbing param
+ return pushable(entity, false);
+ }
+
+ public static Predicate<Entity> 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
2021-03-16 14:04:28 +01:00
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
2021-03-16 14:04:28 +01:00
@@ -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;
}