Jump to content

[1.7.10] Enchantment-Based Bow Modifications


wundrweapon

Recommended Posts

Hello!

In the current state of my mod, the bow has two new enchantments. Unfortunately, I have no idea how to make them work. So here's my questions:

 

1) How would I go about making an arrow that is programmatically equal to EntityArrow, but with no effect of gravity?

2) How can I make the bow fire this anti-gravity arrow only if the bow has a specific enchantment?

3) Is it possible to make an arrow not go through it's trajectory, but instead end up exactly where it would end up going? What I mean is, when i fire the arrow, I want it to instantly land where it would have landed had I fired normally, but still deal the amount of damage it normally would have on that specific shot.

3.1) If so, how?

3.2) If not, what's the best way to feign this effect?

4) How would I make this special shot only occur when a specific enchantment is on the bow?

 

Thanks for the assistance!

Link to comment
Share on other sites

First you would need to go through and and basically copy EntityArrow but you would have to make the edits for gravity yourself there is a way to check if an ItemStack has an enchantment and the instantly hit you could use MovingObjectPosition to get the coords.

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

1) Extend EntityArrow and override is onUpdate method

2) Should be an event for it, check the Bow class, if not you could wait for an EntityConstructed event, if it's an arrow, and the owner/firer is the player and the equipped bow has the enchantment, replace the entity being constructed.

3) Probably? You'd have to migrate all of the onUpdate code to a separate function, then in onUpdate call that function until the arrow collides with something

4) See #1, #2

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1) Extend EntityArrow and override is onUpdate method

2) Should be an event for it, check the Bow class, if not you could wait for an EntityConstructed event, if it's an arrow, and the owner/firer is the player and the equipped bow has the enchantment, replace the entity being constructed.

3) Probably? You'd have to migrate all of the onUpdate code to a separate function, then in onUpdate call that function until the arrow collides with something

4) See #1, #2

 

Do you think this would work to disable gravity with that method?

motionX = 0;
motionY = 0;
motionZ = 0;
rotationPitch = 0;
rotationYaw = 0;
prevRotationPitch = 0;
prevRotationYaw = 0;
setRotation(rotationPitch, rotationYaw);

2) What and where is the event for EntityConstructed? Google didn't really bring up anything, and ItemBow didn't seem to have anything useful (just ArrowLooseEvent, but I don't see how I'd use it's constructor in this sense)

3) I don't really understand - wouldn't that just take the same amount of time, since onUpdate is ultimately called at an equal rate?

4) Oh. Duhr, can't believe I didn't see that

Link to comment
Share on other sites

EntityConstructedEvent is a forge hook. Event Handlers Cool Alias's tutorial http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-forge-1-6-4-1-8-eventhandler-and That will not work that would set all motion to 0 and change the the rotation to 0. Look into ItemBow there are two events called there.

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

Do you think this would work to disable gravity with that method?

motionX = 0;
motionY = 0;
motionZ = 0;
rotationPitch = 0;
rotationYaw = 0;
prevRotationPitch = 0;
prevRotationYaw = 0;
setRotation(rotationPitch, rotationYaw);

 

No, that would prevent all motion.  You need to copy the existing onUpdate method and remove the alterations it makes to motionY to account for gravity.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

EntityConstructedEvent is a forge hook. Event Handlers Cool Alias's tutorial http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-forge-1-6-4-1-8-eventhandler-and That will not work that would set all motion to 0 and change the the rotation to 0. Look into ItemBow there are two events called there.

 

Ah, OK. Thanks for the assist, I'm fairly certain this will help

 

Do you think this would work to disable gravity with that method?

motionX = 0;
motionY = 0;
motionZ = 0;
rotationPitch = 0;
rotationYaw = 0;
prevRotationPitch = 0;
prevRotationYaw = 0;
setRotation(rotationPitch, rotationYaw);

 

No, that would prevent all motion.  You need to copy the existing onUpdate method and remove the alterations it makes to motionY to account for gravity.

 

Oh, I can't believe I didn't see that :P

I'll do what you said though

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.

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.