Help writing a custom prison mining script
-
@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