Solved Removing block drops

  • 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.
Apr 4, 2017
16
0
0
One can prevent specific items from dropping upon mob death with

Code:
remove ghast tears from drops

How can one prevent specific items from dropping when breaking a block?

It's a little hacky but one can remove all drops from a block, including xp, by doing something like this

Code:
on mine of emerald ore:
    cancel event
    set event-block to air

In my case, however, I do not want to remove the dropped xp, only the dropped items. How can I achieve this?
 
One can prevent specific items from dropping upon mob death with

Code:
remove ghast tears from drops

How can one prevent specific items from dropping when breaking a block?

It's a little hacky but one can remove all drops from a block, including xp, by doing something like this

Code:
on mine of emerald ore:
    cancel event
    set event-block to air

In my case, however, I do not want to remove the dropped xp, only the dropped items. How can I achieve this?
code_language.skript:
On death:
    Victim is a zombie
    Remove 20 rotted flash from drops
 
code_language.skript:
On death:
    Victim is a zombie
    Remove 20 rotted flash from drops

Thank you for the reply. I do know how to remove specific items from mob drops---that's what my example code does. What I want to know is how to do the same for drops from mined blocks.
 
There's no way to directly do this. It's not a Skript limitation, the Spigot API just doesn't support getting or modifying drops of a block break event. The best you can do is looping dropped items and trying to determine which ones were dropped. The simplest example using just vanilla Skript is:

code_language.skript:
on mine:
    wait 1 tick
    set {_drops::*:} to dropped items in radius 0.75 of event-location

Naturally, this isn't 100% safe since nearby dropped items could get included even though they weren't part of the block break. To make it even safer, you can install SkStuff and check the age of the drop, which will make it nearly foolproof. This is an example of a section I'm using on my server for an autosmelt enchantment that modifies the block drops:

code_language.skript:
on mine:
    wait 1 tick
    loop dropped items in radius 0.75 of event-location:
        tag "Age" of nbt of loop-entity <= 2
        <do stuff>
 
There's no way to directly do this. It's not a Skript limitation, the Spigot API just doesn't support getting or modifying drops of a block break event. The best you can do is looping dropped items and trying to determine which ones were dropped. The simplest example using just vanilla Skript is:

...

Okay, this is good to know, tyvm for the explanation. It's very puzzling that Spigot does the analogous thing for mobs but doesn't support this!
 
Status
Not open for further replies.