Jump to content

Recommended Posts

Posted

Heyho Guys!

I created a custom bow for custom arrows. The problem with this thing is, that the arrows rotate while they are flying, but only if the player is in survivalmode. Basically the entity just extends EntityArrow without changing any thing of the movement. I didn't attach a renderer, the default one is used instead.

Code of the Arrow:

public class EntityMagicArrow extends EntityArrow {

public EntityMagicArrow(World world) {
	super(world);
}

public EntityMagicArrow(World world, double x, double y, double z) {
	super(world, x, y, z);
}

public EntityMagicArrow(World world, EntityLivingBase source, EntityLivingBase target, float f1, float f2) {
	super(world, source, target, f1, f2);
}

public EntityMagicArrow(World world, EntityLivingBase source, float speed) {
	super(world, source, speed);
}

@Override
public void onUpdate() {
	super.onUpdate();
	//No Gravity
		this.motionY += 0.049999;
		this.motionX /= 0.99;
		this.motionY /= 0.99;
		this.motionZ /= 0.99;
		if (this.posY > 512)
			this.kill();
}
}

Posted

Hi

 

It looks to me like you are trying to undo the motion effects of Entity arrow by guessing what onUpdate did and then undoing it. 

The reason your arrow is still spinning is because you undo motion but not rotation.

 

I'd suggest the best way to do this is to save a copy of the motionX, Y, Z and the rotationPitch and rotationYaw and overwrite them again afterwards if the arrow hasn't stuck in the ground or bounced off an entity or been destroyed or similar

 

so eg

 

{save motion and rotatino variables}

super.onUpdate()

if (! inGround && ticksInAir != 0)

{copy variables back}

 

-TGG

 

 

 

 

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.