#Better block break system

1 messages · Page 1 of 1 (latest)

bronze atlas
#

This shit is too long, and Idk how to make it more compact

#

I basically need it so u cant break any blocks, except some, these blocks when u break them u need a required breaking power hence the "{bpower::%player's uuid%}"... which is set via another skript
when u break the block nothing drops, instead the event is canceled and its instead give to the player as a value in a variable. so for moss blocks its "{mossb::%player's uuid%}". Additionly there is a {mfortune::%player's uuid%} which is a multiplyer that gives extra blocks depending on its value, so 1+{mfortune::%player's uuid%}

#

Lyric sent this

            {_block}, {_min} and {_max} are set
            {_block} is a block # safty check to prevent 'diamond' and 'iron sword' items
            set {breakInfo::%raw name of {_block}%::min} to min({_min}, {_max})
            set {breakInfo::%raw name of {_block}%::max} to max({_min}, {_max})
        
        on load:
            registerBlockInfo(oak wood, 1, 10)
            registerBlockInfo(sprice wood, 15, 50)
        
        on block break:
            {breakInfo::%raw name of event-block%::min} is set
            set {_exp} to a random number between {breakInfo::%raw name of event-block%::min} and {breakInfo::%raw name of event-block%::max}
            add {_exp} * {expmultiplier::%{_p}'s uuid%} to {exp::%{_p}'s uuid%}
            actionBar({_p}, {_exp})```
as an "example" But i have no clue how to use it
#

I came up with this

    {_brokenblock} and {_bpowerb} are set
    {_brokenblock} is a block
    set {breakInfo::%raw name of {_brokenblock}%::bpowerb} to bpower({_bopower})

on load:
    registerBlockInfo(moss block, 0)
    registerBlockInfo(sand, 1)

on block break:
    {breakInfo::%raw name of event-block%::bpowerb} is set
    if {bpower::%player's uuid%} is greater than or equal to {_bpowerb}:
        add 1+{mfortune::%player's uuid%} to {amount.%raw name of event-block%::%player's uuid%}

command mosstest:
  trigger:
    broadcast "%{amount.minecraft:moss_block::%player's uuid%}%"```
but it doesnt work
#

it isnt exactly causing any lag its between around 150ms when i reload

limber seal
#

I will rewrite it

#

I will rewrite it following this steps:

Step 1: Defining Block Properties
Step 2: Generic Block Break Handler
Step 3: Token Drop and Messages

limber seal
#
function registerBlockProperties(blockType: material, requiredBPower: number, blockVar: text):
    set {BlockProperties::%{_blockType}%::requiredBP} to {_requiredBPower}
    set {BlockProperties::%{_blockType}%::variableName} to {_blockVar}

on load:
    registerBlockProperties(moss block, 0, "mossb")
    registerBlockProperties(sand, 1, "sand")
    registerBlockProperties(red sand, 2, "redsand")
    registerBlockProperties(clay block, 2, "clay")
    registerBlockProperties(snow block, 1, "snowb")
    registerBlockProperties(tuff, 3, "tuff")
    registerBlockProperties(blue ice, 3, "blueice")
    registerBlockProperties(calcite, 4, "calcite")
    registerBlockProperties(red mushroom block, 3, "mushroom")
    registerBlockProperties(mushroom stem, 3, "mushroom")
    registerBlockProperties(pearlescent froglight, 4, "pearlfrog")
    registerBlockProperties(concrete, 5, "concrete")

function handleTokenDrop(player: player, chance: number):
    if random number between 0 and 100 < {_chance}:
        give 1 nether star named "&6Token" with lore "" and "&6&lLEGENDARY" to {_player}
        send "<##2BFF7F>You found a token! &b(%{_chance}% chance)" to {_player}
        play sound "entity.arrow.hit_player" at volume 3 at pitch 1 to {_player}

on block break:
    if player's gamemode is survival:
        set {_blockType} to type of event-block
        if {BlockProperties::%{_blockType}%::requiredBP} is set:
            if {bpower::%player's uuid%} >= {BlockProperties::%{_blockType}%::requiredBP}:
                set {_varName} to {BlockProperties::%{_blockType}%::variableName}
                add 1 to {mfortune::%player's uuid%}
                add 1 to {%{_varName}%::%player's uuid%}
                cancel event
                set {_tokenChance} to ({tokenfinder::%player's uuid%}-1)*0.05
                handleTokenDrop(player, {_tokenChance})
            else:
                send action bar "&cYou need higher breaking power!" to player
                play sound "entity.item.break" at volume 3 at pitch 1 to player
                cancel event
        else:
            cancel event  # Cancel event if block is not configured in the properties

command /blockstats [<text>]:
    trigger:
        if arg-1 is set:
            send "%{amount.%arg-1%::%player's uuid%}% blocks collected" to player
        else:
            send "Usage: /blockstats [blocktype]" to player```
#

try this @bronze atlas

#

working?

#

fixed blockstats:

function registerBlockProperties(blockType: material, requiredBPower: number, blockVar: text):
    set {BlockProperties::%{_blockType}%::requiredBP} to {_requiredBPower}
    set {BlockProperties::%{_blockType}%::variableName} to {_blockVar}

on load:
    registerBlockProperties(moss block, 0, "mossb")
    registerBlockProperties(sand, 1, "sand")
    registerBlockProperties(red sand, 2, "redsand")
    registerBlockProperties(clay block, 2, "clay")
    registerBlockProperties(snow block, 1, "snowb")
    registerBlockProperties(tuff, 3, "tuff")
    registerBlockProperties(blue ice, 3, "blueice")
    registerBlockProperties(calcite, 4, "calcite")
    registerBlockProperties(red mushroom block, 3, "mushroom")
    registerBlockProperties(mushroom stem, 3, "mushroom")
    registerBlockProperties(pearlescent froglight, 4, "pearlfrog")
    registerBlockProperties(concrete, 5, "concrete")

function handleTokenDrop(player: player, chance: number):
    if random number between 0 and 100 < {_chance}:
        give 1 nether star named "&6Token" with lore "&7A symbol of luck and fortune." and "&6&lLEGENDARY" to {_player}
        send "<##2BFF7F>You found a token! &b(%{_chance}% chance)" to {_player}
        play sound "entity.arrow.hit_player" at volume 3 at pitch 1 to {_player}

on block break:
    if player's gamemode is survival:
        set {_blockType} to type of event-block
        if {BlockProperties::%{_blockType}%::requiredBP} is set:
            if {bpower::%player's uuid%} >= {BlockProperties::%{_blockType}%::requiredBP}:
                set {_varName} to {BlockProperties::%{_blockType}%::variableName}
                add 1 to {amount.%{_varName}%::%player's uuid%}
                cancel event
                set {_tokenChance} to ({tokenfinder::%player's uuid%}-1)*0.05
                handleTokenDrop(player, {_tokenChance})
            else:
                send action bar "&cYou need higher breaking power!" to player
                play sound "entity.item.break" at volume 3 at pitch 1 to player
                cancel event
        else:
            cancel event  # Cancel event if block is not configured in the properties

command /blockstats [<text>]:
    trigger:
        if arg-1 is set:
            if {amount.%arg-1%::%player's uuid%} is set:
                send "%{amount.%arg-1%::%player's uuid%}% %{arg-1}% blocks collected" to player
            else:
                send "You have not collected any %{arg-1}%" to player
        else:
            send "Usage: /blockstats [blocktype]" to player```