1
1
package jackyy .avaritiatweaks .compat .botania .render ;
2
2
3
3
import jackyy .avaritiatweaks .AvaritiaTweaks ;
4
+ import jackyy .avaritiatweaks .compat .botania .BotaniaCompat ;
4
5
import jackyy .avaritiatweaks .compat .botania .tile .TileInfinitato ;
5
6
import net .minecraft .client .Minecraft ;
6
7
import net .minecraft .client .renderer .GlStateManager ;
8
+ import net .minecraft .client .renderer .OpenGlHelper ;
7
9
import net .minecraft .client .renderer .Tessellator ;
8
10
import net .minecraft .client .renderer .VertexBuffer ;
9
11
import net .minecraft .client .renderer .texture .TextureMap ;
15
17
16
18
public class RenderTileInfinitato extends TileEntitySpecialRenderer <TileInfinitato > {
17
19
18
- public static boolean drawHalo = true ;
19
20
private static final ResourceLocation TEXTURE = new ResourceLocation (AvaritiaTweaks .MODID ,"textures/blocks/infinitato.png" );
20
- public static final ResourceLocation HALO = new ResourceLocation ("avaritia" , "textures/items/halo128.png" );
21
21
private static final ModelInfinitato MODEL = new ModelInfinitato ();
22
22
23
23
@ Override
24
24
public void renderTileEntityAt (TileInfinitato te , double x , double y , double z , float partialTicks , int destroyStage ) {
25
+ if (!te .getWorld ().isBlockLoaded (te .getPos (), false )
26
+ || te .getWorld ().getBlockState (te .getPos ()).getBlock () != BotaniaCompat .infinitato )
27
+ return ;
25
28
Tessellator tessellator = Tessellator .getInstance ();
26
29
VertexBuffer buffer = tessellator .getBuffer ();
27
30
Minecraft mc = Minecraft .getMinecraft ();
@@ -33,44 +36,6 @@ public void renderTileEntityAt(TileInfinitato te, double x, double y, double z,
33
36
GlStateManager .translate (0.5F , 1.5F , 0.5F );
34
37
GlStateManager .scale (1F , -1F , -1F );
35
38
int meta = te .getBlockMetadata ();
36
- if (drawHalo ) {
37
- this .bindTexture (HALO );
38
- GlStateManager .pushMatrix ();
39
- double xdiff = (te .getPos ().getX () + 0.5 ) - pos .hitVec .xCoord ;
40
- double ydiff = (te .getPos ().getY () + 0.4 ) - pos .hitVec .yCoord ;
41
- double zdiff = (te .getPos ().getZ () + 0.5 ) - pos .hitVec .zCoord ;
42
- double len = Math .sqrt (xdiff *xdiff + ydiff *ydiff + zdiff *zdiff );
43
- xdiff /= len ;
44
- ydiff /= len ;
45
- zdiff /= len ;
46
- GlStateManager .translate (-xdiff , ydiff , zdiff );
47
- GlStateManager .scale (1F , -1F , -1F );
48
- GlStateManager .translate (0F , -1.15F , 0F );
49
- GlStateManager .rotate ((float ) -pos .hitVec .yCoord , 0.0F , 1.0F , 0.0F );
50
- GlStateManager .rotate ((float ) pos .hitVec .xCoord , 1.0F , 0.0F , 0.0F );
51
- float f = 1.6F ;
52
- float f1 = 0.016666668F * f ;
53
- GlStateManager .scale (f1 , f1 , f1 );
54
- GlStateManager .disableLighting ();
55
- GlStateManager .depthMask (false );
56
- GlStateManager .enableBlend ();
57
- GlStateManager .disableAlpha ();
58
- GlStateManager .tryBlendFuncSeparate (770 , 771 , 1 , 0 );
59
- buffer .begin (GL11 .GL_QUADS , DefaultVertexFormats .POSITION_TEX );
60
- int i =60 ;
61
- buffer .color (0.0F , 0.0F , 0.0F , 1.0F );
62
- buffer .pos (-i , -i , 0.0D ).tex (0 ,0 ).endVertex ();
63
- buffer .pos (-i , i , 0.0D ).tex (1 ,0 ).endVertex ();
64
- buffer .pos (i , i , 0.0D ).tex (1 ,1 ).endVertex ();
65
- buffer .pos (i , -i , 0.0D ).tex (0 ,1 ).endVertex ();
66
- tessellator .draw ();
67
- GlStateManager .depthMask (true );
68
- GlStateManager .enableLighting ();
69
- GlStateManager .disableBlend ();
70
- GlStateManager .enableAlpha ();
71
- GlStateManager .color (1F , 1F , 1F , 1F );
72
- GlStateManager .popMatrix ();
73
- }
74
39
float rotY = meta * 90F - 180F ;
75
40
GlStateManager .rotate (rotY , 0F , 1F , 0F );
76
41
float jump = te .jumpTicks *0.5f ;
@@ -92,33 +57,32 @@ public void renderTileEntityAt(TileInfinitato te, double x, double y, double z,
92
57
GlStateManager .rotate (-rotY , 0F , 1F , 0F );
93
58
GlStateManager .color (1F , 1F , 1F );
94
59
GlStateManager .scale (1F , -1F , -1F );
95
- if (!te .name .isEmpty () && pos != null && pos . hitVec . xCoord == pos .hitVec . xCoord && pos . hitVec . yCoord == pos . hitVec . yCoord && pos . hitVec . zCoord == pos . hitVec . zCoord ) {
60
+ if (!te .name .isEmpty () && pos != null && te . getPos (). equals ( pos .getBlockPos ()) ) {
96
61
GlStateManager .pushMatrix ();
97
- GlStateManager .translate (0F , -0.4F , 0F );
98
- GlStateManager .rotate (( float ) - pos . hitVec . yCoord , 0.0F , 1.0F , 0.0F );
99
- GlStateManager .rotate (( float ) pos . hitVec . xCoord , 1.0F , 0.0F , 0.0F );
62
+ GlStateManager .translate (0F , -0.6F , 0F );
63
+ GlStateManager .rotate (- mc . getRenderManager (). playerViewY , 0.0F , 1.0F , 0.0F );
64
+ GlStateManager .rotate (mc . getRenderManager (). playerViewX , 1.0F , 0.0F , 0.0F );
100
65
float f = 1.6F ;
101
66
float f1 = 0.016666668F * f ;
102
67
GlStateManager .scale (-f1 , -f1 , f1 );
103
68
GlStateManager .disableLighting ();
104
69
GlStateManager .translate (0.0F , 0F / f1 , 0.0F );
105
70
GlStateManager .depthMask (false );
106
71
GlStateManager .enableBlend ();
107
- GlStateManager . tryBlendFuncSeparate (770 , 771 , 1 , 0 );
108
- GlStateManager .enableTexture2D ();
109
- buffer .begin (GL11 .GL_QUADS , DefaultVertexFormats .POSITION_TEX );
72
+ OpenGlHelper . glBlendFunc (770 , 771 , 1 , 0 );
73
+ GlStateManager .disableTexture2D ();
74
+ buffer .begin (GL11 .GL_QUADS , DefaultVertexFormats .POSITION_COLOR );
110
75
int i = mc .fontRendererObj .getStringWidth (te .name ) / 2 ;
111
- buffer .color (0.0F , 0.0F , 0.0F , 0.25F );
112
- buffer .pos (-i - 1 , -1.0D , 0.0D ).endVertex ();
113
- buffer .pos (-i - 1 , 8.0D , 0.0D ).endVertex ();
114
- buffer .pos (i + 1 , 8.0D , 0.0D ).endVertex ();
115
- buffer .pos (i + 1 , -1.0D , 0.0D ).endVertex ();
76
+ buffer .pos (-i - 1 , -1.0D , 0.0D ).color (0.0F , 0.0F , 0.0F , 0.25F ).endVertex ();
77
+ buffer .pos (-i - 1 , 8.0D , 0.0D ).color (0.0F , 0.0F , 0.0F , 0.25F ).endVertex ();
78
+ buffer .pos (i + 1 , 8.0D , 0.0D ).color (0.0F , 0.0F , 0.0F , 0.25F ).endVertex ();
79
+ buffer .pos (i + 1 , -1.0D , 0.0D ).color (0.0F , 0.0F , 0.0F , 0.25F ).endVertex ();
116
80
tessellator .draw ();
117
81
GlStateManager .enableTexture2D ();
118
82
GlStateManager .depthMask (true );
119
83
mc .fontRendererObj .drawString (te .name , -mc .fontRendererObj .getStringWidth (te .name ) / 2 , 0 , 0xFFFFFF );
120
84
GlStateManager .enableLighting ();
121
- GlStateManager .enableBlend ();
85
+ GlStateManager .disableBlend ();
122
86
GlStateManager .color (1F , 1F , 1F , 1F );
123
87
GlStateManager .scale (1F / -f1 , 1F / -f1 , 1F / f1 );
124
88
GlStateManager .popMatrix ();
0 commit comments