diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/DaylightDetectorTile.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a43994725008e35fceb984d5549df9c8cea470.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/DaylightDetectorTile.cpp')
| -rw-r--r-- | Minecraft.World/DaylightDetectorTile.cpp | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/Minecraft.World/DaylightDetectorTile.cpp b/Minecraft.World/DaylightDetectorTile.cpp new file mode 100644 index 00000000..1bc9943e --- /dev/null +++ b/Minecraft.World/DaylightDetectorTile.cpp @@ -0,0 +1,114 @@ +#include "stdafx.h" +#include "net.minecraft.h" +#include "net.minecraft.world.level.dimension.h" +#include "net.minecraft.world.level.h" +#include "net.minecraft.world.level.redstone.h" +#include "net.minecraft.world.level.tile.entity.h" +#include "net.minecraft.world.h" +#include "JavaMath.h" +#include "DaylightDetectorTile.h" + +DaylightDetectorTile::DaylightDetectorTile(int id) : BaseEntityTile(id, Material::wood, isSolidRender() ) +{ + updateDefaultShape(); +} + +void DaylightDetectorTile::updateDefaultShape() +{ + setShape(0, 0, 0, 1, 6.0f / 16.0f, 1); +} + +void DaylightDetectorTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) +{ + setShape(0, 0, 0, 1, 6.0f / 16.0f, 1); +} + +int DaylightDetectorTile::getSignal(LevelSource *level, int x, int y, int z, int dir) +{ + return level->getData(x, y, z); +} + +void DaylightDetectorTile::tick(Level *level, int x, int y, int z, Random *random) +{ + // updateSignalStrength(level, x, y, z); +} + +void DaylightDetectorTile::neighborChanged(Level *level, int x, int y, int z, int type) +{ + // level.addToTickNextTick(x, y, z, id, getTickDelay()); +} + +void DaylightDetectorTile::onPlace(Level *level, int x, int y, int z) +{ + // level.addToTickNextTick(x, y, z, id, getTickDelay()); +} + +void DaylightDetectorTile::updateSignalStrength(Level *level, int x, int y, int z) +{ + if (level->dimension->hasCeiling) return; + + int current = level->getData(x, y, z); + int target = level->getBrightness(LightLayer::Sky, x, y, z) - level->skyDarken; + float sunAngle = level->getSunAngle(1); + + // tilt sunAngle towards zenith (to make the transition to night + // smoother) + if (sunAngle < PI) + { + sunAngle = sunAngle + (0 - sunAngle) * .2f; + } + else + { + sunAngle = sunAngle + (PI * 2.0f - sunAngle) * .2f; + } + + target = Math::round((float) target * Mth::cos(sunAngle)); + if (target < 0) + { + target = 0; + } + if (target > Redstone::SIGNAL_MAX) + { + target = Redstone::SIGNAL_MAX; + } + + if (current != target) + { + level->setData(x, y, z, target, UPDATE_ALL); + } +} + +bool DaylightDetectorTile::isCubeShaped() +{ + return false; +} + +bool DaylightDetectorTile::isSolidRender(bool isServerLevel) +{ + return false; +} + +bool DaylightDetectorTile::isSignalSource() +{ + return true; +} + +shared_ptr<TileEntity> DaylightDetectorTile::newTileEntity(Level *level) +{ + return shared_ptr<DaylightDetectorTileEntity>( new DaylightDetectorTileEntity() ); +} + +Icon *DaylightDetectorTile::getTexture(int face, int data) +{ + if (face == Facing::UP) + { + return icons[0]; + } + return icons[1]; +} + +void DaylightDetectorTile::registerIcons(IconRegister *iconRegister) +{ + icons[0] = iconRegister->registerIcon(getIconName() + L"_top"); + icons[1] = iconRegister->registerIcon(getIconName() + L"_side"); +}
\ No newline at end of file |
