|
| 1 | +package com.teammoeg.frostedheart.mixin.minecraft.misc; |
| 2 | + |
| 3 | +import blusunrize.immersiveengineering.api.IETags; |
| 4 | +import net.minecraft.world.entity.SlotAccess; |
| 5 | +import net.minecraft.world.entity.player.Player; |
| 6 | +import net.minecraft.world.inventory.ClickAction; |
| 7 | +import net.minecraft.world.inventory.Slot; |
| 8 | +import net.minecraft.world.item.BundleItem; |
| 9 | +import net.minecraft.world.item.ItemStack; |
| 10 | +import org.spongepowered.asm.mixin.Mixin; |
| 11 | +import org.spongepowered.asm.mixin.injection.At; |
| 12 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 13 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
| 14 | + |
| 15 | +/** |
| 16 | + * 防止容器套娃 |
| 17 | + */ |
| 18 | +@Mixin(BundleItem.class) |
| 19 | +public class BundleItemMixin { |
| 20 | + |
| 21 | + @Inject(at = @At("HEAD"), method = "overrideStackedOnOther", cancellable = true) |
| 22 | + public void overrideStackedOnOther(ItemStack pStack, Slot pSlot, ClickAction pAction, Player pPlayer, CallbackInfoReturnable<Boolean> cir) { |
| 23 | + if (pSlot.getItem().is(IETags.forbiddenInCrates)) { |
| 24 | + cir.setReturnValue(false); |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + @Inject(at = @At("HEAD"), method = "overrideOtherStackedOnMe", cancellable = true) |
| 29 | + public void overrideOtherStackedOnMe(ItemStack pStack, ItemStack pOther, Slot pSlot, ClickAction pAction, Player pPlayer, SlotAccess pAccess, CallbackInfoReturnable<Boolean> cir) { |
| 30 | + if (pOther.is(IETags.forbiddenInCrates)) { |
| 31 | + cir.setReturnValue(false); |
| 32 | + } |
| 33 | + } |
| 34 | +} |
0 commit comments