Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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);
}

  • Author

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.