use of me.desht.pneumaticcraft.api.item.IPressurizable in project pnc-repressurized by TeamPneumatic.
the class TileEntityChargingStation method update.
@Override
public void update() {
disCharging = false;
charging = false;
List<IPressurizable> chargingItems = new ArrayList<>();
List<ItemStack> chargedStacks = new ArrayList<>();
if (getChargingItem().getItem() instanceof IPressurizable) {
chargingItems.add((IPressurizable) getChargingItem().getItem());
chargedStacks.add(getChargingItem());
}
if (this.getUpgrades(EnumUpgrade.DISPENSER) > 0) {
// creating a new word, 'entities padding'.
List<Entity> entitiesPadding = getWorld().getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX() + 1, getPos().getY() + 2, getPos().getZ() + 1));
for (Entity entity : entitiesPadding) {
if (entity instanceof IPressurizable) {
chargingItems.add((IPressurizable) entity);
chargedStacks.add(ItemStack.EMPTY);
} else if (entity instanceof EntityItem) {
ItemStack entityStack = ((EntityItem) entity).getItem();
if (entityStack.getItem() instanceof IPressurizable) {
chargingItems.add((IPressurizable) entityStack.getItem());
chargedStacks.add(entityStack);
}
} else if (entity instanceof EntityPlayer) {
InventoryPlayer inv = ((EntityPlayer) entity).inventory;
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (stack.getItem() instanceof IPressurizable) {
chargingItems.add((IPressurizable) stack.getItem());
chargedStacks.add(stack);
}
}
}
}
}
int speedMultiplier = (int) getSpeedMultiplierFromUpgrades();
for (int i = 0; i < PneumaticValues.CHARGING_STATION_CHARGE_RATE * speedMultiplier; i++) {
boolean charged = false;
for (int j = 0; j < chargingItems.size(); j++) {
IPressurizable chargingItem = chargingItems.get(j);
ItemStack chargedItem = chargedStacks.get(j);
if (chargingItem.getPressure(chargedItem) > getPressure() + 0.01F && chargingItem.getPressure(chargedItem) > 0F) {
if (!getWorld().isRemote) {
chargingItem.addAir(chargedItem, -1);
addAir(1);
}
disCharging = true;
renderAirProgress -= ANIMATION_AIR_SPEED;
if (renderAirProgress < 0.0F) {
renderAirProgress += 1F;
}
charged = true;
} else if (chargingItem.getPressure(chargedItem) < getPressure() - 0.01F && chargingItem.getPressure(chargedItem) < chargingItem.maxPressure(chargedItem)) {
// if there is pressure, and the item isn't fully charged yet..
if (!getWorld().isRemote) {
chargingItem.addAir(chargedItem, 1);
addAir(-1);
}
charging = true;
renderAirProgress += ANIMATION_AIR_SPEED;
if (renderAirProgress > 1.0F) {
renderAirProgress -= 1F;
}
charged = true;
}
}
if (!charged)
break;
}
if (!getWorld().isRemote && oldRedstoneStatus != shouldEmitRedstone()) {
oldRedstoneStatus = shouldEmitRedstone();
updateNeighbours();
}
super.update();
if (!getWorld().isRemote) {
List<Pair<EnumFacing, IAirHandler>> teList = getAirHandler(null).getConnectedPneumatics();
if (teList.size() == 0)
getAirHandler(null).airLeak(getRotation());
}
}
use of me.desht.pneumaticcraft.api.item.IPressurizable 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.item.IPressurizable in project pnc-repressurized by TeamPneumatic.
the class CommonHUDHandler method tickEnd.
@SubscribeEvent
public void tickEnd(TickEvent.PlayerTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
EntityPlayer player = event.player;
if (this == PneumaticCraftRepressurized.proxy.getCommonHudHandler()) {
getHandlerForPlayer(player).tickEnd(event);
} else {
ItemStack helmetStack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (helmetStack.getItem() == Itemss.PNEUMATIC_HELMET) {
helmetPressure = ((IPressurizable) helmetStack.getItem()).getPressure(helmetStack);
if (ticksExisted == 0) {
checkHelmetInventory(helmetStack);
}
ticksExisted++;
if (!player.world.isRemote) {
if (ticksExisted > getStartupTime() && !player.capabilities.isCreativeMode) {
((IPressurizable) helmetStack.getItem()).addAir(helmetStack, (int) -UpgradeRenderHandlerList.instance().getAirUsage(player, false));
}
}
} else {
ticksExisted = 0;
}
if (!player.world.isRemote)
handleHacking(player);
}
}
}
use of me.desht.pneumaticcraft.api.item.IPressurizable in project pnc-repressurized by TeamPneumatic.
the class GuiPneumaticInventoryItem method addPressureStatInfo.
@Override
protected void addPressureStatInfo(List<String> pressureStatText) {
pressureStatText.add("\u00a77Current Pressure:");
ItemStack stack = te.getPrimaryInventory().getStackInSlot(TileEntityChargingStation.CHARGE_INVENTORY_INDEX);
float curPressure = ((IPressurizable) itemStack.getItem()).getPressure(stack);
int volume = ItemPneumaticArmor.getUpgrades(EnumUpgrade.VOLUME, stack) * PneumaticValues.VOLUME_VOLUME_UPGRADE + getDefaultVolume();
pressureStatText.add("\u00a70" + (double) Math.round(curPressure * 10) / 10 + " bar.");
pressureStatText.add("\u00a77Current Air:");
pressureStatText.add("\u00a70" + (double) Math.round(curPressure * volume) + " mL.");
pressureStatText.add("\u00a77Volume:");
pressureStatText.add("\u00a70" + getDefaultVolume() + " mL.");
if (volume > getDefaultVolume()) {
pressureStatText.add("\u00a70" + (double) Math.round(volume - getDefaultVolume()) + " mL. (Volume Upgrades)");
pressureStatText.add("\u00a70--------+");
pressureStatText.add("\u00a70" + (double) Math.round(volume) + " mL.");
}
}
use of me.desht.pneumaticcraft.api.item.IPressurizable in project pnc-repressurized by TeamPneumatic.
the class GuiChargingStation method addProblems.
@Override
protected void addProblems(List<String> textList) {
super.addProblems(textList);
ItemStack chargeStack = te.getPrimaryInventory().getStackInSlot(TileEntityChargingStation.CHARGE_INVENTORY_INDEX);
if (chargeStack.isEmpty()) {
textList.add("\u00a77No items to (dis)charge");
textList.addAll(PneumaticCraftUtils.convertStringIntoList("\u00a70Put a pneumatic item in the charge slot.", GuiConstants.MAX_CHAR_PER_LINE_LEFT));
} else if (!(chargeStack.getItem() instanceof IPressurizable)) {
textList.addAll(PneumaticCraftUtils.convertStringIntoList("\u00a77The inserted item can't be (dis)charged", GuiConstants.MAX_CHAR_PER_LINE_LEFT));
textList.addAll(PneumaticCraftUtils.convertStringIntoList("\u00a70Put a pneumatic item in the charge slot.", GuiConstants.MAX_CHAR_PER_LINE_LEFT));
} else {
IPressurizable chargeItem = (IPressurizable) chargeStack.getItem();
if (chargeItem.getPressure(chargeStack) > te.getPressure() + 0.01F && chargeItem.getPressure(chargeStack) <= 0) {
textList.addAll(PneumaticCraftUtils.convertStringIntoList("\u00a77The inserted item can't be discharged", GuiConstants.MAX_CHAR_PER_LINE_LEFT));
textList.add("\u00a70The item is empty.");
} else if (chargeItem.getPressure(chargeStack) < te.getPressure() - 0.01F && chargeItem.getPressure(chargeStack) >= chargeItem.maxPressure(chargeStack)) {
textList.addAll(PneumaticCraftUtils.convertStringIntoList("\u00a77The inserted item can't be charged", GuiConstants.MAX_CHAR_PER_LINE_LEFT));
textList.add("\u00a70The item is full.");
} else if (!te.charging && !te.disCharging) {
textList.addAll(PneumaticCraftUtils.convertStringIntoList("\u00a77The inserted item can't be (dis)charged", GuiConstants.MAX_CHAR_PER_LINE_LEFT));
textList.add("\u00a70The pressures have equalized.");
}
}
}
Aggregations