From 03168769b95746b5251f8dd6d0896814d630a1f3 Mon Sep 17 00:00:00 2001 From: Mariell Hoversholm Date: Sat, 14 Nov 2020 16:49:03 +0100 Subject: [PATCH] Collision option for requiring a player participant Closes #614. --- ...n-for-requiring-a-player-participant.patch | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Spigot-Server-Patches/Collision-option-for-requiring-a-player-participant.patch diff --git a/Spigot-Server-Patches/Collision-option-for-requiring-a-player-participant.patch b/Spigot-Server-Patches/Collision-option-for-requiring-a-player-participant.patch new file mode 100644 index 0000000000..779d07f6d2 --- /dev/null +++ b/Spigot-Server-Patches/Collision-option-for-requiring-a-player-participant.patch @@ -0,0 +1,65 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Mariell Hoversholm +Date: Sat, 14 Nov 2020 16:48:37 +0100 +Subject: [PATCH] Collision option for requiring a player participant + + +diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java ++++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +@@ -0,0 +0,0 @@ public class PaperWorldConfig { + } + } + ++ public boolean onlyPlayersCollide = false; ++ public boolean allowVehicleCollisions = true; ++ private void onlyPlayersCollide() { ++ onlyPlayersCollide = getBoolean("only-players-collide", onlyPlayersCollide); ++ allowVehicleCollisions = getBoolean("allow-vehicle-collisions", allowVehicleCollisions); ++ if (onlyPlayersCollide && !allowVehicleCollisions) { ++ log("Collisions will only work if a player is one of the two entities colliding."); ++ } else if (onlyPlayersCollide) { ++ log("Collisions will only work if a player OR a vehicle is one of the two entities colliding."); ++ } ++ } ++ + public int wanderingTraderSpawnMinuteTicks = 1200; + public int wanderingTraderSpawnDayTicks = 24000; + public int wanderingTraderSpawnChanceFailureIncrement = 25; +diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/Entity.java ++++ b/src/main/java/net/minecraft/server/Entity.java +@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + public void collide(Entity entity) { + if (!this.isSameVehicle(entity)) { + if (!entity.noclip && !this.noclip) { ++ if (this.world.paperConfig.onlyPlayersCollide && !(entity instanceof EntityPlayer || this instanceof EntityPlayer)) return; // Paper + double d0 = entity.locX() - this.locX(); + double d1 = entity.locZ() - this.locZ(); + double d2 = MathHelper.a(d0, d1); +diff --git a/src/main/java/net/minecraft/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/EntityBoat.java ++++ b/src/main/java/net/minecraft/server/EntityBoat.java +@@ -0,0 +0,0 @@ public class EntityBoat extends Entity { + + @Override + public void collide(Entity entity) { ++ if (!this.world.paperConfig.allowVehicleCollisions && this.world.paperConfig.onlyPlayersCollide && !(entity instanceof EntityPlayer)) return; // Paper + if (entity instanceof EntityBoat) { + if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { + // CraftBukkit start +diff --git a/src/main/java/net/minecraft/server/EntityMinecartAbstract.java b/src/main/java/net/minecraft/server/EntityMinecartAbstract.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/EntityMinecartAbstract.java ++++ b/src/main/java/net/minecraft/server/EntityMinecartAbstract.java +@@ -0,0 +0,0 @@ public abstract class EntityMinecartAbstract extends Entity { + public void collide(Entity entity) { + if (!this.world.isClientSide) { + if (!entity.noclip && !this.noclip) { ++ if (!this.world.paperConfig.allowVehicleCollisions && this.world.paperConfig.onlyPlayersCollide && !(entity instanceof EntityPlayer)) return; // Paper + if (!this.w(entity)) { + // CraftBukkit start + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());