-
Notifications
You must be signed in to change notification settings - Fork 9
/
RenderFriendlySlime.java
63 lines (54 loc) · 1.95 KB
/
RenderFriendlySlime.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package net.minecraft.src;
import org.lwjgl.opengl.GL11;
public class RenderFriendlySlime extends RenderLiving
{
private ModelBase scaleAmount;
public RenderFriendlySlime(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3)
{
super(par1ModelBase, par3);
scaleAmount = par2ModelBase;
}
protected int func_40287_a(EntityFriendlySlime par1EntityFriendlySlime, int par2, float par3)
{
if (par2 == 0)
{
setRenderPassModel(scaleAmount);
GL11.glEnable(GL11.GL_NORMALIZE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
return 1;
}
if (par2 == 1)
{
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
return -1;
}
/**
* sets the scale for the slime based on getSlimeSize in EntityFriendlySlime
*/
protected void scaleSlime(EntityFriendlySlime par1EntityFriendlySlime, float par2)
{
int i = par1EntityFriendlySlime.getSlimeSize();
float f = (par1EntityFriendlySlime.field_767_b + (par1EntityFriendlySlime.field_768_a - par1EntityFriendlySlime.field_767_b) * par2) / ((float)i * 0.5F + 1.0F);
float f1 = 1.0F / (f + 1.0F);
float f2 = i;
GL11.glScalef(f1 * f2, (1.0F / f1) * f2, f1 * f2);
}
/**
* Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
* entityLiving, partialTickTime
*/
protected void preRenderCallback(EntityLiving par1EntityLiving, float par2)
{
scaleSlime((EntityFriendlySlime)par1EntityLiving, par2);
}
/**
* Queries whether should render the specified pass or not.
*/
protected int shouldRenderPass(EntityLiving par1EntityLiving, int par2, float par3)
{
return func_40287_a((EntityFriendlySlime)par1EntityLiving, par2, par3);
}
}