Jump to content

[1.8] ask if gui is open (any gui) ?? <SOLVED>


perromercenary00

Recommended Posts

goo days

i been working in mi gun mods and have done something like an OnentityLeftClick method to use left click as if was a rigth click but left side

i make an ak200 fusil whith grenade launcher and set the grenadelauncher part to shoot or reload on entity left click, this causes, if i pause the game and enter to inventory

whith the gun selected and leftclick any slot or other item the gun shoots ad thas not good,

 

is there some where something like if(gui.isopen)    or  if(playerIn.hasGuiOpen) 

Link to comment
Share on other sites

Easy if you are on the client side:

if (Minecraft.getMinecraft().currentScreen != null)

But you shouldn't use that in an Item method - use MouseEvent to handle left clicking.

 

There is also EntityPlayer#openContainer, but I haven't found that to be as reliable as it seems to only account for Container-based GUIs (which the inventory is, so you may be fine).

Link to comment
Share on other sites

is an turn around from a turn around

 

i been doing

 

// ######################################################################################3

public void onUpdate(ItemStack pistola, World worldIn, Entity playerIn, int itemSlot, boolean isSelected)

{

if (isSelected)

                {

 

                        //only ask if in local world

    if (Mouse.isButtonDown(0) & !habilitado  & hacerAlgo & worldIn.isRemote)

    {

                        //send package to server informing of the leftclick action

                            Mercenary.network.sendToServer(new mensajeMercenarioalServidor("leftclick"));

                        }

 

                  }

          }

 

 

i set the gun way it shoots the normal 5.56munition on rigth click, but shoot the grenade launcher on left click, if you enter the inventory whith this gun in hand and accidentally press left click the grenade launcher shoots and bam you are death.

 

in this other gun is not so bad coz leftClick is the chainsaw it will only kill whaever you have in front when wnter in the inventory and accidentally press leftClick

Link to comment
Share on other sites

i make the trick whit  (Minecraft.getMinecraft().currentScreen == null)

 

 

// ######################################################################################3

    public void onUpdate(ItemStack pistola, World worldIn, Entity playerIn, int itemSlot, boolean isSelected)

    {

      if (isSelected)

      {

 

                        //only ask if in local world

            if (Mouse.isButtonDown(0) & !habilitado  & hacerAlgo & worldIn.isRemote)

            {

 

                        if (Minecraft.getMinecraft().currentScreen == null)

                        {

 

                        //send package to server informing of the leftclick action

                            Mercenary.network.sendToServer(new mensajeMercenarioalServidor("leftclick"));

                       

                        }

 

              }

          }

      }

 

Link to comment
Share on other sites

humm

how do you ask what proxy server is being used ??

That question doesn't make any sense... Have you used proxies before in modding? You should Google it.

 

Anyway, it's probably not necessary for your situation - often, you can just place the 'world.isRemote' as the first condition in your if statement before any client-side classes are accessed, and that will be enough to prevent the server from crashing.

 

There are situations where that is not sufficient, however, but in your case, I bet it will be.

Link to comment
Share on other sites

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.