use of pneumaticCraft.api.item.IPressurizable in project PneumaticCraft by MineMaarten.
the class ModuleCharging method update.
@Override
public void update() {
super.update();
IInventory inv = getConnectedInventory();
if (inv != null) {
int[] accessibleSlots = IOHelper.getAccessibleSlotsForInventory(inv, dir.getOpposite());
for (int i = 0; i < (upgraded ? 10 : 1) * PneumaticValues.CHARGING_STATION_CHARGE_RATE; i++) {
boolean charged = false;
for (int slot : accessibleSlots) {
ItemStack chargedItem = inv.getStackInSlot(slot);
if (chargedItem != null && chargedItem.getItem() instanceof IPressurizable) {
IPressurizable chargingItem = (IPressurizable) chargedItem.getItem();
IAirHandler airHandler = ((IPneumaticMachine) pressureTube).getAirHandler();
if (chargingItem.getPressure(chargedItem) > airHandler.getPressure(ForgeDirection.UNKNOWN) + 0.01F && chargingItem.getPressure(chargedItem) > 0F) {
chargingItem.addAir(chargedItem, -1);
airHandler.addAir(1, ForgeDirection.UNKNOWN);
charged = true;
} else if (chargingItem.getPressure(chargedItem) < airHandler.getPressure(ForgeDirection.UNKNOWN) - 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, ForgeDirection.UNKNOWN);
charged = true;
}
}
}
if (!charged)
break;
}
}
}
use of pneumaticCraft.api.item.IPressurizable in project PneumaticCraft by MineMaarten.
the class ContainerAmadron method canInteractWith.
@Override
public boolean canInteractWith(EntityPlayer player) {
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Itemss.amadronTablet) {
IPressurizable pressurizable = (IPressurizable) Itemss.amadronTablet;
pressurizable.addAir(player.getCurrentEquippedItem(), -1);
if (pressurizable.getPressure(player.getCurrentEquippedItem()) > 0)
return true;
else {
player.addChatMessage(new ChatComponentTranslation("gui.tab.problems.notEnoughPressure"));
}
}
return false;
}
use of pneumaticCraft.api.item.IPressurizable in project PneumaticCraft by MineMaarten.
the class ItemManometer method onItemUseFirst.
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
*/
@Override
public boolean onItemUseFirst(ItemStack iStack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) {
if (world.isRemote)
return false;
if (((IPressurizable) iStack.getItem()).getPressure(iStack) > 0F) {
TileEntity te = world.getTileEntity(x, y, z);
IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
List<IChatComponent> curInfo = new ArrayList<IChatComponent>();
List<String> info = new ArrayList<String>();
if (te instanceof IManoMeasurable) {
((IManoMeasurable) te).printManometerMessage(player, info);
} else if (machine != null) {
machine.getAirHandler().printManometerMessage(player, info);
}
for (String s : info) curInfo.add(new ChatComponentTranslation(s));
if (te instanceof IHeatExchanger) {
IHeatExchangerLogic exchanger = ((IHeatExchanger) te).getHeatExchangerLogic(ForgeDirection.getOrientation(side));
if (exchanger != null) {
curInfo.add(new ChatComponentTranslation("waila.temperature", (int) exchanger.getTemperature() - 273));
} else {
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
exchanger = ((IHeatExchanger) te).getHeatExchangerLogic(d);
if (exchanger != null) {
curInfo.add(new ChatComponentTranslation("waila.temperature." + d.toString().toLowerCase(), (int) exchanger.getTemperature() - 273));
}
}
}
}
if (curInfo.size() > 0) {
((IPressurizable) iStack.getItem()).addAir(iStack, -30);
for (IChatComponent s : curInfo) {
player.addChatComponentMessage(s);
}
return true;
}
} else {
player.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.RED + "The Manometer doesn't have any charge!"));
return false;
}
return false;
}
Aggregations