public String getArmorTexture(Item item, String name) {
   String unlocalizedName = name.toLowerCase().replaceAll(" ", "_").replaceAll("'", "");
   item.setUnlocalizedName(unlocalizedName);
   item.setTextureName(Reference.MODID + ":" + unlocalizedName);
   item.setCreativeTab(MAIN_FNAF.tabFnaf);
   return unlocalizedName;
 }
示例#2
0
  public static void registerItemNoTab(Item item, String name) {
    String unlocalizedName = name.toLowerCase().replace(" ", "_").replace("'", "").replace("-", "");

    item.setUnlocalizedName(unlocalizedName);
    item.setTextureName(Flash.modid + ":" + unlocalizedName);

    GameRegistry.registerItem(item, unlocalizedName);
  }
示例#3
0
 public static void renameItemStack(ItemStack target, String name) {
   if (target == null) return;
   Item item = target.getItem();
   item.setUnlocalizedName(name);
   if (item instanceof ItemBlock) {
     Block.blocksList[((ItemBlock) item).getBlockID()].setUnlocalizedName(name);
   }
 }
示例#4
0
 public static void RegistrarItemMilitar(Item nombreClaseItem, String nombreItem) {
   nombreClaseItem
       .setUnlocalizedName(nombreItem)
       .setCreativeTab(tabMilitar)
       .setTextureName(RevolutionMain.MODID + ":" + nombreItem)
       .setFull3D();
   GameRegistry.registerItem(nombreClaseItem, nombreItem);
 };
  public static void tryLoad() {
    Debug.dbg("FMP carriage: loading");
    hollowCarriage = new ItemCarriageFMP();

    hollowCarriage.setUnlocalizedName("hollowCarriage");
    GameRegistry.registerItem(hollowCarriage, "Hollow Carriage");

    FMLInterModComms.sendMessage(
        "ForgeMicroblock", "microMaterial", new ItemStack(RemIMPluginsCommon.getFrameBlock()));
    // Attempting to fix FMP crashing when trying to set creative tab
  }
  @Override
  public void registerItem(ModManager manager, String name, String modPrefix, Item item) {
    super.registerItem(manager, name, modPrefix, item);
    if (modPrefix != null) {
      if (item.unlocalizedName == null || item.unlocalizedName.isEmpty()) {
        item.setUnlocalizedName(modPrefix + name);
      }

      if (item.iconString == null || item.iconString.isEmpty()) {
        item.setTextureName(modPrefix + name);
      }
    }

    if (manager.defaultTab != null && item.getCreativeTab() == null) {
      item.setCreativeTab(manager.defaultTab);
    }
  }
示例#7
0
 public static void initIndigo() {
   itemDyeIndigo = new ItemDyeIndigo();
   OreDictionary.registerOre("dyeBlue", new ItemStack(itemDyeIndigo));
   GameRegistry.registerItem(itemDyeIndigo, "dyeIndigo");
   GameRegistry.addShapelessRecipe(
       new ItemStack(Blocks.wool, 1, 11), new Object[] {itemDyeIndigo, Blocks.wool});
   GameRegistry.addShapelessRecipe(
       new ItemStack(Items.dye, 2, 12),
       new Object[] {itemDyeIndigo, new ItemStack(Items.dye, 1, 15)});
   GameRegistry.addShapelessRecipe(
       new ItemStack(Items.dye, 2, 6),
       new Object[] {itemDyeIndigo, new ItemStack(Items.dye, 1, 2)});
   GameRegistry.addShapelessRecipe(
       new ItemStack(Items.dye, 2, 5),
       new Object[] {itemDyeIndigo, new ItemStack(Items.dye, 1, 1)});
   GameRegistry.addShapelessRecipe(
       new ItemStack(Items.dye, 3, 13),
       new Object[] {
         itemDyeIndigo, new ItemStack(Items.dye, 1, 1), new ItemStack(Items.dye, 1, 9)
       });
   GameRegistry.addShapelessRecipe(
       new ItemStack(Items.dye, 4, 13),
       new Object[] {
         itemDyeIndigo,
         new ItemStack(Items.dye, 1, 1),
         new ItemStack(Items.dye, 1, 1),
         new ItemStack(Items.dye, 1, 15)
       });
   CraftLib.addShapelessOreRecipe(
       new ItemStack(itemLumar, 2, 11),
       new Object[] {Items.redstone, "dyeBlue", "dyeBlue", Items.glowstone_dust});
   CraftLib.addOreRecipe(
       new ItemStack(itemBag, 1, 11),
       new Object[] {
         "CCC", "CDC", "CCC", Character.valueOf('C'), itemCanvas, Character.valueOf('D'), "dyeBlue"
       });
   itemPlanBlank = (new Item()).setTextureName("rpbase:itemPlanBlank");
   itemPlanBlank.setUnlocalizedName("planBlank");
   itemPlanBlank.setCreativeTab(CreativeTabs.tabMisc);
   GameRegistry.addShapelessRecipe(
       new ItemStack(itemPlanBlank), new Object[] {Items.paper, itemDyeIndigo});
   GameRegistry.registerItem(itemPlanBlank, "planBlank");
   itemPlanFull = new ItemPlan();
   GameRegistry.registerItem(itemPlanFull, "planFull");
 }
  private static Item createItem(
      int defaultID,
      Class<? extends ABOItem> clazz,
      String descr,
      Object ingredient1,
      Object ingredient2,
      Object ingredient3) {
    String name =
        Character.toLowerCase(clazz.getSimpleName().charAt(0)) + clazz.getSimpleName().substring(1);

    Property prop = aboConfiguration.getItem(name + ".id", defaultID);

    int id = prop.getInt(defaultID);

    while (id < Item.itemsList.length && Item.itemsList[id] != null) id++;

    if (id >= Item.itemsList.length) {
      aboLog.log(
          Level.SEVERE, "Cannot find free ID for Item + " + name + " starting from " + defaultID);
      return null;
    }

    prop.set(id);

    Item item = null;
    try {
      item = clazz.getConstructor(int.class).newInstance(id);
    } catch (Throwable t) {
      t.printStackTrace();
    }

    if (item == null) return item;

    item.setUnlocalizedName(clazz.getSimpleName());
    GameRegistry.registerItem(item, item.getUnlocalizedName().replace("item.", ""));
    LanguageRegistry.addName(item, descr);

    addReceipe(item, 1, ingredient1, ingredient2, ingredient3);

    return item;
  }
 @Override
 public ItemCircuitDrawingPen setUnlocalizedName(String unlocalizedName) {
   super.setUnlocalizedName(unlocalizedName);
   return this;
 }
 public static Item addItem(String name, Item item) {
   item.setUnlocalizedName("gcewing." + idToName.get(item.itemID));
   LanguageRegistry.addName(item, name);
   item.setCreativeTab(itemTab);
   return item;
 }
 private static Item createPipe(Class<? extends Pipe<?>> clas) {
   Item res = BlockGenericPipe.registerPipe(clas, CreativeTabBuildCraft.PIPES);
   res.setUnlocalizedName(clas.getSimpleName());
   proxy.registerPipeRendering(res);
   return res;
 }
示例#12
0
 public static void initBlocks() {
   blockMultiblock = new BlockMultiblock();
   GameRegistry.registerBlock(blockMultiblock, "multiblock");
   GameRegistry.registerTileEntity(TileMultiblock.class, "RPMulti");
   blockAppliance = new BlockAppliance();
   GameRegistry.registerBlock(blockAppliance, ItemExtended.class, "appliance");
   GameRegistry.registerTileEntity(TileAlloyFurnace.class, "RPAFurnace");
   blockAppliance.addTileEntityMapping(0, TileAlloyFurnace.class);
   blockAppliance.setBlockName(0, "rpafurnace");
   GameRegistry.addRecipe(
       new ItemStack(blockAppliance, 1, 0),
       new Object[] {"BBB", "B B", "BBB", Character.valueOf('B'), Blocks.brick_block});
   GameRegistry.registerTileEntity(TileAdvBench.class, "RPAdvBench");
   blockAppliance.addTileEntityMapping(3, TileAdvBench.class);
   blockAppliance.setBlockName(3, "rpabench");
   CraftLib.addOreRecipe(
       new ItemStack(blockAppliance, 1, 3),
       new Object[] {
         "SSS",
         "WTW",
         "WCW",
         Character.valueOf('S'),
         Blocks.stone,
         Character.valueOf('W'),
         "plankWood",
         Character.valueOf('T'),
         Blocks.crafting_table,
         Character.valueOf('C'),
         Blocks.chest
       });
   itemHandsawIron = new ItemHandsaw(0);
   itemHandsawIron.setUnlocalizedName("handsawIron");
   itemHandsawIron.setTextureName("rpworld:itemHandsawIron");
   itemHandsawIron.setMaxDamage(320);
   itemHandsawDiamond = new ItemHandsaw(2);
   itemHandsawDiamond.setUnlocalizedName("handsawDiamond");
   itemHandsawDiamond.setTextureName("rpworld:itemHandsawDiamond");
   itemHandsawDiamond.setMaxDamage(1280);
   GameRegistry.addRecipe(
       new ItemStack(itemHandsawIron, 1),
       new Object[] {
         "WWW",
         " II",
         " II",
         Character.valueOf('I'),
         Items.iron_ingot,
         Character.valueOf('W'),
         Items.stick
       });
   GameRegistry.addRecipe(
       new ItemStack(itemHandsawDiamond, 1),
       new Object[] {
         "WWW",
         " II",
         " DD",
         Character.valueOf('I'),
         Items.iron_ingot,
         Character.valueOf('D'),
         Items.diamond,
         Character.valueOf('W'),
         Items.stick
       });
   GameRegistry.addShapelessRecipe(
       CoreLib.copyStack(itemWaferSilicon, 16),
       new Object[] {itemBouleSilicon, new ItemStack(itemHandsawDiamond, 1, -1)});
   itemScrewdriver = new ItemScrewdriver();
   GameRegistry.addRecipe(
       new ItemStack(itemScrewdriver, 1),
       new Object[] {
         "I ", " W", Character.valueOf('I'), Items.iron_ingot, Character.valueOf('W'), Items.stick
       });
   GameRegistry.registerItem(itemScrewdriver, "screwdriver");
   GameRegistry.addRecipe(
       new ItemStack(itemDrawplateDiamond, 1),
       new Object[] {
         " I ",
         "IDI",
         " I ",
         Character.valueOf('I'),
         new ItemStack(blockMicro, 1, 5649),
         Character.valueOf('D'),
         new ItemStack(blockMicro, 1, 4115)
       });
   GameRegistry.addShapelessRecipe(
       itemFineIron, new Object[] {Items.iron_ingot, new ItemStack(itemDrawplateDiamond, 1, -1)});
   CraftLib.addShapelessOreRecipe(
       itemFineCopper, new Object[] {"ingotCopper", new ItemStack(itemDrawplateDiamond, 1, -1)});
   GameRegistry.addRecipe(
       CoreLib.copyStack(itemNuggetIron, 9),
       new Object[] {"I", Character.valueOf('I'), Items.iron_ingot});
   CraftLib.addOreRecipe(
       CoreLib.copyStack(itemNuggetCopper, 9),
       new Object[] {"I", Character.valueOf('I'), "ingotCopper"});
   CraftLib.addOreRecipe(
       CoreLib.copyStack(itemNuggetTin, 9),
       new Object[] {"I", Character.valueOf('I'), "ingotTin"});
   CraftLib.addOreRecipe(
       CoreLib.copyStack(itemNuggetSilver, 9),
       new Object[] {"I", Character.valueOf('I'), "ingotSilver"});
   GameRegistry.addRecipe(
       new ItemStack(Items.iron_ingot, 1, 0),
       new Object[] {"III", "III", "III", Character.valueOf('I'), itemNuggetIron});
   GameRegistry.addRecipe(
       itemIngotSilver,
       new Object[] {"III", "III", "III", Character.valueOf('I'), itemNuggetSilver});
   GameRegistry.addRecipe(
       itemIngotTin, new Object[] {"III", "III", "III", Character.valueOf('I'), itemNuggetTin});
   GameRegistry.addRecipe(
       itemIngotCopper,
       new Object[] {"III", "III", "III", Character.valueOf('I'), itemNuggetCopper});
   GameRegistry.addRecipe(
       itemCanvas,
       new Object[] {
         "SSS",
         "SWS",
         "SSS",
         Character.valueOf('S'),
         Items.string,
         Character.valueOf('W'),
         Items.stick
       });
   GameRegistry.addRecipe(
       new ItemStack(Items.diamond, 2),
       new Object[] {"D", Character.valueOf('D'), new ItemStack(blockMicro, 1, 4115)});
   GameRegistry.addRecipe(
       new ItemStack(Items.diamond, 1),
       new Object[] {"D", Character.valueOf('D'), new ItemStack(blockMicro, 1, 19)});
   GameRegistry.addRecipe(
       new ItemStack(Items.iron_ingot, 2),
       new Object[] {"I", Character.valueOf('I'), new ItemStack(blockMicro, 1, 4113)});
   GameRegistry.addRecipe(
       new ItemStack(Items.iron_ingot, 1),
       new Object[] {"I", Character.valueOf('I'), new ItemStack(blockMicro, 1, 17)});
 }
示例#13
0
  public static void initBaseItems() {
    itemLumar = new ItemParts();
    itemLumar.setCreativeTab(CreativeTabs.tabMaterials);

    int i;
    for (i = 0; i < 16; ++i) {
      itemLumar.addItem(i, "rpbase:itemLumar" + i, "item.rplumar." + CoreLib.rawColorNames[i]);
      Config.addName(
          "item.rplumar." + CoreLib.rawColorNames[i] + ".name", CoreLib.enColorNames[i] + " Lumar");
      ItemStack dye = new ItemStack(Items.dye, 1, 15 - i);
      GameRegistry.addShapelessRecipe(
          new ItemStack(itemLumar, 2, i),
          new Object[] {Items.redstone, dye, dye, Items.glowstone_dust});
    }

    itemResource = new ItemParts();
    itemAlloy = new ItemParts();
    itemResource.setCreativeTab(CreativeTabs.tabMaterials);
    itemAlloy.setCreativeTab(CreativeTabs.tabMaterials);
    itemResource.addItem(0, "rpbase:itemRuby", "item.ruby");
    itemResource.addItem(1, "rpbase:itemGreenSapphire", "item.greenSapphire");
    itemResource.addItem(2, "rpbase:itemSapphire", "item.sapphire");
    itemResource.addItem(3, "rpbase:itemSilverIngot", "item.ingotSilver");
    itemResource.addItem(4, "rpbase:itemTinIngot", "item.ingotTin");
    itemResource.addItem(5, "rpbase:itemCopperIngot", "item.ingotCopper");
    itemResource.addItem(6, "rpbase:itemNikolite", "item.nikolite");
    itemAlloy.addItem(0, "rpbase:itemIngotRed", "item.ingotRed");
    itemAlloy.addItem(1, "rpbase:itemIngotBlue", "item.ingotBlue");
    itemAlloy.addItem(2, "rpbase:itemIngotBrass", "item.ingotBrass");
    itemAlloy.addItem(3, "rpbase:itemBouleSilicon", "item.bouleSilicon");
    itemAlloy.addItem(4, "rpbase:itemWaferSilicon", "item.waferSilicon");
    itemAlloy.addItem(5, "rpbase:itemWaferBlue", "item.waferBlue");
    itemAlloy.addItem(6, "rpbase:itemWaferRed", "item.waferRed");
    itemAlloy.addItem(7, "rpbase:itemTinPlate", "item.tinplate");
    itemAlloy.addItem(8, "rpbase:itemFineCopper", "item.finecopper");
    itemAlloy.addItem(9, "rpbase:itemFineIron", "item.fineiron");
    itemAlloy.addItem(10, "rpbase:itemCopperCoil", "item.coppercoil");
    itemAlloy.addItem(11, "rpbase:itemBTMotor", "item.btmotor");
    itemAlloy.addItem(12, "rpbase:itemCanvas", "item.rpcanvas");
    itemRuby = new ItemStack(itemResource, 1, 0);
    itemGreenSapphire = new ItemStack(itemResource, 1, 1);
    itemSapphire = new ItemStack(itemResource, 1, 2);
    itemIngotSilver = new ItemStack(itemResource, 1, 3);
    itemIngotTin = new ItemStack(itemResource, 1, 4);
    itemIngotCopper = new ItemStack(itemResource, 1, 5);
    itemNikolite = new ItemStack(itemResource, 1, 6);
    itemIngotRed = new ItemStack(itemAlloy, 1, 0);
    itemIngotBlue = new ItemStack(itemAlloy, 1, 1);
    itemIngotBrass = new ItemStack(itemAlloy, 1, 2);
    itemBouleSilicon = new ItemStack(itemAlloy, 1, 3);
    itemWaferSilicon = new ItemStack(itemAlloy, 1, 4);
    itemWaferBlue = new ItemStack(itemAlloy, 1, 5);
    itemWaferRed = new ItemStack(itemAlloy, 1, 6);
    itemTinplate = new ItemStack(itemAlloy, 1, 7);
    itemFineCopper = new ItemStack(itemAlloy, 1, 8);
    itemFineIron = new ItemStack(itemAlloy, 1, 9);
    itemCopperCoil = new ItemStack(itemAlloy, 1, 10);
    itemMotor = new ItemStack(itemAlloy, 1, 11);
    itemCanvas = new ItemStack(itemAlloy, 1, 12);
    OreDictionary.registerOre("gemRuby", itemRuby);
    OreDictionary.registerOre("gemGreenSapphire", itemGreenSapphire);
    OreDictionary.registerOre("gemSapphire", itemSapphire);
    OreDictionary.registerOre("ingotTin", itemIngotTin);
    OreDictionary.registerOre("ingotCopper", itemIngotCopper);
    OreDictionary.registerOre("ingotSilver", itemIngotSilver);
    OreDictionary.registerOre("ingotBrass", itemIngotBrass);
    OreDictionary.registerOre("dustNikolite", itemNikolite);
    itemNugget = new ItemParts();
    itemNugget.setCreativeTab(CreativeTabs.tabMaterials);
    itemNugget.addItem(0, "rpbase:itemNuggetIron", "item.nuggetIron");
    itemNugget.addItem(1, "rpbase:itemNuggetSilver", "item.nuggetSilver");
    itemNugget.addItem(2, "rpbase:itemNuggetTin", "item.nuggetTin");
    itemNugget.addItem(3, "rpbase:itemNuggetCopper", "item.nuggetCopper");
    itemNuggetIron = new ItemStack(itemNugget, 1, 0);
    itemNuggetSilver = new ItemStack(itemNugget, 1, 1);
    itemNuggetTin = new ItemStack(itemNugget, 1, 2);
    itemNuggetCopper = new ItemStack(itemNugget, 1, 3);
    OreDictionary.registerOre("nuggetIron", itemNuggetIron);
    OreDictionary.registerOre("nuggetSilver", itemNuggetSilver);
    OreDictionary.registerOre("nuggetTin", itemNuggetTin);
    OreDictionary.registerOre("nuggetCopper", itemNuggetCopper);
    itemDrawplateDiamond = new ItemDrawplate();
    itemDrawplateDiamond
        .setUnlocalizedName("drawplateDiamond")
        .setMaxDamage(255)
        .setTextureName("rpbase:itemDiamondDrawplate");
    GameRegistry.registerItem(itemDrawplateDiamond, "drawplateDiamond");
    itemBag = new ItemBag();
    GameRegistry.addRecipe(
        new ItemStack(itemBag, 1, 0),
        new Object[] {"CCC", "C C", "CCC", Character.valueOf('C'), itemCanvas});

    for (i = 1; i < 16; ++i) {
      GameRegistry.addRecipe(
          new ItemStack(itemBag, 1, i),
          new Object[] {
            "CCC",
            "CDC",
            "CCC",
            Character.valueOf('C'),
            itemCanvas,
            Character.valueOf('D'),
            new ItemStack(Items.dye, 1, 15 - i)
          });
    }
    GameRegistry.registerItem(itemLumar, "lumar");
    GameRegistry.registerItem(itemResource, "resource");
    GameRegistry.registerItem(itemAlloy, "alloy");
    GameRegistry.registerItem(itemNugget, "nugget");
    GameRegistry.registerItem(itemBag, "canvasBag");
  }
  /**
   * Imports resources using the metadata from a resource pack.
   *
   * @param manager - the resource manager to use
   * @param data - the metadata that contains the resource names
   */
  private void importResources(IResourceManager manager, ModbuilderResource data) {
    ResourceDeserializer deserializer = new ResourceDeserializer();
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(BaseItemResource.class, deserializer);
    builder.registerTypeAdapter(BaseBlockResource.class, deserializer);
    builder.registerTypeAdapter(BaseStructureResource.class, deserializer);
    builder.registerTypeAdapter(BaseRecipe.class, deserializer);
    Gson gson = builder.create();

    Map<String, BaseBlockResource> blockResources = new HashMap<String, BaseBlockResource>();
    Map<String, BaseItemResource> itemResources = new HashMap<String, BaseItemResource>();
    for (String path : data.blocks) {
      try {
        ResourceLocation location =
            new ResourceLocation(BuilderMod.MODID + ":blocks/" + path + ".json");
        IResource resource = manager.getResource(location);
        BaseBlockResource blockResource =
            gson.fromJson(
                new InputStreamReader(resource.getInputStream()), BaseBlockResource.class);
        Block block = ResourceConverter.toEmptyBlock(blockResource);
        block.setUnlocalizedName(BuilderMod.MODID + "_" + path);
        if (!registeredBlocks.contains(path)) {
          registeredBlocks.add(path);
          blockModels.put(block, blockResource.model);
          customBlocks.put(path, block);
          blockResources.put(path, blockResource);
        }
      } catch (IOException e) {
        // ignore
      }
    }

    for (String path : data.items) {
      try {
        ResourceLocation location =
            new ResourceLocation(BuilderMod.MODID + ":items/" + path + ".json");
        IResource resource = manager.getResource(location);
        BaseItemResource itemResource =
            gson.fromJson(new InputStreamReader(resource.getInputStream()), BaseItemResource.class);
        Item item = ResourceConverter.toEmptyItem(itemResource);
        item.setUnlocalizedName(BuilderMod.MODID + "_" + path);
        if (!registeredItems.contains(path)) {
          registeredItems.add(path);
          itemModels.put(item, itemResource.model);
          customItems.put(path, item);
          itemResources.put(path, itemResource);
        }
      } catch (IOException e) {
        // ignore
      }
    }

    for (String path : blockResources.keySet()) {
      BaseBlockResource resource = blockResources.get(path);
      Block block = ResourceConverter.toBlock(customBlocks.get(path), resource);
      GameRegistry.registerBlock(block, path);
      if (resource.burntime != null) fuels.put(Item.getItemFromBlock(block), resource.burntime);
    }

    for (String path : itemResources.keySet()) {
      BaseItemResource resource = itemResources.get(path);
      Item item = ResourceConverter.toItem(customItems.get(path), resource);
      GameRegistry.registerItem(item, path);
      if (resource.burntime != null) fuels.put(item, resource.burntime);
    }

    for (String path : data.structures) {
      try {
        ResourceLocation location =
            new ResourceLocation(BuilderMod.MODID + ":structures/" + path + ".json");
        IResource resource = manager.getResource(location);
        BaseStructureResource structureResource =
            gson.fromJson(
                new InputStreamReader(resource.getInputStream()), BaseStructureResource.class);
        BuilderStruct structure = ResourceConverter.toStructure(structureResource);
        if (!registeredStructures.contains(path)) {
          registeredStructures.add(path);
          registry.structs.add(structure);
        }
      } catch (IOException e) {
        // ignore
      }
    }

    for (String path : data.recipes) {
      try {
        ResourceLocation location =
            new ResourceLocation(BuilderMod.MODID + ":recipes/" + path + ".json");
        String s = location.getResourcePath();
        IResource resource = manager.getResource(location);
        BaseRecipe recipe =
            gson.fromJson(new InputStreamReader(resource.getInputStream()), BaseRecipe.class);
        RecipeRegistry.register(recipe);
      } catch (IOException e) {
        // ignore
      }
    }
  }