Java Code Examples for net.minecraft.client.network.ClientPlayerEntity#isTouchingWater()

The following examples show how to use net.minecraft.client.network.ClientPlayerEntity#isTouchingWater() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlideHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUpdate()
{
	ClientPlayerEntity player = MC.player;
	Vec3d v = player.getVelocity();
	
	if(player.isOnGround() || player.isTouchingWater() || player.isInLava()
		|| player.isClimbing() || v.y >= 0)
		return;
	
	if(minHeight.getValue() > 0)
	{
		Box box = player.getBoundingBox();
		box = box.union(box.offset(0, -minHeight.getValue(), 0));
		if(!MC.world.doesNotCollide(box))
			return;
		
		BlockPos min =
			new BlockPos(new Vec3d(box.minX, box.minY, box.minZ));
		BlockPos max =
			new BlockPos(new Vec3d(box.maxX, box.maxY, box.maxZ));
		Stream<BlockPos> stream = StreamSupport
			.stream(BlockUtils.getAllInBox(min, max).spliterator(), true);
		
		// manual collision check, since liquids don't have bounding boxes
		if(stream.map(BlockUtils::getState).map(BlockState::getMaterial)
			.anyMatch(Material::isLiquid))
			return;
	}
	
	player.setVelocity(v.x, Math.max(v.y, -fallSpeed.getValue()), v.z);
	player.flyingSpeed *= moveSpeed.getValueF();
}
 
Example 2
Source File: AutoSwimHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUpdate()
{
	ClientPlayerEntity player = MC.player;
	
	if(player.horizontalCollision || player.isSneaking())
		return;
	
	if(!player.isTouchingWater())
		return;
	
	if(player.forwardSpeed > 0)
		player.setSprinting(true);
}
 
Example 3
Source File: MixinClientPlayerEntity.java    From multiconnect with MIT License 5 votes vote down vote up
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isTouchingWater()Z"))
private boolean allowSprintingInWater(ClientPlayerEntity self) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_12_2) {
        return false; // disable all water related movement
    }
    return self.isTouchingWater();
}