Looking to make a plugin that modifies water friction.

jpaalman

New member
Mar 17, 2022
3
1
1
I'm looking to make a small plugin that modifies the water friction, similar to the dolphin's grace effect but without the speed boost, for players holding or ideally using a riptide trident. I feel they currently are more usable for launching yourself out of water than boosting underwater, which makes the grind to get one just not worth it. I've made a datapack hat give's players holding one dolphin's grace, but the speed boost, especially with depth strider boots, is game-breakingly fast, and also makes it easier to just swim with the speed boost, rather than using the trident.

I'm quite familiar with Java programming, but not with the API, so I'd like to ask how I can detect a player holding or using a trident using the API, and how I modify the underwater friction for that player only. Once I've got the correct class names, I should be ready to get on my way programming.

Thanks in advance.
 

_Iuri

New member
Jan 16, 2022
22
3
3
You could use https://papermc.io/javadocs/paper/1.18/org/bukkit/event/player/PlayerMoveEvent.html to get the player movement and verify the player with https://papermc.io/javadocs/paper/1.18/org/bukkit/entity/Entity.html#isInWater() to check if it's in water.

Or you could just use https://papermc.io/javadocs/paper/1.18/org/bukkit/event/entity/EntityToggleSwimEvent.html to get the player who's start to swim (or end swim).

On both cases you want to use https://papermc.io/javadocs/paper/1.18/org/bukkit/inventory/PlayerInventory.html#getItemInMainHand() to get the item in the player's main hand.

To change the player's speed when swimming, maybe you should try to change the https://papermc.io/javadocs/paper/1.18/org/bukkit/attribute/Attribute.html#GENERIC_MOVEMENT_SPEED attribute.
 

DefineOutside

New member
Feb 5, 2022
2
0
1
Attributes don't change water movement speed. The only thing you can do is setting dolphin's grace or depth strider.
 

jpaalman

New member
Mar 17, 2022
3
1
1
Could I perhaps trick the game into thinking the player is standing on ice blocks, or would this mess up swimming?