Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

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/

  • Author

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.)

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.