CCBlueX Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    check how many blocks are in player inventory

    ScriptAPI
    2
    2
    121
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • skiddermaster412
      skiddermaster412 Banned last edited by

      i am new at javascript and i don't know much about it, so i want to check how many blocks are in theplayer inventory, i didn't find any related posts about this so yeah

      1 Reply Last reply Reply Quote 0
      • CzechHek
        CzechHek last edited by

        using dyskord.cc/Core

                count = 0;
                Java.from(mc.thePlayer.inventory.mainInventory).forEach(function (s) {s && s.getItem() instanceof ItemBlock && (count += s.stackSize)});
        //converts java array to js array and uses js function
        
                //for (i in mc.thePlayer.inventory.mainInventory) (stack = mc.thePlayer.inventory.mainInventory[i]) && stack.getItem() instanceof ItemBlock && (count += stack.stackSize);
        //alternative, cycles through java array via for function
        
                chat.print(count);
        
        1 Reply Last reply Reply Quote 2
        • First post
          Last post
        About
        • Terms of Service
        • Privacy Policy
        • Status
        • Contact Us
        Downloads
        • Releases
        • Source code
        • License
        Docs
        • Tutorials
        • CustomHUD
        • AutoSettings
        • ScriptAPI
        Community
        • Forum
        • Guilded
        • YouTube
        • Twitter
        • D.Tube