2020-11-14 15:49:03 +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
|
2021-06-05 08:07:35 +00:00
|
|
|
index d052d53771d868e6fa25d8854fc675a808722c65..c293efaa70c67d7a4227d779eac5d3a510a79ee0 100644
|
2020-11-14 15:49:03 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2021-06-05 08:07:35 +00:00
|
|
|
@@ -718,6 +718,18 @@ public class PaperWorldConfig {
|
2020-11-14 15:49:03 +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;
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
2021-06-05 08:07:35 +00:00
|
|
|
index f35afa4d8d087649f57020e4f89185cffcb1ed3a..a76d32a978ec6fe749ffc0bd50004bda059b6196 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -1467,6 +1467,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
2020-11-14 15:49:03 +00: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 07:19:45 +00: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
|
2021-03-16 15:50:45 +00:00
|
|
|
index 2609b83573e0e8532e6c4c36d4f475bf0da6a354..069076d3c7165440217a7632b089ab2aa0fbdb1d 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java
|
2021-03-16 15:50:45 +00:00
|
|
|
@@ -14,6 +14,7 @@ import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
|
|
|
import net.minecraft.network.syncher.DataWatcher;
|
|
|
|
import net.minecraft.network.syncher.DataWatcherObject;
|
|
|
|
import net.minecraft.network.syncher.DataWatcherRegistry;
|
|
|
|
+import net.minecraft.server.level.EntityPlayer;
|
|
|
|
import net.minecraft.sounds.SoundEffect;
|
|
|
|
import net.minecraft.sounds.SoundEffects;
|
|
|
|
import net.minecraft.tags.Tag;
|
|
|
|
@@ -230,6 +231,7 @@ public class EntityBoat extends Entity {
|
2020-11-14 15:49:03 +00: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 07:19:45 +00: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
|
2021-03-16 15:50:45 +00:00
|
|
|
index 2e3ceab3e34f7756764b3471b13d48d1263ecba9..57821301ef031995e6044a17b46c70a693322455 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
2021-03-16 15:50:45 +00:00
|
|
|
@@ -21,6 +21,7 @@ import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
|
|
|
import net.minecraft.network.syncher.DataWatcher;
|
|
|
|
import net.minecraft.network.syncher.DataWatcherObject;
|
|
|
|
import net.minecraft.network.syncher.DataWatcherRegistry;
|
|
|
|
+import net.minecraft.server.level.EntityPlayer;
|
|
|
|
import net.minecraft.tags.Tag;
|
|
|
|
import net.minecraft.tags.TagsBlock;
|
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
@@ -767,6 +768,7 @@ public abstract class EntityMinecartAbstract extends Entity {
|
2020-11-14 15:49:03 +00: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());
|