aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/WaterAnimal.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
commit42aec6dac53dffa6afe072560a7e1d4986112538 (patch)
tree0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.World/WaterAnimal.cpp
parentc9d58eeac7c72f0b3038e084667b4d89a6249fce (diff)
parentef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff)
Merge branch 'main' into pr/win64-world-saves
# Conflicts: # Minecraft.Client/MinecraftServer.cpp # README.md
Diffstat (limited to 'Minecraft.World/WaterAnimal.cpp')
-rw-r--r--Minecraft.World/WaterAnimal.cpp22
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