Compare commits
78 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a5c4f1f03 | ||
|
|
787644181a | ||
|
|
7b60943714 | ||
|
|
7879b6909a | ||
|
|
9898e0da26 | ||
|
|
7677ed8240 | ||
|
|
7ad1a2dac7 | ||
|
|
fd55e455a1 | ||
|
|
e7e25abc0b | ||
|
|
4bc9884a95 | ||
|
|
0e35a3e62b | ||
|
|
1112feff5b | ||
|
|
967dc6cbd6 | ||
|
|
2ce60fbb79 | ||
|
|
35b7c48430 | ||
|
|
db842445f6 | ||
|
|
3a8d438d7c | ||
|
|
386caf5d1e | ||
|
|
f7f0c84407 | ||
|
|
75cd4600a0 | ||
|
|
e6642a2122 | ||
|
|
e7252f5b3f | ||
|
|
4168401aa1 | ||
|
|
3e082b21d5 | ||
|
|
85790c0b2f | ||
|
|
c20d40f8dd | ||
|
|
4fa43ce201 | ||
|
|
f51f835b11 | ||
|
|
ec2941bede | ||
|
|
5b37b68363 | ||
|
|
52d077de49 | ||
|
|
b1f35e93dc | ||
|
|
076326dcc3 | ||
|
|
b1b8288d05 | ||
|
|
df62427fee | ||
|
|
61b9762a22 | ||
|
|
06be5f5372 | ||
|
|
fcd20b10f1 | ||
|
|
fd43dace70 | ||
|
|
a475f522ef | ||
|
|
e6cc9b1131 | ||
|
|
347027a8e0 | ||
|
|
f204fbb08e | ||
|
|
606f9c55a8 | ||
|
|
f2a11df616 | ||
|
|
5773da36bd | ||
|
|
86303ed495 | ||
|
|
2b4da2a46c | ||
|
|
f699be7973 | ||
|
|
ed381d6b33 | ||
|
|
1caa99fee3 | ||
|
|
ffbe683e86 | ||
|
|
4dba5a4399 | ||
|
|
8cfdcbdc9e | ||
|
|
6e37221b3c | ||
|
|
caa88c5b60 | ||
|
|
1b3139c99a | ||
|
|
3d95f0ad65 | ||
|
|
0df45a89be | ||
|
|
b0266cd14b | ||
|
|
9bf40dd60b | ||
|
|
56b44496bf | ||
|
|
3df451677c | ||
|
|
9e021d2875 | ||
|
|
db9ee98762 | ||
|
|
d0d74b1591 | ||
|
|
056107a356 | ||
|
|
93a16f356d | ||
|
|
070083dc9b | ||
|
|
af646bd313 | ||
|
|
c3c88c50d1 | ||
|
|
16f93ce769 | ||
|
|
3cee66229a | ||
|
|
88c00f2fec | ||
|
|
394b4fd5b8 | ||
|
|
48b34bfbb8 | ||
|
|
4b2d1fe6b0 | ||
|
|
01c75db38a |
16
.github/workflows/gradle_build.yml
vendored
16
.github/workflows/gradle_build.yml
vendored
@@ -14,23 +14,21 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
|
||||
cache: gradle
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Build (fabric) with Gradle
|
||||
run: ./gradlew build -Pbaritone.fabric_build
|
||||
|
||||
- name: Build (forge) with Gradle
|
||||
run: ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
|
||||
run: ./gradlew build -Pmod_version="$(git describe --always --tags | cut -c2-)"
|
||||
|
||||
- name: Archive Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
@@ -42,4 +40,4 @@ jobs:
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Mappings
|
||||
path: build/tmp/proguard/mapping.txt
|
||||
path: mapping/
|
||||
|
||||
2
.github/workflows/run_tests.yml
vendored
2
.github/workflows/run_tests.yml
vendored
@@ -23,4 +23,4 @@ jobs:
|
||||
|
||||
- name: Executing tests
|
||||
run: ./gradlew test
|
||||
|
||||
|
||||
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -21,6 +21,9 @@ classes/
|
||||
*.iws
|
||||
/logs/
|
||||
|
||||
tweaker/logs/
|
||||
common/logs/
|
||||
|
||||
# Eclipse Files
|
||||
.classpath
|
||||
.project
|
||||
@@ -32,3 +35,6 @@ baritone_Client.launch
|
||||
!/.idea/copyright/profiles_settings.xml
|
||||
|
||||
.vscode/launch.json
|
||||
.architectury-transformer
|
||||
|
||||
mapping
|
||||
@@ -13,5 +13,3 @@ COPY . /code
|
||||
WORKDIR /code
|
||||
|
||||
RUN ./gradlew build
|
||||
RUN ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
|
||||
RUN ./gradlew build -Pbaritone.fabric_build
|
||||
|
||||
219
build.gradle
219
build.gradle
@@ -15,34 +15,89 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'dev.architectury.loom' version '0.10.0-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
allprojects {
|
||||
apply plugin: 'java'
|
||||
apply plugin: "xyz.wagyourtail.unimined"
|
||||
apply plugin: "maven-publish"
|
||||
|
||||
archivesBaseName = rootProject.archives_base_name
|
||||
def vers = 'git describe --always --tags --dirty'.execute().text.trim()
|
||||
if (!vers.startsWith("v")) {
|
||||
println "git doesn't appear to be installed!"
|
||||
println "using version number: " + rootProject.mod_version
|
||||
version = rootProject.mod_version
|
||||
} else {
|
||||
version = vers.substring(1)
|
||||
}
|
||||
group = rootProject.maven_group
|
||||
|
||||
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'spongepowered-repo'
|
||||
url = 'https://repo.spongepowered.org/repository/maven-public/'
|
||||
}
|
||||
maven {
|
||||
name = 'fabric-maven'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
maven {
|
||||
name = "ldtteam"
|
||||
url = "https://maven.parchmentmc.net/"
|
||||
}
|
||||
// for the newer version of launchwrapper
|
||||
maven {
|
||||
name = "multimc-maven"
|
||||
url = "https://files.multimc.org/maven/"
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraft:minecraft:${rootProject.minecraft_version}"
|
||||
// The following line declares the mojmap mappings, you may use other mappings as well
|
||||
mappings "net.fabricmc:intermediary:${rootProject.minecraft_version}:v2"
|
||||
mappings "net.minecraft:minecraft:${rootProject.minecraft_version}:client-mappings"
|
||||
mappings "org.parchmentmc.data:parchment-1.19.2:2022.11.27@zip"
|
||||
|
||||
implementation "org.spongepowered:mixin:0.8.5"
|
||||
implementation "org.ow2.asm:asm:9.3"
|
||||
// The following line declares the yarn mappings you may select this one as well.
|
||||
// mappings "net.fabricmc:yarn:1.17.1+build.32:v2"
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
|
||||
def targetVersion = 17
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
it.options.release = targetVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
|
||||
def compileType = project.hasProperty("baritone.fabric_build") ? "FABRIC" : project.hasProperty("baritone.forge_build") ? "FORGE" : "OFFICIAL"
|
||||
|
||||
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
compileJava {
|
||||
options.encoding = "UTF-8" // allow emoji in comments :^)
|
||||
minecraft {
|
||||
runs.off = true
|
||||
}
|
||||
|
||||
archivesBaseName = archivesBaseName + "-common"
|
||||
|
||||
sourceSets {
|
||||
api {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
}
|
||||
main {
|
||||
compileClasspath += api.output
|
||||
runtimeClasspath += api.output
|
||||
}
|
||||
test {
|
||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
@@ -54,63 +109,25 @@ sourceSets {
|
||||
}
|
||||
schematica_api {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
}
|
||||
main {
|
||||
compileClasspath += schematica_api.output
|
||||
runtimeClasspath += schematica_api.output
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
if (compileType.equals("FORGE")) {
|
||||
forge {
|
||||
mixinConfig 'mixins.baritone.json'
|
||||
}
|
||||
}
|
||||
mixin.defaultRefmapName = "mixins.baritone.refmap.json"
|
||||
|
||||
runs {
|
||||
client {
|
||||
source = sourceSets.launch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
maven {
|
||||
name = "ldtteam"
|
||||
url = "https://maven.parchmentmc.net/"
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
if (compileType.equals("FORGE")) {
|
||||
forge "net.minecraftforge:forge:${project.forge_version}"
|
||||
}
|
||||
mappings loom.layered() {
|
||||
officialMojangMappings()
|
||||
//technically optional, but really helpful in dev:
|
||||
// parchment("org.parchmentmc.data:parchment-1.17.1:2021.10.24@zip" as String)
|
||||
}
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
if (!compileType.equals("FORGE")) {
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.fabric_version}"
|
||||
}
|
||||
// this makes it compile with the forge tweak stuff
|
||||
implementation 'com.github.ImpactDevelopment:SimpleTweaker:1.2'
|
||||
implementation('net.minecraft:launchwrapper:1.12') {
|
||||
exclude module: 'lwjgl'
|
||||
exclude module: 'asm-debug-all'
|
||||
}
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
}
|
||||
|
||||
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||
jar {
|
||||
from sourceSets.main.output, sourceSets.launch.output, sourceSets.api.output
|
||||
}
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
remapJar {
|
||||
targetNamespace = "named"
|
||||
fallbackTargetNamespace = "intermediary"
|
||||
}
|
||||
|
||||
javadoc {
|
||||
@@ -119,72 +136,4 @@ javadoc {
|
||||
options.encoding "UTF-8" // allow emoji in comments :^)
|
||||
source = sourceSets.api.allJava
|
||||
classpath += sourceSets.api.compileClasspath
|
||||
}
|
||||
|
||||
// skidded from fabric-example-mod (comments and all)
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||
// this fixes some edge cases with special characters not displaying correctly
|
||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||
// If Javadoc is generated, this must be specified in that task too.
|
||||
it.options.encoding = "UTF-8"
|
||||
|
||||
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
|
||||
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
|
||||
// We'll use that if it's available, but otherwise we'll use the older option.
|
||||
def targetVersion = 16
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
it.options.release = targetVersion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
jar {
|
||||
from sourceSets.launch.output, sourceSets.api.output
|
||||
|
||||
if (!getProject().hasProperty("baritone.forge_build")) {
|
||||
exclude "**/BaritoneForgeModXD.class"
|
||||
exclude "**/mods.toml"
|
||||
}
|
||||
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
|
||||
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": version
|
||||
}
|
||||
} else {
|
||||
exclude("fabric.mod.json")
|
||||
}
|
||||
|
||||
|
||||
manifest {
|
||||
attributes(
|
||||
'MixinConfigs': 'mixins.baritone.json',
|
||||
"MixinConnector": "baritone.launch.BaritoneMixinConnector",
|
||||
|
||||
'Implementation-Title': 'Baritone',
|
||||
'Implementation-Version': version,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (compileType.equals("OFFICIAL")) {
|
||||
remapJar {
|
||||
toM.set "official"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.0-beta2/proguard-7.2.0-beta2.zip'
|
||||
extract 'proguard-7.2.0-beta2/lib/proguard.jar'
|
||||
compType compileType
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
}
|
||||
@@ -16,10 +16,25 @@
|
||||
*/
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = 'WagYourMaven'
|
||||
url = 'https://maven.wagyourtail.xyz/releases'
|
||||
}
|
||||
maven {
|
||||
name = 'ForgeMaven'
|
||||
url = 'https://maven.minecraftforge.net/'
|
||||
}
|
||||
maven {
|
||||
name = 'FabricMaven'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0'
|
||||
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
|
||||
|
||||
implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '0.3.4'
|
||||
}
|
||||
@@ -18,6 +18,9 @@
|
||||
package baritone.gradle.task;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.Optional;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -40,43 +43,49 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
PROGUARD_API_CONFIG = "api.pro",
|
||||
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
||||
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
||||
PROGUARD_MAPPING_DIR = "mapping",
|
||||
|
||||
ARTIFACT_STANDARD = "%s-%s.jar",
|
||||
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
||||
ARTIFACT_API = "%s-api-%s.jar",
|
||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
|
||||
ARTIFACT_FORGE_UNOPTIMIZED = "%s-unoptimized-forge-%s.jar",
|
||||
ARTIFACT_FORGE_API = "%s-api-forge-%s.jar",
|
||||
ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar",
|
||||
ARTIFACT_FABRIC_UNOPTIMIZED = "%s-unoptimized-fabric-%s.jar",
|
||||
ARTIFACT_FABRIC_API = "%s-api-fabric-%s.jar",
|
||||
ARTIFACT_FABRIC_STANDALONE = "%s-standalone-fabric-%s.jar";
|
||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar";
|
||||
|
||||
protected String artifactName, artifactVersion;
|
||||
protected final Path
|
||||
protected Path
|
||||
artifactPath,
|
||||
artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, // these are different for forge builds
|
||||
proguardOut;
|
||||
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
protected String compType = null;
|
||||
|
||||
public String getCompType() {
|
||||
return compType;
|
||||
}
|
||||
|
||||
public void setCompType(String compType) {
|
||||
this.compType = compType;
|
||||
}
|
||||
|
||||
|
||||
public BaritoneGradleTask() {
|
||||
this.artifactName = getProject().getName();
|
||||
this.artifactVersion = getProject().getVersion().toString();
|
||||
this.artifactName = getProject().getRootProject().getProperties().get("archives_base_name").toString();
|
||||
}
|
||||
|
||||
public void doFirst() {
|
||||
if (compType != null) {
|
||||
this.artifactVersion = compType + "-" + getProject().getVersion();
|
||||
} else {
|
||||
this.artifactVersion = getProject().getVersion().toString();
|
||||
}
|
||||
|
||||
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
|
||||
|
||||
if (getProject().hasProperty("baritone.forge_build")) {
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE));
|
||||
} else if (getProject().hasProperty("baritone.fabric_build")) {
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_STANDALONE));
|
||||
} else {
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
||||
}
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
||||
|
||||
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
|
||||
}
|
||||
@@ -99,7 +108,11 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
}
|
||||
|
||||
protected Path getRelativeFile(String file) {
|
||||
return Paths.get(new File(new File(getProject().getBuildDir(), "../"), file).getAbsolutePath());
|
||||
return Paths.get(new File(getProject().getBuildDir(), file).getAbsolutePath());
|
||||
}
|
||||
|
||||
protected Path getRootRelativeFile(String file) {
|
||||
return Paths.get(new File(getProject().getRootDir(), file).getAbsolutePath());
|
||||
}
|
||||
|
||||
protected Path getTemporaryFile(String file) {
|
||||
@@ -107,6 +120,10 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
}
|
||||
|
||||
protected Path getBuildFile(String file) {
|
||||
return getRelativeFile("build/libs/" + file);
|
||||
return getRelativeFile("libs/" + file);
|
||||
}
|
||||
|
||||
protected String addCompTypeFirst(String string) {
|
||||
return compType == null ? string : compType + "-" + string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.OpenOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -39,15 +41,16 @@ public class CreateDistTask extends BaritoneGradleTask {
|
||||
|
||||
@TaskAction
|
||||
protected void exec() throws Exception {
|
||||
super.doFirst();
|
||||
super.verifyArtifacts();
|
||||
|
||||
// Define the distribution file paths
|
||||
Path api = getRelativeFile("dist/" + getFileName(artifactApiPath));
|
||||
Path standalone = getRelativeFile("dist/" + getFileName(artifactStandalonePath));
|
||||
Path unoptimized = getRelativeFile("dist/" + getFileName(artifactUnoptimizedPath));
|
||||
Path api = getRootRelativeFile("dist/" + getFileName(artifactApiPath));
|
||||
Path standalone = getRootRelativeFile("dist/" + getFileName(artifactStandalonePath));
|
||||
Path unoptimized = getRootRelativeFile("dist/" + getFileName(artifactUnoptimizedPath));
|
||||
|
||||
// NIO will not automatically create directories
|
||||
Path dir = getRelativeFile("dist/");
|
||||
Path dir = getRootRelativeFile("dist/");
|
||||
if (!Files.exists(dir)) {
|
||||
Files.createDirectory(dir);
|
||||
}
|
||||
@@ -59,35 +62,21 @@ public class CreateDistTask extends BaritoneGradleTask {
|
||||
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
||||
|
||||
// Calculate all checksums and format them like "shasum"
|
||||
List<String> shasum = getAllDistJars().stream()
|
||||
.filter(Files::exists)
|
||||
List<String> shasum = Files.list(getRootRelativeFile("dist/"))
|
||||
.filter(e -> e.getFileName().toString().endsWith(".jar"))
|
||||
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
shasum.forEach(System.out::println);
|
||||
|
||||
// Write the checksums to a file
|
||||
Files.write(getRelativeFile("dist/checksums.txt"), shasum);
|
||||
Files.write(getRootRelativeFile("dist/checksums.txt"), shasum);
|
||||
}
|
||||
|
||||
private static String getFileName(Path p) {
|
||||
return p.getFileName().toString();
|
||||
}
|
||||
|
||||
private List<Path> getAllDistJars() {
|
||||
return Arrays.asList(
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_API)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_API)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_API)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_STANDALONE)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_STANDALONE)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_UNOPTIMIZED))
|
||||
);
|
||||
}
|
||||
|
||||
private static synchronized String sha1(Path path) {
|
||||
try {
|
||||
if (SHA1_DIGEST == null) {
|
||||
|
||||
@@ -26,8 +26,12 @@ import org.gradle.api.tasks.TaskCollection;
|
||||
import org.gradle.api.tasks.compile.ForkOptions;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
import org.gradle.internal.jvm.Jvm;
|
||||
import xyz.wagyourtail.unimined.api.Constants;
|
||||
import xyz.wagyourtail.unimined.api.minecraft.EnvType;
|
||||
import xyz.wagyourtail.unimined.api.minecraft.MinecraftProvider;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -59,22 +63,11 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
return extract;
|
||||
}
|
||||
|
||||
@Input
|
||||
private String compType;
|
||||
|
||||
public String getCompType() {
|
||||
return compType;
|
||||
}
|
||||
|
||||
private final File copyMcTargetDir = new File("./build/createMcIntermediaryJar").getAbsoluteFile();
|
||||
private final File copyMcTargetJar = new File(copyMcTargetDir, "client.jar");
|
||||
|
||||
@TaskAction
|
||||
protected void exec() throws Exception {
|
||||
super.doFirst();
|
||||
super.verifyArtifacts();
|
||||
|
||||
copyMcJar();
|
||||
|
||||
// "Haha brady why don't you make separate tasks"
|
||||
processArtifact();
|
||||
downloadProguard();
|
||||
@@ -85,30 +78,14 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private boolean isMcJar(File f) {
|
||||
return f.getName().startsWith(compType.equals("FORGE") ? "forge-" : "minecraft-") && f.getName().contains("minecraft-mapped");
|
||||
MinecraftProvider<?, ?> provider = this.getProject().getExtensions().getByType(MinecraftProvider.class);
|
||||
|
||||
private File getMcJar() {
|
||||
return provider.getMinecraftWithMapping(EnvType.COMBINED, provider.getMcPatcher().getProdNamespace(), provider.getMcPatcher().getProdFallbackNamespace()).toFile();
|
||||
}
|
||||
|
||||
private void copyMcJar() throws IOException {
|
||||
File mcClientJar = this.getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
|
||||
.stream()
|
||||
.filter(this::isMcJar)
|
||||
.map(f -> {
|
||||
switch (compType) {
|
||||
case "OFFICIAL":
|
||||
return new File(f.getParentFile().getParentFile(), "minecraft-merged.jar");
|
||||
case "FABRIC":
|
||||
return new File(f.getParentFile(), "minecraft-intermediary.jar");
|
||||
case "FORGE":
|
||||
return new File(f.getParentFile(), "minecraft-srg.jar");
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.findFirst()
|
||||
.get();
|
||||
if (!mcClientJar.exists()) throw new IOException("Failed to find minecraft! " + mcClientJar.getAbsolutePath());
|
||||
if (!copyMcTargetDir.exists() && !copyMcTargetDir.mkdirs()) throw new IOException("Failed to create target for copyMcJar");
|
||||
Files.copy(mcClientJar.toPath(), copyMcTargetJar.toPath(), REPLACE_EXISTING);
|
||||
private boolean isMcJar(File f) {
|
||||
return this.getProject().getConfigurations().getByName(Constants.MINECRAFT_COMBINED_PROVIDER).getFiles().contains(f);
|
||||
}
|
||||
|
||||
private void processArtifact() throws Exception {
|
||||
@@ -233,7 +210,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
}
|
||||
|
||||
private void generateConfigs() throws Exception {
|
||||
Files.copy(getRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
|
||||
Files.copy(getRootRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
|
||||
|
||||
// Setup the template that will be used to derive the API and Standalone configs
|
||||
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
|
||||
@@ -242,9 +219,17 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
|
||||
template.add(2, "-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)");
|
||||
template.add(3, "-libraryjars <java.home>/jmods/java.desktop.jmod(!**.jar;!module-info.class)");
|
||||
template.add(4, "-libraryjars <java.home>/jmods/jdk.unsupported.jmod(!**.jar;!module-info.class)");
|
||||
|
||||
{
|
||||
final Stream<File> libraries;
|
||||
File mcJar;
|
||||
try {
|
||||
mcJar = getMcJar();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to find Minecraft jar", e);
|
||||
}
|
||||
|
||||
{
|
||||
// Discover all of the libraries that we will need to acquire from gradle
|
||||
final Stream<File> dependencies = acquireDependencies()
|
||||
@@ -252,39 +237,41 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
.filter(f -> !f.toString().endsWith("-recomp.jar") && !f.getName().startsWith("nashorn") && !f.getName().startsWith("coremods"));
|
||||
|
||||
libraries = dependencies
|
||||
.map(f -> isMcJar(f) ? copyMcTargetJar : f);
|
||||
.map(f -> isMcJar(f) ? mcJar : f);
|
||||
}
|
||||
libraries.forEach(f -> {
|
||||
template.add(2, "-libraryjars '" + f + "'");
|
||||
});
|
||||
}
|
||||
|
||||
Files.createDirectories(this.getRootRelativeFile(PROGUARD_MAPPING_DIR));
|
||||
|
||||
List<String> api = new ArrayList<>(template);
|
||||
api.add(2, "-printmapping " + new File(this.getRootRelativeFile(PROGUARD_MAPPING_DIR).toFile(), "mappings-" + addCompTypeFirst("api.txt")));
|
||||
|
||||
// API config doesn't require any changes from the changes that we made to the template
|
||||
Files.write(getTemporaryFile(PROGUARD_API_CONFIG), template);
|
||||
Files.write(getTemporaryFile(compType+PROGUARD_API_CONFIG), api);
|
||||
|
||||
// For the Standalone config, don't keep the API package
|
||||
List<String> standalone = new ArrayList<>(template);
|
||||
standalone.removeIf(s -> s.contains("# this is the keep api"));
|
||||
Files.write(getTemporaryFile(PROGUARD_STANDALONE_CONFIG), standalone);
|
||||
}
|
||||
|
||||
private File getSrgMcJar() {
|
||||
return getProject().getTasks().findByName("copyMcJar").getOutputs().getFiles().getSingleFile();
|
||||
standalone.add(2, "-printmapping " + new File(this.getRootRelativeFile(PROGUARD_MAPPING_DIR).toFile(), "mappings-" + addCompTypeFirst("standalone.txt")));
|
||||
Files.write(getTemporaryFile(compType+PROGUARD_STANDALONE_CONFIG), standalone);
|
||||
}
|
||||
|
||||
private Stream<File> acquireDependencies() {
|
||||
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
|
||||
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("main").getCompileClasspath().getFiles()
|
||||
.stream()
|
||||
.filter(File::isFile);
|
||||
}
|
||||
|
||||
private void proguardApi() throws Exception {
|
||||
runProguard(getTemporaryFile(PROGUARD_API_CONFIG));
|
||||
runProguard(getTemporaryFile(compType+PROGUARD_API_CONFIG));
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString());
|
||||
}
|
||||
|
||||
private void proguardStandalone() throws Exception {
|
||||
runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG));
|
||||
runProguard(getTemporaryFile(compType+PROGUARD_STANDALONE_CONFIG));
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString());
|
||||
}
|
||||
|
||||
@@ -301,11 +288,6 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
public void setExtract(String extract) {
|
||||
this.extract = extract;
|
||||
}
|
||||
|
||||
public void setCompType(String compType) {
|
||||
this.compType = compType;
|
||||
}
|
||||
|
||||
private void runProguard(Path config) throws Exception {
|
||||
// Delete the existing proguard output file. Proguard probably handles this already, but why not do it ourselves
|
||||
if (Files.exists(this.proguardOut)) {
|
||||
|
||||
103
fabric/build.gradle
Normal file
103
fabric/build.gradle
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.0.0"
|
||||
}
|
||||
|
||||
archivesBaseName = archivesBaseName + "-fabric"
|
||||
|
||||
minecraft {
|
||||
fabric()
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
}
|
||||
|
||||
dependencies {
|
||||
fabric "net.fabricmc:fabric-loader:${project.fabric_version}"
|
||||
|
||||
// because of multiple sourcesets `common project(":")` doesn't work
|
||||
for (sourceSet in rootProject.sourceSets) {
|
||||
if (sourceSet == rootProject.sourceSets.test) continue
|
||||
if (sourceSet == rootProject.sourceSets.schematica_api) continue
|
||||
common sourceSet.output
|
||||
shadowCommon sourceSet.output
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
classifier "dev-shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
classifier null
|
||||
}
|
||||
|
||||
jar {
|
||||
classifier "dev"
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
|
||||
extract 'proguard-7.2.1/lib/proguard.jar'
|
||||
compType "fabric"
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard) {
|
||||
compType "fabric"
|
||||
}
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenFabric(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name + "-" + project.name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,11 @@
|
||||
"entrypoints": {
|
||||
},
|
||||
"mixins": [
|
||||
"mixins.baritone.json"
|
||||
"mixins.baritone.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.11.0",
|
||||
"minecraft": "1.18.x"
|
||||
"minecraft": "1.19.3"
|
||||
}
|
||||
}
|
||||
122
forge/build.gradle
Normal file
122
forge/build.gradle
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.0.0"
|
||||
}
|
||||
|
||||
archivesBaseName = archivesBaseName + "-forge"
|
||||
|
||||
minecraft {
|
||||
forge {
|
||||
devFallbackNamespace = "intermediary"
|
||||
mixinConfig = ["mixins.baritone.json"]
|
||||
}
|
||||
}
|
||||
|
||||
//loom {
|
||||
// forge {
|
||||
// mixinConfig 'mixins.baritone.json'
|
||||
// }
|
||||
//}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
}
|
||||
|
||||
dependencies {
|
||||
forge "net.minecraftforge:forge:${rootProject.forge_version}"
|
||||
|
||||
// because of multiple sourcesets `common project(":")` doesn't work
|
||||
for (sourceSet in rootProject.sourceSets) {
|
||||
if (sourceSet == rootProject.sourceSets.test) continue
|
||||
if (sourceSet == rootProject.sourceSets.schematica_api) continue
|
||||
common sourceSet.output
|
||||
shadowCommon sourceSet.output
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("META-INF/mods.toml") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
classifier "dev-shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
classifier null
|
||||
}
|
||||
|
||||
jar {
|
||||
classifier "dev"
|
||||
|
||||
manifest {
|
||||
attributes(
|
||||
'MixinConfigs': 'mixins.baritone.json',
|
||||
"MixinConnector": "baritone.launch.BaritoneMixinConnector",
|
||||
|
||||
'Implementation-Title': 'Baritone',
|
||||
'Implementation-Version': version,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
|
||||
extract 'proguard-7.2.1/lib/proguard.jar'
|
||||
compType "forge"
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard) {
|
||||
compType "forge"
|
||||
}
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenFabric(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name + "-" + project.name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
18
forge/gradle.properties
Normal file
18
forge/gradle.properties
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# This file is part of Baritone.
|
||||
#
|
||||
# Baritone is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Baritone is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
loom.platform=forge
|
||||
22
forge/src/main/java/baritone/launch/BaritoneForgeModXD.java
Normal file
22
forge/src/main/java/baritone/launch/BaritoneForgeModXD.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch;import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod("baritoe")
|
||||
public class BaritoneForgeModXD {
|
||||
}
|
||||
@@ -15,7 +15,7 @@ issueTrackerURL="https://github.com/cabaletta/baritone/issues" #optional
|
||||
# The modid of the mod
|
||||
modId="baritoe" #mandatory
|
||||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
version="${file.jarVersion}" #mandatory
|
||||
version="${version}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="Baritone" #mandatory
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
@@ -31,3 +31,10 @@ description='''
|
||||
A Minecraft pathfinder bot.
|
||||
'''
|
||||
|
||||
[[dependencies.baritoe]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="[1.19.3]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
6
forge/src/main/resources/pack.mcmeta
Normal file
6
forge/src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "null",
|
||||
"pack_format": 8
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
org.gradle.jvmargs=-Xmx2048M
|
||||
org.gradle.jvmargs=-Xmx4G
|
||||
|
||||
mod_version=1.8.3
|
||||
mod_version=1.9.1
|
||||
maven_group=baritone
|
||||
archives_base_name=baritone
|
||||
|
||||
minecraft_version=1.18.2
|
||||
forge_version=1.18.2-40.0.0
|
||||
fabric_version=0.13.1
|
||||
|
||||
# # un comment for forge debugging default (as opposed to fabric)
|
||||
# baritone.forge_build=true
|
||||
# loom.platform=forge
|
||||
minecraft_version=1.19.3
|
||||
forge_version=1.19.3-44.0.1
|
||||
fabric_version=0.14.11
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
4
jitpack.yml
Normal file
4
jitpack.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
before_install:
|
||||
- curl -s "https://get.sdkman.io" | bash
|
||||
- sdk install java 17.0.5-tem
|
||||
- sdk use java 17.0.5-tem
|
||||
4
scripts/proguard.pro
vendored
4
scripts/proguard.pro
vendored
@@ -339,6 +339,4 @@
|
||||
public int length();
|
||||
public java.lang.String substring(int);
|
||||
public java.lang.String substring(int,int);
|
||||
}
|
||||
|
||||
-printmapping mapping.txt
|
||||
}
|
||||
@@ -17,26 +17,35 @@
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven { url "https://maven.architectury.dev/" }
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = 'WagYourMaven'
|
||||
url = 'https://maven.wagyourtail.xyz/snapshots'
|
||||
}
|
||||
maven {
|
||||
name = 'ForgeMaven'
|
||||
url = 'https://maven.minecraftforge.net/'
|
||||
}
|
||||
maven {
|
||||
name = 'FabricMaven'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
maven {
|
||||
name = 'forge'
|
||||
url = 'https://files.minecraftforge.net/maven'
|
||||
}
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
maven {
|
||||
url = 'https://www.dogforce-games.com/maven/'
|
||||
}
|
||||
maven {
|
||||
url = 'https://libraries.minecraft.net/'
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal() {
|
||||
content {
|
||||
excludeGroup "org.apache.logging.log4j"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'baritone'
|
||||
|
||||
include("tweaker")
|
||||
if (System.getProperty("Baritone.enabled_platforms") == null) {
|
||||
System.setProperty("Baritone.enabled_platforms", "fabric,forge")
|
||||
// System.setProperty("Baritone.enabled_platforms", "fabric")
|
||||
}
|
||||
for (platform in System.getProperty("Baritone.enabled_platforms").split(",")) {
|
||||
include(platform)
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ import baritone.api.utils.TypeUtils;
|
||||
import baritone.api.utils.gui.BaritoneToast;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
@@ -19,11 +19,12 @@ 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.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum BlockById implements IDatatypeFor<Block> {
|
||||
INSTANCE;
|
||||
|
||||
@@ -31,7 +32,7 @@ public enum BlockById implements IDatatypeFor<Block> {
|
||||
public Block get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
Block block;
|
||||
if ((block = Registry.BLOCK.getOptional(id).orElse(null)) == null) {
|
||||
if ((block = BuiltInRegistries.BLOCK.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no block found by that id");
|
||||
}
|
||||
return block;
|
||||
@@ -41,7 +42,7 @@ public enum BlockById implements IDatatypeFor<Block> {
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(
|
||||
Registry.BLOCK.keySet()
|
||||
BuiltInRegistries.BLOCK.keySet()
|
||||
.stream()
|
||||
.map(Object::toString)
|
||||
)
|
||||
|
||||
@@ -19,11 +19,12 @@ 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.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum EntityClassById implements IDatatypeFor<EntityType> {
|
||||
INSTANCE;
|
||||
|
||||
@@ -31,7 +32,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
|
||||
public EntityType get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
EntityType entity;
|
||||
if ((entity = Registry.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
|
||||
if ((entity = BuiltInRegistries.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no entity found by that id");
|
||||
}
|
||||
return entity;
|
||||
@@ -40,7 +41,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(Registry.ENTITY_TYPE.stream().map(Object::toString))
|
||||
.append(BuiltInRegistries.ENTITY_TYPE.stream().map(Object::toString))
|
||||
.filterPrefixNamespaced(ctx.getConsumer().getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
|
||||
@@ -21,15 +21,16 @@ import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.Helper;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
public class Paginator<E> implements Helper {
|
||||
|
||||
@@ -74,7 +75,7 @@ public class Paginator<E> implements Helper {
|
||||
}
|
||||
boolean hasPrevPage = commandPrefix != null && validPage(page - 1);
|
||||
boolean hasNextPage = commandPrefix != null && validPage(page + 1);
|
||||
BaseComponent prevPageComponent = new TextComponent("<<");
|
||||
MutableComponent prevPageComponent = Component.literal("<<");
|
||||
if (hasPrevPage) {
|
||||
prevPageComponent.setStyle(prevPageComponent.getStyle()
|
||||
.withClickEvent(new ClickEvent(
|
||||
@@ -83,26 +84,23 @@ public class Paginator<E> implements Helper {
|
||||
))
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to view previous page")
|
||||
Component.literal("Click to view previous page")
|
||||
)));
|
||||
} else {
|
||||
prevPageComponent.setStyle(prevPageComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
|
||||
}
|
||||
BaseComponent nextPageComponent = new TextComponent(">>");
|
||||
MutableComponent nextPageComponent = Component.literal(">>");
|
||||
if (hasNextPage) {
|
||||
nextPageComponent.setStyle(nextPageComponent.getStyle()
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format("%s %d", commandPrefix, page + 1)
|
||||
))
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("%s %d", commandPrefix, page + 1)))
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to view next page")
|
||||
Component.literal("Click to view next page")
|
||||
)));
|
||||
} else {
|
||||
nextPageComponent.setStyle(nextPageComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
|
||||
}
|
||||
BaseComponent pagerComponent = new TextComponent("");
|
||||
MutableComponent pagerComponent = Component.literal("");
|
||||
pagerComponent.setStyle(pagerComponent.getStyle().withColor(ChatFormatting.GRAY));
|
||||
pagerComponent.append(prevPageComponent);
|
||||
pagerComponent.append(" | ");
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
|
||||
@@ -20,20 +20,29 @@ package baritone.api.utils;
|
||||
import baritone.api.utils.accessor.IItemStack;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import io.netty.util.concurrent.ThreadPerTaskExecutor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.*;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.packs.PackResources;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.server.packs.repository.Pack;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import net.minecraft.server.packs.*;
|
||||
import net.minecraft.server.packs.repository.ServerPacksSource;
|
||||
import net.minecraft.server.packs.resources.MultiPackResourceManager;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.CustomSpawner;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import net.minecraft.world.level.storage.ServerLevelData;
|
||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
@@ -41,9 +50,14 @@ import net.minecraft.world.level.storage.loot.PredicateManager;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.regex.MatchResult;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -55,7 +69,7 @@ public final class BlockOptionalMeta {
|
||||
private final ImmutableSet<Integer> stateHashes;
|
||||
private final ImmutableSet<Integer> stackHashes;
|
||||
private static final Pattern pattern = Pattern.compile("^(.+?)(?::(\\d+))?$");
|
||||
private static LootTables manager;
|
||||
private static LootTables lootTables;
|
||||
private static PredicateManager predicate = new PredicateManager();
|
||||
private static Map<Block, List<Item>> drops = new HashMap<>();
|
||||
|
||||
@@ -141,21 +155,37 @@ public final class BlockOptionalMeta {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Method getVanillaServerPack;
|
||||
|
||||
private static VanillaPackResources getVanillaServerPack() {
|
||||
if (getVanillaServerPack == null) {
|
||||
getVanillaServerPack = Arrays.stream(ServerPacksSource.class.getDeclaredMethods()).filter(field -> field.getReturnType() == VanillaPackResources.class).findFirst().orElseThrow();
|
||||
getVanillaServerPack.setAccessible(true);
|
||||
}
|
||||
|
||||
try {
|
||||
return (VanillaPackResources) getVanillaServerPack.invoke(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static LootTables getManager() {
|
||||
if (manager == null) {
|
||||
PackRepository rpl = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource());
|
||||
rpl.reload();
|
||||
PackResources thePack = rpl.getAvailablePacks().iterator().next().open();
|
||||
if (lootTables == null) {
|
||||
MultiPackResourceManager resources = new MultiPackResourceManager(PackType.SERVER_DATA, List.of(getVanillaServerPack()));
|
||||
ReloadableResourceManager resourceManager = new ReloadableResourceManager(PackType.SERVER_DATA);
|
||||
manager = new LootTables(predicate);
|
||||
resourceManager.registerReloadListener(manager);
|
||||
lootTables = new LootTables(predicate);
|
||||
resourceManager.registerReloadListener(lootTables);
|
||||
try {
|
||||
resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), Collections.singletonList(thePack)).done().get();
|
||||
resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), resources.listPacks().toList()).done().get();
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
}
|
||||
return manager;
|
||||
return lootTables;
|
||||
}
|
||||
|
||||
public static PredicateManager getPredicateManager() {
|
||||
@@ -169,20 +199,55 @@ public final class BlockOptionalMeta {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
List<Item> items = new ArrayList<>();
|
||||
|
||||
// the other overload for generate doesnt work in forge because forge adds code that requires a non null world
|
||||
getManager().get(lootTableLocation).getRandomItems(
|
||||
new LootContext.Builder((ServerLevel) null)
|
||||
.withRandom(new Random())
|
||||
.withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO))
|
||||
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
|
||||
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, null)
|
||||
.withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState())
|
||||
.create(LootContextParamSets.BLOCK),
|
||||
try {
|
||||
getManager().get(lootTableLocation).getRandomItems(
|
||||
new LootContext.Builder(ServerLevelStub.fastCreate())
|
||||
.withRandom(RandomSource.create())
|
||||
.withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO))
|
||||
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
|
||||
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, null)
|
||||
.withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState())
|
||||
.create(LootContextParamSets.BLOCK),
|
||||
stack -> items.add(stack.getItem())
|
||||
);
|
||||
);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class ServerLevelStub extends ServerLevel {
|
||||
private static Minecraft client = Minecraft.getInstance();
|
||||
private static Unsafe unsafe = getUnsafe();
|
||||
public ServerLevelStub(MinecraftServer $$0, Executor $$1, LevelStorageSource.LevelStorageAccess $$2, ServerLevelData $$3, ResourceKey<Level> $$4, LevelStem $$5, ChunkProgressListener $$6, boolean $$7, long $$8, List<CustomSpawner> $$9, boolean $$10) {
|
||||
super($$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureFlagSet enabledFeatures() {
|
||||
assert client.level != null;
|
||||
return client.level.enabledFeatures();
|
||||
}
|
||||
|
||||
public static ServerLevelStub fastCreate() {
|
||||
try {
|
||||
return (ServerLevelStub) unsafe.allocateInstance(ServerLevelStub.class);
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Unsafe getUnsafe() {
|
||||
try {
|
||||
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
theUnsafe.setAccessible(true);
|
||||
return (Unsafe) theUnsafe.get(null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.api.utils;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
@@ -28,7 +29,7 @@ public class BlockUtils {
|
||||
private static transient Map<String, Block> resourceCache = new HashMap<>();
|
||||
|
||||
public static String blockToString(Block block) {
|
||||
ResourceLocation loc = Registry.BLOCK.getKey(block);
|
||||
ResourceLocation loc = BuiltInRegistries.BLOCK.getKey(block);
|
||||
String name = loc.getPath(); // normally, only write the part after the minecraft:
|
||||
if (!loc.getNamespace().equals("minecraft")) {
|
||||
// Baritone is running on top of forge with mods installed, perhaps?
|
||||
@@ -56,7 +57,7 @@ public class BlockUtils {
|
||||
if (resourceCache.containsKey(name)) {
|
||||
return null; // cached as null
|
||||
}
|
||||
block = Registry.BLOCK.getOptional(ResourceLocation.tryParse(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
|
||||
block = BuiltInRegistries.BLOCK.getOptional(ResourceLocation.tryParse(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
|
||||
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
|
||||
copy.put(name, block);
|
||||
resourceCache = copy;
|
||||
|
||||
@@ -21,9 +21,10 @@ import baritone.api.BaritoneAPI;
|
||||
import baritone.api.utils.gui.BaritoneToast;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.stream.Stream;
|
||||
@@ -51,11 +52,11 @@ public interface Helper {
|
||||
// Inner text component
|
||||
final Calendar now = Calendar.getInstance();
|
||||
final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3;
|
||||
BaseComponent baritone = new TextComponent(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
|
||||
MutableComponent baritone = Component.literal(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
|
||||
baritone.setStyle(baritone.getStyle().withColor(ChatFormatting.LIGHT_PURPLE));
|
||||
|
||||
// Outer brackets
|
||||
BaseComponent prefix = new TextComponent("");
|
||||
MutableComponent prefix = Component.literal("");
|
||||
prefix.setStyle(baritone.getStyle().withColor(ChatFormatting.DARK_PURPLE));
|
||||
prefix.append("[");
|
||||
prefix.append(baritone);
|
||||
@@ -81,7 +82,7 @@ public interface Helper {
|
||||
* @param message The message to display in the popup
|
||||
*/
|
||||
default void logToast(String title, String message) {
|
||||
logToast(new TextComponent(title), new TextComponent(message));
|
||||
logToast(Component.literal(title), Component.literal(message));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +91,7 @@ public interface Helper {
|
||||
* @param message The message to display in the popup
|
||||
*/
|
||||
default void logToast(String message) {
|
||||
logToast(Helper.getPrefix(), new TextComponent(message));
|
||||
logToast(Helper.getPrefix(), Component.literal(message));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,9 +159,9 @@ public interface Helper {
|
||||
* @param components The components to send
|
||||
*/
|
||||
default void logDirect(boolean logAsToast, Component... components) {
|
||||
BaseComponent component = new TextComponent("");
|
||||
MutableComponent component = Component.literal("");
|
||||
component.append(getPrefix());
|
||||
component.append(new TextComponent(" "));
|
||||
component.append(Component.literal(" "));
|
||||
Arrays.asList(components).forEach(component::append);
|
||||
if (logAsToast) {
|
||||
logToast(getPrefix(), component);
|
||||
@@ -188,7 +189,7 @@ public interface Helper {
|
||||
*/
|
||||
default void logDirect(String message, ChatFormatting color, boolean logAsToast) {
|
||||
Stream.of(message.split("\n")).forEach(line -> {
|
||||
BaseComponent component = new TextComponent(line.replace("\t", " "));
|
||||
MutableComponent component = Component.literal(line.replace("\t", " "));
|
||||
component.setStyle(component.getStyle().withColor(color));
|
||||
logDirect(logAsToast, component);
|
||||
});
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -252,8 +253,8 @@ public class SettingsUtil {
|
||||
),
|
||||
ITEM(
|
||||
Item.class,
|
||||
str -> Registry.ITEM.get(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
|
||||
item -> Registry.ITEM.getKey(item).toString()
|
||||
str -> BuiltInRegistries.ITEM.get(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
|
||||
item -> BuiltInRegistries.ITEM.getKey(item).toString()
|
||||
),
|
||||
LIST() {
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.utils.accessor.IChunkArray;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@@ -27,24 +28,28 @@ import net.minecraft.world.level.chunk.LevelChunk;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.multiplayer.ClientChunkCache$Storage")
|
||||
public abstract class MixinChunkArray implements IChunkArray {
|
||||
@Final
|
||||
@Shadow
|
||||
private AtomicReferenceArray<LevelChunk> chunks;
|
||||
AtomicReferenceArray<LevelChunk> chunks;
|
||||
@Final
|
||||
@Shadow
|
||||
private int chunkRadius;
|
||||
int chunkRadius;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
private int viewRange;
|
||||
@Shadow
|
||||
private int viewCenterX;
|
||||
int viewCenterX;
|
||||
@Shadow
|
||||
private int viewCenterZ;
|
||||
int viewCenterZ;
|
||||
@Shadow
|
||||
private int chunkCount;
|
||||
int chunkCount;
|
||||
|
||||
@Shadow
|
||||
protected abstract boolean inRange(int x, int z);
|
||||
abstract boolean inRange(int x, int z);
|
||||
|
||||
@Shadow
|
||||
protected abstract int getIndex(int x, int z);
|
||||
abstract int getIndex(int x, int z);
|
||||
|
||||
@Shadow
|
||||
protected abstract void replace(int index, LevelChunk chunk);
|
||||
|
||||
@@ -20,14 +20,19 @@ package baritone.launch.mixins;
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.ChatEvent;
|
||||
import baritone.api.event.events.ChunkEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import baritone.cache.CachedChunk;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@@ -63,6 +68,25 @@ public class MixinClientPlayNetHandler {
|
||||
}
|
||||
}*/
|
||||
|
||||
@Shadow @Final private Minecraft minecraft;
|
||||
|
||||
@Inject(
|
||||
method = "sendChat(Ljava/lang/String;)V",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void sendChatMessage(String string, CallbackInfo ci) {
|
||||
ChatEvent event = new ChatEvent(string);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(this.minecraft.player);
|
||||
if (baritone == null) {
|
||||
return;
|
||||
}
|
||||
baritone.getGameEventHandler().onSendChatMessage(event);
|
||||
if (event.isCancelled()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "handleLevelChunkWithLight",
|
||||
at = @At("RETURN")
|
||||
|
||||
@@ -26,6 +26,7 @@ import baritone.api.event.events.type.EventState;
|
||||
import baritone.behavior.LookBehavior;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -40,23 +41,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(LocalPlayer.class)
|
||||
public class MixinClientPlayerEntity {
|
||||
|
||||
@Inject(
|
||||
method = "chat",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void sendChatMessage(String msg, CallbackInfo ci) {
|
||||
ChatEvent event = new ChatEvent(msg);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
|
||||
if (baritone == null) {
|
||||
return;
|
||||
}
|
||||
baritone.getGameEventHandler().onSendChatMessage(event);
|
||||
if (event.isCancelled()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "tick",
|
||||
at = @At(
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class MixinItemStack implements IItemStack {
|
||||
private int baritoneHash;
|
||||
|
||||
@Shadow
|
||||
protected abstract int getDamageValue();
|
||||
public abstract int getDamageValue();
|
||||
|
||||
private void recalculateHash() {
|
||||
baritoneHash = item == null ? -1 : item.hashCode() + getDamageValue();
|
||||
|
||||
@@ -26,6 +26,7 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.PacketSendListener;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@@ -53,14 +54,14 @@ public class MixinNetworkManager {
|
||||
method = "sendPacket",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
|
||||
private void preDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, CallbackInfo ci) {
|
||||
if (this.receiving != PacketFlow.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.PRE, inPacket));
|
||||
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.PRE, packet));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,14 +70,14 @@ public class MixinNetworkManager {
|
||||
method = "sendPacket",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
|
||||
private void postDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, CallbackInfo ci) {
|
||||
if (this.receiving != PacketFlow.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.POST, inPacket));
|
||||
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.POST, packet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,20 @@
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.ChatEvent;
|
||||
import baritone.utils.accessor.IGuiScreen;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import java.net.URI;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Screen.class)
|
||||
public abstract class MixinScreen implements IGuiScreen {
|
||||
@@ -30,4 +38,20 @@ public abstract class MixinScreen implements IGuiScreen {
|
||||
@Override
|
||||
@Invoker("openLink")
|
||||
public abstract void openLinkInvoker(URI url);
|
||||
|
||||
|
||||
//TODO: switch to enum extention with mixin 9.0 or whenever Mumfrey gets around to it
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false, ordinal = 1), method = "handleComponentClicked", cancellable = true)
|
||||
public void handleCustomClickEvent(Style style, CallbackInfoReturnable<Boolean> cir) {
|
||||
ClickEvent clickEvent = style.getClickEvent();
|
||||
if (clickEvent == null) {
|
||||
return;
|
||||
}
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||
if (baritone != null) {
|
||||
baritone.getGameEventHandler().onSendChatMessage(new ChatEvent(clickEvent.getValue()));
|
||||
}
|
||||
cir.setReturnValue(true);
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.RenderEvent;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
||||
Binary file not shown.
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "baritone.launch.mixins",
|
||||
"refmap": "mixins.baritone.refmap.json",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"verbose": false,
|
||||
"injectors": {
|
||||
"maxShiftBy": 2
|
||||
"maxShiftBy": 2,
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"client": [
|
||||
"MixinChunkArray",
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "baritoe",
|
||||
"pack_format": 5
|
||||
}
|
||||
}
|
||||
@@ -238,11 +238,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
if (current != null) {
|
||||
switch (event.getState()) {
|
||||
case PRE:
|
||||
lastAutoJump = mc.options.autoJump;
|
||||
mc.options.autoJump = false;
|
||||
lastAutoJump = mc.options.autoJump().get();
|
||||
mc.options.autoJump().set(false);
|
||||
break;
|
||||
case POST:
|
||||
mc.options.autoJump = lastAutoJump;
|
||||
mc.options.autoJump().set(lastAutoJump);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -25,10 +25,10 @@ import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.level.block.BedBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BedPart;
|
||||
@@ -70,12 +70,12 @@ public class WaypointBehavior extends Behavior {
|
||||
return;
|
||||
Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet());
|
||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint);
|
||||
BaseComponent component = new TextComponent("Death position saved.");
|
||||
MutableComponent component = Component.literal("Death position saved.");
|
||||
component.setStyle(component.getStyle()
|
||||
.withColor(ChatFormatting.WHITE)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to goto death")
|
||||
Component.literal("Click to goto death")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class CachedRegion implements ICachedRegion {
|
||||
/**
|
||||
* Magic value to detect invalid cache files, or incompatible cache files saved in an old version of Baritone
|
||||
*/
|
||||
private static final int CACHED_REGION_MAGIC = 456022910;
|
||||
private static final int CACHED_REGION_MAGIC = 456022911;
|
||||
|
||||
/**
|
||||
* All of the chunks in this region: A 32x32 array of them.
|
||||
@@ -166,7 +166,7 @@ public final class CachedRegion implements ICachedRegion {
|
||||
out.writeShort(entry.getValue().size());
|
||||
for (BlockPos pos : entry.getValue()) {
|
||||
out.writeByte((byte) (pos.getZ() << 4 | pos.getX()));
|
||||
out.writeByte((byte) (pos.getY()));
|
||||
out.writeInt(pos.getY()-dimension.minY());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,8 +270,8 @@ public final class CachedRegion implements ICachedRegion {
|
||||
byte xz = in.readByte();
|
||||
int X = xz & 0x0f;
|
||||
int Z = (xz >>> 4) & 0x0f;
|
||||
int Y = in.readByte() & 0xff;
|
||||
locs.add(new BlockPos(X, Y, Z));
|
||||
int Y = in.readInt();
|
||||
locs.add(new BlockPos(X, Y+dimension.minY(), Z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.PalettedContainer;
|
||||
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import java.util.*;
|
||||
@@ -82,7 +83,7 @@ public final class ChunkPacker {
|
||||
Block block = state.getBlock();
|
||||
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) {
|
||||
String name = BlockUtils.blockToString(block);
|
||||
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y, z));
|
||||
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y+chunk.getMinBuildHeight(), z));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,7 +172,7 @@ public final class ChunkPacker {
|
||||
if (dimension.ultraWarm()) {
|
||||
return Blocks.NETHERRACK.defaultBlockState();
|
||||
}
|
||||
if (dimension.createDragonFight()) {
|
||||
if (dimension.effectsLocation().equals(BuiltinDimensionTypes.END_EFFECTS)) {
|
||||
return Blocks.END_STONE.defaultBlockState();
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -35,10 +35,8 @@ import baritone.command.argument.CommandArguments;
|
||||
import baritone.command.manager.CommandManager;
|
||||
import baritone.utils.accessor.IGuiScreen;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.util.Tuple;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -78,12 +76,12 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
||||
if (settings.echoCommands.value) {
|
||||
String msg = command + rest;
|
||||
String toDisplay = settings.censorRanCommands.value ? command + " ..." : msg;
|
||||
BaseComponent component = new TextComponent(String.format("> %s", toDisplay));
|
||||
MutableComponent component = Component.literal(String.format("> %s", toDisplay));
|
||||
component.setStyle(component.getStyle()
|
||||
.withColor(ChatFormatting.WHITE)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to rerun command")
|
||||
Component.literal("Click to rerun command")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
|
||||
@@ -27,9 +27,11 @@ import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.cache.CachedChunk;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -53,10 +55,10 @@ public class FindCommand extends Command {
|
||||
toFind.add(args.getDatatypeFor(BlockById.INSTANCE));
|
||||
}
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
BaseComponent[] components = toFind.stream()
|
||||
Component[] components = toFind.stream()
|
||||
.flatMap(block ->
|
||||
ctx.worldData().getCachedWorld().getLocationsOf(
|
||||
Registry.BLOCK.getKey(block).getPath(),
|
||||
BuiltInRegistries.BLOCK.getKey(block).getPath(),
|
||||
Integer.MAX_VALUE,
|
||||
origin.x,
|
||||
origin.y,
|
||||
@@ -65,7 +67,7 @@ public class FindCommand extends Command {
|
||||
)
|
||||
.map(BetterBlockPos::new)
|
||||
.map(this::positionToComponent)
|
||||
.toArray(BaseComponent[]::new);
|
||||
.toArray(Component[]::new);
|
||||
if (components.length > 0) {
|
||||
Arrays.asList(components).forEach(this::logDirect);
|
||||
} else {
|
||||
@@ -73,11 +75,11 @@ public class FindCommand extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
private BaseComponent positionToComponent(BetterBlockPos pos) {
|
||||
private Component positionToComponent(BetterBlockPos pos) {
|
||||
String positionText = String.format("%s %s %s", pos.x, pos.y, pos.z);
|
||||
String command = String.format("%sgoal %s", FORCE_COMMAND_PREFIX, positionText);
|
||||
BaseComponent baseComponent = new TextComponent(pos.toString());
|
||||
BaseComponent hoverComponent = new TextComponent("Click to set goal to this position");
|
||||
MutableComponent baseComponent = Component.literal(pos.toString());
|
||||
MutableComponent hoverComponent = Component.literal("Click to set goal to this position");
|
||||
baseComponent.setStyle(baseComponent.getStyle()
|
||||
.withColor(ChatFormatting.GRAY)
|
||||
.withInsertion(positionText)
|
||||
@@ -91,7 +93,7 @@ public class FindCommand extends Command {
|
||||
return new TabCompleteHelper()
|
||||
.append(
|
||||
CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.stream()
|
||||
.map(Registry.BLOCK::getKey)
|
||||
.map(BuiltInRegistries.BLOCK::getKey)
|
||||
.map(Object::toString)
|
||||
)
|
||||
.filterPrefixNamespaced(args.getString())
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -84,7 +85,7 @@ public class FollowCommand extends Command {
|
||||
} else {
|
||||
logDirect("Following these types of entities:");
|
||||
classes.stream()
|
||||
.map(Registry.ENTITY_TYPE::getKey)
|
||||
.map(BuiltInRegistries.ENTITY_TYPE::getKey)
|
||||
.map(Objects::requireNonNull)
|
||||
.map(ResourceLocation::toString)
|
||||
.forEach(this::logDirect);
|
||||
|
||||
@@ -25,16 +25,18 @@ import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandNotFoundException;
|
||||
import baritone.api.command.helpers.Paginator;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
@@ -58,17 +60,17 @@ public class HelpCommand extends Command {
|
||||
command -> {
|
||||
String names = String.join("/", command.getNames());
|
||||
String name = command.getNames().get(0);
|
||||
TextComponent shortDescComponent = new TextComponent(" - " + command.getShortDesc());
|
||||
MutableComponent shortDescComponent = Component.literal(" - " + command.getShortDesc());
|
||||
shortDescComponent.setStyle(shortDescComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
|
||||
TextComponent namesComponent = new TextComponent(names);
|
||||
MutableComponent namesComponent = Component.literal(names);
|
||||
namesComponent.setStyle(namesComponent.getStyle().withColor(ChatFormatting.WHITE));
|
||||
TextComponent hoverComponent = new TextComponent("");
|
||||
MutableComponent hoverComponent = Component.literal("");
|
||||
hoverComponent.setStyle(hoverComponent.getStyle().withColor(ChatFormatting.GRAY));
|
||||
hoverComponent.append(namesComponent);
|
||||
hoverComponent.append("\n" + command.getShortDesc());
|
||||
hoverComponent.append("\n\nClick to view full help");
|
||||
String clickCommand = FORCE_COMMAND_PREFIX + String.format("%s %s", label, command.getNames().get(0));
|
||||
TextComponent component = new TextComponent(name);
|
||||
MutableComponent component = Component.literal(name);
|
||||
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
|
||||
component.append(shortDescComponent);
|
||||
component.setStyle(component.getStyle()
|
||||
@@ -88,7 +90,7 @@ public class HelpCommand extends Command {
|
||||
logDirect("");
|
||||
command.getLongDesc().forEach(this::logDirect);
|
||||
logDirect("");
|
||||
BaseComponent returnComponent = new TextComponent("Click to return to the help menu");
|
||||
MutableComponent returnComponent = Component.literal("Click to return to the help menu");
|
||||
returnComponent.setStyle(returnComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
FORCE_COMMAND_PREFIX + label
|
||||
|
||||
@@ -37,7 +37,7 @@ public class RenderCommand extends Command {
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
int renderDistance = (mc.options.renderDistance + 1) * 16;
|
||||
int renderDistance = (mc.options.renderDistance().get() + 1) * 16;
|
||||
mc.levelRenderer.setBlocksDirty(
|
||||
origin.x - renderDistance,
|
||||
0,
|
||||
|
||||
@@ -28,16 +28,17 @@ import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.helpers.Paginator;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
import static baritone.api.utils.SettingsUtil.*;
|
||||
@@ -77,19 +78,19 @@ public class SetCommand extends Command {
|
||||
: String.format("All %ssettings:", viewModified ? "modified " : "")
|
||||
),
|
||||
setting -> {
|
||||
TextComponent typeComponent = new TextComponent(String.format(
|
||||
MutableComponent typeComponent = Component.literal(String.format(
|
||||
" (%s)",
|
||||
settingTypeToString(setting)
|
||||
));
|
||||
typeComponent.setStyle(typeComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
|
||||
TextComponent hoverComponent = new TextComponent("");
|
||||
MutableComponent hoverComponent = Component.literal("");
|
||||
hoverComponent.setStyle(hoverComponent.getStyle().withColor(ChatFormatting.GRAY));
|
||||
hoverComponent.append(setting.getName());
|
||||
hoverComponent.append(String.format("\nType: %s", settingTypeToString(setting)));
|
||||
hoverComponent.append(String.format("\n\nValue:\n%s", settingValueToString(setting)));
|
||||
hoverComponent.append(String.format("\n\nDefault Value:\n%s", settingDefaultToString(setting)));
|
||||
String commandSuggestion = Baritone.settings().prefix.value + String.format("set %s ", setting.getName());
|
||||
TextComponent component = new TextComponent(setting.getName());
|
||||
MutableComponent component = Component.literal(setting.getName());
|
||||
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
|
||||
component.append(typeComponent);
|
||||
component.setStyle(component.getStyle()
|
||||
@@ -170,12 +171,12 @@ public class SetCommand extends Command {
|
||||
settingValueToString(setting)
|
||||
));
|
||||
}
|
||||
BaseComponent oldValueComponent = new TextComponent(String.format("Old value: %s", oldValue));
|
||||
MutableComponent oldValueComponent = Component.literal(String.format("Old value: %s", oldValue));
|
||||
oldValueComponent.setStyle(oldValueComponent.getStyle()
|
||||
.withColor(ChatFormatting.GRAY)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to set the setting back to this value")
|
||||
Component.literal("Click to set the setting back to this value")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
|
||||
@@ -40,11 +40,11 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
@@ -63,13 +63,13 @@ public class WaypointsCommand extends Command {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "an action");
|
||||
}
|
||||
BiFunction<IWaypoint, Action, Component> toComponent = (waypoint, _action) -> {
|
||||
BaseComponent component = new TextComponent("");
|
||||
BaseComponent tagComponent = new TextComponent(waypoint.getTag().name() + " ");
|
||||
MutableComponent component = Component.literal("");
|
||||
MutableComponent tagComponent = Component.literal(waypoint.getTag().name() + " ");
|
||||
tagComponent.setStyle(tagComponent.getStyle().withColor(ChatFormatting.GRAY));
|
||||
String name = waypoint.getName();
|
||||
BaseComponent nameComponent = new TextComponent(!name.isEmpty() ? name : "<empty>");
|
||||
MutableComponent nameComponent = Component.literal(!name.isEmpty() ? name : "<empty>");
|
||||
nameComponent.setStyle(nameComponent.getStyle().withColor(!name.isEmpty() ? ChatFormatting.GRAY : ChatFormatting.DARK_GRAY));
|
||||
BaseComponent timestamp = new TextComponent(" @ " + new Date(waypoint.getCreationTimestamp()));
|
||||
MutableComponent timestamp = Component.literal(" @ " + new Date(waypoint.getCreationTimestamp()));
|
||||
timestamp.setStyle(timestamp.getStyle().withColor(ChatFormatting.DARK_GRAY));
|
||||
component.append(tagComponent);
|
||||
component.append(nameComponent);
|
||||
@@ -77,7 +77,7 @@ public class WaypointsCommand extends Command {
|
||||
component.setStyle(component.getStyle()
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to select")
|
||||
Component.literal("Click to select")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
@@ -143,7 +143,7 @@ public class WaypointsCommand extends Command {
|
||||
args.requireMax(0);
|
||||
IWaypoint waypoint = new Waypoint(name, tag, pos);
|
||||
ForWaypoints.waypoints(this.baritone).addWaypoint(waypoint);
|
||||
BaseComponent component = new TextComponent("Waypoint added: ");
|
||||
MutableComponent component = Component.literal("Waypoint added: ");
|
||||
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
|
||||
component.append(toComponent.apply(waypoint, Action.INFO));
|
||||
logDirect(component);
|
||||
@@ -155,7 +155,7 @@ public class WaypointsCommand extends Command {
|
||||
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);
|
||||
}
|
||||
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).addAll(Arrays.<IWaypoint>asList(waypoints));
|
||||
BaseComponent textComponent = new TextComponent(String.format("Cleared %d waypoints, click to restore them", waypoints.length));
|
||||
MutableComponent textComponent = Component.literal(String.format("Cleared %d waypoints, click to restore them", waypoints.length));
|
||||
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
@@ -236,7 +236,7 @@ public class WaypointsCommand extends Command {
|
||||
if (action == Action.INFO) {
|
||||
logDirect(transform.apply(waypoint));
|
||||
logDirect(String.format("Position: %s", waypoint.getLocation()));
|
||||
BaseComponent deleteComponent = new TextComponent("Click to delete this waypoint");
|
||||
MutableComponent deleteComponent = Component.literal("Click to delete this waypoint");
|
||||
deleteComponent.setStyle(deleteComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
@@ -247,7 +247,7 @@ public class WaypointsCommand extends Command {
|
||||
waypoint.getCreationTimestamp()
|
||||
)
|
||||
)));
|
||||
BaseComponent goalComponent = new TextComponent("Click to set goal to this waypoint");
|
||||
MutableComponent goalComponent = Component.literal("Click to set goal to this waypoint");
|
||||
goalComponent.setStyle(goalComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
@@ -258,7 +258,7 @@ public class WaypointsCommand extends Command {
|
||||
waypoint.getCreationTimestamp()
|
||||
)
|
||||
)));
|
||||
BaseComponent recreateComponent = new TextComponent("Click to show a command to recreate this waypoint");
|
||||
MutableComponent recreateComponent = Component.literal("Click to show a command to recreate this waypoint");
|
||||
recreateComponent.setStyle(recreateComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.SUGGEST_COMMAND,
|
||||
String.format(
|
||||
@@ -272,7 +272,7 @@ public class WaypointsCommand extends Command {
|
||||
waypoint.getLocation().z
|
||||
)
|
||||
)));
|
||||
BaseComponent backComponent = new TextComponent("Click to return to the waypoints list");
|
||||
MutableComponent backComponent = Component.literal("Click to return to the waypoints list");
|
||||
backComponent.setStyle(backComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
@@ -288,7 +288,7 @@ public class WaypointsCommand extends Command {
|
||||
} else if (action == Action.DELETE) {
|
||||
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);
|
||||
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).add(waypoint);
|
||||
TextComponent textComponent = new TextComponent("That waypoint has successfully been deleted, click to restore it");
|
||||
MutableComponent textComponent = Component.literal("That waypoint has successfully been deleted, click to restore it");
|
||||
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
|
||||
@@ -532,7 +532,6 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
}
|
||||
if (!state.getFluidState().isEmpty()) {
|
||||
// used for frostwalker so only includes blocks where we are still on ground when leaving them to any side
|
||||
// TODO 1.19+ : add leaves, add dripleaf?
|
||||
if (block instanceof SlabBlock) {
|
||||
if (state.getValue(SlabBlock.TYPE) != SlabType.BOTTOM) {
|
||||
return true;
|
||||
@@ -551,6 +550,8 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
}
|
||||
} else if (block == Blocks.SCAFFOLDING) {
|
||||
return true;
|
||||
} else if (block instanceof LeavesBlock) {
|
||||
return true;
|
||||
}
|
||||
if (context.assumeWalkOnWater) {
|
||||
return false;
|
||||
@@ -723,7 +724,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|
||||
static boolean isBlockNormalCube(BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof BambooBlock
|
||||
if (block instanceof BambooStalkBlock
|
||||
|| block instanceof MovingPistonBlock
|
||||
|| block instanceof ScaffoldingBlock
|
||||
|| block instanceof ShulkerBoxBlock
|
||||
|
||||
@@ -24,21 +24,22 @@ import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.Helper;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector4f;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -53,7 +54,7 @@ public class GuiClick extends Screen implements Helper {
|
||||
private BlockPos currentMouseOver;
|
||||
|
||||
public GuiClick() {
|
||||
super(new TextComponent("CLICK"));
|
||||
super(Component.literal("CLICK"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,6 +80,7 @@ public class GuiClick extends Screen implements Helper {
|
||||
HitResult result = player.level.clip(new ClipContext(near.add(viewerPos), far.add(viewerPos), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player));
|
||||
if (result != null && result.getType() == HitResult.Type.BLOCK) {
|
||||
currentMouseOver = ((BlockHitResult) result).getBlockPos();
|
||||
System.out.println("currentMouseOver = " + currentMouseOver);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +92,7 @@ public class GuiClick extends Screen implements Helper {
|
||||
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().removeAllSelections();
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().addSelection(BetterBlockPos.from(clickStart), BetterBlockPos.from(currentMouseOver));
|
||||
BaseComponent component = new TextComponent("Selection made! For usage: " + Baritone.settings().prefix.value + "help sel");
|
||||
MutableComponent component = Component.literal("Selection made! For usage: " + Baritone.settings().prefix.value + "help sel");
|
||||
component.setStyle(component.getStyle()
|
||||
.withColor(ChatFormatting.WHITE)
|
||||
.withClickEvent(new ClickEvent(
|
||||
@@ -117,8 +119,8 @@ public class GuiClick extends Screen implements Helper {
|
||||
}
|
||||
|
||||
public void onRender(PoseStack modelViewStack, Matrix4f projectionMatrix) {
|
||||
this.projectionViewMatrix = projectionMatrix.copy();
|
||||
this.projectionViewMatrix.multiply(modelViewStack.last().pose());
|
||||
this.projectionViewMatrix = new Matrix4f(projectionMatrix);
|
||||
this.projectionViewMatrix.mul(modelViewStack.last().pose());
|
||||
this.projectionViewMatrix.invert();
|
||||
|
||||
if (currentMouseOver != null) {
|
||||
@@ -157,12 +159,13 @@ public class GuiClick extends Screen implements Helper {
|
||||
y = y * 2 - 1;
|
||||
|
||||
Vector4f pos = new Vector4f((float) x, (float) y, (float) z, 1.0F);
|
||||
pos.transform(this.projectionViewMatrix);
|
||||
projectionViewMatrix.transform(pos);
|
||||
|
||||
if (pos.w() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
pos.perspectiveDivide();
|
||||
pos.mul(1/pos.w());
|
||||
return new Vec3(pos.x(), pos.y(), pos.z());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ import baritone.api.utils.Helper;
|
||||
import baritone.utils.accessor.IEntityRenderManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import java.awt.*;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -45,6 +44,7 @@ import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PlayerMovementInput extends net.minecraft.client.player.Input {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(boolean p_225607_1_) {
|
||||
public void tick(boolean p_225607_1_, float f) {
|
||||
this.leftImpulse = 0.0F;
|
||||
this.forwardImpulse = 0.0F;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class Avoidance {
|
||||
if (mobCoeff != 1.0D) {
|
||||
ctx.entitiesStream()
|
||||
.filter(entity -> entity instanceof Mob)
|
||||
.filter(entity -> (!(entity instanceof Spider)) || ctx.player().getBrightness() < 0.5)
|
||||
.filter(entity -> (!(entity instanceof Spider)) || ctx.player().getLightLevelDependentMagicValue() < 0.5)
|
||||
.filter(entity -> !(entity instanceof ZombifiedPiglin) || ((ZombifiedPiglin) entity).getLastHurtByMob() != null)
|
||||
.filter(entity -> !(entity instanceof EnderMan) || ((EnderMan) entity).isCreepy())
|
||||
.forEach(entity -> res.add(new Avoidance(entity.blockPosition(), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
|
||||
|
||||
@@ -76,12 +76,12 @@ public enum PrimaryPlayerController implements IPlayerController, Helper {
|
||||
@Override
|
||||
public InteractionResult processRightClickBlock(LocalPlayer player, Level world, InteractionHand hand, BlockHitResult result) {
|
||||
// primaryplayercontroller is always in a ClientWorld so this is ok
|
||||
return mc.gameMode.useItemOn(player, (ClientLevel) world, hand, result);
|
||||
return mc.gameMode.useItemOn(player, hand, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult processRightClick(LocalPlayer player, Level world, InteractionHand hand) {
|
||||
return mc.gameMode.useItem(player, world, hand);
|
||||
return mc.gameMode.useItem(player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.utils.schematic.format.defaults;
|
||||
import baritone.utils.schematic.StaticSchematic;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -93,7 +94,7 @@ public final class LitematicaSchematic extends StaticSchematic {
|
||||
BlockState[] blockList = new BlockState[blockStatePalette.size()];
|
||||
|
||||
for (int i = 0; i < blockStatePalette.size(); i++) {
|
||||
Block block = Registry.BLOCK.get(new ResourceLocation((((CompoundTag) blockStatePalette.get(i)).getString("Name"))));
|
||||
Block block = BuiltInRegistries.BLOCK.get(new ResourceLocation((((CompoundTag) blockStatePalette.get(i)).getString("Name"))));
|
||||
CompoundTag properties = ((CompoundTag) blockStatePalette.get(i)).getCompound("Properties");
|
||||
|
||||
blockList[i] = getBlockState(block, properties);
|
||||
|
||||
@@ -19,6 +19,7 @@ package baritone.utils.schematic.format.defaults;
|
||||
|
||||
import baritone.utils.schematic.StaticSchematic;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.datafix.fixes.ItemIdFix;
|
||||
@@ -62,7 +63,7 @@ public final class MCEditSchematic extends StaticSchematic {
|
||||
// additional is 0 through 15 inclusive since it's & 0xF above
|
||||
blockID |= additional[blockInd] << 8;
|
||||
}
|
||||
Block block = Registry.BLOCK.get(ResourceLocation.tryParse(ItemIdFix.getItem(blockID)));
|
||||
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.tryParse(ItemIdFix.getItem(blockID)));
|
||||
// int meta = metadata[blockInd] & 0xFF;
|
||||
// this.states[x][z][y] = block.getStateFromMeta(meta);
|
||||
this.states[x][z][y] = block.defaultBlockState();
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.Optional;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -106,7 +107,7 @@ public final class SpongeSchematic extends StaticSchematic {
|
||||
|
||||
private BlockState deserialize() {
|
||||
if (this.blockState == null) {
|
||||
Block block = Registry.BLOCK.get(this.resourceLocation);
|
||||
Block block = BuiltInRegistries.BLOCK.get(this.resourceLocation);
|
||||
this.blockState = block.defaultBlockState();
|
||||
|
||||
this.properties.keySet().stream().sorted(String::compareTo).forEachOrdered(key -> {
|
||||
|
||||
118
tweaker/build.gradle
Normal file
118
tweaker/build.gradle
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
//import baritone.gradle.task.TweakerJsonAssembler
|
||||
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.0.0"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
runs.client = {
|
||||
mainClass = "net.minecraft.launchwrapper.Launch"
|
||||
args.addAll(["--tweakClass", "baritone.launch.BaritoneTweaker"])
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.spongepowered:mixin:0.8.5"
|
||||
|
||||
// for some reason mixin isn't including these...
|
||||
implementation "org.ow2.asm:asm:9.3"
|
||||
implementation "org.ow2.asm:asm-tree:9.3"
|
||||
implementation "org.ow2.asm:asm-commons:9.3"
|
||||
implementation "org.ow2.asm:asm-util:9.3"
|
||||
implementation "org.ow2.asm:asm-analysis:9.3"
|
||||
|
||||
|
||||
implementation 'com.github.ImpactDevelopment:SimpleTweaker:1.2'
|
||||
implementation('net.minecraft:launchwrapper:of-2.3') {
|
||||
exclude module: 'lwjgl'
|
||||
exclude module: 'asm-debug-all'
|
||||
}
|
||||
|
||||
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
|
||||
|
||||
// because of multiple sourcesets `common project(":")` doesn't work
|
||||
for (sourceSet in rootProject.sourceSets) {
|
||||
if (sourceSet == rootProject.sourceSets.test) continue
|
||||
if (sourceSet == rootProject.sourceSets.schematica_api) continue
|
||||
common sourceSet.output
|
||||
shadowCommon sourceSet.output
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
classifier "dev-shadow"
|
||||
}
|
||||
|
||||
|
||||
remapJar {
|
||||
inputFile.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
classifier null
|
||||
}
|
||||
|
||||
jar {
|
||||
classifier "dev"
|
||||
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
|
||||
manifest {
|
||||
attributes(
|
||||
'MixinConfigs': 'mixins.baritone.json',
|
||||
"MixinConnector": "baritone.launch.BaritoneMixinConnector",
|
||||
|
||||
'Implementation-Title': 'Baritone',
|
||||
'Implementation-Version': version,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
|
||||
extract 'proguard-7.2.1/lib/proguard.jar'
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenCommon(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user