Jump to content

Recommended Posts

Posted

So i am custom rendering my block using a tesslator. How would i do that in the inventory?

Here is my code:

My itemrenderer:

 

 

package com.professorvennie.main.Itemrender;

import com.professorvennie.main.render.TileEntityRenderWasher;

import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;

public class ItemRenderWasher implements IItemRenderer{

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	return true;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
	return true;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	new TileEntityRenderWasher();
}

}

 

 

My custom renderer:

 

 

package com.professorvennie.main.render;

import org.lwjgl.opengl.GL11;

import com.professorvennie.block.EFBlock;
import com.professorvennie.lib.Strings;

import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;

public class TileEntityRenderWasher extends TileEntitySpecialRenderer{

private final ResourceLocation texterwasher = new ResourceLocation(Strings.MODID, "textures/blocks/ironoxideblock.png");
private final ResourceLocation glass = new ResourceLocation( "textures/blocks/glass.png");
private float pixel = 1F/16F;
private int textureWidth = 32;
private int textureHeight = 32;

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y,double z, float var8) {
	int x1 = tileentity.xCoord;
	int y1 = tileentity.yCoord;
	int z1 = tileentity.zCoord;

	int metadata =tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord);

	GL11.glPushMatrix();
	GL11.glDisable(GL11.GL_LIGHTING);
		GL11.glTranslatef((float)x, (float)y, (float)z);	



		Tessellator tessellator = Tessellator.instance;
		this.bindTexture(texterwasher);
		tessellator.startDrawingQuads();

		if(metadata == 5){
			this.bindTexture(glass);
			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(1, 1, 1, 1, 0);
			tessellator.addVertexWithUV(0, 1, 1, 0, 0);
			tessellator.addVertexWithUV(0, 0, 1, 0, 1);

			tessellator.addVertexWithUV(1, 1, 0, 1, 0);
			tessellator.addVertexWithUV(1, 0, 0, 1, 1);
			tessellator.addVertexWithUV(0, 0, 0, 0, 1);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);


		}
		if(metadata == 7){
			this.bindTexture(glass);

			tessellator.addVertexWithUV(1, 1, 1, 1, 0);
			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(1, 0, 0, 0, 1);
			tessellator.addVertexWithUV(1, 1, 0, 0, 0);

			tessellator.addVertexWithUV(0, 0, 1, 1, 1);
			tessellator.addVertexWithUV(0, 1, 1, 1, 0);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);
			tessellator.addVertexWithUV(0, 0, 0, 0, 1);

		}
		if(metadata == 6){
			this.bindTexture(texterwasher);
			tessellator.addVertexWithUV(1, 1, 1, 1, 0);
			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(1, 0, 0, 0, 1);
			tessellator.addVertexWithUV(1, 1, 0, 0, 0);

			tessellator.addVertexWithUV(0, 0, 1, 1, 1);
			tessellator.addVertexWithUV(0, 1, 1, 1, 0);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);
			tessellator.addVertexWithUV(0, 0, 0, 0, 1);

			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(1, 1, 1, 1, 0);
			tessellator.addVertexWithUV(0, 1, 1, 0, 0);
			tessellator.addVertexWithUV(0, 0, 1, 0, 1);

			tessellator.addVertexWithUV(1, 1, 0, 1, 0);
			tessellator.addVertexWithUV(1, 0, 0, 1, 1);
			tessellator.addVertexWithUV(0, 0, 0, 0, 1);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);

			tessellator.addVertexWithUV(0, 1, 1, 1, 0);
			tessellator.addVertexWithUV(1, 1, 1, 1, 1);
			tessellator.addVertexWithUV(1, 1, 0, 0, 1);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);

			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(0, 0, 1, 1, 0);
			tessellator.addVertexWithUV(0, 0, 0, 0, 0);
			tessellator.addVertexWithUV(1, 0, 0, 0, 1);
		}
		if(metadata == 3){
			this.bindTexture(texterwasher);
			tessellator.addVertexWithUV(1, 1, 1, 1, 0);
			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(1, 0, 0, 0, 1);
			tessellator.addVertexWithUV(1, 1, 0, 0, 0);

			tessellator.addVertexWithUV(0, 0, 1, 1, 1);
			tessellator.addVertexWithUV(0, 1, 1, 1, 0);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);
			tessellator.addVertexWithUV(0, 0, 0, 0, 1);

			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(1, 1, 1, 1, 0);
			tessellator.addVertexWithUV(0, 1, 1, 0, 0);
			tessellator.addVertexWithUV(0, 0, 1, 0, 1);

			tessellator.addVertexWithUV(1, 1, 0, 1, 0);
			tessellator.addVertexWithUV(1, 0, 0, 1, 1);
			tessellator.addVertexWithUV(0, 0, 0, 0, 1);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);


		}
		if(metadata == 2){
			this.bindTexture(texterwasher);
			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(0, 0, 1, 1, 0);
			tessellator.addVertexWithUV(0, 0, 0, 0, 0);
			tessellator.addVertexWithUV(1, 0, 0, 0, 1);

			tessellator.addVertexWithUV(0, 1, 1, 1, 0);
			tessellator.addVertexWithUV(1, 1, 1, 1, 1);
			tessellator.addVertexWithUV(1, 1, 0, 0, 1);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);

		}

		if(metadata == 4){
			this.bindTexture(texterwasher);
			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(0, 0, 1, 1, 0);
			tessellator.addVertexWithUV(0, 0, 0, 0, 0);
			tessellator.addVertexWithUV(1, 0, 0, 0, 1);

			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(1, 1, 1, 1, 0);
			tessellator.addVertexWithUV(0, 1, 1, 0, 0);
			tessellator.addVertexWithUV(0, 0, 1, 0, 1);

			tessellator.addVertexWithUV(1, 1, 0, 1, 0);
			tessellator.addVertexWithUV(1, 0, 0, 1, 1);
			tessellator.addVertexWithUV(0, 0, 0, 0, 1);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);

			tessellator.addVertexWithUV(0, 1, 1, 1, 0);
			tessellator.addVertexWithUV(1, 1, 1, 1, 1);
			tessellator.addVertexWithUV(1, 1, 0, 0, 1);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);
		}
		if(metadata == 1){
			this.bindTexture(texterwasher);
			tessellator.addVertexWithUV(1, 1, 1, 1, 0);
			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(1, 0, 0, 0, 1);
			tessellator.addVertexWithUV(1, 1, 0, 0, 0);

			tessellator.addVertexWithUV(0, 0, 1, 1, 1);
			tessellator.addVertexWithUV(0, 1, 1, 1, 0);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);
			tessellator.addVertexWithUV(0, 0, 0, 0, 1);

			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(1, 1, 1, 1, 0);
			tessellator.addVertexWithUV(0, 1, 1, 0, 0);
			tessellator.addVertexWithUV(0, 0, 1, 0, 1);

			tessellator.addVertexWithUV(1, 1, 0, 1, 0);
			tessellator.addVertexWithUV(1, 0, 0, 1, 1);
			tessellator.addVertexWithUV(0, 0, 0, 0, 1);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);

			tessellator.addVertexWithUV(0, 1, 1, 1, 0);
			tessellator.addVertexWithUV(1, 1, 1, 1, 1);
			tessellator.addVertexWithUV(1, 1, 0, 0, 1);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);

			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(0, 0, 1, 1, 0);
			tessellator.addVertexWithUV(0, 0, 0, 0, 0);
			tessellator.addVertexWithUV(1, 0, 0, 0, 1);
		}
	if(metadata == 0){
			this.bindTexture(texterwasher);
			tessellator.addVertexWithUV(1, 1, 1, 1, 0);
			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(1, 0, 0, 0, 1);
			tessellator.addVertexWithUV(1, 1, 0, 0, 0);

			tessellator.addVertexWithUV(0, 0, 1, 1, 1);
			tessellator.addVertexWithUV(0, 1, 1, 1, 0);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);
			tessellator.addVertexWithUV(0, 0, 0, 0, 1);

			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(1, 1, 1, 1, 0);
			tessellator.addVertexWithUV(0, 1, 1, 0, 0);
			tessellator.addVertexWithUV(0, 0, 1, 0, 1);

			tessellator.addVertexWithUV(1, 1, 0, 1, 0);
			tessellator.addVertexWithUV(1, 0, 0, 1, 1);
			tessellator.addVertexWithUV(0, 0, 0, 0, 1);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);

			tessellator.addVertexWithUV(1, 0, 1, 1, 1);
			tessellator.addVertexWithUV(0, 0, 1, 1, 0);
			tessellator.addVertexWithUV(0, 0, 0, 0, 0);
			tessellator.addVertexWithUV(1, 0, 0, 0, 1);

			tessellator.addVertexWithUV(0, 1, 1, 1, 0);
			tessellator.addVertexWithUV(1, 1, 1, 1, 1);
			tessellator.addVertexWithUV(1, 1, 0, 0, 1);
			tessellator.addVertexWithUV(0, 1, 0, 0, 0);

	}
	if(metadata == {
		this.bindTexture(texterwasher);
		tessellator.addVertexWithUV(0, 1, 1, 1, 0);
		tessellator.addVertexWithUV(1, 1, 1, 1, 1);
		tessellator.addVertexWithUV(1, 1, 0, 0, 1);
		tessellator.addVertexWithUV(0, 1, 0, 0, 0);
	}
		tessellator.draw();		
		GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glPopMatrix();
}

}

 

 

 

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.