Exemplo n.º 1
0
  public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    if (args.length < 1) {
      throw new WrongUsageException("commands.testfor.usage", new Object[0]);
    } else {
      Entity var3 = func_175768_b(sender, args[0]);
      NBTTagCompound var4 = null;

      if (args.length >= 2) {
        try {
          var4 = JsonToNBT.func_180713_a(func_180529_a(args, 1));
        } catch (NBTException var6) {
          throw new CommandException("commands.testfor.tagError", new Object[] {var6.getMessage()});
        }
      }

      if (var4 != null) {
        NBTTagCompound var5 = new NBTTagCompound();
        var3.writeToNBT(var5);

        if (!CommandTestForBlock.func_175775_a(var4, var5, true)) {
          throw new CommandException("commands.testfor.failure", new Object[] {var3.getName()});
        }
      }

      notifyOperators(sender, this, "commands.testfor.success", new Object[] {var3.getName()});
    }
  }
Exemplo n.º 2
0
  public String loadFromJson(String filename) {
    File file = new File(filename);
    String json;
    try {
      json = FileUtils.readFileToString(file);
    } catch (IOException e) {
      return "Error reading file!";
    }

    NBTTagCompound tagCompound;
    try {
      tagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(json);
    } catch (NBTException e) {
      return "NBT Error: " + e.getMessage();
    }

    readFromNBT(tagCompound);

    return null;
  }
Exemplo n.º 3
0
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    if (par2ArrayOfStr.length >= 1) {
      String var3 = par2ArrayOfStr[0];
      double var4 = (double) par1ICommandSender.getCommandSenderPosition().posX + 0.5D;
      double var6 = (double) par1ICommandSender.getCommandSenderPosition().posY;
      double var8 = (double) par1ICommandSender.getCommandSenderPosition().posZ + 0.5D;

      if (par2ArrayOfStr.length >= 4) {
        var4 = func_110666_a(par1ICommandSender, var4, par2ArrayOfStr[1]);
        var6 = func_110666_a(par1ICommandSender, var6, par2ArrayOfStr[2]);
        var8 = func_110666_a(par1ICommandSender, var8, par2ArrayOfStr[3]);
      }

      World var10 = par1ICommandSender.getEntityWorld();

      if (!var10.blockExists((int) var4, (int) var6, (int) var8)) {
        notifyAdmins(par1ICommandSender, "commands.summon.outOfWorld", new Object[0]);
      } else {
        NBTTagCompound var11 = new NBTTagCompound();
        boolean var12 = false;

        if (par2ArrayOfStr.length >= 5) {
          IChatComponent var13 = func_147178_a(par1ICommandSender, par2ArrayOfStr, 4);

          try {
            NBTBase var14 = JsonToNBT.func_150315_a(var13.getUnformattedText());

            if (!(var14 instanceof NBTTagCompound)) {
              notifyAdmins(
                  par1ICommandSender, "commands.summon.tagError", new Object[] {"Not a valid tag"});
              return;
            }

            var11 = (NBTTagCompound) var14;
            var12 = true;
          } catch (NBTException var17) {
            notifyAdmins(
                par1ICommandSender, "commands.summon.tagError", new Object[] {var17.getMessage()});
            return;
          }
        }

        var11.setString("id", var3);
        Entity var18 = EntityList.createEntityFromNBT(var11, var10);

        if (var18 != null) {
          var18.setLocationAndAngles(var4, var6, var8, var18.rotationYaw, var18.rotationPitch);

          if (!var12 && var18 instanceof EntityLiving) {
            ((EntityLiving) var18).onSpawnWithEgg((IEntityLivingData) null);
          }

          var10.spawnEntityInWorld(var18);
          Entity var19 = var18;

          for (NBTTagCompound var15 = var11;
              var15.func_150297_b("Riding", 10);
              var15 = var15.getCompoundTag("Riding")) {
            Entity var16 = EntityList.createEntityFromNBT(var15.getCompoundTag("Riding"), var10);

            if (var16 != null) {
              var16.setLocationAndAngles(var4, var6, var8, var16.rotationYaw, var16.rotationPitch);
              var10.spawnEntityInWorld(var16);
              var19.mountEntity(var16);
            }

            var19 = var16;
          }

          notifyAdmins(par1ICommandSender, "commands.summon.success", new Object[0]);
        } else {
          notifyAdmins(par1ICommandSender, "commands.summon.failed", new Object[0]);
        }
      }
    } else {
      throw new WrongUsageException("commands.summon.usage", new Object[0]);
    }
  }