Search in sources :

Example 6 with IPressurizable

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;
        }
    }
}
Also used : IPressurizable(me.desht.pneumaticcraft.api.item.IPressurizable) IAirHandler(me.desht.pneumaticcraft.api.tileentity.IAirHandler) IItemHandler(net.minecraftforge.items.IItemHandler) ItemStack(net.minecraft.item.ItemStack)

Example 7 with IPressurizable

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;
}
Also used : IPressurizable(me.desht.pneumaticcraft.api.item.IPressurizable) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Example 8 with IPressurizable

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;
}
Also used : IPressurizable(me.desht.pneumaticcraft.api.item.IPressurizable) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IManoMeasurable(me.desht.pneumaticcraft.api.tileentity.IManoMeasurable) EnumFacing(net.minecraft.util.EnumFacing) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString) TileEntity(net.minecraft.tileentity.TileEntity) IHeatExchanger(me.desht.pneumaticcraft.api.tileentity.IHeatExchanger) IPneumaticMachine(me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine) ItemStack(net.minecraft.item.ItemStack) IHeatExchangerLogic(me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic)

Example 9 with IPressurizable

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;
}
Also used : IPressurizable(me.desht.pneumaticcraft.api.item.IPressurizable) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IPressurizable (me.desht.pneumaticcraft.api.item.IPressurizable)9 ItemStack (net.minecraft.item.ItemStack)7 ArrayList (java.util.ArrayList)3 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)3 IManoMeasurable (me.desht.pneumaticcraft.api.tileentity.IManoMeasurable)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 IHeatExchangerLogic (me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic)1 IAirHandler (me.desht.pneumaticcraft.api.tileentity.IAirHandler)1 IHeatExchanger (me.desht.pneumaticcraft.api.tileentity.IHeatExchanger)1 IPneumaticMachine (me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine)1 Entity (net.minecraft.entity.Entity)1 EntityItem (net.minecraft.entity.item.EntityItem)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 ITextComponent (net.minecraft.util.text.ITextComponent)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 IItemHandler (net.minecraftforge.items.IItemHandler)1