Skip to content

Commit

Permalink
Attempt to fix NPE (#527)
Browse files Browse the repository at this point in the history
  • Loading branch information
2No2Name committed Jun 21, 2024
1 parent c611027 commit a063311
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ public static ChunkSectionChangeCallback create(long sectionPos, World world) {
return chunkSectionChangeCallback;
}

public short onBlockChange(int flagIndex, BlockListeningSection section) {
ArrayList<SectionedBlockChangeTracker> sectionedBlockChangeTrackers = this.trackers[flagIndex];
this.trackers[flagIndex] = null;
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < sectionedBlockChangeTrackers.size(); i++) {
sectionedBlockChangeTrackers.get(i).setChanged(section);
public short onBlockChange(int blockGroupIndex, BlockListeningSection section) {
ArrayList<SectionedBlockChangeTracker> sectionedBlockChangeTrackers = this.trackers[blockGroupIndex];
this.trackers[blockGroupIndex] = null;
if (sectionedBlockChangeTrackers != null) {
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < sectionedBlockChangeTrackers.size(); i++) {
sectionedBlockChangeTrackers.get(i).setChanged(section);
}
}
this.listeningMask &= (short) ~(1 << flagIndex);
this.listeningMask &= (short) ~(1 << blockGroupIndex);

return this.listeningMask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ private void updateFlagCounters(int x, int y, int z, BlockState newState, boolea
@Override
@Unique
public void lithium$invalidateListeningSection(ChunkSectionPos sectionPos) {
if ((this.listeningMask) != 0) {
if (this.listeningMask != 0) {
this.changeListener.onChunkSectionInvalidated(sectionPos);
this.listeningMask = 0;
}
}
}

0 comments on commit a063311

Please sign in to comment.