mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-28 13:36:16 +01:00
40 lines
2.0 KiB
Diff
40 lines
2.0 KiB
Diff
|
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
|
||
|
index 8be1b051543cda2b2e9e3d337834757e53f442de..ed5b00620527c1776722d25b1b45f1544802a341 100644
|
||
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||
|
@@ -432,6 +432,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||
|
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();
|
||
|
@@ -614,6 +615,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||
|
|
||
|
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;
|
||
|
@@ -912,6 +914,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||
|
}
|
||
|
|
||
|
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();
|
||
|
}
|
||
|
|