ActivityData .java

net.minecraft.world.entity.ai.ActivityData (record): members: activityType, behaviorPriorityPairs, conditions, memoriesToEraseWhenStopped, behaviorList.

net.minecraft.world.entity.airecord83 linescommonextends LivingEntity>3.8 KB

API Surface (7)

<E extends LivingEntity> ActivityData<E> create(final Activity activity, final int priorityOfFirstBehavior, final ImmutableList<? extends BehaviorControl<? super E>> behaviorList)
<E extends LivingEntity> ActivityData<E> create(final Activity activity, final int priorityOfFirstBehavior, final ImmutableList<? extends BehaviorControl<? super E>> behaviorList, final MemoryModuleType<?> memoryThatMustHaveValueAndWillBeErasedAfter)
<E extends LivingEntity> ActivityData<E> create(final Activity activity, final ImmutableList<? extends Pair<Integer, ? extends BehaviorControl<? super E>>> behaviorPriorityPairs)
<E extends LivingEntity> ActivityData<E> create(final Activity activity, final int priorityOfFirstBehavior, final ImmutableList<? extends BehaviorControl<? super E>> behaviorList, final Set<Pair<MemoryModuleType<?>, MemoryStatus>> conditions)
<E extends LivingEntity> ActivityData<E> create(final Activity activity, final ImmutableList<? extends Pair<Integer, ? extends BehaviorControl<? super E>>> behaviorPriorityPairs, final Set<Pair<MemoryModuleType<?>, MemoryStatus>> conditions)
<E extends LivingEntity> ActivityData<E> create(final Activity activity, final ImmutableList<? extends Pair<Integer, ? extends BehaviorControl<? super E>>> behaviorPriorityPairs, final Set<Pair<MemoryModuleType<?>, MemoryStatus>> conditions, final Set<MemoryModuleType<?>> memoriesToEraseWhenStopped)
<E extends LivingEntity> ImmutableList<? extends Pair<Integer, ? extends BehaviorControl<? super E>>> createPriorityPairs(final int priorityOfFirstBehavior, final ImmutableList<? extends BehaviorControl<? super E>> behaviorList)

Fields & Constants (5)

priorityOfFirstBehavior
activity
behaviorList
behaviorPriorityPairs
conditions

Same Package (2)

Code Graph: Dependencies (5)

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

Full Source

ActivityData.java83 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai;
2
3
import com.google.common.collect.ImmutableList;
4
import com.google.common.collect.ImmutableSet;
5
import com.google.common.collect.Sets;
6
import com.google.common.collect.ImmutableList.Builder;
7
import com.mojang.datafixers.util.Pair;
8
import java.util.Set;
9
import net.minecraft.world.entity.LivingEntity;
10
import net.minecraft.world.entity.ai.behavior.BehaviorControl;
11
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
12
import net.minecraft.world.entity.ai.memory.MemoryStatus;
13
import net.minecraft.world.entity.schedule.Activity;
14
15
public record ActivityData<E extends LivingEntity>(
16
	Activity activityType,
17
	ImmutableList<? extends Pair<Integer, ? extends BehaviorControl<? super E>>> behaviorPriorityPairs,
18
	Set<Pair<MemoryModuleType<?>, MemoryStatus>> conditions,
19
	Set<MemoryModuleType<?>> memoriesToEraseWhenStopped
20
) {
21
	public static <E extends LivingEntity> ActivityData<E> create(
22
		final Activity activity, final int priorityOfFirstBehavior, final ImmutableList<? extends BehaviorControl<? super E>> behaviorList
23
	) {
24
		return create(activity, createPriorityPairs(priorityOfFirstBehavior, behaviorList));
25
	}
26
27
	public static <E extends LivingEntity> ActivityData<E> create(
28
		final Activity activity,
29
		final int priorityOfFirstBehavior,
30
		final ImmutableList<? extends BehaviorControl<? super E>> behaviorList,
31
		final MemoryModuleType<?> memoryThatMustHaveValueAndWillBeErasedAfter
32
	) {
33
		Set<Pair<MemoryModuleType<?>, MemoryStatus>> conditions = ImmutableSet.of(Pair.of(memoryThatMustHaveValueAndWillBeErasedAfter, MemoryStatus.VALUE_PRESENT));
34
		Set<MemoryModuleType<?>> memoriesToEraseWhenStopped = ImmutableSet.of(memoryThatMustHaveValueAndWillBeErasedAfter);
35
		return create(activity, createPriorityPairs(priorityOfFirstBehavior, behaviorList), conditions, memoriesToEraseWhenStopped);
36
	}
37
38
	public static <E extends LivingEntity> ActivityData<E> create(
39
		final Activity activity, final ImmutableList<? extends Pair<Integer, ? extends BehaviorControl<? super E>>> behaviorPriorityPairs
40
	) {
41
		return create(activity, behaviorPriorityPairs, ImmutableSet.of(), Sets.newHashSet());
42
	}
43
44
	public static <E extends LivingEntity> ActivityData<E> create(
45
		final Activity activity,
46
		final int priorityOfFirstBehavior,
47
		final ImmutableList<? extends BehaviorControl<? super E>> behaviorList,
48
		final Set<Pair<MemoryModuleType<?>, MemoryStatus>> conditions
49
	) {
50
		return create(activity, createPriorityPairs(priorityOfFirstBehavior, behaviorList), conditions);
51
	}
52
53
	public static <E extends LivingEntity> ActivityData<E> create(
54
		final Activity activity,
55
		final ImmutableList<? extends Pair<Integer, ? extends BehaviorControl<? super E>>> behaviorPriorityPairs,
56
		final Set<Pair<MemoryModuleType<?>, MemoryStatus>> conditions
57
	) {
58
		return create(activity, behaviorPriorityPairs, conditions, Sets.newHashSet());
59
	}
60
61
	public static <E extends LivingEntity> ActivityData<E> create(
62
		final Activity activity,
63
		final ImmutableList<? extends Pair<Integer, ? extends BehaviorControl<? super E>>> behaviorPriorityPairs,
64
		final Set<Pair<MemoryModuleType<?>, MemoryStatus>> conditions,
65
		final Set<MemoryModuleType<?>> memoriesToEraseWhenStopped
66
	) {
67
		return new ActivityData<>(activity, behaviorPriorityPairs, conditions, memoriesToEraseWhenStopped);
68
	}
69
70
	public static <E extends LivingEntity> ImmutableList<? extends Pair<Integer, ? extends BehaviorControl<? super E>>> createPriorityPairs(
71
		final int priorityOfFirstBehavior, final ImmutableList<? extends BehaviorControl<? super E>> behaviorList
72
	) {
73
		int nextPrio = priorityOfFirstBehavior;
74
		Builder<Pair<Integer, ? extends BehaviorControl<? super E>>> listBuilder = ImmutableList.builder();
75
76
		for (BehaviorControl<? super E> behavior : behaviorList) {
77
			listBuilder.add(Pair.of(nextPrio++, behavior));
78
		}
79
80
		return listBuilder.build();
81
	}
82
}
83

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