added files.
This commit is contained in:
commit
03a7ed8358
9721 files changed
+828024
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
# Gradle
|
||||
/.gradle/
|
||||
/.jvmdg/
|
||||
/build/
|
||||
/out/
|
||||
/target/
|
||||
|
||||
# Minecraft / Client runtime
|
||||
/run/
|
||||
/ViaVersion/
|
||||
/augustus/
|
||||
/logs/
|
||||
/crash-reports/
|
||||
/screenshots/
|
||||
/saves/
|
||||
/config/
|
||||
options.txt
|
||||
optionsof.txt
|
||||
|
||||
# Logs & crash dumps
|
||||
*.log
|
||||
hs_err_pid*.log
|
||||
replay_pid*.log
|
||||
|
||||
# IDEs
|
||||
.idea/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.vscode/
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
# OS / Temp
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
@@ -0,0 +1,62 @@
|
||||
<p align="center">
|
||||
<img src="assets/ss.png" alt="Skid Solutions Banner" width="350" />
|
||||
<br><br>
|
||||
<a href="https://discord.gg/skidsolutions">
|
||||
<img src="https://img.shields.io/badge/Discord-Skid%20Solutions-18181b?style=for-the-badge&logo=discord&logoColor=ffffff&labelColor=09090b" alt="Discord" />
|
||||
</a>
|
||||
<img src="https://img.shields.io/badge/Version-b4.23.3-27272a?style=for-the-badge&labelColor=09090b" alt="Version b4.23.3" />
|
||||
<img src="https://img.shields.io/badge/Java-8-3f3f46?style=for-the-badge&logo=openjdk&logoColor=ffffff&labelColor=09090b" alt="Java 8" />
|
||||
<img src="https://img.shields.io/badge/Gradle-8.14.3-52525b?style=for-the-badge&logo=gradle&logoColor=ffffff&labelColor=09090b" alt="Gradle 8.14.3" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/skidsolutions">https://discord.gg/skidsolutions</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="assets/divider.svg" alt="" width="720" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="assets/jak.jpg" alt="jak" height="150" />
|
||||
<img src="assets/hack.jpg" alt="hack" height="150" />
|
||||
<img src="assets/deobf2.png" alt="deobf2" height="150" />
|
||||
<img src="assets/deobf.jpg" alt="deobf" height="150" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="assets/divider.svg" alt="" width="720" />
|
||||
</p>
|
||||
|
||||
## How to build
|
||||
|
||||
### Prerequisites
|
||||
- **Java Development Kit**: JDK 8 (used via Gradle toolchain to compile and run the Minecraft 1.8.9 client)
|
||||
- **Gradle Runtime**: JDK 17 or JDK 21 (Gradle wrapper 8.14.3 does not run on JDK 25+)
|
||||
|
||||
### Building OpenAugustus
|
||||
|
||||
Run from this folder:
|
||||
|
||||
```powershell
|
||||
.\gradlew.bat clean build
|
||||
```
|
||||
|
||||
Generated `build/libs/`:
|
||||
- `openaugustus-b4.23.3.jar`
|
||||
|
||||
### Running
|
||||
|
||||
```powershell
|
||||
# Run in local run/ directory (extracts natives and downloads Minecraft 1.8 assets automatically)
|
||||
.\gradlew.bat runClient
|
||||
|
||||
# Or run using your system .minecraft directory
|
||||
.\gradlew.bat runClientMinecraftDir
|
||||
```
|
||||
|
||||
Or run `Start.java` / `StartMinecraftDirectory.java` directly from your IDE.
|
||||
|
||||
---
|
||||
|
||||
Credits to https://github.com/yxzeroo/openaugustus, all features, issues and bugs fixed on this version, jst compare everything.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
@@ -0,0 +1,26 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 820 20" width="820" height="20" role="img" aria-hidden="true">
|
||||
<defs>
|
||||
<linearGradient id="baseLine" x1="0%" y1="0%" x2="100%" y2="0%">
|
||||
<stop offset="0%" stop-color="#000000" stop-opacity="0" />
|
||||
<stop offset="25%" stop-color="#404040" stop-opacity="0.7" />
|
||||
<stop offset="50%" stop-color="#d4d4d4" stop-opacity="0.95" />
|
||||
<stop offset="75%" stop-color="#404040" stop-opacity="0.7" />
|
||||
<stop offset="100%" stop-color="#000000" stop-opacity="0" />
|
||||
</linearGradient>
|
||||
<linearGradient id="pulse" x1="0%" y1="0%" x2="100%" y2="0%">
|
||||
<stop offset="0%" stop-color="#ffffff" stop-opacity="0" />
|
||||
<stop offset="50%" stop-color="#ffffff" stop-opacity="1" />
|
||||
<stop offset="100%" stop-color="#ffffff" stop-opacity="0" />
|
||||
</linearGradient>
|
||||
<clipPath id="lineClip">
|
||||
<rect x="40" y="8" width="740" height="4" rx="2" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
|
||||
<rect x="40" y="9.25" width="740" height="1.5" rx="0.75" fill="url(#baseLine)" />
|
||||
<g clip-path="url(#lineClip)">
|
||||
<rect x="-120" y="8.5" width="140" height="3" rx="1.5" fill="url(#pulse)">
|
||||
<animate attributeName="x" values="-120;820" dur="3.4s" repeatCount="indefinite" />
|
||||
</rect>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 323 KiB |
+374
@@ -0,0 +1,374 @@
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'idea'
|
||||
id 'eclipse'
|
||||
}
|
||||
|
||||
group = 'net.augustus'
|
||||
version = 'b4.23.3'
|
||||
|
||||
def currentOs = OperatingSystem.current()
|
||||
def osClassifier = currentOs.isWindows() ? 'windows' : (currentOs.isMacOsX() ? 'osx' : 'linux')
|
||||
def jfxClassifier = currentOs.isWindows() ? 'win' : (currentOs.isMacOsX() ? 'mac' : 'linux')
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(8)
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = 'Minecraft'
|
||||
url = uri('https://libraries.minecraft.net/')
|
||||
content {
|
||||
includeGroup 'com.mojang'
|
||||
includeGroup 'com.ibm.icu'
|
||||
includeGroup 'com.paulscode'
|
||||
includeGroup 'org.lwjgl.lwjgl'
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = 'ViaVersion'
|
||||
url = uri('https://repo.viaversion.com')
|
||||
}
|
||||
maven {
|
||||
name = 'Lenni0451'
|
||||
url = uri('https://maven.lenni0451.net/releases')
|
||||
}
|
||||
maven {
|
||||
name = 'Wagyourtail'
|
||||
url = uri('https://maven.wagyourtail.xyz/releases')
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
natives
|
||||
jvmdgTool {
|
||||
canBeResolved = true
|
||||
canBeConsumed = false
|
||||
attributes {
|
||||
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
|
||||
}
|
||||
}
|
||||
java8Downgrade {
|
||||
canBeResolved = true
|
||||
canBeConsumed = false
|
||||
attributes {
|
||||
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def downgradedDepsDir = layout.buildDirectory.dir('downgraded-deps')
|
||||
|
||||
def downgradeJava8Deps = tasks.register('downgradeJava8Deps') {
|
||||
group = 'build'
|
||||
description = 'Downgrades Java 11+/17+ Gradle dependencies (ViaVersion, OpenJFX) to Java 8 bytecode.'
|
||||
inputs.files(configurations.java8Downgrade)
|
||||
outputs.dir(downgradedDepsDir)
|
||||
|
||||
doLast {
|
||||
def outDir = downgradedDepsDir.get().asFile
|
||||
outDir.mkdirs()
|
||||
def jvmdgWorkDir = layout.buildDirectory.dir('tmp/jvmdg').get().asFile
|
||||
jvmdgWorkDir.mkdirs()
|
||||
|
||||
def inputFiles = configurations.java8Downgrade.resolve()
|
||||
def extraCp = configurations.compileClasspath.resolve().findAll { !it.absolutePath.startsWith(outDir.absolutePath) }
|
||||
def allCp = (inputFiles + extraCp).unique()
|
||||
def expectedNames = new HashSet<String>()
|
||||
def cpString = allCp.collect { it.absolutePath }.join(File.pathSeparator)
|
||||
|
||||
inputFiles.each { File jarFile ->
|
||||
if (!jarFile.name.endsWith('.jar')) {
|
||||
return
|
||||
}
|
||||
def outName = jarFile.name.replace('.jar', '-java8.jar')
|
||||
expectedNames.add(outName)
|
||||
def outFile = new File(outDir, outName)
|
||||
if (!outFile.exists() || outFile.lastModified() < jarFile.lastModified()) {
|
||||
javaexec {
|
||||
workingDir = jvmdgWorkDir
|
||||
classpath = configurations.jvmdgTool
|
||||
mainClass = 'xyz.wagyourtail.jvmdg.compile.ZipDowngrader'
|
||||
jvmArgs '-Djava.util.concurrent.ForkJoinPool.common.parallelism=1'
|
||||
args '52', jarFile.absolutePath, outFile.absolutePath, cpString
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outDir.listFiles()?.each { File existing ->
|
||||
if (!expectedNames.contains(existing.name)) {
|
||||
existing.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Compile-time annotations & Lombok
|
||||
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
|
||||
compileOnly 'org.jetbrains:annotations:24.0.1'
|
||||
compileOnly 'org.projectlombok:lombok:1.18.30'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.30'
|
||||
|
||||
// Minecraft 1.8.9 standard libraries
|
||||
implementation 'com.mojang:authlib:1.5.21'
|
||||
implementation 'com.ibm.icu:icu4j-core-mojang:51.2'
|
||||
implementation 'com.paulscode:codecjorbis:20101023'
|
||||
implementation 'com.paulscode:codecwav:20101023'
|
||||
implementation 'com.paulscode:libraryjavasound:20101123'
|
||||
implementation 'com.paulscode:librarylwjglopenal:20100824'
|
||||
implementation 'com.paulscode:soundsystem:20120107'
|
||||
implementation 'org.jcraft:jorbis:0.0.17'
|
||||
|
||||
implementation 'org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209'
|
||||
implementation 'org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209'
|
||||
natives "org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209:natives-${osClassifier}"
|
||||
runtimeOnly "org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209:natives-${osClassifier}"
|
||||
|
||||
implementation('net.java.jinput:jinput:2.0.9') {
|
||||
exclude group: 'net.java.jinput', module: 'jinput-platform'
|
||||
}
|
||||
natives "net.java.jinput:jinput:2.0.9:natives-all"
|
||||
runtimeOnly "net.java.jinput:jinput:2.0.9:natives-all"
|
||||
implementation 'net.java.jutils:jutils:1.0.0'
|
||||
|
||||
implementation 'javax.vecmath:vecmath:1.5.2'
|
||||
implementation 'net.sf.jopt-simple:jopt-simple:5.0.4'
|
||||
implementation 'com.google.guava:guava:33.6.0-jre'
|
||||
implementation 'com.google.code.gson:gson:2.13.1'
|
||||
implementation 'commons-io:commons-io:2.18.0'
|
||||
implementation 'commons-codec:commons-codec:1.18.0'
|
||||
implementation 'commons-logging:commons-logging:1.2'
|
||||
implementation 'org.apache.commons:commons-lang3:3.17.0'
|
||||
implementation 'org.apache.commons:commons-compress:1.27.1'
|
||||
implementation 'org.apache.commons:commons-math3:3.6.1'
|
||||
implementation 'org.apache.httpcomponents:httpclient:4.5.14'
|
||||
implementation 'org.apache.httpcomponents:httpcore:4.4.16'
|
||||
implementation 'org.apache.logging.log4j:log4j-api:2.24.3'
|
||||
implementation 'org.apache.logging.log4j:log4j-core:2.24.3'
|
||||
implementation 'org.slf4j:slf4j-api:2.0.17'
|
||||
implementation 'org.slf4j:slf4j-simple:2.0.17'
|
||||
|
||||
implementation 'io.netty:netty-all:4.1.118.Final'
|
||||
implementation 'com.github.oshi:oshi-core:6.6.3'
|
||||
implementation 'net.java.dev.jna:jna:5.15.0'
|
||||
implementation 'net.java.dev.jna:jna-platform:5.15.0'
|
||||
implementation 'it.unimi.dsi:fastutil:8.5.15'
|
||||
implementation 'org.jctools:jctools-core:4.0.5'
|
||||
|
||||
// Client libraries
|
||||
implementation 'com.microsoft.onnxruntime:onnxruntime:1.20.0'
|
||||
implementation 'org.yaml:snakeyaml:2.5'
|
||||
implementation 'org.json:json:20160810'
|
||||
implementation 'io.jsonwebtoken:jjwt-api:0.13.0'
|
||||
implementation 'io.jsonwebtoken:jjwt-impl:0.13.0'
|
||||
runtimeOnly 'io.jsonwebtoken:jjwt-gson:0.13.0'
|
||||
implementation('org.slick2d:slick2d-core:1.0.2') {
|
||||
exclude group: 'javax.jnlp', module: 'jnlp-api'
|
||||
exclude group: 'org.lwjgl.lwjgl'
|
||||
exclude group: 'org.jcraft'
|
||||
}
|
||||
|
||||
// JvmDowngrader CLI tool & Java 8 runtime stubs for downgraded ViaVersion / OpenJFX bytecode
|
||||
jvmdgTool 'xyz.wagyourtail.jvmdowngrader:jvmdowngrader:2.0.1'
|
||||
jvmdgTool 'xyz.wagyourtail.jvmdowngrader:jvmdowngrader-java-api:2.0.1'
|
||||
implementation 'xyz.wagyourtail.jvmdowngrader:jvmdowngrader-java-api:2.0.1:downgraded-8'
|
||||
|
||||
// Java 11+/17+ dependencies downgraded automatically to Java 8 bytecode via downgradeJava8Deps
|
||||
java8Downgrade('com.viaversion:viaversion-common:5.7.1') { transitive = false }
|
||||
java8Downgrade('com.viaversion:viabackwards-common:5.7.1') { transitive = false }
|
||||
java8Downgrade('com.viaversion:viarewind-common:4.0.14') { transitive = false }
|
||||
java8Downgrade('com.viaversion:viaaprilfools-common:4.0.8') { transitive = false }
|
||||
java8Downgrade('com.viaversion:nbt:5.1.2') { transitive = false }
|
||||
|
||||
java8Downgrade("org.openjfx:javafx-base:11.0.2:${jfxClassifier}") { transitive = false }
|
||||
java8Downgrade("org.openjfx:javafx-graphics:11.0.2:${jfxClassifier}") { transitive = false }
|
||||
java8Downgrade("org.openjfx:javafx-controls:11.0.2:${jfxClassifier}") { transitive = false }
|
||||
java8Downgrade("org.openjfx:javafx-fxml:11.0.2:${jfxClassifier}") { transitive = false }
|
||||
java8Downgrade("org.openjfx:javafx-media:11.0.2:${jfxClassifier}") { transitive = false }
|
||||
java8Downgrade("org.openjfx:javafx-swing:11.0.2:${jfxClassifier}") { transitive = false }
|
||||
java8Downgrade("org.openjfx:javafx-web:11.0.2:${jfxClassifier}") { transitive = false }
|
||||
|
||||
implementation files(fileTree(downgradedDepsDir) { include '*.jar' }).builtBy(downgradeJava8Deps)
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
dependsOn downgradeJava8Deps
|
||||
options.encoding = 'UTF-8'
|
||||
options.fork = true
|
||||
options.forkOptions.memoryInitialSize = '1g'
|
||||
options.forkOptions.memoryMaximumSize = '4g'
|
||||
options.warnings = false
|
||||
}
|
||||
|
||||
tasks.withType(AbstractArchiveTask).configureEach {
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
}
|
||||
|
||||
// --- Standard MCP Gradle tasks ---
|
||||
|
||||
def nativesDir = layout.buildDirectory.dir('natives')
|
||||
def runDir = file("${projectDir}/run")
|
||||
def defaultAssetsDir = project.hasProperty('assetsDir')
|
||||
? file(project.property('assetsDir'))
|
||||
: new File(runDir, 'assets')
|
||||
|
||||
def extractNatives = tasks.register('extractNatives', Sync) {
|
||||
group = 'minecraft'
|
||||
description = 'Extracts LWJGL and JInput native libraries for the current OS.'
|
||||
into nativesDir
|
||||
from {
|
||||
configurations.natives.resolve().collect { zipTree(it) }
|
||||
}
|
||||
exclude 'META-INF/**'
|
||||
}
|
||||
|
||||
tasks.named('classes') {
|
||||
dependsOn extractNatives
|
||||
}
|
||||
|
||||
def downloadAssets = tasks.register('downloadAssets') {
|
||||
group = 'minecraft'
|
||||
description = 'Downloads the Minecraft 1.8 asset index and missing asset objects into run/assets.'
|
||||
onlyIf { !project.hasProperty('skipAssets') }
|
||||
|
||||
doLast {
|
||||
def assetsDir = defaultAssetsDir
|
||||
def indexesDir = new File(assetsDir, 'indexes')
|
||||
def objectsDir = new File(assetsDir, 'objects')
|
||||
indexesDir.mkdirs()
|
||||
objectsDir.mkdirs()
|
||||
|
||||
def indexFile = new File(indexesDir, '1.8.json')
|
||||
if (!indexFile.exists()) {
|
||||
logger.lifecycle('Downloading Minecraft 1.8 asset index...')
|
||||
def manifestUrl = new URL('https://piston-meta.mojang.com/mc/game/version_manifest_v2.json')
|
||||
def manifest = new groovy.json.JsonSlurper().parse(manifestUrl)
|
||||
def v189 = manifest.versions.find { it.id == '1.8.9' }
|
||||
if (v189 == null) {
|
||||
throw new GradleException('Could not locate Minecraft 1.8.9 in Mojang version manifest.')
|
||||
}
|
||||
def versionMeta = new groovy.json.JsonSlurper().parse(new URL(v189.url))
|
||||
def assetIndexUrl = new URL(versionMeta.assetIndex.url)
|
||||
indexFile.bytes = assetIndexUrl.bytes
|
||||
}
|
||||
|
||||
def indexJson = new groovy.json.JsonSlurper().parse(indexFile)
|
||||
def objects = indexJson.objects as Map<String, Map>
|
||||
def missing = []
|
||||
objects.each { name, info ->
|
||||
String hash = info.hash
|
||||
String prefix = hash.substring(0, 2)
|
||||
File target = new File(objectsDir, "${prefix}/${hash}")
|
||||
if (!target.exists() || target.length() != (info.size as long)) {
|
||||
missing << [hash: hash, prefix: prefix, target: target]
|
||||
}
|
||||
}
|
||||
|
||||
if (!missing.isEmpty()) {
|
||||
logger.lifecycle("Downloading ${missing.size()} missing Minecraft 1.8 assets...")
|
||||
missing.each { entry ->
|
||||
File target = entry.target
|
||||
target.parentFile.mkdirs()
|
||||
def url = new URL("https://resources.download.minecraft.net/${entry.prefix}/${entry.hash}")
|
||||
url.withInputStream { input ->
|
||||
target.withOutputStream { output -> output << input }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def prepareRunDir = tasks.register('prepareRunDir') {
|
||||
group = 'minecraft'
|
||||
description = 'Prepares the MCP run/ working directory.'
|
||||
doLast {
|
||||
runDir.mkdirs()
|
||||
defaultAssetsDir.mkdirs()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('runClient', JavaExec) {
|
||||
group = 'minecraft'
|
||||
description = 'Runs the Minecraft 1.8.9 OpenAugustus client.'
|
||||
dependsOn tasks.named('classes'), extractNatives, prepareRunDir, downloadAssets
|
||||
|
||||
javaLauncher = javaToolchains.launcherFor {
|
||||
languageVersion = JavaLanguageVersion.of(8)
|
||||
}
|
||||
|
||||
mainClass = 'net.minecraft.client.main.Main'
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
workingDir = runDir
|
||||
|
||||
jvmArgs "-Djava.library.path=${nativesDir.get().asFile.absolutePath}",
|
||||
"-Dorg.lwjgl.librarypath=${nativesDir.get().asFile.absolutePath}",
|
||||
"-Dnet.java.games.input.librarypath=${nativesDir.get().asFile.absolutePath}",
|
||||
'-Xms512m',
|
||||
'-Xmx2g'
|
||||
|
||||
args '--version', '1.8.9',
|
||||
'--accessToken', '0',
|
||||
'--gameDir', runDir.absolutePath,
|
||||
'--assetsDir', defaultAssetsDir.absolutePath,
|
||||
'--assetIndex', '1.8',
|
||||
'--userProperties', '{}'
|
||||
|
||||
if (project.hasProperty('username')) {
|
||||
args '--username', project.property('username').toString()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('runClientMinecraftDir', JavaExec) {
|
||||
group = 'minecraft'
|
||||
description = 'Runs OpenAugustus using the system .minecraft game and assets directory.'
|
||||
dependsOn tasks.named('classes'), extractNatives
|
||||
|
||||
javaLauncher = javaToolchains.launcherFor {
|
||||
languageVersion = JavaLanguageVersion.of(8)
|
||||
}
|
||||
|
||||
mainClass = 'StartMinecraftDirectory'
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
workingDir = runDir
|
||||
|
||||
jvmArgs "-Djava.library.path=${nativesDir.get().asFile.absolutePath}",
|
||||
"-Dorg.lwjgl.librarypath=${nativesDir.get().asFile.absolutePath}",
|
||||
"-Dnet.java.games.input.librarypath=${nativesDir.get().asFile.absolutePath}",
|
||||
'-Xms512m',
|
||||
'-Xmx2g'
|
||||
|
||||
if (project.hasProperty('username')) {
|
||||
args '--username', project.property('username').toString()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('prepareIde') {
|
||||
group = 'ide'
|
||||
description = 'Prepares downgraded dependencies, natives, and compiles the client for IDE import.'
|
||||
dependsOn downgradeJava8Deps, extractNatives, tasks.named('compileJava')
|
||||
}
|
||||
|
||||
tasks.named('jar') {
|
||||
manifest {
|
||||
attributes 'Main-Class': 'Start'
|
||||
}
|
||||
}
|
||||
|
||||
idea {
|
||||
project {
|
||||
languageLevel = '1.8'
|
||||
targetBytecodeVersion = JavaVersion.VERSION_1_8
|
||||
}
|
||||
module {
|
||||
downloadJavadoc = false
|
||||
downloadSources = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
Vendored
BIN
Binary file not shown.
+8
@@ -0,0 +1,8 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionSha256Sum=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531
|
||||
@@ -0,0 +1,251 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 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
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle 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 Gradle
|
||||
#
|
||||
# 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/HEAD/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
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# 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" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
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" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-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" "$@"
|
||||
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
@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 Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
: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
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,12 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
name = 'Wagyourtail'
|
||||
url = uri('https://maven.wagyourtail.xyz/releases')
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'openaugustus'
|
||||
@@ -0,0 +1,21 @@
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import net.minecraft.client.main.Main;
|
||||
|
||||
public class Start {
|
||||
|
||||
public static Object[] concat(Object[] array, Object[] array2) {
|
||||
Object[] array3 = Arrays.copyOf(array, array.length + array2.length);
|
||||
System.arraycopy(array2, 0, array3, array.length, array2.length);
|
||||
return array3;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String assetsDir = new File("assets/indexes").isDirectory()
|
||||
? "assets"
|
||||
: (new File("run/assets").isDirectory() ? "run/assets" : "assets");
|
||||
Main.main(
|
||||
(String[])concat(new String[]{"--version", "1.8.9", "--accessToken", "0", "--assetsDir", assetsDir, "--assetIndex", "1.8", "--userProperties", "{}"}, args)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import net.augustus.utils.OSUtil;
|
||||
import net.minecraft.client.main.Main;
|
||||
|
||||
public class StartMinecraftDirectory {
|
||||
|
||||
public static Object[] concat(Object[] array, Object[] array2) {
|
||||
Object[] array3 = Arrays.copyOf(array, array.length + array2.length);
|
||||
System.arraycopy(array2, 0, array3, array.length, array2.length);
|
||||
return array3;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
File file = new File(OSUtil.detectOS().getMinecraftDirectory());
|
||||
File file2 = new File(file + File.separator + "assets");
|
||||
Main.main(
|
||||
(String[])concat(
|
||||
new String[]{
|
||||
"--version",
|
||||
"1.8.9",
|
||||
"--accessToken",
|
||||
"0",
|
||||
"--assetsDir",
|
||||
file2.toString(),
|
||||
"--gameDir",
|
||||
file.toString(),
|
||||
"--assetIndex",
|
||||
"1.8",
|
||||
"--userProperties",
|
||||
"{}"
|
||||
},
|
||||
args
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
package baritone;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.behavior.IBehavior;
|
||||
import baritone.api.behavior.ILookBehavior;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.cache.IWorldProvider;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import baritone.api.event.listener.IEventBus;
|
||||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.process.IBuilderProcess;
|
||||
import baritone.api.process.ICustomGoalProcess;
|
||||
import baritone.api.process.IExploreProcess;
|
||||
import baritone.api.process.IFarmProcess;
|
||||
import baritone.api.process.IFollowProcess;
|
||||
import baritone.api.process.IGetToBlockProcess;
|
||||
import baritone.api.process.IMineProcess;
|
||||
import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.behavior.InventoryBehavior;
|
||||
import baritone.behavior.LookBehavior;
|
||||
import baritone.behavior.PathingBehavior;
|
||||
import baritone.behavior.WaypointBehavior;
|
||||
import baritone.cache.WorldProvider;
|
||||
import baritone.command.manager.CommandManager;
|
||||
import baritone.event.GameEventHandler;
|
||||
import baritone.process.InventoryPauserProcess;
|
||||
import baritone.utils.player.BaritonePlayerContext;
|
||||
import baritone.api.utils.IInputOverrideHandler;
|
||||
import baritone.process.BackfillProcess;
|
||||
import baritone.process.BuilderProcess;
|
||||
import baritone.process.CustomGoalProcess;
|
||||
import baritone.process.ExploreProcess;
|
||||
import baritone.process.FarmProcess;
|
||||
import baritone.process.FollowProcess;
|
||||
import baritone.process.GetToBlockProcess;
|
||||
import baritone.process.MineProcess;
|
||||
import baritone.selection.SelectionManager;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.GuiClick;
|
||||
import baritone.utils.InputOverrideHandler;
|
||||
import baritone.utils.PathingControlManager;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class Baritone implements IBaritone {
|
||||
private static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
||||
private final Minecraft mc;
|
||||
private final Path directory;
|
||||
private final GameEventHandler gameEventHandler;
|
||||
private final PathingBehavior pathingBehavior;
|
||||
private final LookBehavior lookBehavior;
|
||||
private final InventoryBehavior inventoryBehavior;
|
||||
private final InputOverrideHandler inputOverrideHandler;
|
||||
private final FollowProcess followProcess;
|
||||
private final MineProcess mineProcess;
|
||||
private final GetToBlockProcess getToBlockProcess;
|
||||
private final CustomGoalProcess customGoalProcess;
|
||||
private final BuilderProcess builderProcess;
|
||||
private final ExploreProcess exploreProcess;
|
||||
private final FarmProcess farmProcess;
|
||||
private final InventoryPauserProcess inventoryPauserProcess;
|
||||
private final PathingControlManager pathingControlManager;
|
||||
private final SelectionManager selectionManager;
|
||||
private final CommandManager commandManager;
|
||||
private final IPlayerContext playerContext;
|
||||
private final WorldProvider worldProvider;
|
||||
public BlockStateInterface bsi;
|
||||
|
||||
@Override
|
||||
public IGetToBlockProcess getGetToBlockProcess() {
|
||||
return this.getGetToBlockProcess2();
|
||||
}
|
||||
|
||||
public SelectionManager getSelectionManager2() {
|
||||
return this.selectionManager;
|
||||
}
|
||||
|
||||
public static Executor getThreadPool() {
|
||||
return threadPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILookBehavior getLookBehavior() {
|
||||
return this.getLookBehavior2();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICustomGoalProcess getCustomGoalProcess() {
|
||||
return this.getCustomGoalProcess2();
|
||||
}
|
||||
|
||||
public void registerBehavior(IBehavior behavior) {
|
||||
this.gameEventHandler.registerEventListener(behavior);
|
||||
}
|
||||
|
||||
public InventoryBehavior getInventoryBehavior() {
|
||||
return this.inventoryBehavior;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBuilderProcess getBuilderProcess() {
|
||||
return this.getBuilderProcess2();
|
||||
}
|
||||
|
||||
public MineProcess getMineProcess2() {
|
||||
return this.mineProcess;
|
||||
}
|
||||
|
||||
public LookBehavior getLookBehavior2() {
|
||||
return this.lookBehavior;
|
||||
}
|
||||
|
||||
public FollowProcess getFollowProcess2() {
|
||||
return this.followProcess;
|
||||
}
|
||||
|
||||
public ExploreProcess getExploreProcess2() {
|
||||
return this.exploreProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISelectionManager getSelectionManager() {
|
||||
return this.getSelectionManager2();
|
||||
}
|
||||
|
||||
public WorldProvider getWorldProvider2() {
|
||||
return this.worldProvider;
|
||||
}
|
||||
|
||||
public BuilderProcess getBuilderProcess2() {
|
||||
return this.builderProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPathingBehavior getPathingBehavior() {
|
||||
return this.getPathingBehavior2();
|
||||
}
|
||||
|
||||
public InputOverrideHandler getInputOverrideHandler2() {
|
||||
return this.inputOverrideHandler;
|
||||
}
|
||||
|
||||
public IBaritoneProcess registerProcess(Function<Baritone, ? extends IBaritoneProcess> function) {
|
||||
IBaritoneProcess baritoneProcess = (IBaritoneProcess)function.apply(this);
|
||||
this.pathingControlManager.registerProcess(baritoneProcess);
|
||||
return baritoneProcess;
|
||||
}
|
||||
|
||||
public GetToBlockProcess getGetToBlockProcess2() {
|
||||
return this.getToBlockProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFollowProcess getFollowProcess() {
|
||||
return this.getFollowProcess2();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMineProcess getMineProcess() {
|
||||
return this.getMineProcess2();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExploreProcess getExploreProcess() {
|
||||
return this.getExploreProcess2();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openClick() {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(100L);
|
||||
Minecraft mc2 = this.mc;
|
||||
Runnable runnable = () -> {
|
||||
this.mc.displayGuiScreen(new GuiClick());
|
||||
};
|
||||
mc2.addScheduledTask(runnable);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager2() {
|
||||
return this.commandManager;
|
||||
}
|
||||
|
||||
public CustomGoalProcess getCustomGoalProcess2() {
|
||||
return this.customGoalProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPathingControlManager getPathingControlManager() {
|
||||
return this.getPathingControlManager2();
|
||||
}
|
||||
|
||||
public PathingBehavior getPathingBehavior2() {
|
||||
return this.pathingBehavior;
|
||||
}
|
||||
|
||||
public InventoryPauserProcess getInventoryPauserProcess() {
|
||||
return this.inventoryPauserProcess;
|
||||
}
|
||||
|
||||
public IBehavior registerBehavior2(Function<Baritone, ? extends IBehavior> function) {
|
||||
IBehavior behavior = (IBehavior)function.apply(this);
|
||||
this.registerBehavior(behavior);
|
||||
return behavior;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFarmProcess getFarmProcess() {
|
||||
return this.getFarmProcess2();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEventBus getGameEventHandler() {
|
||||
return this.gameEventHandler;
|
||||
}
|
||||
|
||||
public Path getDirectory() {
|
||||
return this.directory;
|
||||
}
|
||||
|
||||
public static Settings settings() {
|
||||
return BaritoneAPI.getSettings();
|
||||
}
|
||||
|
||||
public PathingControlManager getPathingControlManager2() {
|
||||
return this.pathingControlManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInputOverrideHandler getInputOverrideHandler() {
|
||||
return this.getInputOverrideHandler2();
|
||||
}
|
||||
|
||||
public FarmProcess getFarmProcess2() {
|
||||
return this.farmProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorldProvider getWorldProvider() {
|
||||
return this.getWorldProvider2();
|
||||
}
|
||||
|
||||
public Baritone(Minecraft mc2) {
|
||||
this.mc = mc2;
|
||||
this.gameEventHandler = new GameEventHandler(this);
|
||||
this.directory = mc2.mcDataDir.toPath().resolve("baritone");
|
||||
if (!Files.exists(this.directory)) {
|
||||
try {
|
||||
Files.createDirectories(this.directory);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
this.playerContext = new BaritonePlayerContext(this, mc2);
|
||||
this.lookBehavior = (LookBehavior)this.registerBehavior2(LookBehavior::new);
|
||||
this.pathingBehavior = (PathingBehavior)this.registerBehavior2(PathingBehavior::new);
|
||||
this.inventoryBehavior = (InventoryBehavior)this.registerBehavior2(InventoryBehavior::new);
|
||||
this.inputOverrideHandler = (InputOverrideHandler)this.registerBehavior2(InputOverrideHandler::new);
|
||||
this.registerBehavior2(WaypointBehavior::new);
|
||||
this.pathingControlManager = new PathingControlManager(this);
|
||||
this.followProcess = (FollowProcess)this.registerProcess(FollowProcess::new);
|
||||
this.mineProcess = (MineProcess)this.registerProcess(MineProcess::new);
|
||||
this.customGoalProcess = (CustomGoalProcess)this.registerProcess(CustomGoalProcess::new);
|
||||
this.getToBlockProcess = (GetToBlockProcess)this.registerProcess(GetToBlockProcess::new);
|
||||
this.builderProcess = (BuilderProcess)this.registerProcess(BuilderProcess::new);
|
||||
this.exploreProcess = (ExploreProcess)this.registerProcess(ExploreProcess::new);
|
||||
this.farmProcess = (FarmProcess)this.registerProcess(FarmProcess::new);
|
||||
this.inventoryPauserProcess = (InventoryPauserProcess)this.registerProcess(InventoryPauserProcess::new);
|
||||
this.registerProcess(BackfillProcess::new);
|
||||
this.worldProvider = new WorldProvider(this);
|
||||
this.selectionManager = new SelectionManager(this);
|
||||
this.commandManager = new CommandManager(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayerContext getPlayerContext() {
|
||||
return this.playerContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandManager getCommandManager() {
|
||||
return this.getCommandManager2();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package baritone;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.IBaritoneProvider;
|
||||
import baritone.api.command.ICommandSystem;
|
||||
import baritone.api.schematic.ISchematicSystem;
|
||||
import baritone.cache.WorldScanner;
|
||||
import baritone.command.CommandSystem;
|
||||
import baritone.api.cache.IWorldScanner;
|
||||
import baritone.command.ExampleBaritoneControl;
|
||||
import baritone.utils.schematic.SchematicSystem;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public final class BaritoneProvider implements IBaritoneProvider {
|
||||
private final List all = new CopyOnWriteArrayList();
|
||||
private final List allView = Collections.unmodifiableList(this.all);
|
||||
|
||||
@Override
|
||||
public ISchematicSystem getInstance() {
|
||||
return SchematicSystem.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getAllBaritones() {
|
||||
return this.allView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean destroyBaritone(IBaritone baritone) {
|
||||
return baritone != this.getPrimaryBaritone() && this.all.remove(baritone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandSystem getInstance2() {
|
||||
return CommandSystem.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorldScanner getInstance3() {
|
||||
return WorldScanner.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaritone getPrimaryBaritone() {
|
||||
return (IBaritone)this.all.get(0);
|
||||
}
|
||||
|
||||
public BaritoneProvider() {
|
||||
((Baritone)this.createBaritone(Minecraft.getMinecraft())).registerBehavior2(ExampleBaritoneControl::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized IBaritone createBaritone(Minecraft mc) {
|
||||
Object baritoneForMinecraft = this.getBaritoneForMinecraft(mc);
|
||||
if (baritoneForMinecraft == null) {
|
||||
this.all.add(baritoneForMinecraft = new Baritone(mc));
|
||||
}
|
||||
|
||||
return (IBaritone)baritoneForMinecraft;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package baritone;
|
||||
|
||||
public @interface KeepName {
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package baritone.api;
|
||||
|
||||
import baritone.BaritoneProvider;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
|
||||
public final class BaritoneAPI {
|
||||
private static final SettingsRegistry settingsRegistry = new SettingsRegistry();
|
||||
private static final Settings settings = new Settings(settingsRegistry);
|
||||
private static final IBaritoneProvider provider;
|
||||
|
||||
static {
|
||||
String str = "settings.txt";
|
||||
SettingsUtil.readAndApply(settings, str);
|
||||
provider = new BaritoneProvider();
|
||||
}
|
||||
|
||||
public static IBaritoneProvider getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public static SettingsRegistry getSettingsRegistry() {
|
||||
return settingsRegistry;
|
||||
}
|
||||
|
||||
public static Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package baritone.api;
|
||||
|
||||
import baritone.api.behavior.ILookBehavior;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.cache.IWorldProvider;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import baritone.api.event.listener.IEventBus;
|
||||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.IBuilderProcess;
|
||||
import baritone.api.process.ICustomGoalProcess;
|
||||
import baritone.api.process.IExploreProcess;
|
||||
import baritone.api.process.IFarmProcess;
|
||||
import baritone.api.process.IFollowProcess;
|
||||
import baritone.api.process.IGetToBlockProcess;
|
||||
import baritone.api.process.IMineProcess;
|
||||
import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.api.utils.IInputOverrideHandler;
|
||||
|
||||
public interface IBaritone {
|
||||
IMineProcess getMineProcess();
|
||||
|
||||
ICommandManager getCommandManager();
|
||||
|
||||
IEventBus getGameEventHandler();
|
||||
|
||||
IBuilderProcess getBuilderProcess();
|
||||
|
||||
IWorldProvider getWorldProvider();
|
||||
|
||||
ICustomGoalProcess getCustomGoalProcess();
|
||||
|
||||
IGetToBlockProcess getGetToBlockProcess();
|
||||
|
||||
IFarmProcess getFarmProcess();
|
||||
|
||||
IExploreProcess getExploreProcess();
|
||||
|
||||
IInputOverrideHandler getInputOverrideHandler();
|
||||
|
||||
IPathingControlManager getPathingControlManager();
|
||||
|
||||
ISelectionManager getSelectionManager();
|
||||
|
||||
IPlayerContext getPlayerContext();
|
||||
|
||||
ILookBehavior getLookBehavior();
|
||||
|
||||
IPathingBehavior getPathingBehavior();
|
||||
|
||||
void openClick();
|
||||
|
||||
IFollowProcess getFollowProcess();
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package baritone.api;
|
||||
|
||||
import baritone.api.command.ICommandSystem;
|
||||
import baritone.api.schematic.ISchematicSystem;
|
||||
import baritone.api.cache.IWorldScanner;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
|
||||
public interface IBaritoneProvider {
|
||||
default IBaritone getBaritoneForMinecraft(Minecraft mc) {
|
||||
for (IBaritone baritone : (Iterable<IBaritone>)(this.getAllBaritones())) {
|
||||
if (Objects.equals(mc, baritone.getPlayerContext().getMc())) {
|
||||
return baritone;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean destroyBaritone(IBaritone baritone);
|
||||
|
||||
IWorldScanner getInstance3();
|
||||
|
||||
default IBaritone getBaritoneForPlayer(EntityPlayerSP player) {
|
||||
for (IBaritone baritone : (Iterable<IBaritone>)(this.getAllBaritones())) {
|
||||
if (Objects.equals(player, baritone.getPlayerContext().player())) {
|
||||
return baritone;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
ICommandSystem getInstance2();
|
||||
|
||||
IBaritone getPrimaryBaritone();
|
||||
|
||||
List getAllBaritones();
|
||||
|
||||
ISchematicSystem getInstance();
|
||||
|
||||
default IBaritone getBaritoneForConnection(NetHandlerPlayClient netHandlerPlayClient) {
|
||||
for (IBaritone baritone : (Iterable<IBaritone>)(this.getAllBaritones())) {
|
||||
EntityPlayerSP player = baritone.getPlayerContext().player();
|
||||
if (player != null && player.sendQueue == netHandlerPlayClient) {
|
||||
return baritone;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
IBaritone createBaritone(Minecraft mc);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package baritone.api;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface JavaOnly {
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
package baritone.api;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import java.lang.reflect.Type;
|
||||
import baritone.api.utils.NotificationHelper;
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.Vec3i;
|
||||
|
||||
public final class Settings {
|
||||
public final Settings.Setting allowBreak = new Settings.Setting(this, "allowBreak", true, false);
|
||||
public final Settings.Setting allowBreakAnyway = new Settings.Setting(this, "allowBreakAnyway", new ArrayList(), false);
|
||||
public final Settings.Setting allowSprint = new Settings.Setting(this, "allowSprint", true, false);
|
||||
public final Settings.Setting allowPlace = new Settings.Setting(this, "allowPlace", true, false);
|
||||
public final Settings.Setting allowInventory = new Settings.Setting(this, "allowInventory", false, false);
|
||||
public final Settings.Setting ticksBetweenInventoryMoves = new Settings.Setting(this, "ticksBetweenInventoryMoves", 1, false);
|
||||
public final Settings.Setting inventoryMoveOnlyIfStationary = new Settings.Setting(this, "inventoryMoveOnlyIfStationary", false, false);
|
||||
public final Settings.Setting assumeExternalAutoTool = new Settings.Setting(this, "assumeExternalAutoTool", false, false);
|
||||
public final Settings.Setting autoTool = new Settings.Setting(this, "autoTool", true, false);
|
||||
public final Settings.Setting blockPlacementPenalty = new Settings.Setting(this, "blockPlacementPenalty", 20.0, false);
|
||||
public final Settings.Setting blockBreakAdditionalPenalty = new Settings.Setting(this, "blockBreakAdditionalPenalty", 2.0, false);
|
||||
public final Settings.Setting jumpPenalty = new Settings.Setting(this, "jumpPenalty", 2.0, false);
|
||||
public final Settings.Setting walkOnWaterOnePenalty = new Settings.Setting(this, "walkOnWaterOnePenalty", 3.0, false);
|
||||
public final Settings.Setting strictLiquidCheck = new Settings.Setting(this, "strictLiquidCheck", false, false);
|
||||
public final Settings.Setting allowWaterBucketFall = new Settings.Setting(this, "allowWaterBucketFall", true, false);
|
||||
public final Settings.Setting assumeWalkOnWater = new Settings.Setting(this, "assumeWalkOnWater", false, false);
|
||||
public final Settings.Setting assumeWalkOnLava = new Settings.Setting(this, "assumeWalkOnLava", false, false);
|
||||
public final Settings.Setting assumeStep = new Settings.Setting(this, "assumeStep", false, false);
|
||||
public final Settings.Setting assumeSafeWalk = new Settings.Setting(this, "assumeSafeWalk", false, false);
|
||||
public final Settings.Setting allowJumpAt256 = new Settings.Setting(this, "allowJumpAt256", false, false);
|
||||
public final Settings.Setting allowParkourAscend = new Settings.Setting(this, "allowParkourAscend", true, false);
|
||||
public final Settings.Setting allowDiagonalDescend = new Settings.Setting(this, "allowDiagonalDescend", false, false);
|
||||
public final Settings.Setting allowDiagonalAscend = new Settings.Setting(this, "allowDiagonalAscend", false, false);
|
||||
public final Settings.Setting allowDownward = new Settings.Setting(this, "allowDownward", true, false);
|
||||
public final Settings.Setting acceptableThrowawayItems = new Settings.Setting(
|
||||
this,
|
||||
"acceptableThrowawayItems",
|
||||
new ArrayList<>(
|
||||
Arrays.asList(
|
||||
Item.getItemFromBlock(Blocks.dirt),
|
||||
Item.getItemFromBlock(Blocks.cobblestone),
|
||||
Item.getItemFromBlock(Blocks.netherrack),
|
||||
Item.getItemFromBlock(Blocks.stone)
|
||||
)
|
||||
),
|
||||
false
|
||||
);
|
||||
public final Settings.Setting blocksToAvoid = new Settings.Setting(this, "blocksToAvoid", new ArrayList(), false);
|
||||
public final Settings.Setting blocksToDisallowBreaking = new Settings.Setting(this, "blocksToDisallowBreaking", new ArrayList(), false);
|
||||
public final Settings.Setting blocksToAvoidBreaking = new Settings.Setting(
|
||||
this,
|
||||
"blocksToAvoidBreaking",
|
||||
new ArrayList<>(
|
||||
Arrays.asList(Blocks.crafting_table, Blocks.furnace, Blocks.lit_furnace, Blocks.chest, Blocks.trapped_chest, Blocks.standing_sign, Blocks.wall_sign)
|
||||
),
|
||||
false
|
||||
);
|
||||
public final Settings.Setting avoidBreakingMultiplier = new Settings.Setting(this, "avoidBreakingMultiplier", 0.1, false);
|
||||
public final Settings.Setting buildIgnoreBlocks = new Settings.Setting(this, "buildIgnoreBlocks", new ArrayList(), false);
|
||||
public final Settings.Setting buildSkipBlocks = new Settings.Setting(this, "buildSkipBlocks", new ArrayList(), false);
|
||||
public final Settings.Setting buildValidSubstitutes = new Settings.Setting(this, "buildValidSubstitutes", new HashMap(), false);
|
||||
public final Settings.Setting buildSubstitutes = new Settings.Setting(this, "buildSubstitutes", new HashMap(), false);
|
||||
public final Settings.Setting okIfAir = new Settings.Setting(this, "okIfAir", new ArrayList(), false);
|
||||
public final Settings.Setting buildIgnoreExisting = new Settings.Setting(this, "buildIgnoreExisting", false, false);
|
||||
public final Settings.Setting buildIgnoreDirection = new Settings.Setting(this, "buildIgnoreDirection", false, false);
|
||||
public final Settings.Setting buildIgnoreProperties = new Settings.Setting(this, "buildIgnoreProperties", new ArrayList(), false);
|
||||
public final Settings.Setting avoidUpdatingFallingBlocks = new Settings.Setting(this, "avoidUpdatingFallingBlocks", true, false);
|
||||
public final Settings.Setting allowVines = new Settings.Setting(this, "allowVines", false, false);
|
||||
public final Settings.Setting allowWalkOnBottomSlab = new Settings.Setting(this, "allowWalkOnBottomSlab", true, false);
|
||||
public final Settings.Setting allowParkour = new Settings.Setting(this, "allowParkour", false, false);
|
||||
public final Settings.Setting allowParkourPlace = new Settings.Setting(this, "allowParkourPlace", false, false);
|
||||
public final Settings.Setting considerPotionEffects = new Settings.Setting(this, "considerPotionEffects", true, false);
|
||||
public final Settings.Setting sprintAscends = new Settings.Setting(this, "sprintAscends", true, false);
|
||||
public final Settings.Setting overshootTraverse = new Settings.Setting(this, "overshootTraverse", true, false);
|
||||
public final Settings.Setting pauseMiningForFallingBlocks = new Settings.Setting(this, "pauseMiningForFallingBlocks", true, false);
|
||||
public final Settings.Setting rightClickSpeed = new Settings.Setting(this, "rightClickSpeed", 4, false);
|
||||
public final Settings.Setting blockReachDistance = new Settings.Setting(this, "blockReachDistance", 4.5F, false);
|
||||
public final Settings.Setting randomLooking = new Settings.Setting(this, "randomLooking", 0.01, false);
|
||||
public final Settings.Setting costHeuristic = new Settings.Setting(this, "costHeuristic", 3.563, false);
|
||||
public final Settings.Setting pathingMaxChunkBorderFetch = new Settings.Setting(this, "pathingMaxChunkBorderFetch", 50, false);
|
||||
public final Settings.Setting backtrackCostFavoringCoefficient = new Settings.Setting(this, "backtrackCostFavoringCoefficient", 0.5, false);
|
||||
public final Settings.Setting avoidance = new Settings.Setting(this, "avoidance", false, false);
|
||||
public final Settings.Setting mobSpawnerAvoidanceCoefficient = new Settings.Setting(this, "mobSpawnerAvoidanceCoefficient", 2.0, false);
|
||||
public final Settings.Setting mobSpawnerAvoidanceRadius = new Settings.Setting(this, "mobSpawnerAvoidanceRadius", 16, false);
|
||||
public final Settings.Setting mobAvoidanceCoefficient = new Settings.Setting(this, "mobAvoidanceCoefficient", 1.5, false);
|
||||
public final Settings.Setting mobAvoidanceRadius = new Settings.Setting(this, "mobAvoidanceRadius", 8, false);
|
||||
public final Settings.Setting rightClickContainerOnArrival = new Settings.Setting(this, "rightClickContainerOnArrival", true, false);
|
||||
public final Settings.Setting enterPortal = new Settings.Setting(this, "enterPortal", true, false);
|
||||
public final Settings.Setting minimumImprovementRepropagation = new Settings.Setting(this, "minimumImprovementRepropagation", true, false);
|
||||
public final Settings.Setting cutoffAtLoadBoundary = new Settings.Setting(this, "cutoffAtLoadBoundary", false, false);
|
||||
public final Settings.Setting maxCostIncrease = new Settings.Setting(this, "maxCostIncrease", 10.0, false);
|
||||
public final Settings.Setting costVerificationLookahead = new Settings.Setting(this, "costVerificationLookahead", 5, false);
|
||||
public final Settings.Setting pathCutoffFactor = new Settings.Setting(this, "pathCutoffFactor", 0.9, false);
|
||||
public final Settings.Setting pathCutoffMinimumLength = new Settings.Setting(this, "pathCutoffMinimumLength", 30, false);
|
||||
public final Settings.Setting planningTickLookahead = new Settings.Setting(this, "planningTickLookahead", 150, false);
|
||||
public final Settings.Setting pathingMapDefaultSize = new Settings.Setting(this, "pathingMapDefaultSize", 1024, false);
|
||||
public final Settings.Setting pathingMapLoadFactor = new Settings.Setting(this, "pathingMapLoadFactor", 0.75F, false);
|
||||
public final Settings.Setting maxFallHeightNoWater = new Settings.Setting(this, "maxFallHeightNoWater", 3, false);
|
||||
public final Settings.Setting maxFallHeightBucket = new Settings.Setting(this, "maxFallHeightBucket", 20, false);
|
||||
public final Settings.Setting allowOvershootDiagonalDescend = new Settings.Setting(this, "allowOvershootDiagonalDescend", true, false);
|
||||
public final Settings.Setting simplifyUnloadedYCoord = new Settings.Setting(this, "simplifyUnloadedYCoord", true, false);
|
||||
public final Settings.Setting repackOnAnyBlockChange = new Settings.Setting(this, "repackOnAnyBlockChange", true, false);
|
||||
public final Settings.Setting movementTimeoutTicks = new Settings.Setting(this, "movementTimeoutTicks", 100, false);
|
||||
public final Settings.Setting primaryTimeoutMS = new Settings.Setting(this, "primaryTimeoutMS", 500L, false);
|
||||
public final Settings.Setting failureTimeoutMS = new Settings.Setting(this, "failureTimeoutMS", 2000L, false);
|
||||
public final Settings.Setting planAheadPrimaryTimeoutMS = new Settings.Setting(this, "planAheadPrimaryTimeoutMS", 4000L, false);
|
||||
public final Settings.Setting planAheadFailureTimeoutMS = new Settings.Setting(this, "planAheadFailureTimeoutMS", 5000L, false);
|
||||
public final Settings.Setting slowPath = new Settings.Setting(this, "slowPath", false, false);
|
||||
public final Settings.Setting slowPathTimeDelayMS = new Settings.Setting(this, "slowPathTimeDelayMS", 100L, false);
|
||||
public final Settings.Setting slowPathTimeoutMS = new Settings.Setting(this, "slowPathTimeoutMS", 40000L, false);
|
||||
public final Settings.Setting doBedWaypoints = new Settings.Setting(this, "doBedWaypoints", true, false);
|
||||
public final Settings.Setting doDeathWaypoints = new Settings.Setting(this, "doDeathWaypoints", true, false);
|
||||
public final Settings.Setting chunkCaching = new Settings.Setting(this, "chunkCaching", true, false);
|
||||
public final Settings.Setting pruneRegionsFromRAM = new Settings.Setting(this, "pruneRegionsFromRAM", true, false);
|
||||
public final Settings.Setting chunkPackerQueueMaxSize = new Settings.Setting(this, "chunkPackerQueueMaxSize", 2000, false);
|
||||
public final Settings.Setting backfill = new Settings.Setting(this, "backfill", false, false);
|
||||
public final Settings.Setting logAsToast = new Settings.Setting(this, "logAsToast", false, false);
|
||||
public final Settings.Setting toastTimer = new Settings.Setting(this, "toastTimer", 5000L, false);
|
||||
public final Settings.Setting chatDebug = new Settings.Setting(this, "chatDebug", false, false);
|
||||
public final Settings.Setting chatControl = new Settings.Setting(this, "chatControl", true, false);
|
||||
public final Settings.Setting chatControlAnyway = new Settings.Setting(this, "chatControlAnyway", false, false);
|
||||
public final Settings.Setting renderPath = new Settings.Setting(this, "renderPath", true, false);
|
||||
public final Settings.Setting renderPathAsLine = new Settings.Setting(this, "renderPathAsLine", false, false);
|
||||
public final Settings.Setting renderGoal = new Settings.Setting(this, "renderGoal", true, false);
|
||||
public final Settings.Setting renderGoalAnimated = new Settings.Setting(this, "renderGoalAnimated", true, false);
|
||||
public final Settings.Setting renderSelectionBoxes = new Settings.Setting(this, "renderSelectionBoxes", true, false);
|
||||
public final Settings.Setting renderGoalIgnoreDepth = new Settings.Setting(this, "renderGoalIgnoreDepth", true, false);
|
||||
public final Settings.Setting renderGoalXZBeacon = new Settings.Setting(this, "renderGoalXZBeacon", false, false);
|
||||
public final Settings.Setting renderSelectionBoxesIgnoreDepth = new Settings.Setting(this, "renderSelectionBoxesIgnoreDepth", true, false);
|
||||
public final Settings.Setting renderPathIgnoreDepth = new Settings.Setting(this, "renderPathIgnoreDepth", true, false);
|
||||
public final Settings.Setting pathRenderLineWidthPixels = new Settings.Setting(this, "pathRenderLineWidthPixels", 5.0F, false);
|
||||
public final Settings.Setting goalRenderLineWidthPixels = new Settings.Setting(this, "goalRenderLineWidthPixels", 3.0F, false);
|
||||
public final Settings.Setting fadePath = new Settings.Setting(this, "fadePath", false, false);
|
||||
public final Settings.Setting freeLook = new Settings.Setting(this, "freeLook", true, false);
|
||||
public final Settings.Setting blockFreeLook = new Settings.Setting(this, "blockFreeLook", false, false);
|
||||
public final Settings.Setting antiCheatCompatibility = new Settings.Setting(this, "antiCheatCompatibility", true, false);
|
||||
public final Settings.Setting pathThroughCachedOnly = new Settings.Setting(this, "pathThroughCachedOnly", false, false);
|
||||
public final Settings.Setting sprintInWater = new Settings.Setting(this, "sprintInWater", true, false);
|
||||
public final Settings.Setting blacklistClosestOnFailure = new Settings.Setting(this, "blacklistClosestOnFailure", true, false);
|
||||
public final Settings.Setting renderCachedChunks = new Settings.Setting(this, "renderCachedChunks", false, false);
|
||||
public final Settings.Setting cachedChunksOpacity = new Settings.Setting(this, "cachedChunksOpacity", 0.5F, false);
|
||||
public final Settings.Setting prefixControl = new Settings.Setting(this, "prefixControl", true, false);
|
||||
public final Settings.Setting prefix = new Settings.Setting(this, "prefix", "#", false);
|
||||
public final Settings.Setting shortBaritonePrefix = new Settings.Setting(this, "shortBaritonePrefix", false, false);
|
||||
public final Settings.Setting echoCommands = new Settings.Setting(this, "echoCommands", true, false);
|
||||
public final Settings.Setting censorCoordinates = new Settings.Setting(this, "censorCoordinates", false, false);
|
||||
public final Settings.Setting censorRanCommands = new Settings.Setting(this, "censorRanCommands", false, false);
|
||||
public final Settings.Setting itemSaver = new Settings.Setting(this, "itemSaver", false, false);
|
||||
public final Settings.Setting itemSaverThreshold = new Settings.Setting(this, "itemSaverThreshold", 10);
|
||||
public final Settings.Setting preferSilkTouch = new Settings.Setting(this, "preferSilkTouch", false);
|
||||
public final Settings.Setting walkWhileBreaking = new Settings.Setting(this, "walkWhileBreaking", true);
|
||||
public final Settings.Setting splicePath = new Settings.Setting(this, "splicePath", true);
|
||||
public final Settings.Setting maxPathHistoryLength = new Settings.Setting(this, "maxPathHistoryLength", 300);
|
||||
public final Settings.Setting pathHistoryCutoffAmount = new Settings.Setting(this, "pathHistoryCutoffAmount", 50);
|
||||
public final Settings.Setting mineGoalUpdateInterval = new Settings.Setting(this, "mineGoalUpdateInterval", 5);
|
||||
public final Settings.Setting maxCachedWorldScanCount = new Settings.Setting(this, "maxCachedWorldScanCount", 10);
|
||||
public final Settings.Setting minYLevelWhileMining = new Settings.Setting(this, "minYLevelWhileMining", 0);
|
||||
public final Settings.Setting maxYLevelWhileMining = new Settings.Setting(this, "maxYLevelWhileMining", 255);
|
||||
public final Settings.Setting allowOnlyExposedOres = new Settings.Setting(this, "allowOnlyExposedOres", false);
|
||||
public final Settings.Setting allowOnlyExposedOresDistance = new Settings.Setting(this, "allowOnlyExposedOresDistance", 1);
|
||||
public final Settings.Setting exploreForBlocks = new Settings.Setting(this, "exploreForBlocks", true);
|
||||
public final Settings.Setting worldExploringChunkOffset = new Settings.Setting(this, "worldExploringChunkOffset", 0);
|
||||
public final Settings.Setting exploreChunkSetMinimumSize = new Settings.Setting(this, "exploreChunkSetMinimumSize", 10);
|
||||
public final Settings.Setting exploreMaintainY = new Settings.Setting(this, "exploreMaintainY", 64);
|
||||
public final Settings.Setting replantCrops = new Settings.Setting(this, "replantCrops", true);
|
||||
public final Settings.Setting replantNetherWart = new Settings.Setting(this, "replantNetherWart", false);
|
||||
public final Settings.Setting extendCacheOnThreshold = new Settings.Setting(this, "extendCacheOnThreshold", false);
|
||||
public final Settings.Setting buildInLayers = new Settings.Setting(this, "buildInLayers", false);
|
||||
public final Settings.Setting layerOrder = new Settings.Setting(this, "layerOrder", false);
|
||||
public final Settings.Setting layerHeight = new Settings.Setting(this, "layerHeight", 1);
|
||||
public final Settings.Setting startAtLayer = new Settings.Setting(this, "startAtLayer", 0);
|
||||
public final Settings.Setting skipFailedLayers = new Settings.Setting(this, "skipFailedLayers", false);
|
||||
public final Settings.Setting buildOnlySelection = new Settings.Setting(this, "buildOnlySelection", false);
|
||||
public final Settings.Setting buildRepeat = new Settings.Setting(this, "buildRepeat", new Vec3i(0, 0, 0));
|
||||
public final Settings.Setting buildRepeatCount = new Settings.Setting(this, "buildRepeatCount", -1);
|
||||
public final Settings.Setting buildRepeatSneaky = new Settings.Setting(this, "buildRepeatSneaky", true);
|
||||
public final Settings.Setting breakFromAbove = new Settings.Setting(this, "breakFromAbove", false);
|
||||
public final Settings.Setting goalBreakFromAbove = new Settings.Setting(this, "goalBreakFromAbove", false);
|
||||
public final Settings.Setting mapArtMode = new Settings.Setting(this, "mapArtMode", false);
|
||||
public final Settings.Setting okIfWater = new Settings.Setting(this, "okIfWater", false);
|
||||
public final Settings.Setting incorrectSize = new Settings.Setting(this, "incorrectSize", 100);
|
||||
public final Settings.Setting breakCorrectBlockPenaltyMultiplier = new Settings.Setting(this, "breakCorrectBlockPenaltyMultiplier", 10.0);
|
||||
public final Settings.Setting schematicOrientationX = new Settings.Setting(this, "schematicOrientationX", false);
|
||||
public final Settings.Setting schematicOrientationY = new Settings.Setting(this, "schematicOrientationY", false);
|
||||
public final Settings.Setting schematicOrientationZ = new Settings.Setting(this, "schematicOrientationZ", false);
|
||||
public final Settings.Setting schematicFallbackExtension = new Settings.Setting(this, "schematicFallbackExtension", "schematic");
|
||||
public final Settings.Setting builderTickScanRadius = new Settings.Setting(this, "builderTickScanRadius", 5);
|
||||
public final Settings.Setting mineScanDroppedItems = new Settings.Setting(this, "mineScanDroppedItems", true);
|
||||
public final Settings.Setting mineDropLoiterDurationMSThanksLouca = new Settings.Setting(this, "mineDropLoiterDurationMSThanksLouca", 250L);
|
||||
public final Settings.Setting distanceTrim = new Settings.Setting(this, "distanceTrim", true);
|
||||
public final Settings.Setting cancelOnGoalInvalidation = new Settings.Setting(this, "cancelOnGoalInvalidation", true);
|
||||
public final Settings.Setting axisHeight = new Settings.Setting(this, "axisHeight", 120);
|
||||
public final Settings.Setting disconnectOnArrival = new Settings.Setting(this, "disconnectOnArrival", false);
|
||||
public final Settings.Setting legitMine = new Settings.Setting(this, "legitMine", false);
|
||||
public final Settings.Setting legitMineYLevel = new Settings.Setting(this, "legitMineYLevel", 11);
|
||||
public final Settings.Setting legitMineIncludeDiagonals = new Settings.Setting(this, "legitMineIncludeDiagonals", false);
|
||||
public final Settings.Setting forceInternalMining = new Settings.Setting(this, "forceInternalMining", true);
|
||||
public final Settings.Setting internalMiningAirException = new Settings.Setting(this, "internalMiningAirException", true);
|
||||
public final Settings.Setting followOffsetDistance = new Settings.Setting(this, "followOffsetDistance", 0.0);
|
||||
public final Settings.Setting followOffsetDirection = new Settings.Setting(this, "followOffsetDirection", 0.0F);
|
||||
public final Settings.Setting followRadius = new Settings.Setting(this, "followRadius", 3);
|
||||
public final Settings.Setting disableCompletionCheck = new Settings.Setting(this, "disableCompletionCheck", false);
|
||||
public final Settings.Setting cachedChunksExpirySeconds = new Settings.Setting(this, "cachedChunksExpirySeconds", -1L);
|
||||
@JavaOnly
|
||||
public final Settings.Setting logger = new Settings.Setting(
|
||||
this, "logger", (Consumer<IChatComponent>)component -> Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(component), true
|
||||
);
|
||||
@JavaOnly
|
||||
public final Settings.Setting notifier = new Settings.Setting(this, "notifier", (BiConsumer<String, Boolean>)NotificationHelper::notify, true);
|
||||
public final Settings.Setting yLevelBoxSize = new Settings.Setting(this, "yLevelBoxSize", 15.0);
|
||||
public final Settings.Setting colorCurrentPath = new Settings.Setting(this, "colorCurrentPath", Color.RED);
|
||||
public final Settings.Setting colorNextPath = new Settings.Setting(this, "colorNextPath", Color.MAGENTA);
|
||||
public final Settings.Setting colorBlocksToBreak = new Settings.Setting(this, "colorBlocksToBreak", Color.RED);
|
||||
public final Settings.Setting colorBlocksToPlace = new Settings.Setting(this, "colorBlocksToPlace", Color.GREEN);
|
||||
public final Settings.Setting colorBlocksToWalkInto = new Settings.Setting(this, "colorBlocksToWalkInto", Color.MAGENTA);
|
||||
public final Settings.Setting colorBestPathSoFar = new Settings.Setting(this, "colorBestPathSoFar", Color.BLUE);
|
||||
public final Settings.Setting colorMostRecentConsidered = new Settings.Setting(this, "colorMostRecentConsidered", Color.CYAN);
|
||||
public final Settings.Setting colorGoalBox = new Settings.Setting(this, "colorGoalBox", Color.GREEN);
|
||||
public final Settings.Setting colorInvertedGoalBox = new Settings.Setting(this, "colorInvertedGoalBox", Color.RED);
|
||||
public final Settings.Setting colorSelection = new Settings.Setting(this, "colorSelection", Color.CYAN);
|
||||
public final Settings.Setting colorSelectionPos1 = new Settings.Setting(this, "colorSelectionPos1", Color.BLACK);
|
||||
public final Settings.Setting colorSelectionPos2 = new Settings.Setting(this, "colorSelectionPos2", Color.ORANGE);
|
||||
public final Settings.Setting selectionOpacity = new Settings.Setting(this, "selectionOpacity", 0.5F);
|
||||
public final Settings.Setting selectionLineWidth = new Settings.Setting(this, "selectionLineWidth", 2.0F);
|
||||
public final Settings.Setting renderSelection = new Settings.Setting(this, "renderSelection", true);
|
||||
public final Settings.Setting renderSelectionIgnoreDepth = new Settings.Setting(this, "renderSelectionIgnoreDepth", true);
|
||||
public final Settings.Setting renderSelectionCorners = new Settings.Setting(this, "renderSelectionCorners", true);
|
||||
public final Settings.Setting useSwordToMine = new Settings.Setting(this, "useSwordToMine", true);
|
||||
public final Settings.Setting desktopNotifications = new Settings.Setting(this, "desktopNotifications", false);
|
||||
public final Settings.Setting notificationOnPathComplete = new Settings.Setting(this, "notificationOnPathComplete", true);
|
||||
public final Settings.Setting notificationOnFarmFail = new Settings.Setting(this, "notificationOnFarmFail", true);
|
||||
public final Settings.Setting notificationOnBuildFinished = new Settings.Setting(this, "notificationOnBuildFinished", true);
|
||||
public final Settings.Setting notificationOnExploreFinished = new Settings.Setting(this, "notificationOnExploreFinished", true);
|
||||
public final Settings.Setting notificationOnMineFail = new Settings.Setting(this, "notificationOnMineFail", true);
|
||||
public final Map byLowerName;
|
||||
public final List<Settings.Setting> allSettings;
|
||||
public final Map settingTypes;
|
||||
|
||||
public List<Settings.Setting> getAllValuesByType(Class clazz) {
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
for (Settings.Setting setting : (Iterable<Settings.Setting>)(this.allSettings)) {
|
||||
if (setting.getValueClass().equals(clazz)) {
|
||||
list.add(setting);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public Settings(SettingsRegistry settingsRegistry) {
|
||||
this.byLowerName = Collections.unmodifiableMap(settingsRegistry.byLowerName);
|
||||
this.allSettings = Collections.unmodifiableList(settingsRegistry.allSettings);
|
||||
this.settingTypes = Collections.unmodifiableMap(settingsRegistry.settingTypes);
|
||||
}
|
||||
|
||||
|
||||
public static final class Setting {
|
||||
public Object value;
|
||||
public final Object defaultValue;
|
||||
private String name;
|
||||
private boolean javaOnly;
|
||||
public final Settings settings;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Setting(Settings settings2, String str, Object obj, boolean flag) {
|
||||
this.settings = settings2;
|
||||
this.name = str;
|
||||
this.value = obj;
|
||||
this.defaultValue = obj;
|
||||
this.javaOnly = flag;
|
||||
this.register();
|
||||
}
|
||||
|
||||
public Class getValueClass() {
|
||||
return this.value.getClass();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.value = this.defaultValue;
|
||||
}
|
||||
|
||||
public Setting(Settings settings2, String str, Object obj) {
|
||||
this.settings = settings2;
|
||||
this.name = str;
|
||||
this.value = obj;
|
||||
this.defaultValue = obj;
|
||||
this.javaOnly = false;
|
||||
this.register();
|
||||
}
|
||||
|
||||
public boolean isJavaOnly() {
|
||||
return this.javaOnly;
|
||||
}
|
||||
|
||||
private void register() {
|
||||
BaritoneAPI.getSettingsRegistry().allSettings.add(this);
|
||||
BaritoneAPI.getSettingsRegistry().byLowerName.put(this.name.toLowerCase(), this);
|
||||
BaritoneAPI.getSettingsRegistry().settingTypes.put(this, this.value.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return SettingsUtil.settingToString(this);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return (Type)this.settings.settingTypes.get(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package baritone.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SettingsRegistry {
|
||||
public final Map byLowerName = new HashMap();
|
||||
public final List allSettings = new ArrayList();
|
||||
public final Map settingTypes = new HashMap();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package baritone.api.behavior;
|
||||
|
||||
import baritone.api.event.listener.AbstractGameEventListener;
|
||||
|
||||
public interface IBehavior extends AbstractGameEventListener {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package baritone.api.behavior;
|
||||
|
||||
import baritone.api.utils.Rotation;
|
||||
import baritone.api.behavior.look.IAimProcessor;
|
||||
|
||||
public interface ILookBehavior extends IBehavior {
|
||||
IAimProcessor getAimProcessor();
|
||||
|
||||
void updateTarget(Rotation rotation, boolean flag);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package baritone.api.behavior;
|
||||
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.path.IPathExecutor;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface IPathingBehavior extends IBehavior {
|
||||
Optional estimatedTicksToGoal();
|
||||
|
||||
Optional getInProgress();
|
||||
|
||||
default Optional ticksRemainingInSegment(boolean flag) {
|
||||
IPathExecutor current = this.getCurrent();
|
||||
if (current == null) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
int n = flag ? current.getPosition() : current.getPosition() + 1;
|
||||
return Optional.of(current.getPath().ticksRemainingFrom(n));
|
||||
}
|
||||
}
|
||||
|
||||
boolean isPathing();
|
||||
|
||||
IPathExecutor getNext();
|
||||
|
||||
Goal getGoal();
|
||||
|
||||
IPathExecutor getCurrent();
|
||||
|
||||
default Optional ticksRemainingInSegment() {
|
||||
return this.ticksRemainingInSegment(true);
|
||||
}
|
||||
|
||||
boolean cancelEverything();
|
||||
|
||||
default boolean hasPath() {
|
||||
return this.getCurrent() != null;
|
||||
}
|
||||
|
||||
void forceCancel();
|
||||
|
||||
default Optional getPath() {
|
||||
return Optional.ofNullable(this.getCurrent()).map(IPathExecutor::getPath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package baritone.api.behavior.look;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
public final class ForkableRandom {
|
||||
private static final double DOUBLE_UNIT = 1.110223E-16F;
|
||||
private final long[] state;
|
||||
|
||||
public long next() {
|
||||
long l = rotl(this.state[0] + this.state[3], 23) + this.state[0];
|
||||
long l2 = this.state[1] << 17;
|
||||
this.state[2] = this.state[2] ^ this.state[0];
|
||||
this.state[3] = this.state[3] ^ this.state[1];
|
||||
this.state[1] = this.state[1] ^ this.state[2];
|
||||
this.state[0] = this.state[0] ^ this.state[3];
|
||||
this.state[2] = this.state[2] ^ l2;
|
||||
this.state[3] = rotl(this.state[3], 45);
|
||||
return l;
|
||||
}
|
||||
|
||||
public ForkableRandom fork() {
|
||||
return new ForkableRandom(Arrays.copyOf(this.state, 4));
|
||||
}
|
||||
|
||||
public ForkableRandom(long l) {
|
||||
AtomicLong atomicLong = new AtomicLong(l);
|
||||
LongSupplier longSupplier = () -> {
|
||||
long l2 = atomicLong.addAndGet(-7046029254386353131L);
|
||||
l2 = (l2 ^ l2 >>> 30) * -4658895280553007687L;
|
||||
l2 = (l2 ^ l2 >>> 27) * -7723592293110705685L;
|
||||
return l2 ^ l2 >>> 31;
|
||||
};
|
||||
this.state = new long[]{longSupplier.getAsLong(), longSupplier.getAsLong(), longSupplier.getAsLong(), longSupplier.getAsLong()};
|
||||
}
|
||||
|
||||
private static long rotl(long l, int n) {
|
||||
return l << n | l >>> 64 - n;
|
||||
}
|
||||
|
||||
private ForkableRandom(long[] longs) {
|
||||
this.state = longs;
|
||||
}
|
||||
|
||||
public ForkableRandom() {
|
||||
this(System.nanoTime() ^ System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public double nextDouble() {
|
||||
return (double)(this.next() >>> 11) * 1.110223E-16F;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package baritone.api.behavior.look;
|
||||
|
||||
import baritone.api.utils.Rotation;
|
||||
|
||||
public interface IAimProcessor {
|
||||
ITickableAimProcessor fork();
|
||||
|
||||
Rotation peekRotation(Rotation rotation);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package baritone.api.behavior.look;
|
||||
|
||||
import baritone.api.utils.Rotation;
|
||||
|
||||
public interface ITickableAimProcessor extends IAimProcessor {
|
||||
void tick();
|
||||
|
||||
Rotation nextRotation(Rotation rotation);
|
||||
|
||||
void advance(int n);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package baritone.api.cache;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
public interface IBlockLookup {
|
||||
default IBlockState getBlock(BlockPos pos) {
|
||||
return this.getBlock(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
IBlockState getBlock(int n, int n2, int n3);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package baritone.api.cache;
|
||||
|
||||
|
||||
public interface ICachedRegion extends IBlockLookup {
|
||||
int getZ();
|
||||
|
||||
int getX();
|
||||
|
||||
boolean isCached(int n, int n2);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package baritone.api.cache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
public interface ICachedWorld {
|
||||
void save();
|
||||
|
||||
boolean isCached(int n, int n2);
|
||||
|
||||
ArrayList getLocationsOf(String str, int n, int n2, int n3, int n4);
|
||||
|
||||
void reloadAllFromDisk();
|
||||
|
||||
void queueForPacking(Chunk chunk);
|
||||
|
||||
ICachedRegion getRegion(int n, int n2);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package baritone.api.cache;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
|
||||
public interface IWaypoint {
|
||||
long getCreationTimestamp();
|
||||
|
||||
String getName();
|
||||
|
||||
WaypointTag getTag();
|
||||
|
||||
BetterBlockPos getLocation();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package baritone.api.cache;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface IWaypointCollection {
|
||||
void removeWaypoint(IWaypoint waypoint);
|
||||
|
||||
Set getByTag(WaypointTag waypointTag);
|
||||
|
||||
void addWaypoint(IWaypoint waypoint);
|
||||
|
||||
IWaypoint getMostRecentByTag(WaypointTag waypointTag);
|
||||
|
||||
Set getAllWaypoints();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package baritone.api.cache;
|
||||
|
||||
public interface IWorldData {
|
||||
IWaypointCollection getWaypoints();
|
||||
|
||||
ICachedWorld getCachedWorld();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package baritone.api.cache;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface IWorldProvider {
|
||||
IWorldData getCurrentWorld();
|
||||
|
||||
default void ifWorldLoaded(Consumer consumer) {
|
||||
IWorldData currentWorld = this.getCurrentWorld();
|
||||
if (currentWorld != null) {
|
||||
consumer.accept(currentWorld);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package baritone.api.cache;
|
||||
|
||||
import baritone.utils.ChunkPos;
|
||||
import baritone.api.utils.BlockOptionalMetaLookup;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public interface IWorldScanner {
|
||||
default List scanChunk2(IPlayerContext playerContext, List list, ChunkPos chunkPos, int n, int n2) {
|
||||
return this.scanChunk(playerContext, new BlockOptionalMetaLookup(list), chunkPos, n, n2);
|
||||
}
|
||||
|
||||
int repack(IPlayerContext playerContext);
|
||||
|
||||
default List scanChunkRadius2(IPlayerContext playerContext, List list, int n, int n2, int n3) {
|
||||
return this.scanChunkRadius(playerContext, new BlockOptionalMetaLookup((Block[])list.toArray(new Block[0])), n, n2, n3);
|
||||
}
|
||||
|
||||
List scanChunk(IPlayerContext playerContext, BlockOptionalMetaLookup blockOptionalMetaLookup, ChunkPos chunkPos, int n, int n2);
|
||||
|
||||
List scanChunkRadius(IPlayerContext playerContext, BlockOptionalMetaLookup blockOptionalMetaLookup, int n, int n2, int n3);
|
||||
|
||||
int repack(IPlayerContext playerContext, int n);
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package baritone.api.cache;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import java.util.Date;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
public class Waypoint implements IWaypoint {
|
||||
private final String name;
|
||||
private final WaypointTag tag;
|
||||
private final long timestamp;
|
||||
private final BetterBlockPos location;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode() ^ this.tag.hashCode() ^ this.location.hashCode() ^ Long.hashCode(this.timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaypointTag getTag() {
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
} else if (!(obj instanceof IWaypoint)) {
|
||||
return false;
|
||||
} else {
|
||||
IWaypoint waypoint = (IWaypoint)obj;
|
||||
return this.name.equals(waypoint.getName()) && this.tag == waypoint.getTag() && this.location.equals(waypoint.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
public Waypoint(String str, WaypointTag waypointTag, BetterBlockPos betterBlockPos, long l) {
|
||||
this.name = str;
|
||||
this.tag = waypointTag;
|
||||
this.location = betterBlockPos;
|
||||
this.timestamp = l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s %s %s", this.name, BetterBlockPos.from((BlockPos)this.location).toString(), new Date(this.timestamp).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BetterBlockPos getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTimestamp() {
|
||||
return this.timestamp;
|
||||
}
|
||||
|
||||
public Waypoint(String str, WaypointTag waypointTag, BetterBlockPos betterBlockPos) {
|
||||
this(str, waypointTag, betterBlockPos, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package baritone.api.cache;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public enum WaypointTag {
|
||||
HOME(new String[]{"home", "base"}),
|
||||
DEATH(new String[]{"death"}),
|
||||
BED(new String[]{"bed", "spawn"}),
|
||||
USER(new String[]{"user"});
|
||||
|
||||
private static final List VALUES = Collections.unmodifiableList(Arrays.asList(values()));
|
||||
public final String[] names;
|
||||
public static String[] getAllNames() {
|
||||
HashSet set = new HashSet();
|
||||
|
||||
for (WaypointTag waypointTag : values()) {
|
||||
set.addAll(Arrays.asList(waypointTag.names));
|
||||
}
|
||||
|
||||
return (String[])set.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.names[0];
|
||||
}
|
||||
|
||||
public static WaypointTag getByName(String str) {
|
||||
for (WaypointTag waypointTag : values()) {
|
||||
for (String str2 : waypointTag.names) {
|
||||
if (str2.equalsIgnoreCase(str)) {
|
||||
return waypointTag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private WaypointTag(String[] strings) {
|
||||
this.names = strings;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package baritone.api.command;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public abstract class Command implements ICommand {
|
||||
public IBaritone baritone;
|
||||
public IPlayerContext ctx;
|
||||
public final List names;
|
||||
|
||||
@Override
|
||||
public final List getNames() {
|
||||
return this.names;
|
||||
}
|
||||
|
||||
public Command(IBaritone baritone2, String[] strings) {
|
||||
this.names = Collections.unmodifiableList(Stream.of(strings).map(str -> str.toLowerCase(Locale.US)).collect(Collectors.toList()));
|
||||
this.baritone = baritone2;
|
||||
this.ctx = baritone2.getPlayerContext();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package baritone.api.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface IBaritoneChatControl {
|
||||
String FORCE_COMMAND_PREFIX = String.format("<<%s>>", UUID.randomUUID().toString());
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package baritone.api.command;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface ICommand extends Helper {
|
||||
String getShortDesc();
|
||||
|
||||
Stream tabComplete(String str, IArgConsumer argConsumer) throws CommandException;
|
||||
|
||||
default boolean hiddenFromHelp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void execute(String str, IArgConsumer argConsumer) throws CommandException;
|
||||
|
||||
List getNames();
|
||||
|
||||
List getLongDesc();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package baritone.api.command;
|
||||
|
||||
import baritone.api.command.argparser.IArgParserManager;
|
||||
|
||||
public interface ICommandSystem {
|
||||
IArgParserManager getInstance();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package baritone.api.command.argparser;
|
||||
|
||||
public interface IArgParser {
|
||||
Class getTarget();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package baritone.api.command.argparser;
|
||||
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.registry.Registry;
|
||||
|
||||
public interface IArgParserManager {
|
||||
Object parseStateless(Class clazz, ICommandArgument commandArgument) throws CommandInvalidTypeException;
|
||||
|
||||
Registry getRegistry();
|
||||
|
||||
IStatelessArgParser getParserStateless(Class clazz);
|
||||
|
||||
IStatedArgParser getParserStated(Class clazz, Class clazz2);
|
||||
|
||||
Object parseStated(Class clazz, Class clazz2, ICommandArgument commandArgument, Object obj) throws CommandInvalidTypeException;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package baritone.api.command.argparser;
|
||||
|
||||
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
public interface IStatedArgParser extends IArgParser {
|
||||
Class getStateType();
|
||||
|
||||
Object parseArg(ICommandArgument commandArgument, Object obj) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package baritone.api.command.argparser;
|
||||
|
||||
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
public interface IStatelessArgParser extends IArgParser {
|
||||
Object parseArg(ICommandArgument commandArgument) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package baritone.api.command.argument;
|
||||
|
||||
import baritone.api.command.datatypes.IDatatype;
|
||||
import baritone.api.command.datatypes.IDatatypeFor;
|
||||
import baritone.api.command.datatypes.IDatatypePost;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
|
||||
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface IArgConsumer {
|
||||
LinkedList getArgs();
|
||||
|
||||
Object peekDatatypeOrNull2(IDatatypePost datatypePost);
|
||||
|
||||
Object peekAsOrNull(Class clazz, int n) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
void requireMin(int n) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Object peekAsOrNull(Class clazz) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
ICommandArgument peek(int n) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Object getDatatypeFor(IDatatypeFor datatypeFor) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
boolean hasAny();
|
||||
|
||||
String peekString() throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Enum peekEnumOrNull(Class clazz) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
boolean hasExactly(int n);
|
||||
|
||||
Object peekDatatypeForOrDefault(Class clazz, Object obj);
|
||||
|
||||
Object peekDatatypePostOrDefault(IDatatypePost datatypePost, Object obj, Object obj2);
|
||||
|
||||
String consumedString();
|
||||
|
||||
boolean is(Class clazz, int n) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Object getDatatypePost(IDatatypePost datatypePost, Object obj) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
boolean is(Class clazz) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Object peekDatatypePostOrNull(IDatatypePost datatypePost, Object obj);
|
||||
|
||||
Enum getEnum(Class clazz) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
ICommandArgument consumed();
|
||||
|
||||
boolean hasConsumed();
|
||||
|
||||
Object getAs(Class clazz) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
Object peekDatatypeForOrNull(Class clazz);
|
||||
|
||||
boolean hasAtMost(int n);
|
||||
|
||||
String rawRest();
|
||||
|
||||
boolean hasExactlyOne();
|
||||
|
||||
Object peekDatatype2(IDatatypeFor datatypeFor) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
Object peekDatatypeOrNull(IDatatypeFor datatypeFor);
|
||||
|
||||
Object getAsOrDefault(Class clazz, Object obj) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
boolean hasAtMostOne();
|
||||
|
||||
Enum peekEnum(Class clazz, int n) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
ICommandArgument get() throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Stream tabCompleteDatatype(IDatatype datatype);
|
||||
|
||||
Object getDatatypeForOrNull(IDatatypeFor datatypeFor);
|
||||
|
||||
Object getDatatypePostOrNull(IDatatypePost datatypePost, Object obj);
|
||||
|
||||
void requireExactly(int n) throws CommandException;
|
||||
|
||||
Object peekDatatypePost(IDatatypePost datatypePost, Object obj) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
void requireMax(int n) throws CommandTooManyArgumentsException;
|
||||
|
||||
Enum peekEnum(Class clazz) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
ICommandArgument peek() throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Object peekAsOrDefault(Class clazz, Object obj) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Enum getEnumOrDefault(Class clazz, Enum obj) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
String getString() throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Object peekDatatypeFor(Class clazz);
|
||||
|
||||
String peekString(int n) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Object peekAs(Class clazz, int n) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
Object peekDatatype(IDatatypePost datatypePost) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
Enum peekEnumOrNull(Class clazz, int n) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Object peekAsOrDefault(Class clazz, Object obj, int n) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Enum getEnumOrNull(Class clazz) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
IArgConsumer copy();
|
||||
|
||||
boolean has(int n);
|
||||
|
||||
Object getDatatypePostOrDefault(IDatatypePost datatypePost, Object obj, Object obj2);
|
||||
|
||||
Object getDatatypeForOrDefault(IDatatypeFor datatypeFor, Object obj);
|
||||
|
||||
Object peekDatatype(IDatatypePost datatypePost, Object obj) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
Deque getConsumed();
|
||||
|
||||
Object getAsOrNull(Class clazz) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
Object peekAs(Class clazz) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package baritone.api.command.argument;
|
||||
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
|
||||
public interface ICommandArgument {
|
||||
boolean is(Class clazz);
|
||||
|
||||
int getIndex();
|
||||
|
||||
String getValue();
|
||||
|
||||
String getRawRest();
|
||||
|
||||
Object getAs(Class clazz) throws CommandInvalidTypeException;
|
||||
|
||||
Object getAs(Class clazz, Class clazz2, Object obj) throws CommandInvalidTypeException;
|
||||
|
||||
boolean is(Class clazz, Class clazz2, Object obj);
|
||||
|
||||
Enum getEnum(Class clazz) throws CommandInvalidTypeException;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public enum BlockById implements IDatatypeFor {
|
||||
INSTANCE;
|
||||
|
||||
private static Pattern PATTERN = Pattern.compile("(?:[a-z0-9_.-]+:)?[a-z0-9/_.-]*");
|
||||
@Override
|
||||
public Object get(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return this.get2(datatypeContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
|
||||
String string = datatypeContext.getConsumer().getString();
|
||||
return !PATTERN.matcher(string).matches()
|
||||
? Stream.empty()
|
||||
: new TabCompleteHelper().append(Block.blockRegistry.getKeys().stream().map(Object::toString)).filterPrefixNamespaced(string).sortAlphabetically().getStream();
|
||||
}
|
||||
|
||||
public Block get2(IDatatypeContext datatypeContext) throws CommandException {
|
||||
ResourceLocation location = new ResourceLocation(datatypeContext.getConsumer().getString());
|
||||
Block block;
|
||||
if ((block = (Block)Block.blockRegistry.getObject(location)) == Blocks.air) {
|
||||
throw new IllegalArgumentException("no block found by that id");
|
||||
} else {
|
||||
return block;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public enum EntityClassById implements IDatatypeFor {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Object get(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return this.get2(datatypeContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return new TabCompleteHelper().append(EntityList.getEntityNameList().stream().map(Object::toString)).filterPrefixNamespaced(datatypeContext.getConsumer().getString()).sortAlphabetically().getStream();
|
||||
}
|
||||
|
||||
public Class get2(IDatatypeContext datatypeContext) throws CommandException {
|
||||
ResourceLocation location = new ResourceLocation(datatypeContext.getConsumer().getString());
|
||||
|
||||
Class clazz;
|
||||
try {
|
||||
clazz = (Class)EntityList.idToClassMapping.get(location);
|
||||
} catch (NoSuchFieldError e) {
|
||||
try {
|
||||
Class[] clazzs = new Class[]{ResourceLocation.class};
|
||||
clazz = (Class)EntityList.class.getMethod("getClass", clazzs).invoke(null, location);
|
||||
} catch (Exception e2) {
|
||||
throw new RuntimeException("EntityList.REGISTRY does not exist and failed to call the Forge-replacement method", e2);
|
||||
}
|
||||
}
|
||||
|
||||
if (clazz == null) {
|
||||
throw new IllegalArgumentException("no entity found by that id");
|
||||
} else {
|
||||
return clazz;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum ForAxis implements IDatatypeFor {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Object get(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return this.get2(datatypeContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(Stream.of(EnumFacing.Axis.values()).map(EnumFacing.Axis::getName).map(String::toLowerCase))
|
||||
.filterPrefix(datatypeContext.getConsumer().getString())
|
||||
.getStream();
|
||||
}
|
||||
|
||||
public EnumFacing.Axis get2(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return EnumFacing.Axis.valueOf(datatypeContext.getConsumer().getString().toUpperCase(Locale.US));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public enum ForBlockOptionalMeta implements IDatatypeFor {
|
||||
INSTANCE;
|
||||
private static Pattern PATTERN = Pattern.compile(
|
||||
"(?:[a-z0-9_.-]+:)?(?:[a-z0-9/_.-]+(?:\\[(?:(?:[a-z0-9_.-]+=[a-z0-9_.-]+,)*(?:[a-z0-9_.-]+(?:=(?:[a-z0-9_.-]+(?:\\])?)?)?)?|\\])?)?)?"
|
||||
);
|
||||
public BlockOptionalMeta get2(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return new BlockOptionalMeta(datatypeContext.getConsumer().getString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
|
||||
String str = datatypeContext.getConsumer().peekString();
|
||||
if (!PATTERN.matcher(str).matches()) {
|
||||
datatypeContext.getConsumer().getString();
|
||||
return Stream.empty();
|
||||
} else if (str.endsWith("]")) {
|
||||
datatypeContext.getConsumer().getString();
|
||||
return Stream.empty();
|
||||
} else if (!str.contains("[")) {
|
||||
return datatypeContext.getConsumer().tabCompleteDatatype(BlockById.INSTANCE);
|
||||
} else {
|
||||
datatypeContext.getConsumer().getString();
|
||||
String[] strings = splitLast(str, '[');
|
||||
String str2 = strings[0];
|
||||
String str3 = strings[1];
|
||||
Block object = (Block)Block.blockRegistry.getObject(new ResourceLocation(str2));
|
||||
if (object == null) {
|
||||
return Stream.empty();
|
||||
} else {
|
||||
String[] strings2 = splitLast(str3, ',');
|
||||
String str4 = strings2[0];
|
||||
String str5 = strings2[1];
|
||||
if (!str5.contains("=")) {
|
||||
Set set = Stream.of(str4.split(",")).map(str6 -> str6.split("=")[0]).collect(Collectors.toSet());
|
||||
String str7 = str.substring(0, str.length() - str5.length());
|
||||
return new TabCompleteHelper()
|
||||
.append(object.getBlockState().getProperties().stream().map(obj -> ((IProperty)obj).getName()))
|
||||
.filter(obj2 -> !set.contains(obj2))
|
||||
.filterPrefix(str5)
|
||||
.sortAlphabetically()
|
||||
.map(obj3 -> str7 + obj3)
|
||||
.getStream();
|
||||
} else {
|
||||
String[] strings3 = splitLast(str5, '=');
|
||||
String str8 = strings3[0];
|
||||
String str9 = strings3[1];
|
||||
String str10 = str.substring(0, str.length() - str9.length());
|
||||
IProperty property = null;
|
||||
|
||||
for (IProperty property2 : (Iterable<IProperty>)(object.getBlockState().getProperties())) {
|
||||
if (property2.getName().equals(str8)) {
|
||||
property = property2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return property == null ? Stream.empty() : new TabCompleteHelper().append(getValueNames(property)).filterPrefix(str9).sortAlphabetically().map(obj4 -> str10 + obj4).getStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] splitLast(String str, char ch) {
|
||||
int n = str.lastIndexOf(ch);
|
||||
return n == -1 ? new String[]{"", str} : new String[]{str.substring(0, n), str.substring(n + 1)};
|
||||
}
|
||||
|
||||
private static Stream getValueNames(IProperty property) {
|
||||
return property.getAllowedValues().stream().map(obj -> property.getName((Comparable)obj));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return this.get2(datatypeContext);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public enum ForEnumFacing implements IDatatypeFor {
|
||||
INSTANCE;
|
||||
|
||||
public EnumFacing get2(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return EnumFacing.valueOf(datatypeContext.getConsumer().getString().toUpperCase(Locale.US));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return new TabCompleteHelper().append(Stream.of(EnumFacing.values()).map(EnumFacing::getName).map(String::toLowerCase)).filterPrefix(datatypeContext.getConsumer().getString()).getStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return this.get2(datatypeContext);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.IWaypointCollection;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.cache.WaypointTag;
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum ForWaypoints implements IDatatypeFor {
|
||||
INSTANCE;
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return new TabCompleteHelper().append2(getWaypointNames(datatypeContext.getBaritone())).sortAlphabetically().prepend3(WaypointTag.getAllNames()).filterPrefix(datatypeContext.getConsumer().getString()).getStream();
|
||||
}
|
||||
|
||||
public static IWaypoint[] getWaypointsByTag(IBaritone baritone, WaypointTag waypointTag) {
|
||||
return (IWaypoint[])waypoints(baritone).getByTag(waypointTag).stream().sorted(Comparator.comparingLong(IWaypoint::getCreationTimestamp).reversed()).toArray(IWaypoint[]::new);
|
||||
}
|
||||
|
||||
public static String[] getWaypointNames(IBaritone baritone) {
|
||||
return Stream.of(getWaypoints(baritone)).map(IWaypoint::getName).filter(str -> !str.isEmpty()).toArray(String[]::new);
|
||||
}
|
||||
|
||||
public static IWaypointCollection waypoints(IBaritone baritone) {
|
||||
return baritone.getWorldProvider().getCurrentWorld().getWaypoints();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return this.get2(datatypeContext);
|
||||
}
|
||||
|
||||
public static IWaypoint[] getWaypointsByName(IBaritone baritone, String str) {
|
||||
return Stream.of(getWaypoints(baritone)).filter(waypoint -> waypoint.getName().equalsIgnoreCase(str)).toArray(IWaypoint[]::new);
|
||||
}
|
||||
|
||||
public IWaypoint[] get2(IDatatypeContext datatypeContext) throws CommandException {
|
||||
String string = datatypeContext.getConsumer().getString();
|
||||
WaypointTag byName = WaypointTag.getByName(string);
|
||||
return byName == null ? getWaypointsByName(datatypeContext.getBaritone(), string) : getWaypointsByTag(datatypeContext.getBaritone(), byName);
|
||||
}
|
||||
|
||||
public static IWaypoint[] getWaypoints(IBaritone baritone) {
|
||||
return (IWaypoint[])waypoints(baritone).getAllWaypoints().stream().sorted(Comparator.comparingLong(IWaypoint::getCreationTimestamp).reversed()).toArray(IWaypoint[]::new);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface IDatatype {
|
||||
Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
|
||||
public interface IDatatypeContext {
|
||||
IBaritone getBaritone();
|
||||
|
||||
IArgConsumer getConsumer();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
public interface IDatatypeFor extends IDatatype {
|
||||
Object get(IDatatypeContext datatypeContext) throws CommandException;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
public interface IDatatypePost extends IDatatype {
|
||||
Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public enum NearbyPlayer implements IDatatypeFor {
|
||||
INSTANCE;
|
||||
public EntityPlayer get2(IDatatypeContext datatypeContext) throws CommandException {
|
||||
String string = datatypeContext.getConsumer().getString();
|
||||
return (EntityPlayer)(getPlayers(datatypeContext).stream().filter(obj -> ((EntityPlayer)obj).getName().equalsIgnoreCase(string)).findFirst().orElse(null));
|
||||
}
|
||||
|
||||
private static List getPlayers(IDatatypeContext datatypeContext) {
|
||||
return datatypeContext.getBaritone().getPlayerContext().world().playerEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return this.get2(datatypeContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
|
||||
return new TabCompleteHelper().append(getPlayers(datatypeContext).stream().map(obj -> ((EntityPlayer)obj).getName())).filterPrefix(datatypeContext.getConsumer().getString()).sortAlphabetically().getStream();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeBlockPos implements IDatatypePost {
|
||||
INSTANCE;
|
||||
|
||||
public BetterBlockPos apply2(IDatatypeContext datatypeContext, BetterBlockPos betterBlockPos) throws CommandException {
|
||||
if (betterBlockPos == null) {
|
||||
betterBlockPos = BetterBlockPos.ORIGIN2;
|
||||
}
|
||||
|
||||
IArgConsumer consumer = datatypeContext.getConsumer();
|
||||
return new BetterBlockPos(
|
||||
(Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.x2),
|
||||
(Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.y2),
|
||||
(Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.z2)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
|
||||
IArgConsumer consumer = datatypeContext.getConsumer();
|
||||
if (consumer.hasAny() && !consumer.has(4)) {
|
||||
while (consumer.has(2) && consumer.peekDatatypeOrNull2(RelativeCoordinate.INSTANCE) != null) {
|
||||
consumer.get();
|
||||
}
|
||||
|
||||
return consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE);
|
||||
} else {
|
||||
return Stream.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
|
||||
return this.apply2(datatypeContext, (BetterBlockPos)obj);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeCoordinate implements IDatatypePost {
|
||||
INSTANCE;
|
||||
|
||||
private static String SCALES = "[kKmM]";
|
||||
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(" + SCALES + "?)|)$");
|
||||
|
||||
@Override
|
||||
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
|
||||
return this.apply2(datatypeContext, (Double)obj);
|
||||
}
|
||||
|
||||
public Double apply2(IDatatypeContext datatypeContext, Double d) throws CommandException {
|
||||
if (d == null) {
|
||||
d = 0.0;
|
||||
}
|
||||
|
||||
Matcher matcher = PATTERN.matcher(datatypeContext.getConsumer().getString());
|
||||
if (!matcher.matches()) {
|
||||
throw new IllegalArgumentException("pattern doesn't match");
|
||||
} else {
|
||||
boolean flag = !matcher.group(1).isEmpty();
|
||||
double d2 = matcher.group(2).isEmpty() ? 0.0 : Double.parseDouble(matcher.group(2).replaceAll(SCALES, ""));
|
||||
if (matcher.group(2).toLowerCase().contains("k")) {
|
||||
d2 *= 1000.0;
|
||||
}
|
||||
|
||||
if (matcher.group(2).toLowerCase().contains("m")) {
|
||||
d2 *= 1000000.0;
|
||||
}
|
||||
|
||||
return flag ? d + d2 : d2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
|
||||
IArgConsumer consumer = datatypeContext.getConsumer();
|
||||
return !consumer.has(2) && consumer.getString().matches("^(~|$)") ? Stream.of("~") : Stream.empty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public enum RelativeFile implements IDatatypePost {
|
||||
INSTANCE;
|
||||
public File apply2(IDatatypeContext datatypeContext, File file) throws CommandException {
|
||||
if (file == null) {
|
||||
file = new File("./");
|
||||
}
|
||||
|
||||
Path path;
|
||||
try {
|
||||
path = FileSystems.getDefault().getPath(datatypeContext.getConsumer().getString());
|
||||
} catch (InvalidPathException e) {
|
||||
throw new IllegalArgumentException("invalid path");
|
||||
}
|
||||
|
||||
return getCanonicalFileUnchecked(file.toPath().resolve(path).toFile());
|
||||
}
|
||||
|
||||
public static File gameDir(Minecraft mc) {
|
||||
File absoluteFile = mc.mcDataDir.getAbsoluteFile();
|
||||
return absoluteFile.getName().equals(".") ? absoluteFile.getParentFile() : absoluteFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
private static File getCanonicalFileUnchecked(File file) {
|
||||
try {
|
||||
return file.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Stream tabComplete(IArgConsumer argConsumer, File file) throws CommandException {
|
||||
File canonicalFileUnchecked = getCanonicalFileUnchecked(file);
|
||||
String string = argConsumer.getString();
|
||||
Path path = FileSystems.getDefault().getPath(string);
|
||||
Path path2 = path.isAbsolute() ? path.getRoot() : canonicalFileUnchecked.toPath();
|
||||
boolean flag = !string.isEmpty() && !string.endsWith(File.separator);
|
||||
File file2 = path.isAbsolute() ? path.toFile() : new File(canonicalFileUnchecked, string);
|
||||
return Stream.of(Objects.requireNonNull(getCanonicalFileUnchecked(flag ? file2.getParentFile() : file2).listFiles()))
|
||||
.map(file3 -> (path.isAbsolute() ? file3 : path2.relativize(file3.toPath()).toString()) + (file3.isDirectory() ? File.separator : ""))
|
||||
.filter(str -> str.toLowerCase(Locale.US).startsWith(string.toLowerCase(Locale.US)))
|
||||
.filter(str2 -> !str2.contains(" "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
|
||||
return this.apply2(datatypeContext, (File)obj);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static File gameDir() {
|
||||
return gameDir(Helper.mc);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeGoal implements IDatatypePost {
|
||||
INSTANCE;
|
||||
|
||||
public Goal apply2(IDatatypeContext datatypeContext, BetterBlockPos betterBlockPos) throws CommandException {
|
||||
if (betterBlockPos == null) {
|
||||
betterBlockPos = BetterBlockPos.ORIGIN2;
|
||||
}
|
||||
|
||||
IArgConsumer consumer = datatypeContext.getConsumer();
|
||||
GoalBlock goalBlock = (GoalBlock)consumer.peekDatatypePostOrNull(RelativeGoalBlock.INSTANCE, betterBlockPos);
|
||||
if (goalBlock != null) {
|
||||
return goalBlock;
|
||||
} else {
|
||||
GoalXZ goalXZ = (GoalXZ)consumer.peekDatatypePostOrNull(RelativeGoalXZ.INSTANCE, betterBlockPos);
|
||||
if (goalXZ != null) {
|
||||
return goalXZ;
|
||||
} else {
|
||||
GoalYLevel goalYLevel = (GoalYLevel)consumer.peekDatatypePostOrNull(RelativeGoalYLevel.INSTANCE, betterBlockPos);
|
||||
return (Goal)(goalYLevel != null ? goalYLevel : new GoalBlock(betterBlockPos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) {
|
||||
return datatypeContext.getConsumer().tabCompleteDatatype(RelativeCoordinate.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
|
||||
return this.apply2(datatypeContext, (BetterBlockPos)obj);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public enum RelativeGoalBlock implements IDatatypePost {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
|
||||
return this.apply2(datatypeContext, (BetterBlockPos)obj);
|
||||
}
|
||||
|
||||
public GoalBlock apply2(IDatatypeContext datatypeContext, BetterBlockPos betterBlockPos) throws CommandException {
|
||||
if (betterBlockPos == null) {
|
||||
betterBlockPos = BetterBlockPos.ORIGIN2;
|
||||
}
|
||||
|
||||
IArgConsumer consumer = datatypeContext.getConsumer();
|
||||
return new GoalBlock(
|
||||
MathHelper.floor_double((Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.x2)),
|
||||
MathHelper.floor_double((Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.y2)),
|
||||
MathHelper.floor_double((Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.z2))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) {
|
||||
IArgConsumer consumer = datatypeContext.getConsumer();
|
||||
return consumer.hasAtMost(3) ? consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE) : Stream.empty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public enum RelativeGoalXZ implements IDatatypePost {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) {
|
||||
IArgConsumer consumer = datatypeContext.getConsumer();
|
||||
return consumer.hasAtMost(2) ? consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE) : Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
|
||||
return this.apply2(datatypeContext, (BetterBlockPos)obj);
|
||||
}
|
||||
|
||||
public GoalXZ apply2(IDatatypeContext datatypeContext, BetterBlockPos betterBlockPos) throws CommandException {
|
||||
if (betterBlockPos == null) {
|
||||
betterBlockPos = BetterBlockPos.ORIGIN2;
|
||||
}
|
||||
|
||||
IArgConsumer consumer = datatypeContext.getConsumer();
|
||||
return new GoalXZ(
|
||||
MathHelper.floor_double((Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.x2)),
|
||||
MathHelper.floor_double((Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.z2))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public enum RelativeGoalYLevel implements IDatatypePost {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
|
||||
return this.apply2(datatypeContext, (BetterBlockPos)obj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public GoalYLevel apply2(IDatatypeContext datatypeContext, BetterBlockPos betterBlockPos) throws CommandException {
|
||||
if (betterBlockPos == null) {
|
||||
betterBlockPos = BetterBlockPos.ORIGIN2;
|
||||
}
|
||||
|
||||
return new GoalYLevel(MathHelper.floor_double((Double)datatypeContext.getConsumer().getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.y2)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream tabComplete(IDatatypeContext datatypeContext) {
|
||||
IArgConsumer consumer = datatypeContext.getConsumer();
|
||||
return consumer.hasAtMost(1) ? consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE) : Stream.empty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public abstract class CommandErrorMessageException extends CommandException {
|
||||
public CommandErrorMessageException(String str, Throwable t) {
|
||||
super(str, t);
|
||||
}
|
||||
|
||||
public CommandErrorMessageException(String str) {
|
||||
super(str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public abstract class CommandException extends Exception implements ICommandException {
|
||||
public CommandException(String str, Throwable t) {
|
||||
super(str, t);
|
||||
}
|
||||
|
||||
public CommandException(String str) {
|
||||
super(str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package baritone.api.command.exception;
|
||||
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
|
||||
public abstract class CommandInvalidArgumentException extends CommandErrorMessageException {
|
||||
public final ICommandArgument arg;
|
||||
|
||||
public CommandInvalidArgumentException(ICommandArgument commandArgument, String str) {
|
||||
super(formatMessage(commandArgument, str));
|
||||
this.arg = commandArgument;
|
||||
}
|
||||
|
||||
public CommandInvalidArgumentException(ICommandArgument commandArgument, String str, Throwable t) {
|
||||
super(formatMessage(commandArgument, str), t);
|
||||
this.arg = commandArgument;
|
||||
}
|
||||
|
||||
private static String formatMessage(ICommandArgument commandArgument, String str) {
|
||||
return String.format("Error at argument #%s: %s", commandArgument.getIndex() == -1 ? "<unknown>" : Integer.toString(commandArgument.getIndex() + 1), str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public class CommandInvalidStateException extends CommandErrorMessageException {
|
||||
public CommandInvalidStateException(String str) {
|
||||
super(str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package baritone.api.command.exception;
|
||||
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
|
||||
public class CommandInvalidTypeException extends CommandInvalidArgumentException {
|
||||
|
||||
public CommandInvalidTypeException(ICommandArgument commandArgument, String str, String str2, Throwable t) {
|
||||
super(commandArgument, String.format("Expected %s, but got %s instead", str, str2), t);
|
||||
}
|
||||
|
||||
public CommandInvalidTypeException(ICommandArgument commandArgument, String str, Throwable t) {
|
||||
super(commandArgument, String.format("Expected %s", str), t);
|
||||
}
|
||||
|
||||
public CommandInvalidTypeException(ICommandArgument commandArgument, String str) {
|
||||
super(commandArgument, String.format("Expected %s", str));
|
||||
}
|
||||
|
||||
public CommandInvalidTypeException(ICommandArgument commandArgument, String str, String str2) {
|
||||
super(commandArgument, String.format("Expected %s, but got %s instead", str, str2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package baritone.api.command.exception;
|
||||
|
||||
|
||||
public class CommandNoParserForTypeException extends CommandUnhandledException {
|
||||
public CommandNoParserForTypeException(Class clazz) {
|
||||
super(String.format("Could not find a handler for type %s", clazz.getSimpleName()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public class CommandNotEnoughArgumentsException extends CommandErrorMessageException {
|
||||
public CommandNotEnoughArgumentsException(int n) {
|
||||
super(String.format("Not enough arguments (expected at least %d)", n));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package baritone.api.command.exception;
|
||||
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.utils.Helper;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandNotFoundException extends CommandException {
|
||||
public final String command;
|
||||
|
||||
public CommandNotFoundException(String str) {
|
||||
super(String.format("Command not found: %s", str));
|
||||
this.command = str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ICommand command2, List list) {
|
||||
Helper.HELPER.logDirect2(this.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public class CommandTooManyArgumentsException extends CommandErrorMessageException {
|
||||
public CommandTooManyArgumentsException(int n) {
|
||||
super(String.format("Too many arguments (expected at most %d)", n));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package baritone.api.command.exception;
|
||||
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.utils.Helper;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandUnhandledException extends RuntimeException implements ICommandException {
|
||||
@Override
|
||||
public void handle(ICommand command, List list) {
|
||||
Helper.HELPER.logUnhandledException(this);
|
||||
}
|
||||
|
||||
public CommandUnhandledException(Throwable t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public CommandUnhandledException(String str) {
|
||||
super(str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package baritone.api.command.exception;
|
||||
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.utils.Helper;
|
||||
import java.util.List;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public interface ICommandException {
|
||||
String getMessage();
|
||||
|
||||
default void handle(ICommand command, List list) {
|
||||
Helper.HELPER.logDirect3(this.getMessage(), EnumChatFormatting.RED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package baritone.api.command.helpers;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
public interface CommandFunction {
|
||||
Object apply(Object obj) throws CommandException;
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package baritone.api.command.helpers;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import net.minecraft.event.ClickEvent;
|
||||
import net.minecraft.event.HoverEvent;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
public class Paginator implements Helper {
|
||||
public final List entries;
|
||||
public int pageSize = 8;
|
||||
public int page = 1;
|
||||
|
||||
public void display(Function function, String str) {
|
||||
int n = (this.page - 1) * this.pageSize;
|
||||
|
||||
for (int j = n; j < n + this.pageSize; j++) {
|
||||
if (j < this.entries.size()) {
|
||||
this.logDirect(new IChatComponent[]{(IChatComponent)function.apply(this.entries.get(j))});
|
||||
} else {
|
||||
this.logDirect3("--", EnumChatFormatting.DARK_GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
boolean flag = str != null && this.validPage(this.page - 1);
|
||||
boolean flag2 = str != null && this.validPage(this.page + 1);
|
||||
ChatComponentText chatComponentText = new ChatComponentText("<<");
|
||||
if (flag) {
|
||||
chatComponentText.getChatStyle()
|
||||
.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("%s %d", str, this.page - 1)))
|
||||
.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("Click to view previous page")));
|
||||
} else {
|
||||
chatComponentText.getChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
|
||||
}
|
||||
|
||||
ChatComponentText chatComponentText2 = new ChatComponentText(">>");
|
||||
if (flag2) {
|
||||
chatComponentText2.getChatStyle()
|
||||
.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("%s %d", str, this.page + 1)))
|
||||
.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("Click to view next page")));
|
||||
} else {
|
||||
chatComponentText2.getChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
|
||||
}
|
||||
|
||||
ChatComponentText chatComponentText3 = new ChatComponentText("");
|
||||
chatComponentText3.getChatStyle().setColor(EnumChatFormatting.GRAY);
|
||||
chatComponentText3.appendSibling(chatComponentText);
|
||||
chatComponentText3.appendText(" | ");
|
||||
chatComponentText3.appendSibling(chatComponentText2);
|
||||
chatComponentText3.appendText(String.format(" %d/%d", this.page, this.getMaxPage()));
|
||||
this.logDirect(new IChatComponent[]{chatComponentText3});
|
||||
}
|
||||
|
||||
public void display(Function function) {
|
||||
this.display(function, null);
|
||||
}
|
||||
|
||||
public static void paginate(IArgConsumer argConsumer, List list, Runnable runnable, Function function) throws CommandException {
|
||||
paginate3(argConsumer, new Paginator(list), runnable, function, null);
|
||||
}
|
||||
|
||||
public static void paginate5(IArgConsumer argConsumer, Object[] array, Function function, String str) throws CommandException {
|
||||
paginate2(argConsumer, Arrays.asList(array), null, function, str);
|
||||
}
|
||||
|
||||
public boolean validPage(int n) {
|
||||
return n > 0 && n <= this.getMaxPage();
|
||||
}
|
||||
|
||||
public Paginator skipPages(int n) {
|
||||
this.page += n;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static void paginate3(IArgConsumer argConsumer, List list, Function function) throws CommandException {
|
||||
paginate3(argConsumer, new Paginator(list), null, function, null);
|
||||
}
|
||||
|
||||
public static void paginate2(IArgConsumer argConsumer, Paginator paginator, Function function) throws CommandException {
|
||||
paginate3(argConsumer, paginator, null, function, null);
|
||||
}
|
||||
|
||||
public static void paginate(IArgConsumer argConsumer, Object[] array, Function function) throws CommandException {
|
||||
paginate2(argConsumer, Arrays.asList(array), null, function, null);
|
||||
}
|
||||
|
||||
public static void paginate6(IArgConsumer argConsumer, Paginator paginator, Runnable runnable, Function function) throws CommandException {
|
||||
paginate3(argConsumer, paginator, runnable, function, null);
|
||||
}
|
||||
|
||||
public static void paginate3(IArgConsumer argConsumer, Paginator paginator, Runnable runnable, Function function, String str) throws CommandException {
|
||||
int n = 1;
|
||||
argConsumer.requireMax(1);
|
||||
if (argConsumer.hasAny()) {
|
||||
n = (Integer)argConsumer.getAs(Integer.class);
|
||||
if (!paginator.validPage(n)) {
|
||||
throw new CommandInvalidTypeException(argConsumer.consumed(), String.format("a valid page (1-%d)", paginator.getMaxPage()), argConsumer.consumed().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
paginator.skipPages(n - paginator.page);
|
||||
if (runnable != null) {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
paginator.display(function, str);
|
||||
}
|
||||
|
||||
public Paginator setPageSize(int n) {
|
||||
this.pageSize = n;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Paginator(List list) {
|
||||
this.entries = list;
|
||||
}
|
||||
|
||||
public static void paginate(IArgConsumer argConsumer, Object[] array, Runnable runnable, Function function, String str) throws CommandException {
|
||||
paginate2(argConsumer, Arrays.asList(array), runnable, function, str);
|
||||
}
|
||||
|
||||
public static void paginate4(IArgConsumer argConsumer, Object[] array, Runnable runnable, Function function) throws CommandException {
|
||||
paginate2(argConsumer, Arrays.asList(array), runnable, function, null);
|
||||
}
|
||||
|
||||
public static void paginate2(IArgConsumer argConsumer, Paginator paginator, Function function, String str) throws CommandException {
|
||||
paginate3(argConsumer, paginator, null, function, str);
|
||||
}
|
||||
|
||||
public static void paginate2(IArgConsumer argConsumer, List list, Runnable runnable, Function function, String str) throws CommandException {
|
||||
paginate3(argConsumer, new Paginator(list), runnable, function, str);
|
||||
}
|
||||
|
||||
public Paginator(Object[] array) {
|
||||
this.entries = Arrays.asList(array);
|
||||
}
|
||||
|
||||
public int getMaxPage() {
|
||||
return (this.entries.size() - 1) / this.pageSize + 1;
|
||||
}
|
||||
|
||||
public static void paginate3(IArgConsumer argConsumer, List list, Function function, String str) throws CommandException {
|
||||
paginate3(argConsumer, new Paginator(list), null, function, str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package baritone.api.command.helpers;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class TabCompleteHelper {
|
||||
private Stream stream;
|
||||
|
||||
public TabCompleteHelper filter(Predicate predicate) {
|
||||
this.stream = this.stream.filter(predicate);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TabCompleteHelper append(Stream stream2) {
|
||||
this.stream = Stream.concat(this.stream, stream2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TabCompleteHelper prepend(Stream stream2) {
|
||||
this.stream = Stream.concat(stream2, this.stream);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TabCompleteHelper sortAlphabetically() {
|
||||
return this.sort(String.CASE_INSENSITIVE_ORDER);
|
||||
}
|
||||
|
||||
public TabCompleteHelper filterPrefixNamespaced(String str) {
|
||||
return this.filterPrefix(new ResourceLocation(str).toString());
|
||||
}
|
||||
|
||||
public TabCompleteHelper prepend2(Class clazz) {
|
||||
return this.prepend(Stream.of((Enum[])clazz.getEnumConstants()).map(Enum::name).map(String::toLowerCase));
|
||||
}
|
||||
|
||||
public TabCompleteHelper() {
|
||||
this.stream = Stream.empty();
|
||||
}
|
||||
|
||||
public String[] build() {
|
||||
return (String[])this.stream.toArray(String[]::new);
|
||||
}
|
||||
|
||||
public TabCompleteHelper filterPrefix(String str) {
|
||||
return this.filter(obj -> ((String)obj).toLowerCase(Locale.US).startsWith(str.toLowerCase(Locale.US)));
|
||||
}
|
||||
|
||||
public TabCompleteHelper append3(Class clazz) {
|
||||
return this.append(Stream.of((Enum[])clazz.getEnumConstants()).map(Enum::name).map(String::toLowerCase));
|
||||
}
|
||||
|
||||
public Stream getStream() {
|
||||
return this.stream;
|
||||
}
|
||||
|
||||
public TabCompleteHelper(List list) {
|
||||
this.stream = list.stream();
|
||||
}
|
||||
|
||||
public TabCompleteHelper addModifiedSettings() {
|
||||
return this.append(SettingsUtil.modifiedSettings(BaritoneAPI.getSettings()).stream().map(Settings.Setting::getName).sorted(String.CASE_INSENSITIVE_ORDER));
|
||||
}
|
||||
|
||||
public TabCompleteHelper(String[] strings) {
|
||||
this.stream = Stream.of(strings);
|
||||
}
|
||||
|
||||
public TabCompleteHelper addCommands(ICommandManager commandManager) {
|
||||
return this.append(commandManager.getRegistry().descendingStream().flatMap(obj -> ((ICommand)obj).getNames().stream()).distinct());
|
||||
}
|
||||
|
||||
public TabCompleteHelper addSettings() {
|
||||
return this.append(BaritoneAPI.getSettings().allSettings.stream().filter(setting -> !setting.isJavaOnly()).map(Settings.Setting::getName).sorted(String.CASE_INSENSITIVE_ORDER));
|
||||
}
|
||||
|
||||
public TabCompleteHelper prepend3(String[] strings) {
|
||||
return this.prepend(Stream.of(strings));
|
||||
}
|
||||
|
||||
public TabCompleteHelper addToggleableSettings() {
|
||||
return this.append(BaritoneAPI.getSettings().getAllValuesByType(Boolean.class).stream().map(Settings.Setting::getName).sorted(String.CASE_INSENSITIVE_ORDER));
|
||||
}
|
||||
|
||||
public TabCompleteHelper sort(Comparator comparator) {
|
||||
this.stream = this.stream.sorted(comparator);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TabCompleteHelper append2(String[] strings) {
|
||||
return this.append(Stream.of(strings));
|
||||
}
|
||||
|
||||
public TabCompleteHelper map(Function function) {
|
||||
this.stream = this.stream.map(function);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package baritone.api.command.manager;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.registry.Registry;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.util.Tuple;
|
||||
|
||||
public interface ICommandManager {
|
||||
ICommand getCommand(String str);
|
||||
|
||||
IBaritone getBaritone();
|
||||
|
||||
Registry getRegistry();
|
||||
|
||||
Stream tabComplete2(String str);
|
||||
|
||||
boolean execute(String str);
|
||||
|
||||
boolean execute2(Tuple tuple);
|
||||
|
||||
Stream tabComplete(Tuple tuple);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package baritone.api.command.registry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
import java.util.Spliterators;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public class Registry {
|
||||
private final Deque entries = new LinkedList();
|
||||
private final Set registered = new HashSet();
|
||||
public final Collection registry = Collections.unmodifiableCollection(this.entries);
|
||||
|
||||
public boolean registered(Object obj) {
|
||||
return this.registered.contains(obj);
|
||||
}
|
||||
|
||||
public void unregister(Object obj) {
|
||||
if (this.registered(obj)) {
|
||||
this.entries.remove(obj);
|
||||
this.registered.remove(obj);
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator iterator() {
|
||||
return this.entries.iterator();
|
||||
}
|
||||
|
||||
public Stream stream() {
|
||||
return this.entries.stream();
|
||||
}
|
||||
|
||||
public Stream descendingStream() {
|
||||
return StreamSupport.stream(Spliterators.spliterator(this.descendingIterator(), (long)this.entries.size(), 16448), false);
|
||||
}
|
||||
|
||||
public boolean register(Object obj) {
|
||||
if (!this.registered(obj)) {
|
||||
this.entries.addFirst(obj);
|
||||
this.registered.add(obj);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator descendingIterator() {
|
||||
return this.entries.descendingIterator();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.utils.ChunkPos;
|
||||
import java.util.List;
|
||||
|
||||
public final class BlockChangeEvent {
|
||||
private final ChunkPos chunkPos;
|
||||
private final List blocks;
|
||||
|
||||
public ChunkPos getChunkPos() {
|
||||
return this.chunkPos;
|
||||
}
|
||||
|
||||
public BlockChangeEvent(ChunkPos chunkPos2, List list) {
|
||||
this.chunkPos = chunkPos2;
|
||||
this.blocks = list;
|
||||
}
|
||||
|
||||
public List getBlocks() {
|
||||
return this.blocks;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
public final class BlockInteractEvent {
|
||||
private final BlockPos pos;
|
||||
private final BlockInteractEvent.Type type;
|
||||
|
||||
public final BlockPos getPos() {
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
public BlockInteractEvent(BlockPos pos2, BlockInteractEvent.Type type2) {
|
||||
this.pos = pos2;
|
||||
this.type = type2;
|
||||
}
|
||||
|
||||
public final BlockInteractEvent.Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
|
||||
public enum Type {
|
||||
START_BREAK,
|
||||
USE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.Cancellable;
|
||||
|
||||
public final class ChatEvent extends Cancellable {
|
||||
private final String message;
|
||||
|
||||
public ChatEvent(String str) {
|
||||
this.message = str;
|
||||
}
|
||||
|
||||
public final String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
|
||||
public final class ChunkEvent {
|
||||
private final EventState state;
|
||||
private final ChunkEvent.Type type;
|
||||
private final int x;
|
||||
private final int z;
|
||||
|
||||
public ChunkEvent.Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public EventState getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public boolean isPostPopulate() {
|
||||
return this.state == EventState.POST && this.type.isPopulate();
|
||||
}
|
||||
|
||||
public ChunkEvent(EventState event, ChunkEvent.Type type2, int n, int n2) {
|
||||
this.state = event;
|
||||
this.type = type2;
|
||||
this.x = n;
|
||||
this.z = n2;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
|
||||
public enum Type {
|
||||
LOAD,
|
||||
UNLOAD,
|
||||
POPULATE_FULL,
|
||||
POPULATE_PARTIAL;
|
||||
|
||||
public final boolean isPopulate() {
|
||||
return this == POPULATE_FULL || this == POPULATE_PARTIAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
public final class PacketEvent {
|
||||
private final NetworkManager networkManager;
|
||||
private final EventState state;
|
||||
private final Packet packet;
|
||||
|
||||
public final Packet getPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public final Packet getPacket2() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public final NetworkManager getNetworkManager() {
|
||||
return this.networkManager;
|
||||
}
|
||||
|
||||
public final EventState getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public PacketEvent(NetworkManager networkManager2, EventState event, Packet packet2) {
|
||||
this.networkManager = networkManager2;
|
||||
this.state = event;
|
||||
this.packet = packet2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
public enum PathEvent {
|
||||
CALC_STARTED,
|
||||
CALC_FINISHED_NOW_EXECUTING,
|
||||
CALC_FAILED,
|
||||
NEXT_SEGMENT_CALC_STARTED,
|
||||
NEXT_SEGMENT_CALC_FINISHED,
|
||||
CONTINUING_ONTO_PLANNED_NEXT,
|
||||
SPLICING_ONTO_NEXT_EARLY,
|
||||
AT_GOAL,
|
||||
PATH_FINISHED_NEXT_STILL_CALCULATING,
|
||||
NEXT_CALC_FAILED,
|
||||
DISCARD_NEXT,
|
||||
CANCELED;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
|
||||
public final class PlayerUpdateEvent {
|
||||
private final EventState state;
|
||||
|
||||
public final EventState getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public PlayerUpdateEvent(EventState event) {
|
||||
this.state = event;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
public final class RenderEvent {
|
||||
private final float partialTicks;
|
||||
|
||||
public final float getPartialTicks() {
|
||||
return this.partialTicks;
|
||||
}
|
||||
|
||||
public RenderEvent(float f) {
|
||||
this.partialTicks = f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.utils.Rotation;
|
||||
|
||||
public final class RotationMoveEvent {
|
||||
private final RotationMoveEvent.Type type;
|
||||
private final Rotation original;
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
|
||||
public Rotation getOriginal() {
|
||||
return this.original;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return this.pitch;
|
||||
}
|
||||
|
||||
public RotationMoveEvent(RotationMoveEvent.Type type2, float f, float f2) {
|
||||
this.type = type2;
|
||||
this.original = new Rotation(f, f2);
|
||||
this.yaw = f;
|
||||
this.pitch = f2;
|
||||
}
|
||||
|
||||
public void setYaw(float f) {
|
||||
this.yaw = f;
|
||||
}
|
||||
|
||||
public void setPitch(float f) {
|
||||
this.pitch = f;
|
||||
}
|
||||
|
||||
public RotationMoveEvent.Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return this.yaw;
|
||||
}
|
||||
|
||||
|
||||
public enum Type {
|
||||
MOTION_UPDATE,
|
||||
JUMP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
public final class SprintStateEvent {
|
||||
private Boolean state;
|
||||
|
||||
public final Boolean getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public final void setState(boolean flag) {
|
||||
this.state = flag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.Cancellable;
|
||||
|
||||
public class TabCompleteEvent extends Cancellable {
|
||||
public final String prefix;
|
||||
public String[] completions;
|
||||
|
||||
public TabCompleteEvent(String str) {
|
||||
this.prefix = str;
|
||||
this.completions = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public final class TickEvent {
|
||||
private static int overallTickCount;
|
||||
private final EventState state;
|
||||
private final TickEvent.Type type;
|
||||
private final int count;
|
||||
|
||||
public TickEvent.Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public EventState getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public TickEvent(EventState event, TickEvent.Type type2, int n) {
|
||||
this.state = event;
|
||||
this.type = type2;
|
||||
this.count = n;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public static synchronized BiFunction createNextProvider() {
|
||||
int n = overallTickCount++;
|
||||
return (BiFunction<EventState, TickEvent.Type, TickEvent>)(event, type2) -> new TickEvent(event, type2, n);
|
||||
}
|
||||
|
||||
|
||||
public enum Type {
|
||||
IN,
|
||||
OUT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
|
||||
public final class WorldEvent {
|
||||
private final WorldClient world;
|
||||
private final EventState state;
|
||||
|
||||
public WorldEvent(WorldClient world2, EventState event) {
|
||||
this.world = world2;
|
||||
this.state = event;
|
||||
}
|
||||
|
||||
public final WorldClient getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
public final EventState getState() {
|
||||
return this.state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package baritone.api.event.events.type;
|
||||
|
||||
public class Cancellable implements ICancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
@Override
|
||||
public final void cancel() {
|
||||
this.cancelled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 9721 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user