Jump to content

Recommended Posts

Posted

I'm trying to create a bucket-like tool that fills up if you right click on water.

 

This line of code is being weird.

MovingObjectPosition movingObjectPosition = this.getMovingObjectPositionFromPlayer(world, player, isFull);

 

It only creates a MovingObjectPosition if there is a solid block in range. When there's a water block in range, but not a solid block, it gives me null. When there are both water blocks and solid blocks in range, and the solid blocks are behind the water blocks, the MovingObjectPosition contains information about the solid block instead of the water block.

 

It seems to ignore all the water blocks, which is weird because the bucket works properly.

Posted

I think that is a complicated way to do it.  Why not just handle the PlayerInteractEvent?  In that event you can check if the action is RIGHT_CLICK_BLOCK and then check what kind of block it is with the useBlock field.  Then just do what you want when you detect that player has right clicked on water.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

I tried to use events, here's my source code. I'm probably not doing something right, since the block I click on is never equal to water. (I'm pretty sure that == can check block equality, since only 1 of each Block is ever instantiated.)

c0faae90f1.png

 

Also, how do I check the type of block with useBlock? I don't know what to do with it; it's a Result object that can be DENY, DEFAULT, or ALLOW, which doesn't seem like too much to work with.

 

(The above code is inside the onItemUse method, if that's relevant.)

Posted

Sounds like your code is in onItemUse, try moving it to onItemRightClick. For the other issue I'm not as confident in my answer, but try changing your isFull to !isFull or isEmpty since in vanilla code it passes true when the bucket is full... of air that is.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.