Exemple #1
0
  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();
  }
Exemple #2
0
  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)");
        }
      }
    }
  }
  /**
   * Adds a tool material to TConstruct
   *
   * @param name Name of the material
   * @param stack The stack used to create the material
   * @param ID The unique ID of the material
   * @param mat The base tool material used to generate values
   * @param tooltipColor The colour in the item tooltip
   * @param hexColor The actual colour of the Item
   * @param handleMod The handle modifier of the material
   * @param reinforced The reinforced trait of the material
   * @param stonebound The stonebound modifier of the material, negative is jagged
   * @param maxDamage The base speed of the bow
   * @param bowMaxSpeed The max speed of the bow
   * @param arrowWeight The weight of the arrow
   * @param arrowBreakChance The chance that the arrow will survive on impact
   * @param inGame The in game name of the material
   * @param casting Whether or not this needs casting (true) or part building (false)
   */
  public static void createToolSet(
      String name,
      ItemStack stack,
      int ID,
      ToolMaterial mat,
      EnumChatFormatting tooltipColor,
      int hexColor,
      float handleMod,
      int reinforced,
      float stonebound,
      int maxDamage,
      float bowMaxSpeed,
      float arrowWeight,
      float arrowBreakChance,
      String inGame,
      boolean casting,
      boolean instant) {
    pb.registerMaterialSet(
        name,
        new ItemStack(TinkerTools.toolShard, 1, ID),
        new ItemStack(TinkerTools.toolRod, 1, ID),
        32);
    TConstructClientRegistry.addMaterialRenderMapping(ID, "tinker", name, true);
    if (Loader.isModLoaded("IguanaTweaksTConstruct"))
      //									ID, MaterialName, 	HarvestLevel,	BaseDurability, MiningSpeed, 	Attack,
      //	handleModifier, ReinforcedLevel, 	stonebound
      TConstructRegistry.addToolMaterial(
          ID,
          name,
          mat.getHarvestLevel() + 2,
          mat.getMaxUses(),
          instant ? Integer.MAX_VALUE : (int) mat.getEfficiencyOnProperMaterial() * 100,
          (int) mat.getDamageVsEntity(),
          handleMod,
          reinforced,
          stonebound,
          tooltipColor.toString(),
          hexColor);
    else
      TConstructRegistry.addToolMaterial(
          ID,
          name,
          mat.getHarvestLevel(),
          mat.getMaxUses(),
          instant ? Integer.MAX_VALUE : (int) mat.getEfficiencyOnProperMaterial() * 100,
          (int) mat.getDamageVsEntity(),
          handleMod,
          reinforced,
          stonebound,
          tooltipColor.toString(),
          hexColor);
    //								MatID, DrawSpeed, maxSpeed
    TConstructRegistry.addBowMaterial(ID, maxDamage, bowMaxSpeed);
    //								MatID, Weight, BreakChance
    TConstructRegistry.addArrowMaterial(ID, arrowWeight, arrowBreakChance);
    // TinkerTools.registerPatternMaterial(name, 2, name);
    TConstructRegistry.addDefaultToolPartMaterial(ID);
    pb.registerFullMaterial(
        stack,
        2,
        name,
        new ItemStack(TinkerTools.toolShard, 1, ID),
        new ItemStack(TinkerTools.toolRod, 1, ID),
        ID);
    LanguageRegistry.instance()
        .addStringLocalization("material." + name.toLowerCase(), "en_US", inGame);
    // LogHelper.info("Looking for %s to localise to %s", "material."+name, inGame);
    registerWithStations(stack, name, ID);
    if (!casting) addPartBuilding(ID);
    // else		 addCasting(null, ID);

  }