From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 10 Dec 2023 17:39:52 -0600 Subject: [PATCH] Don't query player data in the `nbt` component diff --git a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java index 2750702cff35762bc817ffbe5bf81631e86bc49b..8714c3be77490a87aa6df0ff36a87557c6b99e25 100644 --- a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java +++ b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java @@ -8,12 +8,15 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import java.util.List; import java.util.stream.Stream; import javax.annotation.Nullable; + +import me.totalfreedom.scissors.ScissorsConfig; import net.minecraft.advancements.critereon.NbtPredicate; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.selector.EntitySelector; import net.minecraft.commands.arguments.selector.EntitySelectorParser; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; public record EntityDataSource(String selectorPattern, @Nullable EntitySelector compiledSelector) implements DataSource { public static final MapCodec SUB_CODEC = RecordCodecBuilder.mapCodec( @@ -39,7 +42,11 @@ public record EntityDataSource(String selectorPattern, @Nullable EntitySelector public Stream getData(CommandSourceStack source) throws CommandSyntaxException { if (this.compiledSelector != null) { List list = this.compiledSelector.findEntities(source); - return list.stream().map(NbtPredicate::getEntityTagToCompare); + // Scissors start + Stream stream = list.stream(); + if (ScissorsConfig.excludePlayersFromNbtComponents) stream = stream.filter((entity) -> !(entity instanceof Player)); + return stream.map(NbtPredicate::getEntityTagToCompare); + // Scissors end } else { return Stream.empty(); }