Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How do I make something happen when I use my item when not looking at a block?
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
mooL

How do I make something happen when I use my item when not looking at a block?

By mooL, July 25, 2016 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

mooL    0

mooL

mooL    0

  • Tree Puncher
  • mooL
  • Members
  • 0
  • 21 posts
Posted July 25, 2016

is there a method like onItemRightClick but only runs when im not looking at a block?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7696

diesieben07

diesieben07    7696

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7696
  • 56376 posts
Posted July 25, 2016

Sounds like you want PlayerInteractEvent.

  • Quote

Share this post


Link to post
Share on other sites

mooL    0

mooL

mooL    0

  • Tree Puncher
  • mooL
  • Members
  • 0
  • 21 posts
Posted July 25, 2016

Sounds like you want PlayerInteractEvent.

 

so i looked at the class file of it, im not too sure how to use it. would this be correct?

 

public PlayerInteractEvent(EntityPlayer player, Action action, BlockPos pos, EnumFacing face, World world){
if (action == RIGHT_CLICK_AIR) {
	//code
}
}

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7696

diesieben07

diesieben07    7696

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7696
  • 56376 posts
Posted July 25, 2016

Look up a tutorial on how to use forge events.

  • Quote

Share this post


Link to post
Share on other sites

mooL    0

mooL

mooL    0

  • Tree Puncher
  • mooL
  • Members
  • 0
  • 21 posts
Posted July 25, 2016

Look up a tutorial on how to use forge events.

 

wow thanks for answering my short question...

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7696

diesieben07

diesieben07    7696

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7696
  • 56376 posts
Posted July 26, 2016

Well, if you want to be pedantic: The answer is no, thats not how to do it.

  • Quote

Share this post


Link to post
Share on other sites

coolAlias    746

coolAlias

coolAlias    746

  • Reality Controller
  • coolAlias
  • Members
  • 746
  • 2805 posts
Posted July 26, 2016

I have a vague memory of #onItemUse being the method called when you right-click on a block, and #onItemRightClick being called only when you clicked in the air... but it's been more than 6 months since I've messed with it, so I could be completely mis-remembering that.

 

But, if it's not your Item class but someone else's (e.g. vanilla item), then yeah, diesieben is right - use PlayerInteractEvent. There are lots of event tutorials online that cover how to do it in detail, more detail than anyone would want to type here.

  • Quote

width=228 height=100http://i.imgur.com/NdrFdld.png[/img]

Share this post


Link to post
Share on other sites

jeffryfisher    183

jeffryfisher

jeffryfisher    183

  • World Shaper
  • jeffryfisher
  • Members
  • 183
  • 1283 posts
Posted July 27, 2016

Food items can be used without acting upon a block, so what path do they take? Using the debugger, try to trace the execution path of a vanilla food item being eaten.

  • Quote

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • JayNeedsHelp
      Logger not working

      By JayNeedsHelp · Posted 16 minutes ago

      So I'm currently creating a forge mod and I'm having an issue where the console stops logging after some errors. It seems to be connected to the access transformers that I'm using as before I added at's my console was working fine.   Here is my at file:  public-f net.minecraft.client.Minecraft session public net.minecraft.client.Minecraft timer public net.minecraft.client.gui.GuiScreen buttonList public net.minecraft.util.Timer tickLength public net.minecraft.network.play.client.CPacketPlayer onGround public net.minecraft.network.play.server.SPacketEntityVelocity motionX public net.minecraft.network.play.server.SPacketEntityVelocity motionY public net.minecraft.network.play.server.SPacketEntityVelocity motionZ public net.minecraft.network.play.server.SPacketExplosion motionX public net.minecraft.network.play.server.SPacketExplosion motionY public net.minecraft.network.play.server.SPacketExplosion motionZ public net.minecraft.client.renderer.entity.RenderManager renderPosX public net.minecraft.client.renderer.entity.RenderManager renderPosY public net.minecraft.client.renderer.entity.RenderManager renderPosZ   Any help is greatly appreciated thank you!
    • cadbane86140
      Minecraft: Hunger Games Game #36- Shear FIGHT!

      By cadbane86140 · Posted 1 hour ago

      Hello There! Today we are back on Hunger Games after a little break but we are finally back! In this episode we are on the good ol' map Survival Games 4 and it ACTUALLY went well for once. Also we have so many great battles on rooftops, small rooms and just out in the open! We also use shears to fight at one point and that was pretty crazy! There are so many hilarious moments in this episode that I know you guys are gonna love! I hope you all enjoy this video and if you did don't forget to like and sub for more Hunger Games in the future!  
    • Sad Whale
      Game crashes whenever I try to increase the RAM

      By Sad Whale · Posted 1 hour ago

      latest.log
    • diesieben07
      Game crashes whenever I try to increase the RAM

      By diesieben07 · Posted 2 hours ago

      In the logs folder of your game directory.
    • Unusualty
      GUI'S and player editing

      By Unusualty · Posted 2 hours ago

      So I'm trying to make a mod that is inspired by Origin's because this mod isn't for forge I was wondering if anyone can help me do something like this where you get a GUI when you join the world where you can select a race that has abilities and down sides to them, I also want to have classes but first I want these race's done so if anyone can help this would be appreciated.
  • Topics

    • JayNeedsHelp
      0
      Logger not working

      By JayNeedsHelp
      Started 17 minutes ago

    • cadbane86140
      0
      Minecraft: Hunger Games Game #36- Shear FIGHT!

      By cadbane86140
      Started 1 hour ago

    • Sad Whale
      6
      Game crashes whenever I try to increase the RAM

      By Sad Whale
      Started 3 hours ago

    • Unusualty
      0
      GUI'S and player editing

      By Unusualty
      Started 2 hours ago

    • fluiX
      1
      server wont start

      By fluiX
      Started 3 hours ago

  • Who's Online (See full list)

    • Chumbanotz
    • _Traficantefav_
    • Lyon
    • JayNeedsHelp
    • PyRoTheLifeLess
    • Beethoven92
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How do I make something happen when I use my item when not looking at a block?
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community