.pushmode config {Minecraft: removing 4 tick mining delay} ||| title {14 May 2020} ||| published {26 May 2022} ||| modified .popmode config Every once in a while I return to playing Minecraft. One thing I always tend to do is removing a 4-tick delay between mining blocks. Usually there should be 20 ticks per second, meaning there's 50ms between ticks. So after breaking a block, there is a 200ms delay before the next block will start to be mined. Since I usually spend most of my time mining, this delay frustrates me quite a bit. Even if you have a pickaxe that breaks a block as good as instantly, you'd still have to wait for those annoying 200ms {for every block}. ||| em .pushmode section {Index} ||| h id=index {} ||| index .popmode section .pushmode section {Finding the class to modify} ||| h id=findingtheclass Years ago, in a previous life, I used MCP (which stood for Minecraft Coder Pack) to decompile minecraft. There I found how to remove the delay, by setting the {blockHitDelay} to {0} in {PlayerControllerMP#onPlayerDamageBlock}. It usually ||| code,code,code takes a while for MCP to get updated for newer versions, and nowadays I don't even try to find updated version anymore since at some point it started to get impossible to find them (at this point maybe it even doesn't exist anymore). So the way I've been doing it now is to find the class, edit the value and recompile it. Then attach a debugger to the running JVM instance and hot-swap the class. To begin, we would need to find the class. Most identifiers are usually minified, so this can be done by searching for a pattern. I saw this code in the (older versions) of the class we need, and thought maybe the { 4.5} ||| code value would be easy to find. .pushmode pre public float getBlockReachDistance() { return !creativeMode ? 4.5F : 5F; } .popmode pre {The JVM specs for CONSTANT_Float_info structure} tells us that a float constant ||| a class=ext href=https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.4 consists of a byte with value {4}, followed by the float value in IEEE-754 ||| code format, big endian. So, find the jar (in my case {%APPDATA%\.minecraft\versions\20w20b\20w20b.jar}), extract it somewhere ||| code and grep for our pattern. .pushmode pre $ find . -name "*.class" | xargs grep -obUaP "\x04\x40\x90\x00\x00" ./azg.class:2765:@P ./dls$a.class:1083:@P ./dvt.class:348:@P ./dwx.class:591:@P ./dxn.class:1969:@P ./ebd$m.class:1185:@P ./efs.class:277:@P ./eik.class:724:@P .popmode pre There aren't too many matches, so it's doable to go through every one of them with your favorite decompiler and see if it's the target class. In {dxn.class} I found following method which sort of looks like the ||| code {getBlockReachDistance()} method we're trying to find. ||| code .pushmode pre public float c() { return this.j.e() ? 5.0F : 4.5F; } .popmode pre So this is the class that we need and will modify and hot-swap. .popmode section .pushmode section {Modifying the class to remove the delay and compiling} ||| h id=modifytheclass Copy the contents of that class file and copy it into a source file in a project in your favorite IDE, with the same name. One method up is this method: .pushmode pre public boolean b(ft var1, fy var2) { this.n(); if (this.h > 0) { --this.h; return true; } else { cel var3; (..) .popmode pre That {if} is checking the block hit delay, so I put this line above the {if} ||| code,code to get rid of the block hit delay. .pushmode pre this.h = 0; .popmode pre To compile the file you probably need to link the jar and some libraries, which can usually be found in {%APPDATA%\.minecraft\libraries}. I used ||| code Fernflower to decompile and had to fix some usages of an enum. For some reason it added an import for {rz.a} but the compiler wasn't accepting it, so I ||| code removed the import and replace all usages of the enum type {a} in method ||| code parameters with {rz.a}. ||| code .popmode section .pushmode section {Launching Minecraft with debug and hotswapping} ||| h id=launch The next step is to add some arguments to Minecraft to enable debugging, it doesn't seem too hard to do with the new launcher. I added following arguments: .pushmode pre -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1052 .popmode pre Then simply launch the game, attach the debugger of your favorite IDE and hot-swap the class. .popmode section