use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.
the class BlockVortexTube method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) {
super.onBlockPlacedBy(world, x, y, z, par5EntityLiving, par6ItemStack);
TileEntityVortexTube te = (TileEntityVortexTube) world.getTileEntity(x, y, z);
for (int i = 0; i < 4; i++) {
te.rotateRoll(1);
ForgeDirection d = te.getTubeDirection();
IPneumaticMachine pneumaticMachine = ModInteractionUtils.getInstance().getMachine(world.getTileEntity(x + d.offsetX, y + d.offsetY, z + d.offsetZ));
if (pneumaticMachine != null && pneumaticMachine.isConnectedTo(d.getOpposite()))
break;
}
}
use of pneumaticCraft.api.tileentity.IPneumaticMachine 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.tileentity.IPneumaticMachine 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;
}
use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.
the class TileEntityElevatorBase method updateConnections.
public void updateConnections() {
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
TileEntity te = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
if (te instanceof IPneumaticMachine) {
sidesConnected[direction.ordinal()] = ((IPneumaticMachine) te).isConnectedTo(direction.getOpposite());
} else {
sidesConnected[direction.ordinal()] = false;
}
}
if (worldObj.getBlock(xCoord, yCoord + 1, zCoord) != Blockss.elevatorBase) {
coreElevator = this;
int i = -1;
TileEntity te = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
while (te instanceof TileEntityElevatorBase) {
((TileEntityElevatorBase) te).coreElevator = this;
i--;
te = worldObj.getTileEntity(xCoord, yCoord + i, zCoord);
}
}
}
use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.
the class TileEntityPneumaticBase method getConnectedPneumatics.
/**
* Retrieves a list of all the connecting pneumatics. It takes sides in account.
* @return
*/
@Override
public List<Pair<ForgeDirection, IAirHandler>> getConnectedPneumatics() {
List<Pair<ForgeDirection, IAirHandler>> teList = new ArrayList<Pair<ForgeDirection, IAirHandler>>();
for (IAirHandler specialConnection : specialConnectedHandlers) {
teList.add(new ImmutablePair(ForgeDirection.UNKNOWN, specialConnection));
}
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
TileEntity te = getTileCache()[direction.ordinal()].getTileEntity();
IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
if (machine != null && isConnectedTo(direction) && machine.isConnectedTo(direction.getOpposite())) {
teList.add(new ImmutablePair(direction, machine.getAirHandler()));
} else if (te instanceof ISidedPneumaticMachine) {
IAirHandler handler = ((ISidedPneumaticMachine) te).getAirHandler(direction.getOpposite());
if (handler != null) {
teList.add(new ImmutablePair(direction, handler));
}
}
}
return teList;
}
Aggregations