Posted July 16, 201510 yr 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)
July 16, 201510 yr I think in this case you can better use the onItemUse Event. Its only fired on left click with the Item, so no wories about opengui stuff, equiped Itemstack checking etc. Projects: Discontinued: - N2ConfigAPI - Meachanical Crafting Table Latest: - CollectionUtils Coöperations: - InGameConfigManager
July 16, 201510 yr 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). http://i.imgur.com/NdrFdld.png[/img]
July 16, 201510 yr Author 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
July 16, 201510 yr Author 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")); } } } }
July 17, 201510 yr You'll want to make sure you are on the client BEFORE checking any Mouse or Keyboard states, and it would be even better if you checked that state through your proxy. As your code is now, it will crash a server. http://i.imgur.com/NdrFdld.png[/img]
July 17, 201510 yr 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. http://i.imgur.com/NdrFdld.png[/img]
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.