Package erogenousbeef.bigreactors.common.multiblock

Examples of erogenousbeef.bigreactors.common.multiblock.MultiblockReactor


 
  // Redstone methods
  public boolean isRedstoneActive() {
    if(!this.isConnected()) { return false; }

    MultiblockReactor reactor = (MultiblockReactor)getMultiblockController();

    switch(circuitType) {
    case outputFuelTemperature:
      return checkVariable((int)reactor.getFuelHeat());
    case outputCasingTemperature:
      return checkVariable((int)reactor.getReactorHeat());
    case outputFuelMix:
      return checkVariable((int)(reactor.getFuelRichness()*100));
    case outputFuelAmount:
      return checkVariable(reactor.getFuelAmount());
    case outputWasteAmount:
      return checkVariable(reactor.getWasteAmount());
    case outputEnergyAmount:
      return checkVariable(reactor.getEnergyStoredPercentage());
    case DISABLED:
      return false;
    default:
      return this.isExternallyPowered;
    }
View Full Code Here


  // Called to do business logic when the redstone value has changed
  protected void onRedstoneInputUpdated() {
    if(!this.isConnected()) { return; }

    MultiblockReactor reactor = (MultiblockReactor)getMultiblockController();
    switch(this.circuitType) {
    case inputActive:
      if(this.isInputActiveOnPulse()) {
        if(this.isExternallyPowered) {
          reactor.setActive(!reactor.getActive());
        }
      }
      else {
        reactor.setActive(this.isExternallyPowered);
      }
      break;
    case inputSetControlRod:
      // On/off only
      if(this.isInputActiveOnPulse()) {
        if(this.isExternallyPowered) {
          if(this.shouldSetControlRodsInsteadOfChange()) {
            reactor.setAllControlRodInsertionValues(this.outputLevel);
          }
          else {
            reactor.changeAllControlRodInsertionValues((short)this.outputLevel); // Can be negative, don't want to mask.
          }
        }
      }
      else {
        if(this.isExternallyPowered) {
          reactor.setAllControlRodInsertionValues(getControlRodLevelWhileOn());
        }
        else {
          reactor.setAllControlRodInsertionValues(getControlRodLevelWhileOff());
        }
      }
      break;
    case inputEjectWaste:
      // Pulse only
      if(this.isExternallyPowered) {
        reactor.ejectWaste(false, null);
      }
      break;
    default:
      break;
    }
View Full Code Here

    }

    if(!this.isConnected()) {
      throw new Exception("Unable to access reactor - port is not connected");
    }
    MultiblockReactor reactor = this.getReactorController();

    ComputerMethod computerMethod = ComputerMethod.values()[method];
    int index, newLevel;
    boolean newState;
    TileEntityReactorControlRod controlRod;

    switch(computerMethod) {
    case getEnergyStored:
      return new Object[] { (int)reactor.getEnergyStored() };
    case getNumberOfControlRods:
      return new Object[] { (int)reactor.getFuelRodCount() };
    case getActive:
      return new Object[] { reactor.getActive() };
    case getFuelTemperature:
      return new Object[] { reactor.getFuelHeat() };
    case getCasingTemperature:
      return new Object[] { reactor.getReactorHeat() };
    case getFuelAmount:
      return new Object[] { (int)reactor.getFuelAmount() };
    case getWasteAmount:
      return new Object[] { (int)reactor.getWasteAmount() };
    case getFuelAmountMax:
      return new Object[] { reactor.getCapacity() };
    case getControlRodName:
      if(arguments.length < 1) {
        throw new IllegalArgumentException("Insufficient number of arguments, expected 1");
      }
     
      controlRod = getControlRodFromArguments(reactor, arguments, 0);
      return new Object[] { controlRod.getName() };

    case getControlRodLevel:
      if(arguments.length < 1) {
        throw new IllegalArgumentException("Insufficient number of arguments, expected 1");
      }
     
      controlRod = getControlRodFromArguments(reactor, arguments, 0);
      return new Object[] { (int)controlRod.getControlRodInsertion() };

    case getEnergyProducedLastTick:
      return new Object[] { reactor.getEnergyGeneratedLastTick() };
   
    case getHotFluidProducedLastTick:
      if(reactor.isPassivelyCooled())
        return new Object[] { 0f };
      else
        return new Object[] { reactor.getEnergyGeneratedLastTick() };
     
    case isActivelyCooled:
      return new Object[] { !reactor.isPassivelyCooled() };

    case getCoolantAmount:
      return new Object[] { reactor.getCoolantContainer().getCoolantAmount() };
     
    case getCoolantAmountMax:
      return new Object[] { reactor.getCoolantContainer().getCapacity() };

    case getCoolantType: {
      Fluid fluidType = reactor.getCoolantContainer().getCoolantType();
      if(fluidType == null) {
        return null;
      }
      else {
        return new Object[] { fluidType.getName() };
      }
    }

    case getHotFluidAmount:
      return new Object[] { reactor.getCoolantContainer().getVaporAmount() };
   
    case getHotFluidAmountMax:
      return new Object[] { reactor.getCoolantContainer().getCapacity() };

    case getHotFluidType: {
      Fluid fluidType = reactor.getCoolantContainer().getVaporType();
      if(fluidType == null) {
        return null;
      }
      else {
        return new Object[] { fluidType.getName() };
      }
    }
   
    case getFuelReactivity:
      return new Object[] { reactor.getFuelFertility() * 100f };

    case getFuelConsumedLastTick:
      return new Object[] { reactor.getFuelConsumedLastTick() };
     
    case getMinimumCoordinate:
    {
      CoordTriplet coord = reactor.getMinimumCoord();
      return new Object[] { coord.x, coord.y, coord.z };
    }
     
    case getMaximumCoordinate:
    {
      CoordTriplet coord = reactor.getMaximumCoord();
      return new Object[] { coord.x, coord.y, coord.z };
    }

    case setActive:
      if(arguments.length < 1) {
        throw new IllegalArgumentException("Insufficient number of arguments, expected 1");
      }
      if(!(arguments[0] instanceof Boolean)) {
        throw new IllegalArgumentException("Invalid argument 0, expected Boolean");
      }
      newState = (Boolean)arguments[0];
      reactor.setActive(newState);
      return null;

    case setAllControlRodLevels:
      if(arguments.length < 1) {
        throw new IllegalArgumentException("Insufficient number of arguments, expected 1");
      }
      if(!(arguments[0] instanceof Double)) {
        throw new IllegalArgumentException("Invalid argument 0, expected Number");
      }
      newLevel = (int)Math.round((Double)arguments[0]);
      reactor.setAllControlRodInsertionValues(newLevel);
      return null;

    case setControlRodLevel:
      if(arguments.length < 2) {
        throw new IllegalArgumentException("Insufficient number of arguments, expected 2 (control rod index, level)");
      }

      if(!(arguments[1] instanceof Double)) {
        throw new IllegalArgumentException("Invalid argument 0, expected Number");
      }

      newLevel = (int)Math.round((Double)arguments[1]);
      if(newLevel < 0 || newLevel > 100) {
        throw new IllegalArgumentException("Invalid argument 1, valid range is 0-100");
      }

      controlRod = getControlRodFromArguments(reactor, arguments, 0);
      controlRod.setControlRodInsertion((short) newLevel);
     
      return null;
    // "do" methods - void return, no inputs
    case doEjectWaste:
      reactor.ejectWaste(false, null);
      return null;
    case doEjectFuel:
      reactor.ejectFuel(false, null);
      return null;

    default: throw new Exception("Method unimplemented - yell at Beef");
    }
  }
View Full Code Here

  @Override
  public void onMultiblockServerTick() {
    if(!isConnected()) { return; }
   
    MultiblockReactor reactor = getReactorController();

    if(isInlet()) {
      CoolantContainer cc = reactor.getCoolantContainer();
      if(cc.getCoolantAmount() < cc.getCapacity())
      {
        reactor.getCoolantContainer().addCoolant(new FluidStack(FluidRegistry.WATER, cc.getCapacity()));
      }
    }
    else {
      reactor.getCoolantContainer().emptyVapor();
    }
  }
View Full Code Here

  }

  public void forceAddWater() {
    if(!isConnected()) { return; }
   
    MultiblockReactor reactor = getReactorController();
    reactor.getCoolantContainer().addCoolant(new FluidStack(FluidRegistry.WATER, 1000));
  }
View Full Code Here

    protected abstract IMessage handleMessage(M message, MessageContext ctx, MultiblockReactor reactor);

    @Override
    protected IMessage handleMessage(M message, MessageContext ctx, TileEntity te) {
      if(te instanceof TileEntityReactorPartBase) {
        MultiblockReactor reactor = ((TileEntityReactorPartBase)te).getReactorController();
        if(reactor != null) {
          return handleMessage(message, ctx, reactor);
        }
        else {
          BRLog.error("Received ReactorMessageClient for a reactor part @ %d, %d, %d which has no attached reactor", te.xCoord, te.yCoord, te.zCoord);
View Full Code Here

TOP

Related Classes of erogenousbeef.bigreactors.common.multiblock.MultiblockReactor

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.