Skip to content

Prevent item frame transmutation #8552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: mc1.20.1/dev
Choose a base branch
from
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
Expand Up @@ -14,6 +14,7 @@
import com.simibubi.create.api.schematic.requirement.SpecialEntityItemRequirement;
import com.simibubi.create.compat.framedblocks.FramedBlocksInSchematics;
import com.simibubi.create.foundation.data.recipe.Mods;
import com.simibubi.create.foundation.mixin.accessor.ItemFrameAccessor;

import net.createmod.catnip.nbt.NBTProcessors;
import net.minecraft.world.entity.Entity;
Expand Down Expand Up @@ -141,10 +142,10 @@ public static ItemRequirement of(Entity entity) {
}

if (entity instanceof ItemFrame itemFrame) {
ItemStack frame = new ItemStack(Items.ITEM_FRAME);
ItemStack frame = ((ItemFrameAccessor) itemFrame).create$getFrameItemStack();
ItemStack displayedItem = NBTProcessors.withUnsafeNBTDiscarded(itemFrame.getItem());
if (displayedItem.isEmpty())
return new ItemRequirement(ItemUseType.CONSUME, Items.ITEM_FRAME);
return new ItemRequirement(ItemUseType.CONSUME, frame);
return new ItemRequirement(List.of(new ItemRequirement.StackRequirement(frame, ItemUseType.CONSUME),
new ItemRequirement.StrictNbtStackRequirement(displayedItem, ItemUseType.CONSUME)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.simibubi.create.foundation.mixin.accessor;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.item.ItemStack;

@Mixin(ItemFrame.class)
public interface ItemFrameAccessor {
@Invoker("getFrameItemStack")
ItemStack create$getFrameItemStack();
}
1 change: 1 addition & 0 deletions src/main/resources/create.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"accessor.FlowingFluidAccessor",
"accessor.FluidInteractionRegistryAccessor",
"accessor.GameTestHelperAccessor",
"accessor.ItemFrameAccessor",
"accessor.ItemModelGeneratorsAccessor",
"accessor.LivingEntityAccessor",
"accessor.MobEffectInstanceAccessor",
Expand Down