mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-01 12:37:10 +00:00
40 lines
2.2 KiB
Diff
40 lines
2.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Telesphoreo <me@telesphoreo.me>
|
|
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<EntityDataSource> SUB_CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
|
@@ -39,7 +42,11 @@ public record EntityDataSource(String selectorPattern, @Nullable EntitySelector
|
|
public Stream<CompoundTag> getData(CommandSourceStack source) throws CommandSyntaxException {
|
|
if (this.compiledSelector != null) {
|
|
List<? extends Entity> list = this.compiledSelector.findEntities(source);
|
|
- return list.stream().map(NbtPredicate::getEntityTagToCompare);
|
|
+ // Scissors start
|
|
+ Stream<? extends Entity> stream = list.stream();
|
|
+ if (ScissorsConfig.excludePlayersFromNbtComponents) stream = stream.filter((entity) -> !(entity instanceof Player));
|
|
+ return stream.map(NbtPredicate::getEntityTagToCompare);
|
|
+ // Scissors end
|
|
} else {
|
|
return Stream.empty();
|
|
}
|