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