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 "TerrainParticle.h"
3#include "Tesselator.h"
4#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
5#include "..\Minecraft.World\net.minecraft.world.level.h"
6#include "..\Minecraft.World\net.minecraft.world.h"
7
8TerrainParticle::TerrainParticle(Level *level, double x, double y, double z, double xa, double ya, double za, Tile *tile, int face, int data, Textures *textures) : Particle(level, x, y, z, xa, ya, za)
9{
10 this->tile = tile;
11 this->setTex(textures, tile->getTexture(0, data)); // 4J - change brought forward from 1.8.2 to fix purple particles on door damage
12 this->gravity = tile->gravity;
13 rCol = gCol = bCol = 0.6f;
14 size /= 2;
15}
16
17shared_ptr<TerrainParticle> TerrainParticle::init(int x, int y, int z, int data) // 4J - added data parameter
18{
19 if (tile == Tile::grass) return dynamic_pointer_cast<TerrainParticle>( shared_from_this() );
20 int col = tile->getColor(level, x, y, z, data); // 4J - added data parameter
21 rCol *= ((col >> 16) & 0xff) / 255.0f;
22 gCol *= ((col >> 8) & 0xff) / 255.0f;
23 bCol *= ((col) & 0xff) / 255.0f;
24 return dynamic_pointer_cast<TerrainParticle>( shared_from_this() );
25}
26
27shared_ptr<TerrainParticle> TerrainParticle::init(int data)
28{
29 if (tile == Tile::grass) return dynamic_pointer_cast<TerrainParticle>( shared_from_this() );
30 int col = tile->getColor(data);
31 rCol *= ((col >> 16) & 0xff) / 255.0f;
32 gCol *= ((col >> 8) & 0xff) / 255.0f;
33 bCol *= ((col) & 0xff) / 255.0f;
34 return dynamic_pointer_cast<TerrainParticle>( shared_from_this() );
35}
36
37int TerrainParticle::getParticleTexture()
38{
39 return ParticleEngine::TERRAIN_TEXTURE;
40}
41
42void TerrainParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2)
43{
44 float u0 = (texX + uo / 4.0f) / 16.0f;
45 float u1 = u0 + 0.999f / 16.0f / 4;
46 float v0 = (texY + vo / 4.0f) / 16.0f;
47 float v1 = v0 + 0.999f / 16.0f / 4;
48 float r = 0.1f * size;
49
50 if (tex != NULL)
51 {
52 u0 = tex->getU((uo / 4.0f) * SharedConstants::WORLD_RESOLUTION);
53 u1 = tex->getU(((uo + 1) / 4.0f) * SharedConstants::WORLD_RESOLUTION);
54 v0 = tex->getV((vo / 4.0f) * SharedConstants::WORLD_RESOLUTION);
55 v1 = tex->getV(((vo + 1) / 4.0f) * SharedConstants::WORLD_RESOLUTION);
56 }
57
58 float x = (float) (xo + (this->x - xo) * a - xOff);
59 float y = (float) (yo + (this->y - yo) * a - yOff);
60 float z = (float) (zo + (this->z - zo) * a - zOff);
61
62 // 4J - don't render terrain particles that are less than a metre away, to try and avoid large particles that are causing us problems with
63 // photosensitivity testing
64 float distSq = (x*x + y*y + z*z);
65 if( distSq < 1.0f ) return;
66
67 float br = SharedConstants::TEXTURE_LIGHTING ? 1.0f : getBrightness(a); // 4J - change brought forward from 1.8.2
68 t->color(br * rCol, br * gCol, br * bCol);
69
70 t->vertexUV((float)(x - xa * r - xa2 * r), (float)( y - ya * r), (float)( z - za * r - za2 * r), (float)( u0), (float)( v1));
71 t->vertexUV((float)(x - xa * r + xa2 * r), (float)( y + ya * r), (float)( z - za * r + za2 * r), (float)( u0), (float)( v0));
72 t->vertexUV((float)(x + xa * r + xa2 * r), (float)( y + ya * r), (float)( z + za * r + za2 * r), (float)( u1), (float)( v0));
73 t->vertexUV((float)(x + xa * r - xa2 * r), (float)( y - ya * r), (float)( z + za * r - za2 * r), (float)( u1), (float)( v1));
74
75}