Jump to content

[SOLVED][1.8.9] TileEntityContainer per-slot max stack size possible?


Recommended Posts

Posted

Hi, I'm a novice modder (and coder), and I need your help...!!!

 

I have a working furnace with multiple input slots (1 fuel and 1 output). All basic functionality is working properly. I'd like to implement some additional behavior, but for the life of me I can't figure out how. I did an initial search and was surprised to turn up nothing about this. All the info I found was to set behaviors for the entire entity, not individual slots.

[*]I'd like to restrict maxstacksize for input slots to 1, and leave maxstacksize for fuel and output slots at default (64).

[*]I'd also like to be able to restrict valid ItemStack for input slots based on oredict tags (ore* and dust*)

 

PART 1

 

I've been able to get correct shift-click behavior with custom Slot class, custom mergeItemStack(), and transferStackInSlot() in the Container class. But this yields odd left-click behavior if implemented (left clicking an occupied input slot while holding a matching ItemStack withdraws the stack from the slot and increases the held stack, even past stacksize limits) so I've reverted it.

 

I also can't get automation (hoppers) to change behavior (round robin) or respect the custom inputSlot's stacksize limits, without setting the TileEntity'sgetInventoryStackLimit() to return 1 instead of 64. This of course causes problems for the fuel and output slots.

 

PART 2

 

Honestly have no clue where to begin. I looked through the oredict class, but couldn't find any way to make a given ItemStack return its oredict tag.

 

CODE

 

Tile Entity:

 

  Reveal hidden contents

 

 

Container:

 

  Reveal hidden contents

 

 

Thanks for any help!

Posted

Use your custom slot for the slot that should have a max stack size of 1 and return 1 for the Slot#getSlotStackLimit method.

 

However, the vanilla #mergeStackInSlot implementations DO NOT check the slot's stack limit (at least as of 1.8 - maybe it has changed), and also has trouble handling slot limits of 1.

 

Here is an implementation I came up with for #mergeStackInSlot - there are others out there as well that do the same thing.

 

As for the shift-clicking moving items into the wrong slots, that has to do with how you choose to implement #transferStackInSlot - you can find some information about that in this tutorial, though I recommend you skip to the final spoiler section first, as that is the most recent.

Posted

!!!

 

Hey, it's you! Your tutorials (and others') are the reason I've gotten this far. Thanks for putting those together!

 

I've re-implemented custom Slot classes and MergeStackInSlot() to handle the Container interactions. This time I've also implemented more comprehensive logic in TileEntity.isItemValidForSlot() to handle automated insertion, to catch itemstack.stackSize > 1 for those slots. Hopefully that'll cover all of it.

 

The errant clicking behavior actually happens on regular click and not shift click, as described in the OP:

  Quote
(If for whatever reason the itemstack in the slot has stacksize > 1) left clicking an occupied input slot while holding a matching ItemStack withdraws the stack from the slot and increases the held stack, even past stacksize limits, so I've reverted it.

 

Hopefully now it's a moot point, unless there's a way to get an itemstack > 1 into a slot that I'm missing. I still want to fix that behavior, just in case. Thanks for the help, and again for the tutorials.

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.