use of net.silentchaos512.gems.api.energy.IChaosStorage in project SilentGems by SilentChaos512.
the class ChaosUtil method getAmountPlayerCanAccept.
/**
* Gets the amount of chaos the player could receive, include available capacity in items that store chaos.
*/
public static int getAmountPlayerCanAccept(EntityPlayer player, int maxToSend) {
PlayerData data = PlayerDataHandler.get(player);
int amount = data.getMaxChaos() - data.getCurrentChaos();
for (ItemStack stack : getChaosStorageItems(player)) {
amount += ((IChaosStorage) stack.getItem()).receiveCharge(stack, maxToSend - amount, true);
if (amount >= maxToSend)
return maxToSend;
}
return amount;
}
use of net.silentchaos512.gems.api.energy.IChaosStorage in project SilentGems by SilentChaos512.
the class ChaosUtil method getTotalChaosAvailable.
/**
* Gets the total amount of chaos the player has available, including chaos stored in items.
*/
public static int getTotalChaosAvailable(EntityPlayer player) {
PlayerData data = PlayerDataHandler.get(player);
int amount = data.getCurrentChaos();
for (ItemStack stack : getChaosStorageItems(player)) {
if (stack.getItem() instanceof IChaosStorage) {
amount += ((IChaosStorage) stack.getItem()).getCharge(stack);
}
}
return amount;
}
Aggregations