From 73d67dd2dc21e00d14617c565f03fa8efbe8f844 Mon Sep 17 00:00:00 2001 From: Markus Bordihn Date: Mon, 7 Oct 2024 20:26:37 +0200 Subject: [PATCH] Fixed #73 by ignoring corpse entities. Fixed #71 by adding additional checks for the spawn module. Smaller code optimizations and improvements. --- CHANGELOG.md | 6 ++++ .../CoreConstants.java | 3 ++ .../entity/CoreEntityManager.java | 35 ++++++++++--------- gradle.properties | 2 +- settings.gradle | 2 +- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 804f8a39..76172b7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ This change log includes the summarized changes. For the full changelog, please go to the [GitHub History][history] instead. +### v11.2.0 + +- Fixed #73 by ignoring corpse entities. +- Fixed #71 by adding additional checks for the spawn module. +- Smaller code optimizations and improvements. + ### v11.1.0 - Fixed #65 by detecting villager zombie conversion and automatically allowing the conversion. diff --git a/core/src/main/java/de/markusbordihn/adaptiveperformancetweakscore/CoreConstants.java b/core/src/main/java/de/markusbordihn/adaptiveperformancetweakscore/CoreConstants.java index 1eb286ab..5888816e 100644 --- a/core/src/main/java/de/markusbordihn/adaptiveperformancetweakscore/CoreConstants.java +++ b/core/src/main/java/de/markusbordihn/adaptiveperformancetweakscore/CoreConstants.java @@ -62,6 +62,9 @@ public final class CoreConstants { public static final String COFH_CORE_MOD = "cofh_core"; public static final String COFH_CORE_NAME = "CoFH Core"; public static final boolean COFH_CORE_LOADED = ModList.get().isLoaded(COFH_CORE_MOD); + public static final String CORPSE_MOD = "corpse"; + public static final String CORPSE_NAME = "Corpse"; + public static final boolean CORPSE_LOADED = ModList.get().isLoaded(CORPSE_MOD); public static final String CLUMPS_MOD = "clumps"; public static final String CLUMPS_NAME = "Clumps"; public static final boolean CLUMPS_LOADED = ModList.get().isLoaded(CLUMPS_MOD); diff --git a/core/src/main/java/de/markusbordihn/adaptiveperformancetweakscore/entity/CoreEntityManager.java b/core/src/main/java/de/markusbordihn/adaptiveperformancetweakscore/entity/CoreEntityManager.java index 6c29c87e..b4c283b4 100644 --- a/core/src/main/java/de/markusbordihn/adaptiveperformancetweakscore/entity/CoreEntityManager.java +++ b/core/src/main/java/de/markusbordihn/adaptiveperformancetweakscore/entity/CoreEntityManager.java @@ -374,17 +374,19 @@ private static void verifyEntities() { private static int removeDiscardedEntities(ConcurrentMap> entityMapToCheck) { int removedEntries = 0; - if (entityMapToCheck != null && !entityMapToCheck.isEmpty()) { - // Remove entities which are no longer valid like removed entities. - for (Set entities : entityMapToCheck.values()) { - Iterator entityIterator = entities.iterator(); - while (entityIterator.hasNext()) { - // Check if the entity is still valid. - Entity entity = entityIterator.next(); - if (entity == null || entity.isRemoved()) { - entityIterator.remove(); - removedEntries++; - } + if (entityMapToCheck == null || entityMapToCheck.isEmpty()) { + return removedEntries; + } + + // Remove entities which are no longer valid like removed entities. + for (Set entities : entityMapToCheck.values()) { + Iterator entityIterator = entities.iterator(); + while (entityIterator.hasNext()) { + // Check if the entity is still valid. + Entity entity = entityIterator.next(); + if (entity == null || entity.isRemoved()) { + entityIterator.remove(); + removedEntries++; } } } @@ -465,6 +467,7 @@ public static boolean isRelevantEntity(Entity entity, String entityName) { && entityName.startsWith(CoreConstants.BIGGER_REACTORS_MOD)) || (CoreConstants.BOTANIA_LOADED && entityName.startsWith(CoreConstants.BOTANIA_MOD)) || (CoreConstants.CREATE_LOADED && entityName.startsWith(CoreConstants.CREATE_MOD)) + || (CoreConstants.CORPSE_LOADED && entityName.startsWith(CoreConstants.CORPSE_MOD)) || (CoreConstants.EASY_NPC_LOADED && entityName.startsWith(CoreConstants.EASY_NPC_MOD)) || (CoreConstants.FLUX_NETWORKS_LOADED && entityName.startsWith(CoreConstants.FLUX_NETWORKS_MOD)) @@ -505,12 +508,10 @@ public static boolean isRelevantEntity(Entity entity, String entityName) { if (compoundTag.contains(ENTITY_OWNER_TAG) && compoundTag.get(ENTITY_OWNER_TAG) != null) { return false; } - if (compoundTag.contains(PERSISTENCE_REQUIRED) - && compoundTag.get(PERSISTENCE_REQUIRED) != null - && compoundTag.getBoolean(PERSISTENCE_REQUIRED)) { - return false; - } - return true; + // Checking if entity is persistence required. + return !compoundTag.contains(PERSISTENCE_REQUIRED) + || compoundTag.get(PERSISTENCE_REQUIRED) == null + || !compoundTag.getBoolean(PERSISTENCE_REQUIRED); } } diff --git a/gradle.properties b/gradle.properties index 9391b6e4..7912c3a0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false # Project -version=11.1.0 +version=11.2.0 # Mod mod_author=Markus Bordihn vendor_name=markusbordihn diff --git a/settings.gradle b/settings.gradle index 0639c0a6..5e05bdd6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,7 +4,7 @@ pluginManagement { } } -rootProject.name = 'Adaptive Performance Tweaks' +rootProject.name = 'Adaptive Performance Tweaks 1.18.2' include("core") include("gamerules", "items", "player", "spawn") include("bundle")