Search in sources :

Example 1 with PhasedFieldGeneratorItem

use of mcjty.rftoolsdim.items.PhasedFieldGeneratorItem in project RFToolsDimensions by McJty.

the class RfToolsDimensionManager method checkValidPhasedFieldGenerator.

public static boolean checkValidPhasedFieldGenerator(EntityPlayer player, boolean consume, int tickCost) {
    InventoryPlayer inventory = player.inventory;
    for (int i = 0; i < InventoryPlayer.getHotbarSize(); i++) {
        ItemStack slot = inventory.getStackInSlot(i);
        if (!slot.isEmpty() && slot.getItem() == ModItems.phasedFieldGeneratorItem) {
            PhasedFieldGeneratorItem pfg = (PhasedFieldGeneratorItem) slot.getItem();
            int energyStored = pfg.getEnergyStored(slot);
            int toConsume;
            if (GeneralConfiguration.enableDynamicPhaseCost) {
                toConsume = (int) (DimensionTickEvent.MAXTICKS * tickCost * GeneralConfiguration.dynamicPhaseCostAmount);
            } else {
                toConsume = DimensionTickEvent.MAXTICKS * PowerConfiguration.PHASEDFIELD_CONSUMEPERTICK;
            }
            if (energyStored >= toConsume) {
                if (consume) {
                    pfg.extractEnergy(slot, toConsume, false);
                }
                return true;
            }
        }
    }
    return false;
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) ItemStack(net.minecraft.item.ItemStack) PhasedFieldGeneratorItem(mcjty.rftoolsdim.items.PhasedFieldGeneratorItem)

Aggregations

PhasedFieldGeneratorItem (mcjty.rftoolsdim.items.PhasedFieldGeneratorItem)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1 ItemStack (net.minecraft.item.ItemStack)1