Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

LiquidBounce Forum

  1. Home
  2. ScriptAPI
  3. Help writing a custom prison mining script

Help writing a custom prison mining script

Scheduled Pinned Locked Moved ScriptAPI
21 Posts 8 Posters 5.4k Views 1 Watching
  • 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.
  • P Paranoid_breS

    Is there any more tutorials on the script API (other than https://liquidbounce.net/docs/ScriptAPI/Getting Started)? And the Minecraft docs (https://scriptapi.liquidbounce.net/) are a bit confusing to me, I only know how to use mc.thePlayer and that's it.

    For the mining script I need:
    -A way to path find from /mine to the mining location
    -A 'legit' mining mode (I know how to activate modules via script so I might just use nuker)
    -Check if inventory is full
    -Path finding to the 'Sell' NPC or using the /store menu to sell ore and blocks
    -Fix broken tools by going to another warp and interacting with an NCP
    -Upgrade tools (there's a special plugin in the server for upgrading tools with custom enchants)
    -Read /bal and then /rankup when possible
    -Detect if players are nearby, stop and go to /cell if anyone is nearby
    -Delayed /cell and logout if staff are seen online with /staff
    -And repeat

    I'm not asking anyone to write the script, just asking if there are any resources on writing more world involved scripts. Most scripts I've seen were PVP based so I don't have much experience in custom mining scripts.

    exit scammedE Offline
    exit scammedE Offline
    exit scammed
    wrote on last edited by
    #4

    @paranoid_bres you can try Impact client, it has Baritone that can do 1/2 of your requests

    1 Reply Last reply
    1
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #5

      you can't

      1 Reply Last reply
      0
      • C Offline
        C Offline
        commandblock2
        wrote on last edited by
        #6

        A way to path find from /mine to the mining location

        This could be a bit much work to do. U might have to write a path finding algorithm like A*. However I do have a A* in my reachaura branch. Could be hell if u try to write it in js.

        A 'legit' mining mode (I know how to activate modules via script so I might just use nuker)

        Look for RotationUtils.faceBlock method in Nuker.kt in LB's src (cross_version here), it would be a bit different with/without cross_version.

        Check if inventory is full

        Maybe look at the inventory related module of LB and Hek's InventoryManger. Shouldn't be as hard as A*.

        Interact/Right Click NPC

        There is a packet for that and u can find the usage in KillAura.kt.

        Text related operation

        https://github.com/CzechHek/Core/blob/master/Scripts/Deprecated/BasicLogin.js

        P 1 Reply Last reply
        3
        • C commandblock2

          A way to path find from /mine to the mining location

          This could be a bit much work to do. U might have to write a path finding algorithm like A*. However I do have a A* in my reachaura branch. Could be hell if u try to write it in js.

          A 'legit' mining mode (I know how to activate modules via script so I might just use nuker)

          Look for RotationUtils.faceBlock method in Nuker.kt in LB's src (cross_version here), it would be a bit different with/without cross_version.

          Check if inventory is full

          Maybe look at the inventory related module of LB and Hek's InventoryManger. Shouldn't be as hard as A*.

          Interact/Right Click NPC

          There is a packet for that and u can find the usage in KillAura.kt.

          Text related operation

          https://github.com/CzechHek/Core/blob/master/Scripts/Deprecated/BasicLogin.js

          P Offline
          P Offline
          Paranoid_breS
          wrote on last edited by
          #7

          @commandblock2 , thanks for the info. Doesn't Minecraft have built in pathfinding ? I saw that the Minecraft java docs have methods for path finding to a x,y,z position and path finding to an entity. Isn't there a way to already use what's built into the game ?

          yorik100Y C 2 Replies Last reply
          0
          • ruado_VnR Offline
            ruado_VnR Offline
            ruado_Vn
            wrote on last edited by
            #8

            @paranoid_bres btw download liquidbounce from github and then try to learn how the code like mc.thePlayer or others work

            1 Reply Last reply
            0
            • P Paranoid_breS

              @commandblock2 , thanks for the info. Doesn't Minecraft have built in pathfinding ? I saw that the Minecraft java docs have methods for path finding to a x,y,z position and path finding to an entity. Isn't there a way to already use what's built into the game ?

              yorik100Y Offline
              yorik100Y Offline
              yorik100
              wrote on last edited by
              #9

              @paranoid_bres minecraft's pathfinder is literally running into blocks

              1 Reply Last reply
              0
              • P Paranoid_breS

                @commandblock2 , thanks for the info. Doesn't Minecraft have built in pathfinding ? I saw that the Minecraft java docs have methods for path finding to a x,y,z position and path finding to an entity. Isn't there a way to already use what's built into the game ?

                C Offline
                C Offline
                commandblock2
                wrote on last edited by commandblock2
                #10

                @paranoid_bres Indeed there is a builtin pathfinding for minecraft (net.minecraft.pathfinding), but it seemed that it only has the behavior for Climber/Ground/Swimmer things, mining might require a different one which can navigate through stones. But you do remind me that you can just inherit the net.minecraft.pathfinding.PathNavigate and might be less work. Btw it is generally recommended to have a copy of mcp or do gradlew setupDecompWorkspace in LB's repo and attach the src to the project.
                Edit: I didn't know it runs into blocks

                1 Reply Last reply
                3
                • P Offline
                  P Offline
                  Paranoid_breS
                  wrote on last edited by
                  #11

                  The path finding doesn't have to be state of the art, most mines require you to go forward from the /mine starting point or they require you to climb up some stairs.

                  And for actual mining, we can use the nuker module. Or somehow implement a dead simple 'legit' mining mode which just goes forward and mines then turns left or right until it hits an unbreakable wall.

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Paranoid_breS
                    wrote on last edited by
                    #12

                    I wrote the 'path finding' part of the script. The mining location isn't hard to get to from the /mine warp. So I wrote this:

                    if (!IsAtMineLocation) { //Todo: Destination X,Z and rotation yaw will be read from a .ini file
                    		mc.thePlayer.rotationYaw = 0;
                    		if (mc.thePlayer.posX >= -2) 
                    			mc.thePlayer.moveEntityWithHeading(-0.5,0);
                    		if (mc.thePlayer.posZ <= 30) 
                    			mc.thePlayer.moveEntityWithHeading(0,0.8);
                    		if (Math.round(mc.thePlayer.posZ) == 30 && 
                    			Math.round(mc.thePlayer.posX) == -2)
                    			IsAtMineLocation = true;
                    	}	
                    
                    yorik100Y 1 Reply Last reply
                    0
                    • P Paranoid_breS

                      I wrote the 'path finding' part of the script. The mining location isn't hard to get to from the /mine warp. So I wrote this:

                      if (!IsAtMineLocation) { //Todo: Destination X,Z and rotation yaw will be read from a .ini file
                      		mc.thePlayer.rotationYaw = 0;
                      		if (mc.thePlayer.posX >= -2) 
                      			mc.thePlayer.moveEntityWithHeading(-0.5,0);
                      		if (mc.thePlayer.posZ <= 30) 
                      			mc.thePlayer.moveEntityWithHeading(0,0.8);
                      		if (Math.round(mc.thePlayer.posZ) == 30 && 
                      			Math.round(mc.thePlayer.posX) == -2)
                      			IsAtMineLocation = true;
                      	}	
                      
                      yorik100Y Offline
                      yorik100Y Offline
                      yorik100
                      wrote on last edited by
                      #13

                      @paranoid_bres said in Help writing a custom prison mining script:

                      I wrote the 'path finding' part of the script. The mining location isn't hard to get to from the /mine warp. So I wrote this:

                      if (!IsAtMineLocation) { //Todo: Destination X,Z and rotation yaw will be read from a .ini file
                      		mc.thePlayer.rotationYaw = 0;
                      		if (mc.thePlayer.posX >= -2) 
                      			mc.thePlayer.moveEntityWithHeading(-0.5,0);
                      		if (mc.thePlayer.posZ <= 30) 
                      			mc.thePlayer.moveEntityWithHeading(0,0.8);
                      		if (Math.round(mc.thePlayer.posZ) == 30 && 
                      			Math.round(mc.thePlayer.posX) == -2)
                      			IsAtMineLocation = true;
                      	}	
                      

                      Interesting

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        Paranoid_breS
                        wrote on last edited by
                        #14

                        How do I interact with inventory ? I know that I can check if my inventory is full by doing :

                        mc.thePlayer.inventory.getFirstEmptyStack() == -1
                        

                        But how do I interact with opened chest/containers ? To sell blocks/items in the game, you have to type /shop and click on the blocks that you want to sell.

                        CzechHekC 1 Reply Last reply
                        0
                        • P Paranoid_breS

                          How do I interact with inventory ? I know that I can check if my inventory is full by doing :

                          mc.thePlayer.inventory.getFirstEmptyStack() == -1
                          

                          But how do I interact with opened chest/containers ? To sell blocks/items in the game, you have to type /shop and click on the blocks that you want to sell.

                          CzechHekC Offline
                          CzechHekC Offline
                          CzechHek
                          wrote on last edited by CzechHek
                          #15

                          @paranoid_bres You check if mc.currentScreen instanceof GuiChest and then you get what it contains in many ways such as mc.currentScreen.inventorySlots.getInventory()
                          mc.thePlayer.openContainer.getInventory() to get inventory + chest stacks

                          You can then interact with the stacks using mc.playerController.windowClick(int windowId, int slotId, int mouseButtonClicked, int mode, EntityPlayer playerIn), in order to find the right arguments you should debug what properties does C0EPacketClickWindow when you click legitimately.

                          Consider looking into src of LB modules like ChestStealer or into scripts such as InventoryManager as well.

                          P 1 Reply Last reply
                          0
                          • CzechHekC CzechHek

                            @paranoid_bres You check if mc.currentScreen instanceof GuiChest and then you get what it contains in many ways such as mc.currentScreen.inventorySlots.getInventory()
                            mc.thePlayer.openContainer.getInventory() to get inventory + chest stacks

                            You can then interact with the stacks using mc.playerController.windowClick(int windowId, int slotId, int mouseButtonClicked, int mode, EntityPlayer playerIn), in order to find the right arguments you should debug what properties does C0EPacketClickWindow when you click legitimately.

                            Consider looking into src of LB modules like ChestStealer or into scripts such as InventoryManager as well.

                            P Offline
                            P Offline
                            Paranoid_breS
                            wrote on last edited by
                            #16

                            @czechhek Thx, I've read your inventory manager script and found how to access the inventory. I've wrote this prototype code for testing purposes, and it works as expected.

                            if (mc.thePlayer.inventory.getFirstEmptyStack() == -1) {
                            		if (!(mc.currentScreen instanceof GuiChest))
                            			mc.thePlayer.sendChatMessage("/shop");
                            		else
                            			mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, 14, 0, 1, mc.thePlayer);
                            	}
                            
                            1 Reply Last reply
                            0
                            • P Offline
                              P Offline
                              Paranoid_breS
                              wrote on last edited by
                              #17

                              How do I get the number of players nearby, how do I get the names of the players nearby? And how to swing at/hit an entity nearby?

                              1 Reply Last reply
                              0
                              • P Offline
                                P Offline
                                Paranoid_breS
                                wrote on last edited by
                                #18

                                I figured out how to get the number of entity present using:

                                mc.theWorld.loadedEntityList.length
                                
                                CzechHekC 1 Reply Last reply
                                0
                                • ? Offline
                                  ? Offline
                                  A Former User
                                  wrote on last edited by
                                  #19
                                  for(int i = 1;i<= mc.theWorld.loadedEntityList.size();i++) {
                                  							EntityLivingBase entity = (EntityLivingBase) mc.theWorld.loadedEntityList.get(i);
                                  							System.out.print(entity.getName());
                                  						}
                                  

                                  java codes, but you can convert to javascript easily

                                  1 Reply Last reply
                                  0
                                  • P Paranoid_breS

                                    I figured out how to get the number of entity present using:

                                    mc.theWorld.loadedEntityList.length
                                    
                                    CzechHekC Offline
                                    CzechHekC Offline
                                    CzechHek
                                    wrote on last edited by CzechHek
                                    #20

                                    @paranoid_bres

                                    Java.from(mc.theWorld.playerEntities).filter(function (e) mc.thePlayer.getDistanceToEntity(e) < distance) ;
                                    
                                    1 Reply Last reply
                                    0
                                    • P Offline
                                      P Offline
                                      Paranoid_breS
                                      wrote on last edited by
                                      #21

                                      thx for the help

                                      1 Reply Last reply
                                      0
                                      Reply
                                      • Reply as topic
                                      Log in to reply
                                      • Oldest to Newest
                                      • Newest to Oldest
                                      • Most Votes


                                      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
                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups