Jump to content

Recommended Posts

Posted

I want to render an item in the world through my block renderer, but every time I place my block, I get the same item rendering. Right now I'm in the process of debugging, so I have the item change based on the X location of the block. Can anyone help? Here is my render code:

 

package mods.test;

 

import net.minecraft.block.Block;

import net.minecraft.client.gui.FontRenderer;

import net.minecraft.client.renderer.entity.RenderItem;

import net.minecraft.client.renderer.entity.RenderManager;

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

import net.minecraft.entity.item.EntityItem;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.tileentity.TileEntity;

import org.lwjgl.opengl.GL11;

import java.io.IOException;

import java.io.InputStream;

import java.util.Random;

 

public class Renderer extends TileEntitySpecialRenderer{

RenderItem renderitem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);

    EntityItem entityitem = new EntityItem(null);

 

   

private model model;

public Renderer(){

model = new model();

}

 

public void renderAModelAt(TE tile, double d, double d1, double d2, float f) {

 

int rotation = 0;

if(tile.worldObj != null)

{

rotation = tile.getBlockMetadata();

}

bindTextureByName("/mods/mod/texture.png"); //texture

GL11.glPushMatrix();

GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F);

GL11.glScalef(1.0F, -1F, -1F);

GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F);

model.renderAll();

GL11.glPopMatrix(); //end

}

 

 

 

 

 

@Override

public void renderTileEntityAt(TileEntity tileentity, double d0, double d1,

double d2, float f) {

TE TE = (TE)tileentity;

Random r = new Random();

    this.entityitem.worldObj = tileentity.worldObj;

    this.entityitem.age = 0;

    this.entityitem.rotationYaw = (float)(Math.random() * 360.0D);

 

 

 

  // this.entityitem.setPosition((double)d0, (double)d1, (double)d2);

    this.entityitem.hoverStart = 2.0F;

 

this.renderAModelAt((TE)TE, d0, d1, d2, f);

 

GL11.glTranslated(d0 + 0.5d, d1 + 0.25D, d2+ 0.5d);

 

switch(TE.xCoord % 2){

    case 1: this.entityitem.setEntityItemStack(new ItemStack(Item.diamond, 1));

    case 0:  this.entityitem.setEntityItemStack(new ItemStack(Item.ingotGold, 1));

    }

renderitem.doRenderItem(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);

 

GL11.glScaled(1.0D / 1, 1.0D / 1, 1.0D / 1);

GL11.glTranslated(-1 * (d0 + 0.5d), (d1 + 0.25D) * -1, -1 * (d2+ 0.5d));

}

 

}

 

 

There was no rendering error, I just had some bad debug code.

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.