Jump to content

Recommended Posts

Posted

If I have an IIventory TileEntity with several slots, and want only one of these to only take one item at a time(an Itemstack of size 1, that is), even if the item itself can be stacked, is that possible?

Posted

I did this in my Particle Deco Mod, here's the source:

https://github.com/SanAndreasP/Particle-Decoration-Mod

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

What I'm seeing in your source is that you make getStackSizeLimit return 1, but that will make all slots accept only 1 item per stack. What I'm thinking is an inventory where each slot can accept different max sizes.

Posted

That shouldn't be a problem. You can make a variable like

public int stackLimit = 64;

 

let it return in getSlotStackLimit:

    public int getSlotStackLimit()
    {
        return this.stackLimit;
    }

 

and make a constructor like:

public SlotCustom(ContainerCustom container, IInventory iinventory, int i, int j, int k, int l)
    {
        super(iinventory, i, j, k);
        field_40442_a = container;
        this.stackLimit = l;
    }

 

After all that, when you define the slots in the container, you can do this:

         addSlotToContainer(new SlotCustom(this, tileentity, 0, 47, 17, 4));
         addSlotToContainer(new PD_SlotCustom(this, tileentity, 1, 47, 52, 32));

 

The first would then take stacks with max. quantity 4, the second would take 32.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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.