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 3bec895fecb3521653fb0b88d4a4854fd3766b46..5fd278ac13c02b9d511be22dba9719cb0cb0e17b 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((instance) -> { @@ -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(); }