diff --git a/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch b/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch index cfcf69a8d4..e750492f2a 100644 --- a/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch +++ b/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch @@ -21,13 +21,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public Collection getSelectedEntities() { + if (io.papermc.paper.configuration.GlobalConfiguration.get().commands.fixTargetSelectorTagCompletion && this.source instanceof ServerPlayer player) { -+ double pickDistance = player.gameMode.getGameModeForPlayer().isCreative() ? 5.0F : 4.5F; -+ Vec3 min = player.getEyePosition(1.0F); -+ Vec3 viewVector = player.getViewVector(1.0F); -+ Vec3 max = min.add(viewVector.x * pickDistance, viewVector.y * pickDistance, viewVector.z * pickDistance); -+ net.minecraft.world.phys.AABB aabb = player.getBoundingBox().expandTowards(viewVector.scale(pickDistance)).inflate(1.0D, 1.0D, 1.0D); -+ pickDistance = player.gameMode.getGameModeForPlayer().isCreative() ? 6.0F : pickDistance; -+ net.minecraft.world.phys.EntityHitResult hitResult = net.minecraft.world.entity.projectile.ProjectileUtil.getEntityHitResult(player, min, max, aabb, (e) -> !e.isSpectator() && e.isPickable(), pickDistance); ++ final Entity cameraEntity = player.getCamera(); ++ final double pickDistance = player.gameMode.getGameModeForPlayer().isCreative() ? 6.0F : 4.5F; ++ final Vec3 min = cameraEntity.getEyePosition(1.0F); ++ final Vec3 viewVector = cameraEntity.getViewVector(1.0F); ++ final Vec3 max = min.add(viewVector.x * pickDistance, viewVector.y * pickDistance, viewVector.z * pickDistance); ++ final net.minecraft.world.phys.AABB aabb = cameraEntity.getBoundingBox().expandTowards(viewVector.scale(pickDistance)).inflate(1.0D, 1.0D, 1.0D); ++ final net.minecraft.world.phys.EntityHitResult hitResult = net.minecraft.world.entity.projectile.ProjectileUtil.getEntityHitResult(cameraEntity, min, max, aabb, (e) -> !e.isSpectator() && e.isPickable(), pickDistance * pickDistance); + return hitResult != null ? java.util.Collections.singletonList(hitResult.getEntity().getStringUUID()) : SharedSuggestionProvider.super.getSelectedEntities(); + } + return SharedSuggestionProvider.super.getSelectedEntities();