Open tatoyoda600 opened 1 week ago
Don't know anything about Minecraft modding, so I don't know the repercussions of the following code, if any, but I was able to get the game to stop freezing by editing MobMixin.java to have the code below. https://github.com/team-abnormals/environmental/blob/464409ecbfc7668b4703bdfe50e557bfbaf61c80/src/main/java/com/teamabnormals/environmental/core/mixin/MobMixin.java#L46
The code below is based heavily on the code Structure Gel API began using after the issue cropped up there.
ServerLevelAccessor
: https://gitlab.com/modding-legacy/dungeons-plus/-/blob/1.19.x/src/main/java/com/legacy/dungeons_plus/events/DPCommonEvents.java#L82StructureManager
: https://gitlab.com/modding-legacy/structure-gel-api/-/blob/1.19.2/src/main/java/com/legacy/structure_gel/api/structure/StructureAccessHelper.java#L102#
New imports added:
import net.minecraft.server.level.WorldGenRegion;
import net.minecraft.world.level.StructureManager;
import net.minecraft.world.level.ServerLevelAccessor;
Modification of the populateDefaultEquipmentSlots
function:
@Inject(method = "populateDefaultEquipmentSlots", at = @At("TAIL"))
private void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty, CallbackInfo info) {
int difficultyChance = difficulty.getDifficulty().getId() + 1;
if (this.getLevel() instanceof ServerLevelAccessor levelAccessor) {
if (levelAccessor.hasChunkAt(this.blockPosition())) {
StructureManager structureManager = levelAccessor instanceof ServerLevel sl ? sl.structureManager() : levelAccessor instanceof WorldGenRegion wg ? levelAccessor.getLevel().structureManager().forWorldGenRegion(wg) : null;
Optional<Named<Structure>> structures = levelAccessor.registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY).getTag(EnvironmentalStructureTags.HAS_HEALER_POUCH);
if (structureManager != null && structures.isPresent()) {
boolean valid = false;
for (Holder<Structure> structure : structures.get()) {
if (structure != null && structureManager.getStructureAt(this.blockPosition(), structure.value()).isValid()) {
valid = true;
break;
}
}
if (valid && random.nextDouble() < difficultyChance * 0.01F) {
this.setItemSlot(EquipmentSlot.CHEST, new ItemStack(EnvironmentalItems.HEALER_POUCH.get()));
this.armorDropChances[EquipmentSlot.CHEST.getIndex()] = 1.0F;
}
}
}
}
}
Was using this mod in a modpack alongside the Repurposed Structures mod in a modpack and the game froze indefinitely upon loading a chunk with one of its structures in it, the Underground Bastion. I narrowed the modpack down to just 4 mods and filed an issue with the Repurposed Structures mod (TelepathicGrunt/RepurposedStructures#340), but the creator informed me that it's an issue with a section of this mod's code: https://github.com/team-abnormals/environmental/blob/464409ecbfc7668b4703bdfe50e557bfbaf61c80/src/main/java/com/teamabnormals/environmental/core/mixin/MobMixin.java#L46
This issue appears to happen because they include mobs in their structures, and has caused this same issue before alongside the Structure Gel API (https://gitlab.com/modding-legacy/structure-gel-api/-/issues/36).
Was able to narrow it down to the following mod combination:
Steps I used to consistently repeat the issue:
-7123539784518700980
/locate structure #repurposed_structures:explorer_maps/bastion_underground
/tp @s 2384 ~ -3888
No crash report because it never reaches the crash. Game log looks fine, it freezes without ever logging anything useful, so the last thing in all my logs is always the result of the
/locate
command, followed by the logs for force quitting Minecraft when I decide to use Task Manager on it:The launcher just tells me that the game was closed forcefully: