Nature Reclaims Remake

Discussion in 'Skript' started by Hosom, Aug 7, 2018.

  1. Nature Reclaims was a really old mod that i loved during the good old days.
    It has been discontinued since a loong time. During the last summer i decided to remake it in Skirpt (because i am lazy and i don't want to learn how to program a Spigot plugin even if i can program in java, lol).
    However, winter came and i discontinued it too.

    Here is the source code, as I left it last summer. If someone wants to fork it, remake it, go aheand and complete it... you are welcome! Just mention me in your finished product :)

    I would really love to see this completed, but i have no time to do it.

    (Original file)

    Code (Text):
     
    # TO DO #
    # Allow piston retracting with SkMorkaz
    # Fine tune aging timings
    # ...

    # CONFIG #
    options: #Some options:
        worldname: "Map" #Name of the world you want to enable Nature Reclaims in
        #Minimum and maxmium hours of life to apply first stage of aging
        #(Life starts when block is placed, ends when removed)
        a: 1
        b: 10
       
        #Second stage
        c: 10
        d: 20
        #Third stage
        e: 20
        f: 30
        #Fourth stage
        g: 30
        h: 40 # <<-- After this value, the block will not age anymore.
       
        #Minimum hours of life to apply water-caused moulding (growth of moss)
        a1: 1
       
        #Minimum and maxmium hours of life to make wood start falling if not supported
        {@wood_a}: 1
        {@wood_b}: 10 <<-- After this value, wood will not fall anymore
    on script load: #More options...
        #If you have SkMorkaz installed set this to true to re-enable pistons
        #otherwise pistons will be disabled entirely to prevent bug exploiting.
        set {skmorkaz} to true
    # ADD BLOCK TO POSITION AND DATE LISTS #
    on block place:
        if event-block is (stone brick or cobblestone or 5 or 5:1 or 5:2 or 5:3 or 5:4 or 5:5 or 43:2):
            add position of block to {locations::*}
            add now to {dates::*}
           
    # ADD BLOCK TO POSITION AND DATE LISTS ON FARMING #
    on right click holding an hoe:
        add position of event-block to {locations::*}
        add now to {dates::*}
    # REMOVE BLOCK FROM POSITION AND DATE LISTS #
    on block break:
        set {_position} to position of block
        loop {locations::*}:
            if loop-value is equal to {_position}:
                delete {locations::%loop-index%}
                delete {dates::%loop-index%}
               
    # REMOVE BLOCK FROM POSITION AND DATE LISTS ON EXPLOSION #
    on explode:
        loop exploded blocks:
            set {_exploded} to position of loop-value
            loop {locations::*}:
                if {_exploded} is equal to loop-value-2:
                    delete {locations::%loop-index%}
                    delete {dates::%loop-index%}
    # UPDATE BLOCK POSITION ON PISTON PUSH OR PULL #
    on block piston push:
        loop {locations::*}:
            if position of event-block is equal to loop-value:
                if event-string is "WEST"    :
                    subtract 1 from x-coordinate of {locations::%loop-index%}
                if event-string is "EAST"    :
                    add 1 to x-coordinate of {locations::%loop-index%}
                if event-string is "NORTH":
                    subtract 1 to z-coordinate of {locations::%loop-index%}
                if event-string is "SOUTH":
                    add 1 to z-coordinate of {locations::%loop-index%}
                if event-string is "UP":
                    add 1 to y-coordinate of {locations::%loop-index%}
                if event-string is "DOWN":
                    subtract 1 from y-coordinate of {locations::%loop-index%}
    on piston retract:
        #Wip
    # AGE THE BLOCK (Random-spot and propagation) #
    on every 1 second in world {@worldname}:
        loop {locations::*}:
            set {_location} to loop-value
            set {_date} to {dates::%loop-index%}
            set {_mainloopindex} to loop-index
           
            # RANDOM-SPOT AGING #
           
            if {_date} was more than {@a} second ago:
                if {_date} was less than {@b} second ago:
                    chance of 10%:
                        if block at {_location} is stone brick:
                            set block at {_location} to cracked stone brick
            if {_date} was more than {@c} second ago:
                if {_date} was less than {@d} second ago:
                    if block at {_location} is cracked stone brick:
                        chance of 3%:
                            set block at {_location} to mossy stone brick
                            chance of 50%:
                                if block behind {_location} is air:
                                    set block behind {_location} to vine
                            chance of 50%:
                                if block in front of {_location} is air:
                                    set block in front of {_location} to vine:4
            if {_date} was more than {@e} second ago:
                if {_date} was less than {@f} second ago:
                    chance of 1%:
                        chance of 10%:
                            if block above {_location} is air:
                                set block above {_location} to cobweb
                               
                            else if block in front of {_location} is air:
                                set block in front of {_location} to cobweb
                               
                            else if block behind {_location} is air:
                                set block behind {_location} to cobweb
                               
                            else if block under {_location} is air:
                                set block under {_location} to cobweb
                       
            if {_date} was more than {@g} second ago:
                if {_date} was less than {@h} second ago:
                    if block at {_location} is mossy stone brick:
                        chance of 2%:
                            set block at {_location} to air
                            delete {locations::%loop-index%}
                            delete {dates::%loop-index%}
            # WATER EROSION AGING (Growth of moss and cracks) #
           
            if {_date} was more than 1 second ago:
                loop blocks in radius 3 around {_location}:
                    if loop-value-2 is water:
                        if block in front of {_location} is air:
                            set block in front of {_location} to vine:4
       
                        else if block behind {_location} is air:
                            set block behind {_location} to vine
                       
                        if block at {_location} is stone brick or cracked stone brick:
                            set block at {_location} to mossy stone brick
                       
                        else if block at {_location} is (5 or 5:1 or 5:2 or 5:3 or 5:4 or 5:5 or 43:2):
                            chance of 1%:
                                delete {locations::%{_mainloopindex}%}
                                delete {dates::%{_mainloopindex}%}
                                set block at {_location} to dirt
                        else if block at {_location} is cobblestone:
                            set block at {_location} to mossy cobblestone
                               
            # WOOD FALLING #
           
            if {_date} was more than 1 second ago:
                if {_date} was less than 10 second ago:
                    if block at {_location} is (5 or 5:1 or 5:2 or 5:3 or 5:4 or 5:5 or 43:2):
                        chance of 1%:
                            set block at {_location} to coarse dirt
                            delete {locations::%{_mainloopindex}%}
                            delete {dates::%{_mainloopindex}%}
                            if block above {_location} is air:
                                chance of 10%:
                                    set block above {_location} to oak sapling
                    chance of 3%:
                        if block at {_location} is (5 or 5:1 or 5:2 or 5:3 or 5:4 or 5:5 or 43:2):
                            set {_wood} to the block at {_location}
                            if block below {_wood} is air:
                                set block below {_wood} to {_wood}
                                subtract 1 from y-coordinate of {locations::%{_mainloopindex}%}
                                set block at {_location} to air
                               
            # GLOWSTONE AND TORCHES DECAY #
           
            if {_date} was more than 10 second ago:
                if {_date} was less than 20 second ago:
                    chance of 25%:
                        loop blocks in radius 10 around {_location}:
                            if loop-value-2 is (torch or glowstone):
                                chance of 5%:
                                    set loop-value-2 to air
                                   
            # FARMS DECAY #
           
            if {_date} was more than 15 second ago:
                if {_date} was less than 30 second ago:
                    if block at {_location} is (grass or farmland or dirt):
                        chance of 20%:
                            set block at {_location} to coarse dirt
                        chance of 5%:
                            if block above {_location} is air:
                                set block above {_location} to dead bush
                        delete {locations::%{_mainloopindex}%}
                        delete {dates::%{_mainloopindex}%}
                       
            # SPAWN SOME WATER PUDDLES #
           
            if {_date} was more than 15 second ago:
                if {_date} was less than 30 second ago:
                    chance of 3%:
                        if block at {_location} is (cobblestone or stone brick or mossy stone brick or cracked stone brick):
                            if block in front of {_location} is not air:
                                if block behind {_location} is not air:
                                    if block under {_location} is not air:
                                        chance of 1%:
                                            set block at {_location} to water
                                            delete {locations::%{_mainloopindex}%}
                                            delete {dates::%{_mainloopindex}%}
            # SPAWN DIRT ON BRICKS #
           
            if {_date} was more than 30 second ago:
                if {_date} was less than 40 second ago:
                    if block at {_location} is (cracked stone brick or stone brick or mossy stone brick):
                        chance of 1%:
                            chance of 50%:
                                set block at {_location} to coarse dirt
                                delete {locations::%loop-index%}
                                delete {dates::%loop-index%}
                                chance of 50%:
                                    set block above {_location} to oak sapling
                                   
    # FOREST SPREADING #
    command /test:
        trigger:
            message "%{locations::*}%"
            message "%{dates::*}%"
           
    command /cancel:
        trigger:
            delete {locations::*}
            delete {dates::*}
           
    command /ll:
        trigger:
            message "%light level at player%" to player