Fixed OpenComputer API so it's actually exposed
This commit is contained in:
parent
4e5bd4cc00
commit
16df2df5d9
11 changed files with 55 additions and 48 deletions
|
@ -93,7 +93,7 @@ public class TileEntityCamera extends WarpInterfacedTE {
|
|||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] freq(Context context, Arguments arguments) {
|
||||
public Object[] freq(Context context, Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setFrequency(arguments.checkInteger(0));
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class TileEntityCloakingDeviceCore extends WarpEnergyTE {
|
|||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Reset sound timer
|
||||
soundTicks++;
|
||||
if (soundTicks >= 40) {
|
||||
|
@ -338,7 +338,7 @@ public class TileEntityCloakingDeviceCore extends WarpEnergyTE {
|
|||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] tier(Context context, Arguments arguments) {
|
||||
public Object[] tier(Context context, Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
if (arguments.checkInteger(0) == 2) {
|
||||
tier = 2;
|
||||
|
@ -351,13 +351,13 @@ public class TileEntityCloakingDeviceCore extends WarpEnergyTE {
|
|||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] isAssemblyValid(Context context, Arguments arguments) {
|
||||
public Object[] isAssemblyValid(Context context, Arguments arguments) {
|
||||
return new Object[] { (boolean)validateAssembly() };
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] enable(Context context, Arguments arguments) {
|
||||
public Object[] enable(Context context, Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
isEnabled = arguments.checkBoolean(0);
|
||||
}
|
||||
|
|
|
@ -495,19 +495,19 @@ public class TileEntityLaser extends WarpInterfacedTE {
|
|||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] emitBeam(Context context, Arguments arguments) {
|
||||
public Object[] emitBeam(Context context, Arguments arguments) {
|
||||
return emitBeam(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] pos(Context context, Arguments arguments) {
|
||||
public Object[] pos(Context context, Arguments arguments) {
|
||||
return new Integer[] { xCoord, yCoord, zCoord };
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] freq(Context context, Arguments arguments) {
|
||||
public Object[] freq(Context context, Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setBeamFrequency(arguments.checkInteger(0));
|
||||
}
|
||||
|
@ -516,20 +516,20 @@ public class TileEntityLaser extends WarpInterfacedTE {
|
|||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] getFirstHit(Context context, Arguments arguments) {
|
||||
public Object[] getFirstHit(Context context, Arguments arguments) {
|
||||
return getFirstHit();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] getBoosterDXDZ(Context context, Arguments arguments) {
|
||||
public Object[] getBoosterDXDZ(Context context, Arguments arguments) {
|
||||
findFirstBooster();
|
||||
return new Integer[] { dx, dz };
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] CamFreq(Context context, Arguments arguments) {
|
||||
public Object[] CamFreq(Context context, Arguments arguments) {
|
||||
if (isWithCamera()) {
|
||||
if (arguments.count() == 1) {
|
||||
setCameraFrequency(arguments.checkInteger(0));
|
||||
|
|
|
@ -203,13 +203,13 @@ public class TileEntityLift extends WarpEnergyTE {
|
|||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] mode(Context context, Arguments arguments) {
|
||||
public Object[] mode(Context context, Arguments arguments) {
|
||||
return mode(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] active(Context context, Arguments arguments) {
|
||||
public Object[] active(Context context, Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
computerEnabled = arguments.checkBoolean(0);
|
||||
}
|
||||
|
|
|
@ -563,38 +563,38 @@ public class TileEntityMiningLaser extends WarpInterfacedTE {
|
|||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] mine(Context context, Arguments arguments) {
|
||||
public Object[] mine(Context context, Arguments arguments) {
|
||||
return mine(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] stop(Context context, Arguments arguments) {
|
||||
public Object[] stop(Context context, Arguments arguments) {
|
||||
stop();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] isMining(Context context, Arguments arguments) {
|
||||
public Object[] isMining(Context context, Arguments arguments) {
|
||||
return new Boolean[] { isMining() };
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] quarry(Context context, Arguments arguments) {
|
||||
public Object[] quarry(Context context, Arguments arguments) {
|
||||
return quarry(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] state(Context context, Arguments arguments) {
|
||||
public Object[] state(Context context, Arguments arguments) {
|
||||
return state(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] offset(Context context, Arguments arguments) {
|
||||
public Object[] offset(Context context, Arguments arguments) {
|
||||
return offset(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class TileEntityMonitor extends WarpInterfacedTE {
|
|||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] freq(Context context, Arguments arguments) {
|
||||
public Object[] freq(Context context, Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setFrequency(arguments.checkInteger(0));
|
||||
}
|
||||
|
|
|
@ -419,56 +419,56 @@ public class TileEntityProtocol extends WarpInterfacedTE {
|
|||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] dim_positive(Context context, Arguments arguments) {
|
||||
public Object[] dim_positive(Context context, Arguments arguments) {
|
||||
return dim_positive(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] dim_negative(Context context, Arguments arguments) {
|
||||
public Object[] dim_negative(Context context, Arguments arguments) {
|
||||
return dim_negative(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] mode(Context context, Arguments arguments) {
|
||||
public Object[] mode(Context context, Arguments arguments) {
|
||||
return mode(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] distance(Context context, Arguments arguments) {
|
||||
public Object[] distance(Context context, Arguments arguments) {
|
||||
return distance(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] direction(Context context, Arguments arguments) {
|
||||
public Object[] direction(Context context, Arguments arguments) {
|
||||
return direction(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] getAttachedPlayers(Context context, Arguments arguments) {
|
||||
public Object[] getAttachedPlayers(Context context, Arguments arguments) {
|
||||
return getAttachedPlayers(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] summon(Context context, Arguments arguments) {
|
||||
public Object[] summon(Context context, Arguments arguments) {
|
||||
return summon(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] summon_all(Context context, Arguments arguments) {
|
||||
public Object[] summon_all(Context context, Arguments arguments) {
|
||||
setSummonAllFlag(true);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] pos(Context context, Arguments arguments) {
|
||||
public Object[] pos(Context context, Arguments arguments) {
|
||||
if (core == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ public class TileEntityProtocol extends WarpInterfacedTE {
|
|||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] getEnergyLevel(Context context, Arguments arguments) {
|
||||
public Object[] getEnergyLevel(Context context, Arguments arguments) {
|
||||
if (core == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ public class TileEntityProtocol extends WarpInterfacedTE {
|
|||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] getEnergyRequired(Context context, Arguments arguments) {
|
||||
public Object[] getEnergyRequired(Context context, Arguments arguments) {
|
||||
if (core == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -498,26 +498,26 @@ public class TileEntityProtocol extends WarpInterfacedTE {
|
|||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] jump(Context context, Arguments arguments) {
|
||||
public Object[] jump(Context context, Arguments arguments) {
|
||||
doJump();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] getShipSize(Context context, Arguments arguments) {
|
||||
public Object[] getShipSize(Context context, Arguments arguments) {
|
||||
return getShipSize(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] beaconFrequency(Context context, Arguments arguments) {
|
||||
public Object[] beaconFrequency(Context context, Arguments arguments) {
|
||||
return beaconFrequency(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] getOrientation(Context context, Arguments arguments) {
|
||||
public Object[] getOrientation(Context context, Arguments arguments) {
|
||||
if (core != null) {
|
||||
return new Object[] { core.dx, 0, core.dz };
|
||||
}
|
||||
|
@ -526,31 +526,31 @@ public class TileEntityProtocol extends WarpInterfacedTE {
|
|||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] coreFrequency(Context context, Arguments arguments) {
|
||||
public Object[] coreFrequency(Context context, Arguments arguments) {
|
||||
return coreFrequency(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] isInSpace(Context context, Arguments arguments) {
|
||||
public Object[] isInSpace(Context context, Arguments arguments) {
|
||||
return new Boolean[] { worldObj.provider.dimensionId == WarpDriveConfig.G_SPACE_DIMENSION_ID };
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] isInHyperspace(Context context, Arguments arguments) {
|
||||
public Object[] isInHyperspace(Context context, Arguments arguments) {
|
||||
return new Boolean[] { worldObj.provider.dimensionId == WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID };
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] targetJumpgate(Context context, Arguments arguments) {
|
||||
public Object[] targetJumpgate(Context context, Arguments arguments) {
|
||||
return targetJumpgate(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] isAttached(Context context, Arguments arguments) {
|
||||
public Object[] isAttached(Context context, Arguments arguments) {
|
||||
if (core != null) {
|
||||
return new Object[] { (boolean) (core.controller != null) };
|
||||
}
|
||||
|
|
|
@ -68,13 +68,13 @@ public class TileEntityRadar extends WarpEnergyTE {
|
|||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] scanRadius(Context context, Arguments arguments) {
|
||||
public Object[] scanRadius(Context context, Arguments arguments) {
|
||||
return scanRadius(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] getResultsCount(Context context, Arguments arguments) {
|
||||
public Object[] getResultsCount(Context context, Arguments arguments) {
|
||||
if (results != null) {
|
||||
return new Integer[] { results.size() };
|
||||
}
|
||||
|
@ -83,13 +83,13 @@ public class TileEntityRadar extends WarpEnergyTE {
|
|||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] getResult(Context context, Arguments arguments) {
|
||||
public Object[] getResult(Context context, Arguments arguments) {
|
||||
return getResult(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] pos(Context context, Arguments arguments) {
|
||||
public Object[] pos(Context context, Arguments arguments) {
|
||||
return new Integer[] { xCoord, yCoord, zCoord };
|
||||
}
|
||||
|
||||
|
|
|
@ -506,19 +506,19 @@ public class TileEntityShipScanner extends WarpEnergyTE {
|
|||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] scan(Context context, Arguments arguments) {
|
||||
public Object[] scan(Context context, Arguments arguments) {
|
||||
return scan(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] filename(Context context, Arguments arguments) {
|
||||
public Object[] filename(Context context, Arguments arguments) {
|
||||
return filename(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] deploy(Context context, Arguments arguments) {
|
||||
public Object[] deploy(Context context, Arguments arguments) {
|
||||
return deploy(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ public abstract class WarpEnergyTE extends WarpInterfacedTE implements IEnergyHa
|
|||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
private Object[] getEnergyLevel(Context context, Arguments arguments) {
|
||||
public Object[] getEnergyLevel(Context context, Arguments arguments) {
|
||||
return getEnergyLevel();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Set;
|
|||
|
||||
import li.cil.oc.api.Network;
|
||||
import li.cil.oc.api.machine.Arguments;
|
||||
import li.cil.oc.api.machine.Callback;
|
||||
import li.cil.oc.api.machine.Context;
|
||||
import li.cil.oc.api.network.Environment;
|
||||
import li.cil.oc.api.network.Message;
|
||||
|
@ -175,6 +176,12 @@ public abstract class WarpInterfacedTE extends WarpTE implements IPeripheral, En
|
|||
}
|
||||
|
||||
// OpenComputers methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] interfaced(Context context, Arguments arguments) {
|
||||
return new String[] { "This is a WarpDrive interfaced tile entity." };
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public void OC_constructor() {
|
||||
OC_node = Network.newNode(this, Visibility.Network).withComponent(peripheralName).create();
|
||||
|
|
Loading…
Reference in a new issue