EntityDataSource .java

net.minecraft.network.chat.contents.data.EntityDataSource (record): members: selector, getData, MAP_CODEC, codec. strings: "entity". imports: NbtPredicate.

net.minecraft.network.chat.contents.datarecord31 linescommon1.2 KB

Implements

API Surface (2)

Stream<CompoundTag> getData(final CommandSourceStack sender)
MapCodec<EntityDataSource> codec()

Fields & Constants (1)

MAP_CODEC

String literals (1)

"entity"

Code Graph: Dependencies (7)

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

Full Source

EntityDataSource.java31 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.chat.contents.data;
2
3
import com.mojang.brigadier.exceptions.CommandSyntaxException;
4
import com.mojang.serialization.MapCodec;
5
import com.mojang.serialization.codecs.RecordCodecBuilder;
6
import java.util.List;
7
import java.util.stream.Stream;
8
import net.minecraft.advancements.predicates.NbtPredicate;
9
import net.minecraft.commands.CommandSourceStack;
10
import net.minecraft.commands.arguments.selector.EntitySelector;
11
import net.minecraft.nbt.CompoundTag;
12
import net.minecraft.util.CompilableString;
13
import net.minecraft.world.entity.Entity;
14
15
public record EntityDataSource(CompilableString<EntitySelector> selector) implements DataSource {
16
	public static final MapCodec<EntityDataSource> MAP_CODEC = RecordCodecBuilder.mapCodec(
17
		i -> i.group(EntitySelector.COMPILABLE_CODEC.fieldOf("entity").forGetter(EntityDataSource::selector)).apply(i, EntityDataSource::new)
18
	);
19
20
	@Override
21
	public Stream<CompoundTag> getData(final CommandSourceStack sender) throws CommandSyntaxException {
22
		List<? extends Entity> entities = this.selector.compiled().findEntities(sender);
23
		return entities.stream().map(NbtPredicate::getEntityTagToCompare);
24
	}
25
26
	@Override
27
	public MapCodec<EntityDataSource> codec() {
28
		return MAP_CODEC;
29
	}
30
}
31

Decompiled Minecraft 26.3 source of EntityDataSource (net/minecraft/network/chat/contents/data/EntityDataSource.java) with Mojang official mappings, stored verbatim on the site.