3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 20:40:07 +01:00
Paper/patches/server/0573-Collision-option-for-requiring-a-player-participant.patch
Jake 00be0b7b30 Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
d25437bc Update to Minecraft 1.18-pre8

CraftBukkit Changes:
5a39a236 Update to Minecraft 1.18-pre8

Spigot Changes:
7840c2af Update to Minecraft 1.18-pre8
2021-11-30 19:26:33 +01:00

66 Zeilen
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 4d723f5327a64cd8257bab502ae59a35b4a35cc1..e8f5ad4925b4d02bf79f9f56d0dac3f0cc410e71 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -82,6 +82,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 b3ba775d4c4674dc8cd85145cacf9ca93737fe04..392b2745821077d4d3a99872a8b4d50da305c97c 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1581,6 +1581,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 75cff07051d3b81d37926fb1da50af5ba27c34dc..ad49dcc3473fbad306d21cbac4600574e80220a7 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
@@ -832,6 +832,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 b4516094996c80886b8d7af599ba7c3d4229ba9d..c3d111204601270b57389e1f85456a9e2ada4629 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
@@ -240,6 +240,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