我的世界 JavaScript 错误
我正在尝试制作一个使用单人命令为我的世界绘制圆圈的脚本。首先,我尝试做基础工作;这是我的代码:
importPackage(Packages.com.sk89q.worldedit.blocks);
importPackage(Packages.com.sk89q.worldedit);
var sess = context.remember();
var playerBlock = player.getBlockOn();
var other = playerBlock.setY(playerBlock.getY + 1);
sess.setBlock(other, new BaseBlock(BlockID.CLOTH, argv[1]));
但是当我运行它时,它说:
无法执行: Java 构造函数 setY 匹配 JavaScript 参数类型(字符串)的选择不明确;候选构造函数是: C:\Users\Darcy\AppData\Roaming 中的 class com.sk89q.worldedit.Vector setY(int) (C:\Users\Darcy\AppData\Roaming.minecraft\craftscripts\circle.js#6)。 minecraft\craftscripts\circle.js 在第 6 行
有什么建议吗?
I am trying to make a script that draws a circle for minecraft using singleplayer commands. For starting, I tried to do the basics; here is my code:
importPackage(Packages.com.sk89q.worldedit.blocks);
importPackage(Packages.com.sk89q.worldedit);
var sess = context.remember();
var playerBlock = player.getBlockOn();
var other = playerBlock.setY(playerBlock.getY + 1);
sess.setBlock(other, new BaseBlock(BlockID.CLOTH, argv[1]));
But when I run it, it says:
Failed to execute:
The choice of Java constructor setY matching JavaScript argument types (string) is ambiguous; candidate constructors are: class com.sk89q.worldedit.Vector setY(int) (C:\Users\Darcy\AppData\Roaming.minecraft\craftscripts\circle.js#6) in C:\Users\Darcy\AppData\Roaming.minecraft\craftscripts\circle.js at line nuber 6
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来
playerBlock.getY
是一个函数,您应该传递其结果。现在您传递函数本身(它被转换为其源代码,即字符串)。It seems
playerBlock.getY
is a function, the result of which you should pass. Now you pass the function itself (which gets converted to it's source code, i.e. a string).