-
-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Scripting APIs undefined #1811
Comments
Looking into it now. |
const script = registerScript({
name: "MyScript",
version: "1.0.0",
authors: ["My Name"]
});
script.registerModule({
name: "SpeedModule",
category: "Misc",
description: "An example module created with LiquidBounce's script API."
}, function (module) {
module.on("enable", function() {
client.displayChatMessage("§aHallo - du solltest funktionieren.");
});
module.on("disable", function() {
client.displayChatMessage("§cTschüss - du solltest nicht mehr funktionieren.");
});
module.on("playerTick", function(event) {
if (movementUtil.moving()) {
movementUtil.strafeWithSpeed(0.3);
}
const speed = movementUtil.speed();
client.displayChatMessage(speed.toString());
// add velocity
if (mc.player.onGround) {
mc.player.jump();
client.displayChatMessage("jump! :)");
} else if (mc.player.velocity.y < 0) {
mc.player.addVelocity(new Vec3d(0.0, 0.0002, 0.0));
} else {
mc.player.velocity.y -= 0.1;
}
});
}); It works well. :) |
Thanks, the API is working now. But in your script, the line
|
It looks like it worked in your screenshot but for me it seems some things under player is undefined. It doesn't jump for me (nor print the jump message) and Random guess but maybe it's due to mappings? |
Yes it might be. I actually tested on the dev environment, instead of the release version, so it's likely something with the remapper. |
It seems the remapper we can access the field of MinecraftClient.player in the remapped name, however after this, we cannot access Entity.onGround, but we can access ClientPlayerEntity.lastOnGround const script = registerScript({
name: "MyScript",
version: "1.0.0",
authors: ["My Name"]
});
script.registerModule({
name: "SpeedModule",
category: "Misc",
description: "An example module created with LiquidBounce's script API."
}, function (module) {
module.on("enable", function() {
client.displayChatMessage("§aHallo - du solltest funktionieren.");
//client.displayChatMessage(JSON.stringify(mc.player));
});
module.on("disable", function() {
client.displayChatMessage("§cTschüss - du solltest nicht mehr funktionieren.");
});
module.on("playerTick", function(event) {
if (movementUtil.moving()) {
movementUtil.strafeWithSpeed(0.3);
}
const speed = movementUtil.speed();
client.displayChatMessage(speed.toString());
client.displayChatMessage(typeof mc.player);
client.displayChatMessage(typeof mc);
client.displayChatMessage(typeof mc.player.onGround);
client.displayChatMessage(typeof mc.player.aJ);
client.displayChatMessage(typeof mc.player.field_5952);
client.displayChatMessage(typeof mc.player.lastOnGround);
});
}); I will further debug on what is exactly going on, but since we cannot even access the obfuscated name of it, this means it is likely being remapped, however something else goes wrong. |
So, my guess is the Remapper does not really function as intended. However we can write a better one by injection into Members, which collects all methods and fields of an class and translate there. |
It is now fixed. |
Thanks, but I can't use the mapped names with reflection, is this a bug?
|
Oh, I missed this! Please create another issue, since this was closed now. Yes, I forgot about remapping the input of the reflection util. Otherwise use the GraalJS var BigDecimal = Java.type('java.math.BigDecimal');
var point1 = new BigDecimal("0.1");
var two = BigDecimal.TWO;
console.log(point1.multiply(two).toString()); |
LiquidBounce Branch
Nextgen
LiquidBounce Build/Version
96f3064
Operating System
Linux
Minecraft Version
1.20.4
Describe the bug
Not sure if anyone saw my comment at #1552 (comment), so I'm moving this to an issue:
Steps to reproduce
Try to use one of the scripting APIs, like so:
Client Log
Screenshots
No response
The text was updated successfully, but these errors were encountered: