@Callback( doc = "function(x:number,y:number,z:number,facing:number):nill -- Sets The golems home position") @Optional.Method(modid = "OpenComputers") public Object[] setHome(Context context, Arguments args) throws Exception { return setHomeImplementation( args.checkDouble(0), args.checkDouble(1), args.checkDouble(2), args.checkDouble(3)); }
@Callback public Object[] writeNFCData(Context contex, Arguments args) { if (args.count() == 1 && args.checkString(0).length() <= 1024) { NFCData = args.checkString(0); worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, 1, 2); } else { new Exception("No arguments or data is bigger than 1024 characters."); } return null; }
@Override @Optional.Method(modid = "OpenComputers") public Object[] invoke(final String method, final Context context, final Arguments args) throws Exception { final Object[] arguments = new Object[args.count()]; for (int i = 0; i < args.count(); ++i) { if (args.isString(i)) { arguments[i] = args.checkString(i); } else { arguments[i] = args.checkAny(i); } } final Integer methodId = methodIds.get(method); if (methodId == null) { throw new NoSuchMethodError(); } delayedCall = new Runnable() { @Override public void run() { if (Error == null) { // TODO The computer has already been saved when we get here // so we have to come up with some other way to tell the // computer that the command was a success *after* the move. // Possibly by saving a flag in this tile entity's nbt tag, // but I don't know how RiM saves the command block itself. // context.signal("carriage_moved", true); } else if (!Obstructed) { context.signal("carriage_moved", false, Error.getMessage()); } else { context.signal( "carriage_moved", false, Error.getMessage(), ObstructionX, ObstructionY, ObstructionZ); } } }; callMethod(methodId, arguments); return new Object[] {true}; }
@Callback(direct = true, limit = CALL_LIMIT) public Object[] setRayDirection(Context context, Arguments args) { camera.reset(); float x = args.count() == 2 ? (float) args.checkDouble(0) : 0.0F; float y = args.count() == 2 ? (float) args.checkDouble(1) : 0.0F; if (args.count() == 2) { int l = MathHelper.floor_double((double) (robot.player().rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; l = Direction.directionToFacing[l]; return new Object[] { camera.setRayDirection( entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord, ForgeDirection.getOrientation(l), (float) args.checkDouble(0), (float) args.checkDouble(1)) }; } return null; }
@Callback(direct = true, limit = CALL_LIMIT) public Object[] distanceDown(Context context, Arguments args) { camera.reset(); if (args.count() == 2) { camera.setRayDirection( entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord, ForgeDirection.DOWN, (float) args.checkDouble(0), (float) args.checkDouble(1)); } else { camera.setRayDirection( entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord, ForgeDirection.DOWN, 0.0F, 0.0F); } return new Object[] {camera.getDistance()}; }
@Callback(doc = "function(markerNum:number):table -- gets a specific marker") @Optional.Method(modid = "OpenComputers") public Object[] getMarker(Context context, Arguments args) throws Exception { return getMarkerImplementation((double) args.checkInteger(0)); }
@Callback(doc = "function(markerNum:number,marker:table):table -- saves current marker") @Optional.Method(modid = "OpenComputers") public Object[] saveMarker(Context context, Arguments args) throws Exception { return saveMarkerImplementation((double) args.checkInteger(0), args.checkTable(0)); }
@Callback(doc = "function(marker:table):table -- Adds the marker to the end of the marker list") @Optional.Method(modid = "OpenComputers") public Object[] addMarker(Context context, Arguments args) throws Exception { return addMarkerImplementation(args.checkTable(0)); }
@Callback(doc = "function(list:table):table -- Sets list of markers") @Optional.Method(modid = "OpenComputers") public Object[] setMarkers(Context context, Arguments args) throws Exception { return setMarkersImplementation(args.checkTable(0)); }