Solved Regenerating bamboo and sugarcane

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Iroh

New Member
Apr 8, 2022
9
0
1
  1. Script Version 2.6.1
  2. Minecraft Version 1.17
I am trying to make a skript that will allow bamboo and sugarcane to regenerate when broken.
The skript I am using for other crops is something like
Code:
on break of pumpkin or melon:
  if "%region at player%" contains "spawn":
    wait 35 seconds
    set {rand.fruit.block} to a random integer between 1 and 2
    if {rand.fruit.block} is 1:
      set the block to melon
    if {rand.fruit.block} is 2:
      set the block to pumpkin
but this will not work for bamboo or sugarcane because breaking the bottom block will cause the top blocks to break without registering those blocks as breaking in the script, so only the directly broken block regens.
I would instead like to know if I can make all blocks above the broken plant regen when a block is broken.

i hope this makes sense

also I can't use tuske or skillet btw
 
  1. Script Version 2.6.1
  2. Minecraft Version 1.17
I am trying to make a skript that will allow bamboo and sugarcane to regenerate when broken.
The skript I am using for other crops is something like
Code:
on break of pumpkin or melon:
  if "%region at player%" contains "spawn":
    wait 35 seconds
    set {rand.fruit.block} to a random integer between 1 and 2
    if {rand.fruit.block} is 1:
      set the block to melon
    if {rand.fruit.block} is 2:
      set the block to pumpkin
but this will not work for bamboo or sugarcane because breaking the bottom block will cause the top blocks to break without registering those blocks as breaking in the script, so only the directly broken block regens.
I would instead like to know if I can make all blocks above the broken plant regen when a block is broken.

i hope this makes sense

also I can't use tuske or skillet btw
Try getting the Y coordinate to avoid breaking the fist sugarcane
 
If anyone is having trouble with this or something similar, here was my solution:

Code:
on break of sugar cane:
  if "%region at player%" contains "spawn":
    cancel event
    if block above event-block is sugar cane:
      break block above event-block
      if block 2 above event-block is sugar cane:
        break block 2 above event-block
        if block 3 above event-block is sugar cane:
          break block 3 above event-block
          if block 4 above event-block is sugar cane:
            break block 4 above event-block
            if block 5 above event-block is sugar cane:
              break block 5 above event-block
              if block 6 above event-block is sugar cane:
                break block 6 above event-block
                wait 20 seconds
                set block above event-block to sugar cane
                set block 2 above event-block to sugar cane
                set block 3 above event-block to sugar cane
                set block 4 above event-block to sugar cane
                set block 5 above event-block to sugar cane
                set block 6 above event-block to sugar cane
              else:
                wait 20 seconds
                set block above event-block to sugar cane
                set block 2 above event-block to sugar cane
                set block 3 above event-block to sugar cane
                set block 4 above event-block to sugar cane
                set block 5 above event-block to sugar cane
            else:
              wait 20 seconds
              set block above event-block to sugar cane
              set block 2 above event-block to sugar cane
              set block 3 above event-block to sugar cane
              set block 4 above event-block to sugar cane
          else:
            wait 20 seconds
            set block above event-block to sugar cane
            set block 2 above event-block to sugar cane
            set block 3 above event-block to sugar cane
        else:
          wait 20 seconds
          set block above event-block to sugar cane
          set block 2 above event-block to sugar cane
      else:
        wait 20 seconds
        set block above event-block to sugar cane
 
Status
Not open for further replies.