Ways to replace a spawn egg item after it is used?
I'm trying to make a spawn egg that places a custom block, but I need the spawn egg to have a
max_stack_count:1and does not consumes upon using (there's other costs for placing it). I use advancement to trigger a function to process the placing of the block, and tried to replaceweapon.mainhandto the spawn egg, but this cannot correctly process the situation of using it from offhand. I tried using theuse_remaindercomponent but it doesn't apply to spawn eggs. The following is the advancement I used{ "criteria": { "use_potato_mine_seed": { "trigger": "minecraft:item_used_on_block", "conditions": { "location": [ { "condition": "minecraft:match_tool", "predicate": { "items": ["creeper_spawn_egg"] } } ] } } }, "rewards": { "function": "eutils:use_creeper_egg" } }(The type of the block placed is handled by the function, so I only need a way to tell which hand the spawn egg was used in.) I checked the wiki so I think maybe not, but is there a way to modify the criteria of the advancement so that it can detect which hand the spawn egg is used in? If there isn't, are there any workarounds? I know I could probably just give the player the spawn egg back...but this block is intended to be used mid combat so simply giving back could be a problem..
Also if there truly isn't a way for this to work on spawn egg, will it be practical to make an item with
consumableand ray casting whenever the player right clicks it and summon a marker when ray casting correctly in range on a block? Second thought, giving the spawn egg in the player offhand a custom data, removing the custom data if not in offhand, and detect the custom data in advancement might be easier...