the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "..\Minecraft.World\net.minecraft.world.level.h"
3#include "..\Minecraft.World\net.minecraft.world.level.material.h"
4#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
5#include "..\Minecraft.World\JavaMath.h"
6#include "..\Minecraft.World\Mth.h"
7#include "DripParticle.h"
8
9DripParticle::DripParticle(Level *level, double x, double y, double z, Material *material) : Particle(level, x, y, z, 0, 0, 0)
10{
11 xd = yd = zd = 0;
12
13 unsigned int clr;
14 if (material == Material::water)
15 {
16 clr = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Particle_DripWater);
17 }
18 else
19 {
20 clr = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Particle_DripLavaStart );
21 }
22
23 rCol = ( (clr>>16)&0xFF )/255.0f;
24 gCol = ( (clr>>8)&0xFF )/255.0;
25 bCol = ( clr&0xFF )/255.0;
26
27 setMiscTex(16 * 7 + 1);
28 this->setSize(0.01f, 0.01f);
29 gravity = 0.06f;
30 this->material = material;
31 stuckTime = 40;
32
33 lifetime = (int) (64 / (Math::random() * 0.8 + 0.2));
34 xd = yd = zd = 0;
35}
36
37int DripParticle::getLightColor(float a)
38{
39 if (material == Material::water) return Particle::getLightColor(a);
40
41 // 4J-JEV: Looks like this value was never used on the java version,
42 // but it is on ours, so I've changed this to be bright manualy.
43 int s = 0x0f;
44 int b = 0x0f;
45 return s << 20 | b << 4; // MGH changed this to a proper value as PS3 wasn't clamping the values.
46}
47
48float DripParticle::getBrightness(float a)
49{
50 if (material == Material::water) return Particle::getBrightness(a);
51 else return 1.0f;
52}
53
54void DripParticle::tick()
55{
56 xo = x;
57 yo = y;
58 zo = z;
59
60 if (material == Material::water)
61 {
62 //rCol = 0.2f;
63 //gCol = 0.3f;
64 //bCol = 1.0f;
65
66 unsigned int clr = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Particle_DripWater);
67 rCol = ( (clr>>16)&0xFF )/255.0f;
68 gCol = ( (clr>>8)&0xFF )/255.0;
69 bCol = ( clr&0xFF )/255.0;
70 }
71 else
72 {
73 //rCol = 1.0f;
74 //gCol = 16.0f / (40 - stuckTime + 16);
75 //bCol = 4.0f / (40 - stuckTime + 8);
76
77 unsigned int cStart = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Particle_DripLavaStart );
78 unsigned int cEnd = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Particle_DripLavaEnd );
79 double rStart = ( (cStart>>16)&0xFF )/255.0f, gStart = ( (cStart>>8)&0xFF )/255.0, bStart = ( cStart&0xFF )/255.0;
80 double rEnd = ( (cEnd>>16)&0xFF )/255.0f, gEnd = ( (cEnd>>8)&0xFF )/255.0, bEnd = ( cEnd&0xFF )/255.0;
81
82 float variance = (40 - stuckTime);
83 rCol = rStart - ((rStart - rEnd)/40) * variance;
84 gCol = gStart - ((gStart - gEnd)/40) * variance;
85 bCol = bStart - ((bStart - bEnd)/40) * variance;
86 }
87
88 yd -= gravity;
89 if (stuckTime-- > 0)
90 {
91 xd *= 0.02;
92 yd *= 0.02;
93 zd *= 0.02;
94 setMiscTex(16 * 7 + 1);
95 }
96 else
97 {
98 setMiscTex(16 * 7 + 0);
99 }
100 move(xd, yd, zd);
101 xd *= 0.98f;
102 yd *= 0.98f;
103 zd *= 0.98f;
104
105 if (lifetime-- <= 0) remove();
106
107 if (onGround)
108 {
109 if (material == Material::water)
110 {
111 remove();
112 level->addParticle(eParticleType_splash, x, y, z, 0, 0, 0);
113 }
114 else
115 {
116 setMiscTex(16 * 7 + 2);
117
118 }
119 xd *= 0.7f;
120 zd *= 0.7f;
121 }
122
123 Material *m = level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z));
124 if (m->isLiquid() || m->isSolid())
125 {
126 double y0 = Mth::floor(y) + 1 - LiquidTile::getHeight(level->getData(Mth::floor(x), Mth::floor(y), Mth::floor(z)));
127 if (y < y0)
128 {
129 remove();
130 }
131 }
132}