diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt index 37e5483ac..6764fc0b4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt @@ -53,4 +53,23 @@ class FluidTankBlock : RotatableMatteryBlock(), EntityBlock { ): VoxelShape { return shapes[state]!! } + + override fun getLightEmission(state: BlockState?, level: BlockGetter?, pos: BlockPos?): Int { + if (pos == BlockPos.ZERO) return 15 + + val lightLevel = super.getLightEmission(state, level, pos) + + val tile = level?.getExistingBlockEntity(pos) ?: lightLevel + + if (tile is FluidTankBlockEntity) { + val fluid = tile.synchronizedFluid + + if (!fluid.isEmpty) { + val newLevel = fluid.fluid.fluidType.getLightLevel(fluid) + return newLevel.coerceAtLeast(lightLevel) + } + } + + return lightLevel + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt index 5b184133e..ce5f0ac78 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt @@ -29,8 +29,11 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.FLUID_TANK, blockPos, blockState) { val fluid = BlockMatteryFluidHandler(::onChanged, ItemsConfig::FLUID_TANK_CAPACITY) - var synchronizedFluid by synchronizer.Field(FluidStack.EMPTY, FluidStackValueCodec) - private set + var synchronizedFluid by synchronizer.Field(FluidStack.EMPTY, FluidStackValueCodec, setter = { value, access, remote -> + access.write(value) + + level?.lightEngine?.checkBlock(blockPos) + }) val fillInput = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) val drainInput = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer)