Package buildcraft.api.power.PowerHandler

Examples of buildcraft.api.power.PowerHandler.PowerReceiver


  }

  @Override
  public int getEnergyStored(ForgeDirection dir) {   
    if(bcPower != null) {
      PowerReceiver pr = bcPower.getPowerReceiver(dir);
      if(pr != null) {
         return (int)(pr.getEnergyStored() * 10);
      }
    }
    return 0;
  }
View Full Code Here


  }

  @Override
  public int getMaxEnergyStored(ForgeDirection dir) {
    if(bcPower != null && !(bcPower instanceof IPowerEmitter)) {
      PowerReceiver pr = bcPower.getPowerReceiver(dir);
      if(pr != null) {
        return (int)(pr.getMaxEnergyStored() * 10);
      }
    }
    return 0;
  }
View Full Code Here

  }

  @Override
  public int getPowerRequest(ForgeDirection dir) {
    if(bcPower != null) {
      PowerReceiver pr = bcPower.getPowerReceiver(dir);
      if(pr == null || pr.getType() == Type.ENGINE) {
        return 0;
      }
      return (int)( pr.powerRequest() * 10);
    }
    return 0;
  }
View Full Code Here

  }

  @Override
  public int getMinEnergyReceived(ForgeDirection dir) {
    if(bcPower != null) {
      PowerReceiver pr = bcPower.getPowerReceiver(dir);
      if(pr == null) {
        return 0;
      }
      return (int) (pr.getMinEnergyReceived() * 10);
    }
    return 0;
  }
View Full Code Here

  public int recieveEnergy(ForgeDirection opposite, int canOffer) {
    if(bcPower != null) {    
      if(bcPower instanceof IPowerEmitter) {
        return 0;
      }
      PowerReceiver pr = bcPower.getPowerReceiver(opposite);
      if(pr == null) {
        return 0;
      }
      double offer = Math.min(pr.powerRequest(), canOffer / 10f);     
      double used = pr.receiveEnergy(Type.PIPE, offer, opposite);
      return (int) (used * 10);
    }
    return 0;
  }
View Full Code Here

{
  @Override
  public long doReceiveEnergy(Object handler, ForgeDirection direction, long energy, boolean doReceive)
  {
    IPowerReceptor receptor = ((IPowerReceptor) handler);
    PowerReceiver receiver = receptor.getPowerReceiver(direction);

    if (receiver != null && energy > 0)
    {
        float bc = (float) (energy * CompatibilityType.BUILDCRAFT.ratio);
      if (doReceive)
      {
        return (long) (receiver.receiveEnergy(Type.PIPE, bc, direction) * CompatibilityType.BUILDCRAFT.reciprocal_ratio);
      }

      return (long) bc;
    }

View Full Code Here

            return (float) MjAPI.getMjBattery(tileAdj, MjAPI.DEFAULT_POWER_FRAMEWORK, inputAdj).addEnergy(toSendBC) * EnergyConfigHandler.BC3_RATIO;
        }
        else if (isBCLoaded && tileAdj instanceof IPowerReceptor)
        //Legacy BC API
        {
            PowerReceiver receiver = ((IPowerReceptor) tileAdj).getPowerReceiver(inputAdj);
            if (receiver != null)
            {
                double toSendBC = Math.min(toSend * EnergyConfigHandler.TO_BC_RATIO, Math.min(receiver.powerRequest(), receiver.getMaxEnergyReceived()));
                if (simulate)
                {
                    return (float) toSendBC * EnergyConfigHandler.BC3_RATIO;
                }
                float rec = (float) receiver.receiveEnergy(buildcraft.api.power.PowerHandler.Type.PIPE, toSendBC, inputAdj);
                return rec * EnergyConfigHandler.BC3_RATIO;
            }
        }
       
        return 0F;
View Full Code Here

                        e = (float) MjAPI.getMjBattery(acceptor, MjAPI.DEFAULT_POWER_FRAMEWORK, sideFrom).getEnergyRequested() * EnergyConfigHandler.BC3_RATIO;
                    }
                    else if (isBCLoaded && acceptor instanceof IPowerReceptor)
                    //Legacy BC API
                    {
                        PowerReceiver BCreceiver = ((IPowerReceptor) acceptor).getPowerReceiver(sideFrom);
                        if (BCreceiver != null)
                        {
                            e = (float) BCreceiver.powerRequest() * EnergyConfigHandler.BC3_RATIO;
                        }
                    }

                    if (e > 0.0F)
                    {
View Full Code Here

                    sentToAcceptor = (float) MjAPI.getMjBattery(tileEntity, MjAPI.DEFAULT_POWER_FRAMEWORK, sideFrom).addEnergy(currentSending * EnergyConfigHandler.TO_BC_RATIO) * EnergyConfigHandler.BC3_RATIO;
                }
                else if (isBCLoaded && tileEntity instanceof IPowerReceptor)
                //Legacy BC API
                {
                    PowerReceiver receiver = ((IPowerReceptor) tileEntity).getPowerReceiver(sideFrom);

                    if (receiver != null)
                    {
                        double toSendBC = Math.min(currentSending * EnergyConfigHandler.TO_BC_RATIO, receiver.powerRequest());
                        sentToAcceptor = (float) receiver.receiveEnergy(buildcraft.api.power.PowerHandler.Type.PIPE, toSendBC, sideFrom) * EnergyConfigHandler.BC3_RATIO;
                    }
                    else
                    {
                        sentToAcceptor = 0F;
                    }
View Full Code Here

  public IBatteryObject provider(final TileEntity te, final ForgeDirection side)
  {
    if ( te instanceof IPowerReceptor )
    {
      final IPowerReceptor receptor = (IPowerReceptor) te;
      final PowerReceiver ph = receptor.getPowerReceiver( side );

      if ( ph == null )
        return null;

      return new IBatteryObject() {

        @Override
        public void setEnergyStored(double mj)
        {

        }

        @Override
        public IBatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption)
        {
          return this;
        }

        @Override
        public double minimumConsumption()
        {
          return ph.getMinEnergyReceived();
        }

        @Override
        public double maxReceivedPerCycle()
        {
          return ph.getMaxEnergyReceived();
        }

        @Override
        public double maxCapacity()
        {
          return ph.getMaxEnergyStored();
        }

        @Override
        public String kind()
        {
          return MjAPI.DEFAULT_POWER_FRAMEWORK;
        }

        @Override
        public double getEnergyStored()
        {
          return ph.getEnergyStored();
        }

        @Override
        public double getEnergyRequested()
        {
          return ph.getMaxEnergyStored() - ph.getEnergyStored();
        }

        @Override
        public double addEnergy(double mj, boolean ignoreCycleLimit)
        {
          return ph.receiveEnergy( Type.PIPE, mj, side );
        }

        @Override
        public double addEnergy(double mj)
        {
          return ph.receiveEnergy( Type.PIPE, mj, side );
        }
      };
    }
    return null;
  }
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.