|
27 | 27 | import com.llamalad7.mixinextras.injector.wrapoperation.Operation; |
28 | 28 | import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
29 | 29 | import com.llamalad7.mixinextras.sugar.Local; |
| 30 | +import net.minecraft.core.Holder; |
30 | 31 | import net.minecraft.recipebook.ServerPlaceRecipe; |
31 | 32 | import net.minecraft.world.entity.player.Inventory; |
32 | 33 | import net.minecraft.world.entity.player.StackedItemContents; |
33 | 34 | import net.minecraft.world.inventory.Slot; |
| 35 | +import net.minecraft.world.item.Item; |
34 | 36 | import net.minecraft.world.item.ItemStack; |
35 | 37 | import net.minecraft.world.item.crafting.RecipeHolder; |
36 | 38 | import org.spongepowered.asm.mixin.Mixin; |
37 | 39 | import org.spongepowered.asm.mixin.injection.At; |
38 | | -import org.spongepowered.asm.mixin.injection.ModifyArg; |
39 | 40 | import org.spongepowered.common.bridge.world.item.crafting.PlacementInfoBridge; |
40 | 41 | import org.spongepowered.common.item.recipe.crafting.SpongeStackedItemContents; |
41 | 42 |
|
@@ -74,14 +75,25 @@ public abstract class ServerPlaceRecipeMixin { |
74 | 75 | : original.call(); |
75 | 76 | } |
76 | 77 |
|
77 | | - @ModifyArg( |
| 78 | + @WrapOperation( |
78 | 79 | method = "moveItemToGrid", |
79 | 80 | at = @At( |
80 | 81 | value = "INVOKE", |
81 | 82 | target = "Lnet/minecraft/world/entity/player/Inventory;findSlotMatchingCraftingIngredient(Lnet/minecraft/core/Holder;Lnet/minecraft/world/item/ItemStack;)I" |
82 | 83 | ) |
83 | 84 | ) |
84 | | - private ItemStack impl$adjustMatchingSlotFinder(final ItemStack craftInputStack) { |
85 | | - return this.impl$stackList.isEmpty() ? craftInputStack : this.impl$stackList.poll(); |
| 85 | + private int impl$adjustMatchingSlotFinder( |
| 86 | + final Inventory instance, final Holder<Item> exemplaryItem, final ItemStack craftInputStack, |
| 87 | + final Operation<Integer> original |
| 88 | + ) { |
| 89 | + if (this.impl$stackList.isEmpty()) { |
| 90 | + return original.call(instance, exemplaryItem, craftInputStack); |
| 91 | + } else { |
| 92 | + final ItemStack input = this.impl$stackList.poll(); |
| 93 | + if (!craftInputStack.isEmpty() && !ItemStack.isSameItemSameComponents(craftInputStack, input)) { |
| 94 | + return -1; |
| 95 | + } |
| 96 | + return original.call(instance, exemplaryItem, input); |
| 97 | + } |
86 | 98 | } |
87 | 99 | } |
0 commit comments