コード例 #1
0
ファイル: Patcher.java プロジェクト: reteo/SI-Mods
 public static ToolMaterial patchToolMaterial(
     String toolmatname,
     int harvestLevel,
     int maxUses,
     float efficiency,
     float damageVsEntity,
     int enchantability) {
   ToolMaterial toolmat = ToolMaterial.valueOf(toolmatname);
   return patchToolMaterial(
       toolmat, harvestLevel, maxUses, efficiency, damageVsEntity, enchantability);
 }
コード例 #2
0
ファイル: Patcher.java プロジェクト: reteo/SI-Mods
  public static void patchRoCSteelTools() {

    Object[] items =
        new Object[] {
          ItemRegistry.STEELPICK.getItemInstance(),
          ItemRegistry.STEELAXE.getItemInstance(),
          ItemRegistry.STEELSHOVEL.getItemInstance()
        };

    for (int c = 0; c < items.length; c++) {
      Reflector itemreflector = new Reflector(items[c], ItemTool.class);
      ToolMaterial toolmat = ToolMaterial.valueOf("STEEL");
      itemreflector
          .set("field_77862_b", toolmat)
          .set("field_77865_bY", toolmat.getDamageVsEntity() + 2F)
          .set("field_77864_a", toolmat.getEfficiencyOnProperMaterial());
      ((ItemTool) items[c]).setMaxDamage(toolmat.getMaxUses());
    }
    // throw new RuntimeException();
  }
コード例 #3
0
ファイル: Patcher.java プロジェクト: reteo/SI-Mods
  public static void patchTools() {

    FMLControlledNamespacedRegistry<Item> gamereg = GameData.getItemRegistry();

    @SuppressWarnings("unchecked")
    Set<String> allItems = GameData.getItemRegistry().getKeys();

    for (String itemname : allItems) {

      Item item = gamereg.getObject(itemname);
      if (item instanceof ItemTool || item instanceof ItemHoe || item instanceof ItemSword) {

        if (item.getClass().getCanonicalName().contains("Reika.RotaryCraft")) {
          continue;
        }

        ToolMaterial toolmat = null;
        String toolmatname = null;
        if (item instanceof ItemTool) toolmatname = ((ItemTool) item).getToolMaterialName();
        else if (item instanceof ItemHoe) toolmatname = ((ItemHoe) item).getToolMaterialName();
        else if (item instanceof ItemSword) toolmatname = ((ItemSword) item).getToolMaterialName();

        if (toolmatname == null) {
        } else {
          try {
            toolmat = ToolMaterial.valueOf(toolmatname);
          } catch (IllegalArgumentException e) {
            toolmat = null;
          }
        }

        if (toolmat == null) {
        } else {
          // Update the tool material
          if (item instanceof ItemTool) {
            if (item.getClass().getCanonicalName().contains("fi.dy.masa.enderutilities")) {
              Reflector endertoolreflector = new Reflector(item, ItemEnderTool.class);
              endertoolreflector
                  .set("material", toolmat)
                  .set("field_77865_bY", toolmat.getDamageVsEntity() + 2F)
                  .set("field_77864_a", toolmat.getEfficiencyOnProperMaterial());

            } else {
              Reflector itemreflector = new Reflector(item, ItemTool.class);
              Float damagemodifier = 0F;
              if (item instanceof ItemAxe) damagemodifier = 3F;
              if (item instanceof ItemPickaxe) damagemodifier = 2F;
              if (item instanceof ItemSpade) damagemodifier = 1F;

              itemreflector
                  .set("field_77862_b", toolmat)
                  .set("field_77865_bY", toolmat.getDamageVsEntity() + damagemodifier)
                  .set("field_77864_a", toolmat.getEfficiencyOnProperMaterial());
            }
          }
          if (item instanceof ItemHoe) {
            new Reflector(item, ItemHoe.class).set("field_77843_a", toolmat);
          }
          if (item instanceof ItemSword) {
            new Reflector(item, ItemSword.class)
                .set("field_150933_b", toolmat)
                .set("field_150934_a", toolmat.getDamageVsEntity() + 4F);
          }

          // Update the max damage
          if (item.getMaxDamage() > 0) item.setMaxDamage(toolmat.getMaxUses());

          if (item instanceof ItemTool)
            FMLLog.info(
                "[si.core] [tool patcher] is a "
                    + ((ItemTool) item).getToolMaterialName()
                    + " tool");
          if (item instanceof ItemHoe)
            FMLLog.info(
                "[si.core] [tool patcher] is a " + ((ItemHoe) item).getToolMaterialName() + " hoe");
          if (item instanceof ItemSword)
            FMLLog.info(
                "[si.core] [tool patcher] is a "
                    + ((ToolMaterial) new Reflector(item, ItemSword.class).get("field_150933_b"))
                        .name()
                    + " weapon (basically a sword)");
        }
      }
    }
  }