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;
}
Aggregations