From 6690ca03c476ee8970970896507eb49fff5a74fc Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 1 Jul 2023 18:18:15 +0300 Subject: [PATCH] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2017:34=20=D1=8D=D1=82=D0=BE?= =?UTF-8?q?-=D1=82=D0=BE=20=D0=BB=D0=B5=D0=B3=D0=BA=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit <----- clueless --- .../mc/otm/block/decorative/FluidTankBlock.kt | 19 +++++++++++++++++++ .../entity/decorative/FluidTankBlockEntity.kt | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) 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)