Jump to content

Recommended Posts

Posted

I am returning to modding from a four year hiatus, and I wanted to start by recreating a simple plugin I developed back then which created new behaviors for vanilla tools interacting with vanilla blocks. One such behavior in mind requires interaction with the flowing segments of water, but I can't seem to find a BlockInteractEvent that fires when a player attempts to use a tool on them. (I read somewhere that flowing water is considered a gas and not a fluid. Worst case of the imagination, I might suspect a flowing segment of water is not actually a block and is just an effect generated by one or more water source blocks.) I remember it was troublesome to implement back then, too, as I recall having to resort to checking for any right click action with an appropriate tool in hand combined with having flowing water within a few blocks of the player's line-of-sight vector, and today that feels like a bit of a cop-out approach. Are there any suggestions for a simpler and preferably more straightforward method of recognizing when a player uses a tool on flowing water? Thanks in advance!

Posted (edited)

I'm not 100% sure this works with flowing water, but you could try this...

 

Add an

onItemRightClick

to your item that does a ray trace like this:

final RayTraceResult target = this.rayTrace(world, player, true); // true: useLiquids

if(target.typeOfHit != RayTraceResult.Type.BLOCK) {
  return ActionResult.newResult(EnumActionResult.PASS, itemstack);
}

// ...

 

Edited by Corey
Posted

I'm not sure about whether it works on flowing water, either. Since I am modifying existing tools, not adding my own, I'd need to do an @Override of the onItemRightClick method for each intended tool, correct? Is that even allowed?

Posted (edited)

The only PlayerInteractEvent sub class that makes sense here (as far as I know) is RightClickBlock event, and it presents the same issue from the original post of the flowing water not being recognized as a block. The event registers fine with water source blocks, but that's not what I'm looking for.

 

Edit: PlayerInteractEvent.RightClickBlock did not work for me with water sources either; I was mistakenly remembering the results of a different test case.

Edited by bulldogg6404
Posted
33 minutes ago, bulldogg6404 said:

The only PlayerInteractEvent sub class that makes sense here (as far as I know) is RightClickBlock event, and it presents the same issue from the original post of the flowing water not being recognized as a block. The event registers fine with water source blocks, but that's not what I'm looking for.

 

Edit: PlayerInteractEvent.RightClickBlock did not work for me with water sources either; I was mistakenly remembering the results of a different test case.

47 minutes ago, bulldogg6404 said:

onItemRightClick

I wonder if there is a sub-class that has a similar name to this where one can to RayTracing to check for flowing water?

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
11 minutes ago, Animefan8888 said:

I wonder

 

.... well, would you look at that. I for some reason thought that RightClickItem meant it fires when they right click on an item (whatever that was supposed to mean). Thanks, that should be enough to get the ball rolling again.

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.