Jump to content

[1.6.4] Custom Rendered Block Not Rendering Right


Xcox123

Recommended Posts

I am making a custom rendered block called a Blender. I used Techne for making the model.

However, as you can see here, the bottom of the block renders bad, plus the lighting's off.

 

width=800 height=449http://i1156.photobucket.com/albums/p580/electricx9001/2014-05-18_160051_zps089dafe4.png[/img]

 

Here is my code:

 

BlockBlender:

package net.minecraft.MFM.blocks;

 

import java.util.Random;

 

import cpw.mods.fml.common.network.FMLNetworkHandler;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.MFM.morefoodmod;

import net.minecraft.MFM.tileEntity.TileEntityBlender;

import net.minecraft.MFM.tileEntity.TileEntityCooker;

import net.minecraft.MFM.tileEntity.TileEntityFoodInfuser;

import net.minecraft.block.Block;

import net.minecraft.block.BlockContainer;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.Container;

import net.minecraft.inventory.IInventory;

import net.minecraft.item.ItemStack;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.Icon;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

 

public class BlockBlender extends BlockContainer{

 

public BlockBlender(int id){

super(id, Material.rock);

 

this.setBlockBounds(1f/16f*3f, 0f, 1f/16f*3f, 1f-1f/16f*3f, 1f-1f/16f*3f, 1f-1f/16f*3f);

this.setCreativeTab(morefoodmod.mfmTab);

}

public TileEntity createNewTileEntity(World world){

return new TileEntityBlender();

 

}

public int getRenderType(){

return -1;

}

public boolean isOpaqueCude(){

return false;

}

public boolean renderAsNormalBlock(){

return false;

}

public void setBlockBoundsForItemRender()

    {

        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);

    }

public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)

    {

        if (par6ItemStack.hasDisplayName())

        {

            ((TileEntityBlender)par1World.getBlockTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName());

        }

    }

 

 

@SideOnly(Side.CLIENT)

public void registerIcons(IconRegister icon){

this.blockIcon = icon.registerIcon(morefoodmod.modid + ":" + "blender");

}

 

 

}

 

 

 

ModelBlender:

 

package net.minecraft.MFM.models;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

 

public class ModelBlender extends ModelBase

{

  //fields

    ModelRenderer Shape1;

    ModelRenderer Shape2;

    ModelRenderer Shape3;

    ModelRenderer Shape4;

    ModelRenderer Shape5;

    ModelRenderer Shape6;

    ModelRenderer Shape7;

    ModelRenderer hgf;

    ModelRenderer Shape9;

    ModelRenderer Shape10;

    ModelRenderer Shape11;

    ModelRenderer Shape12;

    ModelRenderer Shape13;

    ModelRenderer glass1;

    ModelRenderer Shape14;

    ModelRenderer Shape15;

    ModelRenderer Shape16;

    ModelRenderer Shape17;

    ModelRenderer Shape18;

    ModelRenderer Shape19;

    ModelRenderer Shape20;

    ModelRenderer Shape21;

    ModelRenderer Shape22;

    ModelRenderer Shape23;

    ModelRenderer Shape24;

    ModelRenderer Shape25;

    ModelRenderer Shape26;

    ModelRenderer Shape27;

    ModelRenderer Shape28;

    ModelRenderer lid1;

    ModelRenderer Shape29;

    ModelRenderer Shape30;

    ModelRenderer Shape31;

    ModelRenderer Shape32;

    ModelRenderer handle;

    ModelRenderer Shape33;

    ModelRenderer Shape34;

 

  public ModelBlender()

  {

    textureWidth = 128;

    textureHeight = 128;

   

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

      Shape1.addBox(0F, 0F, 0F, 12, 1, 12);

      Shape1.setRotationPoint(-6F, 23F, -6F);

      Shape1.setTextureSize(128, 128);

      Shape1.mirror = true;

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

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

      Shape2.addBox(0F, 0F, 0F, 4, 5, 1);

      Shape2.setRotationPoint(-2F, 18F, 4F);

      Shape2.setTextureSize(128, 128);

      Shape2.mirror = true;

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

      Shape3 = new ModelRenderer(this, 0, 39);

      Shape3.addBox(0F, 0F, 0F, 1, 5, 1);

      Shape3.setRotationPoint(2F, 18F, 3F);

      Shape3.setTextureSize(128, 128);

      Shape3.mirror = true;

      setRotation(Shape3, 0F, 0F, 0F);

      Shape4 = new ModelRenderer(this, 0, 33);

      Shape4.addBox(0F, 0F, 0F, 1, 5, 1);

      Shape4.setRotationPoint(3F, 18F, 2F);

      Shape4.setTextureSize(128, 128);

      Shape4.mirror = true;

      setRotation(Shape4, 0F, 0F, 0F);

      Shape5 = new ModelRenderer(this, 0, 24);

      Shape5.addBox(0F, 0F, 0F, 1, 5, 4);

      Shape5.setRotationPoint(4F, 18F, -2F);

      Shape5.setTextureSize(128, 128);

      Shape5.mirror = true;

      setRotation(Shape5, 0F, 0F, 0F);

      Shape6 = new ModelRenderer(this, 0, 18);

      Shape6.addBox(0F, 0F, 0F, 1, 5, 1);

      Shape6.setRotationPoint(3F, 18F, -3F);

      Shape6.setTextureSize(128, 128);

      Shape6.mirror = true;

      setRotation(Shape6, 0F, 0F, 0F);

      Shape7 = new ModelRenderer(this, 10, 45);

      Shape7.addBox(0F, 0F, 0F, 1, 5, 1);

      Shape7.setRotationPoint(2F, 18F, -4F);

      Shape7.setTextureSize(128, 128);

      Shape7.mirror = true;

      setRotation(Shape7, 0F, 0F, 0F);

      hgf = new ModelRenderer(this, 4, 39);

      hgf.addBox(0F, 0F, 0F, 4, 5, 1);

      hgf.setRotationPoint(-2F, 18F, -5F);

      hgf.setTextureSize(128, 128);

      hgf.mirror = true;

      setRotation(hgf, 0F, 0F, 0F);

      Shape9 = new ModelRenderer(this, 10, 33);

      Shape9.addBox(0F, 0F, 0F, 1, 5, 1);

      Shape9.setRotationPoint(-3F, 18F, -4F);

      Shape9.setTextureSize(128, 128);

      Shape9.mirror = true;

      setRotation(Shape9, 0F, 0F, 0F);

      Shape10 = new ModelRenderer(this, 10, 27);

      Shape10.addBox(0F, 0F, 0F, 1, 5, 1);

      Shape10.setRotationPoint(-4F, 18F, -3F);

      Shape10.setTextureSize(128, 128);

      Shape10.mirror = true;

      setRotation(Shape10, 0F, 0F, 0F);

      Shape11 = new ModelRenderer(this, 14, 42);

      Shape11.addBox(0F, 0F, 0F, 1, 5, 4);

      Shape11.setRotationPoint(-5F, 18F, -2F);

      Shape11.setTextureSize(128, 128);

      Shape11.mirror = true;

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

      Shape12 = new ModelRenderer(this, 10, 21);

      Shape12.addBox(0F, 0F, -1F, 1, 5, 1);

      Shape12.setRotationPoint(-4F, 18F, 3F);

      Shape12.setTextureSize(128, 128);

      Shape12.mirror = true;

      setRotation(Shape12, 0F, 0F, 0F);

      Shape13 = new ModelRenderer(this, 4, 18);

      Shape13.addBox(0F, 0F, -1F, 1, 5, 1);

      Shape13.setRotationPoint(-3F, 18F, 4F);

      Shape13.setTextureSize(128, 128);

      Shape13.mirror = true;

      setRotation(Shape13, 0F, 0F, 0F);

      glass1 = new ModelRenderer(this, 14, 28);

      glass1.addBox(0F, 0F, 0F, 1, 10, 4);

      glass1.setRotationPoint(5F, 8F, -2F);

      glass1.setTextureSize(128, 128);

      glass1.mirror = true;

      setRotation(glass1, 0F, 0F, 0F);

      Shape14 = new ModelRenderer(this, 14, 17);

      Shape14.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape14.setRotationPoint(4F, 8F, 2F);

      Shape14.setTextureSize(128, 128);

      Shape14.mirror = true;

      setRotation(Shape14, 0F, 0F, 0F);

      Shape15 = new ModelRenderer(this, 18, 17);

      Shape15.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape15.setRotationPoint(3F, 8F, 3F);

      Shape15.setTextureSize(128, 128);

      Shape15.mirror = true;

      setRotation(Shape15, 0F, 0F, 0F);

      Shape16 = new ModelRenderer(this, 24, 40);

      Shape16.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape16.setRotationPoint(2F, 8F, 4F);

      Shape16.setTextureSize(128, 128);

      Shape16.mirror = true;

      setRotation(Shape16, 0F, 0F, 0F);

      Shape17 = new ModelRenderer(this, 24, 29);

      Shape17.addBox(0F, 0F, 0F, 4, 10, 1);

      Shape17.setRotationPoint(-2F, 8F, 5F);

      Shape17.setTextureSize(128, 128);

      Shape17.mirror = true;

      setRotation(Shape17, 0F, 0F, 0F);

      Shape18 = new ModelRenderer(this, 22, 17);

      Shape18.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape18.setRotationPoint(-3F, 8F, 4F);

      Shape18.setTextureSize(128, 128);

      Shape18.mirror = true;

      setRotation(Shape18, 0F, 0F, 0F);

      Shape19 = new ModelRenderer(this, 26, 18);

      Shape19.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape19.setRotationPoint(-4F, 8F, 3F);

      Shape19.setTextureSize(128, 128);

      Shape19.mirror = true;

      setRotation(Shape19, 0F, 0F, 0F);

      Shape20 = new ModelRenderer(this, 30, 18);

      Shape20.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape20.setRotationPoint(-5F, 8F, 2F);

      Shape20.setTextureSize(128, 128);

      Shape20.mirror = true;

      setRotation(Shape20, 0F, 0F, 0F);

      Shape21 = new ModelRenderer(this, 24, 37);

      Shape21.addBox(0F, 0F, 0F, 1, 10, 4);

      Shape21.setRotationPoint(-6F, 8F, -2F);

      Shape21.setTextureSize(128, 128);

      Shape21.mirror = true;

      setRotation(Shape21, 0F, 0F, 0F);

      Shape22 = new ModelRenderer(this, 34, 26);

      Shape22.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape22.setRotationPoint(-5F, 8F, -3F);

      Shape22.setTextureSize(128, 128);

      Shape22.mirror = true;

      setRotation(Shape22, 0F, 0F, 0F);

      Shape23 = new ModelRenderer(this, 38, 26);

      Shape23.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape23.setRotationPoint(-4F, 8F, -4F);

      Shape23.setTextureSize(128, 128);

      Shape23.mirror = true;

      setRotation(Shape23, 0F, 0F, 0F);

      Shape24 = new ModelRenderer(this, 34, 15);

      Shape24.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape24.setRotationPoint(-3F, 8F, -5F);

      Shape24.setTextureSize(128, 128);

      Shape24.mirror = true;

      setRotation(Shape24, 0F, 0F, 0F);

      Shape25 = new ModelRenderer(this, 38, 15);

      Shape25.addBox(0F, 0F, 0F, 4, 10, 1);

      Shape25.setRotationPoint(-2F, 8F, -6F);

      Shape25.setTextureSize(128, 128);

      Shape25.mirror = true;

      setRotation(Shape25, 0F, 0F, 0F);

      Shape26 = new ModelRenderer(this, 48, 53);

      Shape26.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape26.setRotationPoint(2F, 8F, -5F);

      Shape26.setTextureSize(128, 128);

      Shape26.mirror = true;

      setRotation(Shape26, 0F, 0F, 0F);

      Shape27 = new ModelRenderer(this, 48, 42);

      Shape27.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape27.setRotationPoint(3F, 8F, -4F);

      Shape27.setTextureSize(128, 128);

      Shape27.mirror = true;

      setRotation(Shape27, 0F, 0F, 0F);

      Shape28 = new ModelRenderer(this, 48, 31);

      Shape28.addBox(0F, 0F, 0F, 1, 10, 1);

      Shape28.setRotationPoint(4F, 8F, -3F);

      Shape28.setTextureSize(128, 128);

      Shape28.mirror = true;

      setRotation(Shape28, 0F, 0F, 0F);

      lid1 = new ModelRenderer(this, 52, 59);

      lid1.addBox(0F, 0F, 0F, 1, 1, 4);

      lid1.setRotationPoint(-5F, 8F, -2F);

      lid1.setTextureSize(128, 128);

      lid1.mirror = true;

      setRotation(lid1, 0F, 0F, 0F);

      lid1 = new ModelRenderer(this, 52, 52);

      lid1.addBox(0F, 0F, 0F, 1, 1, 6);

      lid1.setRotationPoint(-4F, 8F, -3F);

      lid1.setTextureSize(128, 128);

      lid1.mirror = true;

      setRotation(lid1, 0F, 0F, 0F);

      lid1 = new ModelRenderer(this, 52, 43);

      lid1.addBox(0F, 0F, 0F, 1, 1, 8);

      lid1.setRotationPoint(-3F, 8F, -4F);

      lid1.setTextureSize(128, 128);

      lid1.mirror = true;

      setRotation(lid1, 0F, 0F, 0F);

      lid1 = new ModelRenderer(this, 52, 32);

      lid1.addBox(0F, 0F, 0F, 1, 1, 10);

      lid1.setRotationPoint(-2F, 8F, -5F);

      lid1.setTextureSize(128, 128);

      lid1.mirror = true;

      setRotation(lid1, 0F, 0F, 0F);

      lid1 = new ModelRenderer(this, 52, 21);

      lid1.addBox(0F, 0F, 0F, 1, 1, 10);

      lid1.setRotationPoint(-1F, 8F, -5F);

      lid1.setTextureSize(128, 128);

      lid1.mirror = true;

      setRotation(lid1, 0F, 0F, 0F);

      lid1 = new ModelRenderer(this, 49, 10);

      lid1.addBox(0F, 0F, 0F, 1, 1, 10);

      lid1.setRotationPoint(0F, 8F, -5F);

      lid1.setTextureSize(128, 128);

      lid1.mirror = true;

      setRotation(lid1, 0F, 0F, 0F);

      Shape29 = new ModelRenderer(this, 80, 53);

      Shape29.addBox(0F, 0F, 0F, 1, 1, 10);

      Shape29.setRotationPoint(1F, 8F, -5F);

      Shape29.setTextureSize(128, 128);

      Shape29.mirror = true;

      setRotation(Shape29, 0F, 0F, 0F);

      Shape30 = new ModelRenderer(this, 80, 44);

      Shape30.addBox(0F, 0F, 0F, 1, 1, 8);

      Shape30.setRotationPoint(2F, 8F, -4F);

      Shape30.setTextureSize(128, 128);

      Shape30.mirror = true;

      setRotation(Shape30, 0F, 0F, 0F);

      Shape31 = new ModelRenderer(this, 80, 37);

      Shape31.addBox(0F, 0F, 0F, 1, 1, 6);

      Shape31.setRotationPoint(3F, 8F, -3F);

      Shape31.setTextureSize(128, 128);

      Shape31.mirror = true;

      setRotation(Shape31, 0F, 0F, 0F);

      Shape32 = new ModelRenderer(this, 80, 32);

      Shape32.addBox(0F, 0F, 0F, 1, 1, 4);

      Shape32.setRotationPoint(4F, 8F, -2F);

      Shape32.setTextureSize(128, 128);

      Shape32.mirror = true;

      setRotation(Shape32, 0F, 0F, 0F);

      handle = new ModelRenderer(this, 102, 20);

      handle.addBox(0F, 0F, 0F, 1, 1, 1);

      handle.setRotationPoint(0F, 7F, -3F);

      handle.setTextureSize(128, 128);

      handle.mirror = true;

      setRotation(handle, 0F, 0F, 0F);

      Shape33 = new ModelRenderer(this, 102, 13);

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

      Shape33.setRotationPoint(0F, 6F, -2F);

      Shape33.setTextureSize(128, 128);

      Shape33.mirror = true;

      setRotation(Shape33, 0F, 0F, 0F);

      Shape34 = new ModelRenderer(this, 102, 8);

      Shape34.addBox(0F, 0F, 0F, 1, 1, 1);

      Shape34.setRotationPoint(0F, 7F, 1F);

      Shape34.setTextureSize(128, 128);

      Shape34.mirror = true;

      setRotation(Shape34, 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);

    Shape5.render(f5);

    Shape6.render(f5);

    Shape7.render(f5);

    hgf.render(f5);

    Shape9.render(f5);

    Shape10.render(f5);

    Shape11.render(f5);

    Shape12.render(f5);

    Shape13.render(f5);

    glass1.render(f5);

    Shape14.render(f5);

    Shape15.render(f5);

    Shape16.render(f5);

    Shape17.render(f5);

    Shape18.render(f5);

    Shape19.render(f5);

    Shape20.render(f5);

    Shape21.render(f5);

    Shape22.render(f5);

    Shape23.render(f5);

    Shape24.render(f5);

    Shape25.render(f5);

    Shape26.render(f5);

    Shape27.render(f5);

    Shape28.render(f5);

    lid1.render(f5);

    lid1.render(f5);

    lid1.render(f5);

    lid1.render(f5);

    lid1.render(f5);

    lid1.render(f5);

    Shape29.render(f5);

    Shape30.render(f5);

    Shape31.render(f5);

    Shape32.render(f5);

    handle.render(f5);

    Shape33.render(f5);

    Shape34.render(f5);

  }

 

  public void renderModel(float f5){

  Shape1.render(f5);

    Shape2.render(f5);

    Shape3.render(f5);

    Shape4.render(f5);

    Shape5.render(f5);

    Shape6.render(f5);

    Shape7.render(f5);

    hgf.render(f5);

    Shape9.render(f5);

    Shape10.render(f5);

    Shape11.render(f5);

    Shape12.render(f5);

    Shape13.render(f5);

    glass1.render(f5);

    Shape14.render(f5);

    Shape15.render(f5);

    Shape16.render(f5);

    Shape17.render(f5);

    Shape18.render(f5);

    Shape19.render(f5);

    Shape20.render(f5);

    Shape21.render(f5);

    Shape22.render(f5);

    Shape23.render(f5);

    Shape24.render(f5);

    Shape25.render(f5);

    Shape26.render(f5);

    Shape27.render(f5);

    Shape28.render(f5);

    lid1.render(f5);

    lid1.render(f5);

    lid1.render(f5);

    lid1.render(f5);

    lid1.render(f5);

    lid1.render(f5);

    Shape29.render(f5);

    Shape30.render(f5);

    Shape31.render(f5);

    Shape32.render(f5);

    handle.render(f5);

    Shape33.render(f5);

    Shape34.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);

  }

 

}

 

 

 

RenderBlender:

package net.minecraft.MFM.renderer;

 

import org.lwjgl.opengl.GL11;

 

import net.minecraft.MFM.morefoodmod;

import net.minecraft.MFM.models.ModelBlender;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.ResourceLocation;

 

public class RenderBlender extends TileEntitySpecialRenderer{

 

private static final ResourceLocation texture = new ResourceLocation(morefoodmod.modid, "textures/model/blender.png");

 

private ModelBlender model;

 

public RenderBlender(){

this.model = new ModelBlender();

}

 

public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {

GL11.glPushMatrix();

GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);

GL11.glRotatef(180, 0f, 0f, 1f);

 

this.bindTexture(texture);

GL11.glPushMatrix();

this.model.renderModel(0.0625F);

GL11.glPopMatrix();

GL11.glPopMatrix();

 

}

 

}

 

 

 

ItemRenderBlender:

package net.minecraft.MFM.renderer;

 

import net.minecraft.MFM.models.ModelBlender;

import net.minecraft.MFM.tileEntity.TileEntityBlender;

import net.minecraft.client.renderer.tileentity.TileEntityRenderer;

import net.minecraft.item.ItemStack;

import net.minecraftforge.client.IItemRenderer;

 

public class ItemRenderBlender implements IItemRenderer{

 

private ModelBlender model;

 

public ItemRenderBlender(){

model = new ModelBlender();

}

 

 

public boolean handleRenderType(ItemStack item, ItemRenderType type) {

return false;

}

 

public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {

return false;

}

 

 

 

 

public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

TileEntityRenderer.instance.renderTileEntityAt(new TileEntityBlender(), 0.0D, 0.0D, 0.0D, 0.0F);

}

 

}

 

 

 

I have messed around with this code, and tryed to base it off the vannila code as much as I could(mainy Brewing Stand) and it still doesn't work.

Link to comment
Share on other sites

    @Override
    public boolean isOpaqueCube(){
        return false;
    }

in the block class should fix at least some of it.

 

Now that I look closer you seem to have tried-

   public boolean isOpaqueCude(){
      return false;
   }

Which should encourage you to use that Override annotation.

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.