Nukkit
Nukkit copied to clipboard
Daylight sensors implementation
This is a draft of a pull request with the implementation of daylight sensors.
TODOs:
- [x] Ensure that daylight sensors don't work in nether and end. Don't create a BlockEntityDaylightSensor for sensors placed in these worlds.
- [ ] Check if the power output levels are correct (they must be, as I copied the calculation logic from Minecraft sources (https://github.com/ObelouixServer/Minecraft-1.12/blob/2f4d739d08c237147982e970dd9bbae927d07f49/src/minecraft_server/net/minecraft/block/BlockDaylightDetector.java#L54), but I am not quite sure)
- [x] Remove logging (I used it for checking the power output)
- [x]
getStrongPower()
for BlockDaylightSensor must probably return 0 (from my understanding it means the ability of the block to strongly power other blocks, which daylight sensor doesn't have) - [x] Only call setBlockDataAt() when there are actual changes in power level (because updatePower() is being called every game tick and rewriting data every tick is a bad thing)
MINECRFAT JAVA EDITION SERVER SOURCE CODE that might need to be copied: World.checkLight() https://github.com/ObelouixServer/Minecraft-1.12/blob/2f4d739d08c237147982e970dd9bbae927d07f49/src/minecraft_server/net/minecraft/world/World.java#L2596
Currently there is not any skylight calculation
@Creeperface01 What do you mean?
He means there is no light calculation for block light in Nukkit so the light levels will not be correct for the daylight sensor.
@SupremeMortal @Creeperface01 What is missing from the light implementation?
Skylight
@Creeperface01 @SupremeMortal yeah, I know that it's the skylight, i meant what exactly is wrong with it? It seems to me that the reading of the light map from the world file and writing it back are implemented. Is it the skylight map update logic that needs to be implemented? Can someone pinpoint the exact things that need to be implemented in Nukkit so that skylight works as it's supposed to?
Alright, I think I found it, it is Level.updateBlockSkyLight() that is not implemented. https://github.com/NukkitX/Nukkit/blob/f82b9b7c389ff1cdb1f617d19239ee1b7e263e27/src/main/java/cn/nukkit/level/Level.java#L1494
We probably could copy logic from here https://github.com/pmmp/PocketMine-MP/blob/b788982d6000aff12182d4e3d726153581c5420c/src/pocketmine/level/Level.php#L1512
@Leonidius20 i think is better start a PR with reimplementing all redstone and will be async ;) or just threaded because nukkit is still single thread and that will make just lag.
sensors' power output seems to be correct now, but I'm not sure about skylight levels (for example, when I place a block on top of a sensor sensor's skylight value is 0 (as at should be), but when I remove it, the skylight level doesn't go back to 15.
You can use this plugin to test skylight levels and power outputs: https://drive.google.com/open?id=16ayjQ0owv2h9tgntz586MIX2-3Znu1bk It writes the info to the chat when you tap a block with a stick.
There is also a problem with my implementation of BaseFullChunk.populateSkyLight(). Non-exposed blocks have a value of 15 while exposed ones have a value of 0.