diff --git a/Xplat/src/main/java/vazkii/botania/mixin/LoomMenuMixin.java b/Xplat/src/main/java/vazkii/botania/mixin/LoomMenuMixin.java index c6adf7e512..5c1e82b434 100644 --- a/Xplat/src/main/java/vazkii/botania/mixin/LoomMenuMixin.java +++ b/Xplat/src/main/java/vazkii/botania/mixin/LoomMenuMixin.java @@ -4,21 +4,33 @@ import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.LoomMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BannerPattern; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Final; 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.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import vazkii.botania.common.item.ItemWithBannerPattern; import java.util.List; @Mixin(LoomMenu.class) -public class LoomMenuMixin { +public abstract class LoomMenuMixin extends AbstractContainerMenu { + protected LoomMenuMixin(@Nullable MenuType menuType, int containerId) { + super(menuType, containerId); + } + @Inject(at = @At("HEAD"), method = "getSelectablePatterns(Lnet/minecraft/world/item/ItemStack;)Ljava/util/List;", cancellable = true) private void handleBotaniaPatternItems(ItemStack stack, CallbackInfoReturnable>> cir) { if (stack.getItem() instanceof ItemWithBannerPattern p) { @@ -27,5 +39,19 @@ private void handleBotaniaPatternItems(ItemStack stack, CallbackInfoReturnable cir, ItemStack dummyStack, + Slot slot, ItemStack movedStack) { + if (movedStack.getItem() instanceof ItemWithBannerPattern + && moveItemStackTo(movedStack, this.patternSlot.index, this.patternSlot.index + 1, false)) { + cir.setReturnValue(ItemStack.EMPTY); + } + } }