Help writing a custom prison mining script
-
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 inNuker.kt
in LB's src (cross_version
here), it would be a bit different with/withoutcross_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
-
@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 ?
-
@paranoid_bres btw download liquidbounce from github and then try to learn how the code like mc.thePlayer or others work
-
@paranoid_bres minecraft's pathfinder is literally running into blocks
-
@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 thenet.minecraft.pathfinding.PathNavigate
and might be less work. Btw it is generally recommended to have a copy of mcp or dogradlew setupDecompWorkspace
in LB's repo and attach the src to the project.
Edit: I didn't know it runs into blocks -
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.
-
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; }
-
@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
-
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.
-
@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 stacksYou 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.
-
@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); }
-
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?
-
I figured out how to get the number of entity present using:
mc.theWorld.loadedEntityList.length
-
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
-
Java.from(mc.theWorld.playerEntities).filter(function (e) mc.thePlayer.getDistanceToEntity(e) < distance) ;
-
thx for the help