Package buildcraft.api.power.PowerHandler

Examples of buildcraft.api.power.PowerHandler.PowerReceiver


      for (PartP2PBCPower o : tunnels)
      {
        IPowerReceptor target = o.getPowerTarget();
        if ( target != null )
        {
          PowerReceiver tp = target.getPowerReceiver( side.getOpposite() );
          if ( tp != null )
          {
            double request = tp.powerRequest();

            if ( request > tp.getMaxEnergyReceived() )
              request = tp.getMaxEnergyReceived();

            if ( request > 0.01 && request > tp.getMinEnergyReceived() )
            {
              totalRequiredPower += request;
            }
          }
        }
      }

      if ( totalRequiredPower < 0.1 )
        return TickRateModulation.SLOWER;

      double currentTotal = pp.getPowerReceiver().getEnergyStored();
      if ( currentTotal < 0.01 )
        return TickRateModulation.SLOWER;

      for (PartP2PBCPower o : tunnels)
      {
        IPowerReceptor target = o.getPowerTarget();
        if ( target != null )
        {
          PowerReceiver tp = target.getPowerReceiver( side.getOpposite() );
          if ( tp != null )
          {
            double request = tp.powerRequest();

            if ( request > tp.getMaxEnergyReceived() )
              request = tp.getMaxEnergyReceived();

            if ( request > 0.01 && request > tp.getMinEnergyReceived() )
            {
              double toPull = currentTotal * (request / totalRequiredPower);
              double pulled = pp.useEnergy( 0, toPull, true );
              QueueTunnelDrain( PowerUnits.MJ, pulled );

              tp.receiveEnergy( Type.PIPE, pulled, o.side.getOpposite() );
            }
          }
        }
      }

View Full Code Here


                TileEntity tile = WorldPlugin.getTileEntityOnSide(worldObj, xCoord, yCoord, zCoord, direction);

                if (EngineTools.isPoweredTile(tile, direction.getOpposite())) {
                    IPowerReceptor receptor = (IPowerReceptor) tile;

                    PowerReceiver recProv = receptor.getPowerReceiver(direction.getOpposite());

                    double extracted = extractEnergy(recProv.getMinEnergyReceived(), recProv.getMaxEnergyReceived(), true);

                    if (extracted > 0)
                        recProv.receiveEnergy(PowerHandler.Type.ENGINE, extracted, direction.getOpposite());
                }
            } else if (pistonProgress >= 1) {
                pistonProgress = 0;
                pistonStage = 0;
            }
        } else if (powered) {
            TileEntity tile = WorldPlugin.getTileEntityOnSide(worldObj, xCoord, yCoord, zCoord, direction);

            if (EngineTools.isPoweredTile(tile, direction.getOpposite())) {
                IPowerReceptor receptor = (IPowerReceptor) tile;

                PowerReceiver recProv = receptor.getPowerReceiver(direction.getOpposite());

                if (extractEnergy(recProv.getMinEnergyReceived(), recProv.getMaxEnergyReceived(), false) > 0) {
                    pistonStage = 1;
                    setActive(true);
                } else
                    setActive(false);
            } else
View Full Code Here

public class EngineTools {

    public static boolean isPoweredTile(TileEntity tile, ForgeDirection side) {
        if (tile instanceof IPowerReceptor) {
            IPowerReceptor receptor = (IPowerReceptor) tile;
            PowerReceiver provider = receptor.getPowerReceiver(side);

            return provider instanceof PowerReceiver;
        }

        return false;
View Full Code Here

    }

    @Override
    public void detectAndSendChanges() {
        super.detectAndSendChanges();
        PowerReceiver provider = tile.getPowerReceiver(null);
        for (int i = 0; i < crafters.size(); i++) {
            ICrafting icrafting = (ICrafting) crafters.get(i);

            if (lastProcessTime != tile.getProcessTime())
                icrafting.sendProgressBarUpdate(this, 0, tile.getProcessTime());

            if (provider != null)
                icrafting.sendProgressBarUpdate(this, 1, (int) provider.getEnergyStored());
        }

        lastProcessTime = tile.getProcessTime();
    }
View Full Code Here

    @Override
    public void addCraftingToCrafters(ICrafting icrafting) {
        super.addCraftingToCrafters(icrafting);
        icrafting.sendProgressBarUpdate(this, 0, tile.getProcessTime());
        PowerReceiver provider = tile.getPowerReceiver(null);
        if (provider != null)
            icrafting.sendProgressBarUpdate(this, 2, (int) provider.getEnergyStored());
    }
View Full Code Here

    }

    @Override
    public void detectAndSendChanges() {
        super.detectAndSendChanges();
        PowerReceiver provider = tile.getPowerReceiver(null);
        for (int i = 0; i < crafters.size(); i++) {
            ICrafting icrafting = (ICrafting) crafters.get(i);

            if (lastProgress != tile.getProgress())
                icrafting.sendProgressBarUpdate(this, 0, tile.getProgress());

            if (provider != null)
                icrafting.sendProgressBarUpdate(this, 1, (int) provider.getEnergyStored());
        }

        ItemStack output = tile.getStackInSlot(0);
        if (!InvTools.isItemEqualStrict(output, prevOutput)) {
            onCraftMatrixChanged(craftMatrix);
View Full Code Here

    @Override
    public void addCraftingToCrafters(ICrafting icrafting) {
        super.addCraftingToCrafters(icrafting);
        icrafting.sendProgressBarUpdate(this, 0, tile.getProgress());
        PowerReceiver provider = tile.getPowerReceiver(null);
        if (provider != null)
            icrafting.sendProgressBarUpdate(this, 2, (int) provider.getEnergyStored());
    }
View Full Code Here

      int maxEnergy = handler.receiveEnergy(
          orientation.getOpposite(),
          Math.round(this.energy), true);
      return extractEnergy(minEnergy, maxEnergy, false);
    } else if (tile instanceof IPowerReceptor) {
      PowerReceiver receptor = ((IPowerReceptor) tile)
          .getPowerReceiver(orientation.getOpposite());

      return extractEnergy((int) Math.floor(receptor.getMinEnergyReceived() * 10),
          (int) Math.ceil(receptor.getMaxEnergyReceived() * 10), false);
    } else {
      return 0;
    }
  }
View Full Code Here

              (int) Math.round(extracted), false);

          extractEnergy(0, neededRF, true);
        }
      } else if (tile instanceof IPowerReceptor) {
        PowerReceiver receptor = ((IPowerReceptor) tile)
            .getPowerReceiver(orientation.getOpposite());

        if (extracted > 0) {
          double neededMJ = receptor.receiveEnergy(
              PowerHandler.Type.ENGINE, extracted / 10.0,
              orientation.getOpposite());

          extractEnergy((int) Math.floor(receptor.getMinEnergyReceived() * 10), (int) Math.ceil(neededMJ * 10), true);
        }
      }
    }
  }
View Full Code Here

  private void sendPower() {
    for (ForgeDirection s : ForgeDirection.VALID_DIRECTIONS) {
      TileEntity tile = getTileBuffer(s).getTile();

      if (tile instanceof IPowerReceptor) {
        PowerReceiver receptor = ((IPowerReceptor) tile)
            .getPowerReceiver(s.getOpposite());

        if (receptor != null) {
          receptor.receiveEnergy(PowerHandler.Type.ENGINE, energyStored / 10.0,
              s.getOpposite());

          energyStored = 0;
        }
      } else if (tile instanceof IEnergyHandler) {
View Full Code Here

TOP

Related Classes of buildcraft.api.power.PowerHandler.PowerReceiver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.