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

Hi,

  I'm working in 1.8.

 

  I have successfully made several projectile weapons, all of which used bullets. Now I'm working on throwing knives, and want my projectile rotated like an arrow, so that it starts (and continues) facing away from the player, instead of being parallel to the camera angle.

 

    How do I accomplish this?

 

I'm not sure what code is relevant yet, if any, so sorry if I'm spraying irrelevant code all over the place.

 

Here's my renderer:

 

public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float partialTicks)

    {

        GlStateManager.pushMatrix();

        GlStateManager.translate((float)x, (float)y, (float)z);

        GlStateManager.enableRescaleNormal();

        GlStateManager.scale(0.5F, 0.5F, 0.5F);

     

        //I tried changing this a couple different ways, but nothing happened. It's

        //possible that if this is the method I'm looking for, I just don't know how

        //use it.

        GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);

        GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);

        this.bindTexture(modelResourceLocation);

        this.renderitem.renderItemModel(this.convertEntitytoStack(entity));

        GlStateManager.disableRescaleNormal();

        GlStateManager.popMatrix();

        super.doRender(entity, x, y, z, p_76986_8_, partialTicks);

    }

 

 

 

And here's the constructor for the entity.

 

public class EntityThrowingKnife extends EntityThrowable

{

public static final float speed = 1;

public static final float inacurracy = .35f;

 

 

    public EntityThrowingKnife(World world)

    {

        super(world);

        this.motionX += calcinaccuracy();

        this.motionY += calcinaccuracy();

        this.motionZ += calcinaccuracy();

        this.motionX *= speed;

        this.motionY *= speed;

        this.motionZ *= speed;

    }

    public EntityThrowingKnife(World world, EntityLivingBase par2EntityLivingBase)

    {

        super(world, par2EntityLivingBase);

        this.motionX += calcinaccuracy();

        this.motionY += calcinaccuracy();

        this.motionZ += calcinaccuracy();

        this.motionX *= speed;

        this.motionY *= speed;

        this.motionZ *= speed;

    }

   

    public float calcinaccuracy()

    {

    return (rand.nextFloat() * inacurracy) - (.5f * inacurracy);

    }

 

//.....

 

 

 

 

 

 

 

Thanks!

 

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.