Jump to content

Recommended Posts

Posted

I have a custom wand that I would like to summon a fireball entity and shoot it like a Ghast on right click using ActionResultType onItemUse and then remove one durability from the item.  I have created a class and put together what I thought would work for this situation but I am currently lost on it.  Any help is appreciated and I feel bad for asking anything.  Thank you!  Here is the item class:  https://pastebin.com/0h9XLTYi

Posted (edited)
1 hour ago, jaxbymc42 said:

but I am currently lost on it.

Generally it helps if you give more information. What is it doing vs what you want it to do? The first thing I notice is you are using Item::onItemUse. Item::onItemUse is called when the player right clicks on a Block. Check out this video. It talks about the basic Item methods. You want Item::onItemRightClick

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

I want this item to shoot a fireball in the direction I am looking whenever I right click with the item, removing one durability on each use.  Currently, right clicking does absolutely nothing.  (Is this enough info? (I'm sorry!))

Posted

Okay, so I have changed a bunch of code and now the fireball shoots but only in one general direction (it varies a little bit on the direction every time I throw it).  The fireballs fly into the +X and +Z plane.  I don't understand raytracing very well as I haven't worked with it much up until this point.  https://pastebin.com/Xt9M3Rkd

Posted
2 minutes ago, jaxbymc42 said:

I don't understand raytracing very well

You don't need to understand ray tracing to do what you want to do. If you want a code example check out the GhastEntity::FireballAttackGoal::tick on lines 194-203

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted (edited)

I took your advice and now the item is working... kind of.  The only issue now is that it won't shoot in the y-range (up or down).  It only shoots straight out no matter how high or low I look. Basically, I used the code from GhastEntity like you had mentioned and targetted the PlayerEntity instead of the livingentity variable but with negative values so the fireball shot away from the player.  https://pastebin.com/Q9RwgBNf

Edited by jaxbymc42
Posted
1 hour ago, jaxbymc42 said:

I took your advice and now the item is working... kind of.  The only issue now is that it won't shoot in the y-range (up or down).  It only shoots straight out no matter how high or low I look. Basically, I used the code from GhastEntity like you had mentioned and targetted the PlayerEntity instead of the livingentity variable but with negative values so the fireball shot away from the player.  https://pastebin.com/Q9RwgBNf

This will always be -0.5 right?

Quote

double d3 = playerIn.getPosYHeight(0.5D) - (0.5D + playerIn.getPosYHeight(0.5D));

Sounds like you need to read the code to understand what it's doing instead of blindly copy-pasting it.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • 4 weeks later...

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.