Jump to content

Getting the crafting result out of a custom crafting block


McJty

Recommended Posts

I have the following code in my container (which is a crafting mechanism):

 

    @Override
    public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {
        if (factory.isGhostOutputSlot(index)) {
            Slot slot = getSlot(index);
            if (slot.getHasStack()) {
                ItemStack result = slot.getStack().copy();
                getSlot(SLOT_BASE).decrStackSize(1);
                getSlot(SLOT_CONTROLLER).decrStackSize(1);
                getSlot(SLOT_TYPE_CONTROLLER).decrStackSize(1);
                getSlot(SLOT_ENERGY).decrStackSize(1);
                getSlot(SLOT_MEMORY).decrStackSize(1);
                getSlot(SLOT_ESSENCE).decrStackSize(1);
                slot.putStack(null);
                return result;
            } else {
                return null;
            }
        } else {
            return super.slotClick(index, button, mode, player);
        }
    }

 

The idea is that certain slots are consumed (this works) and that the crafted item is returned to the user. But apparently it just disappears. How can I make sure that the user can pull out the end result out of this crafter?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.