on mine glitch

Discussion in 'Skript' started by AggerTV, Jan 11, 2020.

  1. Every time i mine, the block glitches out.
    Code (Text):
    on mine:
        set {_b} to block
        if block is coal ore:
            set {_drop} to coal item
            give player {@coalxp} xp
        else if block is diamond ore:
            set {_drop} to diamond item
            give player {@diamondxp} xp
        else if block is emerald ore:
            set {_drop} to emerald item
            give player {@emeraldxp} xp
        else:
            set {_drop} to block
        if player's tool is a pickaxe:
            set {_multi} to 1
            if player's tool's lore contains "fortune":
                set {_multi} to round(level of fortune of the player's tool * {@fortunemultiplier}) + {_multi}
            if {autosell:toggle:%player's uuid%} is true:
                loop {autosell:shop::*}:
                    set {_shops::*} to loop-value split at ":"
                    if player has permission "autosell.shop.%{_shops::1}%":
                        loop {_shops::*}:
                            set {_blocks::*} to loop-value-2 split at ","
                            if "%{_drop}%" is "%{_blocks::1}%":
                                set {_p} to {_blocks::2} parsed as number
                                add {_p} * {_multi} to player's balance  
                                add {_p} * {_multi} to {autosell:%player's uuid%:blockssoldprice}
                                add 1 to {autosell:%player's uuid%:blockssolditems}
                                set {_sold} to true
                if {_sold} is not set:
                    loop {_multi} times:
                        give player {_drop}              
            else:
                loop {_multi} times:
                    give player {_drop}
        cancel event
        set event-block to air
    I also tried

    Code (Text):
    cancel event
        wait 1 tick
        set event-block to air
     
  2. So any ideas of how i might imrove the code, so that the block doesn't glitch out?
     
  3. don't use "cancel event", it glitches it out, if you want it to drop custom items - you can kill the item entity which gets dropped out of the block by looping all dropped item entities near and checking if their Spigot.ticksLived nbt tag is less than 2 (or 1?) additionally for extra accuracy you can also check if the dropped item is one which would usually get dropped from this block, so you would be unlikely to delete items dropped by players in the same place and the same tick as block break
     
  4. nvm. found this plugin wich works just fine DropsToInventory
     
  5. you can also just take advantage of "drops of event-block" expression and don't need to calculate all fortune stuff yourself (or my nbt check way above)