package minefantasy.client.entityrender;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import minefantasy.entity.EntityRockSling;
import minefantasy.entity.IBomb;
import minefantasy.item.ItemListMF;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityPotion;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPotion;
import net.minecraft.potion.PotionHelper;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
@SideOnly(Side.CLIENT)
public class RenderBomb extends Render
{
/**
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
* (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
public void doRender(Entity bomb, double x, double y, double z, float pitch, float yaw)
{
Icon icon = null;
if(bomb instanceof IBomb)
{
icon = ((IBomb)bomb).getIcon();
}
if (icon != null)
{
GL11.glPushMatrix();
GL11.glTranslatef((float)x, (float)y, (float)z);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glScalef(0.5F, 0.5F, 0.5F);
this.bindTexture(TextureMap.locationItemsTexture);
Tessellator tessellator = Tessellator.instance;
if (icon == ItemPotion.func_94589_d("potion_splash"))
{
int i = PotionHelper.func_77915_a(((EntityPotion)bomb).getPotionDamage(), false);
float f2 = (float)(i >> 16 & 255) / 255.0F;
float f3 = (float)(i >> 8 & 255) / 255.0F;
float f4 = (float)(i & 255) / 255.0F;
GL11.glColor3f(f2, f3, f4);
GL11.glPushMatrix();
this.func_77026_a(tessellator, ItemPotion.func_94589_d("potion_contents"));
GL11.glPopMatrix();
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
this.func_77026_a(tessellator, icon);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
private void func_77026_a(Tessellator model, Icon image)
{
float f = image.getMinU();
float f1 = image.getMaxU();
float f2 = image.getMinV();
float f3 = image.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);
model.startDrawingQuads();
model.setNormal(0.0F, 1.0F, 0.0F);
model.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3);
model.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3);
model.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2);
model.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2);
model.draw();
}
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
return TextureMap.locationItemsTexture;
}
}