diff --git a/src/main/java/carpet/mixins/ContainerMixin.java b/src/main/java/carpet/mixins/ContainerMixin.java index ea1b83fb..0fb1c58c 100644 --- a/src/main/java/carpet/mixins/ContainerMixin.java +++ b/src/main/java/carpet/mixins/ContainerMixin.java @@ -16,10 +16,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.List; @Mixin(Container.class) -public class ContainerMixin +public abstract class ContainerMixin { @Shadow @Final public List slotList; - + + @Shadow public abstract ItemStack onSlotClick(int int_1, int int_2, SlotActionType slotActionType_1, PlayerEntity playerEntity_1); + + @Shadow public abstract void sendContentUpdates(); + @Inject( method = "onSlotClick", at = @At(value = "HEAD"), cancellable = true) private void onThrowClick( int int_1, @@ -33,47 +37,19 @@ public class ContainerMixin { ItemStack itemStack_1 = ItemStack.EMPTY; Slot slot_4 = slotList.get(int_1); - if (slot_4 != null && slot_4.canTakeItems(playerEntity_1)) + if (slot_4 != null && slot_4.hasStack() && slot_4.canTakeItems(playerEntity_1)) { if(int_1 == 0 && int_2 == 1) { - ItemStack itemStackDropAll = dropAllCrafting(playerEntity_1, int_1, slotList); - while (!itemStackDropAll.isEmpty() && ItemStack.areItemsEqual(slot_4.getStack(), itemStackDropAll)) + while(slot_4.hasStack()) { - itemStack_1 = itemStackDropAll.copy(); - itemStackDropAll = dropAllCrafting(playerEntity_1, int_1, slotList); + this.onSlotClick(int_1, 0, SlotActionType.THROW, playerEntity_1); } + this.sendContentUpdates(); cir.setReturnValue(itemStack_1); cir.cancel(); } } } } - - private ItemStack dropAllCrafting(PlayerEntity playerIn, int index, List invSlotParam) - { - ItemStack itemstack = ItemStack.EMPTY; - Slot slot = invSlotParam.get(index); - if (slot != null && slot.hasStack()) - { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - if (index == 0) - { - playerIn.dropItem(itemstack, true); - itemstack1.setCount(0); - slot.onStackChanged(itemstack1, itemstack); - } - if (itemstack.getCount() == itemstack1.getCount()) - { - return ItemStack.EMPTY; - } - ItemStack itemstack2 = slot.onTakeItem(playerIn, itemstack1); - if (index == 0) - { - playerIn.dropItem(itemstack2, false); - } - } - return itemstack; - } }