Skip to content

Commit

Permalink
Revert "Minor fix, Urgent: Fix soft-overwrite preventing other mods' …
Browse files Browse the repository at this point in the history
…mobs fro…" (#911)

This reverts commit e8120ae.
  • Loading branch information
StewStrong authored Jul 21, 2024
1 parent e8120ae commit 2d456ca
Showing 1 changed file with 20 additions and 18 deletions.
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();
}
}

0 comments on commit 2d456ca

Please sign in to comment.