Example #1
0
  private static void func_151179_e() {
    Iterator var0 = Item.itemRegistry.iterator();

    while (var0.hasNext()) {
      Item var1 = (Item) var0.next();

      if (var1 != null) {
        int var2 = Item.getIdFromItem(var1);
        String var3 = func_180204_a(var1);

        if (var3 != null && var1.isDamageable()) {
          objectBreakStats[var2] =
              (new StatCrafting(
                      "stat.breakItem.",
                      var3,
                      new ChatComponentTranslation(
                          "stat.breakItem",
                          new Object[] {(new ItemStack(var1)).getChatComponent()}),
                      var1))
                  .registerStat();
        }
      }
    }

    replaceAllSimilarBlocks(objectBreakStats);
  }
Example #2
0
 public static ItemStack getRecipeElement(String s, int amount, int damage) {
   if (s.equals("doorIron")) {
     return new ItemStack(Item.doorIron, amount);
   }
   if (s.equals("doorWood")) {
     return new ItemStack(Item.doorWood, amount);
   }
   if (s.equals("clayItem")) {
     return new ItemStack(Item.clay, amount);
   }
   for (Item item : Item.itemsList) {
     if (item != null
         && item.getUnlocalizedName() != null
         && (item.getUnlocalizedName().equals("item." + s)
             || item.getUnlocalizedName().equals("tile." + s))) {
       return new ItemStack(item, amount, damage);
     }
   }
   for (InfoType type : infoTypes) {
     if (type.shortName.equals(s)) return new ItemStack(type.item, amount, damage);
   }
   if (s.equals("gunpowder")) {
     return new ItemStack(Item.gunpowder, amount);
   }
   if (s.equals("iron")) {
     return new ItemStack(Item.ingotIron, amount);
   }
   FlansMod.log("Could not find " + s + " when adding recipe");
   return null;
 }
  @Override
  public int getItemBurnTime(ItemStack p_145952_0_) {
    if (p_145952_0_ == null) {
      return 0;
    } else {
      Item item = p_145952_0_.getItem();

      if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {
        Block block = Block.getBlockFromItem(item);

        if (block == Blocks.wooden_slab) {
          return 100;
        }

        if (block.getMaterial() == Material.wood) {
          return 200;
        }

        if (block == Blocks.coal_block) {
          return 8000;
        }
      }
      if (item == Items.stick) return 75;
      if (item == Items.coal) return 800;
      if (item == Item.getItemFromBlock(Blocks.sapling)) return 100;
      if (item == Item.getItemFromBlock(ZombieModpackWorld.zombieFlesh)) {
        return 700;
      }
      return 0;
    }
  }
  @SideOnly(Side.CLIENT)
  private static Pair<String, KnowledgeObject<?>> getObject(char type, String identifier) {
    KnowledgeObject<?> obj = null;
    String text = null;

    boolean isHEE = identifier.charAt(0) == '~' && identifier.length() > 1;
    if (isHEE) identifier = identifier.substring(1);

    switch (type) {
      case 'b':
      case 'i':
        int metaIndex = identifier.indexOf('/'), meta = 0;

        if (metaIndex != -1 && metaIndex + 1 < identifier.length()) {
          meta = DragonUtil.tryParse(identifier.substring(metaIndex + 1), 0);
          identifier = identifier.substring(0, metaIndex);
        }

        Item item =
            GameRegistry.findItem(isHEE ? "HardcoreEnderExpansion" : "minecraft", identifier);

        if (item != null) {
          text =
              StatCollector.translateToLocal(
                  item.getUnlocalizedName(new ItemStack(item, 1, meta)) + ".name");
          obj =
              KnowledgeObject.fromObject(
                  type == 'b'
                      ? (item instanceof ItemBlock
                          ? new BlockInfo(((ItemBlock) item).field_150939_a, meta)
                          : null)
                      : item);
        }

        break;

      case 'e':
        if (isHEE)
          text =
              ItemSpawnEggs.getMobName(
                  (Class<?>)
                      EntityList.stringToClassMapping.get(
                          identifier = ("HardcoreEnderExpansion." + identifier)));
        else text = StatCollector.translateToLocal("entity." + identifier + ".name");

        Class<?> cls = (Class<?>) EntityList.stringToClassMapping.get(identifier);
        if (cls != null) obj = KnowledgeObject.fromObject(cls);
        break;

      case 'd':
        obj = KnowledgeObject.fromObject(identifier);
        if (obj != null) text = obj.getTranslatedTooltip();
        break;
    }

    if (text == null || obj == null) {
      Log.warn("Invalid object type or identifier: $0:$1", type, identifier);
      return Pair.<String, KnowledgeObject<?>>of(text == null ? identifier : text, obj);
    } else return Pair.<String, KnowledgeObject<?>>of(text, obj);
  }
 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;
 }
Example #6
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());
  }
Example #7
0
  @SubscribeEvent
  public void onPlayerOpenContainer(PlayerOpenContainerEvent event) {
    if (event.entityPlayer instanceof EntityPlayerMP) {
      if (event.entityPlayer.openContainer instanceof net.minecraft.inventory.ContainerWorkbench
          && event.entityPlayer.openContainer.inventoryItemStacks.get(0) != null) {
        EntityPlayerMP playerMP = (EntityPlayerMP) event.entityPlayer;
        PlayerData player = PlayerStore.getInstance().getPlayer(playerMP.getUniqueID().toString());
        Item item =
            (Item)
                ((ItemStack) event.entityPlayer.openContainer.inventoryItemStacks.get(0)).getItem();
        ArrayList<ItemPerk> entitylist = PerkStore.getPerksForItem(item.getUnlocalizedName());
        boolean requiresPerk = false;
        if (entitylist != null) {
          requiresPerk = true;
        }
        for (ItemSkill skill : SkillStore.getInstance().getItemSkill()) {
          ArrayList<ItemXP> temp = skill.getExp();
          for (int i = 0; i < temp.size(); i++) {
            Item compareItem = ((ItemXP) temp.get(i)).getItem();
            if (item.equals(compareItem)) {
              if (requiresPerk) {
                if (PlayerHandler.hasPerk(player, entitylist)) {

                } else {
                  PlayerHandler.taskFail((EntityPlayer) playerMP);
                  event.entityPlayer.closeScreen();
                  break;
                }
              }
            }
          }
        }
      }
    }
  }
 public static void configureIDs(Configuration config) {
   int i = 0;
   for (Item thisItem : itemList) {
     config.getItem(thisItem.getItemName(), defaultIdsList[i]);
     i++;
   }
 }
  @Override
  public void parentBlockHarvestItem(
      World world,
      IvTileEntityMultiBlock tileEntity,
      int x,
      int y,
      int z,
      Block block,
      int metadata) {
    if (tileEntity instanceof TileEntityStatue) {
      Entity statueEntity = ((TileEntityStatue) tileEntity).getStatueEntity();

      if (statueEntity != null) {
        Item item = null;

        if (statueMaterial == 0) item = Item.getItemFromBlock(YGCBlocks.statueStone);
        else if (statueMaterial == 1) item = Item.getItemFromBlock(YGCBlocks.statuePlanks);
        else if (statueMaterial == 2) item = Item.getItemFromBlock(YGCBlocks.statueGold);

        if (item != null) {
          ItemStack stack = new ItemStack(item);
          ItemStatue.setStatueEntity(stack, statueEntity);

          dropBlockAsItem(world, x, y, z, stack);
        }
      }
    }
  }
Example #10
0
  /**
   * Registeres a piece (called by code or config)
   *
   * @param piece the item to list
   * @param weight the weight of the piece (Kg)
   * @param bulk the bulk of the piece
   * @param alterSpeed if the armour's weight slows you down
   */
  public static void registerItem(Item piece, float efficiency) {
    int id = Item.getIdFromItem(piece);

    MineFantasyAPI.debugMsg(
        "Added Custom hoe: " + piece.getUnlocalizedName() + " Efficiency = " + efficiency);
    entries.put(id, new CustomHoeEntry(id, efficiency));
  }
 private static int getFuelTime(ItemStack stack) {
   if (stack == null) return 0;
   if (stack.getItem() == Item.getItemFromBlock(Blocks.packed_ice)) return 3000;
   if (stack.getItem() == Item.getItemFromBlock(Blocks.ice)) return 2000;
   if (stack.getItem() == FurnitureItems.itemCoolPack) return 400;
   return 0;
 }
  private void stageReturnWood() {
    theFolk.isWorking = false;

    if (step == 1) {
      theFolk.statusText = "Delivering wood back to base";
      theFolk.gotoXYZ(theFolk.employedAt, null);
      step = 2;
    } else if (step == 2) {
      if (theFolk.gotoMethod == GotoMethod.WALK) {
        theFolk.updateLocationFromEntity();
      }

      int dist = theFolk.location.getDistanceTo(theFolk.employedAt);

      if (dist <= 1) {
        step = 3;
      } else {
        if (theFolk.destination == null && theFolk.theEntity != null) {
          // step=1;
        }
      }
    } else if (step == 3) {
      theFolk.stayPut = true;
      int count = getInventoryCount(theFolk, Item.getItemFromBlock(Blocks.log));
      millChests = inventoriesFindClosest(theFolk.employedAt, 6);
      inventoriesTransferFromFolk(
          theFolk.inventory, millChests, new ItemStack(Item.getItemFromBlock(Blocks.log)));
      pay = (float) count * 0.03f;
      SimukraftReloaded.states.credits -= pay;
      SimukraftReloaded.sendChat(
          theFolk.name + " has delivered " + count + " logs at the lumbermill");
      theStage = Stage.SCANFORTREE;
      step = 1;
    }
  }
Example #13
0
  /** Used to check if a recipe matches current crafting inventory */
  @Override
  public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) {
    this.enchantedBook = null;
    this.tool = null;

    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        ItemStack itemstack = par1InventoryCrafting.getStackInRowAndColumn(j, i);

        if (itemstack != null) {
          if (Item.getIdFromItem(itemstack.getItem()) == Item.getIdFromItem(Items.enchanted_book)) {
            if (this.enchantedBook != null) return false;

            this.enchantedBook = itemstack;
          }

          if (itemstack.getItem() instanceof ToolBase) {
            if (this.tool != null) return false;

            this.tool = ((ToolBase) itemstack.getItem()).getToolProperties(itemstack);
          }
        }
      }
    }

    return this.enchantedBook != null && this.tool != null;
  }
Example #14
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);
  }
Example #15
0
 @Override
 public int compareTo(ItemKey o) {
   if (stack.getItem() != o.stack.getItem())
     return compareInt(Item.getIdFromItem(stack.getItem()), Item.getIdFromItem(o.stack.getItem()));
   if (actualDamage(stack) != actualDamage(o.stack))
     return compareInt(actualDamage(stack), actualDamage(o.stack));
   return 0;
 }
Example #16
0
  public static ItemStack createStackedBlock(Block block, int bMeta) {

    Item item = Item.getItemFromBlock(block);
    if (item.getHasSubtypes()) {
      return new ItemStack(item, 1, bMeta);
    }
    return new ItemStack(item, 1, 0);
  }
Example #17
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);
   }
 }
  /** 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 void stopUsing(EntityPlayer player) {
   if (stack != null) {
     Item instance = stack.getItem();
     instance.onPlayerStoppedUsing(
         stack, player.worldObj, player, useDuration - useDurationLeft);
   }
   useDurationLeft = 0;
   stack = null;
 }
 private static String upgradeItemId(String id) {
   Matcher match = oldNamePattern.matcher(id);
   if (!match.matches()) return null;
   id = match.group(1);
   for (Item item : GameData.getItemRegistry().typeSafeIterable())
     if (id.equals(item.getUnlocalizedName()))
       return GameData.getItemRegistry().getNameForObject(item).replace(':', '.') + match.group(2);
   return null;
 }
Example #21
0
 public AnvilRecipe SetCraftingBound(int max) {
   craftingValue =
       70
           + new Random(
                   (input1 != null ? Item.getIdFromItem(input1.getItem()) : 0)
                       + (result != null ? Item.getIdFromItem(result.getItem()) : 0))
               .nextInt(max);
   return this;
 }
 @Override
 @SideOnly(Side.CLIENT)
 public Item getItem(World par1World, int par2, int par3, int par4) {
   return isBlockSingleSlab(this)
       ? Item.getItemFromBlock(this)
       : (this == BlockRegistry.chocoSmoothSandStoneSlabdouble
           ? Item.getItemFromBlock(BlockRegistry.chocoSmoothSandStoneSlabsingle)
           : Item.getItemFromBlock(BlockRegistry.chocoSmoothSandStoneSlabsingle));
 }
Example #23
0
  @Override
  public void preInit() {
    super.preInit();

    EventUtil.register(ClientTimerHandler.INSTANCE, EventUtil.Type.BOTH);

    File file = new File(Subsistence.configPath + "foliage.json");
    if (file.exists()) {
      FoliageHandler.initialize(file);
    } else {
      FoliageHandler.initialize(null);
    }

    AdvancedModelLoader.registerModelHandler(new FixedTechneModelLoader());

    // TILE
    ClientRegistry.bindTileEntitySpecialRenderer(TileTable.class, new RenderTileTable());
    ClientRegistry.bindTileEntitySpecialRenderer(TileSieveTable.class, new RenderTileSieveTable());
    ClientRegistry.bindTileEntitySpecialRenderer(
        TileSinteringOven.class, new RenderTileSinteringOven());
    ClientRegistry.bindTileEntitySpecialRenderer(TileHammerMill.class, new RenderTileHammerMill());
    ClientRegistry.bindTileEntitySpecialRenderer(TileHandCrank.class, new RenderTileCrank());
    ClientRegistry.bindTileEntitySpecialRenderer(
        TileKineticCrank.class, new RenderTileKineticCrank());
    ClientRegistry.bindTileEntitySpecialRenderer(TileWaterMill.class, new RenderTileWaterMill());
    ClientRegistry.bindTileEntitySpecialRenderer(TileKiln.class, new RenderTileKiln());
    ClientRegistry.bindTileEntitySpecialRenderer(TileMetalPress.class, new RenderTileMetalPress());
    ClientRegistry.bindTileEntitySpecialRenderer(
        TileSpawnMarker.class, new RenderTileSpawnMarker());
    ClientRegistry.bindTileEntitySpecialRenderer(TileMetalShaft.class, new RenderTileMetalShaft());
    ClientRegistry.bindTileEntitySpecialRenderer(TileCompost.class, new RenderTileCompost());
    ClientRegistry.bindTileEntitySpecialRenderer(TileBarrel.class, new RenderTileBarrel());

    // ITEM
    MinecraftForgeClient.registerItemRenderer(
        Item.getItemFromBlock(SubsistenceBlocks.table), new RenderItemTable());
    MinecraftForgeClient.registerItemRenderer(
        Item.getItemFromBlock(SubsistenceBlocks.tableSieve), new RenderItemSieveTable());
    MinecraftForgeClient.registerItemRenderer(
        Item.getItemFromBlock(SubsistenceBlocks.sinteringOven), new RenderItemSinteringOven());
    MinecraftForgeClient.registerItemRenderer(
        Item.getItemFromBlock(SubsistenceBlocks.hammerMill), new RenderItemHammerMill());
    MinecraftForgeClient.registerItemRenderer(
        Item.getItemFromBlock(SubsistenceBlocks.kineticCrank), new RenderItemKineticCrank());
    MinecraftForgeClient.registerItemRenderer(
        Item.getItemFromBlock(SubsistenceBlocks.kiln), new RenderItemKiln());
    MinecraftForgeClient.registerItemRenderer(
        Item.getItemFromBlock(SubsistenceBlocks.metalPress), new RenderItemMetalPress());
    MinecraftForgeClient.registerItemRenderer(
        Item.getItemFromBlock(SubsistenceBlocks.spawnMarker), new RenderItemSpawnMarker());
    MinecraftForgeClient.registerItemRenderer(
        Item.getItemFromBlock(SubsistenceBlocks.compost), new RenderItemCompost());
    MinecraftForgeClient.registerItemRenderer(
        Item.getItemFromBlock(SubsistenceBlocks.barrel), new RenderItemBarrel());
    MinecraftForgeClient.registerItemRenderer(
        SubsistenceItems.barrelLid, new RenderItemBarrelLid());
  }
Example #24
0
  public static NBTTagList getEnchantmentTagList(ItemStack itemStack) {
    NBTTagList nbttaglist = itemStack.getEnchantmentTagList();

    if (nbttaglist == null
        || (nbttaglist.tagCount() == 0
            && Item.getIdFromItem(itemStack.getItem()) == Item.getIdFromItem(Items.enchanted_book)))
      nbttaglist = Items.enchanted_book.func_92110_g(itemStack);

    return nbttaglist != null ? nbttaglist : new NBTTagList();
  }
  public static ItemStack createStackedBlock(Block block, int metadata) {
    int md = 0;
    Item item = Item.getItemFromBlock(block);

    if ((item != null) && item.getHasSubtypes()) {
      md = metadata;
    }

    return new ItemStack(item, 1, md);
  }
 @SuppressWarnings("unchecked")
 @Override
 @SideOnly(Side.CLIENT)
 public void getSubItems(
     Item par1, CreativeTabs par2CreativeTabs, @SuppressWarnings("rawtypes") List par3List) {
   if (par1.equals(emptyItem)) par3List.add(new ItemStack(par1, 1, 0));
   if (par1.equals(filledItem))
     for (int i = 0, e = LiquidRegistry.getRegisteredLiquidCount(); i++ < e; )
       par3List.add(new ItemStack(par1, 1, i));
 }
 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()))));
   }
 }
Example #28
0
 @Nullable
 @Override
 public BaseItem createFromId(int id) {
   Item item = (Item) Item.itemRegistry.getObjectById(id);
   if (item != null) {
     return new BaseItem(Item.getIdFromItem(item), (short) item.getDamage(new ItemStack(item, 1)));
   } else {
     return null;
   }
 }
Example #29
0
 public static void registerRender(Block block) {
   Item item = Item.getItemFromBlock(block);
   Minecraft.getMinecraft()
       .getRenderItem()
       .getItemModelMesher()
       .register(
           item,
           0,
           new ModelResourceLocation(
               strings.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
 }
Example #30
0
  /** only shows items which have tabToDisplayOn == this */
  public void getItemsForTab(List<ItemStack> stacks) {
    for (Item item : Item.itemRegistry) {
      if (item != null && item.getCreativeTab() == this) {
        item.getSubItems(item, this, stacks);
      }
    }

    if (this.getRelevantEnchantmentTypes() != null) {
      this.addEnchantmentBooksToList(stacks, this.getRelevantEnchantmentTypes());
    }
  }