# [1.7.10][and newer]How to get the speed part pushed by water?

## Recommended Posts

Entities can be pushed by water.

How to get the speed part pushed by water?

The code is expected as below:

```public static Vec3 getSpeedPartByWater(Eneity x){
Vec3 y=㊣㊣㊣㊣㊣;
㊣㊣㊣㊣㊣
㊣㊣㊣㊣㊣
㊣㊣㊣㊣㊣
return y;
}
```

example : make a player move 2x in water

```Vec3 playerSpeedPartByWater=getSpeedPartByWater(player);
player.moveEntity(player.motionX-playerSpeedPartByWater.xCoord , player.motionY-playerSpeedPartByWater.yCoord, player.motionZ-playerSpeedPartByWater.zCoord);
```

##### Share on other sites

The method that handles water acceleration is in the World class and is called #handleMaterialAcceleration.

If you determine the player is in water, you can do some math to reverse it and then reapply it, or you could probably get by with a simple player.motionX/Y/Z *= 2.

If you don't want the player to get pushed at all, you can make a method to reverse the applied motion.

##### Share on other sites

The method that handles water acceleration is in the World class and is called #handleMaterialAcceleration.

If you determine the player is in water, you can do some math to reverse it and then reapply it, or you could probably get by with a simple player.motionX/Y/Z *= 2.

If you don't want the player to get pushed at all, you can make a method to reverse the applied motion.

Now I can see the effect.

The code looks like this now:

```
public static Vec3 getSpeedPartByWater(Entity x,World xworld){
Vec3 y=Vec3.createVectorHelper(0d,0d,0d);
AxisAlignedBB zaabb=x.boundingBox.expand(0d,-0.40234375,0d).contract(0.001D, 0.001D, 0.001D);
int i1=(int)Math.floor(zaabb.minX);
int i2=(int)Math.floor(zaabb.maxX)+1;
int j1=(int)Math.floor(zaabb.minY);
int j2=(int)Math.floor(zaabb.maxY)+1;
int k1=(int)Math.floor(zaabb.minZ);
int k2=(int)Math.floor(zaabb.maxZ)+1;
if (!xworld.checkChunksExist(i1,j1,k1,i2,j2,k2)) {return y;}
int i,j,k;
Block zblock=null;
for(i=i1;i<i2;i++){
for(j=j1;j<j2;j++){
for(k=k1;k<k2;k++){
zblock=xworld.getBlock(i,j,k);
if(zblock==null){continue;}
if(zblock.getMaterial()!=Material.water){continue;}
}
}
}
if(y.lengthVector()>0&&x.isPushedByWater()) {
y=y.normalize();
y.xCoord=x.motionX*0.15+y.xCoord*0.0119;
y.yCoord=x.motionY*0.15+y.yCoord*0.0119;
y.zCoord=x.motionZ*0.15+y.zCoord*0.0119;
}
return y;
}
```

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

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

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

• ### Posts

• Im trying to play a modded 1.7.10 minecraft server, but when i try joining, it says Connecting to server, and then it goes to Logging in. Even after i wait a while it stays on that screen, i waited maybe an hour for it to work and it did not. The game is not frozen because i can press Cancel and it goes back to normal, and singleplayer works fine, so i dont know what to do. I even tried using a mod called Lan UPNP, which lets you host servers from singleplayer using the hosts ip address, and it did not work. The same screen showed up. And i have been trying for the whole day, using Hamachi, reinstalling the game, and lowering my settings. One time i lowered my settings and it let me almost join, it said something along the lines of Fatally missing block and items. I searched up and it said to use the config of the server, i tried it and it went back to logging in. Please help, thanks.
• When trying  to open up game, this pops up: https://api.mclo.gs/1/raw/E6nMPZe
• Hello all, I am trying to figure out how to prevent a custom entity from walking over blocks. My Entity is extending PathfinderMob. I have tried setMapUpStep(0.6f), disabling jumping, and overriding getStepHeight and returning 0.6f. Any help would be greatly appreciated. Thank you! EDIT: Thought I should include MC and Forge versions. MC : 1.20.1 Forge: 47.3.0
• 🅱️org is better
• i tried starting the game, minecraft starts; crashes after a couple seconds of loading screen. heres the log: https://pastebin.com/a6aMcGYF im playing on curseforge launcher, forge 1.20.1 and got quite a few mods pls help

• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...