mirror of https://github.com/YatopiaMC/Yatopia.git
48 lines
2.1 KiB
Diff
48 lines
2.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Paul Sauve <paul@technove.co>
|
|
Date: Mon, 26 Apr 2021 11:20:12 -0500
|
|
Subject: [PATCH] Reduce frequency of checking for entity despawn
|
|
|
|
This isn't a great way to deal with this, but at a high number of
|
|
entities this starts adding up more than it should, and it's already
|
|
fairly optimized. Just starts being slow when you have 30k entities.
|
|
|
|
diff --git a/src/main/java/gg/airplane/AirplaneConfig.java b/src/main/java/gg/airplane/AirplaneConfig.java
|
|
index 94c18e824695af69e39288195cc2fa83a13029d6..a673eaad4cd80287e8a357f8c45b2add156ff0b9 100644
|
|
--- a/src/main/java/gg/airplane/AirplaneConfig.java
|
|
+++ b/src/main/java/gg/airplane/AirplaneConfig.java
|
|
@@ -103,4 +103,13 @@ public class AirplaneConfig {
|
|
}
|
|
|
|
|
|
+ public static byte entityDespawnCheckFrequency;
|
|
+
|
|
+ private static void entitySettings() {
|
|
+ config.setComment("entities", "Configures settings for generic entities");
|
|
+
|
|
+ entityDespawnCheckFrequency = (byte) Math.max(config.getInt("entities.despawn-check-freq", 8), Byte.MAX_VALUE);
|
|
+ }
|
|
+
|
|
+
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityInsentient.java b/src/main/java/net/minecraft/world/entity/EntityInsentient.java
|
|
index c67138e6a4dcbe823e894f6bb948742bfb8f9943..0f0bf91a3d01c0eb841db81ac441cf5936a2cdfe 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityInsentient.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityInsentient.java
|
|
@@ -774,8 +774,15 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
return false;
|
|
}
|
|
|
|
+ // Airplane start - just reduce frequency of checking for despawn
|
|
+ private byte despawnCheck = 0;
|
|
@Override
|
|
public void checkDespawn() {
|
|
+ if (++despawnCheck < gg.airplane.AirplaneConfig.entityDespawnCheckFrequency) {
|
|
+ return;
|
|
+ }
|
|
+ this.despawnCheck = 0;
|
|
+ // Airplane end
|
|
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.L()) {
|
|
this.die();
|
|
} else if (!this.isPersistent() && !this.isSpecialPersistence()) {
|