Jump to content

[1.15.2] Summon Fireball on Item Use


jaxbymc42

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

9 minutes ago, jaxbymc42 said:

(Is this enough info? (I'm sorry!))

Did you read my entire post. I told you what was immediately wrong.

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 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.



×
×
  • Create New...

Important Information

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