Jump to content

Creating A Model File For A Custom Model; Breaking Particles Not Rendering


riderj

Recommended Posts

I'm trying to create a model file for a custom block, it has 2 parts. I tried creating one on my own but can't seem to get the grasp of how  to render the model like it looks in world. I don't have a model file for the in world object because I had used opengl to render the texture. How would I create a model file to display that specific object in the hotbar?

 


 

 

The breaking particles are also not rendering, I have looked at a few solutions but they seem to not work because setBlockTextureName is non existent. The following image includes the particle issue, and a preview of the model, the classes are below.

 

6beeca11108c0747168886e2dc0daac4.png

 

 

 

TileEntityZygoBush.java

 

package riderj.harvester.tileentity;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import riderj.harvester.entity.block.TileEntityZygoBushEntity;

public class TileEntityZygoBush extends BlockContainer {

public TileEntityZygoBush(Material materialIn) {
	super(materialIn);
	 this.setBlockBounds(0.12F, 0.0F, 0.12F, .88F, 1F, .88F);
}

@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
	return new TileEntityZygoBushEntity();
}

//You don't want the normal render type, or it wont render properly.
    @Override
    public int getRenderType() {
            return -1;
    }
    
    //It's not an opaque cube, so you need this.
    @Override
    public boolean isOpaqueCube() {
            return false;
    }
    
    //It's not a normal block, so you need this too.
    public boolean renderAsNormalBlock() {
            return false;
    }

}

 

 

TileEntityZygoBushRender.java

 

package riderj.harvester.client.renderer.tileentity;

import net.minecraft.client.Minecraft;
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;

import org.lwjgl.opengl.GL11;

import riderj.harvester.client.renderer.models.blocks.ZygoBushModel;

public class TileEntityZygoBushRender extends TileEntitySpecialRenderer {

public ZygoBushModel model;

public TileEntityZygoBushRender(){
	this.model = new ZygoBushModel();
}


@Override
public void renderTileEntityAt(TileEntity te, double x,double y, double z, float scale, int idk) {
	GL11.glPushMatrix();
	GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
	ResourceLocation texture = new ResourceLocation("harvester:textures/blocks/zygo_bush.png");
	Minecraft.getMinecraft().renderEngine.bindTexture(texture);
	GL11.glPushMatrix();
	GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
	this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
	GL11.glPopMatrix();
	GL11.glPopMatrix();
}

}

 

ZygoBushModel.java

 

package riderj.harvester.client.renderer.models.blocks;

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

public class ZygoBushModel extends ModelBase{
//fields
    ModelRenderer BushTop;
    ModelRenderer Stem;
  
    public ZygoBushModel()
    {
      textureWidth = 64;
      textureHeight = 64;
      
      BushTop = new ModelRenderer(this, 0, 0);
      BushTop.addBox(0F, 0F, 0F, 12, 10, 12);
      BushTop.setRotationPoint(-6F, 8F, -6F);
      BushTop.setTextureSize(64, 64);
      BushTop.mirror = true;
      setRotation(BushTop, 0F, 0F, 0F);
      Stem = new ModelRenderer(this, 20, 28);
      Stem.addBox(0F, 0F, 0F, 2, 6, 2);
      Stem.setRotationPoint(-1F, 18F, -1F);
      Stem.setTextureSize(64, 64);
      Stem.mirror = true;
      setRotation(Stem, 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);
      BushTop.render(f5);
      Stem.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);
    }


}

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.