Skip to content

Instantly share code, notes, and snippets.

@HatTrkPatrk
Created November 2, 2025 13:19
Show Gist options
  • Save HatTrkPatrk/20f1345c1a6acccef1b6cfb03aa7434e to your computer and use it in GitHub Desktop.
Save HatTrkPatrk/20f1345c1a6acccef1b6cfb03aa7434e to your computer and use it in GitHub Desktop.
public class NoFallDamage {
private static final Logger logger = Logger.getLogger(NoFallDamage.class.getName());
private static final double fallDamageModifier = 1.0;
public static void preinit() {
try {
ClassPool classPool = HookManager.getInstance().getClassPool();
CtClass ctMovementScheme = classPool.get("com.wurmonline.server.creatures.MovementScheme");
CtMethod ctHitGround = ctMovementScheme.getDeclaredMethod("hitGround", new CtClass[]{CtClass.floatType});
ctHitGround.instrument(new ExprEditor() {
@Override
public void edit(MethodCall m) throws CannotCompileException {
if (m.getClassName().equals("com.wurmonline.server.creatures.Creature") && m.getMethodName().equals("addWoundOfType")) {
m.replace(
"$7 *= " + fallDamageModifier + ";\n" +
"if ($7 <= 0)\n" +
"{\n" +
" $_ = false;\n" +
"}\n" +
"else\n" +
"{\n" +
" $_ = $proceed($$);\n" +
"}"
);
logger.info("Modified fall damage.");
}
}
});
} catch (NotFoundException | CannotCompileException e) {
logger.severe("Failed to apply NoFallDamage patch: " + e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment