aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0581-Collision-option-for-requiring-a-player-participant.patch
blob: 2453830557957c3a47b4a96ef8f1b69ede778537 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mariell Hoversholm <proximyst@proximyst.com>
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 797275dd2dc0f7c2ef24311ebdd9659e8b2fdf2f..55c997bc5fb41e16d965c6017128c90321d8457a 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -81,6 +81,18 @@ 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/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 86a9cbc0768575138c09217cd300c2d9d08540fc..b28591ec812aead480fc55c50bce4bd3cbbb2409 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1631,6 +1631,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
     public void push(Entity entity) {
         if (!this.isPassengerOfSameVehicle(entity)) {
             if (!entity.noPhysics && !this.noPhysics) {
+                if (this.level.paperConfig.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) return; // Paper
                 double d0 = entity.getX() - this.getX();
                 double d1 = entity.getZ() - this.getZ();
                 double d2 = Mth.absMax(d0, d1);
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
index 110006087af3f87457031dad7756235363af0506..96a7bfd921e59f298f0ee502d356cc3552c30ce8 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
@@ -831,6 +831,7 @@ public abstract class AbstractMinecart extends Entity {
     public void push(Entity entity) {
         if (!this.level.isClientSide) {
             if (!entity.noPhysics && !this.noPhysics) {
+                if (!this.level.paperConfig.allowVehicleCollisions && this.level.paperConfig.onlyPlayersCollide && !(entity instanceof Player)) return; // Paper
                 if (!this.hasPassenger(entity)) {
                     // CraftBukkit start
                     VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
index c75e45bcb8cd6da154c7ca1719711622c009f463..a8f37fab9c8020e884bf029145d03e3be57b7f2b 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
@@ -239,6 +239,7 @@ public class Boat extends Entity {
 
     @Override
     public void push(Entity entity) {
+        if (!this.level.paperConfig.allowVehicleCollisions && this.level.paperConfig.onlyPlayersCollide && !(entity instanceof Player)) return; // Paper
         if (entity instanceof Boat) {
             if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) {
                 // CraftBukkit start