Jump to content

Recommended Posts

Posted

In ItemBow, there's a bit that says:

 

ArrowLooseEvent event = new ArrowLooseEvent(player, bow, var6);

MinecraftForge.EVENT_BUS.post(event);

 

I'm trying to find the handler that handles this event. I tried looking through the call hierarchy, did a search within eclipse, even ran my mod in debug mode, but I could not find it. Does anyone know where it is or what it's called?

 

Essentially, I'm trying to make a custom arrow start out straight. For some reason, even with the same code as the normal bow/arrow, its angle is weird at first but then fixes itself in a couple seconds (if it makes it that far). Also, shooting a normal arrow with my modified bow works just fine, so I'm guessing it's something in the arrow entity class. So, I wrote this method to fix it and call it right after it's fired, but it doesn't seem to make any changes whatsoever.

 

public void setAngles(Vec3 v)
{
double x = v.xCoord;
double y = v.yCoord;
double z = v.zCoord;

float a = MathHelper.sqrt_double(x * x + z * z);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)a) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch;
this.prevRotationYaw = this.rotationYaw;
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
}

Posted

So, I hacked together a quick "fix." It still has the same problem, but it fixes itself so quick that it doesn't matter that much now.

 

I just changed the onUpdate() method in my custom EntityArrow class to force a fix if ticksInAir < 4.

 

public void onUpdate()
{
super.onUpdate();

if((!this.inGround && this.ticksInAir < 4) || (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F))
{
	float var1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
	this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
	this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)var1) * 180.0D / Math.PI);
}
...

 

If anyone knows a proper fix though, please let me know.

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.