Package vazkii.botania.client.render.tile

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

/**
* 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 @ [Jul 18, 2014, 10:48:46 PM (GMT)]
*/
package vazkii.botania.client.render.tile;

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

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.model.ModelTinyPotato;
import vazkii.botania.common.block.tile.TileTinyPotato;

public class RenderTileTinyPotato extends TileEntitySpecialRenderer {

  private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TINY_POTATO);
  private static final ModelTinyPotato model = new ModelTinyPotato();

  @Override
  public void renderTileEntityAt(TileEntity var1, double d0, double d1, double d2, float var8) {
    TileTinyPotato potato = (TileTinyPotato) var1;
    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    GL11.glTranslated(d0, d1, d2);

    Minecraft.getMinecraft().renderEngine.bindTexture(texture);

    GL11.glTranslatef(0.5F, 1.5F, 0.5F);
    GL11.glScalef(1F, -1F, -1F);
    int meta = potato.getWorldObj() == null ? 3 : potato.getBlockMetadata();
    GL11.glRotatef(meta * 90F - 180F, 0F, 1F, 0F);

    float jump = potato.jumpTicks;
    if(jump > 0)
      jump += var8;

    float up = (float) -Math.abs(Math.sin(jump / 10 * Math.PI)) * 0.2F;
    float rot = (float) Math.sin(jump / 10 * Math.PI) * 2;

    GL11.glTranslatef(0F, up, 0F);
    GL11.glRotatef(rot, 0F, 0F, 1F);

    model.render();
    GL11.glColor3f(1F, 1F, 1F);
    GL11.glScalef(1F, -1F, -1F);
    GL11.glPopMatrix();
  }
}
TOP

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

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.