StopBeingAngryIfTargetDead .java

net.minecraft.world.entity.ai.behavior.StopBeingAngryIfTargetDead (class): members: create. imports: BehaviorBuilder, GameRules, MemoryModuleType.

net.minecraft.world.entity.ai.behaviorclass28 linescommon1.0 KB

API Surface (1)

BehaviorControl<LivingEntity> create()

Code Graph: Dependencies (6)

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

Full Source

StopBeingAngryIfTargetDead.java28 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.behavior;
2
3
import java.util.Optional;
4
import net.minecraft.world.entity.EntityTypes;
5
import net.minecraft.world.entity.LivingEntity;
6
import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder;
7
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
8
import net.minecraft.world.level.gamerules.GameRules;
9
10
public class StopBeingAngryIfTargetDead {
11
	public static BehaviorControl<LivingEntity> create() {
12
		return BehaviorBuilder.create(
13
			i -> i.group(i.present(MemoryModuleType.ANGRY_AT))
14
				.apply(
15
					i,
16
					angryAt -> (level, body, timestamp) -> {
17
						Optional.ofNullable(level.getEntity(i.get(angryAt)))
18
							.map(entity -> entity instanceof LivingEntity livingEntity ? livingEntity : null)
19
							.filter(LivingEntity::isDeadOrDying)
20
							.filter(angerTarget -> !angerTarget.is(EntityTypes.PLAYER) || level.getGameRules().get(GameRules.FORGIVE_DEAD_PLAYERS))
21
							.ifPresent(angerTarget -> angryAt.erase());
22
						return true;
23
					}
24
				)
25
		);
26
	}
27
}
28

Decompiled Minecraft 26.3 source of StopBeingAngryIfTargetDead (net/minecraft/world/entity/ai/behavior/StopBeingAngryIfTargetDead.java) with Mojang official mappings, stored verbatim on the site.