Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

Climbing the interface ladder

From basic graphical interfaces to very advanced ones

Input to output

  • 2014-01-18 20:37:35
    How do you make it so that once an itemstack in say items[1] == a custom item and the stack size is 64 it outputs something in items[2]?
  • 2014-01-18 23:03:21
    You can for example check in onInventoryChanged if that slot has the items and that amount.
    Here is an example of you could do it (untested):

    @Override
    public void onInventoryChanged() {
        super.onInventoryChanged();
        
        if (items[1].getItem() == Item.glowstone && items[1].stackSize == 64) {
            setInventorySlotContents(1, null);
            setInventorySlotContents(2, new ItemStack(Block.glowStone, 4));
        }
    }
  • 2014-01-19 17:27:25
    You'll need a null check there as well. And check for the content in the output slot.
  • 2014-01-20 23:20:56
    Thanks for the help, works fine with the null check!
  • Log in or sign up to reply to this thread