-
Notifications
You must be signed in to change notification settings - Fork 755
/
ArrowRenderCustom.java
103 lines (90 loc) · 4.1 KB
/
ArrowRenderCustom.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package tconstruct.client.entity.projectile;
import java.util.Random;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.ForgeHooksClient;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import tconstruct.entity.projectile.ArrowEntity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ArrowRenderCustom extends Render
{
private static RenderItem renderer = new RenderItem();
private Random random = new Random();
public ArrowRenderCustom()
{
}
/**
* Renders the item
*/
public void doRenderItem (ArrowEntity arrow, double par2, double par4, double par6, float par8, float par9)
{
random.setSeed(187L);
ItemStack item = arrow.getEntityItem();
GL11.glPushMatrix();
GL11.glTranslatef((float) par2, (float) par4, (float) par6);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glRotatef(arrow.prevRotationYaw + (arrow.rotationYaw - arrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(arrow.prevRotationPitch + (arrow.rotationPitch - arrow.prevRotationPitch) * par9 - 45.0F, 0.0F, 0.0F, 1.0F);
float shake = arrow.arrowShake - par9;
if (shake > 0.0F)
GL11.glRotatef(-MathHelper.sin(shake * 3) * shake, 0, 0, 1);
GL11.glTranslatef(-7 / 16f, -8 / 16f, -1 / 32f);
float scale = 1.35f;
GL11.glScalef(scale, scale, scale);
ForgeHooksClient.renderEntityItem(null, item, 0, 0, random, renderManager.renderEngine, field_147909_c, 1);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
/**
* Renders the item's icon or block into the UI at the specified position.
*/
public void renderItemIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
renderer.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5);
}
/**
* Render the item's icon or block into the GUI, including the glint effect.
*/
public void renderItemAndEffectIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
renderer.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5);
}
/**
* Renders the item's overlay information. Examples being stack count or
* damage on top of the item's image at the specified position.
*/
public void renderItemOverlayIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
renderer.renderItemOverlayIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5);
}
/**
* 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.
*/
@Override
public void doRender (Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
this.doRenderItem((ArrowEntity) par1Entity, par2, par4, par6, par8, par9);
}
protected ResourceLocation getEntityTexture (Entity par1Entity)
{
return this.func_110796_a((ArrowEntity) par1Entity);
}
protected ResourceLocation func_110796_a (ArrowEntity par1ArrowEntity)
{
return this.renderManager.renderEngine.getResourceLocation(par1ArrowEntity.getEntityItem().getItemSpriteNumber());
}
}