TechManDylan

Farmer

Apr 29th, 2026 (edited)
47
0
Never
10
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.52 KB | None | 0 0
  1. -- Wheat Harvester + Instant Replanter Turtle
  2. -- For ComputerCraft / CC:Tweaked
  3. --
  4. -- Setup:
  5. -- Turtle starts 1 block above the wheat crop space.
  6. -- Turtle faces forward down the first row.
  7. -- Chest is directly behind the turtle's starting position.
  8. -- Infinite fuel is enabled.
  9. --
  10. -- New boundary rule:
  11. -- Air below = valid farm space.
  12. -- Wheat below = valid farm space.
  13. -- Cobblestone/slabs below = ignored water cover.
  14. -- Any other detected block below = border/barrier/end of row.
  15.  
  16. --------------------------------------------------
  17. -- CONFIG
  18. --------------------------------------------------
  19.  
  20. local CHECK_DELAY = 60
  21. local SEEDS_TO_KEEP = 64
  22. local CHEST_PULL_ATTEMPTS = 8
  23. local ENABLE_CHEST_SEED_PULL = true
  24. local PLANT_EMPTY_SPOTS = true
  25.  
  26. --------------------------------------------------
  27. -- POSITION TRACKING
  28. --------------------------------------------------
  29.  
  30. -- x = sideways from start
  31. -- y = forward/back from start
  32. -- dir:
  33. -- 0 = starting forward
  34. -- 1 = right
  35. -- 2 = backward
  36. -- 3 = left
  37.  
  38. local x, y, dir = 0, 0, 0
  39.  
  40. --------------------------------------------------
  41. -- BASIC HELPERS
  42. --------------------------------------------------
  43.  
  44. local function log(msg)
  45. print("[WheatBot] " .. msg)
  46. end
  47.  
  48. local function updateForward()
  49. if dir == 0 then
  50. y = y + 1
  51. elseif dir == 1 then
  52. x = x + 1
  53. elseif dir == 2 then
  54. y = y - 1
  55. elseif dir == 3 then
  56. x = x - 1
  57. end
  58. end
  59.  
  60. local function updateBack()
  61. if dir == 0 then
  62. y = y - 1
  63. elseif dir == 1 then
  64. x = x - 1
  65. elseif dir == 2 then
  66. y = y + 1
  67. elseif dir == 3 then
  68. x = x + 1
  69. end
  70. end
  71.  
  72. local function turnRight()
  73. turtle.turnRight()
  74. dir = (dir + 1) % 4
  75. end
  76.  
  77. local function turnLeft()
  78. turtle.turnLeft()
  79. dir = (dir + 3) % 4
  80. end
  81.  
  82. local function face(targetDir)
  83. while dir ~= targetDir do
  84. turnRight()
  85. end
  86. end
  87.  
  88. local function forward()
  89. while not turtle.forward() do
  90. -- Do not put your border wall at turtle height,
  91. -- or the turtle will try to dig it.
  92. turtle.dig()
  93. sleep(0.25)
  94. end
  95.  
  96. updateForward()
  97. end
  98.  
  99. local function back()
  100. while not turtle.back() do
  101. turnRight()
  102. turnRight()
  103. turtle.dig()
  104. turnRight()
  105. turnRight()
  106. sleep(0.25)
  107. end
  108.  
  109. updateBack()
  110. end
  111.  
  112. local function goTo(targetX, targetY)
  113. if x < targetX then
  114. face(1)
  115. while x < targetX do
  116. forward()
  117. end
  118. elseif x > targetX then
  119. face(3)
  120. while x > targetX do
  121. forward()
  122. end
  123. end
  124.  
  125. if y < targetY then
  126. face(0)
  127. while y < targetY do
  128. forward()
  129. end
  130. elseif y > targetY then
  131. face(2)
  132. while y > targetY do
  133. forward()
  134. end
  135. end
  136. end
  137.  
  138. local function goHome()
  139. goTo(0, 0)
  140. face(0)
  141. end
  142.  
  143. local function returnTo(savedX, savedY, savedDir)
  144. goTo(savedX, savedY)
  145. face(savedDir)
  146. end
  147.  
  148. --------------------------------------------------
  149. -- BLOCK / ITEM CHECKS
  150. --------------------------------------------------
  151.  
  152. local function isWheatBlock(name)
  153. return name == "minecraft:wheat"
  154. end
  155.  
  156. local function isFarmlandBlock(name)
  157. return name == "minecraft:farmland"
  158. end
  159.  
  160. local function isSeedItem(name)
  161. return name == "minecraft:wheat_seeds" or name == "minecraft:seeds"
  162. end
  163.  
  164. local function isIgnoredWaterCoverBlock(data)
  165. if not data then
  166. return false
  167. end
  168.  
  169. local name = data.name
  170.  
  171. if name == "minecraft:cobblestone" then
  172. return true
  173. end
  174.  
  175. if name == "minecraft:cobblestone_slab" then
  176. return true
  177. end
  178.  
  179. -- Minecraft 1.12.2 often reports cobblestone slabs as minecraft:stone_slab.
  180. if name == "minecraft:stone_slab" then
  181. return true
  182. end
  183.  
  184. if name == "minecraft:stone_slab2" then
  185. return true
  186. end
  187.  
  188. return false
  189. end
  190.  
  191. local function getBlockDown()
  192. local ok, data = turtle.inspectDown()
  193.  
  194. if not ok then
  195. return nil
  196. end
  197.  
  198. return data
  199. end
  200.  
  201. -- This is the main new rule.
  202. -- nil/air below is allowed.
  203. -- wheat is allowed.
  204. -- farmland is allowed, just in case your turtle sees it directly.
  205. -- cobble/slabs are allowed as pass-through water covers.
  206. -- anything else is treated as a border/end marker.
  207. local function isBoundaryBlockBelow()
  208. local data = getBlockDown()
  209.  
  210. -- Air below means crop space is empty.
  211. -- This should NOT trigger a turn anymore.
  212. if not data then
  213. return false
  214. end
  215.  
  216. if isWheatBlock(data.name) then
  217. return false
  218. end
  219.  
  220. if isFarmlandBlock(data.name) then
  221. return false
  222. end
  223.  
  224. if isIgnoredWaterCoverBlock(data) then
  225. return false
  226. end
  227.  
  228. return true
  229. end
  230.  
  231. local function isWaterCoverBelow()
  232. local data = getBlockDown()
  233. return isIgnoredWaterCoverBlock(data)
  234. end
  235.  
  236. local function isWheatBelow()
  237. local data = getBlockDown()
  238.  
  239. if not data then
  240. return false
  241. end
  242.  
  243. return isWheatBlock(data.name)
  244. end
  245.  
  246. local function isPlantableFarmSpace()
  247. local data = getBlockDown()
  248.  
  249. -- Empty air below turtle usually means empty crop space above farmland.
  250. if not data then
  251. return true
  252. end
  253.  
  254. -- If it sees farmland directly, try planting too.
  255. if isFarmlandBlock(data.name) then
  256. return true
  257. end
  258.  
  259. return false
  260. end
  261.  
  262. local function wheatIsReady()
  263. local data = getBlockDown()
  264.  
  265. if not data then
  266. return false
  267. end
  268.  
  269. if not isWheatBlock(data.name) then
  270. return false
  271. end
  272.  
  273. if data.state and data.state.age ~= nil then
  274. return tonumber(data.state.age) >= 7
  275. end
  276.  
  277. return false
  278. end
  279.  
  280. --------------------------------------------------
  281. -- INVENTORY HELPERS
  282. --------------------------------------------------
  283.  
  284. local function countEmptySlots()
  285. local empty = 0
  286.  
  287. for slot = 1, 16 do
  288. if turtle.getItemCount(slot) == 0 then
  289. empty = empty + 1
  290. end
  291. end
  292.  
  293. return empty
  294. end
  295.  
  296. local function countSeeds()
  297. local total = 0
  298.  
  299. for slot = 1, 16 do
  300. local item = turtle.getItemDetail(slot)
  301.  
  302. if item and isSeedItem(item.name) then
  303. total = total + turtle.getItemCount(slot)
  304. end
  305. end
  306.  
  307. return total
  308. end
  309.  
  310. local function selectSeedSlot()
  311. local currentSlot = turtle.getSelectedSlot()
  312. local currentItem = turtle.getItemDetail(currentSlot)
  313.  
  314. if currentItem and isSeedItem(currentItem.name) and turtle.getItemCount(currentSlot) > 0 then
  315. return true
  316. end
  317.  
  318. for slot = 1, 16 do
  319. local item = turtle.getItemDetail(slot)
  320.  
  321. if item and isSeedItem(item.name) and turtle.getItemCount(slot) > 0 then
  322. turtle.select(slot)
  323. return true
  324. end
  325. end
  326.  
  327. return false
  328. end
  329.  
  330. local function hasUsefulFreeSpace()
  331. return countEmptySlots() > 0
  332. end
  333.  
  334. --------------------------------------------------
  335. -- CHEST HELPERS
  336. --------------------------------------------------
  337.  
  338. local function faceChest()
  339. goHome()
  340. face(2)
  341. end
  342.  
  343. local function pullFromChest()
  344. faceChest()
  345.  
  346. for i = 1, CHEST_PULL_ATTEMPTS do
  347. if countEmptySlots() <= 0 then
  348. break
  349. end
  350.  
  351. turtle.suck()
  352. sleep(0.1)
  353. end
  354.  
  355. face(0)
  356. end
  357.  
  358. local function depositItems()
  359. goHome()
  360. face(2)
  361.  
  362. local seedsLeftToKeep = SEEDS_TO_KEEP
  363.  
  364. for slot = 1, 16 do
  365. turtle.select(slot)
  366.  
  367. local item = turtle.getItemDetail(slot)
  368.  
  369. if item then
  370. if isSeedItem(item.name) then
  371. local count = turtle.getItemCount(slot)
  372.  
  373. if seedsLeftToKeep > 0 then
  374. if count <= seedsLeftToKeep then
  375. seedsLeftToKeep = seedsLeftToKeep - count
  376. else
  377. local amountToDrop = count - seedsLeftToKeep
  378. turtle.drop(amountToDrop)
  379. seedsLeftToKeep = 0
  380. end
  381. else
  382. turtle.drop()
  383. end
  384. else
  385. turtle.drop()
  386. end
  387. end
  388. end
  389.  
  390. face(0)
  391. turtle.select(1)
  392. end
  393.  
  394. local function depositButKeepSeeds()
  395. depositItems()
  396. end
  397.  
  398. local function restockSeedsAndReturn(savedX, savedY, savedDir)
  399. if not ENABLE_CHEST_SEED_PULL then
  400. return false
  401. end
  402.  
  403. log("No seeds in inventory. Returning to chest for seeds.")
  404.  
  405. pullFromChest()
  406.  
  407. if countSeeds() <= 0 then
  408. log("No seeds found in chest.")
  409. depositButKeepSeeds()
  410. returnTo(savedX, savedY, savedDir)
  411. return false
  412. end
  413.  
  414. depositButKeepSeeds()
  415. returnTo(savedX, savedY, savedDir)
  416.  
  417. return countSeeds() > 0
  418. end
  419.  
  420. --------------------------------------------------
  421. -- SEED PLANTING
  422. --------------------------------------------------
  423.  
  424. local function placeSeedDown()
  425. if not selectSeedSlot() then
  426. return false
  427. end
  428.  
  429. if turtle.placeDown() then
  430. sleep(0.1)
  431. return true
  432. end
  433.  
  434. -- Try every seed stack if the first one fails.
  435. for slot = 1, 16 do
  436. local item = turtle.getItemDetail(slot)
  437.  
  438. if item and isSeedItem(item.name) and turtle.getItemCount(slot) > 0 then
  439. turtle.select(slot)
  440.  
  441. if turtle.placeDown() then
  442. sleep(0.1)
  443. return true
  444. end
  445. end
  446. end
  447.  
  448. return false
  449. end
  450.  
  451. local function ensureSeedsAtCurrentPosition()
  452. if countSeeds() > 0 then
  453. return true
  454. end
  455.  
  456. local savedX = x
  457. local savedY = y
  458. local savedDir = dir
  459.  
  460. return restockSeedsAndReturn(savedX, savedY, savedDir)
  461. end
  462.  
  463. local function plantEmptySpotIfNeeded()
  464. if not PLANT_EMPTY_SPOTS then
  465. return false
  466. end
  467.  
  468. if isBoundaryBlockBelow() then
  469. return false
  470. end
  471.  
  472. if isWaterCoverBelow() then
  473. return false
  474. end
  475.  
  476. if isWheatBelow() then
  477. return false
  478. end
  479.  
  480. if not isPlantableFarmSpace() then
  481. return false
  482. end
  483.  
  484. if not ensureSeedsAtCurrentPosition() then
  485. return false
  486. end
  487.  
  488. if placeSeedDown() then
  489. log("Planted empty spot.")
  490. return true
  491. end
  492.  
  493. return false
  494. end
  495.  
  496. --------------------------------------------------
  497. -- FARM ACTIONS
  498. --------------------------------------------------
  499.  
  500. local function harvestAndReplantIfReady()
  501. if not wheatIsReady() then
  502. return false
  503. end
  504.  
  505. if not ensureSeedsAtCurrentPosition() then
  506. log("Skipping harvest because no seeds are available.")
  507. return false
  508. end
  509.  
  510. turtle.digDown()
  511. sleep(0.2)
  512.  
  513. if placeSeedDown() then
  514. log("Harvested and replanted.")
  515. else
  516. log("Harvested, but failed to replant.")
  517. end
  518.  
  519. return true
  520. end
  521.  
  522. --------------------------------------------------
  523. -- INVENTORY FULL PROTECTION
  524. --------------------------------------------------
  525.  
  526. local function handleInventoryIfFull()
  527. if hasUsefulFreeSpace() then
  528. return
  529. end
  530.  
  531. log("Inventory full. Returning home to deposit.")
  532.  
  533. local savedX = x
  534. local savedY = y
  535. local savedDir = dir
  536.  
  537. depositButKeepSeeds()
  538.  
  539. log("Returning to previous farm position.")
  540. returnTo(savedX, savedY, savedDir)
  541. end
  542.  
  543. --------------------------------------------------
  544. -- FIELD SCANNING
  545. --------------------------------------------------
  546.  
  547. local function tryMoveToNextRow(turnRightNext)
  548. if turnRightNext then
  549. turnRight()
  550. forward()
  551.  
  552. if isBoundaryBlockBelow() then
  553. back()
  554. turnLeft()
  555. return false
  556. end
  557.  
  558. turnRight()
  559. return true
  560. else
  561. turnLeft()
  562. forward()
  563.  
  564. if isBoundaryBlockBelow() then
  565. back()
  566. turnRight()
  567. return false
  568. end
  569.  
  570. turnLeft()
  571. return true
  572. end
  573. end
  574.  
  575. local function scanAndHarvest()
  576. local checkedCells = 0
  577. local harvested = 0
  578. local planted = 0
  579. local turnRightNext = true
  580.  
  581. log("Starting farm scan...")
  582.  
  583. while true do
  584. if isBoundaryBlockBelow() then
  585. break
  586. end
  587.  
  588. handleInventoryIfFull()
  589.  
  590. if isWaterCoverBelow() then
  591. -- Cobble/slab water cover. Skip it.
  592. elseif isWheatBelow() then
  593. checkedCells = checkedCells + 1
  594.  
  595. if harvestAndReplantIfReady() then
  596. harvested = harvested + 1
  597. end
  598. else
  599. checkedCells = checkedCells + 1
  600.  
  601. if plantEmptySpotIfNeeded() then
  602. planted = planted + 1
  603. end
  604. end
  605.  
  606. forward()
  607.  
  608. if isBoundaryBlockBelow() then
  609. back()
  610.  
  611. local movedToNextRow = tryMoveToNextRow(turnRightNext)
  612.  
  613. if not movedToNextRow then
  614. break
  615. end
  616.  
  617. turnRightNext = not turnRightNext
  618. end
  619. end
  620.  
  621. log("Farm scan complete.")
  622. log("Checked farm cells: " .. tostring(checkedCells))
  623. log("Wheat harvested: " .. tostring(harvested))
  624. log("Empty spots planted: " .. tostring(planted))
  625.  
  626. return checkedCells, harvested, planted
  627. end
  628.  
  629. --------------------------------------------------
  630. -- MAIN CYCLE
  631. --------------------------------------------------
  632.  
  633. local function runFarmCycle()
  634. local checkedCells, harvested, planted = scanAndHarvest()
  635.  
  636. if checkedCells == 0 then
  637. log("No farm path detected. Make sure border blocks are only around the outside.")
  638. goHome()
  639. return false
  640. end
  641.  
  642. goHome()
  643. depositItems()
  644.  
  645. if harvested == 0 then
  646. log("No mature wheat found this cycle.")
  647. end
  648.  
  649. log("Cycle complete. Waiting for wheat to grow again.")
  650. return true
  651. end
  652.  
  653. --------------------------------------------------
  654. -- START
  655. --------------------------------------------------
  656.  
  657. log("Wheat farm turtle started.")
  658. log("Start above first crop space.")
  659. log("Chest must be directly behind starting position.")
  660. log("Infinite fuel mode enabled.")
  661. log("Air below is treated as valid farm space.")
  662. log("Any non-cobble/slab/non-wheat block below is treated as a border.")
  663.  
  664. while true do
  665. local success = runFarmCycle()
  666.  
  667. if not success then
  668. log("Issue detected. Retrying soon.")
  669. sleep(30)
  670. else
  671. sleep(CHECK_DELAY)
  672. end
  673. end
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Silsaldo
    26 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • Julikky
    21 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • Jautovoh
    2 days
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=jzxvqlbehn
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment