Jump to content

Recommended Posts

Posted (edited)

I am trying to make a command to open a crafting table gui, when i run the command, it crashes the server. here is the code i have for the command:
 

@Override
    public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
        if (src instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) src;
            player.displayGui(new BlockWorkbench.InterfaceCraftingTable(player.worldObj, player.playerLocation));
            player.addStat(StatList.CRAFTING_TABLE_INTERACTION);

        } else {
            src.sendMessage(Text.of(TextColors.RED, "Must be a player to run this command"));
        }
        return CommandResult.success();
    }

and this is the error it sends to the logs:
 

Spoiler

2017-11-12 07:10:10 | [nucleus]: Elrol_Arrowsend ran the command: /wb 
2017-11-12 07:10:10 | [ERROR] Encountered an unexpected exception
2017-11-12 07:10:10 | [RAW] net.minecraft.util.ReportedException: Ticking player
2017-11-12 07:10:10 | [RAW]     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:715) ~[MinecraftServer.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:387) ~[ld.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:613) ~[MinecraftServer.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:471) [MinecraftServer.class:?]
2017-11-12 07:10:10 | [RAW]     at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
2017-11-12 07:10:10 | [RAW] Caused by: java.lang.NullPointerException
2017-11-12 07:10:10 | [RAW]     at net.minecraft.world.WorldServer.func_180495_p(WorldServer.java:3091) ~[ls.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.inventory.ContainerWorkbench.func_75145_c(SourceFile:74) ~[abm.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.entity.player.EntityPlayerMP.func_70071_h_(EntityPlayerMP.java:256) ~[lu.class:?]
2017-11-12 07:10:10 | [RAW]     at org.spongepowered.common.event.tracking.TrackingUtil.tickEntity(TrackingUtil.java:159) ~[TrackingUtil.class:1.10.2-2281-5.2.0-BETA-2424]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.world.WorldServer.redirect$onCallEntityUpdate$zka000(WorldServer.java:2843) ~[ls.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.world.World.func_72866_a(World.java:4072) ~[aid.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:839) ~[ls.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.world.World.func_72870_g(World.java:1934) ~[aid.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.world.WorldServer.func_184147_l(WorldServer.java:649) ~[ls.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.world.World.func_72939_s(World.java:5981) ~[aid.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:2185) ~[ls.class:?]
2017-11-12 07:10:10 | [RAW]     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:709) ~[MinecraftServer.class:?]
2017-11-12 07:10:10 | [RAW]     ... 4 more
2017-11-12 07:10:10 # server crashed for unknown reason, restarting...

If you can tell me what im doing wrong that would help. I know that the crash was caused by the world object being null, but how is that possible when i take it right from the player? The code i am using to open the gui is the same as the way minecraft does it when a player activates the crafting bench. I am assuming there is a better way to do it, but I am not sure what it would be.

Edited by Elrol_Arrowsend
Posted (edited)

Ok, well good to know about the playerLocation, that explains alot really. Ok thanks for the help, i will see what i can do.

well now i have the command place a crafting table at 0, 1, 0 and it opened the gui for a split second. the issue is that now its too far away that the player cant open it, there is only one way i can think of getting it to work, and that is to set a block around them to the crafting table and when they close the ui to remove the table, is there a better way to do it without having players need the mod too?

 

Edited by Elrol_Arrowsend

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.