Skip to content

Instantly share code, notes, and snippets.

@yrsegal
Created December 8, 2015 03:21
Show Gist options
  • Save yrsegal/d54f6cbb1ad7d929e96c to your computer and use it in GitHub Desktop.
Save yrsegal/d54f6cbb1ad7d929e96c to your computer and use it in GitHub Desktop.
new provideblock
/**
* Uses Botania's API to make the backpack able to provide blocks to items that need it.
* @param player - the player
* @param requestor - itemStack requesting items
* @param stack - the stack to request items from (i.e. my backpack)
* @param block - the block requested
* @param meta - metadata of the block
* @param doIt - if mana should be consumed (if the item uses mana)
* @return - true if successful, false otherwise
*/
// @Optional.Method(modid="botania")
@Override
public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doIt) {
//simulate inventory to see if it has items
InventoryBackpack invBackpack = makeInv(IronBackpacks.proxy.getCurrBackpack(player), player);
int amount = invBackpack.hasStackInInv(block, meta);
if (amount > 0){
return invBackpack.removeOneItem(block, meta); //returns true if it was removed
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment