use of me.desht.pneumaticcraft.api.item.IPressurizable in project pnc-repressurized by TeamPneumatic.
the class ModuleCharging method update.
@Override
public void update() {
super.update();
IItemHandler handler = getConnectedInventory();
if (handler != null) {
for (int i = 0; i < (upgraded ? 10 : 1) * PneumaticValues.CHARGING_STATION_CHARGE_RATE; i++) {
boolean charged = false;
for (int slot = 0; slot < handler.getSlots(); slot++) {
ItemStack chargedItem = handler.getStackInSlot(slot);
if (chargedItem.getItem() instanceof IPressurizable) {
IPressurizable chargingItem = (IPressurizable) chargedItem.getItem();
IAirHandler airHandler = pressureTube.getAirHandler(null);
if (chargingItem.getPressure(chargedItem) > airHandler.getPressure() + 0.01F && chargingItem.getPressure(chargedItem) > 0F) {
chargingItem.addAir(chargedItem, -1);
airHandler.addAir(1);
charged = true;
} else if (chargingItem.getPressure(chargedItem) < airHandler.getPressure() - 0.01F && chargingItem.getPressure(chargedItem) < chargingItem.maxPressure(chargedItem)) {
// if there is pressure, and the item isn't fully charged yet..
chargingItem.addAir(chargedItem, 1);
airHandler.addAir(-1);
charged = true;
}
}
}
if (!charged)
break;
}
}
}
use of me.desht.pneumaticcraft.api.item.IPressurizable in project pnc-repressurized by TeamPneumatic.
the class ContainerAmadron method canInteractWith.
@Override
public boolean canInteractWith(EntityPlayer player) {
if (player.getHeldItemMainhand().getItem() == Itemss.AMADRON_TABLET) {
IPressurizable pressurizable = (IPressurizable) Itemss.AMADRON_TABLET;
pressurizable.addAir(player.getHeldItemMainhand(), -1);
if (pressurizable.getPressure(player.getHeldItemMainhand()) > 0) {
return true;
} else {
player.sendStatusMessage(new TextComponentTranslation("gui.tab.problems.notEnoughPressure"), false);
}
}
return false;
}
use of me.desht.pneumaticcraft.api.item.IPressurizable in project pnc-repressurized by TeamPneumatic.
the class ItemManometer method onItemUseFirst.
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (world.isRemote)
return EnumActionResult.PASS;
ItemStack iStack = player.getHeldItem(hand);
if (((IPressurizable) iStack.getItem()).getPressure(iStack) > 0F) {
TileEntity te = world.getTileEntity(pos);
IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
List<ITextComponent> curInfo = new ArrayList<>();
List<String> info = new ArrayList<>();
if (machine != null && machine.getAirHandler(side) != null) {
machine.getAirHandler(side).printManometerMessage(player, info);
}
if (te instanceof IManoMeasurable) {
((IManoMeasurable) te).printManometerMessage(player, info);
}
for (String s : info) curInfo.add(new TextComponentTranslation(s));
if (te instanceof IHeatExchanger) {
IHeatExchangerLogic exchanger = ((IHeatExchanger) te).getHeatExchangerLogic(side);
if (exchanger != null) {
curInfo.add(new TextComponentTranslation("waila.temperature", (int) exchanger.getTemperature() - 273));
} else {
for (EnumFacing d : EnumFacing.VALUES) {
exchanger = ((IHeatExchanger) te).getHeatExchangerLogic(d);
if (exchanger != null) {
curInfo.add(new TextComponentTranslation("waila.temperature." + d.toString().toLowerCase(), (int) exchanger.getTemperature() - 273));
}
}
}
}
if (curInfo.size() > 0) {
((IPressurizable) iStack.getItem()).addAir(iStack, -30);
for (ITextComponent s : curInfo) {
player.sendStatusMessage(s, false);
}
return EnumActionResult.SUCCESS;
}
} else {
player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "The Manometer doesn't have any charge!"), false);
return EnumActionResult.FAIL;
}
return EnumActionResult.PASS;
}
use of me.desht.pneumaticcraft.api.item.IPressurizable in project pnc-repressurized by TeamPneumatic.
the class RecipePneumaticHelmet method getCraftingResult.
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
ItemStack output = getRecipeOutput();
// As the recipe is 2 high it could be in the 2nd row too.
int offsetY = inventory.getStackInRowAndColumn(0, 0).isEmpty() ? 1 : 0;
int totalDamage = inventory.getStackInRowAndColumn(0, offsetY).getItemDamage() + inventory.getStackInRowAndColumn(2, offsetY).getItemDamage() + inventory.getStackInRowAndColumn(0, offsetY + 1).getItemDamage() + inventory.getStackInRowAndColumn(2, offsetY + 1).getItemDamage();
((IPressurizable) output.getItem()).addAir(output, PneumaticValues.PNEUMATIC_HELMET_VOLUME * 10 - totalDamage);
return output;
}
Aggregations