20 lines
752 B
Kotlin
20 lines
752 B
Kotlin
package de.mattv.quarry
|
|
|
|
import net.minecraft.world.InteractionHand
|
|
import net.minecraft.world.InteractionResult
|
|
import net.minecraft.world.item.CreativeModeTab
|
|
import net.minecraft.world.item.Item
|
|
import net.minecraft.world.item.context.UseOnContext
|
|
|
|
class QuarryUpgrade(val ty: Type) : Item(Properties().tab(CreativeModeTab.TAB_MISC)) {
|
|
enum class Type { SPEED, FORTUNE }
|
|
|
|
override fun useOn(ctx: UseOnContext): InteractionResult {
|
|
val be = ctx.level.getBlockEntity(ctx.clickedPos)
|
|
if (!ctx.level.isClientSide() && ctx.hand == InteractionHand.MAIN_HAND && be is QuarryTile) {
|
|
be.useUpgrade(ctx.player!!, ctx.itemInHand)
|
|
return InteractionResult.CONSUME
|
|
}
|
|
return super.useOn(ctx)
|
|
}
|
|
} |