Fixed stabilize LUA return values inconsistency
Added reactor protection for frozen chunks
This commit is contained in:
parent
240a8b0aaf
commit
949a0ef630
2 changed files with 25 additions and 18 deletions
|
@ -222,7 +222,11 @@ public class TileEntityEnanReactorCore extends TileEntityEnanReactorController {
|
|||
if (instabilityValues[reactorFace.indexStability] > instabilityTarget) {
|
||||
final TileEntityEnanReactorLaser tileEntityEnanReactorLaser = getLaser(reactorFace);
|
||||
if (tileEntityEnanReactorLaser != null) {
|
||||
tileEntityEnanReactorLaser.stabilize(stabilizerEnergy);
|
||||
if (tileEntityEnanReactorLaser.stabilize(stabilizerEnergy) == -stabilizerEnergy) {
|
||||
// chunk isn't updating properly => protect the reactor
|
||||
instabilityValues[reactorFace.indexStability] = instabilityTarget;
|
||||
hold = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,17 +154,21 @@ public class TileEntityEnanReactorLaser extends TileEntityAbstractLaser implemen
|
|||
}
|
||||
}
|
||||
|
||||
boolean stabilize(final int energy) {
|
||||
protected int stabilize(final int energy) {
|
||||
if (energy <= 0) {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (laserMedium_direction == null) {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
if (energyStabilizationRequest > 0) {
|
||||
WarpDrive.logger.warn("%s Stabilization already requested for %s",
|
||||
this, energy);
|
||||
return -energy;
|
||||
}
|
||||
|
||||
energyStabilizationRequest = energy;
|
||||
return true;
|
||||
return energy;
|
||||
}
|
||||
|
||||
private void doStabilize(final int energy) {
|
||||
|
@ -229,20 +233,19 @@ public class TileEntityEnanReactorLaser extends TileEntityAbstractLaser implemen
|
|||
|
||||
@Override
|
||||
public Object[] stabilize(final Object[] arguments) {
|
||||
if (arguments.length != 1) {
|
||||
return new Object[] { false, "Invalid number of arguments" };
|
||||
}
|
||||
final int energy;
|
||||
try {
|
||||
energy = Commons.toInt(arguments[0]);
|
||||
} catch (final Exception exception) {
|
||||
if (WarpDriveConfig.LOGGING_LUA) {
|
||||
WarpDrive.logger.error(String.format("%s LUA error on stabilize(): Integer expected for 1st argument %s",
|
||||
this, arguments[0]));
|
||||
if (arguments.length == 1) {
|
||||
final int energy;
|
||||
try {
|
||||
energy = Commons.toInt(arguments[0]);
|
||||
return new Object[] { stabilize(energy) };
|
||||
} catch (final Exception exception) {
|
||||
if (WarpDriveConfig.LOGGING_LUA) {
|
||||
WarpDrive.logger.error(String.format("%s LUA error on stabilize(): Integer expected for 1st argument %s",
|
||||
this, arguments[0]));
|
||||
}
|
||||
}
|
||||
return new Object[] { false, "Invalid integer" };
|
||||
}
|
||||
return new Object[] { stabilize(energy) };
|
||||
return new Object[] { energyStabilizationRequest };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue