From 8a83c2697e7e2350cdd83996f9846ec0c4904664 Mon Sep 17 00:00:00 2001 From: Allmoz Date: Wed, 20 May 2026 05:54:44 -0400 Subject: [PATCH 1/2] backport #9399 --- .../bug_fixes/dupes/ContraptionMixin.java | 33 +++++++++++++++++++ src/main/resources/mixins.create_repair.json | 1 + 2 files changed, 34 insertions(+) create mode 100644 src/main/java/ch/voidlee/repair/mixin/bug_fixes/dupes/ContraptionMixin.java diff --git a/src/main/java/ch/voidlee/repair/mixin/bug_fixes/dupes/ContraptionMixin.java b/src/main/java/ch/voidlee/repair/mixin/bug_fixes/dupes/ContraptionMixin.java new file mode 100644 index 0000000..59d48b2 --- /dev/null +++ b/src/main/java/ch/voidlee/repair/mixin/bug_fixes/dupes/ContraptionMixin.java @@ -0,0 +1,33 @@ +package ch.voidlee.repair.mixin.bug_fixes.dupes; + +import com.simibubi.create.content.contraptions.Contraption; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; +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; + +import java.util.*; + +// https://github.com/Creators-of-Create/Create/pull/9399 +@Mixin(Contraption.class) +public class ContraptionMixin { + @Shadow(remap = false) + protected Map blocks; + + @Inject(method = "()V", at = @At("TAIL"), remap = false) + private void create_repair$blocksStoredInLinkedHashMap(CallbackInfo ci) { + this.blocks = new LinkedHashMap<>(this.blocks); + } + + @Inject(method = "removeBlocksFromWorld", at = @At("HEAD"), remap = false) + private void create_repair$iterateBlocksInReverse(Level world, BlockPos offset, CallbackInfo ci) { + List> entries = new ArrayList<>(this.blocks.entrySet()); + Collections.reverse(entries); + this.blocks.clear(); + entries.forEach(e -> this.blocks.put(e.getKey(), e.getValue())); + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.create_repair.json b/src/main/resources/mixins.create_repair.json index f9f7a5a..c517401 100644 --- a/src/main/resources/mixins.create_repair.json +++ b/src/main/resources/mixins.create_repair.json @@ -44,6 +44,7 @@ "bug_fixes.clearable.StockTickerBlockEntityMixin", "bug_fixes.clearable.ThresholdSwitchBlockEntityMixin", "bug_fixes.clearable.TrackObserverBlockEntityMixin", + "bug_fixes.dupes.ContraptionMixin", "bug_fixes.dupes.DeployerNotifyUpdateMixin", "bug_fixes.dupes.PostboxBlockEntityMixin", "bug_fixes.dupes.SchematicPrinterMixin", From c967ae2377f2617e32291634555396f57fdd98ec Mon Sep 17 00:00:00 2001 From: Allmoz Date: Wed, 20 May 2026 19:29:11 -0400 Subject: [PATCH 2/2] Fixes --- REPAIRED.md | 1 + .../voidlee/repair/mixin/bug_fixes/dupes/ContraptionMixin.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/REPAIRED.md b/REPAIRED.md index 95e6f78..a136a7d 100644 --- a/REPAIRED.md +++ b/REPAIRED.md @@ -77,3 +77,4 @@ Unticked checkboxes indicate the issue is fixed in dev but not released yet. - [x] [Fix a dupe when breaking a Postbox while its menu is open](https://github.com/Creators-of-Create/Create/pull/9802) (Thanks, techno-sam!) - [x] [Fix a dupe with the Schematicannon ignoring BlockEntity item requirements](https://github.com/Creators-of-Create/Create/issues/9511) (Thanks, IThundxr!) - [x] [Fix a dupe with the Deployer](https://github.com/Creators-of-Create/Create/commit/dd133f667969870dd6e9b96395097ac93cd91ced) (Thanks, IThundxr!) +- [ ] [Fix a dupe when making a contraption with attached blocks to attached blocks](https://github.com/Creators-of-Create/Create/pull/9399) (Thanks, Allmoz!) diff --git a/src/main/java/ch/voidlee/repair/mixin/bug_fixes/dupes/ContraptionMixin.java b/src/main/java/ch/voidlee/repair/mixin/bug_fixes/dupes/ContraptionMixin.java index 59d48b2..d8e1175 100644 --- a/src/main/java/ch/voidlee/repair/mixin/bug_fixes/dupes/ContraptionMixin.java +++ b/src/main/java/ch/voidlee/repair/mixin/bug_fixes/dupes/ContraptionMixin.java @@ -14,7 +14,7 @@ // https://github.com/Creators-of-Create/Create/pull/9399 @Mixin(Contraption.class) -public class ContraptionMixin { +public abstract class ContraptionMixin { @Shadow(remap = false) protected Map blocks;