Added laserMediumCount to LUA API
This commit is contained in:
parent
70cf61d797
commit
dce510cdfe
4 changed files with 30 additions and 15 deletions
|
@ -20,7 +20,8 @@ public abstract class TileEntityAbstractLaser extends TileEntityAbstractInterfac
|
|||
// direction of the laser medium stack
|
||||
protected ForgeDirection directionLaserMedium = ForgeDirection.UNKNOWN;
|
||||
protected ForgeDirection[] directionsValidLaserMedium = ForgeDirection.VALID_DIRECTIONS;
|
||||
protected int countMaxLaserMediums = 0;
|
||||
protected int laserMediumMaxCount = 0;
|
||||
protected int laserMediumCount = 0;
|
||||
|
||||
private final int updateInterval_ticks = 20 * WarpDriveConfig.SHIP_CONTROLLER_UPDATE_INTERVAL_SECONDS;
|
||||
private int updateTicks = updateInterval_ticks;
|
||||
|
@ -31,7 +32,8 @@ public abstract class TileEntityAbstractLaser extends TileEntityAbstractInterfac
|
|||
|
||||
addMethods(new String[] {
|
||||
"energy",
|
||||
"laserMediumDirection"
|
||||
"laserMediumDirection",
|
||||
"laserMediumCount"
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -54,15 +56,23 @@ public abstract class TileEntityAbstractLaser extends TileEntityAbstractInterfac
|
|||
if (updateTicks <= 0) {
|
||||
updateTicks = updateInterval_ticks;
|
||||
|
||||
updateLaserMediumDirection();
|
||||
updateLaserMediumStatus();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLaserMediumDirection() {
|
||||
private void updateLaserMediumStatus() {
|
||||
for(ForgeDirection direction : directionsValidLaserMedium) {
|
||||
TileEntity tileEntity = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
|
||||
TileEntity tileEntity = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
|
||||
if (tileEntity != null && tileEntity instanceof TileEntityLaserMedium) {
|
||||
directionLaserMedium = direction;
|
||||
laserMediumCount = 0;
|
||||
while(tileEntity != null && tileEntity instanceof TileEntityLaserMedium && laserMediumCount < laserMediumMaxCount) {
|
||||
laserMediumCount++;
|
||||
tileEntity = worldObj.getTileEntity(
|
||||
xCoord + laserMediumMaxCount * direction.offsetX,
|
||||
yCoord + laserMediumMaxCount * direction.offsetY,
|
||||
zCoord + laserMediumMaxCount * direction.offsetZ);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +97,7 @@ public abstract class TileEntityAbstractLaser extends TileEntityAbstractInterfac
|
|||
int totalEnergy = 0;
|
||||
int count = 1;
|
||||
List<TileEntityLaserMedium> laserMediums = new LinkedList();
|
||||
for (; count <= countMaxLaserMediums; count++) {
|
||||
for (; count <= laserMediumMaxCount; count++) {
|
||||
TileEntity tileEntity = worldObj.getTileEntity(
|
||||
xCoord + count * directionLaserMedium.offsetX,
|
||||
yCoord + count * directionLaserMedium.offsetY,
|
||||
|
@ -142,7 +152,7 @@ public abstract class TileEntityAbstractLaser extends TileEntityAbstractInterfac
|
|||
int energyStoredMax = 0;
|
||||
int count = 1;
|
||||
List<TileEntityLaserMedium> laserMediums = new LinkedList();
|
||||
for (; count <= countMaxLaserMediums; count++) {
|
||||
for (; count <= laserMediumMaxCount; count++) {
|
||||
TileEntity tileEntity = worldObj.getTileEntity(
|
||||
xCoord + count * directionLaserMedium.offsetX,
|
||||
yCoord + count * directionLaserMedium.offsetY,
|
||||
|
@ -162,6 +172,9 @@ public abstract class TileEntityAbstractLaser extends TileEntityAbstractInterfac
|
|||
return new Object[] { directionLaserMedium.name(), directionLaserMedium.offsetX, directionLaserMedium.offsetY, directionLaserMedium.offsetZ };
|
||||
}
|
||||
|
||||
protected Object[] laserMediumCount() {
|
||||
return new Object[] { laserMediumCount };
|
||||
}
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
|
@ -185,6 +198,8 @@ public abstract class TileEntityAbstractLaser extends TileEntityAbstractInterfac
|
|||
return energy();
|
||||
} else if (methodName.equals("laserMediumDirection")) {
|
||||
return laserMediumDirection();
|
||||
} else if (methodName.equals("laserMediumCount")) {
|
||||
return laserMediumCount();
|
||||
}
|
||||
|
||||
return super.callMethod(computer, context, method, arguments);
|
||||
|
|
|
@ -77,7 +77,7 @@ public class TileEntityLaser extends TileEntityAbstractLaser {
|
|||
"getScanResult",
|
||||
"videoChannel"
|
||||
});
|
||||
countMaxLaserMediums = WarpDriveConfig.LASER_CANNON_MAX_MEDIUMS_COUNT;
|
||||
laserMediumMaxCount = WarpDriveConfig.LASER_CANNON_MAX_MEDIUMS_COUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
|
|||
public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
||||
private final boolean canSilktouch = (WarpDriveConfig.MINING_LASER_SILKTOUCH_DEUTERIUM_L <= 0 || FluidRegistry.isFluidRegistered("deuterium"));
|
||||
|
||||
private boolean isMining() {
|
||||
private boolean isActive() {
|
||||
return currentState != STATE_IDLE;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
|||
"silktouch"
|
||||
});
|
||||
CC_scripts = Arrays.asList("mine", "stop");
|
||||
countMaxLaserMediums = WarpDriveConfig.MINING_LASER_MAX_MEDIUMS_COUNT;
|
||||
laserMediumMaxCount = WarpDriveConfig.MINING_LASER_MAX_MEDIUMS_COUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -375,7 +375,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
|||
|
||||
// Common OC/CC methods
|
||||
private Object[] start(Object[] arguments) {
|
||||
if (isMining()) {
|
||||
if (isActive()) {
|
||||
return new Object[] { false, "Already started" };
|
||||
}
|
||||
|
||||
|
@ -390,13 +390,13 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
|||
int energy = getEnergyStored();
|
||||
String status = getStatus();
|
||||
Integer retValuablesInLayer, retValuablesMined;
|
||||
if (isMining()) {
|
||||
if (isActive()) {
|
||||
retValuablesInLayer = valuablesInLayer.size();
|
||||
retValuablesMined = valuableIndex;
|
||||
|
||||
return new Object[] { status, isMining(), energy, currentLayer, retValuablesMined, retValuablesInLayer };
|
||||
return new Object[] { status, isActive(), energy, currentLayer, retValuablesMined, retValuablesInLayer };
|
||||
}
|
||||
return new Object[] { status, isMining(), energy, currentLayer, 0, 0 };
|
||||
return new Object[] { status, isActive(), energy, currentLayer, 0, 0 };
|
||||
}
|
||||
|
||||
private Object[] onlyOres(Object[] arguments) {
|
||||
|
|
|
@ -32,7 +32,7 @@ public class TileEntityEnanReactorLaser extends TileEntityAbstractLaser {
|
|||
"stabilize"
|
||||
});
|
||||
peripheralName = "warpdriveEnanReactorLaser";
|
||||
countMaxLaserMediums = 1;
|
||||
laserMediumMaxCount = 1;
|
||||
directionsValidLaserMedium = new ForgeDirection[] { ForgeDirection.UP, ForgeDirection.DOWN };
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue