|
/** |
|
* 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 a test or real thing (currently opposite of what it should be...) |
|
* @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){ |
|
if (!doIt){ //TODO: VAZKIIIIIIIIII why is it opposite :( |
|
return invBackpack.removeOneItem(block, meta); //returns true if it was removed |
|
} |
|
} |
|
|
|
return false; |
|
} |
If doIt
is true, mana should be consumed. This will produce unexpected behavior. You should replace those lines with:
https://gist.github.com/yrsegal/d54f6cbb1ad7d929e96c
(this isn't big enough for a PR)