Package vazkii.botania.client.render.tile

Source Code of vazkii.botania.client.render.tile.RenderTileTerraPlate

/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Nov 8, 2014, 7:20:26 PM (GMT)]
*/
package vazkii.botania.client.render.tile;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;

import org.lwjgl.opengl.GL11;

import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.common.block.BlockEnchanter;
import vazkii.botania.common.block.BlockTerraPlate;
import vazkii.botania.common.block.tile.TileTerraPlate;

public class RenderTileTerraPlate extends TileEntitySpecialRenderer {

  @Override
  public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
    TileTerraPlate plate = (TileTerraPlate) tileentity;

    float max = (float) TileTerraPlate.MAX_MANA / 10F;
    float alphaMod = (float) Math.min(max, plate.getCurrentMana()) / max;
    GL11.glPushMatrix();
    GL11.glTranslated(d0, d1, d2);

    GL11.glRotated(90F, 1F, 0F, 0F);
    GL11.glTranslatef(0F, 0F, -3F / 16F - 0.001F);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    float alpha = (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 5D + 0.6D) * alphaMod;
    if(ShaderHelper.useShaders())
      GL11.glColor4f(1F, 1F, 1F, alpha);
    else {
      int light = 15728880;
      int lightmapX = light % 65536;
      int lightmapY = light / 65536;
      OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
      GL11.glColor4f(0.6F + (float) ((Math.cos((ClientTickHandler.ticksInGame + f) / 6D) + 1D) / 5D), 0.1F, 0.9F, alpha);
    }

    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);

    ShaderHelper.useShader(ShaderHelper.terraPlateRune);
    renderIcon(0, 0, BlockTerraPlate.overlay, 1, 1, 240);
    ShaderHelper.releaseShader();

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    GL11.glPopMatrix();
  }

  public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.setBrightness(brightness);
    tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV());
    tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV());
    tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV());
    tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV());
    tessellator.draw();
  }

}
TOP

Related Classes of vazkii.botania.client.render.tile.RenderTileTerraPlate

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.