2021-06-11 12:02:28 +00: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
|
2022-03-11 20:13:46 +00:00
|
|
|
index 512720c6c13edcdae8f334ee584da8c4bca30c5f..ea5f021c4ce2274869d884b90aeaba35d4e2db84 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2021-11-29 11:55:13 +00:00
|
|
|
@@ -81,6 +81,18 @@ public class PaperWorldConfig {
|
2021-06-11 12:02:28 +00: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
|
2022-03-30 20:28:38 +00:00
|
|
|
index dbfe16f904382f3fa3790fc8da0f5c7b5b83a501..162542958a331fd0ff0623266c9c62211152b1a6 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2022-03-30 20:28:38 +00:00
|
|
|
@@ -1631,6 +1631,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
2021-06-11 12:02:28 +00: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
|
2022-03-01 05:43:03 +00:00
|
|
|
index 110006087af3f87457031dad7756235363af0506..96a7bfd921e59f298f0ee502d356cc3552c30ce8 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -831,6 +831,7 @@ public abstract class AbstractMinecart extends Entity {
|
2021-06-11 12:02:28 +00:00
|
|
|
public void push(Entity entity) {
|
|
|
|
if (!this.level.isClientSide) {
|
|
|
|
if (!entity.noPhysics && !this.noPhysics) {
|
2021-11-24 18:27:25 +00:00
|
|
|
+ if (!this.level.paperConfig.allowVehicleCollisions && this.level.paperConfig.onlyPlayersCollide && !(entity instanceof Player)) return; // Paper
|
2021-06-11 12:02:28 +00: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
|
2022-03-01 05:43:03 +00:00
|
|
|
index c75e45bcb8cd6da154c7ca1719711622c009f463..a8f37fab9c8020e884bf029145d03e3be57b7f2b 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -239,6 +239,7 @@ public class Boat extends Entity {
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void push(Entity entity) {
|
2021-11-24 18:27:25 +00:00
|
|
|
+ if (!this.level.paperConfig.allowVehicleCollisions && this.level.paperConfig.onlyPlayersCollide && !(entity instanceof Player)) return; // Paper
|
2021-06-11 12:02:28 +00:00
|
|
|
if (entity instanceof Boat) {
|
|
|
|
if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) {
|
|
|
|
// CraftBukkit start
|