HungerMobEffect .java

net.minecraft.world.effect.HungerMobEffect (class, 26 lines): extends MobEffect. members: shouldApplyEffectTickThisTick, applyEffectTick. imports: Player.

net.minecraft.world.effectclass26 linescommonextends MobEffect707 B

API Surface (2)

boolean applyEffectTick(final ServerLevel serverLevel, final LivingEntity mob, final int amplification)
boolean shouldApplyEffectTickThisTick(final int tickCount, final int amplification)

Code Graph: Dependencies (5)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

HungerMobEffect.java26 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.effect;
2
3
import net.minecraft.server.level.ServerLevel;
4
import net.minecraft.world.entity.LivingEntity;
5
import net.minecraft.world.entity.player.Player;
6
7
class HungerMobEffect extends MobEffect {
8
	protected HungerMobEffect(final MobEffectCategory category, final int color) {
9
		super(category, color);
10
	}
11
12
	@Override
13
	public boolean applyEffectTick(final ServerLevel serverLevel, final LivingEntity mob, final int amplification) {
14
		if (mob instanceof Player player) {
15
			player.causeFoodExhaustion(0.005F * (amplification + 1));
16
		}
17
18
		return true;
19
	}
20
21
	@Override
22
	public boolean shouldApplyEffectTickThisTick(final int tickCount, final int amplification) {
23
		return true;
24
	}
25
}
26

Decompiled Minecraft 26.3 source of HungerMobEffect (net/minecraft/world/effect/HungerMobEffect.java) with Mojang official mappings, stored verbatim on the site.