#Block drop handling leading to duplication/deletion

1 messages · Page 1 of 1 (latest)

robust storm
#

I'm making an item that when active and in the inventory, smelts dropped blocks.

Here's the snippet:

on block drop:
    if player's tool is not enchanted with silk touch: # this segment is irrelevant
        loop items in player's inventory:
            if loop-item is a furnace minecart:
                if custom model data of loop-item is 4008:
                    set {_s} to true
    if {_s} is true:
        if inventory of block is not set:
            set {_drops::*} to block dropped itemtypes
            loop {_drops::*}:
                set {_d::%loop-index%} to smelted form of {_drops::%loop-index%}
                send block dropped items to the player
                set block dropped items to {_d::%loop-index%}

The issue with this handling is that it seems to loop the drops for each of the blocks (i.e. 4 entries for 2 blocks, 9 entries for 3 blocks, etc.
This causes breaking the block to convert all blocks depending on it (e.g. signs, amethyst clusters, pointed dripstone) to the source block.
Skript addons and versions are below

[15:43:24 INFO]: [Skript] Server Version: 1.21.5-92-113b18e (MC: 1.21.5)
[15:43:24 INFO]: [Skript] Skript Version: 2.11.1 (skriptlang-github)
[15:43:24 INFO]: [Skript] Installed Skript Addons:
[15:43:24 INFO]: [Skript]  - SkJson v5.4 (https://skjson.coffeerequired.info)
[15:43:24 INFO]: [Skript]  - Skonic v1.2.2
[15:43:24 INFO]: [Skript]  - skript-particle v1.3.2 (https://github.com/sovdeeth/skript-particle)
[15:43:24 INFO]: [Skript]  - Lusk v1.3.5 (https://github.com/JakeGBLP/Lusk)
[15:43:24 INFO]: [Skript]  - skript-reflect v2.6 (https://github.com/SkriptLang/skript-reflect)
[15:43:24 INFO]: [Skript]  - SkBee v3.11.2 (https://github.com/ShaneBeee/SkBee)

Video attached of behavior

devout spruce
#

use drops of loop-block

robust storm
#

there's no loop that matches loop-block

#

and skript says drops of the block can't be set to anything, which is why i'm doing it via block dropped items

devout spruce
#

what are you trying to do? Is this a pickaxe that mines a 3x3x3 area?

robust storm
#

no, this is an "accessory" that automatically smelts mined blocks

#

it also happens to convert blocks that depend on the mined block to the mined block itself

devout spruce
#

ah so then just something like on mine: if player has this auto-smelt thing: cancel drops set {_originalDrops::*} to drops of event-block using player's tool #smelt {_originalDrops::*} drop {_smeltedDrops::*} at event-block's location

#

that way you only do it for the one block that was broken

devout spruce
robust storm
#

wait no now it deletes the dependants

devout spruce
#

oh hmm

#

maybe remove {_originalDrops::*} from drops then

robust storm
#

drops can't have anything removed

robust storm
#

Block drop handling leading to duplication/deletion

#

updated (semi-working) code

on mine:
    if player's tool is not enchanted with silk touch:
        loop items in player's inventory:
            if loop-item is a furnace minecart:
                if custom model data of loop-item is 4008:
                    set {_s} to true
    if {_s} is true:
        if inventory of block is not set: # relevant bits past here
            set {_drops::*} to drops of event-block using player's tool
            clear drops # works, but clears all dependant block drops (e.g. signs, rails, or redstone components that rely on the block
            set {_drops::*} to smelted form of {_drops::*}
            drop {_drops::*} at event-block's location
devout spruce
#

maybe drops where [{_drops::*} does not contain input] would be the ones you want?

#

also maybe use player's inventory contains ... instead of looping each slot

robust storm
#

in the drop items line?

#

i tried it in the clear line; it can't be cleared

devout spruce
#

thats going to take the drops expression, and then filter it to only drops that are not also in {_drops::*}

#

and since {_drops::*} is the drops for only the mined block, that whole expression should return everythign else, so you can drop that manually as well

robust storm
#

am i understanding you right

#

first is with mine event, second is with block drop event

devout spruce
#

can I see the code

robust storm
#
on block drop: # or on mine
    if player's tool is not enchanted with silk touch:
        loop items in player's inventory:
            if loop-item is a furnace minecart:
                if custom model data of loop-item is 4008:
                    set {_s} to true
    if {_s} is true:
        if inventory of block is not set:
            set {_drops::*} to drops of event-block using player's tool
            clear drops
            drop drops where [{_drops::*} does not contain input] at event-block's location
            set {_drops::*} to smelted form of {_drops::*}
            drop {_drops::*} at event-block's location
devout spruce
#

maybe block dropped itemtypes where [...]

#

as you had earlier

#

if that doesnt work im not too sure

robust storm
#

it's trying to read it as a location?

devout spruce
#

add parenthesis

#

send the line

robust storm
#

drop [block dropped itemtypes where [{_drops::*} does not contain input]] at event-block's location
new line but new error; i need on block drop for this, but cancel drops requires on mine

devout spruce
#

drop ((block dropped itemtypes) where [{_drops::*} does not contain input]) at (event-block's location)

robust storm
#

yea, skript can't understand that

devout spruce
#

hang on, whats wrong with on mine: loop items in radius 0.3 around event-block: #smelt the item

robust storm
#

i want to make sure the only item smelted is the one coming from the mined block

devout spruce
#

thats why small radius