-
-
Save yrsegal/d54f6cbb1ad7d929e96c to your computer and use it in GitHub Desktop.
new provideblock
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
/** | |
* 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