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
|
package kubatech.client.effect;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.lang.reflect.Field;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.init.Blocks;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class CropRenderer extends EntityFX {
int[] meta = new int[8];
static Field tessellatorHasBrightnessField = null;
public CropRenderer(World world, int x, int y, int z, int age) {
super(world, (double) x, ((double) y - 0.0625d), (double) z);
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.particleMaxAge = age;
for (int i = 0; i < 8; i++) this.meta[i] = this.rand.nextInt(8);
}
@Override
public void onUpdate() {
if (this.particleAge++ >= this.particleMaxAge) this.setDead();
}
@Override
public void renderParticle(
Tessellator p_70539_1_,
float p_70539_2_,
float p_70539_3_,
float p_70539_4_,
float p_70539_5_,
float p_70539_6_,
float p_70539_7_) {
Tessellator tessellator = Tessellator.instance;
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDepthMask(false);
try {
if (tessellatorHasBrightnessField == null) {
tessellatorHasBrightnessField = Tessellator.class.getDeclaredField(
(boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")
? "hasBrightness"
: "field_78414_p");
tessellatorHasBrightnessField.setAccessible(true);
}
tessellatorHasBrightnessField.set(tessellator, false);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
tessellator.setColorRGBA(255, 255, 255, 255);
double f12 = this.posY - interpPosY;
int i = 0;
for (int x = -1; x <= 1; x++)
for (int z = -1; z <= 1; z++) {
if (x == 0 && z == 0) continue;
double f11 = (this.posX + (double) x) - interpPosX;
double f13 = (this.posZ + (double) z) - interpPosZ;
RenderBlocks.getInstance().renderBlockCropsImpl(Blocks.wheat, meta[i++], f11, f12, f13);
}
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDepthMask(true);
}
@Override
public int getFXLayer() {
return 1;
}
@Override
public boolean shouldRenderInPass(int pass) {
return pass == 2;
}
}
|