-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear lastSection on game event listener removal (fixes #87)
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/DynamicGameEventListenerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ca.spottedleaf.moonrise.mixin.chunk_system; | ||
|
||
import net.minecraft.core.SectionPos; | ||
import net.minecraft.world.level.gameevent.DynamicGameEventListener; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(DynamicGameEventListener.class) | ||
abstract class DynamicGameEventListenerMixin { | ||
@Shadow @Nullable private SectionPos lastSection; | ||
|
||
@Inject(method = "remove", at = @At("RETURN")) | ||
private void onRemove(final CallbackInfo ci) { | ||
// We need to unset the last section when removed, otherwise if the same instance is re-added at the same position it | ||
// will assume there was no change and fail to re-register. | ||
// In vanilla, chunks rarely unload and re-load quickly enough to trigger this issue. However, our chunk system has a | ||
// quirk where fast chunk reload cycles will often occur on player login (see PR #22). | ||
// So we fix this vanilla oversight as our changes cause it to manifest in bugs much more often (see issue #87). | ||
this.lastSection = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters