Search in sources :

Example 1 with IManoMeasurable

use of me.desht.pneumaticcraft.api.tileentity.IManoMeasurable in project pnc-repressurized by TeamPneumatic.

the class ItemManometer method itemInteractionForEntity.

@Override
public boolean itemInteractionForEntity(ItemStack iStack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) {
    if (!player.world.isRemote) {
        if (entity instanceof IManoMeasurable) {
            if (((IPressurizable) iStack.getItem()).getPressure(iStack) > 0F) {
                List<String> curInfo = new ArrayList<String>();
                ((IManoMeasurable) entity).printManometerMessage(player, curInfo);
                if (curInfo.size() > 0) {
                    ((IPressurizable) iStack.getItem()).addAir(iStack, -30);
                    for (String s : curInfo) {
                        player.sendStatusMessage(new TextComponentTranslation(s), false);
                    }
                    return true;
                }
            } else {
                player.sendStatusMessage(new TextComponentTranslation(TextFormatting.RED + "The Manometer doesn't have any charge!"), false);
            }
        }
    }
    return false;
}
Also used : IPressurizable(me.desht.pneumaticcraft.api.item.IPressurizable) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IManoMeasurable(me.desht.pneumaticcraft.api.tileentity.IManoMeasurable) ArrayList(java.util.ArrayList) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 2 with IManoMeasurable

use of me.desht.pneumaticcraft.api.tileentity.IManoMeasurable 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)

Aggregations

ArrayList (java.util.ArrayList)2 IPressurizable (me.desht.pneumaticcraft.api.item.IPressurizable)2 IManoMeasurable (me.desht.pneumaticcraft.api.tileentity.IManoMeasurable)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 IHeatExchangerLogic (me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic)1 IHeatExchanger (me.desht.pneumaticcraft.api.tileentity.IHeatExchanger)1 IPneumaticMachine (me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1 ITextComponent (net.minecraft.util.text.ITextComponent)1