Improved logs for OC LUA calls
- added method name - extended to support all callback methods - refactored videoChannel() and beamFrequency()
This commit is contained in:
parent
714b69c5da
commit
a6d423cf59
26 changed files with 143 additions and 69 deletions
|
@ -58,6 +58,7 @@ import java.lang.management.ManagementFactory;
|
|||
import java.lang.management.ThreadInfo;
|
||||
import java.lang.management.ThreadMXBean;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -85,6 +86,18 @@ public class Commons {
|
|||
EnumBlockRenderType.MODEL
|
||||
);
|
||||
|
||||
private static Method methodThrowable_getStackTraceElement;
|
||||
|
||||
static {
|
||||
try {
|
||||
methodThrowable_getStackTraceElement = Throwable.class.getDeclaredMethod("getStackTraceElement",
|
||||
int.class);
|
||||
methodThrowable_getStackTraceElement.setAccessible(true);
|
||||
} catch (final Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions") // IDE says "§" == CHAR_FORMATTING, execution says otherwise
|
||||
public static String updateEscapeCodes(final String message) {
|
||||
return message
|
||||
|
@ -625,6 +638,17 @@ public class Commons {
|
|||
WarpDrive.logger.error(stringBuilder.toString());
|
||||
}
|
||||
|
||||
public static String getMethodName(final int depth) {
|
||||
try {
|
||||
final StackTraceElement stackTraceElement = (StackTraceElement) methodThrowable_getStackTraceElement.invoke(
|
||||
new Throwable(), depth + 1);
|
||||
return stackTraceElement.getMethodName();
|
||||
} catch (final Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return "-?-";
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeNBTToFile(final String fileName, final NBTTagCompound tagCompound) {
|
||||
if (WarpDrive.isDev) {
|
||||
WarpDrive.logger.info(String.format("writeNBTToFile %s",
|
||||
|
|
|
@ -146,10 +146,11 @@ public class TileEntitySecurityStation extends TileEntityAbstractMachine impleme
|
|||
return new Object[] { list.toString(), players.toArray() };
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getAttachedPlayers(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getAttachedPlayers();
|
||||
}
|
||||
|
||||
|
|
|
@ -184,10 +184,11 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractMachine
|
|||
return new Object[] { energy_getEnergyStored(), energy_getMaxStorage() };
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] energy(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return energy();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,11 @@ public abstract class TileEntityAbstractEnergyConsumer extends TileEntityAbstrac
|
|||
@Override
|
||||
public abstract Object[] getEnergyRequired();
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getEnergyRequired(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getEnergyRequired();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public abstract class TileEntityAbstractEnergyCoreOrController extends TileEntit
|
|||
// Common OC/CC methods
|
||||
// (none)
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
// (none)
|
||||
|
||||
// ComputerCraft IPeripheral methods
|
||||
|
|
|
@ -9,6 +9,7 @@ import cr0s.warpdrive.data.EnumComponentType;
|
|||
import cr0s.warpdrive.data.Vector3;
|
||||
import cr0s.warpdrive.data.VectorI;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
@ -254,8 +255,8 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
|
|||
}
|
||||
index++;
|
||||
}
|
||||
final String methodName = "-?-";
|
||||
if (WarpDriveConfig.LOGGING_LUA) {
|
||||
final String methodName = Commons.getMethodName(1);
|
||||
WarpDrive.logger.info(String.format("LUA call %s to %s(%s).%s(%s)",
|
||||
Commons.format(world, pos),
|
||||
peripheralName, context, methodName, Commons.format(arguments)));
|
||||
|
@ -555,30 +556,35 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] isInterfaced(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return isInterfaced();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getLocalPosition(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getLocalPosition();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getUpgrades(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getUpgrades();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getTier(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getTier();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getVersion(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getVersion();
|
||||
}
|
||||
|
||||
|
|
|
@ -214,18 +214,21 @@ public abstract class TileEntityAbstractLaser extends TileEntityAbstractMachine
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] energy(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return energy();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] laserMediumDirection(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return laserMediumDirection();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] laserMediumCount(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return laserMediumCount();
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ public abstract class TileEntityAbstractMachine extends TileEntityAbstractInterf
|
|||
return new Object[] { true, "ok" };
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] name(final Context context, final Arguments arguments) {
|
||||
|
@ -157,6 +157,7 @@ public abstract class TileEntityAbstractMachine extends TileEntityAbstractInterf
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] isAssemblyValid(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return isAssemblyValid();
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading {
|
|||
return new Object[] { calculateEnergyRequired() };
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] bounds(final Context context, final Arguments arguments) {
|
||||
|
|
|
@ -740,7 +740,15 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
|
|||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// Common OC/CC methods
|
||||
public Object[] beamFrequency(final Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
setBeamFrequency(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { getBeamFrequency() };
|
||||
}
|
||||
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] emitBeam(final Context context, final Arguments arguments) {
|
||||
|
@ -750,15 +758,13 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] beamFrequency(final Context context, final Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setBeamFrequency(arguments.checkInteger(0));
|
||||
}
|
||||
return new Integer[] { beamFrequency };
|
||||
return beamFrequency(OC_convertArgumentsAndLogCall(context, arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getScanResult(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getScanResult();
|
||||
}
|
||||
|
||||
|
@ -813,15 +819,12 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
|
|||
final String methodName = CC_getMethodNameAndLogCall(method, arguments);
|
||||
|
||||
switch (methodName) {
|
||||
case "beamFrequency":
|
||||
return beamFrequency(arguments);
|
||||
|
||||
case "emitBeam": // emitBeam(yaw, pitch) or emitBeam(deltaX, deltaY, deltaZ)
|
||||
return emitBeam(arguments);
|
||||
|
||||
case "beamFrequency":
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setBeamFrequency(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { beamFrequency };
|
||||
|
||||
case "getScanResult":
|
||||
return getScanResult();
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ public class TileEntityAcceleratorControlPoint extends TileEntityAbstractMachine
|
|||
return new Object[] { status, isEnabled, controlChannel };
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] controlChannel(final Context context, final Arguments arguments) {
|
||||
|
@ -170,6 +170,7 @@ public class TileEntityAcceleratorControlPoint extends TileEntityAbstractMachine
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] state(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return state();
|
||||
}
|
||||
|
||||
|
|
|
@ -632,16 +632,18 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
|
|||
readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] scan(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return scan();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] filename(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return filename();
|
||||
}
|
||||
|
||||
|
@ -654,6 +656,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] state(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return state();
|
||||
}
|
||||
|
||||
|
|
|
@ -610,10 +610,11 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
currentState = tagCompound.getInteger("currentState");
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] start(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return start();
|
||||
}
|
||||
|
||||
|
@ -621,6 +622,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] stop(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
stop();
|
||||
return null;
|
||||
}
|
||||
|
@ -628,6 +630,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] state(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return state();
|
||||
}
|
||||
|
||||
|
|
|
@ -417,10 +417,11 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] start(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return start();
|
||||
}
|
||||
|
||||
|
@ -428,6 +429,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] stop(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
stop();
|
||||
return null;
|
||||
}
|
||||
|
@ -435,6 +437,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] state(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return state();
|
||||
}
|
||||
|
||||
|
|
|
@ -135,14 +135,19 @@ public class TileEntityCamera extends TileEntityAbstractMachine implements IVide
|
|||
readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// Common OC/CC methods
|
||||
public Object[] videoChannel(final Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
setVideoChannel(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { getVideoChannel() };
|
||||
}
|
||||
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] videoChannel(final Context context, final Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setVideoChannel(arguments.checkInteger(0));
|
||||
}
|
||||
return new Integer[] { videoChannel };
|
||||
return videoChannel(OC_convertArgumentsAndLogCall(context, arguments));
|
||||
}
|
||||
|
||||
// ComputerCraft IPeripheral methods
|
||||
|
@ -153,10 +158,7 @@ public class TileEntityCamera extends TileEntityAbstractMachine implements IVide
|
|||
|
||||
switch (methodName) {
|
||||
case "videoChannel":
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setVideoChannel(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { videoChannel };
|
||||
return videoChannel(arguments);
|
||||
}
|
||||
|
||||
return super.callMethod(computer, context, method, arguments);
|
||||
|
|
|
@ -469,7 +469,7 @@ public class TileEntityCloakingCore extends TileEntityAbstractEnergyConsumer {
|
|||
return super.isAssemblyValid();
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
// (none)
|
||||
|
||||
// ComputerCraft IPeripheral methods
|
||||
|
|
|
@ -96,14 +96,19 @@ public class TileEntityMonitor extends TileEntityAbstractMachine implements IVid
|
|||
readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// Common OC/CC methods
|
||||
public Object[] videoChannel(final Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
setVideoChannel(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { getVideoChannel() };
|
||||
}
|
||||
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] videoChannel(final Context context, final Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setVideoChannel(arguments.checkInteger(0));
|
||||
}
|
||||
return new Integer[] { videoChannel };
|
||||
return videoChannel(OC_convertArgumentsAndLogCall(context, arguments));
|
||||
}
|
||||
|
||||
// ComputerCraft IPeripheral methods
|
||||
|
@ -114,10 +119,7 @@ public class TileEntityMonitor extends TileEntityAbstractMachine implements IVid
|
|||
|
||||
switch (methodName) {
|
||||
case "videoChannel":
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setVideoChannel(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { videoChannel };
|
||||
return videoChannel(arguments);
|
||||
}
|
||||
|
||||
return super.callMethod(computer, context, method, arguments);
|
||||
|
|
|
@ -225,10 +225,11 @@ public class TileEntityRadar extends TileEntityAbstractEnergyConsumer {
|
|||
return new Object[] { false, COMPUTER_ERROR_TAG, null, 0, 0, 0 };
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getGlobalPosition(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getGlobalPosition();
|
||||
}
|
||||
|
||||
|
@ -247,18 +248,21 @@ public class TileEntityRadar extends TileEntityAbstractEnergyConsumer {
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] start(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return start();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getResults(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getResults();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getResultsCount(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getResultsCount();
|
||||
}
|
||||
|
||||
|
|
|
@ -156,10 +156,11 @@ public class TileEntityEnanReactorController extends TileEntityAbstractEnergyCor
|
|||
return tileEntityEnanReactorCore.energy();
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getInstabilities(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getInstabilities();
|
||||
}
|
||||
|
||||
|
@ -184,6 +185,7 @@ public class TileEntityEnanReactorController extends TileEntityAbstractEnergyCor
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] state(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return state();
|
||||
}
|
||||
|
||||
|
|
|
@ -264,6 +264,7 @@ public class TileEntityEnanReactorLaser extends TileEntityAbstractLaser implemen
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] side(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return side();
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ public abstract class TileEntityAbstractForceField extends TileEntityAbstractEne
|
|||
return new Object[] { beamFrequency };
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] beamFrequency(final Context context, final Arguments arguments) {
|
||||
|
|
|
@ -1239,10 +1239,11 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
return computer_getOrSetVector3(this::getTranslation, this::setTranslation, arguments);
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] state(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return state();
|
||||
}
|
||||
|
||||
|
|
|
@ -370,22 +370,25 @@ public abstract class TileEntityAbstractShipController extends TileEntityAbstrac
|
|||
return new Object[] { nameTarget };
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getOrientation(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getOrientation();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] isInSpace(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return isInSpace();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] isInHyperspace(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return isInHyperspace();
|
||||
}
|
||||
|
||||
|
@ -410,12 +413,14 @@ public abstract class TileEntityAbstractShipController extends TileEntityAbstrac
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getShipSize(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getShipSize();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getMaxJumpDistance(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getMaxJumpDistance();
|
||||
}
|
||||
|
||||
|
|
|
@ -249,10 +249,11 @@ public class TileEntityLift extends TileEntityAbstractEnergyConsumer implements
|
|||
return new Object[] { status, isActive, energy, isValid, isEnabled, computerMode.getName() };
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] mode(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return mode(
|
||||
new Object[] {
|
||||
arguments.checkString(0)
|
||||
|
@ -263,6 +264,7 @@ public class TileEntityLift extends TileEntityAbstractEnergyConsumer implements
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] state(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return state();
|
||||
}
|
||||
|
||||
|
|
|
@ -1551,6 +1551,14 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyConsumer
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsEnabled(final boolean isEnabled) {
|
||||
super.setIsEnabled(isEnabled);
|
||||
if (isEnabled) {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
// Common OC/CC methods
|
||||
@Override
|
||||
public String[] name(final Object[] arguments) {
|
||||
|
@ -1562,12 +1570,11 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyConsumer
|
|||
return new String[] { name, uuid == null ? null : uuid.toString() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsEnabled(final boolean isEnabled) {
|
||||
super.setIsEnabled(isEnabled);
|
||||
if (isEnabled) {
|
||||
markDirty();
|
||||
public Object[] beamFrequency(final Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
setBeamFrequency(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { getBeamFrequency() };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1671,15 +1678,13 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyConsumer
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] beamFrequency(final Context context, final Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setBeamFrequency(arguments.checkInteger(0));
|
||||
}
|
||||
return new Integer[] { beamFrequency };
|
||||
return beamFrequency(OC_convertArgumentsAndLogCall(context, arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] state(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return state();
|
||||
}
|
||||
|
||||
|
@ -1704,6 +1709,7 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyConsumer
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getLockStrength(final Context context, final Arguments arguments) {
|
||||
OC_convertArgumentsAndLogCall(context, arguments);
|
||||
return getLockStrength();
|
||||
}
|
||||
|
||||
|
@ -1721,10 +1727,7 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyConsumer
|
|||
|
||||
switch (methodName) {
|
||||
case "beamFrequency":
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setBeamFrequency(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { beamFrequency };
|
||||
return beamFrequency(arguments);
|
||||
|
||||
case "state":
|
||||
return state();
|
||||
|
|
|
@ -125,14 +125,19 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan
|
|||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
// OpenComputer callback methods
|
||||
// Common OC/CC methods
|
||||
public Object[] videoChannel(final Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
setVideoChannel(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { getVideoChannel() };
|
||||
}
|
||||
|
||||
// OpenComputers callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] videoChannel(final Context context, final Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setVideoChannel(arguments.checkInteger(0));
|
||||
}
|
||||
return new Integer[] { videoChannel };
|
||||
return videoChannel(OC_convertArgumentsAndLogCall(context, arguments));
|
||||
}
|
||||
|
||||
// ComputerCraft IPeripheral methods
|
||||
|
@ -143,10 +148,7 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan
|
|||
|
||||
switch (methodName) {
|
||||
case "videoChannel":
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setVideoChannel(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { videoChannel };
|
||||
return videoChannel(arguments);
|
||||
}
|
||||
|
||||
return super.callMethod(computer, context, method, arguments);
|
||||
|
|
Loading…
Add table
Reference in a new issue