Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query(e, 'brain', 'visible_mobs') returning null #1481

Merged
merged 1 commit into from
Jul 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/java/carpet/script/value/ValueConversions.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.ai.behavior.PositionTracker;
import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities;
import net.minecraft.world.entity.ai.memory.WalkTarget;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
Expand All @@ -49,6 +50,7 @@
import java.util.UUID;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

public class ValueConversions
{
Expand Down Expand Up @@ -267,6 +269,9 @@ private static Value fromEntityMemory(Entity e, Object v)
new NumericValue(((WalkTarget) v).getCloseEnoughDist())
);
}
if (v instanceof NearestVisibleLivingEntities nvle) {
v = StreamSupport.stream(nvle.findAll(entity -> true).spliterator(), false).toList();
}
if (v instanceof Set)
{
v = new ArrayList(((Set) v));
Expand Down