Search in sources :

Example 1 with BlockBeetroot

use of net.minecraft.block.BlockBeetroot in project VoodooCraft by Mod-DevCafeTeam.

the class HexGreenFingers method activeUse.

@Override
public ItemStack activeUse(ItemStack stackIn, World world, EntityPlayer player, EnumHand hand, int strength, @Nullable EntityLivingBase target) {
    if (world.isRemote)
        return super.activeUse(stackIn, world, player, hand, strength, target);
    RayTraceResult result = Minecraft.getMinecraft().objectMouseOver;
    BlockPos pos = result.getBlockPos();
    Block block = world.getBlockState(pos).getBlock();
    if (block instanceof BlockCrops) {
        if (block instanceof BlockBeetroot) {
            world.setBlockState(pos, block.getDefaultState().cycleProperty(BlockBeetroot.BEETROOT_AGE));
        } else {
            world.setBlockState(pos, block.getDefaultState().cycleProperty(BlockCrops.AGE));
        }
    }
    return super.activeUse(stackIn, world, player, hand, strength, target);
}
Also used : BlockCrops(net.minecraft.block.BlockCrops) RayTraceResult(net.minecraft.util.math.RayTraceResult) Block(net.minecraft.block.Block) BlockBeetroot(net.minecraft.block.BlockBeetroot) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

Block (net.minecraft.block.Block)1 BlockBeetroot (net.minecraft.block.BlockBeetroot)1 BlockCrops (net.minecraft.block.BlockCrops)1 BlockPos (net.minecraft.util.math.BlockPos)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1