Search in sources :

Example 6 with IChaosStorage

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;
}
Also used : ItemStack(net.minecraft.item.ItemStack) PlayerData(net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData)

Example 7 with IChaosStorage

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;
}
Also used : IChaosStorage(net.silentchaos512.gems.api.energy.IChaosStorage) ItemStack(net.minecraft.item.ItemStack) PlayerData(net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData)

Aggregations

ItemStack (net.minecraft.item.ItemStack)7 IChaosStorage (net.silentchaos512.gems.api.energy.IChaosStorage)6 PlayerData (net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 RecipeChaosAltar (net.silentchaos512.gems.api.recipe.altar.RecipeChaosAltar)1