2021-06-11 14:02:28 +02: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
|
2021-12-03 22:28:15 +01:00
|
|
|
index 95952806a544d38952b82f7078a46a5eeb622cd8..19ae4ae82be4a5a387b0f6e1b18e36b24d0cbbdb 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2021-11-29 12:55:13 +01:00
|
|
|
@@ -81,6 +81,18 @@ public class PaperWorldConfig {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ 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
|
2021-12-03 22:28:15 +01:00
|
|
|
index 1f43c7bd5d711c2e5a7ff67b3b399b408e950b59..9bb77e98466544aa8efe603618348990e8e40546 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2021-12-03 22:28:15 +01:00
|
|
|
@@ -1620,6 +1620,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2021-11-24 19:27:25 +01:00
|
|
|
index 75cff07051d3b81d37926fb1da50af5ba27c34dc..ad49dcc3473fbad306d21cbac4600574e80220a7 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
2021-11-24 19:27:25 +01:00
|
|
|
@@ -832,6 +832,7 @@ public abstract class AbstractMinecart extends Entity {
|
2021-06-11 14:02:28 +02:00
|
|
|
public void push(Entity entity) {
|
|
|
|
if (!this.level.isClientSide) {
|
|
|
|
if (!entity.noPhysics && !this.noPhysics) {
|
2021-11-24 19:27:25 +01:00
|
|
|
+ if (!this.level.paperConfig.allowVehicleCollisions && this.level.paperConfig.onlyPlayersCollide && !(entity instanceof Player)) return; // Paper
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2021-11-24 19:27:25 +01:00
|
|
|
index b4516094996c80886b8d7af599ba7c3d4229ba9d..c3d111204601270b57389e1f85456a9e2ada4629 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
2021-11-24 19:27:25 +01:00
|
|
|
@@ -240,6 +240,7 @@ public class Boat extends Entity {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void push(Entity entity) {
|
2021-11-24 19:27:25 +01:00
|
|
|
+ if (!this.level.paperConfig.allowVehicleCollisions && this.level.paperConfig.onlyPlayersCollide && !(entity instanceof Player)) return; // Paper
|
2021-06-11 14:02:28 +02:00
|
|
|
if (entity instanceof Boat) {
|
|
|
|
if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) {
|
|
|
|
// CraftBukkit start
|