Beispiel #1
0
  @Mod.EventHandler
  public void init(FMLInitializationEvent pEvent) {
    // 一応ドキュメント上ではここでレシピとかを宣言するらしい。
    GunsBase.init();
    // レシピ
    // 5.7x28mm SS190
    GameRegistry.addRecipe(
        new ItemStack(fn_SS190, 16), "i", "g", "g", 'i', Items.iron_ingot, 'g', Items.gunpowder);
    // 5.7x28mm L191
    GameRegistry.addRecipe(
        new ItemStack(fn_SS190, 16, 1),
        "ir",
        "g ",
        "g ",
        'i',
        Items.iron_ingot,
        'g',
        Items.gunpowder,
        'r',
        new ItemStack(Items.dye, 1, 1));
    // 5.7x28mm SS197SR
    GameRegistry.addRecipe(
        new ItemStack(fn_SS190, 20, 7),
        "ir",
        "g ",
        "g ",
        'i',
        Items.iron_ingot,
        'g',
        Items.gunpowder,
        'r',
        new ItemStack(Items.dye, 1, 12));
    // Five-seveN
    GameRegistry.addRecipe(
        new ItemStack(fn_fiveseven, 1, fn_fiveseven.getMaxDamage()),
        "iii",
        "  i",
        'i',
        Items.iron_ingot,
        'g',
        Items.gunpowder);
    // P90
    GameRegistry.addRecipe(
        new ItemStack(fn_p90, 1, fn_p90.getMaxDamage()),
        "i  ",
        "iii",
        "iii",
        'i',
        Items.iron_ingot);

    // レンダラの登録
    proxy.init();

    //		FMLCommonHandler.instance().bus().register(new RefinedMilitaryShovelReplicaEventHandler());
    //		ModLoader.registerPacketChannel(this, "IFN");

    // MMMLibのRevisionチェック
    //		MMM_Helper.checkRevision("7");
    //		MMM_Config.checkConfig(this.getClass());
  }
  /** Find recipes excluding one or more recipe types */
  public static ItemStack findMatchingRecipeExcluding(
      InventoryCrafting inv, World world, Class... excluding) {
    int i = 0;
    ItemStack itemstack = null;
    ItemStack itemstack1 = null;
    int j;
    List recipes = CraftingManager.getInstance().getRecipeList();

    for (j = 0; j < inv.getSizeInventory(); ++j) {
      ItemStack itemstack2 = inv.getStackInSlot(j);

      if (itemstack2 != null) {
        if (i == 0) {
          itemstack = itemstack2;
        }

        if (i == 1) {
          itemstack1 = itemstack2;
        }

        ++i;
      }
    }

    if (i == 2
        && itemstack.getItem() == itemstack1.getItem()
        && itemstack.stackSize == 1
        && itemstack1.stackSize == 1
        && itemstack.getItem().isRepairable()) {
      Item item = itemstack.getItem();
      int j1 = item.getMaxDamage() - itemstack.getItemDamage(); // getItemDamageForDisplay
      int k = item.getMaxDamage() - itemstack1.getItemDamage();
      int l = j1 + k + item.getMaxDamage() * 5 / 100;
      int i1 = item.getMaxDamage() - l;

      if (i1 < 0) {
        i1 = 0;
      }

      return new ItemStack(itemstack.getItem(), 1, i1);
    } else {
      for (j = 0; j < recipes.size(); ++j) {
        IRecipe irecipe = (IRecipe) recipes.get(j);

        // 1.1.1 Botania fix (try catch)
        try {
          if ((!Arrays.asList(excluding).contains(irecipe.getClass()))
              && irecipe.matches(inv, world)) {
            return irecipe.getCraftingResult(inv);
          }
        } catch (Exception e) {
        }
      }

      return null;
    }
  }
 public static void registerSmeltTool(Item item, CrucibleLiquid liquid, int m) {
   for (int i = 0; i < item.getMaxDamage(); i++) {
     smeltThings.put(
         MutablePair.of(item, i),
         MutablePair.of(
             liquid,
             MathHelper.floor_double(
                 m * ((float) (item.getMaxDamage() - i) / (float) item.getMaxDamage()))));
   }
 }
Beispiel #4
0
  public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) {
    int var3 = 0;
    ItemStack var4 = null;
    ItemStack var5 = null;

    for (int var6 = 0; var6 < par1InventoryCrafting.getSizeInventory(); ++var6) {
      ItemStack var7 = par1InventoryCrafting.getStackInSlot(var6);

      if (var7 != null) {
        if (var3 == 0) {
          var4 = var7;
        }

        if (var3 == 1) {
          var5 = var7;
        }

        ++var3;
      }
    }

    if (var3 == 2
        && var4.itemID == var5.itemID
        && var4.stackSize == 1
        && var5.stackSize == 1
        && Item.itemsList[var4.itemID].isRepairable()) {
      Item var13 = Item.itemsList[var4.itemID];
      int var14 = var13.getMaxDamage() - var4.getItemDamageForDisplay();
      int var8 = var13.getMaxDamage() - var5.getItemDamageForDisplay();
      int var9 = var14 + var8 + var13.getMaxDamage() * 5 / 100;
      int var10 = var13.getMaxDamage() - var9;

      if (var10 < 0) {
        var10 = 0;
      }

      return new ItemStack(var4.itemID, 1, var10);
    } else {
      Iterator var11 = this.recipes.iterator();
      IRecipe var12;

      do {
        if (!var11.hasNext()) {
          return null;
        }

        var12 = (IRecipe) var11.next();
      } while (!var12.matches(par1InventoryCrafting, par2World));

      return var12.getCraftingResult(par1InventoryCrafting);
    }
  }
  public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) {
    int i = 0;
    ItemStack itemstack = null;
    ItemStack itemstack1 = null;
    int j;

    for (j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j) {
      ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j);

      if (itemstack2 != null) {
        if (i == 0) {
          itemstack = itemstack2;
        }

        if (i == 1) {
          itemstack1 = itemstack2;
        }

        ++i;
      }
    }

    if (i == 2
        && itemstack.getItem() == itemstack1.getItem()
        && itemstack.stackSize == 1
        && itemstack1.stackSize == 1
        && itemstack.getItem().isRepairable()) {
      Item item = itemstack.getItem();
      int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay();
      int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay();
      int l = j1 + k + item.getMaxDamage() * 5 / 100;
      int i1 = item.getMaxDamage() - l;

      if (i1 < 0) {
        i1 = 0;
      }

      return new ItemStack(itemstack.getItem(), 1, i1);
    } else {
      for (j = 0; j < this.recipes.size(); ++j) {
        IRecipe irecipe = (IRecipe) this.recipes.get(j);

        if (irecipe.matches(par1InventoryCrafting, par2World)) {
          return irecipe.getCraftingResult(par1InventoryCrafting);
        }
      }

      return null;
    }
  }
Beispiel #6
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)");
        }
      }
    }
  }