2024-11-23 22:27:37 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Kevin Raneri <kevin.raneri@gmail.com>
|
|
|
|
Date: Mon, 30 Sep 2024 09:50:55 -0700
|
|
|
|
Subject: [PATCH] Configurable Entity Despawn Time
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-12-03 22:06:05 +01:00
|
|
|
index 62cefff26daecd4626ef1d1ab033dcd003e0b799..27618d07d718cb2a5783536e11d56f712303487b 100644
|
2024-11-23 22:27:37 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-11-27 15:16:27 +01:00
|
|
|
@@ -388,6 +388,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
2024-11-23 22:27:37 +01:00
|
|
|
private UUID originWorld;
|
|
|
|
public boolean freezeLocked = false; // Paper - Freeze Tick Lock API
|
|
|
|
public boolean fixedPose = false; // Paper - Expand Pose API
|
|
|
|
+ private final int despawnTime; // Paper - entity despawn time limit
|
|
|
|
|
|
|
|
public void setOrigin(@javax.annotation.Nonnull Location location) {
|
|
|
|
this.origin = location.toVector();
|
2024-11-27 15:16:27 +01:00
|
|
|
@@ -570,6 +571,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
2024-11-23 22:27:37 +01:00
|
|
|
|
|
|
|
public Entity(EntityType<?> type, Level world) {
|
|
|
|
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
|
|
|
+ this.despawnTime = type == EntityType.PLAYER ? -1 : world.paperConfig().entities.spawning.despawnTime.getOrDefault(type, io.papermc.paper.configuration.type.number.IntOr.Disabled.DISABLED).or(-1); // Paper - entity despawn time limit
|
|
|
|
this.passengers = ImmutableList.of();
|
|
|
|
this.deltaMovement = Vec3.ZERO;
|
|
|
|
this.bb = Entity.INITIAL_AABB;
|
2024-12-03 21:24:17 +01:00
|
|
|
@@ -872,6 +874,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
2024-11-23 22:27:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void tick() {
|
|
|
|
+ // Paper start - entity despawn time limit
|
|
|
|
+ if (this.despawnTime >= 0 && this.tickCount >= this.despawnTime) {
|
|
|
|
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end - entity despawn time limit
|
|
|
|
this.baseTick();
|
|
|
|
}
|
|
|
|
|