diff options
Diffstat (limited to 'Minecraft.World/WaterAnimal.cpp')
| -rw-r--r-- | Minecraft.World/WaterAnimal.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Minecraft.World/WaterAnimal.cpp b/Minecraft.World/WaterAnimal.cpp index 0a7313d1..fe94b628 100644 --- a/Minecraft.World/WaterAnimal.cpp +++ b/Minecraft.World/WaterAnimal.cpp @@ -3,6 +3,7 @@ #include "net.minecraft.world.level.tile.h" #include "net.minecraft.world.phys.h" #include "net.minecraft.world.level.h" +#include "net.minecraft.world.damagesource.h" #include "WaterAnimal.h" @@ -39,4 +40,25 @@ bool WaterAnimal::removeWhenFarAway() int WaterAnimal::getExperienceReward(shared_ptr<Player> killedBy) { return 1 + level->random->nextInt(3); +} + +void WaterAnimal::baseTick() +{ + int airSupply = getAirSupply(); + + PathfinderMob::baseTick(); // this modified the airsupply + + if (isAlive() && !isInWater()) + { + setAirSupply(--airSupply); + if (getAirSupply() == -20) + { + setAirSupply(0); + hurt(DamageSource::drown, 2); + } + } + else + { + setAirSupply(TOTAL_AIR_SUPPLY); + } }
\ No newline at end of file |
