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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Dude thanks for the help and all but I removed the client side mods that were failing in the crashlog and now everything runs!
    • Hello, Hi and I am making a forge 1.12.2 mod and also trying to get a custom model helmet item (I made a joker mask) and exported it to .json format and put it in the ~/namespace/models/item folder. Though, I'm struggling to get the item to render what I want it to be rendered like as I've positioned it in the 'head' window view in blockbench. How did you render out your model? I checked your code and it looks like no references to the actual model are being made. I'm new to this forge modding stuff (was a fabric modder) and I desperately need some help. Is there a way to standardly render out armor models made using blockbench? any methods that one can use? My model in JSON: ```json { "credit": "Made with Blockbench", "texture_size": [160, 160], "textures": { "0": "ydyrn:items/joker_mask_texture", "particle": "ydyrn:items/joker_mask_texture" }, "elements": [ { "from": [0, 0, 0], "to": [16, 16, 1], "faces": { "north": {"uv": [0, 1.7, 16, 14.2], "texture": "#0"}, "east": {"uv": [0, 4, 0.9, 5.6], "texture": "#0"}, "south": {"uv": [0, 5.8, 1.6, 7.4], "texture": "#0"}, "west": {"uv": [0, 1.9, 1.3, 3.5], "texture": "#0"}, "up": {"uv": [0, 3.4, 1.6, 4.2], "texture": "#0"}, "down": {"uv": [0, 9, 1.6, 9.7], "texture": "#0"} } }, { "from": [15.8, 11, 0.5], "to": [16.2, 13, 15], "faces": { "north": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "east": {"uv": [7.9, 7.9, 9.35, 8.1], "texture": "#0"}, "south": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "west": {"uv": [7.9, 7.9, 9.35, 8.1], "texture": "#0"}, "up": {"uv": [7.9, 7.9, 7.94, 9.35], "texture": "#0"}, "down": {"uv": [7.9, 7.9, 7.94, 9.35], "texture": "#0"} } }, { "from": [0.2, 11, 14.6], "to": [15.8, 13, 15], "faces": { "north": {"uv": [7.9, 7.9, 9.46, 8.1], "texture": "#0"}, "east": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "south": {"uv": [7.9, 7.9, 9.46, 8.1], "texture": "#0"}, "west": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "up": {"uv": [7.9, 7.9, 9.46, 7.94], "texture": "#0"}, "down": {"uv": [7.9, 7.9, 9.46, 7.94], "texture": "#0"} } }, { "from": [-0.2, 11, 0.5], "to": [0.2, 13, 15], "faces": { "north": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "east": {"uv": [7.9, 7.9, 9.35, 8.1], "texture": "#0"}, "south": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "west": {"uv": [7.9, 7.9, 9.35, 8.1], "texture": "#0"}, "up": {"uv": [7.9, 7.9, 7.94, 9.35], "texture": "#0"}, "down": {"uv": [7.9, 7.9, 7.94, 9.35], "texture": "#0"} } } ], "display": { "thirdperson_righthand": { "translation": [-0.25, -2.75, 0], "scale": [0.3, 0.3, 0.3] }, "thirdperson_lefthand": { "translation": [-0.25, -2.75, 0], "scale": [0.3, 0.3, 0.3] }, "firstperson_righthand": { "rotation": [-9, 115, 15], "translation": [0, 1.25, -1.75], "scale": [0.5, 0.5, 0.5] }, "firstperson_lefthand": { "rotation": [-9, 115, 15], "translation": [0, 1.25, -1.75], "scale": [0.5, 0.5, 0.5] }, "ground": { "rotation": [40, 0, 0], "translation": [0, -2.5, 0], "scale": [0.5, 0.5, 0.5] }, "gui": { "rotation": [0, 180, 0] }, "head": { "translation": [0, 0, 0.25], "scale": [0.82773, 0.73594, 0.9] }, "fixed": { "translation": [0, 0, 8.75] } }, "groups": [ 0, { "name": "straps", "origin": [0, 0, 0], "color": 0, "children": [1, 2, 3] } ] } ```
    • Add the crash-report or latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
    • In your config folder, delete the sophisticatedcore-common.toml file and test it again
  • Topics

×
×
  • Create New...

Important Information

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