#Use items

16 messages · Page 1 of 1 (latest)

dusk jetty
#

How to use the item? (I am writing a mod so that the player puts water under him)

visual cryptBOT
#

This post has been reserved for your question.

Hey @dusk jetty! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

shy citrus
#

You can subscribe to the PlayerInteractEvent to check if the player is using an item.

visual cryptBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

dusk jetty
shy citrus
#

Use the item in what way? Right clicking it?

#

Then that would be a PlayerInteractEvent like I previously mentioned

dusk jetty
#

I'm just using TickEvent.PlayerTickEvent, I need the check to happen all the time

#
@SubscribeEvent
    public void onPlayerTick(TickEvent.PlayerTickEvent event){
        if (event.player.getMainHandItem().getItem() == Items.WATER_BUCKET) {
            if (!event.player.isOnGround()) {
                    if (event.player.getXRot() == 90.0) {
                        //Here need to use water bucket
                }
            }
        }
    }
#

@shy citrus ?

shy citrus
#

ohhhh I see.

#

You want the player to place water under them for as long as they're holding the water bucket

#

do you want it to consume the water from the bucket or do you want it to just spawn a water block?

dusk jetty
#

But now I have a suspicion that event.player covers not just one player (who we play as) but all of them, should I check if it's the main or another player?