package com.futhark.item; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemUsageContext; import net.minecraft.util.ActionResult; import net.minecraft.util.math.BlockPos; import static com.futhark.block.ModBlocks.RUNE_BLOCK; public class RunicChiselItem extends Item { public RunicChiselItem(Settings settings) { super(settings); } @Override public ActionResult useOnBlock(ItemUsageContext context) { if (!context.getWorld().isClient()) { BlockPos pos = context.getBlockPos(); PlayerEntity player = context.getPlayer(); BlockState state = context.getWorld().getBlockState(pos); if (state.isOf(Blocks.STONE)) { context.getWorld().setBlockState(pos, RUNE_BLOCK.getDefaultState()); } else if (state.isOf(RUNE_BLOCK)) { context.getWorld().setBlockState(pos, Blocks.STONE.getDefaultState()); } } return ActionResult.SUCCESS; } }