比较提交
| 作者 | SHA1 | 提交日期 | |
|---|---|---|---|
|
|
b8e56dafcb | ||
|
|
d0ed839d9f | ||
|
|
20c9cb10a3 | ||
|
|
e8f6009a66 | ||
|
|
8a2c4a21d8 | ||
|
|
134a6e6f20 | ||
|
|
84abb75573 | ||
|
|
e0aadf6564 | ||
|
|
6cbd2a324a | ||
|
|
64e47e7781 |
+19
@@ -0,0 +1,19 @@
|
|||||||
|
# Gradle
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
.vscode/
|
||||||
|
.settings/
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
bin/
|
||||||
|
|
||||||
|
# OS
|
||||||
|
Thumbs.db
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Build temp
|
||||||
|
.buildtmp/
|
||||||
@@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
- 从远程 `markers.json` 拉取各国领土边界
|
- 从远程 `markers.json` 拉取各国领土边界
|
||||||
- 四种扩地策略:方形外扩、区域扩地、玩家周围、绕国一圈
|
- 四种扩地策略:方形外扩、区域扩地、玩家周围、绕国一圈
|
||||||
- 自动寻路(Baritone)前往目标区块
|
- 区域扩地采用 S 形扫描:从与现有领土接壤的区块开始,横向/纵向 S 形扫过整个矩形,不沿邦国边界,但保证每个新占领区块都与已占领领土接壤
|
||||||
|
- 自动寻路(Baritone)前往目标区块,寻路优先走地面减少走入矿洞,超时自动 `/u return` 回城自救
|
||||||
|
- 目标有效性校验:寻路/等待/重试前实时校验目标是否仍与己方领土接壤,不接壤立即跳过并重新规划
|
||||||
- 自动进食(饥饿时自动吃背包食物)
|
- 自动进食(饥饿时自动吃背包食物)
|
||||||
- 实时地图 GUI(通过 Ctrl+R 打开)
|
- 实时地图 GUI(通过 Ctrl+R 打开)
|
||||||
- 监听聊天/字幕消息判断开垦结果
|
- 监听聊天/字幕消息判断开垦结果
|
||||||
@@ -14,7 +16,7 @@
|
|||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
1. 安装 Fabric Loader 0.16.14+ 和 Fabric API
|
1. 安装 Fabric Loader 0.16.14+ 和 Fabric API
|
||||||
2. 将 `autostore-1.0.4.jar` 放入 `.minecraft/mods/` 目录
|
2. 将 `autostore-1.1.6.jar` 放入 `.minecraft/mods/` 目录
|
||||||
3. 启动游戏,按 `Ctrl+R` 打开 GUI
|
3. 启动游戏,按 `Ctrl+R` 打开 GUI
|
||||||
|
|
||||||
## 构建
|
## 构建
|
||||||
@@ -24,4 +26,4 @@
|
|||||||
./build_mod.sh
|
./build_mod.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
输出文件:`autostore-1.0.4.jar`
|
输出文件:`autostore-1.1.6.jar`
|
||||||
|
|||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
plugins {
|
||||||
|
id 'fabric-loom' version '1.17.19'
|
||||||
|
id 'maven-publish'
|
||||||
|
}
|
||||||
|
|
||||||
|
version = project.mod_version
|
||||||
|
group = project.maven_group
|
||||||
|
|
||||||
|
base {
|
||||||
|
archivesName = project.archives_base_name
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// Minecraft
|
||||||
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||||
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
|
|
||||||
|
// Fabric API
|
||||||
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
|
// Baritone API (local jar, compile only)
|
||||||
|
modImplementation files("libs/baritone-api-fabric-1.13.1.jar")
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property "version", project.version
|
||||||
|
filteringCharset "UTF-8"
|
||||||
|
|
||||||
|
filesMatching("fabric.mod.json") {
|
||||||
|
expand "version": project.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
it.options.release = 21
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(21)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
org.gradle.jvmargs=-Xmx2G
|
||||||
|
org.gradle.parallel=true
|
||||||
|
|
||||||
|
# Fabric Properties
|
||||||
|
minecraft_version=1.21.4
|
||||||
|
yarn_mappings=1.21.4+build.8
|
||||||
|
loader_version=0.19.3
|
||||||
|
|
||||||
|
# Mod Properties
|
||||||
|
mod_version=1.1.6
|
||||||
|
maven_group=autostore
|
||||||
|
archives_base_name=autostore
|
||||||
|
|
||||||
|
# Fabric API
|
||||||
|
fabric_version=0.119.4+1.21.4
|
||||||
二进制
二进制文件未显示。
@@ -0,0 +1,9 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-9.7.0-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
retries=0
|
||||||
|
retryBackOffMs=500
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
@@ -0,0 +1,248 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# gradlew start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh gradlew
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
第三方依赖
+82
@@ -0,0 +1,82 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem gradlew startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||||
|
setlocal EnableExtensions
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute gradlew
|
||||||
|
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||||
|
@rem which allows us to clear the local environment before executing the java command
|
||||||
|
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||||
|
|
||||||
|
:exitWithErrorLevel
|
||||||
|
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||||
|
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||||
二进制文件未显示。
+12
@@ -0,0 +1,12 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = 'Fabric'
|
||||||
|
url = 'https://maven.fabricmc.net/'
|
||||||
|
}
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = 'autostore'
|
||||||
@@ -13,6 +13,7 @@ import autostore.client.config.ExpansionConfig;
|
|||||||
import autostore.client.territory.ChunkPos;
|
import autostore.client.territory.ChunkPos;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Baritone API 封装(桥接层)。
|
* Baritone API 封装(桥接层)。
|
||||||
@@ -36,6 +37,12 @@ public final class BaritoneBridge {
|
|||||||
settings.allowPlace.value = config.allowPlace;
|
settings.allowPlace.value = config.allowPlace;
|
||||||
settings.allowParkour.value = config.allowJump;
|
settings.allowParkour.value = config.allowJump;
|
||||||
settings.avoidance.value = config.avoidMobs;
|
settings.avoidance.value = config.avoidMobs;
|
||||||
|
// 减少走入地下矿洞:限制无水源时的下落高度,避免掉进深坑/矿洞。
|
||||||
|
// 放宽到 10 格,仍允许穿越峡谷、下坡等正常地形,同时避免掉入深坑
|
||||||
|
settings.maxFallHeightNoWater.value = 10;
|
||||||
|
// 轻微提高挖掘方块的额外代价,让寻路尽量绕行地面而非挖洞穿山,
|
||||||
|
// 但不会阻止必要挖掘(高山、峡谷等仍可通行)
|
||||||
|
settings.blockBreakAdditionalPenalty.value = 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,6 +69,18 @@ public final class BaritoneBridge {
|
|||||||
baritone.getPathingBehavior().forceCancel();
|
baritone.getPathingBehavior().forceCancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送服务器聊天命令(如 /u return 回城),command 参数不含前导斜杠。
|
||||||
|
* 用于寻路超时后的回城自救,避免玩家被困在地下矿洞等位置。
|
||||||
|
*/
|
||||||
|
public void sendCommand(String command) {
|
||||||
|
MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
if (client == null || client.player == null || client.getNetworkHandler() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
client.getNetworkHandler().sendChatCommand(command);
|
||||||
|
}
|
||||||
|
|
||||||
/** @return 当前是否正在寻路 */
|
/** @return 当前是否正在寻路 */
|
||||||
public boolean isPathing() {
|
public boolean isPathing() {
|
||||||
IBaritone baritone = this.primary();
|
IBaritone baritone = this.primary();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
@@ -76,6 +77,8 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
private final Set<ChunkPos> claimedSet = new HashSet<>();
|
private final Set<ChunkPos> claimedSet = new HashSet<>();
|
||||||
/** 是否正在自动进食 */
|
/** 是否正在自动进食 */
|
||||||
private boolean eating;
|
private boolean eating;
|
||||||
|
/** 回城自救后重新规划时保留重试计数,避免无限循环 */
|
||||||
|
private boolean keepRetryCount;
|
||||||
|
|
||||||
public ExpansionController(TerritoryDataService dataService) {
|
public ExpansionController(TerritoryDataService dataService) {
|
||||||
this.dataService = dataService;
|
this.dataService = dataService;
|
||||||
@@ -230,6 +233,10 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
this.tickNext();
|
this.tickNext();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 9: {
|
||||||
|
this.tickReturning();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +275,10 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
|
|
||||||
/** 让 Baritone 寻路前往当前目标区块,并进入 PATHING 状态 */
|
/** 让 Baritone 寻路前往当前目标区块,并进入 PATHING 状态 */
|
||||||
private void startPathing() {
|
private void startPathing() {
|
||||||
|
if (!this.keepRetryCount) {
|
||||||
this.retryCount = 0;
|
this.retryCount = 0;
|
||||||
|
}
|
||||||
|
this.keepRetryCount = false;
|
||||||
this.stageStartedMillis = System.currentTimeMillis();
|
this.stageStartedMillis = System.currentTimeMillis();
|
||||||
this.lastProgress = 0;
|
this.lastProgress = 0;
|
||||||
this.baritoneBridge.pathTo(this.target);
|
this.baritoneBridge.pathTo(this.target);
|
||||||
@@ -284,8 +294,8 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
this.setState(State.NEXT, "\u76ee\u6807\u4e3a\u7a7a");
|
this.setState(State.NEXT, "\u76ee\u6807\u4e3a\u7a7a");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 目标已被他人占领(地图刷新后发现):立即跳过,避免继续寻路到无效区块
|
// 目标已失效(被占领或不再与己方领土接壤):立即跳过,避免继续寻路到无效区块
|
||||||
if (this.skipIfTargetClaimed("\u76ee\u6807\u5df2\u88ab\u5360\u9886")) {
|
if (this.skipIfTargetInvalid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.playerChunk.equals(this.target)) {
|
if (this.playerChunk.equals(this.target)) {
|
||||||
@@ -302,6 +312,10 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
if (this.retryCount >= this.config.retries) {
|
if (this.retryCount >= this.config.retries) {
|
||||||
this.log("\u5bfb\u8def\u8d85\u65f6\uff0c\u8df3\u8fc7 " + this.target.x() + "," + this.target.z());
|
this.log("\u5bfb\u8def\u8d85\u65f6\uff0c\u8df3\u8fc7 " + this.target.x() + "," + this.target.z());
|
||||||
this.setState(State.FAIL, "\u5bfb\u8def\u8d85\u65f6");
|
this.setState(State.FAIL, "\u5bfb\u8def\u8d85\u65f6");
|
||||||
|
} else if (this.isUnderground()) {
|
||||||
|
// 玩家被困地下(矿洞等):执行 /u return 回城自救,避免被困
|
||||||
|
this.log("\u5bfb\u8def\u8d85\u65f6\u4e14\u73a9\u5bb6\u5728\u5730\u4e0b\uff0c\u6267\u884c /u return \u56de\u57ce\u81ea\u6551 " + this.retryCount + "/" + this.config.retries);
|
||||||
|
this.returnToCapital("\u56de\u57ce\u540e\u91cd\u65b0\u5bfb\u8def " + this.target.x() + "," + this.target.z());
|
||||||
} else {
|
} else {
|
||||||
this.log("\u5bfb\u8def\u8d85\u65f6\uff0c\u91cd\u8bd5 " + this.retryCount + "/" + this.config.retries);
|
this.log("\u5bfb\u8def\u8d85\u65f6\uff0c\u91cd\u8bd5 " + this.retryCount + "/" + this.config.retries);
|
||||||
this.retrySameTarget("\u91cd\u8bd5\u524d\u5f80 " + this.target.x() + "," + this.target.z());
|
this.retrySameTarget("\u91cd\u8bd5\u524d\u5f80 " + this.target.x() + "," + this.target.z());
|
||||||
@@ -315,8 +329,8 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
this.setState(State.NEXT, "\u76ee\u6807\u4e3a\u7a7a");
|
this.setState(State.NEXT, "\u76ee\u6807\u4e3a\u7a7a");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 目标已被他人占领(地图刷新后发现):立即跳过,避免被困在已占领区块
|
// 目标已失效(被占领或不再与己方领土接壤):立即跳过,避免被困在无效区块
|
||||||
if (this.skipIfTargetClaimed("\u76ee\u6807\u5df2\u88ab\u5360\u9886")) {
|
if (this.skipIfTargetInvalid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 玩家离开了目标区块(被击退/寻路偏差),重新寻路回去
|
// 玩家离开了目标区块(被击退/寻路偏差),重新寻路回去
|
||||||
@@ -341,8 +355,9 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
|
|
||||||
/** 重试当前目标:取消旧寻路,重新让 Baritone 前往同一目标区块 */
|
/** 重试当前目标:取消旧寻路,重新让 Baritone 前往同一目标区块 */
|
||||||
private void retrySameTarget(String statusText) {
|
private void retrySameTarget(String statusText) {
|
||||||
// 目标已被他人占领(地图刷新后发现):不再重试,直接跳过,避免玩家被困在已占领区块
|
// 目标已失效(被占领或不再与己方领土接壤):不再重试,直接跳过,
|
||||||
if (this.skipIfTargetClaimed("\u91cd\u8bd5\u65f6\u53d1\u73b0\u76ee\u6807\u5df2\u88ab\u5360\u9886")) {
|
// 避免玩家被反复拉回与领土不接壤的孤立区块
|
||||||
|
if (this.skipIfTargetInvalid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.baritoneBridge.cancel();
|
this.baritoneBridge.cancel();
|
||||||
@@ -352,19 +367,130 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 若当前目标区块已被任何邦国占领(含己方与本次会话),
|
* 若当前目标已失效(被其他邦国占领,或不再与己方领土接壤),
|
||||||
* 则记录日志、跳过该目标并进入 NEXT 状态,返回 true。
|
* 则取消寻路、记录日志、跳过该目标并进入 NEXT 状态,返回 true。
|
||||||
* 用于在地图数据异步刷新后及时识别"已被占领"的区块,避免死循环。
|
* 用于修复"寻路走到与领土不接壤区块后死等"的 bug:
|
||||||
|
* 地图数据刷新后,若目标周围被他人占领导致不再接壤,立即放弃该目标并重新规划。
|
||||||
*/
|
*/
|
||||||
private boolean skipIfTargetClaimed(String reason) {
|
private boolean skipIfTargetInvalid() {
|
||||||
if (this.target != null && this.isClaimedByOthers(this.target)) {
|
if (this.target == null) {
|
||||||
this.log(reason + " " + this.target.x() + "," + this.target.z() + "\uff0c\u8df3\u8fc7");
|
return false;
|
||||||
this.setState(State.NEXT, "\u8df3\u8fc7\u5df2\u5360\u9886\u533a\u5757");
|
}
|
||||||
|
if (!this.isTargetStillValid()) {
|
||||||
|
this.baritoneBridge.cancel();
|
||||||
|
this.log("\u76ee\u6807\u5df2\u5931\u6548\uff08\u88ab\u5360\u9886\u6216\u4e0d\u518d\u4e0e\u9886\u571f\u63a5\u58e4\uff09\uff0c\u8df3\u8fc7 " + this.target.x() + "," + this.target.z());
|
||||||
|
this.setState(State.NEXT, "\u76ee\u6807\u5931\u6548\uff0c\u91cd\u65b0\u89c4\u5212");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断当前目标是否仍然有效:
|
||||||
|
* 未被任何邦国占领,且与己方领土(含本次会话新占领)至少一个区块接壤。
|
||||||
|
* 使用实时地图数据校验,避免寻路到与领土不接壤的孤立区块。
|
||||||
|
*/
|
||||||
|
private boolean isTargetStillValid() {
|
||||||
|
if (this.target == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TerritoryModel m = this.dataService.model();
|
||||||
|
if (m.allClaimedChunks().contains(this.target)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
HashSet<ChunkPos> own = new HashSet<ChunkPos>(m.sessionClaims());
|
||||||
|
TerritoryState self = m.selfState();
|
||||||
|
// Fallback:如果当前刷新后的模型找不到己方邦国,使用启动/规划时缓存的模型
|
||||||
|
// 启动检查成功说明邦国一定存在,fallback 解决竞态/刷新导致的 self 暂时性 null,避免所有目标被跳过
|
||||||
|
if (self == null && this.model != null) {
|
||||||
|
self = this.model.selfState();
|
||||||
|
}
|
||||||
|
if (self != null) {
|
||||||
|
own.addAll(self.chunks());
|
||||||
|
}
|
||||||
|
// 己方领土数据暂时不可用时保守视为有效,避免所有目标被误跳过导致玩家原地不动;
|
||||||
|
// 规划器生成目标时己方领土必然非空,此处 own 为空仅可能是刷新竞态,放行让寻路继续
|
||||||
|
if (own.isEmpty()) {
|
||||||
|
this.log("警告:己方领土数据暂时为空,保守放行目标 " + this.target.x() + "," + this.target.z());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return this.ownNeighbors(this.target, own) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 统计区块周围(上下左右)属于给定集合的邻居数量 */
|
||||||
|
private int ownNeighbors(ChunkPos chunk, Set<ChunkPos> own) {
|
||||||
|
int count = 0;
|
||||||
|
for (ChunkPos neighbor : this.cardinalNeighbors(chunk)) {
|
||||||
|
if (own.contains(neighbor)) {
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 判断区块是否属于己方领土(含本次会话新占领) */
|
||||||
|
private boolean isInOwnTerritory(ChunkPos chunk) {
|
||||||
|
TerritoryModel m = this.dataService.model();
|
||||||
|
if (m.sessionClaims().contains(chunk)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
TerritoryState self = m.selfState();
|
||||||
|
return self != null && self.chunks().contains(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断玩家是否被困在地下(头顶上方连续数格被实心方块遮挡)。
|
||||||
|
* 用于寻路超时时识别"走进矿洞"的情况,从而触发回城自救。
|
||||||
|
*/
|
||||||
|
private boolean isUnderground() {
|
||||||
|
MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
if (client == null || client.player == null || client.world == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
BlockPos pos = client.player.getBlockPos();
|
||||||
|
for (int y = pos.getY() + 1; y <= pos.getY() + 3; ++y) {
|
||||||
|
BlockPos above = new BlockPos(pos.getX(), y, pos.getZ());
|
||||||
|
BlockState state = client.world.getBlockState(above);
|
||||||
|
if (state.isOpaqueFullCube()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回城自救:取消当前寻路,发送 /u return 命令回到国家王城区块,
|
||||||
|
* 并进入 RETURNING 状态等待回城完成后重新规划扩地任务。
|
||||||
|
* 用于避免玩家被困在地下矿洞或无效区块。
|
||||||
|
*/
|
||||||
|
private void returnToCapital(String statusText) {
|
||||||
|
this.baritoneBridge.cancel();
|
||||||
|
this.stageStartedMillis = System.currentTimeMillis();
|
||||||
|
this.keepRetryCount = true;
|
||||||
|
this.baritoneBridge.sendCommand("u return");
|
||||||
|
this.setState(State.RETURNING, "\u56de\u57ce\u81ea\u6551\u4e2d");
|
||||||
|
this.log("\u6267\u884c /u return \u56de\u57ce\uff0c\u7b49\u5f85\u8fd4\u56de\u738b\u57ce\u540e\u7ee7\u7eed");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回城阶段每帧逻辑:等待玩家回到己方领土(含王城)后重新规划。
|
||||||
|
* /u return 传送需要约 10 秒,因此前 10 秒不检查位置,避免传送未完成就误判;
|
||||||
|
* 若等待超时(60 秒)仍未回到领土,则跳过当前目标继续,避免死等。
|
||||||
|
*/
|
||||||
|
private void tickReturning() {
|
||||||
|
long elapsedSeconds = (System.currentTimeMillis() - this.stageStartedMillis) / 1000L;
|
||||||
|
if (elapsedSeconds >= 60) {
|
||||||
|
this.log("\u56de\u57ce\u7b49\u5f85\u8d85\u65f6\uff0c\u8df3\u8fc7\u5f53\u524d\u76ee\u6807\u7ee7\u7eed");
|
||||||
|
this.setState(State.FAIL, "\u56de\u57ce\u8d85\u65f6\uff0c\u8df3\u8fc7\u76ee\u6807");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// /u return 传送约需 10 秒,等待传送完成后才检查是否回到己方领土
|
||||||
|
if (elapsedSeconds >= 10 && this.isInOwnTerritory(this.playerChunk)) {
|
||||||
|
this.log("\u5df2\u56de\u5230\u5df1\u65b9\u9886\u571f\uff0c\u91cd\u65b0\u89c4\u5212\u6269\u5730\u4efb\u52a1");
|
||||||
|
this.setState(State.NEXT, "\u5df2\u56de\u57ce\uff0c\u91cd\u65b0\u89c4\u5212");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 成功后的过渡:进入 NEXT 状态,准备处理下一个目标 */
|
/** 成功后的过渡:进入 NEXT 状态,准备处理下一个目标 */
|
||||||
private void tickSuccess() {
|
private void tickSuccess() {
|
||||||
this.setState(State.NEXT, "\u5df2\u5b8c\u6210 " + this.completedClaims + (this.config.targetCount > 0 ? "/" + this.config.targetCount : "/\u6301\u7eed"));
|
this.setState(State.NEXT, "\u5df2\u5b8c\u6210 " + this.completedClaims + (this.config.targetCount > 0 ? "/" + this.config.targetCount : "/\u6301\u7eed"));
|
||||||
@@ -502,7 +628,8 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动游泳逻辑(每帧调用):
|
* 自动游泳逻辑(每帧调用):
|
||||||
* 玩家处于水中且未站在地面上时自动跳跃(模拟按住空格键),防止溺水。
|
* 仅在玩家完全没入水中(有溺水风险)时自动跳跃,保持浮在水面。
|
||||||
|
* 玩家在水面上正常游泳时不做任何干预,避免干扰 Baritone 的水平寻路。
|
||||||
*/
|
*/
|
||||||
private void tickAutoSwim(MinecraftClient client) {
|
private void tickAutoSwim(MinecraftClient client) {
|
||||||
if (!this.isRunning()) {
|
if (!this.isRunning()) {
|
||||||
@@ -512,10 +639,8 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 完全没入水中,或接触水面且未站在地面(深水区漂浮)时都需要游泳
|
// 只有完全没入水中(头部在水面以下)才有溺水风险,此时才需要跳跃上浮
|
||||||
boolean inWater = player.isSubmergedInWater()
|
if (player.isSubmergedInWater()) {
|
||||||
|| (player.isTouchingWater() && !player.isOnGround());
|
|
||||||
if (inWater) {
|
|
||||||
player.jump();
|
player.jump();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -564,7 +689,7 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
}
|
}
|
||||||
this.baritoneBridge.cancel();
|
this.baritoneBridge.cancel();
|
||||||
client.player.getInventory().selectedSlot = slot;
|
client.player.getInventory().selectedSlot = slot;
|
||||||
client.interactionManager.interactItem(client.player, Hand.field_5808);
|
client.interactionManager.interactItem(client.player, Hand.MAIN_HAND);
|
||||||
this.eating = true;
|
this.eating = true;
|
||||||
this.status = "\u81ea\u52a8\u8fdb\u98df\u4e2d";
|
this.status = "\u81ea\u52a8\u8fdb\u98df\u4e2d";
|
||||||
this.log("\u81ea\u52a8\u8fdb\u98df\uff0c\u9965\u997f\u503c " + foodLevel);
|
this.log("\u81ea\u52a8\u8fdb\u98df\uff0c\u9965\u997f\u503c " + foodLevel);
|
||||||
@@ -575,7 +700,7 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
private int findFoodSlot(PlayerInventory inventory) {
|
private int findFoodSlot(PlayerInventory inventory) {
|
||||||
for (int slot = 0; slot < 36; ++slot) {
|
for (int slot = 0; slot < 36; ++slot) {
|
||||||
ItemStack stack = inventory.getStack(slot);
|
ItemStack stack = inventory.getStack(slot);
|
||||||
if (stack.isEmpty() || stack.getComponents().get(DataComponentTypes.field_50075) == null) continue;
|
if (stack.isEmpty() || stack.getComponents().get(DataComponentTypes.FOOD) == null) continue;
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -631,7 +756,8 @@ implements SubtitleChatMonitor.Listener {
|
|||||||
FAIL,
|
FAIL,
|
||||||
NEXT,
|
NEXT,
|
||||||
COMPLETE,
|
COMPLETE,
|
||||||
STOPPED;
|
STOPPED,
|
||||||
|
RETURNING;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import java.util.List;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.util.Util;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
@@ -38,6 +39,9 @@ import net.minecraft.text.StringVisitable;
|
|||||||
*/
|
*/
|
||||||
public final class AutoStoreGui
|
public final class AutoStoreGui
|
||||||
extends Screen {
|
extends Screen {
|
||||||
|
// ---- 外部链接 ----
|
||||||
|
private static final String GIT_REPO_URL = "https://git.bgjq.top/Lyizai/AutoStore/";
|
||||||
|
private static final String HOMEPAGE_URL = "https://8w.bgjq.top/";
|
||||||
private final AutoStoreModClient mod;
|
private final AutoStoreModClient mod;
|
||||||
private final ExpansionConfig config;
|
private final ExpansionConfig config;
|
||||||
private final ExpansionController controller;
|
private final ExpansionController controller;
|
||||||
@@ -89,7 +93,7 @@ extends Screen {
|
|||||||
this.mapY = 40;
|
this.mapY = 40;
|
||||||
this.mapW = Math.max(120, this.panelX - this.mapX - 8);
|
this.mapW = Math.max(120, this.panelX - this.mapX - 8);
|
||||||
// 底部信息区高度(日志 + 状态文本),地图填满其上方空间
|
// 底部信息区高度(日志 + 状态文本),地图填满其上方空间
|
||||||
int infoHeight = 78;
|
int infoHeight = 88;
|
||||||
this.mapH = Math.max(140, this.height - this.mapY - infoHeight - 8);
|
this.mapH = Math.max(140, this.height - this.mapY - infoHeight - 8);
|
||||||
|
|
||||||
// 屏幕较矮时压缩垂直间距,保证右侧面板内容不被截断
|
// 屏幕较矮时压缩垂直间距,保证右侧面板内容不被截断
|
||||||
@@ -99,6 +103,9 @@ extends Screen {
|
|||||||
|
|
||||||
// ===== 顶部控制按钮 =====
|
// ===== 顶部控制按钮 =====
|
||||||
int topX = this.panelX;
|
int topX = this.panelX;
|
||||||
|
// 左上角外部链接按钮:Git 仓库与官网(点击在系统浏览器打开)
|
||||||
|
this.addDrawableChild(ButtonWidget.builder(Text.literal((String)"Git \u4ed3\u5e93"), button -> this.openUrl(GIT_REPO_URL)).dimensions(this.mapX, 8, 70, 16).build());
|
||||||
|
this.addDrawableChild(ButtonWidget.builder(Text.literal((String)"\u5b98\u7f51"), button -> this.openUrl(HOMEPAGE_URL)).dimensions(this.mapX + 76, 8, 50, 16).build());
|
||||||
ButtonWidget startButton = ButtonWidget.builder(Text.literal((String)"\u5f00\u59cb\u81ea\u52a8\u6269\u5730"), button -> this.start()).dimensions(topX, 34, 154, 30).build();
|
ButtonWidget startButton = ButtonWidget.builder(Text.literal((String)"\u5f00\u59cb\u81ea\u52a8\u6269\u5730"), button -> this.start()).dimensions(topX, 34, 154, 30).build();
|
||||||
ButtonWidget stopButton = ButtonWidget.builder(Text.literal((String)"\u505c\u6b62"), button -> this.controller.stop()).dimensions(topX + 160, 34, 74, 30).build();
|
ButtonWidget stopButton = ButtonWidget.builder(Text.literal((String)"\u505c\u6b62"), button -> this.controller.stop()).dimensions(topX + 160, 34, 74, 30).build();
|
||||||
this.addDrawableChild(startButton);
|
this.addDrawableChild(startButton);
|
||||||
@@ -158,6 +165,15 @@ extends Screen {
|
|||||||
this.initializeMapView();
|
this.initializeMapView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 在系统默认浏览器中打开外部链接(失败时静默忽略) */
|
||||||
|
private void openUrl(String url) {
|
||||||
|
try {
|
||||||
|
Util.getOperatingSystem().open(new java.net.URI(url));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// 链接打开失败不影响界面正常使用
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 创建整数输入框(初始值为 value,最多 12 位) */
|
/** 创建整数输入框(初始值为 value,最多 12 位) */
|
||||||
private TextFieldWidget numberField(int value, int x, int y, int width) {
|
private TextFieldWidget numberField(int value, int x, int y, int width) {
|
||||||
TextFieldWidget field = new TextFieldWidget(this.textRenderer, x, y, width, 20, Text.literal((String)""));
|
TextFieldWidget field = new TextFieldWidget(this.textRenderer, x, y, width, 20, Text.literal((String)""));
|
||||||
@@ -422,26 +438,50 @@ extends Screen {
|
|||||||
|
|
||||||
/** 绘制右侧信息面板:字段标签、运行日志与状态/进度信息 */
|
/** 绘制右侧信息面板:字段标签、运行日志与状态/进度信息 */
|
||||||
private void drawInfo(DrawContext context) {
|
private void drawInfo(DrawContext context) {
|
||||||
int shown;
|
// ===== 右侧配置面板字段标签 =====
|
||||||
context.drawTextWithShadow(this.textRenderer, "\u90a6\u56fd", this.panelX + 4, this.stateFieldY + 4, -5592406);
|
context.drawTextWithShadow(this.textRenderer, "\u90a6\u56fd", this.panelX + 4, this.stateFieldY + 4, -5592406);
|
||||||
context.drawTextWithShadow(this.textRenderer, "\u76ee\u6807\u6570\u91cf", this.panelX + 4, this.targetFieldY + 4, -5592406);
|
context.drawTextWithShadow(this.textRenderer, "\u76ee\u6807\u6570\u91cf", this.panelX + 4, this.targetFieldY + 4, -5592406);
|
||||||
context.drawTextWithShadow(this.textRenderer, "\u6743\u9650\u8bbe\u7f6e", this.panelX + 4, this.advancedY, -5592406);
|
context.drawTextWithShadow(this.textRenderer, "\u6743\u9650\u8bbe\u7f6e", this.panelX + 4, this.advancedY, -5592406);
|
||||||
int belowY = this.mapY + this.mapH + 12;
|
|
||||||
|
// ===== 底部信息面板:日志(左)+ 状态(右),均单行截断,避免换行导致的重叠 =====
|
||||||
|
int infoTop = this.mapY + this.mapH + 10;
|
||||||
int logWidth = Math.max(120, (int)(this.mapW * 0.52));
|
int logWidth = Math.max(120, (int)(this.mapW * 0.52));
|
||||||
int statusX = this.mapX + logWidth + 20;
|
int statusX = this.mapX + logWidth + 24;
|
||||||
int statusWidth = this.mapW - logWidth - 20;
|
int statusWidth = this.mapW - logWidth - 24;
|
||||||
|
|
||||||
|
// 半透明面板背景,使信息区与地图明显分隔
|
||||||
|
context.fill(this.mapX, infoTop - 2, this.mapX + this.mapW, infoTop + 74, 0x30000000);
|
||||||
|
// 两栏标题与竖向分隔线
|
||||||
|
context.drawTextWithShadow(this.textRenderer, "\u8fd0\u884c\u65e5\u5fd7", this.mapX + 2, infoTop, -5592406);
|
||||||
|
context.drawTextWithShadow(this.textRenderer, "\u72b6\u6001\u4fe1\u606f", statusX, infoTop, -5592406);
|
||||||
|
context.fill(statusX - 12, infoTop - 1, statusX - 11, infoTop + 58, -12761518);
|
||||||
|
|
||||||
|
// 运行日志:最多 4 条,最新日志在最下方
|
||||||
List<String> logs = this.controller.logs();
|
List<String> logs = this.controller.logs();
|
||||||
for (int i = shown = Math.min(4, logs.size()); i > 0; --i) {
|
int shown = Math.min(4, logs.size());
|
||||||
String trimmed = this.textRenderer.trimToWidth(logs.get(logs.size() - i), logWidth);
|
for (int i = 0; i < shown; ++i) {
|
||||||
context.drawTextWithShadow(this.textRenderer, trimmed, this.mapX, belowY + (shown - i) * 12, -6577233);
|
String trimmed = this.textRenderer.trimToWidth(logs.get(logs.size() - shown + i), logWidth - 4);
|
||||||
|
context.drawTextWithShadow(this.textRenderer, trimmed, this.mapX + 2, infoTop + 12 + i * 12, -6577233);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 状态信息:单行截断 + 固定 12px 行距,彻底消除换行重叠
|
||||||
int target = this.config.targetCount;
|
int target = this.config.targetCount;
|
||||||
String targetText = target > 0 ? Integer.toString(target) : "\u6301\u7eed";
|
String targetText = target > 0 ? Integer.toString(target) : "\u6301\u7eed";
|
||||||
context.drawWrappedTextWithShadow(this.textRenderer, Text.literal(("\u72b6\u6001\uff1a" + this.controller.status())), statusX, belowY, statusWidth, -1);
|
String error = this.mod.dataService().lastError();
|
||||||
context.drawWrappedTextWithShadow(this.textRenderer, Text.literal(("\u8fdb\u5ea6\uff1a" + this.controller.completedClaims() + " / " + targetText + "\uff0c\u7b49\u5f85\uff1a" + this.controller.lastProgress() + "%")), statusX, belowY + 14, statusWidth, -1);
|
String[] statusLines = new String[]{
|
||||||
context.drawWrappedTextWithShadow(this.textRenderer, Text.literal(("\u961f\u5217\uff1a" + this.controller.queuedTargets() + "\uff0c\u6570\u636e\u9519\u8bef\uff1a" + (this.mod.dataService().lastError().isEmpty() ? "\u65e0" : this.mod.dataService().lastError()))), statusX, belowY + 30, statusWidth, -1);
|
"\u72b6\u6001\uff1a" + this.controller.status(),
|
||||||
context.drawWrappedTextWithShadow(this.textRenderer, Text.literal(this.refreshStatusText()), statusX, belowY + 46, statusWidth, -5592406);
|
"\u8fdb\u5ea6\uff1a" + this.controller.completedClaims() + " / " + targetText + "\uff0c\u7b49\u5f85\uff1a" + this.controller.lastProgress() + "%",
|
||||||
context.drawWrappedTextWithShadow(this.textRenderer, Text.literal((String)"\u5f00\u59cb\u524d\u8bf7\u786e\u8ba4\u5df2\u624b\u52a8\u6267\u884c /u claimmode"), statusX, belowY + 62, statusWidth, -13210);
|
"\u961f\u5217\uff1a" + this.controller.queuedTargets() + "\uff0c\u6570\u636e\u9519\u8bef\uff1a" + (error.isEmpty() ? "\u65e0" : error),
|
||||||
|
this.refreshStatusText()
|
||||||
|
};
|
||||||
|
for (int i = 0; i < statusLines.length; ++i) {
|
||||||
|
String trimmed = this.textRenderer.trimToWidth(statusLines[i], statusWidth);
|
||||||
|
context.drawTextWithShadow(this.textRenderer, trimmed, statusX, infoTop + 12 + i * 12, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 底部整行提示
|
||||||
|
String hint = this.textRenderer.trimToWidth("\u5f00\u59cb\u524d\u8bf7\u786e\u8ba4\u5df2\u624b\u52a8\u6267\u884c /u claimmode", this.mapW);
|
||||||
|
context.drawTextWithShadow(this.textRenderer, hint, this.mapX + 2, infoTop + 62, -13210);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 生成地图刷新状态文本(显示上次成功刷新距今的时间) */
|
/** 生成地图刷新状态文本(显示上次成功刷新距今的时间) */
|
||||||
@@ -500,6 +540,11 @@ extends Screen {
|
|||||||
target.avoidMobs = this.config.avoidMobs;
|
target.avoidMobs = this.config.avoidMobs;
|
||||||
target.allowBreak = this.config.allowBreak;
|
target.allowBreak = this.config.allowBreak;
|
||||||
target.allowPlace = this.config.allowPlace;
|
target.allowPlace = this.config.allowPlace;
|
||||||
|
// 同步矩形圈选坐标到全局配置(修复:之前忘记同步,导致区域扩地总是为空)
|
||||||
|
target.regionMinX = this.config.regionMinX;
|
||||||
|
target.regionMaxX = this.config.regionMaxX;
|
||||||
|
target.regionMinZ = this.config.regionMinZ;
|
||||||
|
target.regionMaxZ = this.config.regionMaxZ;
|
||||||
this.mod.saveConfig();
|
this.mod.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import autostore.client.config.ExpansionConfig;
|
|||||||
import autostore.client.territory.ChunkPos;
|
import autostore.client.territory.ChunkPos;
|
||||||
import autostore.client.territory.TerritoryModel;
|
import autostore.client.territory.TerritoryModel;
|
||||||
import autostore.client.territory.TerritoryState;
|
import autostore.client.territory.TerritoryState;
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -191,11 +190,13 @@ public final class ExpansionPlanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 策略 2 矩形区域扩地:完全按玩家圈选的矩形区域扩地。
|
* 策略 2 矩形区域扩地:在玩家圈选的矩形内,从与现有领土接壤的区块开始,
|
||||||
|
* 横向或纵向 S 形扫过整个矩形。
|
||||||
*
|
*
|
||||||
* <p>先检查矩形区域是否与己方领土接壤(矩形内至少有一个未占领区块与领土相邻),
|
* <p>与旧版"沿邦国边界逐层向内 BFS"不同,本算法不再贴着邦国现有边界,
|
||||||
* 若未接壤则返回空列表(不扩地)。接壤后,从接壤边界开始 BFS 逐层向内,
|
* 而是生成一条贯穿矩形的 S 形路径:从接壤起点开始,逐行/逐列交替反向扫过,
|
||||||
* 将矩形内所有未被占领的区块全部纳入计划,保证每个区块都与已占领领土连通。
|
* 保证路径上每个区块都与已占领领土(含己方领土、本次会话新占领)接壤,
|
||||||
|
* 矩形内已占领的区块自动跳过、不重复占领。
|
||||||
*/
|
*/
|
||||||
private List<ChunkPos> generateRectangle(TerritoryModel model, ExpansionConfig config, ChunkPos playerChunk) {
|
private List<ChunkPos> generateRectangle(TerritoryModel model, ExpansionConfig config, ChunkPos playerChunk) {
|
||||||
Set<ChunkPos> actualOwn = this.ownChunks(model);
|
Set<ChunkPos> actualOwn = this.ownChunks(model);
|
||||||
@@ -208,50 +209,138 @@ public final class ExpansionPlanner {
|
|||||||
int minZ = config.regionMinZ;
|
int minZ = config.regionMinZ;
|
||||||
int maxZ = config.regionMaxZ;
|
int maxZ = config.regionMaxZ;
|
||||||
int limit = config.targetCount > 0 ? config.targetCount : Integer.MAX_VALUE;
|
int limit = config.targetCount > 0 ? config.targetCount : Integer.MAX_VALUE;
|
||||||
// 检查矩形是否与己方领土接壤:矩形内至少有一个未占领区块与领土相邻
|
// 找出矩形内所有与己方领土接壤的未占领区块(作为 S 形起点候选)
|
||||||
boolean bordersOwn = false;
|
ArrayList<ChunkPos> borderChunks = new ArrayList<ChunkPos>();
|
||||||
for (int x = minX; x <= maxX; ++x) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
ChunkPos chunk = new ChunkPos(x, z);
|
ChunkPos chunk = new ChunkPos(x, z);
|
||||||
if (allClaimed.contains(chunk)) continue;
|
if (allClaimed.contains(chunk)) continue;
|
||||||
if (this.ownNeighbors(chunk, actualOwn) > 0) {
|
if (this.ownNeighbors(chunk, actualOwn) > 0) {
|
||||||
bordersOwn = true;
|
borderChunks.add(chunk);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bordersOwn) break;
|
|
||||||
}
|
}
|
||||||
if (!bordersOwn) {
|
if (borderChunks.isEmpty()) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
// 初始边界:矩形内与己方领土(原始领土)直接相邻的未占领区块
|
// 选择起点:优先矩形角落附近与领土接壤的区块,使 S 形能自然覆盖整个矩形
|
||||||
HashSet<ChunkPos> plannedOwn = new HashSet<ChunkPos>(actualOwn);
|
ChunkPos start = this.chooseStart(borderChunks, minX, maxX, minZ, maxZ);
|
||||||
ArrayDeque<ChunkPos> frontier = new ArrayDeque<ChunkPos>();
|
// 生成 S 形扫描路径(覆盖矩形内所有区块,含已占领的)
|
||||||
|
List<ChunkPos> sPath = this.buildSPath(start, minX, maxX, minZ, maxZ);
|
||||||
|
// 已占领集合:己方领土 + 所有已占领 + 本次规划已纳入的区块
|
||||||
|
HashSet<ChunkPos> claimed = new HashSet<ChunkPos>(actualOwn);
|
||||||
|
claimed.addAll(allClaimed);
|
||||||
ArrayList<ChunkPos> result = new ArrayList<ChunkPos>();
|
ArrayList<ChunkPos> result = new ArrayList<ChunkPos>();
|
||||||
for (int x = minX; x <= maxX; ++x) {
|
for (ChunkPos chunk : sPath) {
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
if (result.size() >= limit) break;
|
||||||
ChunkPos chunk = new ChunkPos(x, z);
|
if (claimed.contains(chunk)) continue;
|
||||||
if (allClaimed.contains(chunk) || plannedOwn.contains(chunk)) continue;
|
// 必须与已占领领土接壤,保证能够开拓
|
||||||
if (this.ownNeighbors(chunk, actualOwn) > 0) {
|
if (this.ownNeighbors(chunk, claimed) == 0) continue;
|
||||||
plannedOwn.add(chunk);
|
|
||||||
frontier.add(chunk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// BFS 逐层向内填满整个矩形
|
|
||||||
while (!frontier.isEmpty() && result.size() < limit) {
|
|
||||||
ChunkPos chunk = frontier.removeFirst();
|
|
||||||
result.add(chunk);
|
result.add(chunk);
|
||||||
for (ChunkPos neighbor : this.cardinalNeighbors(chunk)) {
|
claimed.add(chunk);
|
||||||
if (neighbor.x() < minX || neighbor.x() > maxX || neighbor.z() < minZ || neighbor.z() > maxZ) continue;
|
|
||||||
if (allClaimed.contains(neighbor) || plannedOwn.contains(neighbor)) continue;
|
|
||||||
plannedOwn.add(neighbor);
|
|
||||||
frontier.add(neighbor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从接壤候选区块中选择 S 形扫描的起点:
|
||||||
|
* 优先选择矩形角落上的接壤区块;没有角落接壤时,选择离任一角落最近的接壤区块。
|
||||||
|
*/
|
||||||
|
private ChunkPos chooseStart(List<ChunkPos> borderChunks, int minX, int maxX, int minZ, int maxZ) {
|
||||||
|
ChunkPos[] corners = new ChunkPos[]{new ChunkPos(minX, minZ), new ChunkPos(maxX, minZ), new ChunkPos(minX, maxZ), new ChunkPos(maxX, maxZ)};
|
||||||
|
for (ChunkPos corner : corners) {
|
||||||
|
if (borderChunks.contains(corner)) {
|
||||||
|
return corner;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ChunkPos best = null;
|
||||||
|
int bestDist = Integer.MAX_VALUE;
|
||||||
|
for (ChunkPos chunk : borderChunks) {
|
||||||
|
for (ChunkPos corner : corners) {
|
||||||
|
int dist = Math.abs(chunk.x() - corner.x()) + Math.abs(chunk.z() - corner.z());
|
||||||
|
if (dist < bestDist) {
|
||||||
|
bestDist = dist;
|
||||||
|
best = chunk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成从起点开始的 S 形扫描路径,覆盖矩形内所有区块。
|
||||||
|
*
|
||||||
|
* <p>扫描主轴根据起点所在边缘决定:起点在顶/底行时横向逐行扫描,
|
||||||
|
* 起点在左/右列时纵向逐列扫描。每行/列内方向交替反向,形成 S 形。
|
||||||
|
* 起点所在行/列从起点向两侧铺开,保证起点是路径第一个区块。
|
||||||
|
*/
|
||||||
|
private List<ChunkPos> buildSPath(ChunkPos start, int minX, int maxX, int minZ, int maxZ) {
|
||||||
|
ArrayList<ChunkPos> path = new ArrayList<ChunkPos>();
|
||||||
|
boolean horizontal = start.z() == minZ || start.z() == maxZ;
|
||||||
|
if (horizontal) {
|
||||||
|
int startRow = start.z();
|
||||||
|
// 起点行:从起点向一侧到边缘,再反向到另一侧,完整覆盖该行
|
||||||
|
boolean leftToRight = start.x() == minX;
|
||||||
|
if (leftToRight) {
|
||||||
|
for (int x = start.x(); x <= maxX; ++x) path.add(new ChunkPos(x, startRow));
|
||||||
|
for (int x = start.x() - 1; x >= minX; --x) path.add(new ChunkPos(x, startRow));
|
||||||
|
} else {
|
||||||
|
for (int x = start.x(); x >= minX; --x) path.add(new ChunkPos(x, startRow));
|
||||||
|
for (int x = start.x() + 1; x <= maxX; ++x) path.add(new ChunkPos(x, startRow));
|
||||||
|
}
|
||||||
|
// 其余行:先向下(+z)再向上(-z),每行方向交替,形成 S 形
|
||||||
|
boolean ltr = leftToRight;
|
||||||
|
for (int z = startRow + 1; z <= maxZ; ++z) {
|
||||||
|
this.appendRow(path, z, minX, maxX, ltr);
|
||||||
|
ltr = !ltr;
|
||||||
|
}
|
||||||
|
for (int z = startRow - 1; z >= minZ; --z) {
|
||||||
|
this.appendRow(path, z, minX, maxX, ltr);
|
||||||
|
ltr = !ltr;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int startCol = start.x();
|
||||||
|
// 起点列:从起点向一侧到边缘,再反向到另一侧,完整覆盖该列
|
||||||
|
boolean topToBottom = start.z() == minZ;
|
||||||
|
if (topToBottom) {
|
||||||
|
for (int z = start.z(); z <= maxZ; ++z) path.add(new ChunkPos(startCol, z));
|
||||||
|
for (int z = start.z() - 1; z >= minZ; --z) path.add(new ChunkPos(startCol, z));
|
||||||
|
} else {
|
||||||
|
for (int z = start.z(); z >= minZ; --z) path.add(new ChunkPos(startCol, z));
|
||||||
|
for (int z = start.z() + 1; z <= maxZ; ++z) path.add(new ChunkPos(startCol, z));
|
||||||
|
}
|
||||||
|
// 其余列:先向右(+x)再向左(-x),每列方向交替,形成 S 形
|
||||||
|
boolean ttb = topToBottom;
|
||||||
|
for (int x = startCol + 1; x <= maxX; ++x) {
|
||||||
|
this.appendCol(path, x, minZ, maxZ, ttb);
|
||||||
|
ttb = !ttb;
|
||||||
|
}
|
||||||
|
for (int x = startCol - 1; x >= minX; --x) {
|
||||||
|
this.appendCol(path, x, minZ, maxZ, ttb);
|
||||||
|
ttb = !ttb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 追加一行区块到路径(leftToRight=true 时从左到右,否则从右到左) */
|
||||||
|
private void appendRow(List<ChunkPos> path, int row, int minX, int maxX, boolean leftToRight) {
|
||||||
|
if (leftToRight) {
|
||||||
|
for (int x = minX; x <= maxX; ++x) path.add(new ChunkPos(x, row));
|
||||||
|
} else {
|
||||||
|
for (int x = maxX; x >= minX; --x) path.add(new ChunkPos(x, row));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 追加一列区块到路径(topToBottom=true 时从上到下,否则从下到上) */
|
||||||
|
private void appendCol(List<ChunkPos> path, int col, int minZ, int maxZ, boolean topToBottom) {
|
||||||
|
if (topToBottom) {
|
||||||
|
for (int z = minZ; z <= maxZ; ++z) path.add(new ChunkPos(col, z));
|
||||||
|
} else {
|
||||||
|
for (int z = maxZ; z >= minZ; --z) path.add(new ChunkPos(col, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 在候选集中找到离当前游标最近的一个区块(曼哈顿距离),作为推进的前沿 */
|
/** 在候选集中找到离当前游标最近的一个区块(曼哈顿距离),作为推进的前沿 */
|
||||||
private ChunkPos nearestFrontier(Set<ChunkPos> candidates, ChunkPos cursor) {
|
private ChunkPos nearestFrontier(Set<ChunkPos> candidates, ChunkPos cursor) {
|
||||||
return candidates.stream().min(Comparator.comparingInt(cursor::manhattanDistance)).orElse(null);
|
return candidates.stream().min(Comparator.comparingInt(cursor::manhattanDistance)).orElse(null);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"schemaVersion":1,"id":"autostore","version":"1.0.4","name":"AutoStore","description":"","authors":[],"contact":{},"license":"All-Rights-Reserved","environment":"client","entrypoints":{"fabric-datagen":["autostore.client.AutoStoreModDataGenerator"],"client":["autostore.client.AutoStoreModClient"],"main":["autostore.AutoStoreMod"]},"mixins":["autostore.mixins.json",{"config":"autostore.client.mixins.json","environment":"client"}],"depends":{"fabricloader":">=0.16.14","fabric-api":"*","minecraft":"1.21.4"},"jars":[{"file":"META-INF/jars/baritone-api-fabric-1.13.1.jar"}]}
|
{"schemaVersion":1,"id":"autostore","version":"1.1.6","name":"AutoStore","description":"","authors":[],"contact":{},"license":"All-Rights-Reserved","environment":"client","entrypoints":{"fabric-datagen":["autostore.client.AutoStoreModDataGenerator"],"client":["autostore.client.AutoStoreModClient"],"main":["autostore.AutoStoreMod"]},"mixins":["autostore.mixins.json",{"config":"autostore.client.mixins.json","environment":"client"}],"depends":{"fabricloader":">=0.16.14","fabric-api":"*","minecraft":"1.21.4"},"jars":[{"file":"META-INF/jars/baritone-api-fabric-1.13.1.jar"}]}
|
||||||
在新工单中引用
屏蔽一个用户