Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Minor fix, Urgent: Fix soft-overwrite preventing other mods' mobs from despawning with special conditions." #911

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
import it.unimi.dsi.fastutil.longs.LongPredicate;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.entity.EntitySectionStorage;
Expand Down Expand Up @@ -54,21 +53,24 @@ private boolean processChunkUnload(final long l) {
/**
* This fixes this function randomly crashing. I'm not sure why but the removeIf() function is buggy
*/
@ModifyArg(
method="processUnloads",
at=@At(
target="Lit/unimi/dsi/fastutil/longs/LongSet;removeIf(Lit/unimi/dsi/fastutil/longs/LongPredicate;)Z",
value="INVOKE"
)
)
private LongPredicate processUnloads_catchException(LongPredicate par1) {
return (l) -> {
try {
return par1.test(l);
} catch (Exception e) {
e.printStackTrace();
return false;
}
};
}
@Inject(
method = "processUnloads", at = @At(value = "HEAD"), cancellable = true
)
private void replaceProcessUnloads(final CallbackInfo ci) {
// I don't know why this crashes, try-catch please help me!
try {
final LongSet toRemove = new LongOpenHashSet();
for (final long key : this.chunksToUnload) {
if (this.chunkVisibility.get(key) != Visibility.HIDDEN) {
toRemove.add(key);
} else if (this.processChunkUnload(key)) {
toRemove.add(key);
}
}
chunksToUnload.removeAll(toRemove);
} catch (final Exception e) {
e.printStackTrace();
}
ci.cancel();
}
}
Loading