English 中文(简体)
使用命令项时Minecraft崩溃
原标题:Minecraft Crashes when Using Command Item

我在我的mod中包含了一个简单的项目,当它在实体上使用时,应该会导致游戏运行由其名称指定的命令,以下是代码:

        public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity entity, Hand hand) {
        if(user.getItemCooldownManager().getCooldownProgress(this, 0) == 0){
            //user.getWorld().getServer().getCommandManager().executeWithPrefix(user.getServer().getCommandSource(), stack.getName().toString());
            user.getWorld().getServer().getCommandManager().execute(user.getWorld().getServer().getCommandManager().getDispatcher().parse(stack.getName().toString(), user.getServer().getCommandSource()), stack.getName().toString());
            //user.sendMessage(stack.getName());

            user.getItemCooldownManager().set(this, 40);
        }

        return super.useOnEntity(stack, user, entity, hand);
    }

我已经尝试了注释和未注释的代码,当我在暴民上使用该项目时,两者都会导致相同的结果,游戏崩溃并出现错误:

Execution failed for task :runClient . Process command C:Program Filesuluzulu-17injava.exe finished with non-zero exit value -1

我真的不明白,似乎是说它无法运行客户端,但客户端确实运行了,只是在我使用该项时崩溃了。


更新:

在遵循mineblock的建议后,使用“Minecraft客户端”配置,错误已更改为无法调用“net.Minecraft.server.MinecraftServer.getCommandManager()”,因为“net.Minecraft.world.world.getServer()”的返回值为null。这是由我的代码调用user.getWorld().getServer()引起的。

当我把它改为user.getServer()时,它说。。。“net.minecraft.entity.player.PlayerEntity.getServer()”为空

简而言之,如果我不能使用user.getServer(),也不能使用world.getServer我能用什么?

问题回答

引起原因:com.mojang.authlib.exceptions.MinecraftClientHttpException:状态:401

这个错误是无害的,它只是告诉你你没有登录游戏,因为你处于开发环境中——你可以忽略它。


任务的执行失败:runClient。进程命令C:程序文件uluzulu-17在java.exe中以非零退出值-1结束

您应该使用IDE的运行配置。在IntelliJ IDEA和Eclipse中,您应该运行“Minecraft Client”配置。

您的代码与此错误无关。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签