Jump to content

[1.8] Rotating and positioning custom entity, or it's parts


Warix

Recommended Posts

Hello , i made a custom entity and when i summon it , it's not placed in center of bounding box, also how do i rotate it's parts? I tried but i can't seem to succeed at it. Also i used Techne to make model for my entity.

Render code:

 

package ga.warixmods.akamegakillmod.client.renderer.entity;

 

import ga.warixmods.akamegakillmod.client.model.ModelRocketLauncherRM;

import ga.warixmods.akamegakillmod.entity.special.EntityRocketLauncher;

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelCow;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.client.renderer.GlStateManager;

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

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

import net.minecraft.entity.Entity;

import net.minecraft.util.ResourceLocation;

 

public class RenderRocketLauncher extends Render{

 

 

public RenderRocketLauncher(RenderManager rendermanagerIn) {

super(rendermanagerIn);

// TODO Auto-generated constructor stub

}

protected ModelBase modelRocketLauncher = new ModelRocketLauncherRM();

 

 

@Override

protected ResourceLocation getEntityTexture(Entity entity) {

// TODO Auto-generated method stub

return new ResourceLocation("agkm:textures/entity/rocket_launcher.png");

}

 

public void doRender(Entity boat, double p_180552_2_, double p_180552_4_, double p_180552_6_, float p_180552_8_, float p_180552_9_)

    {

        GlStateManager.pushMatrix();

        GlStateManager.translate((float)p_180552_2_, (float)p_180552_4_ + 0.25F, (float)p_180552_6_);

        GlStateManager.rotate(180.0F - p_180552_8_, 0.0F, 1.0F, 0.0F);

        this.bindEntityTexture(boat);

        ModelRenderer toRotate = (ModelRenderer) this.modelRocketLauncher.boxList.get(0);

        // toRotate.rotateAngleX = 90F;

        this.modelRocketLauncher.render(boat, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

        GlStateManager.popMatrix();

        super.doRender(boat, p_180552_2_, p_180552_4_, p_180552_6_, p_180552_8_, p_180552_9_);

    }

}

 

 

Model code:

 

  // Date: 9.2.2015 9:16:16 PM

// Template version 1.1

// Java generated by Techne

// Keep in mind that you still need to fill in some blanks

// - ZeuX

 

 

 

 

 

 

package ga.warixmods.akamegakillmod.client.model;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

 

public class ModelRocketLauncherRM extends ModelBase

{

  //fields

  public ModelRenderer Shape1;

  public ModelRenderer Shape2;

  public ModelRenderer Shape11;

 

  public ModelRocketLauncherRM()

  {

    textureWidth = 64;

    textureHeight = 32;

   

      Shape1 = new ModelRenderer(this, 0, 0);

      Shape1.addBox(0F, 0F, 0F, 7, 5, 7);

      Shape1.setRotationPoint(0F,4F,0F);

      Shape1.setTextureSize(64, 32);

     

      setRotation(Shape1, 0F, 0F, 0F);

      Shape2 = new ModelRenderer(this, 0, 0);

      Shape2.addBox(0F, 0F, 0F, 1, 3, 1);

      Shape2.setRotationPoint(3F, 1F, 3F);

      Shape2.setTextureSize(64, 32);

     

     

      setRotation(Shape2, 0F, 0F, 0F);

      Shape11 = new ModelRenderer(this, 0, 0);

      Shape11.addBox(0F, 0F, 0F, 7, 1, 7);

      Shape11.setRotationPoint(0F, 0F, 0F);

      Shape11.setTextureSize(64, 32);

     

      setRotation(Shape11, 0F, 0F, 0F);

  }

 

  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)

  {

    super.render(entity, f, f1, f2, f3, f4, f5);

    setRotationAngles(f, f1, f2, f3, f4, f5,entity);

    Shape1.render(f5);

    Shape2.render(f5);

    Shape11.render(f5);

  }

 

  public void setRotation(ModelRenderer model, float x, float y, float z)

  {

    model.rotateAngleX = x;

    model.rotateAngleY = y;

    model.rotateAngleZ = z;

  }

 

  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5,Entity entity)

  {

    super.setRotationAngles(f, f1, f2, f3, f4, f5,entity);

  }

 

}

 

 

Normally spawned entity:

width=800 height=449http://orig14.deviantart.net/809a/f/2015/248/c/5/2015_09_05_20_58_25_by_warix3-d98hcdd.png[/img]

Side view:

width=800 height=449http://orig01.deviantart.net/c2a5/f/2015/248/7/6/2015_09_05_20_58_47_by_warix3-d98hccn.png[/img]

Rotated X by 90 degrees:

width=800 height=449http://orig05.deviantart.net/2cb3/f/2015/248/e/0/2015_09_05_21_01_13_by_warix3-d98hcbu.png[/img]

:D
Link to comment
Share on other sites

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.