Jump to content

Gun Firing Issues


Recommended Posts

I am trying to create a gun (I'm using forge for 1.8.9) and I'm running into some issues relating to firing methods. There are three different ways I have tried doing it:

1. Just firing bullets in the onItemRightClick method. Disadvantage: this method gets called MUCH less frequently than regular ticks, so guns fire very slowly

2. Firing bullets in the onUsingTick method. Disadvantage: since I'm modifying the NBT of  the item, this method has very odd behavior and causes the gun to never stop firing

3. Checking for key presses in the onUdpate method. Disadvantage: doesn't work on servers.

Is there some solution or better method I'm not seeing?

Before you say that I need to learn java, I will have you know that I have completed an advanced java course from johns hopkins university with an A- average.

Thanks, and have a nice day and a smiley :)

Link to comment
Share on other sites

The fastest Minecraft can do anything is on a per-tick basis. Theoretically, someone might be able to right-click faster than once per tick and thus fire more bullets than any other method, but I haven't tested that. At worst, #onItemRightClick will be just as fast (or slow, depending on your perspective) as any of the tick methods.


You can, however, simulate faster than once-per-tick by spawning multiple bullets per click/tick with their position offset so that bullet 1 starts further away than bullet 2, e.g. by 1/2 to several block distances between each bullet. You could also give them slightly different trajectories to emulate 'spray' or not-quite-perfect accuracy (take a look at EntitySkeleton's ranged attack for an example).

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.

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.


  • Create New...

Important Information

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