Using '- inventory adjust durability' requires the slot where the item is located, but players can place the item in either their left or right hand. The player's issue can be resolved in a relatively simple manner, but there's also the issue with items in a dispenser. When the event 'on dispenser dispenses item' is triggered, even if '- determine cancelled' is passively placed as the first command, it still reports that the dispenser has 9 empty slots (originally there should be a tool inside). Is there any way to get this?
#(yukiyahana) How to get the slot of <context.item> in the inventory
40 messages · Page 1 of 1 (latest)
(yukiyahana) How to get the slot of <context.item> in the inventory
Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
anyone!?
Help us help you by pasting your script to https://paste.denizenscript.com/New/Script and linking it back here.
You want to get the slot that the dispenser is firing from?
I don't think a context exists for this event, even on the spigot api. Maybe the paper API but I could be wrong?
I suppose a quick solution would be...
!t inventorytag.find_item
Returns the location of the first slot that contains an item that matches the given item matcher.
Returns -1 if there's no match.
Uses the system behind !language Advanced Object Matching.
Returns
ElementTag(Number)
https://jd.papermc.io/paper/1.16/io/papermc/paper/event/block/BlockPreDispenseEvent.html Actually there seems to be some Pre event for block dispensing and it allows you to fetch the slot it's going to use, not sure how relevant or helpful to anyone who knows java.
declaration: package: io.papermc.paper.event.block, class: BlockPreDispenseEvent
Sorry for the late reply
Can <InventoryTag.find_item[<matcher>]> match a specific item?
I tried <context.bow> but it doesn't work
If a player holds multiple identical items, this will cause problems with my script
https://paste.denizenscript.com/View/117008
This is my script, along with specific explanations
Content of Denizen Script Paste #117008: Edit of paste 117007: The two scenarios of the script... pasted 2023/11/01 02:43:59 UTC-07:00, Paste length: 1189 characters across 11 lines, Content: #In this scenario, players can place the crossbow in either their hand or offhand. The script conten...
context.bow isn't a valid context in the dispense event.
Also.
!tias
Try it and see!
If somebody pulled this up for you, you're probably asking a question of the public channel that's easier and faster to figure out by just attempting your idea in-game and looking at the result of that attempt.
!e dispenser dispenses
Group
Block
Event Lines
<block> dispenses <item>
Triggers
when a block dispenses an item.
Context
<context.location> returns the LocationTag of the dispenser.
<context.item> returns the ItemTag of the item being dispensed.
<context.velocity> returns a LocationTag vector of the velocity the item will be shot at.
Determine
LocationTag to set the velocity the item will be shot at.
ItemTag to set the item being shot.
Has Known Location
True - this adds switches in:<area> + location_flagged:<flag name>.
Cancellable
True - this adds <context.cancelled> and determines cancelled + cancelled:false.
There is two scenarios
one is after player shoots crossbow
one is on dispenser dispenses Special_Iron_Pickaxe
Before asking, I had already tried for more than ten hours
<context.bow> is 'after player shoots crossbow' one
Spigot doesn't seem to expose the slot, you could theoretically go over all of the dispenser's items and find one that's equal to the one being dispensed, but that isn't flawless either
Oh I see you're also having trouble seeing which slot the hand is in for the shoots event.
This seems to be a missing context.
Yes, this issue has been troubling me for two days, driving me crazy
May want to consider a feature request of context.hand since the https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityShootBowEvent.html event has a thing for getting this.
declaration: package: org.bukkit.event.entity, class: EntityShootBowEvent
But the denizen event has no context for it.
I also linked the PreDispense event, not sure how helpful that is since it can fetch the slot?
Yeah that event looks like it could be useful for that, could feature request that if you'd like
It seems that to solve this problem, I might have to do a feature request. How should I go about doing this?
Create a thread explaining your request and /featurethread
Thank you for your help! The Denizen community is one of the best communities I have ever seen
No worries! feel free to open these feature threads if you'd like to requerst that, but for this thread -
Thread Closing Reminder
Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.
If not yet resolved, please reply below to tell us what you still need.
(Note that if there is no reply for a few days, this thread will eventually close itself.)
@junior coral