Jump to content

Recommended Posts

Posted

So, i've got this action, that my mob perform when attack( basicly when it jumps on me ):

protected void attackEntity(Entity par1Entity, float par2)
    {
        float f1 = this.getBrightness(1.0F);

        if (f1 > 0.5F && this.rand.nextInt(100) == 0)
        {
            this.entityToAttack = null;
        }
        else
        {
            if (par2 > 2.0F && par2 < 6.0F && this.rand.nextInt(10) == 0)
            {
                if (this.onGround)
                {
                	this.playSound("headcrab.hc_attack", 1.0F, 1.0F);
                    double d0 = par1Entity.posX - this.posX;
                    double d1 = par1Entity.posZ - this.posZ;
                    float f2 = MathHelper.sqrt_double(d0 * d0 + d1 * d1);
                    this.motionX = d0 / (double)f2 * 0.5D * 1.800000011920929D + this.motionX * 0.20000000298023224D;
                    this.motionZ = d1 / (double)f2 * 0.5D * 0.800000011920929D + this.motionZ * 0.20000000298023224D;
                    this.motionY = 0.5000000059604645D;
                }
            }
            else
            {
                super.attackEntity(par1Entity, par2);
            }
        }
    }

 

For this action, i want my mob to do GL11.rotatef() itself. Basicly when my mob jumps, it performs rotation. How can i do that? I suppose, i have to put GL11.rotatef in Render but how? Can somebody help me with that? Thanks alot if you do, thats a very important thing for me.

 

P.S> Would be better if you give a code as example

Posted

I tried  to use those strings, but that didnt help. DO anybody have any suggestions?

 

 

protected void rotateCorpse(EntityLiving par1EntityLiving, float par2, float par3, float par4, EntityHeadcrab entityheadcrab)

{

if(entityheadcrab.onGround = false)

{

GL11.glRotatef(60.0F,1.0F,0.0F,0.0F);

GL11.glRotatef(60.0F,0.0F,1.0F,0.0F);

GL11.glRotatef(60.0F,0.0F,0.0F,1.0F);

}

 

}

 

 

Posted

well i have a different method on this , i was working on tigrex spin thou but its not on render however i can make it using part.rotateAngleX and by putting the offset into the center inner of the main body of the mob :)

Posted

well i have a different method on this , i was working on tigrex spin thou but its not on render however i can make it using part.rotateAngleX and by putting the offset into the center inner of the main body of the mob :)

 

Well, thats livingAnimations. I almost know what to do with that too. But i dont need only one part rotating, i want the whole body rotate.

Posted

Well, i tried that out. Still dont work.

protected void rotateHeadcrabCorpse(EntityHeadcrab par1EntityHeadcrab, float par2, float par3, float par4)
{
    super.rotateCorpse(par1EntityHeadcrab, par2, par3, par4);
    
    if (par2 > 2.0F && par2 < 6.0F && this.rand.nextInt(10) == 0)
    {
    if (par1EntityHeadcrab.onGround = true)
    {
        GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F);
    }
    else
    {
    	GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F);
    }
}
}

 

COme on guys, i've already checked out alot of ways to do so. Could anybody help me please?

Posted

Hi

 

Your glRotatef are right but probably in the wrong place.  They need to go just before you render your model.  Show us your render code?

 

eg from RendererLivingEntity

    protected void renderModel(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4, float par5, float par6, float par7)

    {

        this.bindEntityTexture(par1EntityLivingBase);

 

        if (!par1EntityLivingBase.isInvisible())

        {

 

// put your rotates here - eg if you want to rotate about the vertical axis:

GL11.glRotatef(angle, 0.0, 1.0, 0.0);

 

            this.mainModel.render(par1EntityLivingBase, par2, par3, par4, par5, par6, par7);

        }

// etc

 

    }

 

-TGG

Posted

Hi

 

Your glRotatef are right but probably in the wrong place.  They need to go just before you render your model.  Show us your render code?

 

eg from RendererLivingEntity

    protected void renderModel(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4, float par5, float par6, float par7)

    {

        this.bindEntityTexture(par1EntityLivingBase);

 

        if (!par1EntityLivingBase.isInvisible())

        {

 

// put your rotates here - eg if you want to rotate about the vertical axis:

GL11.glRotatef(angle, 0.0, 1.0, 0.0);

 

            this.mainModel.render(par1EntityLivingBase, par2, par3, par4, par5, par6, par7);

        }

// etc

 

    }

 

-TGG

 

WEll, i havent got that part of code you gave me here. Maybe you can help with my code?

 

package halflifemod.client.renderer.entity;

 

import java.util.Random;

 

import halflifemod.client.model.ModelHeadcrab;

import halflifemod.entity.monster.EntityHeadcrab;

 

import org.lwjgl.opengl.GL11;

 

import net.minecraft.client.renderer.entity.RenderLiving;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLiving;

import net.minecraft.entity.monster.EntityIronGolem;

import net.minecraft.util.MathHelper;

 

public class RenderHeadcrab extends RenderLiving

{

protected ModelHeadcrab model;

protected Random rand;

 

public RenderHeadcrab(ModelHeadcrab modelheadcrab, float f)

{

super(modelheadcrab, f);

model = ((ModelHeadcrab)mainModel);

}

protected void rotateHeadcrabCorpse(EntityHeadcrab par1EntityHeadcrab, float par2, float par3, float par4)

{

    super.rotateCorpse(par1EntityHeadcrab, par2, par3, par4);

   

    if (par2 > 2.0F && par2 < 6.0F && this.rand.nextInt(10) == 0)

    {

    if (par1EntityHeadcrab.onGround = true)

    {

        GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F);

    }

    else

    {

    GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F);

    }

}

}

public void renderHeadcrab(EntityHeadcrab entityheadcrab, double par2, double par4, double par6,

float par8, float par9)

{

super.doRenderLiving(entityheadcrab, par2, par4, par6, par8, par9);

}

 

public void doRenderLiving(EntityLiving entityliving, double par2, double par4, double par6,

float par8, float par9, EntityHeadcrab entityheadcrab)

{

renderHeadcrab((EntityHeadcrab)entityliving, par2, par4, par6, par8, par9);

}

 

public void doRender(Entity entity, double par2, double par4, double par6,

float par8, float par9)

{

renderHeadcrab((EntityHeadcrab)entity, par2, par4, par6, par8, par9);

}

 

}

 

 

Posted

Hi

 

If you're using the RenderLiving methods, you can set the

Entity.renderYawOffset

in your Entity.onLivingUpdate code ; something like

 

private int rotationStartTicks;

@Override
public void onLivingUpdate()
   super.onLivingUpdate();
  double newYaw = 0.0;
  final double ROTATION_ANGLE_PER_TICK = 18.0;
  if (entityheadcrab.onGround = true) {
    rotationStartTicks = ticksExisted;
  } else {
    newYaw += (ticksExisted - rotationStartTicks) * ROTATION_ANGLE_PER_TICK;
  }
  renderYawOffset = newYaw;
}

 

I haven't compiled this but I reckon the basic idea should work. 

 

Alternatively, your glRotate code might work if you put it here - but I'm not 100% certain of that.

 

public void renderHeadcrab(EntityHeadcrab entityheadcrab, double x, double y, double z,

      float yaw, float partialTick)

{

  GL11.glPushMatrix();

  if(entityheadcrab.onGround = false)

  {

      GL11.glRotatef(60.0F,1.0F,0.0F,0.0F);

      GL11.glRotatef(60.0F,0.0F,1.0F,0.0F);

      GL11.glRotatef(60.0F,0.0F,0.0F,1.0F);

  }

  super.doRenderLiving(entityheadcrab, x, y, z, yaw, partialTick);

  GL11.glPopMatrix();

}

 

-TGG

Posted

Hi

 

If you're using the RenderLiving methods, you can set the

Entity.renderYawOffset

in your Entity.onLivingUpdate code ; something like

 

private int rotationStartTicks;

@Override
public void onLivingUpdate()
   super.onLivingUpdate();
  double newYaw = 0.0;
  final double ROTATION_ANGLE_PER_TICK = 18.0;
  if (entityheadcrab.onGround = true) {
    rotationStartTicks = ticksExisted;
  } else {
    newYaw += (ticksExisted - rotationStartTicks) * ROTATION_ANGLE_PER_TICK;
  }
  renderYawOffset = newYaw;
}

 

I haven't compiled this but I reckon the basic idea should work. 

 

Alternatively, your glRotate code might work if you put it here - but I'm not 100% certain of that.

 

public void renderHeadcrab(EntityHeadcrab entityheadcrab, double x, double y, double z,

      float yaw, float partialTick)

{

  GL11.glPushMatrix();

  if(entityheadcrab.onGround = false)

  {

      GL11.glRotatef(60.0F,1.0F,0.0F,0.0F);

      GL11.glRotatef(60.0F,0.0F,1.0F,0.0F);

      GL11.glRotatef(60.0F,0.0F,0.0F,1.0F);

  }

  super.doRenderLiving(entityheadcrab, x, y, z, yaw, partialTick);

  GL11.glPopMatrix();

}

 

-TGG

 

Well, i tried to use this code:

protected void rotateHeadcrabCorpse(EntityHeadcrab par1EntityHeadcrab, float par2, float par3, float par4)
    {
        super.rotateCorpse(par1EntityHeadcrab, par2, par3, par4);
        	if (!par1EntityHeadcrab.onGround)
        		{
        			float f3 = 13.0F;
        			float f4 = par1EntityHeadcrab.limbSwing - par1EntityHeadcrab.limbYaw * (1.0F - par4) + 6.0F;
        			float f5 = (Math.abs(f3 - f3 * 0.5F) - f3 * 0.25F) / (f3 * 0.25F);
        			GL11.glRotatef(75.5F * f5, 1.0F, 0.0F, 0.0F);
        		}
    }

And everything almost works. Thanks)

Posted

Hi

 

If you're using the RenderLiving methods, you can set the

Entity.renderYawOffset

in your Entity.onLivingUpdate code ; something like

 

private int rotationStartTicks;

@Override
public void onLivingUpdate()
   super.onLivingUpdate();
  double newYaw = 0.0;
  final double ROTATION_ANGLE_PER_TICK = 18.0;
  if (entityheadcrab.onGround = true) {
    rotationStartTicks = ticksExisted;
  } else {
    newYaw += (ticksExisted - rotationStartTicks) * ROTATION_ANGLE_PER_TICK;
  }
  renderYawOffset = newYaw;
}

 

I haven't compiled this but I reckon the basic idea should work. 

 

Alternatively, your glRotate code might work if you put it here - but I'm not 100% certain of that.

 

public void renderHeadcrab(EntityHeadcrab entityheadcrab, double x, double y, double z,

      float yaw, float partialTick)

{

  GL11.glPushMatrix();

  if(entityheadcrab.onGround = false)

  {

      GL11.glRotatef(60.0F,1.0F,0.0F,0.0F);

      GL11.glRotatef(60.0F,0.0F,1.0F,0.0F);

      GL11.glRotatef(60.0F,0.0F,0.0F,1.0F);

  }

  super.doRenderLiving(entityheadcrab, x, y, z, yaw, partialTick);

  GL11.glPopMatrix();

}

 

-TGG

 

protected void rotateHeadcrabCorpse(EntityHeadcrab par1EntityHeadcrab, float par2, float par3, float par4)
    {
        super.rotateCorpse(par1EntityHeadcrab, par2, par3, par4);
        	if (!par1EntityHeadcrab.onGround)
        		{
        			float f3 = 13.0F;
        			float f4 = par1EntityHeadcrab.limbSwing - par1EntityHeadcrab.limbYaw * (1.0F - par4) + 6.0F;
        			float f5 = (Math.abs(f3 - f3 * 0.5F) - f3 * 0.25F) / (f3 * 0.25F);
        			GL11.glRotatef(75.5F * f5, 1.0F, 0.0F, 0.0F);
        		}
    }

 

I used that and it works. Thanks anyways)

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.