コード例 #1
0
 @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;
 }
コード例 #2
0
 @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};
 }