From cf11e9bb24797c338bb95224e35463330d0464b3 Mon Sep 17 00:00:00 2001 From: myriantics Date: Tue, 2 Jun 2026 22:23:11 -0700 Subject: [PATCH 1/6] WrapPresentRecipe now copies the present stack into the output with a count of 1 instead of the original count. --- .../spectrum/recipe/crafting/dynamic/WrapPresentRecipe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/dafuqs/spectrum/recipe/crafting/dynamic/WrapPresentRecipe.java b/src/main/java/de/dafuqs/spectrum/recipe/crafting/dynamic/WrapPresentRecipe.java index 803af48657..81cf62e5e2 100644 --- a/src/main/java/de/dafuqs/spectrum/recipe/crafting/dynamic/WrapPresentRecipe.java +++ b/src/main/java/de/dafuqs/spectrum/recipe/crafting/dynamic/WrapPresentRecipe.java @@ -66,7 +66,7 @@ public ItemStack assemble(CraftingInput input, HolderLookup.Provider registryLoo for (int j = 0; j < input.size(); ++j) { ItemStack stack = input.getItem(j); if (stack.getItem() instanceof PresentBlockItem) { - presentStack = stack.copy(); + presentStack = stack.copyWithCount(1); } else if (stack.getItem() instanceof PigmentItem pigmentItem) { InkColor color = pigmentItem.getInkColor(); if (colors.containsKey(color)) { From 40115d2543379cb1634646bd9d1e88105947f78a Mon Sep 17 00:00:00 2001 From: myriantics Date: Tue, 2 Jun 2026 22:42:58 -0700 Subject: [PATCH 2/6] PresentBlock now copies the stack used to place it with a count of 1. PresentBlock now handles present variant switching in getStateForPlacement() --- .../spectrum/blocks/present/PresentBlock.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/dafuqs/spectrum/blocks/present/PresentBlock.java b/src/main/java/de/dafuqs/spectrum/blocks/present/PresentBlock.java index e11c4b428e..974a8e1b5c 100644 --- a/src/main/java/de/dafuqs/spectrum/blocks/present/PresentBlock.java +++ b/src/main/java/de/dafuqs/spectrum/blocks/present/PresentBlock.java @@ -3,6 +3,7 @@ import com.mojang.serialization.*; import de.dafuqs.spectrum.api.energy.color.*; import de.dafuqs.spectrum.api.item.*; +import de.dafuqs.spectrum.components.*; import de.dafuqs.spectrum.helpers.*; import de.dafuqs.spectrum.networking.s2c_payloads.*; import de.dafuqs.spectrum.particle.effect.*; @@ -17,6 +18,7 @@ import net.minecraft.world.entity.*; import net.minecraft.world.entity.player.*; import net.minecraft.world.item.*; +import net.minecraft.world.item.context.*; import net.minecraft.world.level.*; import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.entity.*; @@ -106,9 +108,8 @@ public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { @Override public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { BlockEntity blockEntity = world.getBlockEntity(pos); - world.setBlockAndUpdate(pos, state.setValue(PresentBlock.VARIANT, PresentBlockItem.getWrapData(itemStack).variant())); if (blockEntity instanceof PresentBlockEntity presentBlockEntity) { - presentBlockEntity.setPresent(itemStack); + presentBlockEntity.setPresent(itemStack.copyWithCount(1)); } } @@ -220,7 +221,16 @@ private static void spawnParticlesClient(Level world, BlockPos pos, int color, i world.addParticle(particleEffect, posX, posY, posZ, randX, randY, randZ); } } - + + @Override + public @Nullable BlockState getStateForPlacement(BlockPlaceContext context) { + WrappedPresentComponent presentComponent = PresentBlockItem.getWrapData(context.getItemInHand()); + if (presentComponent != null) { + return this.defaultBlockState().setValue(VARIANT, presentComponent.variant()); + } + return super.getStateForPlacement(context); + } + @Override public @Nullable BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return new PresentBlockEntity(pos, state); From 22467629edf8e2c73832d62b4142d62bf5671449 Mon Sep 17 00:00:00 2001 From: myriantics Date: Tue, 2 Jun 2026 22:47:37 -0700 Subject: [PATCH 3/6] Fixed Pride wrapping paper being unobtainable due to Spore Blossoms being in the #minecraft:flowers tag and that check preceding the spore blossom check. --- .../recipe/crafting/dynamic/WrapPresentRecipe.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/dafuqs/spectrum/recipe/crafting/dynamic/WrapPresentRecipe.java b/src/main/java/de/dafuqs/spectrum/recipe/crafting/dynamic/WrapPresentRecipe.java index 81cf62e5e2..54f8636fa4 100644 --- a/src/main/java/de/dafuqs/spectrum/recipe/crafting/dynamic/WrapPresentRecipe.java +++ b/src/main/java/de/dafuqs/spectrum/recipe/crafting/dynamic/WrapPresentRecipe.java @@ -101,14 +101,14 @@ public ItemStack assemble(CraftingInput input, HolderLookup.Provider registryLoo return PresentBlock.WrappingPaper.PURPLE; } else if (item == Items.CAKE) { return PresentBlock.WrappingPaper.CAKE; - } else if (stack.is(ItemTags.FLOWERS)) { - return PresentBlock.WrappingPaper.STRIPED; + } else if (item == Items.SPORE_BLOSSOM) { + return PresentBlock.WrappingPaper.PRIDE; } else if (item == Items.FIREWORK_STAR) { return PresentBlock.WrappingPaper.STARRY; } else if (item == Items.SNOWBALL) { return PresentBlock.WrappingPaper.WINTER; - } else if (item == Items.SPORE_BLOSSOM) { - return PresentBlock.WrappingPaper.PRIDE; + } else if (stack.is(ItemTags.FLOWERS)) { + return PresentBlock.WrappingPaper.STRIPED; } return null; } From adbeb549d59430f844f280deadcb78272a316890 Mon Sep 17 00:00:00 2001 From: myriantics Date: Tue, 2 Jun 2026 23:59:36 -0700 Subject: [PATCH 4/6] Fixed PresentBlockItems not having their owner set when quick-crafted in the player's inventory. --- .../spectrum/mixin/InventoryMenuMixin.java | 31 +++++++++++++++++++ src/main/resources/spectrum.mixins.json | 1 + 2 files changed, 32 insertions(+) create mode 100644 src/main/java/de/dafuqs/spectrum/mixin/InventoryMenuMixin.java diff --git a/src/main/java/de/dafuqs/spectrum/mixin/InventoryMenuMixin.java b/src/main/java/de/dafuqs/spectrum/mixin/InventoryMenuMixin.java new file mode 100644 index 0000000000..48377b6184 --- /dev/null +++ b/src/main/java/de/dafuqs/spectrum/mixin/InventoryMenuMixin.java @@ -0,0 +1,31 @@ +package de.dafuqs.spectrum.mixin; + +import com.llamalad7.mixinextras.injector.wrapoperation.*; +import de.dafuqs.spectrum.blocks.present.*; +import net.minecraft.world.entity.player.*; +import net.minecraft.world.inventory.*; +import net.minecraft.world.item.*; +import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.injection.*; + +@Mixin(InventoryMenu.class) +public abstract class InventoryMenuMixin { + @Shadow + @Final + private Player owner; + + @WrapOperation( + method = "quickMoveStack", + slice = @Slice( + from = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;getEquipmentSlotForItem(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/EquipmentSlot;"), + to = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/Slot;onQuickCraft(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)V") + ), + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/InventoryMenu;moveItemStackTo(Lnet/minecraft/world/item/ItemStack;IIZ)Z") + ) + private boolean spectrum$triggerOnCraftedBeforeQuickMove(InventoryMenu instance, ItemStack itemStack, int startIndex, int endIndex, boolean reverseDirection, Operation original) { + if (itemStack.getItem() instanceof PresentBlockItem) { + itemStack.getItem().onCraftedBy(itemStack, this.owner.level(), this.owner); + } + return original.call(instance, itemStack, startIndex, endIndex, reverseDirection); + } +} diff --git a/src/main/resources/spectrum.mixins.json b/src/main/resources/spectrum.mixins.json index 76d767e19d..a67e8ac815 100644 --- a/src/main/resources/spectrum.mixins.json +++ b/src/main/resources/spectrum.mixins.json @@ -35,6 +35,7 @@ "GeodesGenerateWithGemstoneOresMixin", "GlassBottleItemMixin", "InfestedBlockMixin", + "InventoryMenuMixin", "ItemEntityMixin", "ItemStackMixin", "KilledByPlayerLootConditionMixin", From 11607f5a82876544a7a2cac20ffd56d8b4328c35 Mon Sep 17 00:00:00 2001 From: DaFuqs Date: Fri, 5 Jun 2026 17:41:44 +0200 Subject: [PATCH 5/6] filled / wrapped presents only stack to 1 --- .../de/dafuqs/spectrum/blocks/present/PresentBlockItem.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/de/dafuqs/spectrum/blocks/present/PresentBlockItem.java b/src/main/java/de/dafuqs/spectrum/blocks/present/PresentBlockItem.java index d3d5b9ad33..223ffb7ccf 100644 --- a/src/main/java/de/dafuqs/spectrum/blocks/present/PresentBlockItem.java +++ b/src/main/java/de/dafuqs/spectrum/blocks/present/PresentBlockItem.java @@ -151,6 +151,11 @@ public InteractionResultHolder use(Level world, Player user, Interact return InteractionResultHolder.pass(itemStack); } + @Override + public int getMaxStackSize(ItemStack stack) { + return stack.has(SpectrumDataComponentTypes.WRAPPED_PRESENT) || !isEmpty(stack) ? 1 : super.getMaxStackSize(stack); + } + // CraftingInventory does not recalculate the recipe after inputting / retrieving stacks from the present. // The recipes output will still hold the original present data from when it was put into the crafting grid // If the player then puts / receives items from the present they are able to duplicate items From 055f5f43cf84db1caef6fdd54ecc166b504201b1 Mon Sep 17 00:00:00 2001 From: DaFuqs Date: Fri, 5 Jun 2026 17:49:45 +0200 Subject: [PATCH 6/6] remove possibly not needed mixin --- .../spectrum/mixin/InventoryMenuMixin.java | 31 ------------------- src/main/resources/spectrum.mixins.json | 1 - 2 files changed, 32 deletions(-) delete mode 100644 src/main/java/de/dafuqs/spectrum/mixin/InventoryMenuMixin.java diff --git a/src/main/java/de/dafuqs/spectrum/mixin/InventoryMenuMixin.java b/src/main/java/de/dafuqs/spectrum/mixin/InventoryMenuMixin.java deleted file mode 100644 index 48377b6184..0000000000 --- a/src/main/java/de/dafuqs/spectrum/mixin/InventoryMenuMixin.java +++ /dev/null @@ -1,31 +0,0 @@ -package de.dafuqs.spectrum.mixin; - -import com.llamalad7.mixinextras.injector.wrapoperation.*; -import de.dafuqs.spectrum.blocks.present.*; -import net.minecraft.world.entity.player.*; -import net.minecraft.world.inventory.*; -import net.minecraft.world.item.*; -import org.spongepowered.asm.mixin.*; -import org.spongepowered.asm.mixin.injection.*; - -@Mixin(InventoryMenu.class) -public abstract class InventoryMenuMixin { - @Shadow - @Final - private Player owner; - - @WrapOperation( - method = "quickMoveStack", - slice = @Slice( - from = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;getEquipmentSlotForItem(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/EquipmentSlot;"), - to = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/Slot;onQuickCraft(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)V") - ), - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/InventoryMenu;moveItemStackTo(Lnet/minecraft/world/item/ItemStack;IIZ)Z") - ) - private boolean spectrum$triggerOnCraftedBeforeQuickMove(InventoryMenu instance, ItemStack itemStack, int startIndex, int endIndex, boolean reverseDirection, Operation original) { - if (itemStack.getItem() instanceof PresentBlockItem) { - itemStack.getItem().onCraftedBy(itemStack, this.owner.level(), this.owner); - } - return original.call(instance, itemStack, startIndex, endIndex, reverseDirection); - } -} diff --git a/src/main/resources/spectrum.mixins.json b/src/main/resources/spectrum.mixins.json index a67e8ac815..76d767e19d 100644 --- a/src/main/resources/spectrum.mixins.json +++ b/src/main/resources/spectrum.mixins.json @@ -35,7 +35,6 @@ "GeodesGenerateWithGemstoneOresMixin", "GlassBottleItemMixin", "InfestedBlockMixin", - "InventoryMenuMixin", "ItemEntityMixin", "ItemStackMixin", "KilledByPlayerLootConditionMixin",