public function onMove(PlayerMoveEvent $event){
$player = $event->getPlayer();
$block = $player->getLevel()->getBlock($player->subtract(0, -1 , 0)); //Detects the block at y-1 of the player's location
if ($block->getId() === Item::WATER) { //there are many types of water. I think this is "Still_Water"
$player->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_SWIMMING, true);
} else {
$player->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_SWIMMING, false);
}
public function onMove(PlayerMoveEvent $event){
$player = $event->getPlayer();
$block = $player->getLevel()->getBlock($player->subtract(0, -1 , 0)); //Detects the block at y-1 of the player's location
if ($block->getId() === Item::WATER) { //there are many types of water. I think this is "Still_Water"
$player->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_SWIMMING, true);
} else {
$player->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_SWIMMING, false);
}