Minecraftforge: Update IItemHandler.getStackInSlot documentation to forbid null ItemStacks

Created on 25 Nov 2017  路  4Comments  路  Source: MinecraftForge/MinecraftForge

I wrote the IItemHandler code for 1.10.2 when null stacks were still a thing. Now we have ItemStack.EMPTY and the getStackInSlot is marked as @Nonnull, this should be updated to say the returned value should never be null.

1.12 Bug

Most helpful comment

The javadoc shouldn't disagree with the annotation though.

I'd like to request that extractItem (and possibly insertItem) explicitly mention whether the returned stack can (or cannot) be modified. I've seen a few mods who return their internal stack on simulate, and dupes pop up when other mods modify that (because they expected it to be a copy already)

All 4 comments

Are the annotations fixed? Only the annotations really matter

The javadoc shouldn't disagree with the annotation though.

I'd like to request that extractItem (and possibly insertItem) explicitly mention whether the returned stack can (or cannot) be modified. I've seen a few mods who return their internal stack on simulate, and dupes pop up when other mods modify that (because they expected it to be a copy already)

Also, there's this bit of javadoc:

     * If the result is not null but the stack size is zero, then it represents
     * an empty slot that will only accept* a specific itemstack.

Stack size zero? Completely impossible.

Fixed here: bbd4d8d

Was this page helpful?
0 / 5 - 0 ratings