mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-21 16:09:19 +00:00
80 lines
3.3 KiB
Diff
80 lines
3.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Kevin Raneri <kevin.raneri@gmail.com>
|
|
Date: Thu, 2 Jun 2022 19:54:09 -0500
|
|
Subject: [PATCH] Pufferfish: Entity TTL
|
|
|
|
Original license: GPL v3
|
|
Original project: https://github.com/pufferfish-gg/Pufferfish
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index be9815bdf5652a7856fd72d3fca3e2562b2fb8c6..815db5b0a24f1628d646893ebad466dcee2ab0bd 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -849,6 +849,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
|
|
public void tick() {
|
|
+ // Pufferfish start - entity TTL
|
|
+ if (type != EntityType.PLAYER && type.ttl >= 0 && this.tickCount >= type.ttl) {
|
|
+ discard();
|
|
+ return;
|
|
+ }
|
|
+ // Pufferfish end - entity TTL
|
|
this.baseTick();
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
|
index b2d8a858d8767bd6ca52e0b8db84757986c6ed61..f9440014ab2fe753c16b9383f5fffbb8adb76e79 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
|
@@ -317,6 +317,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
|
private final int clientTrackingRange;
|
|
private final int updateInterval;
|
|
public boolean dabEnabled = false; // Pufferfish
|
|
+ public int ttl = -1; // Pufferfish
|
|
@Nullable
|
|
private String descriptionId;
|
|
@Nullable
|
|
diff --git a/src/main/java/org/dreeam/leaf/config/modules/opt/EntityTTL.java b/src/main/java/org/dreeam/leaf/config/modules/opt/EntityTTL.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..656655343653b1854a93fb074c4fa04bda98754d
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/EntityTTL.java
|
|
@@ -0,0 +1,36 @@
|
|
+package org.dreeam.leaf.config.modules.opt;
|
|
+
|
|
+import net.minecraft.core.registries.BuiltInRegistries;
|
|
+import net.minecraft.world.entity.EntityType;
|
|
+import org.dreeam.leaf.config.ConfigModules;
|
|
+import org.dreeam.leaf.config.EnumConfigCategory;
|
|
+
|
|
+import java.util.Locale;
|
|
+
|
|
+public class EntityTTL extends ConfigModules {
|
|
+
|
|
+ public String getBasePath() {
|
|
+ return EnumConfigCategory.PERF.getBaseKeyName() + ".entity-timeouts";
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void onLoaded() {
|
|
+ config.addComment(getBasePath(), """
|
|
+ These values define a entity's maximum lifespan. If an
|
|
+ entity is in this list and it has survived for longer than
|
|
+ that number of ticks, then it will be removed. Setting a value to
|
|
+ -1 disables this feature.""");
|
|
+
|
|
+ // Set some defaults
|
|
+ config.getInt(getBasePath() + ".SNOWBALL", -1);
|
|
+ config.getInt(getBasePath() + ".LLAMA_SPIT", -1);
|
|
+ for (EntityType<?> entityType : BuiltInRegistries.ENTITY_TYPE) {
|
|
+ if (entityType == EntityType.PLAYER) {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ String type = EntityType.getKey(entityType).getPath().toUpperCase(Locale.ROOT);
|
|
+ entityType.ttl = config.getInt(getBasePath() + "." + type, -1);
|
|
+ }
|
|
+ }
|
|
+}
|