mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-19 19:59:34 +00:00
Stage 1 of Reactor Core refactoring
This commit is contained in:
1 parent
2221ed2a14
commit
8cc8cee2da
2 files changed
+339
-272
No files matched your search
+16
-27
@@ -1,8 +1,8 @@
|
||||
package com.brandon3055.draconicevolution.common.blocks.multiblock;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
@@ -19,7 +19,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
/**
|
||||
* Created by Brandon on 16/6/2015.
|
||||
*/
|
||||
public class ReactorCore extends BlockDE {
|
||||
public class ReactorCore extends BlockDE implements ITileEntityProvider {
|
||||
|
||||
public ReactorCore() {
|
||||
this.setCreativeTab(DraconicEvolution.tabBlocksItems);
|
||||
@@ -29,8 +29,8 @@ public class ReactorCore extends BlockDE {
|
||||
ModBlocks.register(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency");
|
||||
}
|
||||
@@ -56,40 +56,29 @@ public class ReactorCore extends BlockDE {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
public TileEntity createNewTileEntity(World world, int metadata) {
|
||||
return new TileReactorCore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore
|
||||
? (TileReactorCore) world.getTileEntity(x, y, z)
|
||||
: null;
|
||||
if (tile != null) tile.onPlaced();
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileReactorCore) {
|
||||
((TileReactorCore) tile).onPlaced();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int x, int y, int z) {
|
||||
|
||||
return AxisAlignedBB.getBoundingBox(0, 0, 0, 1, 1, 1); // super.getSelectedBoundingBoxFromPool(p_149633_1_, x,
|
||||
// y, z);
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
return AxisAlignedBB.getBoundingBox(0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_,
|
||||
float p_149727_7_, float p_149727_8_, float p_149727_9_) {
|
||||
// TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore)
|
||||
// world.getTileEntity(x, y, z) : null;
|
||||
// if (tile != null) return tile.onStructureRightClicked(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) {
|
||||
TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore
|
||||
? (TileReactorCore) world.getTileEntity(x, y, z)
|
||||
: null;
|
||||
if (tile != null) tile.onBroken();
|
||||
super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_);
|
||||
public void breakBlock(World world, int x, int y, int z, Block blockBroken, int metadata) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileReactorCore) {
|
||||
((TileReactorCore) tile).onBroken();
|
||||
}
|
||||
super.breakBlock(world, x, y, z, blockBroken, metadata);
|
||||
}
|
||||
}
|
||||
+323
-245
@@ -1,8 +1,6 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -10,6 +8,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -55,8 +54,7 @@ public class TileReactorCore extends TileObjectSync {
|
||||
public int reactorFuel = 0;
|
||||
public int convertedFuel = 0; // The amount of fuel that has converted
|
||||
public double conversionUnit = 0; // used to smooth out the conversion between int and floating point. When >= 1
|
||||
// minus one and convert one
|
||||
// int worth of fuel
|
||||
// minus one and convert one int worth of fuel
|
||||
|
||||
public double reactionTemperature = 20;
|
||||
public double maxReactTemperature = 10000;
|
||||
@@ -70,8 +68,6 @@ public class TileReactorCore extends TileObjectSync {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private ReactorSound reactorSound;
|
||||
|
||||
// #######################
|
||||
|
||||
// TODO DONT FORGET TO ACTUALLY FINISH ALL THESE THINGS!!!!
|
||||
// Check //-Bounding box
|
||||
// Check //-Custom player collision
|
||||
@@ -87,7 +83,7 @@ public class TileReactorCore extends TileObjectSync {
|
||||
// Check //-Redstone
|
||||
// -Add reactor and gates to tablet
|
||||
|
||||
public List<TileLocation> stabilizerLocations = new ArrayList<TileLocation>();
|
||||
public List<TileLocation> stabilizerLocations = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
@@ -98,11 +94,9 @@ public class TileReactorCore extends TileObjectSync {
|
||||
renderSpeed = (float) Math.min((reactionTemperature - 20) / 2000D, 1D);
|
||||
stabilizerRender = (float) Math.min(fieldCharge / (maxFieldCharge * 0.1D), 1D);
|
||||
renderRotation += renderSpeed;
|
||||
// LogHelper.info(renderSpeed +" "+(reactionTemperature));
|
||||
checkPlayerCollision();
|
||||
return;
|
||||
}
|
||||
// else injectEnergy(10000000);
|
||||
|
||||
switch (reactorState) {
|
||||
case STATE_OFFLINE:
|
||||
@@ -112,8 +106,6 @@ public class TileReactorCore extends TileObjectSync {
|
||||
startingTick();
|
||||
break;
|
||||
case STATE_ONLINE:
|
||||
runTick();
|
||||
break;
|
||||
case STATE_STOP:
|
||||
runTick();
|
||||
break;
|
||||
@@ -124,30 +116,31 @@ public class TileReactorCore extends TileObjectSync {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void updateSound() {
|
||||
if (reactorSound == null)
|
||||
if (reactorSound == null) {
|
||||
reactorSound = (ReactorSound) DraconicEvolution.proxy.playISound(new ReactorSound(this));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPlayerCollision() {
|
||||
EntityPlayer player = BrandonsCore.proxy.getClientPlayer();
|
||||
double distance = Utills
|
||||
.getDistanceAtoB(player.posX, player.posY, player.posZ, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
|
||||
if (distance < (getCoreDiameter() / 2) + 0.5) {
|
||||
double dMod = 1D - (distance / Math.max(0.1, (getCoreDiameter() / 2) + 0.5));
|
||||
double coreRadiusWithMargin = getCoreRadius() + 0.5;
|
||||
if (distance < coreRadiusWithMargin) {
|
||||
double distanceMod = 1D - (distance / Math.max(0.1, coreRadiusWithMargin));
|
||||
double offsetX = player.posX - xCoord + 0.5;
|
||||
double offsetY = player.posY - yCoord + 0.5;
|
||||
double offsetZ = player.posZ - zCoord + 0.5;
|
||||
double m = 1D * dMod;
|
||||
player.addVelocity(offsetX * m, offsetY * m, offsetZ * m);
|
||||
player.addVelocity(offsetX * distanceMod, offsetY * distanceMod, offsetZ * distanceMod);
|
||||
}
|
||||
}
|
||||
|
||||
private void offlineTick() {
|
||||
if (reactionTemperature > 20) reactionTemperature -= 0.5;
|
||||
if (fieldCharge > 0) fieldCharge -= maxFieldCharge * 0.0005;
|
||||
else if (fieldCharge < 0) fieldCharge = 0;
|
||||
if (energySaturation > 0) energySaturation -= maxEnergySaturation * 0.000001;
|
||||
else if (energySaturation < 0) energySaturation = 0;
|
||||
if (reactionTemperature > 20) {
|
||||
reactionTemperature -= 0.5;
|
||||
}
|
||||
fieldCharge = Math.max(0, fieldCharge - maxFieldCharge * 0.0005);
|
||||
energySaturation = (int) Math.max(0, energySaturation - maxEnergySaturation * 0.000001);
|
||||
}
|
||||
|
||||
private void startingTick() {
|
||||
@@ -155,8 +148,12 @@ public class TileReactorCore extends TileObjectSync {
|
||||
int totalFuel = reactorFuel + convertedFuel;
|
||||
maxFieldCharge = totalFuel * 96.45061728395062 * 100;
|
||||
maxEnergySaturation = (int) (totalFuel * 96.45061728395062 * 1000);
|
||||
if (energySaturation > maxEnergySaturation) energySaturation = maxEnergySaturation;
|
||||
if (fieldCharge > maxFieldCharge) fieldCharge = maxFieldCharge;
|
||||
if (energySaturation > maxEnergySaturation) {
|
||||
energySaturation = maxEnergySaturation;
|
||||
}
|
||||
if (fieldCharge > maxFieldCharge) {
|
||||
fieldCharge = maxFieldCharge;
|
||||
}
|
||||
startupInitialized = true;
|
||||
}
|
||||
}
|
||||
@@ -171,50 +168,47 @@ public class TileReactorCore extends TileObjectSync {
|
||||
|
||||
private void runTick() {
|
||||
// Inverted core saturation (if multiplied by 100 this creates infinite numbers which breaks the code)
|
||||
double saturation = ((double) energySaturation / (double) maxEnergySaturation);
|
||||
double saturationI = (1D - ((double) energySaturation / (double) maxEnergySaturation)) * 99D;
|
||||
double temp = ((reactionTemperature) / maxReactTemperature) * 50D;
|
||||
double saturation = (double) energySaturation / (double) maxEnergySaturation;
|
||||
double saturationI = (1D - saturation) * 99D;
|
||||
double temp = (reactionTemperature / maxReactTemperature) * 50D;
|
||||
// The conversion level. Ranges from -0.3 to 1.0
|
||||
double conversion = (((double) convertedFuel + conversionUnit)
|
||||
/ ((double) (convertedFuel + reactorFuel) - conversionUnit)
|
||||
* 1.3) - 0.3D;
|
||||
double conversion = (convertedFuel + conversionUnit) / (convertedFuel + reactorFuel - conversionUnit) * 1.3
|
||||
- 0.3D;
|
||||
|
||||
// Temperature Calculation
|
||||
double tempOffset = 444.7; // Adjusts where the temp falls to at 100% saturation
|
||||
final double tempOffset = 444.7; // Adjusts where the temp falls to at 100% saturation
|
||||
// The exponential temperature rise which increases as the core saturation goes down
|
||||
double tempRiseExpo = (saturationI * saturationI * saturationI) / (100 - saturationI) + tempOffset;
|
||||
double tempRiseExpo = Math.pow(saturationI, 3) / (100 - saturationI) + tempOffset;
|
||||
// This is used to add resistance as the temp rises because the hotter something gets the more energy it takes
|
||||
// to get it hotter
|
||||
double tempRiseResist = (temp * temp * temp * temp) / (100 - temp);
|
||||
double tempRiseResist = Math.pow(temp, 4) / (100 - temp);
|
||||
// This puts all the numbers together and gets the value to raise or lower the temp by this tick. This is
|
||||
// dealing with very big numbers so the result is divided by 10000
|
||||
double riseAmount = (tempRiseExpo - (tempRiseResist * (1D - conversion)) + conversion * 1000) / 10000;
|
||||
double riseAmount = (tempRiseExpo - tempRiseResist * (1D - conversion) + conversion * 1000) / 10000;
|
||||
if (reactorState == STATE_STOP) {
|
||||
if (reactionTemperature <= 2001) {
|
||||
reactorState = STATE_OFFLINE;
|
||||
startupInitialized = false;
|
||||
return;
|
||||
}
|
||||
if (energySaturation >= maxEnergySaturation * 0.99 && reactorFuel > 0)
|
||||
if (energySaturation >= maxEnergySaturation * 0.99 && reactorFuel > 0) {
|
||||
reactionTemperature -= 1D - conversion;
|
||||
else reactionTemperature += riseAmount * 10;
|
||||
} else reactionTemperature += riseAmount * 10;
|
||||
|
||||
// ======================
|
||||
} else {
|
||||
reactionTemperature += riseAmount * 10;
|
||||
}
|
||||
} else {
|
||||
reactionTemperature += riseAmount * 10;
|
||||
}
|
||||
|
||||
// Energy Calculation
|
||||
int baseMaxRFt = (int) ((maxEnergySaturation / 1000D) * ConfigHandler.reactorOutputMultiplier * 1.5D);
|
||||
int maxRFt = (int) (baseMaxRFt * (1D + (conversion * 2)));
|
||||
int maxRFt = (int) (baseMaxRFt * (1D + conversion * 2));
|
||||
generationRate = (1D - saturation) * maxRFt;
|
||||
energySaturation += generationRate;
|
||||
|
||||
// LogHelper.info((1D - saturation) * maxRFt);
|
||||
// ======================
|
||||
|
||||
// When temp < 1000 power drain is 0, when temp > 2000 power drain is 1, when temp > 8000 power drain increases
|
||||
// exponentially
|
||||
tempDrainFactor = reactionTemperature > 8000
|
||||
? 1 + ((reactionTemperature - 8000) * (reactionTemperature - 8000) * 0.0000025)
|
||||
tempDrainFactor = reactionTemperature > 8000 ? 1 + (Math.pow(reactionTemperature - 8000, 2) * 0.0000025)
|
||||
: reactionTemperature > 2000 ? 1 : reactionTemperature > 1000 ? (reactionTemperature - 1000) / 1000 : 0;
|
||||
// todo add to guiInfo
|
||||
// -temp drain factor
|
||||
@@ -223,31 +217,15 @@ public class TileReactorCore extends TileObjectSync {
|
||||
// -field drain
|
||||
|
||||
// Field Drain Calculation
|
||||
fieldDrain = (int) Math
|
||||
.min(tempDrainFactor * (1D - saturation) * (baseMaxRFt / 10.923556), (double) Integer.MAX_VALUE); // <(baseMaxRFt/make
|
||||
// smaller
|
||||
// to
|
||||
// increase
|
||||
// field
|
||||
// power
|
||||
// drain)
|
||||
// (baseMaxRFt/make smaller to increase field power drain)
|
||||
fieldDrain = (int) Math.min(tempDrainFactor * (1D - saturation) * (baseMaxRFt / 10.923556), Integer.MAX_VALUE);
|
||||
|
||||
double fieldNegPercent = 1D - (fieldCharge / maxFieldCharge);
|
||||
double fieldNegPercent = 1D - fieldCharge / maxFieldCharge;
|
||||
fieldInputRate = fieldDrain / fieldNegPercent;
|
||||
|
||||
// LogHelper.info(fieldDrain+" "+tempDrainFactor+" "+(1D-saturation)+" "+tempDrainFactor * (1D-saturation) *
|
||||
// (baseMaxRFt/10.923556));
|
||||
fieldCharge -= fieldDrain;
|
||||
// ======================
|
||||
|
||||
// Calculate Fuel Usage
|
||||
fuelUseRate = tempDrainFactor * (1D - saturation) * (0.001 * ConfigHandler.reactorFuelUsageMultiplier); // <Last
|
||||
// number
|
||||
// is
|
||||
// base
|
||||
// fuel
|
||||
// usage
|
||||
// rate
|
||||
fuelUseRate = tempDrainFactor * (1D - saturation) * (0.001 * ConfigHandler.reactorFuelUsageMultiplier);
|
||||
conversionUnit += fuelUseRate;
|
||||
if (conversionUnit >= 1 && reactorFuel > 0) {
|
||||
conversionUnit--;
|
||||
@@ -255,277 +233,320 @@ public class TileReactorCore extends TileObjectSync {
|
||||
convertedFuel++;
|
||||
}
|
||||
|
||||
// ====================
|
||||
|
||||
// Make BOOM!!!
|
||||
if ((fieldCharge <= 0) && !hasExploded) {
|
||||
if (fieldCharge <= 0 && !hasExploded) {
|
||||
hasExploded = true;
|
||||
goBoom();
|
||||
}
|
||||
// ===========
|
||||
}
|
||||
|
||||
private void goBoom() {
|
||||
if (!ConfigHandler.enableReactorBigBoom) {
|
||||
worldObj.createExplosion(null, xCoord, yCoord, zCoord, 5, true);
|
||||
} else {
|
||||
// float power = 10F + Math.min(10F, ((float) (convertedFuel + reactorFuel) / 10369F) * 10F);
|
||||
float power = 2F + (((float) (convertedFuel + reactorFuel) / 10369F) * 18F);
|
||||
if (ConfigHandler.enableReactorBigBoom) {
|
||||
float power = 2F + ((float) (convertedFuel + reactorFuel) / 10369F * 18F);
|
||||
ProcessHandler.addProcess(new ReactorExplosion(worldObj, xCoord, yCoord, zCoord, power));
|
||||
sendObjectToClient(
|
||||
References.INT_ID,
|
||||
100,
|
||||
(int) (power * 10F),
|
||||
new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 512));
|
||||
} else {
|
||||
worldObj.createExplosion(null, xCoord, yCoord, zCoord, 5, true);
|
||||
}
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public void validateStructure() {
|
||||
boolean updateRequired = false;
|
||||
// Check that all of the stabilizers are still valid
|
||||
Iterator<TileLocation> i = stabilizerLocations.iterator();
|
||||
List<TileReactorStabilizer> stabilizers = new ArrayList<TileReactorStabilizer>();
|
||||
while (i.hasNext()) {
|
||||
TileLocation location = i.next();
|
||||
if (!(location.getTileEntity(worldObj) instanceof TileReactorStabilizer)
|
||||
|| !((TileReactorStabilizer) location.getTileEntity(worldObj)).masterLocation
|
||||
.isThisLocation(xCoord, yCoord, zCoord)) {
|
||||
i.remove();
|
||||
updateRequired = true;
|
||||
} else stabilizers.add((TileReactorStabilizer) location.getTileEntity(worldObj));
|
||||
}
|
||||
private boolean isFacingToCore(int x, int y, int z, IReactorPart part) {
|
||||
ForgeDirection facing = part.getFacing();
|
||||
int offsetX = Integer.signum(xCoord - x);
|
||||
int offsetY = Integer.signum(yCoord - y);
|
||||
int offsetZ = Integer.signum(zCoord - z);
|
||||
return offsetX == facing.offsetX && offsetY == facing.offsetY && offsetZ == facing.offsetZ;
|
||||
}
|
||||
|
||||
// Check that there are 4 stabilizers in the correct configuration
|
||||
isStructureValid = false;
|
||||
List<TileReactorStabilizer> checkList = new ArrayList<TileReactorStabilizer>();
|
||||
for (TileReactorStabilizer stabilizer : stabilizers) {
|
||||
if (checkList.contains(stabilizer)) continue;
|
||||
|
||||
for (TileReactorStabilizer comp : stabilizers) {
|
||||
if (!(comp == stabilizer || checkList.contains(comp))
|
||||
&& ForgeDirection.getOrientation(comp.facingDirection)
|
||||
== ForgeDirection.getOrientation(stabilizer.facingDirection).getOpposite()) {
|
||||
checkList.add(comp);
|
||||
checkList.add(stabilizer);
|
||||
if (checkList.size() == 4) {
|
||||
isStructureValid = true;
|
||||
if (reactorState == STATE_INVALID) reactorState = STATE_OFFLINE;
|
||||
break;
|
||||
public void updateReactorParts(boolean shouldSetUp) {
|
||||
stabilizerLocations.clear();
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
for (int distance = 1; distance <= MAX_SLAVE_RANGE; distance++) {
|
||||
int targetX = xCoord + direction.offsetX * distance;
|
||||
int targetY = yCoord + direction.offsetY * distance;
|
||||
int targetZ = zCoord + direction.offsetZ * distance;
|
||||
TileEntity tile = worldObj.getTileEntity(targetX, targetY, targetZ);
|
||||
if (tile instanceof IReactorPart && isFacingToCore(targetX, targetY, targetZ, (IReactorPart) tile)) {
|
||||
if (shouldSetUp) {
|
||||
((IReactorPart) tile).setUp(new TileLocation(xCoord, yCoord, zCoord));
|
||||
}
|
||||
if (tile instanceof TileReactorStabilizer) {
|
||||
stabilizerLocations.add(new TileLocation(targetX, targetY, targetZ));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TileReactorStabilizer stabilizer : stabilizers) {
|
||||
if (Utills.getDistanceAtoB(stabilizer.xCoord, stabilizer.yCoord, stabilizer.zCoord, xCoord, yCoord, zCoord)
|
||||
< (getMaxCoreDiameter() / 2) + 1) {
|
||||
isStructureValid = false;
|
||||
break;
|
||||
public void validateStructure() {
|
||||
final double margin = 0.5D;
|
||||
final double coreRadiusSquared = Math.pow(getCoreRadius() + margin, 2);
|
||||
|
||||
boolean updateRequired = false;
|
||||
int stabilizersCount = 0;
|
||||
Iterator<TileLocation> iterator = stabilizerLocations.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TileLocation location = iterator.next();
|
||||
if (location.getDistanceSquared(xCoord, yCoord, zCoord) > coreRadiusSquared) {
|
||||
TileEntity tile = location.getTileEntity(worldObj);
|
||||
if (tile instanceof TileReactorStabilizer) {
|
||||
TileReactorStabilizer stabilizer = (TileReactorStabilizer) tile;
|
||||
if (stabilizer.masterLocation.isThisLocation(xCoord, yCoord, zCoord)) {
|
||||
stabilizersCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
iterator.remove();
|
||||
updateRequired = true;
|
||||
}
|
||||
|
||||
if (!isStructureValid) {
|
||||
isStructureValid = stabilizersCount == 4;
|
||||
if (isStructureValid) {
|
||||
if (reactorState == STATE_INVALID) {
|
||||
reactorState = STATE_OFFLINE;
|
||||
}
|
||||
} else {
|
||||
reactorState = STATE_INVALID;
|
||||
if (reactionTemperature >= 2000) {
|
||||
goBoom();
|
||||
}
|
||||
}
|
||||
|
||||
if (updateRequired) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
if (updateRequired) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlaced() {
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
boolean flag = false;
|
||||
for (int i = 1; i < MAX_SLAVE_RANGE && !flag; i++) {
|
||||
TileLocation location = new TileLocation(
|
||||
xCoord + direction.offsetX * i,
|
||||
yCoord + direction.offsetY * i,
|
||||
zCoord + direction.offsetZ * i);
|
||||
if (location.getTileEntity(worldObj) != null) {
|
||||
if (location.getTileEntity(worldObj) instanceof IReactorPart
|
||||
&& !((IReactorPart) location.getTileEntity(worldObj)).getMaster().initialized)
|
||||
((IReactorPart) location.getTileEntity(worldObj)).checkForMaster();
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReactorParts(true);
|
||||
validateStructure();
|
||||
}
|
||||
|
||||
public void onBroken() {
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
for (int i = 1; i < MAX_SLAVE_RANGE; i++) {
|
||||
TileLocation location = new TileLocation(
|
||||
xCoord + direction.offsetX * i,
|
||||
yCoord + direction.offsetY * i,
|
||||
zCoord + direction.offsetZ * i);
|
||||
if (location.getTileEntity(worldObj) instanceof IReactorPart
|
||||
&& ((IReactorPart) location.getTileEntity(worldObj)).getMaster()
|
||||
.compareTo(new TileLocation(xCoord, yCoord, zCoord)) == 0)
|
||||
((IReactorPart) location.getTileEntity(worldObj)).shutDown();
|
||||
for (int distance = 1; distance <= MAX_SLAVE_RANGE; distance++) {
|
||||
TileEntity tile = worldObj.getTileEntity(
|
||||
xCoord + direction.offsetX * distance,
|
||||
yCoord + direction.offsetY * distance,
|
||||
zCoord + direction.offsetZ * distance);
|
||||
if (tile instanceof IReactorPart) {
|
||||
IReactorPart part = (IReactorPart) tile;
|
||||
if (part.getMasterLocation().isThisLocation(xCoord, yCoord, zCoord)) {
|
||||
part.shutDown();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (reactionTemperature >= 2000) {
|
||||
goBoom();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onStructureRightClicked(EntityPlayer player) {
|
||||
if (!worldObj.isRemote)
|
||||
if (!worldObj.isRemote) {
|
||||
player.openGui(DraconicEvolution.instance, GuiHandler.GUIID_REACTOR, worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int injectEnergy(int RF) {
|
||||
int received = 0;
|
||||
public int injectEnergy(int energyToInject) {
|
||||
int energyInjected = 0;
|
||||
if (reactorState == STATE_START) {
|
||||
if (!startupInitialized) return 0;
|
||||
if (fieldCharge < (maxFieldCharge / 2)) {
|
||||
received = Math.min(RF, (int) (maxFieldCharge / 2) - (int) fieldCharge + 1);
|
||||
fieldCharge += received;
|
||||
if (fieldCharge > (maxFieldCharge / 2)) fieldCharge = (maxFieldCharge / 2);
|
||||
} else if (energySaturation < (maxEnergySaturation / 2)) {
|
||||
received = Math.min(RF, (maxEnergySaturation / 2) - energySaturation);
|
||||
energySaturation += received;
|
||||
if (!startupInitialized) {
|
||||
return 0;
|
||||
}
|
||||
if (fieldCharge < maxFieldCharge / 2) {
|
||||
energyInjected = Math.min(energyToInject, (int) (maxFieldCharge / 2) - (int) fieldCharge + 1);
|
||||
fieldCharge += energyInjected;
|
||||
if (fieldCharge > (maxFieldCharge / 2)) {
|
||||
fieldCharge = maxFieldCharge / 2;
|
||||
}
|
||||
} else if (energySaturation < maxEnergySaturation / 2) {
|
||||
energyInjected = Math.min(energyToInject, maxEnergySaturation / 2 - energySaturation);
|
||||
energySaturation += energyInjected;
|
||||
} else if (reactionTemperature < 2000) {
|
||||
received = RF;
|
||||
reactionTemperature += ((double) received / (1000D + (reactorFuel * 10)));
|
||||
if (reactionTemperature > 2000) reactionTemperature = 2000;
|
||||
energyInjected = energyToInject;
|
||||
reactionTemperature += (double) energyInjected / (1000D + reactorFuel * 10);
|
||||
if (reactionTemperature > 2000) {
|
||||
reactionTemperature = 2000;
|
||||
}
|
||||
}
|
||||
} else if (reactorState == STATE_ONLINE || reactorState == STATE_STOP) {
|
||||
fieldCharge += (RF * (1D - (fieldCharge / maxFieldCharge)));
|
||||
if (fieldCharge > maxFieldCharge) fieldCharge = maxFieldCharge;
|
||||
return RF;
|
||||
energyInjected = energyToInject;
|
||||
fieldCharge += energyInjected * (1D - fieldCharge / maxFieldCharge);
|
||||
if (fieldCharge > maxFieldCharge) {
|
||||
fieldCharge = maxFieldCharge;
|
||||
}
|
||||
}
|
||||
return received;
|
||||
return energyInjected;
|
||||
}
|
||||
|
||||
public boolean canStart() {
|
||||
validateStructure();
|
||||
return reactionTemperature >= 2000 && fieldCharge >= (maxFieldCharge / 2)
|
||||
&& energySaturation >= (maxEnergySaturation / 2)
|
||||
&& isStructureValid
|
||||
return isStructureValid && reactionTemperature >= 2000
|
||||
&& fieldCharge >= maxFieldCharge / 2
|
||||
&& energySaturation >= maxEnergySaturation / 2
|
||||
&& convertedFuel + reactorFuel + conversionUnit >= 144;
|
||||
}
|
||||
|
||||
public boolean canCharge() {
|
||||
validateStructure();
|
||||
return reactorState != STATE_ONLINE && isStructureValid && convertedFuel + reactorFuel + conversionUnit >= 144;
|
||||
return isStructureValid && reactorState != STATE_ONLINE && convertedFuel + reactorFuel + conversionUnit >= 144;
|
||||
}
|
||||
|
||||
public boolean canStop() {
|
||||
validateStructure();
|
||||
return reactorState != STATE_OFFLINE && isStructureValid;
|
||||
return isStructureValid && reactorState != STATE_OFFLINE;
|
||||
}
|
||||
|
||||
public void processButtonPress(int button) {
|
||||
if (button == 0 && canCharge()) reactorState = STATE_START;
|
||||
else if (button == 1 && canStart()) reactorState = STATE_ONLINE;
|
||||
else if (button == 2 && canStop()) reactorState = STATE_STOP;
|
||||
if (button == 0 && canCharge()) {
|
||||
reactorState = STATE_START;
|
||||
} else if (button == 1 && canStart()) {
|
||||
reactorState = STATE_ONLINE;
|
||||
} else if (button == 2 && canStop()) {
|
||||
reactorState = STATE_STOP;
|
||||
}
|
||||
}
|
||||
|
||||
public double getCoreRadius() {
|
||||
double volume = (double) (reactorFuel + convertedFuel) / 1296D;
|
||||
volume *= 1 + (reactionTemperature / maxReactTemperature) * 10D;
|
||||
return Math.cbrt(volume / (4D / 3D * Math.PI));
|
||||
}
|
||||
|
||||
public double getCoreDiameter() { // todo adjust so the core dose not expand before 1000>2000c
|
||||
// return (((1F + Math.sin((float)tick/50F)) / 2F) * 4) + 0.3;
|
||||
double volume = (double) (reactorFuel + convertedFuel) / 1296D;
|
||||
volume *= 1 + (reactionTemperature / maxReactTemperature) * 10D;
|
||||
return Math.cbrt(volume / (4 / 3 * Math.PI)) * 2;
|
||||
return getCoreRadius() * 2;
|
||||
}
|
||||
|
||||
public double getMaxCoreDiameter() {
|
||||
// return (((1F + Math.sin((float)tick/50F)) / 2F) * 4) + 0.3;
|
||||
double volume = (double) (reactorFuel + convertedFuel) / 1296D;
|
||||
volume *= 1 + 1 * 10D;
|
||||
return Math.cbrt(volume / (4 / 3 * Math.PI)) * 2;
|
||||
}
|
||||
|
||||
private boolean isStructureValidCach = false;
|
||||
private boolean startupInitializedCach = false;
|
||||
private int reactorStateCach = -1;
|
||||
private int reactorFuelCach = -1;
|
||||
private int convertedFuelCach = -1;
|
||||
private int energySaturationCach = -1;
|
||||
private int maxEnergySaturationCach = -1;
|
||||
private double reactionTemperatureCach = -1;
|
||||
private double maxReactTemperatureCach = -1;
|
||||
private double fieldChargeCach = -1;
|
||||
private double maxFieldChargeCach = -1;
|
||||
private boolean isStructureValidCache = false;
|
||||
private boolean startupInitializedCache = false;
|
||||
private int reactorStateCache = -1;
|
||||
private int reactorFuelCache = -1;
|
||||
private int convertedFuelCache = -1;
|
||||
private int energySaturationCache = -1;
|
||||
private int maxEnergySaturationCache = -1;
|
||||
private double reactionTemperatureCache = -1;
|
||||
private double maxReactTemperatureCache = -1;
|
||||
private double fieldChargeCache = -1;
|
||||
private double maxFieldChargeCache = -1;
|
||||
|
||||
private void detectAndSendChanges() {
|
||||
NetworkRegistry.TargetPoint tp = new NetworkRegistry.TargetPoint(
|
||||
NetworkRegistry.TargetPoint targetPoint = new NetworkRegistry.TargetPoint(
|
||||
worldObj.provider.dimensionId,
|
||||
xCoord,
|
||||
yCoord,
|
||||
zCoord,
|
||||
128);
|
||||
if (reactionTemperatureCach != reactionTemperature)
|
||||
reactionTemperatureCach = (Double) sendObjectToClient(References.DOUBLE_ID, 8, reactionTemperature, tp);
|
||||
if (tick % 10 != 0) return;
|
||||
if (isStructureValidCach != isStructureValid)
|
||||
isStructureValidCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 0, isStructureValid, tp);
|
||||
// if (isActiveCach != isActive) isActiveCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID,
|
||||
// 1, isActive, tp);
|
||||
if (startupInitializedCach != startupInitialized)
|
||||
startupInitializedCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 2, startupInitialized, tp);
|
||||
if (reactorStateCach != reactorState)
|
||||
reactorStateCach = (Integer) sendObjectToClient(References.INT_ID, 3, reactorState, tp);
|
||||
if (reactorFuelCach != reactorFuel)
|
||||
reactorFuelCach = (Integer) sendObjectToClient(References.INT_ID, 4, reactorFuel, tp);
|
||||
if (convertedFuelCach != convertedFuel)
|
||||
convertedFuelCach = (Integer) sendObjectToClient(References.INT_ID, 5, convertedFuel, tp);
|
||||
if (energySaturationCach != energySaturation)
|
||||
energySaturationCach = (Integer) sendObjectToClient(References.INT_ID, 6, energySaturation, tp);
|
||||
if (maxEnergySaturationCach != maxEnergySaturation)
|
||||
maxEnergySaturationCach = (Integer) sendObjectToClient(References.INT_ID, 7, maxEnergySaturation, tp);
|
||||
if (maxReactTemperatureCach != maxReactTemperature)
|
||||
maxReactTemperatureCach = (Double) sendObjectToClient(References.DOUBLE_ID, 9, maxReactTemperature, tp);
|
||||
if (fieldChargeCach != fieldCharge)
|
||||
fieldChargeCach = (Double) sendObjectToClient(References.DOUBLE_ID, 10, fieldCharge, tp);
|
||||
if (maxFieldChargeCach != maxFieldCharge)
|
||||
maxFieldChargeCach = (Double) sendObjectToClient(References.DOUBLE_ID, 11, maxFieldCharge, tp);
|
||||
if (reactionTemperatureCache != reactionTemperature) {
|
||||
reactionTemperatureCache = (double) sendObjectToClient(
|
||||
References.DOUBLE_ID,
|
||||
8,
|
||||
reactionTemperature,
|
||||
targetPoint);
|
||||
}
|
||||
if (tick % 10 != 0) {
|
||||
return;
|
||||
}
|
||||
if (isStructureValidCache != isStructureValid) {
|
||||
isStructureValidCache = (boolean) sendObjectToClient(
|
||||
References.BOOLEAN_ID,
|
||||
0,
|
||||
isStructureValid,
|
||||
targetPoint);
|
||||
}
|
||||
if (startupInitializedCache != startupInitialized) {
|
||||
startupInitializedCache = (boolean) sendObjectToClient(
|
||||
References.BOOLEAN_ID,
|
||||
2,
|
||||
startupInitialized,
|
||||
targetPoint);
|
||||
}
|
||||
if (reactorStateCache != reactorState) {
|
||||
reactorStateCache = (int) sendObjectToClient(References.INT_ID, 3, reactorState, targetPoint);
|
||||
}
|
||||
if (reactorFuelCache != reactorFuel) {
|
||||
reactorFuelCache = (int) sendObjectToClient(References.INT_ID, 4, reactorFuel, targetPoint);
|
||||
}
|
||||
if (convertedFuelCache != convertedFuel) {
|
||||
convertedFuelCache = (int) sendObjectToClient(References.INT_ID, 5, convertedFuel, targetPoint);
|
||||
}
|
||||
if (energySaturationCache != energySaturation) {
|
||||
energySaturationCache = (int) sendObjectToClient(References.INT_ID, 6, energySaturation, targetPoint);
|
||||
}
|
||||
if (maxEnergySaturationCache != maxEnergySaturation) {
|
||||
maxEnergySaturationCache = (int) sendObjectToClient(References.INT_ID, 7, maxEnergySaturation, targetPoint);
|
||||
}
|
||||
if (maxReactTemperatureCache != maxReactTemperature) {
|
||||
maxReactTemperatureCache = (double) sendObjectToClient(
|
||||
References.DOUBLE_ID,
|
||||
9,
|
||||
maxReactTemperature,
|
||||
targetPoint);
|
||||
}
|
||||
if (fieldChargeCache != fieldCharge) {
|
||||
fieldChargeCache = (double) sendObjectToClient(References.DOUBLE_ID, 10, fieldCharge, targetPoint);
|
||||
}
|
||||
if (maxFieldChargeCache != maxFieldCharge) {
|
||||
maxFieldChargeCache = (double) sendObjectToClient(References.DOUBLE_ID, 11, maxFieldCharge, targetPoint);
|
||||
}
|
||||
}
|
||||
|
||||
public int getComparatorOutput(int rsMode) {
|
||||
switch (rsMode) {
|
||||
public int getComparatorOutput(int redstoneMode) {
|
||||
switch (redstoneMode) {
|
||||
case IReactorPart.RMODE_TEMP:
|
||||
return toRSStrength(reactionTemperature, maxReactTemperature, rsMode);
|
||||
return toRedstoneStrength(reactionTemperature, maxReactTemperature, redstoneMode);
|
||||
case IReactorPart.RMODE_TEMP_INV:
|
||||
return 15 - toRSStrength(reactionTemperature, maxReactTemperature, rsMode);
|
||||
return 15 - toRedstoneStrength(reactionTemperature, maxReactTemperature, redstoneMode);
|
||||
case IReactorPart.RMODE_FIELD:
|
||||
return toRSStrength(fieldCharge, maxFieldCharge, rsMode);
|
||||
return toRedstoneStrength(fieldCharge, maxFieldCharge, redstoneMode);
|
||||
case IReactorPart.RMODE_FIELD_INV:
|
||||
return 15 - toRSStrength(fieldCharge, maxFieldCharge, rsMode);
|
||||
return 15 - toRedstoneStrength(fieldCharge, maxFieldCharge, redstoneMode);
|
||||
case IReactorPart.RMODE_SAT:
|
||||
return toRSStrength(energySaturation, maxEnergySaturation, rsMode);
|
||||
return toRedstoneStrength(energySaturation, maxEnergySaturation, redstoneMode);
|
||||
case IReactorPart.RMODE_SAT_INV:
|
||||
return 15 - toRSStrength(energySaturation, maxEnergySaturation, rsMode);
|
||||
return 15 - toRedstoneStrength(energySaturation, maxEnergySaturation, redstoneMode);
|
||||
case IReactorPart.RMODE_FUEL:
|
||||
return toRSStrength(convertedFuel + conversionUnit, reactorFuel - conversionUnit, rsMode);
|
||||
return toRedstoneStrength(convertedFuel + conversionUnit, reactorFuel - conversionUnit, redstoneMode);
|
||||
case IReactorPart.RMODE_FUEL_INV:
|
||||
return 15 - toRSStrength(convertedFuel + conversionUnit, reactorFuel - conversionUnit, rsMode);
|
||||
return 15 - toRedstoneStrength(
|
||||
convertedFuel + conversionUnit,
|
||||
reactorFuel - conversionUnit,
|
||||
redstoneMode);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int toRSStrength(double value, double maxValue, int mode) {
|
||||
if (maxValue == 0) return 0;
|
||||
double d = value / maxValue;
|
||||
int rs = (int) (d * 15D);
|
||||
private int toRedstoneStrength(double value, double maxValue, int mode) {
|
||||
if (maxValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
double proportion = value / maxValue;
|
||||
int redstoneStrength = (int) (proportion * 15D);
|
||||
switch (mode) {
|
||||
case IReactorPart.RMODE_FIELD:
|
||||
case IReactorPart.RMODE_FIELD_INV: {
|
||||
if (d < 0.1) rs = 0;
|
||||
if (proportion < 0.1) {
|
||||
redstoneStrength = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IReactorPart.RMODE_FUEL:
|
||||
case IReactorPart.RMODE_FUEL_INV: {
|
||||
if (d > 0.9) rs = 15;
|
||||
if (proportion > 0.9) {
|
||||
redstoneStrength = 15;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
return redstoneStrength;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -533,48 +554,47 @@ public class TileReactorCore extends TileObjectSync {
|
||||
public void receiveObjectFromServer(int index, Object object) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
isStructureValid = (Boolean) object;
|
||||
isStructureValid = (boolean) object;
|
||||
break;
|
||||
// case 1: isActive = (Boolean) object; break;
|
||||
case 2:
|
||||
startupInitialized = (Boolean) object;
|
||||
startupInitialized = (boolean) object;
|
||||
break;
|
||||
case 3:
|
||||
reactorState = (Integer) object;
|
||||
reactorState = (int) object;
|
||||
break;
|
||||
case 4:
|
||||
reactorFuel = (Integer) object;
|
||||
reactorFuel = (int) object;
|
||||
break;
|
||||
case 5:
|
||||
convertedFuel = (Integer) object;
|
||||
convertedFuel = (int) object;
|
||||
break;
|
||||
case 6:
|
||||
energySaturation = (Integer) object;
|
||||
energySaturation = (int) object;
|
||||
break;
|
||||
case 7:
|
||||
maxEnergySaturation = (Integer) object;
|
||||
maxEnergySaturation = (int) object;
|
||||
break;
|
||||
case 8:
|
||||
reactionTemperature = (Double) object;
|
||||
reactionTemperature = (double) object;
|
||||
break;
|
||||
case 9:
|
||||
maxReactTemperature = (Double) object;
|
||||
maxReactTemperature = (double) object;
|
||||
break;
|
||||
case 10:
|
||||
fieldCharge = (Double) object;
|
||||
fieldCharge = (double) object;
|
||||
break;
|
||||
case 11:
|
||||
maxFieldCharge = (Double) object;
|
||||
maxFieldCharge = (double) object;
|
||||
break;
|
||||
case 100:
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(
|
||||
new Particles.ReactorExplosionParticle(worldObj, xCoord, yCoord, zCoord, (Integer) object));
|
||||
new Particles.ReactorExplosionParticle(worldObj, xCoord, yCoord, zCoord, (int) object));
|
||||
}
|
||||
super.receiveObjectFromServer(index, object);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return INFINITE_EXTENT_AABB;
|
||||
}
|
||||
@@ -611,7 +631,6 @@ public class TileReactorCore extends TileObjectSync {
|
||||
compound.setByte("State", (byte) reactorState);
|
||||
compound.setBoolean("isStructureValid", isStructureValid);
|
||||
compound.setBoolean("startupInitialized", startupInitialized);
|
||||
// compound.setBoolean("isActive", isActive);
|
||||
compound.setInteger("energySaturation", energySaturation);
|
||||
compound.setInteger("maxEnergySaturation", maxEnergySaturation);
|
||||
compound.setInteger("reactorFuel", reactorFuel);
|
||||
@@ -626,7 +645,7 @@ public class TileReactorCore extends TileObjectSync {
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
|
||||
stabilizerLocations = new ArrayList<TileLocation>();
|
||||
stabilizerLocations = new ArrayList<>();
|
||||
if (compound.hasKey("Stabilizers")) {
|
||||
NBTTagList stabilizerList = compound.getTagList("Stabilizers", 10);
|
||||
for (int i = 0; i < stabilizerList.tagCount(); i++) {
|
||||
@@ -639,7 +658,6 @@ public class TileReactorCore extends TileObjectSync {
|
||||
reactorState = compound.getByte("State");
|
||||
isStructureValid = compound.getBoolean("isStructureValid");
|
||||
startupInitialized = compound.getBoolean("startupInitialized");
|
||||
// isActive = compound.getBoolean("isActive");
|
||||
energySaturation = compound.getInteger("energySaturation");
|
||||
maxEnergySaturation = compound.getInteger("maxEnergySaturation");
|
||||
reactorFuel = compound.getInteger("reactorFuel");
|
||||
@@ -649,4 +667,64 @@ public class TileReactorCore extends TileObjectSync {
|
||||
fieldCharge = compound.getDouble("fieldCharge");
|
||||
maxFieldCharge = compound.getDouble("maxFieldCharge");
|
||||
}
|
||||
|
||||
public Object[] callMethod(String methodName, Object... args) {
|
||||
if (args.length > 0) {
|
||||
throw new IllegalArgumentException("This method does not accept arguments");
|
||||
}
|
||||
|
||||
if (methodName.equals("getReactorInfo")) {
|
||||
Map<Object, Object> map = new HashMap<>();
|
||||
map.put("temperature", Utills.round(reactionTemperature, 100));
|
||||
map.put("fieldStrength", Utills.round(fieldCharge, 100));
|
||||
map.put("maxFieldStrength", Utills.round(maxFieldCharge, 100));
|
||||
map.put("energySaturation", energySaturation);
|
||||
map.put("maxEnergySaturation", maxEnergySaturation);
|
||||
map.put("fuelConversion", Utills.round(convertedFuel + conversionUnit, 1000));
|
||||
map.put("maxFuelConversion", reactorFuel + convertedFuel);
|
||||
map.put("generationRate", (int) generationRate);
|
||||
map.put("fieldDrainRate", fieldDrain);
|
||||
map.put("fuelConversionRate", (int) Math.round(fuelUseRate * 1000000D));
|
||||
switch (reactorState) {
|
||||
case STATE_OFFLINE:
|
||||
map.put("status", "offline");
|
||||
break;
|
||||
case STATE_START:
|
||||
map.put("status", canStart() ? "charged" : "charging");
|
||||
break;
|
||||
case STATE_ONLINE:
|
||||
map.put("status", "online");
|
||||
break;
|
||||
case STATE_STOP:
|
||||
map.put("status", "stopping");
|
||||
break;
|
||||
default:
|
||||
map.put("status", "invalid");
|
||||
break;
|
||||
}
|
||||
return new Object[] { map };
|
||||
}
|
||||
if (methodName.equals("chargeReactor")) {
|
||||
if (canCharge()) {
|
||||
reactorState = STATE_START;
|
||||
return new Object[] { true };
|
||||
}
|
||||
return new Object[] { false };
|
||||
}
|
||||
if (methodName.equals("activateReactor")) {
|
||||
if (canStart()) {
|
||||
reactorState = STATE_ONLINE;
|
||||
return new Object[] { true };
|
||||
}
|
||||
return new Object[] { false };
|
||||
}
|
||||
if (methodName.equals("stopReactor")) {
|
||||
if (canStop()) {
|
||||
reactorState = STATE_STOP;
|
||||
return new Object[] { true };
|
||||
}
|
||||
return new Object[] { false };
|
||||
}
|
||||
return new Object[] {};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user