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 "FallingTileRenderer.h"
3#include "TextureAtlas.h"
4#include "TileRenderer.h"
5#include "..\Minecraft.World\net.minecraft.world.entity.item.h"
6#include "..\Minecraft.World\net.minecraft.world.level.h"
7#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
8#include "EntityRenderDispatcher.h"
9
10FallingTileRenderer::FallingTileRenderer() : EntityRenderer()
11{
12 tileRenderer = new TileRenderer();
13 this->shadowRadius = 0.5f;
14}
15
16void FallingTileRenderer::render(shared_ptr<Entity> _tile, double x, double y, double z, float rot, float a)
17{
18 // 4J - dynamic cast required because we aren't using templates/generics in our version
19 shared_ptr<FallingTile> tile = dynamic_pointer_cast<FallingTile>(_tile);
20 Level *level = tile->getLevel();
21
22 if (level->getTile(floor(tile->x), floor(tile->y), floor(tile->z)) != tile->tile)
23 {
24 glPushMatrix();
25 glTranslatef((float) x, (float) y, (float) z);
26
27 bindTexture(tile); // 4J was L"/terrain.png"
28 Tile *tt = Tile::tiles[tile->tile];
29
30 Level *level = tile->getLevel();
31
32 glDisable(GL_LIGHTING);
33 glColor4f(1, 1, 1, 1); // 4J added - this wouldn't be needed in real opengl as the block render has vertex colours and so this isn't use, but our pretend gl always modulates with this
34 if (tt == Tile::anvil && tt->getRenderShape() == Tile::SHAPE_ANVIL)
35 {
36 tileRenderer->level = level;
37 Tesselator *t = Tesselator::getInstance();
38 t->begin();
39 t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f, -Mth::floor(tile->z) - 0.5f);
40 tileRenderer->tesselateAnvilInWorld((AnvilTile *) tt, Mth::floor(tile->x), Mth::floor(tile->y), Mth::floor(tile->z), tile->data);
41 t->offset(0, 0, 0);
42 t->end();
43 }
44 else if (tt == Tile::dragonEgg)
45 {
46 tileRenderer->level = level;
47 Tesselator *t = Tesselator::getInstance();
48 t->begin();
49 t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f, -Mth::floor(tile->z) - 0.5f);
50 tileRenderer->tesselateInWorld(tt, Mth::floor(tile->x), Mth::floor(tile->y), Mth::floor(tile->z));
51 t->offset(0, 0, 0);
52 t->end();
53 }
54 else if( tt != NULL )
55 {
56 tileRenderer->setShape(tt);
57 tileRenderer->renderBlock(tt, level, Mth::floor(tile->x), Mth::floor(tile->y), Mth::floor(tile->z), tile->data);
58 }
59 glEnable(GL_LIGHTING);
60 glPopMatrix();
61 }
62}
63
64ResourceLocation *FallingTileRenderer::getTextureLocation(shared_ptr<Entity> mob)
65{
66 return &TextureAtlas::LOCATION_BLOCKS;
67}