the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 114 lines 2.8 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.h" 3#include "net.minecraft.world.level.dimension.h" 4#include "net.minecraft.world.level.h" 5#include "net.minecraft.world.level.redstone.h" 6#include "net.minecraft.world.level.tile.entity.h" 7#include "net.minecraft.world.h" 8#include "JavaMath.h" 9#include "DaylightDetectorTile.h" 10 11DaylightDetectorTile::DaylightDetectorTile(int id) : BaseEntityTile(id, Material::wood, isSolidRender() ) 12{ 13 updateDefaultShape(); 14} 15 16void DaylightDetectorTile::updateDefaultShape() 17{ 18 setShape(0, 0, 0, 1, 6.0f / 16.0f, 1); 19} 20 21void DaylightDetectorTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) 22{ 23 setShape(0, 0, 0, 1, 6.0f / 16.0f, 1); 24} 25 26int DaylightDetectorTile::getSignal(LevelSource *level, int x, int y, int z, int dir) 27{ 28 return level->getData(x, y, z); 29} 30 31void DaylightDetectorTile::tick(Level *level, int x, int y, int z, Random *random) 32{ 33 // updateSignalStrength(level, x, y, z); 34} 35 36void DaylightDetectorTile::neighborChanged(Level *level, int x, int y, int z, int type) 37{ 38 // level.addToTickNextTick(x, y, z, id, getTickDelay()); 39} 40 41void DaylightDetectorTile::onPlace(Level *level, int x, int y, int z) 42{ 43 // level.addToTickNextTick(x, y, z, id, getTickDelay()); 44} 45 46void DaylightDetectorTile::updateSignalStrength(Level *level, int x, int y, int z) 47{ 48 if (level->dimension->hasCeiling) return; 49 50 int current = level->getData(x, y, z); 51 int target = level->getBrightness(LightLayer::Sky, x, y, z) - level->skyDarken; 52 float sunAngle = level->getSunAngle(1); 53 54 // tilt sunAngle towards zenith (to make the transition to night 55 // smoother) 56 if (sunAngle < PI) 57 { 58 sunAngle = sunAngle + (0 - sunAngle) * .2f; 59 } 60 else 61 { 62 sunAngle = sunAngle + (PI * 2.0f - sunAngle) * .2f; 63 } 64 65 target = Math::round((float) target * Mth::cos(sunAngle)); 66 if (target < 0) 67 { 68 target = 0; 69 } 70 if (target > Redstone::SIGNAL_MAX) 71 { 72 target = Redstone::SIGNAL_MAX; 73 } 74 75 if (current != target) 76 { 77 level->setData(x, y, z, target, UPDATE_ALL); 78 } 79} 80 81bool DaylightDetectorTile::isCubeShaped() 82{ 83 return false; 84} 85 86bool DaylightDetectorTile::isSolidRender(bool isServerLevel) 87{ 88 return false; 89} 90 91bool DaylightDetectorTile::isSignalSource() 92{ 93 return true; 94} 95 96shared_ptr<TileEntity> DaylightDetectorTile::newTileEntity(Level *level) 97{ 98 return shared_ptr<DaylightDetectorTileEntity>( new DaylightDetectorTileEntity() ); 99} 100 101Icon *DaylightDetectorTile::getTexture(int face, int data) 102{ 103 if (face == Facing::UP) 104 { 105 return icons[0]; 106 } 107 return icons[1]; 108} 109 110void DaylightDetectorTile::registerIcons(IconRegister *iconRegister) 111{ 112 icons[0] = iconRegister->registerIcon(getIconName() + L"_top"); 113 icons[1] = iconRegister->registerIcon(getIconName() + L"_side"); 114}