#Is it possible to detect if a specific item has been destroyed?

1 messages · Page 1 of 1 (latest)

wary elk
#

So I was thinking about first how can an item be destroyed? Inside GUI? It cant. You have to drop it out. So if it disappears after dropped out you could check if its at any player's inventory but I have no idea how to do it and I'm 99% sure there is a better solution.
I would also like to know if its possible to print a text containing a variable.
Lets say:
playerHead .. " has died permanently. ( Head Destroyed )"

manic surgeBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

manic surgeBOT
# manic surge <@&1201956957406109788>

<@&1166082198152159386> <@&1202694677766348840>

🙇 Helpers Arise!

Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)

surreal star
#

You can use the durability_changed advancement to check if an item breaks

#

for items on the ground, you could check if like this execute as @e[type=item] if data entity @s {Age:5999s} run say I DED

#

there could be a very slight possibility that it fails if a player picks it up in the last tick

wary elk
surreal star
#

for despawn that's what I just sent, for cactus and lava you cannot reliably and accurately detect that

#

the only thing you can do for cactus and lava is to check the blocks in a vey small radius around the item and hope that it doesn't get picked up before it is destroyed

wary elk
# surreal star the only thing you can do for cactus and lava is to check the blocks in a vey sm...

Oof... Well honestly the only thing I wanted to do is that when a player dies "forever" he drops his head. And with the revive beacon which is almost done can be revived. But what if someone destroys someone's head. So I was thinking of printing a message because killing someone forerever should be either impossible or be notified. So what would you do?
Maybe with context you could provide some better and more possible solution.

surreal star
#

You can give the item a special nbt so that you can detect that in entity form and make it invulnerable.

#

That makes them not able to be destroyed by lava and cactus

#

for void you can give it levitation

#

you can make it immune to despawn by setting its age to a very high negative number

wary elk
#

OHH. That sounds really good actually. Can you get its cordinates? So like can you get the cordinates of that item? Cuz then it could be detected if y is bellow -64 and then just give it levitation for idk 3 seconds. And then it could be done.

surreal star
#

execute as @e[type=item] if items entity @s contents *[custom_data~{revive_item:true}] at @s if predicate {"condition":"minecraft:location_check","predicate":{"position":{"y":{"min":-64}}}} run effect give @s levitation 3 1

wary elk
#

That is a very unusual syntax but I think I understand... I mean I said the same about macros and I'd say its about now when I feel like I can kinda use them.

surreal star
#

the unusual syntax you mean is probably the inlined predicate

#

you don't have to put them in seperate files (same with item modifiers/loot tables/etc..)

wary elk
surreal star
#

for short predicates that I only use once I just inline them

#

yeah, mcf is not like your traditional programming, it is a language of workarounds and abyssmaly long one liners

#

Although the workaround part was a lot worse in the past

wary elk
surreal star
#

the player doesn't store its name

#

you can only get it by dropping a player head whith a loot table that is filled with the player that dropped it from it's profile.name nbt

wary elk
surreal star
wary elk
#

Ok so I only used loot-tables to make blocks dont drop in a custom dimension so I would like to ask you how do I even use them? Do I add loot-tables to the player? Or... ( Sorry )

surreal star
#

I think this will work

#

Idk if mc ignores this loot table or applies it

#

I never tried it

#

there does exist a file in the original files (it's empty)

#

so should work

wary elk
#

And how do II use it or test it? Cuz the other issue is that it should only trigger when its their last life. But then I could just delete that item if its not so it could stay.

#

Damn I hate theese workarounds. Mojang why?

surreal star
#

you can have a score check in the loot table to only make it drop if their life score is 0

wary elk
#

And I'm not sure if it runs on the same tick.

surreal star
#

loot tables come after advancements and functions in the process sequence afaik

#

advancements are triggered immediately so this all should work

wary elk
#

Eh. Imma try then.
Sorry for hitting you with questions constantly. I just wanna learn the reasons too not just the solutions and later on I wanna be able to work on my datapacks without being a burden lol.

surreal star
#

np, thats the purpose of dph. Not just giving the answer but teaching how it works.

wary elk
surreal star
#

/recipe take @s *

wary elk
#

I have never noticed this command 😭

surreal star
wary elk
#

Could you send me the github link to the vanilla datapack pls?

#

I forgot what is the link...

#

So I can search up the player loot_table

frail bane
#

And then use the top left drop-down to switch to the data branch

wary elk
# surreal star
{
  "type": "minecraft:entity",
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:item",
          "name": "minecraft:player_head",
          "functions": [
            {
              "function": "minecraft:fill_player_head",
              "entity": "this"
            }
          ]
        }
      ],
      "conditions": [
        {
          "condition": "minecraft:entity_scores",
          "entity": "this",
          "scores": {
            "maxHealth": 0
          }
        }
      ]
    }
  ],
  "random_sequence": "minecraft:entities/player"
}
wary elk
#

For now I'll set this as done.