the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 71 lines 3.0 kB view raw
1#include "stdafx.h" 2#include "PistonPieceRenderer.h" 3#include "Lighting.h" 4#include "Tesselator.h" 5#include "TextureAtlas.h" 6#include "TileRenderer.h" 7#include "..\Minecraft.World\net.minecraft.world.level.h" 8#include "..\Minecraft.World\PistonPieceEntity.h" 9#include "..\Minecraft.World\net.minecraft.world.level.tile.h" 10 11ResourceLocation PistonPieceRenderer::SIGN_LOCATION = ResourceLocation(TN_ITEM_SIGN); 12 13PistonPieceRenderer::PistonPieceRenderer() 14{ 15 tileRenderer = NULL; 16} 17 18void PistonPieceRenderer::render(shared_ptr<TileEntity> _entity, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled) 19{ 20 // 4J - dynamic cast required because we aren't using templates/generics in our version 21 shared_ptr<PistonPieceEntity> entity = dynamic_pointer_cast<PistonPieceEntity>(_entity); 22 23 Tile *tile = Tile::tiles[entity->getId()]; 24 if (tile != NULL && entity->getProgress(a) <= 1) // 4J - changed condition from < to <= as our chunk update is async to main thread and so we can have to render these with progress of 1 25 { 26 Tesselator *t = Tesselator::getInstance(); 27 bindTexture(&TextureAtlas::LOCATION_BLOCKS); 28 29 Lighting::turnOff(); 30 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 31 32 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 33 glEnable(GL_BLEND); 34 glDisable(GL_CULL_FACE); 35 36 t->begin(); 37 38 t->offset((float) x - entity->x + entity->getXOff(a), (float) y - entity->y + entity->getYOff(a), (float) z - entity->z + entity->getZOff(a)); 39 t->color(1, 1, 1); 40 if (tile == Tile::pistonExtension && entity->getProgress(a) < 0.5f) 41 { 42 // extending arms may appear through the base block 43 tileRenderer->tesselatePistonArmNoCulling(tile, entity->x, entity->y, entity->z, false, entity->getData()); 44 } 45 else if (entity->isSourcePiston() && !entity->isExtending()) 46 { 47 // special case for withdrawing the arm back into the base 48 Tile::pistonExtension->setOverrideTopTexture(((PistonBaseTile *) tile)->getPlatformTexture()); 49 tileRenderer->tesselatePistonArmNoCulling(Tile::pistonExtension, entity->x, entity->y, entity->z, entity->getProgress(a) < 0.5f, entity->getData()); 50 Tile::pistonExtension->clearOverrideTopTexture(); 51 52 t->offset((float) x - entity->x, (float) y - entity->y, (float) z - entity->z); 53 tileRenderer->tesselatePistonBaseForceExtended(tile, entity->x, entity->y, entity->z, entity->getData()); 54 } 55 else 56 { 57 tileRenderer->tesselateInWorldNoCulling(tile, entity->x, entity->y, entity->z, entity->getData(), entity); 58 } 59 t->offset(0, 0, 0); 60 t->end(); 61 62 Lighting::turnOn(); 63 } 64 65} 66 67void PistonPieceRenderer::onNewLevel(Level *level) 68{ 69 delete tileRenderer; 70 tileRenderer = new TileRenderer(level); 71}