Allow interacting with essence storage as fluid tank

This commit is contained in:
DBotThePony 2025-02-21 18:21:27 +07:00
parent e53676a91f
commit 0b5ff224f8
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -23,6 +23,7 @@ import net.minecraft.world.level.material.PushReaction
import net.minecraft.world.phys.BlockHitResult
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape
import net.neoforged.neoforge.fluids.FluidUtil
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
import ru.dbotthepony.mc.otm.block.addSimpleDescription
import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity
@ -32,6 +33,7 @@ import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.core.util.getLevelFromXp
import ru.dbotthepony.mc.otm.item.EssenceServoItem
import ru.dbotthepony.mc.otm.registry.game.MItems
import ru.dbotthepony.mc.otm.shapes.BlockShapes
@ -65,8 +67,12 @@ class EssenceStorageBlock(val color: DyeColor?) : RotatableMatteryBlock(Properti
}
override fun useItemOn(itemStack: ItemStack, blockState: BlockState, level: Level, blockPos: BlockPos, ply: Player, hand: InteractionHand, blockHitResult: BlockHitResult): ItemInteractionResult {
if (itemStack.item == MItems.ESSENCE_SERVO) {
return MItems.ESSENCE_SERVO.useServo(ply, blockPos)
if (itemStack.item is EssenceServoItem) {
return (itemStack.item as EssenceServoItem).useServo(ply, blockPos)
}
if (FluidUtil.interactWithFluidHandler(ply, hand, level, blockPos, blockHitResult.direction)) {
return ItemInteractionResult.sidedSuccess(level.isClientSide)
}
return super.useItemOn(itemStack, blockState, level, blockPos, ply, hand, blockHitResult)