Jump to content

Custom block model not rendering [1.6.4]


Enkey

Recommended Posts

I wanted to make a custom model for block so I made it with this tutorial http://www.minecraftforge.net/wiki/Rendering_a_Techne_Model_as_a_Block, but it's not rendering :(

 

Classes:

 

Block class:

package testmod;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockCustomModel extends BlockContainer{

protected BlockCustomModel(int par1) {
	super(par1, Material.rock);
}

@Override
public TileEntity createNewTileEntity(World world) {
	return new TileEntityCustomModel();
}

public int getRenderType(){
	return -1;
}

public boolean isOpaqueCube(){
	return false;
}

public boolean renderAsNormalBlock(){
	return false;
}

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister icon){
	this.blockIcon = icon.registerIcon(Main.modid + ":" + this.getUnlocalizedName().substring(5));
}

}

 

Tile entity class:

 

package testmod;

import net.minecraft.tileentity.TileEntity;

public class TileEntityCustomModel extends {

}

 

Tile Entity Renderer class:

 

package testmod;

import org.lwjgl.opengl.GL11;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

public class TileEntityCustomModelRenderer extends TileEntitySpecialRenderer {

private final TestingModel model;

public TileEntityCustomModelRenderer() {
        this.model = new TestingModel();
}

private void adjustRotatePivotViaMeta(World world, int x, int y, int z) {
        int meta = world.getBlockMetadata(x, y, z);
        GL11.glPushMatrix();
        GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F);
        GL11.glPopMatrix();
}

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {
	//The PushMatrix tells the renderer to "start" doing something.
        GL11.glPushMatrix();
      //This is setting the initial location.
        GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
      //Use in 1.6.2  this
        ResourceLocation forge = (new ResourceLocation("mods:roads/textures/blocks/TestingModel.png")); 
      //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!                      
        GL11.glPushMatrix();
        GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
      //A reference to your Model file. Again, very important.
        this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
      //Tell it to stop rendering for both the PushMatrix's
        GL11.glPopMatrix();
        GL11.glPopMatrix();
}

//Set the lighting stuff, so it changes it's brightness properly.      
    private void adjustLightFixture(World world, int i, int j, int k, Block block) {
            Tessellator tess = Tessellator.instance;
            float brightness = block.getBlockBrightness(world, i, j, k);
            int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
            int modulousModifier = skyLight % 65536;
            int divModifier = skyLight / 65536;
            tess.setColorOpaque_F(brightness, brightness, brightness);
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit,  (float) modulousModifier,  divModifier);
    }

}

 

Model class (exported from techne):

 

package testmod;

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


public class TestingModel extends ModelBase
{
  //fields
    ModelRenderer Shape1;
    ModelRenderer Shape2;
    ModelRenderer Shape3;
    ModelRenderer Shape4;
  
  public TestingModel()
  {
    textureWidth = 64;
    textureHeight = 64;
    
      Shape1 = new ModelRenderer(this, 0, 0);
      Shape1.addBox(0F, 0F, 0F, 4, 5, 4);
      Shape1.setRotationPoint(0F, 0F, 0F);
      Shape1.setTextureSize(64, 64);
      Shape1.mirror = true;
      setRotation(Shape1, 0F, 0F, 0F);
      Shape2 = new ModelRenderer(this, 0, 0);
      Shape2.addBox(0F, 0F, -5F, 4, 5, 4);
      Shape2.setRotationPoint(0F, 0F, 0F);
      Shape2.setTextureSize(64, 64);
      Shape2.mirror = true;
      setRotation(Shape2, 0F, 0F, 0F);
      Shape3 = new ModelRenderer(this, 0, 0);
      Shape3.addBox(-5F, 0F, 0F, 4, 5, 4);
      Shape3.setRotationPoint(0F, 0F, 0F);
      Shape3.setTextureSize(64, 64);
      Shape3.mirror = true;
      setRotation(Shape3, 0F, 0F, 0F);
      Shape4 = new ModelRenderer(this, 0, 0);
      Shape4.addBox(-5F, 0F, -5F, 4, 5, 4);
      Shape4.setRotationPoint(0F, 0F, 0F);
      Shape4.setTextureSize(64, 64);
      Shape4.mirror = true;
      setRotation(Shape4, 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);
    Shape3.render(f5);
    Shape4.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 entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  }

}

 

Any help?  :-\

 

 

If someone helps you, click that thank you button ;)

 

EasyTessellator library: http://www.minecraftforge.net/forum/index.php/topic,14705.0.html

Link to comment
Share on other sites

public class TileEntityCustomModel extends {

 

Uh...how is that not throwing an error?

 

Secondly, you still need to register your renderer:

 

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCustomModel.class, new TileEntityCustomModelRenderer());

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

public class TileEntityCustomModel extends {

 

Uh...how is that not throwing an error?

 

I probably deleted that by mistake when I was copiing the class.

 

Secondly, you still need to register your renderer:

 

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCustomModel.class, new TileEntityCustomModelRenderer());

 

Oh... ok. Now it works... kinda... It just randomly switches random textures...

 

EDIT: I have noticed that I haven't changed the path to the texture from roads to testmod(my modid) at : ResourceLocation forge = (new ResourceLocation("mods:roads/textures/blocks/TestingModel.png")); , but that doesn't fixed it.

If someone helps you, click that thank you button ;)

 

EasyTessellator library: http://www.minecraftforge.net/forum/index.php/topic,14705.0.html

Link to comment
Share on other sites

I'm not sure what's going on, but take a gander at Unique Artifacts.  I've got a few TESpecialRenderers.

 

(Just FYI: you're going to need a common and client proxy, as TileEntitySpecialRenderer doesn't exist on the server)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Take all the time you need.  It's why my mod is open source: a reference for others.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Yay! It works! :)

 

I just changed this string: "mods:testmod/textures/blocks/TestingModel.png"

to this: "testmod:/textures/blocks/TestingModel.png"

and added this: Minecraft.getMinecraft().renderEngine.bindTexture(textures);

 

And why do I need the proxies? Cuz it works without them.

 

And how do I make the model render as an item in inventory?

If someone helps you, click that thank you button ;)

 

EasyTessellator library: http://www.minecraftforge.net/forum/index.php/topic,14705.0.html

Link to comment
Share on other sites

Yay! It works! :)

 

I just changed this string: "mods:testmod/textures/blocks/TestingModel.png"

to this: "testmod:/textures/blocks/TestingModel.png"

and added this: Minecraft.getMinecraft().renderEngine.bindTexture(textures);

 

This part:


Remove the / as you don't need it.  The colon is automatically converted to a /

 

And why do I need the proxies? Cuz it works without them.

 

As soon as you compile it and release it, it will crash the standalone server.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.