Jump to content

Recommended Posts

Posted

Whenever I right click a custom block I created, no matter what the action (Sysout, addChatMessage, etc.) it will run twice. I am trying to create a simple block that will open a custom crafting GUI upon right click, but it opens and closes when clicked on.

 

All I have in the method is 'p.displayerGUIWorkbench(0,0,0);'

 

Thanks in advance for your help.

Posted

It is firing once on the client, and once on the server.

 

You will need to add some world.isRemote checks and only run the action on the proper side. 

 

 

Also, I believe that the container workbench has some code in it to auto-close if the player is out of range of the workbench, which is set via the (0,0,0) you are passing in...so unless the player is standing at 0,0,0 or near to it, it will close shortly after opening.

 

vanilla workbench code that causes the closing in ContainerWorkbench:

    public boolean canInteractWith(EntityPlayer par1EntityPlayer)
    {
        return this.worldObj.getBlock(this.posX, this.posY, this.posZ) != Blocks.crafting_table ? false : par1EntityPlayer.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D;
    }

Posted

You can's use the displayGUIWorkbench, because some code in the ContainerWorkbench checks for a workbench at the location you specify, and if there isn't, you can't open the gui.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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.