2020-11-14 16:49:03 +01:00
|
|
|
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 234d2daecc5d0bf6a99c0a5f4a87f947a15029d9..89f3a28c20f0e4db4650c435dbcbc923b7bde8aa 100644
|
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
@@ -716,6 +716,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;
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
index 7ad4d20cd43ad100ab8a1987d061bb523fb66ea5..f64d37aa1183fe1a7c6f3131f945d9bd4e43bf3c 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
@@ -1460,6 +1460,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
2020-11-14 16:49:03 +01:00
|
|
|
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);
|
2021-03-16 08:19:45 +01:00
|
|
|
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 2609b83573e0e8532e6c4c36d4f475bf0da6a354..5ae7620be7b0b5fba6aab8173aed45dc28bf36e3 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java
|
|
|
|
@@ -230,6 +230,7 @@ public class EntityBoat extends Entity {
|
2020-11-14 16:49:03 +01:00
|
|
|
|
|
|
|
@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
|
2021-03-16 08:19:45 +01:00
|
|
|
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 2e3ceab3e34f7756764b3471b13d48d1263ecba9..c79474ffb455bb87bfdd98bc68b3dc8dfcdca45e 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
|
|
|
@@ -767,6 +767,7 @@ public abstract class EntityMinecartAbstract extends Entity {
|
2020-11-14 16:49:03 +01:00
|
|
|
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());
|