66 lines
4.1 KiB
Diff
66 lines
4.1 KiB
Diff
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 96fd9803810db0f8a4b25e070a56da05862e1e4e..2b3e034d6cddbe5c94f2be856833680dd7b3b4f0 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -115,6 +115,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 a260eeed180b43bb0b13e3192682822a4fde624c..5f5c6b2bf1c3056965ea343a1444e1be753d819f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -1678,6 +1678,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
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 4984b2b3294e425247b595bcf36812728fb4cd16..dd2dfffcb5715b34a58262a52e83ff3030212ac4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
|
@@ -833,6 +833,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 904ef44f6bb25a617c6e80d025fa0780a3bd63ec..ae069489eeb52489e69c10207739f07f867c58e4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
|
@@ -243,6 +243,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
|