Java Code Examples for net.minecraft.item.Item.getIdFromItem()

The following are Jave code examples for showing how to use getIdFromItem() of the net.minecraft.item.Item class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Wurst-MC-1.12   File: AuthorCmd.java   Source Code and License Vote up 6 votes
@Override
public void call(String[] args) throws CmdException
{
	if(args.length == 0)
		throw new CmdSyntaxError();
	if(!WMinecraft.getPlayer().capabilities.isCreativeMode)
		throw new CmdError("Creative mode only.");
	ItemStack item = WMinecraft.getPlayer().inventory.getCurrentItem();
	if(item == null || Item.getIdFromItem(item.getItem()) != 387)
		throw new CmdError(
			"You are not holding a written book in your hand.");
	String author = args[0];
	for(int i = 1; i < args.length; i++)
		author += " " + args[i];
	item.setTagInfo("author", new NBTTagString(author));
}
 
Example 2
Project: CustomWorldGen   File: StatList.java   Source Code and License Vote up 6 votes
private static void initItemDepleteStats()
{
    for (Item item : net.minecraftforge.fml.common.registry.GameData.getItemRegistry().typeSafeIterable())
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = getItemName(item);

            if (s != null && item.isDamageable())
            {
                OBJECT_BREAK_STATS[i] = (new StatCrafting("stat.breakItem.", s, new TextComponentTranslation("stat.breakItem", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat();
            }
        }
    }

    replaceAllSimilarBlocks(OBJECT_BREAK_STATS, true);
}
 
Example 3
Project: BaseClient   File: StatList.java   Source Code and License Vote up 6 votes
private static void initStats()
{
    for (Item item : Item.itemRegistry)
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = func_180204_a(item);

            if (s != null)
            {
                objectUseStats[i] = (new StatCrafting("stat.useItem.", s, new ChatComponentTranslation("stat.useItem", new Object[] {(new ItemStack(item)).getChatComponent()}), item)).registerStat();

                if (!(item instanceof ItemBlock))
                {
                    itemStats.add((StatCrafting)objectUseStats[i]);
                }
            }
        }
    }

    replaceAllSimilarBlocks(objectUseStats);
}
 
Example 4
Project: Backmemed   File: StatList.java   Source Code and License Vote up 6 votes
private static void initPickedUpAndDroppedStats()
{
    for (Item item : Item.REGISTRY)
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = getItemName(item);

            if (s != null)
            {
                OBJECTS_PICKED_UP_STATS[i] = (new StatCrafting("stat.pickup.", s, new TextComponentTranslation("stat.pickup", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat();
                OBJECTS_DROPPED_STATS[i] = (new StatCrafting("stat.drop.", s, new TextComponentTranslation("stat.drop", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat();
            }
        }
    }

    replaceAllSimilarBlocks(OBJECT_BREAK_STATS);
}
 
Example 5
Project: BaseClient   File: BlockJukebox.java   Source Code and License Vote up 6 votes
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof BlockJukebox.TileEntityJukebox)
    {
        ItemStack itemstack = ((BlockJukebox.TileEntityJukebox)tileentity).getRecord();

        if (itemstack != null)
        {
            return Item.getIdFromItem(itemstack.getItem()) + 1 - Item.getIdFromItem(Items.record_13);
        }
    }

    return 0;
}
 
Example 6
Project: BaseClient   File: StatList.java   Source Code and License Vote up 6 votes
private static void initItemDepleteStats()
{
    for (Item item : Item.itemRegistry)
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = func_180204_a(item);

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

    replaceAllSimilarBlocks(objectBreakStats);
}
 
Example 7
Project: BaseClient   File: GuiStats.java   Source Code and License Vote up 5 votes
protected void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
{
    StatCrafting statcrafting = this.func_148211_c(entryID);
    Item item = statcrafting.func_150959_a();
    GuiStats.this.drawStatsScreen(p_180791_2_ + 40, p_180791_3_, item);
    int i = Item.getIdFromItem(item);
    this.func_148209_a(StatList.objectCraftStats[i], p_180791_2_ + 115, p_180791_3_, entryID % 2 == 0);
    this.func_148209_a(StatList.objectUseStats[i], p_180791_2_ + 165, p_180791_3_, entryID % 2 == 0);
    this.func_148209_a(statcrafting, p_180791_2_ + 215, p_180791_3_, entryID % 2 == 0);
}
 
Example 8
Project: ForgeHax   File: ProjectileUtils.java   Source Code and License Vote up 5 votes
/**
 * Check if the item is a bow, snowball, egg, fishing rod, or ender pearl
 */
public static boolean isThrowable(ItemStack itemStack) {
    if(itemStack == null) return false;
    switch (Item.getIdFromItem(itemStack.getItem())) {
        case 261: // bow
        case 332: // snowball
        case 344: // egg
        case 346: // fishing rod
        case 368: // ender pearl
            return true;
        default:
            return false;
    }
}
 
Example 9
Project: BaseClient   File: StatList.java   Source Code and License Vote up 5 votes
/**
 * Initializes statistics related to craftable items. Is only called after both block and item stats have been
 * initialized.
 */
private static void initCraftableStats()
{
    Set<Item> set = Sets.<Item>newHashSet();

    for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList())
    {
        if (irecipe.getRecipeOutput() != null)
        {
            set.add(irecipe.getRecipeOutput().getItem());
        }
    }

    for (ItemStack itemstack : FurnaceRecipes.instance().getSmeltingList().values())
    {
        set.add(itemstack.getItem());
    }

    for (Item item : set)
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = func_180204_a(item);

            if (s != null)
            {
                objectCraftStats[i] = (new StatCrafting("stat.craftItem.", s, new ChatComponentTranslation("stat.craftItem", new Object[] {(new ItemStack(item)).getChatComponent()}), item)).registerStat();
            }
        }
    }

    replaceAllSimilarBlocks(objectCraftStats);
}
 
Example 10
Project: Backmemed   File: CustomItems.java   Source Code and License Vote up 5 votes
private static CustomItemProperties getCustomItemProperties(ItemStack p_getCustomItemProperties_0_, int p_getCustomItemProperties_1_)
{
    if (itemProperties == null)
    {
        return null;
    }
    else if (p_getCustomItemProperties_0_ == null)
    {
        return null;
    }
    else
    {
        Item item = p_getCustomItemProperties_0_.getItem();
        int i = Item.getIdFromItem(item);

        if (i >= 0 && i < itemProperties.length)
        {
            CustomItemProperties[] acustomitemproperties = itemProperties[i];

            if (acustomitemproperties != null)
            {
                for (int j = 0; j < acustomitemproperties.length; ++j)
                {
                    CustomItemProperties customitemproperties = acustomitemproperties[j];

                    if (customitemproperties.type == p_getCustomItemProperties_1_ && matchesProperties(customitemproperties, p_getCustomItemProperties_0_, (int[][])null))
                    {
                        return customitemproperties;
                    }
                }
            }
        }

        return null;
    }
}
 
Example 11
Project: BaseClient   File: S0CPacketSpawnPlayer.java   Source Code and License Vote up 5 votes
public S0CPacketSpawnPlayer(EntityPlayer player)
{
    this.entityId = player.getEntityId();
    this.playerId = player.getGameProfile().getId();
    this.x = MathHelper.floor_double(player.posX * 32.0D);
    this.y = MathHelper.floor_double(player.posY * 32.0D);
    this.z = MathHelper.floor_double(player.posZ * 32.0D);
    this.yaw = (byte)((int)(player.rotationYaw * 256.0F / 360.0F));
    this.pitch = (byte)((int)(player.rotationPitch * 256.0F / 360.0F));
    ItemStack itemstack = player.inventory.getCurrentItem();
    this.currentItem = itemstack == null ? 0 : Item.getIdFromItem(itemstack.getItem());
    this.watcher = player.getDataWatcher();
}
 
Example 12
Project: Backmemed   File: StatList.java   Source Code and License Vote up 4 votes
@Nullable
public static StatBase getDroppedObjectStats(Item itemIn)
{
    return OBJECTS_DROPPED_STATS[Item.getIdFromItem(itemIn)];
}
 
Example 13
Project: Backmemed   File: CustomItems.java   Source Code and License Vote up 4 votes
private static Properties makePotionProperties(String p_makePotionProperties_0_, String p_makePotionProperties_1_, int p_makePotionProperties_2_, String p_makePotionProperties_3_)
{
    if (StrUtils.endsWith(p_makePotionProperties_0_, new String[] {"_n", "_s"}))
    {
        return null;
    }
    else if (p_makePotionProperties_0_.equals("empty") && p_makePotionProperties_1_.equals("normal"))
    {
        p_makePotionProperties_2_ = Item.getIdFromItem(Items.GLASS_BOTTLE);
        Properties properties = new Properties();
        properties.put("type", "item");
        properties.put("items", "" + p_makePotionProperties_2_);
        return properties;
    }
    else
    {
        int[] aint = (int[])((int[])getMapPotionIds().get(p_makePotionProperties_0_));

        if (aint == null)
        {
            Config.warn("Potion not found for image: " + p_makePotionProperties_3_);
            return null;
        }
        else
        {
            StringBuffer stringbuffer = new StringBuffer();

            for (int i = 0; i < aint.length; ++i)
            {
                int j = aint[i];

                if (p_makePotionProperties_1_.equals("splash"))
                {
                    j |= 16384;
                }

                if (i > 0)
                {
                    stringbuffer.append(" ");
                }

                stringbuffer.append(j);
            }

            int k = 16447;

            if (p_makePotionProperties_0_.equals("water") || p_makePotionProperties_0_.equals("mundane"))
            {
                k |= 64;
            }

            Properties properties1 = new Properties();
            properties1.put("type", "item");
            properties1.put("items", "" + p_makePotionProperties_2_);
            properties1.put("damage", "" + stringbuffer.toString());
            properties1.put("damageMask", "" + k);

            if (p_makePotionProperties_1_.equals("splash"))
            {
                properties1.put("texture.potion_bottle_splash", p_makePotionProperties_0_);
            }
            else
            {
                properties1.put("texture.potion_bottle_drinkable", p_makePotionProperties_0_);
            }

            return properties1;
        }
    }
}
 
Example 14
Project: BaseClient   File: GuiStats.java   Source Code and License Vote up 4 votes
public StatsBlock(Minecraft mcIn)
{
    super(mcIn);
    this.statsHolder = Lists.<StatCrafting>newArrayList();

    for (StatCrafting statcrafting : StatList.objectMineStats)
    {
        boolean flag = false;
        int i = Item.getIdFromItem(statcrafting.func_150959_a());

        if (GuiStats.this.field_146546_t.readStat(statcrafting) > 0)
        {
            flag = true;
        }
        else if (StatList.objectUseStats[i] != null && GuiStats.this.field_146546_t.readStat(StatList.objectUseStats[i]) > 0)
        {
            flag = true;
        }
        else if (StatList.objectCraftStats[i] != null && GuiStats.this.field_146546_t.readStat(StatList.objectCraftStats[i]) > 0)
        {
            flag = true;
        }

        if (flag)
        {
            this.statsHolder.add(statcrafting);
        }
    }

    this.statSorter = new Comparator<StatCrafting>()
    {
        public int compare(StatCrafting p_compare_1_, StatCrafting p_compare_2_)
        {
            int j = Item.getIdFromItem(p_compare_1_.func_150959_a());
            int k = Item.getIdFromItem(p_compare_2_.func_150959_a());
            StatBase statbase = null;
            StatBase statbase1 = null;

            if (StatsBlock.this.field_148217_o == 2)
            {
                statbase = StatList.mineBlockStatArray[j];
                statbase1 = StatList.mineBlockStatArray[k];
            }
            else if (StatsBlock.this.field_148217_o == 0)
            {
                statbase = StatList.objectCraftStats[j];
                statbase1 = StatList.objectCraftStats[k];
            }
            else if (StatsBlock.this.field_148217_o == 1)
            {
                statbase = StatList.objectUseStats[j];
                statbase1 = StatList.objectUseStats[k];
            }

            if (statbase != null || statbase1 != null)
            {
                if (statbase == null)
                {
                    return 1;
                }

                if (statbase1 == null)
                {
                    return -1;
                }

                int l = GuiStats.this.field_146546_t.readStat(statbase);
                int i1 = GuiStats.this.field_146546_t.readStat(statbase1);

                if (l != i1)
                {
                    return (l - i1) * StatsBlock.this.field_148215_p;
                }
            }

            return j - k;
        }
    };
}
 
Example 15
Project: Backmemed   File: ItemModelMesher.java   Source Code and License Vote up 4 votes
private int getIndex(Item item, int meta)
{
    return Item.getIdFromItem(item) << 16 | meta;
}