package ru.dbotthepony.mc.otm.block.decorative

import net.minecraft.ChatFormatting
import net.minecraft.core.BlockPos
import net.minecraft.network.chat.Component
import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.TooltipFlag
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.block.SoundType
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.material.MapColor
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
import ru.dbotthepony.mc.otm.shapes.BlockShapes

class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_ORANGE).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) {
	override fun appendHoverText(
		p_49816_: ItemStack,
		p_49817_: BlockGetter?,
		p_49818_: MutableList<Component>,
		p_49819_: TooltipFlag
	) {
		super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_)
		p_49818_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.DARK_GRAY))
	}

	override fun rotationFreedom(): BlockRotationFreedom {
		return BlockRotationFreedom.TWO
	}

	private val shapes = getShapeForEachState { BlockShapes.ENGINE.rotateFromNorth(it[rotationProperty]).computeShape() }

	override fun getShape(
		p_60555_: BlockState,
		p_60556_: BlockGetter,
		p_60557_: BlockPos,
		p_60558_: CollisionContext
	): VoxelShape {
		return shapes[p_60555_]!!
	}
}
