3

I've been creating a modded adventure map over the last three years and have finally decided to deal with an issue that I've been aware of for a long while. I'm trying to make it so certain items are undroppable quest items and keys that are using CanPlaceOn Commands. I put together this command as an example... /give TRENADIX minecraft:lever 1 0 {display:{Name:"Asylum Key",Lore:["Escape the Asylum"]},CanPlaceOn: ["minecraft:iron_block"],PickupDelay:0,Age:-32768}

The point of this is that the player will instantly pick the item back up if accidentally dropped but it can still be placed in storage or placed on specific blocks. I set the pickup delay to 0 but that's not working fast enough.

Cover Art

1
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Dec 21, 2021 at 4:07

1 Answer 1

2

You can teleport the item to the nearest player when dropped with the help of a custom tag:

This would be the command for the key with the special tag:

/give @p minecraft:lever 1 0 {display:{Name:"Asylum Key",Lore:["Escape the Asylum"]},CanPlaceOn: ["minecraft:iron_block"],PickupDelay:0,Age:-32768,noDrop:1}

This would be the first command to add a tag to the dropped item:

/scoreboard players tag @e[type=Item] add noDrop {Item:{tag:{noDrop:1}}}

This command you should place in a repeating command block.

The next command executes any item with the tag and teleports it to the nearest player, this will be the player that drops it, placed in a chain command block:

/execute @e[tag=noDrop,type=Item] ~ ~ ~ /tp @e[type=Item,dx=0] @p

The next command would as well placed in a chain block, and adds a pickup delay of 0 to the item, in case it resets somehow:

/entitydata @e[tag=noDrop] {PickupDelay:0}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .