So im trying to create a custom arrow for my mod. Problem is that when you shoot it the entity is in the middle of the air:
The last time I brought this problem up people said to have my arrow extend EntityArrow, which fixed that problem. But because I was always testing things in creative mode at the time I never noticed the new problem until now.
Turns out that when you use my bow/arrow in survival mode the arrow turns around and shoots the player. Or it just goes right into the player. Whether it turns around or not though the arrow manages to hit the player, thats the point im trying to make. So why is my arrow hitting the player? (probably something that im overlooking).
Although when It was extending entity there was no problem except for that render issue. Its only when It extends EntityArrow that I have the issue. And I know that It spawns in front of the player, because sometimes it does fire, its only when it's charged that it hits me. Like I charge the bow, It fires and immediately turns around and hits me.
This is increased each tick of the EntityArrow's existence until it hits something. More importantly, it is used to check how far away from the source (bow / player / skeleton, etc.) the arrow is.
In your custom arrow class, make a field that does the same thing (EntityArrow#ticksInAir is not visible, have to make your own). Increase each tick it is in the air -- look at EntityArrow#onUpdate for examples.
Then in this method:
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer p_70100_1_)
{
}
Check your air ticks counter and make sure it is more than a certain number. If it is, call the super method. If the counter is too low, do nothing.
You will need to test to determine what number works best. I'm thinking somewhere around 4.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Im just going to have my arrow extend the entity class and keep the arrow floating in midair problem. Its only like that for a short amount of time and its better than having the player shooting themselves.
So im trying to create a custom arrow for my mod. Problem is that when you shoot it the entity is in the middle of the air:
The last time I brought this problem up people said to have my arrow extend EntityArrow, which fixed that problem. But because I was always testing things in creative mode at the time I never noticed the new problem until now.
Turns out that when you use my bow/arrow in survival mode the arrow turns around and shoots the player. Or it just goes right into the player. Whether it turns around or not though the arrow manages to hit the player, thats the point im trying to make. So why is my arrow hitting the player? (probably something that im overlooking).
EntityChocolateArrow
Check the location of the spawned entity and the location with the vanilla bow/ arrow. My guess is that you are spawning it inside/behind the player.
Alternatively you could be determining the direction incorrectly, so it is starting in the right place, but going towards the player instead of away
If I helped you, please click the green up arrow.
Although when It was extending entity there was no problem except for that render issue. Its only when It extends EntityArrow that I have the issue. And I know that It spawns in front of the player, because sometimes it does fire, its only when it's charged that it hits me. Like I charge the bow, It fires and immediately turns around and hits me.
I dont think its a problem with the bow. Because when I shoot a regular arrow it works fine. It's only my custom arrow that has the problem.
You should spawn it in front of your player. That'll work.
Problem: I dont know how XD
EntityArrow has a field called
This is increased each tick of the EntityArrow's existence until it hits something. More importantly, it is used to check how far away from the source (bow / player / skeleton, etc.) the arrow is.
In your custom arrow class, make a field that does the same thing (EntityArrow#ticksInAir is not visible, have to make your own). Increase each tick it is in the air -- look at EntityArrow#onUpdate for examples.
Then in this method:
Check your air ticks counter and make sure it is more than a certain number. If it is, call the super method. If the counter is too low, do nothing.
You will need to test to determine what number works best. I'm thinking somewhere around 4.
Im just going to have my arrow extend the entity class and keep the arrow floating in midair problem. Its only like that for a short amount of time and its better than having the player shooting themselves.
Thanks for trying the help though.