mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-21 07:59:26 +00:00
* Region based comment helper functions * (Region based comment) Dont save entity * (Region based comment) Pufferfish DAB * (Region based comment) Cache EntityType * (Region based comment) Cache EntityType * (Region based comment) Pufferfish EntityTTL * (Region based comment) Faster sequence * (Region based comment) FastRNG * (Region based comment) 0042 * (Region based comment) 0721 * (Region based comment) 0009 * (Region based comment) V1rtUal tHReaD * (Region based comment) ZSSM * [ci skip] (Region based comment) 0079 * [ci skip] (Region based comment) 0089 0090 * [ci skip] (Region based comment) 0049 0118 0138 * [ci skip] (Region based comment) 0006 0017 0018 0080 0081 * [ci skip] (Region based comment) 0019 0038 0059 0108 0117 0127 * ALL PATCHES ARE DONE * [ci skip] NZDD
83 lines
3.5 KiB
Diff
83 lines
3.5 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 22d3d963dc9806643608d077324b27832641ce57..60fbed7a31fbeca07eae8ea6b0fb97705961bb7e 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..dbab6168992fb9bb50f7cbc49a0cc7aa7e357666
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/EntityTTL.java
|
|
@@ -0,0 +1,39 @@
|
|
+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.addCommentRegionBased(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.""",
|
|
+ """
|
|
+ 这些值定义了实体的最大生命周期.
|
|
+ 如果实体存活时间超过指定的 tick 将被移除, 设置为 -1 可禁用此功能.""");
|
|
+
|
|
+ // 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);
|
|
+ }
|
|
+ }
|
|
+}
|