Created
July 2, 2016 10:04
-
-
Save dazsim/f38b33fad711292459551adb22473916 to your computer and use it in GitHub Desktop.
item handler code insertItem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) | |
{ | |
if (count == 0) | |
{ | |
this.barrelContents[0]=stack; | |
count = stack.stackSize; | |
} | |
if (count == size) | |
{ | |
//barrel is full | |
return stack; | |
} | |
if (this.barrelContents[0].isItemEqual(stack)) | |
{ | |
if (stack.stackSize+count<=size) | |
{ | |
//input stack will not fill barrel | |
count+=stack.stackSize; | |
return null; | |
} else if (stack.stackSize+count>size) | |
{ | |
//input stack will fill barrel | |
int a = size - count; | |
count = size; | |
stack.stackSize -= a; | |
return stack; | |
} | |
} | |
return stack; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment