Skip to content

Commit

Permalink
Fixed #73 by ignoring corpse entities.
Browse files Browse the repository at this point in the history
Fixed #71 by adding additional checks for the spawn module.
Smaller code optimizations and improvements.
  • Loading branch information
MarkusBordihn committed Oct 7, 2024
1 parent 9c6c99f commit 73d67dd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,19 @@ private static void verifyEntities() {

private static int removeDiscardedEntities(ConcurrentMap<String, Set<Entity>> entityMapToCheck) {
int removedEntries = 0;
if (entityMapToCheck != null && !entityMapToCheck.isEmpty()) {
// Remove entities which are no longer valid like removed entities.
for (Set<Entity> entities : entityMapToCheck.values()) {
Iterator<Entity> 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<Entity> entities : entityMapToCheck.values()) {
Iterator<Entity> 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++;
}
}
}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 73d67dd

Please sign in to comment.