BadOmenMobEffect .java

net.minecraft.world.effect.BadOmenMobEffect (class): members: shouldApplyEffectTickThisTick, applyEffectTick. imports: Raid, Difficulty, ServerPlayer.

net.minecraft.world.effectclass33 linescommonextends MobEffect1.1 KB

API Surface (2)

boolean shouldApplyEffectTickThisTick(final int remainingDuration, final int amplification)
boolean applyEffectTick(final ServerLevel level, final LivingEntity mob, final int amplification)

Code Graph: Dependencies (7)

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

Full Source

BadOmenMobEffect.java33 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.effect;
2
3
import net.minecraft.server.level.ServerLevel;
4
import net.minecraft.server.level.ServerPlayer;
5
import net.minecraft.world.Difficulty;
6
import net.minecraft.world.entity.LivingEntity;
7
import net.minecraft.world.entity.raid.Raid;
8
9
class BadOmenMobEffect extends MobEffect {
10
	protected BadOmenMobEffect(final MobEffectCategory category, final int color) {
11
		super(category, color);
12
	}
13
14
	@Override
15
	public boolean shouldApplyEffectTickThisTick(final int remainingDuration, final int amplification) {
16
		return true;
17
	}
18
19
	@Override
20
	public boolean applyEffectTick(final ServerLevel level, final LivingEntity mob, final int amplification) {
21
		if (mob instanceof ServerPlayer player && !player.isSpectator() && level.getDifficulty() != Difficulty.PEACEFUL && level.isVillage(player.blockPosition())) {
22
			Raid raid = level.getRaidAt(player.blockPosition());
23
			if (raid == null || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) {
24
				player.addEffect(new MobEffectInstance(MobEffects.RAID_OMEN, 600, amplification));
25
				player.setRaidOmenPosition(player.blockPosition());
26
				return false;
27
			}
28
		}
29
30
		return true;
31
	}
32
}
33

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