Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package so101.bricks;
- import org.lwjgl.opengl.GL11;
- import org.lwjgl.opengl.GL12;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.client.renderer.Tessellator;
- import net.minecraft.client.renderer.entity.Render;
- import net.minecraft.entity.Entity;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.IIcon;
- import net.minecraft.util.ResourceLocation;
- @SideOnly(Side.CLIENT)
- public class RenderBrick extends Render
- {
- private ItemStack brick;
- public RenderBrick()
- {
- super();
- }
- public void doRender(Entity eentity, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
- {
- EntityBrick entity = (EntityBrick)eentity;
- this.brick = entity.entityItemStack;
- IIcon iicon = this.brick.getIconIndex();
- if (iicon != null)
- {
- GL11.glPushMatrix();
- GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_);
- GL11.glEnable(GL12.GL_RESCALE_NORMAL);
- GL11.glScalef(0.5F, 0.5F, 0.5F);
- //this.preRender(entity);
- this.bindEntityTexture(entity);
- Tessellator tessellator = Tessellator.instance;
- this.func_77026_a(tessellator, iicon);
- GL11.glDisable(GL12.GL_RESCALE_NORMAL);
- GL11.glPopMatrix();
- }
- }
- private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_)
- {
- float f = p_77026_2_.getMinU();
- float f1 = p_77026_2_.getMaxU();
- float f2 = p_77026_2_.getMinV();
- float f3 = p_77026_2_.getMaxV();
- float f4 = 1.0F;
- float f5 = 0.5F;
- float f6 = 0.25F;
- GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
- GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
- p_77026_1_.startDrawingQuads();
- p_77026_1_.setNormal(0.0F, 1.0F, 0.0F);
- p_77026_1_.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3);
- p_77026_1_.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3);
- p_77026_1_.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2);
- p_77026_1_.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2);
- p_77026_1_.draw();
- }
- /**
- * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
- */
- protected ResourceLocation getEntityTexture(Entity p_110775_1_)
- {
- //return TextureMap.locationItemsTexture;
- return this.getEntityTexture((EntityBrick)p_110775_1_);
- }
- protected ResourceLocation getEntityTexture(EntityBrick entity)
- {
- return this.renderManager.renderEngine.getResourceLocation(entity.brickType.brick.getSpriteNumber());
- }
- /**Prerender method for entity. Used for scaling.*/
- public void preRender(EntityBrick entity)
- {
- if (entity.getEntityData().getFloat("Scale") != 1.0F)
- {
- float scale = entity.getEntityData().getFloat("Scale");
- GL11.glScalef(scale, scale, scale);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement