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