Skip to content
Open
Show file tree
Hide file tree
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
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2026 The Debugify Contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
package dev.isxander.debugify.mixins.basic.mc89146;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import dev.isxander.debugify.fixes.BugFix;
import dev.isxander.debugify.fixes.FixCategory;
import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Consumer;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.chunk.LevelChunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

/**
* The linked block entity map from {@link ChunkAccessMixin} throws when removal
* is re-entered during {@code clearAllBlockEntities}: mods reacting to
* {@code setRemoved} can call {@code getBlockEntity}, which strips removed
* entries from the map mid-iteration, and fastutil's linked map iterator then
* reads a stale slot and passes null to the consumer. Iterating a snapshot
* keeps the removal order while tolerating concurrent map modification.
*/
@BugFix(id = "MC-89146", category = FixCategory.BASIC, env = BugFix.Env.SERVER, description = "Pistons forget update when being reloaded")
@Mixin(LevelChunk.class)
public class LevelChunkMixin {
@WrapOperation(
method = "clearAllBlockEntities",
at = @At(
value = "INVOKE",
target = "Ljava/util/Collection;forEach(Ljava/util/function/Consumer;)V",
ordinal = 0
)
)
private void snapshotBlockEntitiesOnClear(Collection<BlockEntity> values, Consumer<BlockEntity> consumer, Operation<Void> original) {
original.call(new ArrayList<>(values), consumer);
}
}
1 change: 1 addition & 0 deletions src/main/resources/debugify.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"basic.mc84661.MobEffectsMixin",
"basic.mc88371.DragonLandingPhaseMixin",
"basic.mc89146.ChunkAccessMixin",
"basic.mc89146.LevelChunkMixin",
"basic.mc93018.AnimalMixin",
"basic.mc94054.WallClimberNavigationMixin",
"errorhandler.CrashReportMixin",
Expand Down