• Minecraft 1.16.220 Update + Bug/Crash Fixes
    Added MCPE 1.16.220 version and fixed crashes for multiple plugins. You can view the full changelist here.
  • Forum Updates - 4/11/2021
    Various changes have been made to the forums and a few categories. You can view the full changelist here.

Suggestion Simple swim plugin

Warning!
Hello , there have been no replies in this thread for more than 30 days.
Please make sure you have a valid reason before you reply to this thread or you may face moderation action.

thedeibo

Department Head
Staff Member
Department Head
Community Team
#2
All the plugin does is detect if the player is standing in the water, and enables the swim packet. Very simple as intended.
PHP:
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);
}
That's how simple it is... XD
 
#3
Is t
All the plugin does is detect if the player is standing in the water, and enables the swim packet. Very simple as intended.
PHP:
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);
}
That's how simple it is... XD
Is that all the code xD