From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 2 Apr 2023 16:29:51 -0300 Subject: [PATCH] Patch large selector distance crash diff --git a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java index a890f52e2214242f6e31353bb912813d00e41045..bc0e1938d6e1faca64bb041442bad9e501708fe4 100644 --- a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java +++ b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java @@ -173,7 +173,7 @@ public abstract class MinMaxBounds { return double_ == null ? null : double_ * double_; } - private Doubles(@Nullable Double min, @Nullable Double max) { + public Doubles(@Nullable Double min, @Nullable Double max) { // Scissors - private -> public super(min, max); this.minSq = squareOpt(min); this.maxSq = squareOpt(max); diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java index 0fb8f32427843f4bfd90ab88ecb3ab3e4a4fda31..c9b5f7715d4a866d477c65adb39f11cc46e5623a 100644 --- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java @@ -58,9 +58,27 @@ public class EntitySelector { this.includesEntities = includesNonPlayers; this.worldLimited = localWorldOnly; this.predicate = basePredicate; - this.range = distance; + + // Scissors start - Patch large selector distance crash + this.range = new MinMaxBounds.Doubles( + distance.getMin() != null ? Math.min(distance.getMin(), 1024) : null, + distance.getMax() != null ? Math.min(distance.getMax(), 1024) : null + ); this.position = positionOffset; - this.aabb = box; + if (box != null) { + this.aabb = new AABB( + Math.min(Math.max(box.minX, -1024), 1025), + Math.min(Math.max(box.minY, -1024), 1025), + Math.min(Math.max(box.minZ, -1024), 1025), + Math.min(Math.max(box.maxX, -1024), 1025), + Math.min(Math.max(box.maxY, -1024), 1025), + Math.min(Math.max(box.maxZ, -1024), 1025), + false + ); + } else { + this.aabb = null; + } + // Scissors end this.order = sorter; this.currentEntity = senderOnly; this.playerName = playerName;