Paper/Spigot-Server-Patches/0014-Add-configurable-despawn-distances-for-living-entiti.patch
Shane Freeder 9946cef8c5
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears 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:
f52c70ab Fix incorrect nullability in MultipleFacing
6af4c0b2 SPIGOT-5311: Add API to get/set item associated with throwable projectiles
97aeae56 Add set/isAware to disable Vanilla AI components of a Mob

CraftBukkit Changes:
fba9f487 Improve legacy conversion of some materials that changed post flattening
b1ba8749 Move Bukkit.Aware loading/saving to correct location
f7cdb53c SPIGOT-5311: Add API to get/set item associated with throwable projectiles
689f429c #634: Cross platform patch scripts
ab85433d Add set/isAware to disable Vanilla AI components of a Mob

Spigot Changes:
8faa8b45 Rebuild patches
2020-02-21 17:52:20 +00:00

53 lines
2.6 KiB
Diff

From 150dd44b4bb4169b9568dfc931b7a77f40469e65 Mon Sep 17 00:00:00 2001
From: Suddenly <suddenly@suddenly.coffee>
Date: Tue, 1 Mar 2016 13:51:54 -0600
Subject: [PATCH] Add configurable despawn distances for living entities
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 6d6a68cb1b..2845686411 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -97,4 +97,20 @@ public class PaperWorldConfig {
private void nerfedMobsShouldJump() {
nerfedMobsShouldJump = getBoolean("spawner-nerfed-mobs-should-jump", false);
}
+
+ public int softDespawnDistance;
+ public int hardDespawnDistance;
+ private void despawnDistances() {
+ softDespawnDistance = getInt("despawn-ranges.soft", 32); // 32^2 = 1024, Minecraft Default
+ hardDespawnDistance = getInt("despawn-ranges.hard", 128); // 128^2 = 16384, Minecraft Default
+
+ if (softDespawnDistance > hardDespawnDistance) {
+ softDespawnDistance = hardDespawnDistance;
+ }
+
+ log("Living Entity Despawn Ranges: Soft: " + softDespawnDistance + " Hard: " + hardDespawnDistance);
+
+ softDespawnDistance = softDespawnDistance*softDespawnDistance;
+ hardDespawnDistance = hardDespawnDistance*hardDespawnDistance;
+ }
}
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index 70cd0801dc..23995b68a1 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -630,11 +630,11 @@ public abstract class EntityInsentient extends EntityLiving {
if (entityhuman != null) {
double d0 = entityhuman.h(this);
- if (d0 > 16384.0D) { // CraftBukkit - remove isTypeNotPersistent() check
+ if (d0 > world.paperConfig.hardDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // Paper - custom despawn distances
this.die();
}
- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > 1024.0D) { // CraftBukkit - remove isTypeNotPersistent() check
+ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > world.paperConfig.softDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // Paper - custom despawn distances
this.die();
} else if (d0 < 1024.0D) {
this.ticksFarFromPlayer = 0;
--
2.25.0