Jump to content

Recommended Posts

Posted

Hello all, I'm new to entities, modelling, and rendering (though I do know how to mod blocks and items and have a good knowledge of Java). I read about five different tutorials on how to mod custom entities in 1.7 (I'm not going with 1.8 because it's too much hassle for me), but for some reason I simply can't get my entity to render properly. My entity has its own class, it's registered, and it even appeared as a white block before I wrote the rendering class. I made a model in Techne, exported it as Java and a texturemap, put the texturemap under src/main/resources/assets/rendertestmod/textures/entity/drill.png, and fixed up the Java file the way other tutorials said to do it. Then I wrote the rendering class the way the tutorials said, but whenever I summon my entity, I now get an extremely strange pattern of textures floating in the air, that seem to follow me, and definitely don't conform to the shape of the model I made. I'll put the code below.

package com.example.rendertestmod;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelDrill extends ModelBase
{
    ModelRenderer Base;
    ModelRenderer Bit;
  
  public ModelDrill()
  {
    textureWidth = 64;
    textureHeight = 64;
    
      Base = new ModelRenderer(this, 0, 0);
      Base.addBox(0F, 0F, 0F, 16, 8, ;
      Base.setRotationPoint(-8F, 0F, -4F);
      Base.setTextureSize(64, 64);
      Base.mirror = true;
      setRotation(Base, 0F, 0F, 0F);
      Bit = new ModelRenderer(this, 0, 16);
      Bit.addBox(-8F, -2F, -2F, 8, 4, 4);
      Bit.setRotationPoint(-8F, 4F, 0F);
      Bit.setTextureSize(64, 64);
      Bit.mirror = true;
      setRotation(Bit, 0F, 0F, 0F);
  }
  
  public void render(float f5)
  {
Base.render(f5);
    Bit.render(f5);
  }
  
  private 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 e)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
  }

}

package com.example.rendertestmod;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;

public class RenderDrill extends Render {

static ModelDrill drill = new ModelDrill();

public RenderDrill() {
	// TODO Auto-generated constructor stub
}

@Override
public void doRender(Entity e, double f1,
		double f2, double f3, float f4,
		float f5) {
	GL11.glPushMatrix();
	drill.render(.0625F);
                GL11.glPopMatrix();
}

@Override
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
	// TODO Auto-generated method stub
	return new ResourceLocation("rendertestmod:textures/entity/drill.png");
}

}

package com.example.rendertestmod;

import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

public class EntityDrill extends Entity {

public EntityDrill(World w) {
	super(w);
	// TODO Auto-generated constructor stub
}

@Override
protected void entityInit() {
	// TODO Auto-generated method stub

}

@Override
protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {
	// TODO Auto-generated method stub

}

@Override
protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {
	// TODO Auto-generated method stub

}

}

 

About the rendering class: I used render(.0625F) because that's what I saw in another code file in another mod. I have no idea what that float argument means. Also, there were no errors during startup even when I changed the texture name to gibberish, so I feel like I might be doing something wrong about the location of the texture, but I don't know what. Sorry if this sounds like a noobish question, and sorry if I wasn't supposed to ask questions about such basic topics on this forum, but the tutorials are not very helpful. I'll post screenshots of my Eclipse setup if you need to see those.

 

Also, bear in mind that this is just an experiment for me to find out the basics of rendering entities. That's why the entity does nothing except sit there and display its textures to me.  :)

Posted

Calling the GL translate method with the 2nd, 3rd, and 4th parameters (x, y, and z) is also very important - if you don't, you very likely will not see anything at all.

 

Yes, now I can see the entity the way I intended. I also discovered that the argument to the render(float) method is the scale. However, the entity vanishes when being viewed from certain angles. I can see it from some angles and not from others. Anyone have any insights? Maybe a call to glEnable() and glDisable() with one of the filter constants?

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.

×
×
  • Create New...

Important Information

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