Compare commits
17 Commits
v0.2.0-bet
...
v0.2.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d3b4a52a6 | ||
|
|
a746449be8 | ||
|
|
13948cdf26 | ||
|
|
ac0c7deb43 | ||
|
|
16c8398d8a | ||
|
|
661ef813bb | ||
|
|
cf1d26a73c | ||
|
|
0cbff02a1c | ||
|
|
ce4ee767fe | ||
|
|
d31b15122f | ||
|
|
ca931e842b | ||
|
|
c2cf985899 | ||
|
|
d270cf06d9 | ||
|
|
09735958c0 | ||
|
|
6ec14ff755 | ||
|
|
18e872ad12 | ||
|
|
13c6499854 |
10
build.gradle
10
build.gradle
@@ -3,7 +3,7 @@ import me.modmuss50.mpp.ReleaseType
|
|||||||
plugins {
|
plugins {
|
||||||
id("java-library")
|
id("java-library")
|
||||||
id("net.neoforged.moddev")
|
id("net.neoforged.moddev")
|
||||||
id("me.modmuss50.mod-publish-plugin") version "0.8.1" apply false
|
id("me.modmuss50.mod-publish-plugin") version "0.8.4" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions.create("runConfigCommon", RunConfigCommon.class)
|
extensions.create("runConfigCommon", RunConfigCommon.class)
|
||||||
@@ -68,19 +68,19 @@ allprojects {
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url "https://repo.papermc.io/repository/maven-public/"
|
url = "https://repo.papermc.io/repository/maven-public/"
|
||||||
mavenContent {
|
mavenContent {
|
||||||
includeGroup("ca.spottedleaf")
|
includeGroup("ca.spottedleaf")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
url "https://api.modrinth.com/maven"
|
url = "https://api.modrinth.com/maven"
|
||||||
mavenContent {
|
mavenContent {
|
||||||
includeGroup("maven.modrinth")
|
includeGroup("maven.modrinth")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maven { url "https://maven.shedaniel.me/" }
|
maven { url = "https://maven.shedaniel.me/" }
|
||||||
maven { url "https://maven.terraformersmc.com/releases/" }
|
maven { url = "https://maven.terraformersmc.com/releases/" }
|
||||||
}
|
}
|
||||||
|
|
||||||
// make build reproducible
|
// make build reproducible
|
||||||
|
|||||||
@@ -2,11 +2,17 @@ import dev.architectury.at.AccessChange;
|
|||||||
import dev.architectury.at.AccessTransform;
|
import dev.architectury.at.AccessTransform;
|
||||||
import dev.architectury.at.AccessTransformSet;
|
import dev.architectury.at.AccessTransformSet;
|
||||||
import dev.architectury.at.ModifierChange;
|
import dev.architectury.at.ModifierChange;
|
||||||
|
import dev.architectury.at.io.AccessTransformFormat;
|
||||||
import dev.architectury.at.io.AccessTransformFormats;
|
import dev.architectury.at.io.AccessTransformFormats;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.fabricmc.accesswidener.AccessWidenerReader;
|
import net.fabricmc.accesswidener.AccessWidenerReader;
|
||||||
import net.fabricmc.accesswidener.AccessWidenerVisitor;
|
import net.fabricmc.accesswidener.AccessWidenerVisitor;
|
||||||
@@ -66,12 +72,29 @@ public abstract class Aw2AtTask extends DefaultTask {
|
|||||||
final AccessTransformSet accessTransformSet = toAccessTransformSet(reader);
|
final AccessTransformSet accessTransformSet = toAccessTransformSet(reader);
|
||||||
Files.deleteIfExists(this.getOutputFile().get().getAsFile().toPath());
|
Files.deleteIfExists(this.getOutputFile().get().getAsFile().toPath());
|
||||||
Files.createDirectories(this.getOutputFile().get().getAsFile().toPath().getParent());
|
Files.createDirectories(this.getOutputFile().get().getAsFile().toPath().getParent());
|
||||||
AccessTransformFormats.FML.write(this.getOutputFile().get().getAsFile().toPath(), accessTransformSet);
|
writeLF(AccessTransformFormats.FML, this.getOutputFile().get().getAsFile().toPath(), accessTransformSet);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void writeLF(final AccessTransformFormat format, final Path path, final AccessTransformSet at) throws IOException {
|
||||||
|
final StringWriter stringWriter = new StringWriter();
|
||||||
|
final BufferedWriter writer = new BufferedWriter(stringWriter);
|
||||||
|
format.write(writer, at);
|
||||||
|
writer.close();
|
||||||
|
final List<String> lines = Arrays.stream(stringWriter.toString()
|
||||||
|
// unify line endings
|
||||||
|
.replace("\r\n", "\n")
|
||||||
|
.split("\n"))
|
||||||
|
// skip blank lines
|
||||||
|
.filter(it -> !it.isBlank())
|
||||||
|
// sort
|
||||||
|
.sorted()
|
||||||
|
.toList();
|
||||||
|
Files.writeString(path, String.join("\n", lines));
|
||||||
|
}
|
||||||
|
|
||||||
// Below methods are heavily based on architectury-loom Aw2At class (MIT licensed)
|
// Below methods are heavily based on architectury-loom Aw2At class (MIT licensed)
|
||||||
/*
|
/*
|
||||||
MIT License
|
MIT License
|
||||||
@@ -98,8 +121,7 @@ public abstract class Aw2AtTask extends DefaultTask {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public static AccessTransformSet toAccessTransformSet(final BufferedReader reader) throws IOException {
|
public static AccessTransformSet toAccessTransformSet(final BufferedReader reader) throws IOException {
|
||||||
// TODO: Remove copied classes once https://github.com/architectury/at/pull/1 is released
|
AccessTransformSet atSet = AccessTransformSet.create();
|
||||||
AccessTransformSet atSet = new at.AccessTransformSetImpl();
|
|
||||||
|
|
||||||
new AccessWidenerReader(new AccessWidenerVisitor() {
|
new AccessWidenerReader(new AccessWidenerVisitor() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2023 Architectury
|
|
||||||
* Copyright (c) 2018 Minecrell (https://github.com/Minecrell)
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package at;
|
|
||||||
|
|
||||||
import dev.architectury.at.AccessTransformSet;
|
|
||||||
import net.fabricmc.mappingio.tree.MappingTreeView;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class AccessTransformSetImpl implements AccessTransformSet {
|
|
||||||
|
|
||||||
private final Map<String, Class> classes = new LinkedHashMap<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Class> getClasses() {
|
|
||||||
return Collections.unmodifiableMap(this.classes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Class> getClass(String name) {
|
|
||||||
Objects.requireNonNull(name, "name");
|
|
||||||
return Optional.ofNullable(this.classes.get(name.replace('.', '/')));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class getOrCreateClass(String name) {
|
|
||||||
Objects.requireNonNull(name, "name");
|
|
||||||
return this.classes.computeIfAbsent(name.replace('.', '/'), n -> new ClassAccessTransformSetImpl(this, n));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Class> removeClass(String name) {
|
|
||||||
Objects.requireNonNull(name, "name");
|
|
||||||
return Optional.ofNullable(this.classes.remove(name.replace('.', '/')));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransformSet remap(MappingTreeView mappings, String from, String to) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void merge(AccessTransformSet other) {
|
|
||||||
other.getClasses().forEach((name, classSet) -> getOrCreateClass(name).merge(classSet));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(o instanceof AccessTransformSetImpl)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
AccessTransformSetImpl that = (AccessTransformSetImpl) o;
|
|
||||||
return this.classes.equals(that.classes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return this.classes.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "AccessTransformSet{" + classes + '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,256 +0,0 @@
|
|||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2023 Architectury
|
|
||||||
* Copyright (c) 2018 Minecrell (https://github.com/Minecrell)
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package at;
|
|
||||||
|
|
||||||
import dev.architectury.at.AccessTransform;
|
|
||||||
import dev.architectury.at.AccessTransformSet;
|
|
||||||
import org.cadixdev.bombe.analysis.InheritanceProvider;
|
|
||||||
import org.cadixdev.bombe.type.signature.MethodSignature;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.StringJoiner;
|
|
||||||
|
|
||||||
class ClassAccessTransformSetImpl implements AccessTransformSet.Class {
|
|
||||||
|
|
||||||
private final AccessTransformSet parent;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
private AccessTransform classTransform = AccessTransform.EMPTY;
|
|
||||||
private AccessTransform allFields = AccessTransform.EMPTY;
|
|
||||||
private AccessTransform allMethods = AccessTransform.EMPTY;
|
|
||||||
|
|
||||||
private final Map<String, AccessTransform> fields = new LinkedHashMap<>();
|
|
||||||
private final Map<MethodSignature, AccessTransform> methods = new LinkedHashMap<>();
|
|
||||||
|
|
||||||
private boolean complete;
|
|
||||||
|
|
||||||
ClassAccessTransformSetImpl(AccessTransformSet parent, String name) {
|
|
||||||
this.parent = parent;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransformSet getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform get() {
|
|
||||||
return this.classTransform;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform merge(AccessTransform transform) {
|
|
||||||
return this.classTransform = this.classTransform.merge(transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform replace(AccessTransform transform) {
|
|
||||||
return this.classTransform = Objects.requireNonNull(transform, "transform");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform allFields() {
|
|
||||||
return this.allFields;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform mergeAllFields(AccessTransform transform) {
|
|
||||||
return this.allFields = this.allFields.merge(transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform replaceAllFields(AccessTransform transform) {
|
|
||||||
return this.allFields = Objects.requireNonNull(transform, "transform");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform allMethods() {
|
|
||||||
return this.allMethods;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform mergeAllMethods(AccessTransform transform) {
|
|
||||||
return this.allMethods = this.allMethods.merge(transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform replaceAllMethods(AccessTransform transform) {
|
|
||||||
return this.allMethods = Objects.requireNonNull(transform, "transform");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, AccessTransform> getFields() {
|
|
||||||
return Collections.unmodifiableMap(this.fields);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform getField(String name) {
|
|
||||||
return this.fields.getOrDefault(Objects.requireNonNull(name, "name"), this.allFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform mergeField(String name, AccessTransform transform) {
|
|
||||||
Objects.requireNonNull(name, "name");
|
|
||||||
Objects.requireNonNull(transform, "transform");
|
|
||||||
|
|
||||||
if (transform.isEmpty()) {
|
|
||||||
return this.fields.getOrDefault(name, AccessTransform.EMPTY);
|
|
||||||
}
|
|
||||||
return this.fields.merge(name, transform, AccessTransform::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform replaceField(String name, AccessTransform transform) {
|
|
||||||
Objects.requireNonNull(name, "name");
|
|
||||||
Objects.requireNonNull(transform, "transform");
|
|
||||||
|
|
||||||
if (transform.isEmpty()) {
|
|
||||||
return this.fields.remove(name);
|
|
||||||
}
|
|
||||||
return this.fields.put(name, transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<MethodSignature, AccessTransform> getMethods() {
|
|
||||||
return Collections.unmodifiableMap(this.methods);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform getMethod(MethodSignature signature) {
|
|
||||||
return this.methods.getOrDefault(Objects.requireNonNull(signature, "signature"), this.allMethods);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform mergeMethod(MethodSignature signature, AccessTransform transform) {
|
|
||||||
Objects.requireNonNull(signature, "signature");
|
|
||||||
Objects.requireNonNull(transform, "transform");
|
|
||||||
|
|
||||||
if (transform.isEmpty()) {
|
|
||||||
return this.methods.getOrDefault(signature, AccessTransform.EMPTY);
|
|
||||||
}
|
|
||||||
return this.methods.merge(signature, transform, AccessTransform::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessTransform replaceMethod(MethodSignature signature, AccessTransform transform) {
|
|
||||||
Objects.requireNonNull(signature, "signature");
|
|
||||||
Objects.requireNonNull(transform, "transform");
|
|
||||||
|
|
||||||
if (transform.isEmpty()) {
|
|
||||||
return this.methods.remove(signature);
|
|
||||||
}
|
|
||||||
return this.methods.put(signature, transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void merge(AccessTransformSet.Class other) {
|
|
||||||
Objects.requireNonNull(other, "other");
|
|
||||||
|
|
||||||
merge(other.get());
|
|
||||||
mergeAllFields(other.allFields());
|
|
||||||
mergeAllMethods(other.allMethods());
|
|
||||||
|
|
||||||
other.getFields().forEach(this::mergeField);
|
|
||||||
other.getMethods().forEach(this::mergeMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isComplete() {
|
|
||||||
return this.complete;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void complete(InheritanceProvider provider, InheritanceProvider.ClassInfo info) {
|
|
||||||
if (this.complete) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (InheritanceProvider.ClassInfo parent : info.provideParents(provider)) {
|
|
||||||
AccessTransformSet.Class parentAts = getParent().getOrCreateClass(parent.getName());
|
|
||||||
parentAts.complete(provider, parent);
|
|
||||||
|
|
||||||
parentAts.getMethods().forEach((signature, transform) -> {
|
|
||||||
if (info.overrides(signature, parent)) {
|
|
||||||
mergeMethod(signature, transform);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.complete = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(o instanceof ClassAccessTransformSetImpl)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClassAccessTransformSetImpl that = (ClassAccessTransformSetImpl) o;
|
|
||||||
return this.classTransform.equals(that.classTransform) &&
|
|
||||||
this.allFields.equals(that.allFields) &&
|
|
||||||
this.allMethods.equals(that.allMethods) &&
|
|
||||||
this.fields.equals(that.fields) &&
|
|
||||||
this.methods.equals(that.methods);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(this.classTransform, this.allFields, this.allMethods, this.fields, this.methods);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringJoiner joiner = new StringJoiner(", ", "AccessTransformSet.Class{", "}");
|
|
||||||
if (!this.classTransform.isEmpty()) {
|
|
||||||
joiner.add(this.classTransform.toString());
|
|
||||||
}
|
|
||||||
if (!this.allFields.isEmpty()) {
|
|
||||||
joiner.add("allFields=" + this.allFields);
|
|
||||||
}
|
|
||||||
if (!this.allMethods.isEmpty()) {
|
|
||||||
joiner.add("allMethods=" + this.allMethods);
|
|
||||||
}
|
|
||||||
if (!this.fields.isEmpty()) {
|
|
||||||
joiner.add("fields=" + this.fields);
|
|
||||||
}
|
|
||||||
if (!this.methods.isEmpty()) {
|
|
||||||
joiner.add("method=" + this.methods);
|
|
||||||
}
|
|
||||||
return joiner.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,16 +2,17 @@
|
|||||||
org.gradle.jvmargs=-Xmx2G
|
org.gradle.jvmargs=-Xmx2G
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
|
org.gradle.configuration-cache=true
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://modmuss50.me/fabric.html
|
# check these on https://modmuss50.me/fabric.html
|
||||||
minecraft_version=1.21.4
|
minecraft_version=1.21.4
|
||||||
loader_version=0.16.9
|
loader_version=0.16.9
|
||||||
supported_minecraft_versions=1.21.4
|
supported_minecraft_versions=1.21.4
|
||||||
neoforge_version=21.4.0-beta
|
neoforge_version=21.4.33-beta
|
||||||
neoform_version=1.21.4-20241203.161809
|
neoform_version=1.21.4-20241203.161809
|
||||||
fabric_api_version=0.110.5+1.21.4
|
fabric_api_version=0.110.5+1.21.4
|
||||||
snakeyaml_version=2.3
|
snakeyaml_version=2.3
|
||||||
concurrentutil_version=0.0.2
|
concurrentutil_version=0.0.3
|
||||||
yamlconfig_version=1.0.2
|
yamlconfig_version=1.0.2
|
||||||
cloth_version=17.0.144
|
cloth_version=17.0.144
|
||||||
modmenu_version=13.0.0-beta.1
|
modmenu_version=13.0.0-beta.1
|
||||||
@@ -20,6 +21,6 @@ junit_version=5.11.3
|
|||||||
fabric_lithium_version=t1FlWYl9
|
fabric_lithium_version=t1FlWYl9
|
||||||
neo_lithium_version=iDqQi66g
|
neo_lithium_version=iDqQi66g
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=0.2.0-beta.6
|
mod_version=0.2.0-beta.10
|
||||||
maven_group=ca.spottedleaf.moonrise
|
maven_group=ca.spottedleaf.moonrise
|
||||||
archives_base_name=moonrise
|
archives_base_name=moonrise
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
3
gradlew
vendored
3
gradlew
vendored
@@ -86,8 +86,7 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
|
||||||
id("quiet-fabric-loom") version "1.8.309" apply false
|
id("quiet-fabric-loom") version "1.9.312" apply false
|
||||||
id("net.neoforged.moddev") version "2.0.49-beta" apply false
|
id("net.neoforged.moddev") version "2.0.61-beta" apply false
|
||||||
id 'com.gradleup.shadow' version '8.3.5' apply false
|
id 'com.gradleup.shadow' version '8.3.5' apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package ca.spottedleaf.moonrise.common.util;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public final class EntityUtil {
|
||||||
|
|
||||||
|
private static final ThreadLocal<DecimalFormat> THREE_DECIMAL_PLACES = ThreadLocal.withInitial(() -> {
|
||||||
|
return new DecimalFormat("#,##0.000");
|
||||||
|
});
|
||||||
|
|
||||||
|
private static String formatVec(final Vec3 vec) {
|
||||||
|
final DecimalFormat format = THREE_DECIMAL_PLACES.get();
|
||||||
|
|
||||||
|
return "(" + format.format(vec.x) + "," + format.format(vec.y) + "," + format.format(vec.z) + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String dumpEntityWithoutReferences(final Entity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return "{null}";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "{type=" + entity.getClass().getSimpleName() + ",id=" + entity.getId() + ",uuid=" + entity.getUUID() + ",pos=" + formatVec(entity.position())
|
||||||
|
+ ",mot=" + formatVec(entity.getDeltaMovement()) + ",aabb=" + entity.getBoundingBox() + ",removed=" + entity.getRemovalReason() + ",has_vehicle=" + (entity.getVehicle() != null)
|
||||||
|
+ ",passenger_count=" + entity.getPassengers().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String dumpEntity(final Entity entity) {
|
||||||
|
final List<Entity> passengers = entity.getPassengers();
|
||||||
|
final List<String> passengerStrings = new ArrayList<>(passengers.size());
|
||||||
|
|
||||||
|
for (final Entity passenger : passengers) {
|
||||||
|
passengerStrings.add("(" + dumpEntityWithoutReferences(passenger) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
return "{root=[" + dumpEntityWithoutReferences(entity) + "], vehicle=[" + dumpEntityWithoutReferences(entity.getVehicle())
|
||||||
|
+ "], passengers=[" + String.join(",", passengerStrings) + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
private EntityUtil() {}
|
||||||
|
}
|
||||||
@@ -15,56 +15,81 @@ public class TickThread extends Thread {
|
|||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(TickThread.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(TickThread.class);
|
||||||
|
|
||||||
|
private static String getThreadContext() {
|
||||||
|
return "thread=" + Thread.currentThread().getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void ensureTickThread(final String reason) {
|
public static void ensureTickThread(final String reason) {
|
||||||
if (!isTickThread()) {
|
if (!isTickThread()) {
|
||||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
LOGGER.error("Thread failed main thread check: " + reason + ", context=" + getThreadContext(), new Throwable());
|
||||||
throw new IllegalStateException(reason);
|
throw new IllegalStateException(reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureTickThread(final Level world, final BlockPos pos, final String reason) {
|
public static void ensureTickThread(final Level world, final BlockPos pos, final String reason) {
|
||||||
if (!isTickThreadFor(world, pos)) {
|
if (!isTickThreadFor(world, pos)) {
|
||||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
final String ex = "Thread failed main thread check: " +
|
||||||
throw new IllegalStateException(reason);
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos;
|
||||||
|
LOGGER.error(ex, new Throwable());
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ensureTickThread(final Level world, final BlockPos pos, final int blockRadius, final String reason) {
|
||||||
|
if (!isTickThreadFor(world, pos, blockRadius)) {
|
||||||
|
final String ex = "Thread failed main thread check: " +
|
||||||
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos + ", block_radius=" + blockRadius;
|
||||||
|
LOGGER.error(ex, new Throwable());
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureTickThread(final Level world, final ChunkPos pos, final String reason) {
|
public static void ensureTickThread(final Level world, final ChunkPos pos, final String reason) {
|
||||||
if (!isTickThreadFor(world, pos)) {
|
if (!isTickThreadFor(world, pos)) {
|
||||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
final String ex = "Thread failed main thread check: " +
|
||||||
throw new IllegalStateException(reason);
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + pos;
|
||||||
|
LOGGER.error(ex, new Throwable());
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureTickThread(final Level world, final int chunkX, final int chunkZ, final String reason) {
|
public static void ensureTickThread(final Level world, final int chunkX, final int chunkZ, final String reason) {
|
||||||
if (!isTickThreadFor(world, chunkX, chunkZ)) {
|
if (!isTickThreadFor(world, chunkX, chunkZ)) {
|
||||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
final String ex = "Thread failed main thread check: " +
|
||||||
throw new IllegalStateException(reason);
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + new ChunkPos(chunkX, chunkZ);
|
||||||
|
LOGGER.error(ex, new Throwable());
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureTickThread(final Entity entity, final String reason) {
|
public static void ensureTickThread(final Entity entity, final String reason) {
|
||||||
if (!isTickThreadFor(entity)) {
|
if (!isTickThreadFor(entity)) {
|
||||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
final String ex = "Thread failed main thread check: " +
|
||||||
throw new IllegalStateException(reason);
|
reason + ", context=" + getThreadContext() + ", entity=" + EntityUtil.dumpEntity(entity);
|
||||||
|
LOGGER.error(ex, new Throwable());
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureTickThread(final Level world, final AABB aabb, final String reason) {
|
public static void ensureTickThread(final Level world, final AABB aabb, final String reason) {
|
||||||
if (!isTickThreadFor(world, aabb)) {
|
if (!isTickThreadFor(world, aabb)) {
|
||||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
final String ex = "Thread failed main thread check: " +
|
||||||
throw new IllegalStateException(reason);
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", aabb=" + aabb;
|
||||||
|
LOGGER.error(ex, new Throwable());
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureTickThread(final Level world, final double blockX, final double blockZ, final String reason) {
|
public static void ensureTickThread(final Level world, final double blockX, final double blockZ, final String reason) {
|
||||||
if (!isTickThreadFor(world, blockX, blockZ)) {
|
if (!isTickThreadFor(world, blockX, blockZ)) {
|
||||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
final String ex = "Thread failed main thread check: " +
|
||||||
throw new IllegalStateException(reason);
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + new Vec3(blockX, 0.0, blockZ);
|
||||||
|
LOGGER.error(ex, new Throwable());
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +130,10 @@ public class TickThread extends Thread {
|
|||||||
return isTickThread();
|
return isTickThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isTickThreadFor(final Level world, final BlockPos pos, final int blockRadius) {
|
||||||
|
return isTickThread();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isTickThreadFor(final Level world, final ChunkPos pos) {
|
public static boolean isTickThreadFor(final Level world, final ChunkPos pos) {
|
||||||
return isTickThread();
|
return isTickThread();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package ca.spottedleaf.moonrise.mixin.chunk_system;
|
||||||
|
|
||||||
|
import net.minecraft.core.SectionPos;
|
||||||
|
import net.minecraft.world.level.gameevent.DynamicGameEventListener;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Mixin(DynamicGameEventListener.class)
|
||||||
|
abstract class DynamicGameEventListenerMixin {
|
||||||
|
@Shadow @Nullable private SectionPos lastSection;
|
||||||
|
|
||||||
|
@Inject(method = "remove", at = @At("RETURN"))
|
||||||
|
private void onRemove(final CallbackInfo ci) {
|
||||||
|
// We need to unset the last section when removed, otherwise if the same instance is re-added at the same position it
|
||||||
|
// will assume there was no change and fail to re-register.
|
||||||
|
// In vanilla, chunks rarely unload and re-load quickly enough to trigger this issue. However, our chunk system has a
|
||||||
|
// quirk where fast chunk reload cycles will often occur on player login (see PR #22).
|
||||||
|
// So we fix this vanilla oversight as our changes cause it to manifest in bugs much more often (see issue #87).
|
||||||
|
this.lastSection = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -74,7 +74,7 @@ interface EntityGetterMixin {
|
|||||||
@Overwrite
|
@Overwrite
|
||||||
default boolean isUnobstructed(final Entity entity, final VoxelShape voxel) {
|
default boolean isUnobstructed(final Entity entity, final VoxelShape voxel) {
|
||||||
if (voxel.isEmpty()) {
|
if (voxel.isEmpty()) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final AABB singleAABB = ((CollisionVoxelShape)voxel).moonrise$getSingleAABBRepresentation();
|
final AABB singleAABB = ((CollisionVoxelShape)voxel).moonrise$getSingleAABBRepresentation();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ abstract class LevelMixin implements LevelAccessor, AutoCloseable {
|
|||||||
public boolean isUnobstructed(final Entity entity) {
|
public boolean isUnobstructed(final Entity entity) {
|
||||||
final AABB boundingBox = entity.getBoundingBox();
|
final AABB boundingBox = entity.getBoundingBox();
|
||||||
if (CollisionUtil.isEmpty(boundingBox)) {
|
if (CollisionUtil.isEmpty(boundingBox)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Entity> entities = this.getEntities(
|
final List<Entity> entities = this.getEntities(
|
||||||
|
|||||||
@@ -1143,7 +1143,7 @@ public final class MoonriseRegionFileIO {
|
|||||||
LOGGER.error("Failed to decompress chunk data for task: " + this.toString(), thr);
|
LOGGER.error("Failed to decompress chunk data for task: " + this.toString(), thr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compoundTag == null) {
|
if (throwable == null && compoundTag == null) {
|
||||||
// need to re-try from the start
|
// need to re-try from the start
|
||||||
this.scheduleReadIO();
|
this.scheduleReadIO();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
"chunk_system.ChunkStepMixin",
|
"chunk_system.ChunkStepMixin",
|
||||||
"chunk_system.ChunkStorageMixin",
|
"chunk_system.ChunkStorageMixin",
|
||||||
"chunk_system.DistanceManagerMixin",
|
"chunk_system.DistanceManagerMixin",
|
||||||
|
"chunk_system.DynamicGameEventListenerMixin",
|
||||||
"chunk_system.EntityGetterMixin",
|
"chunk_system.EntityGetterMixin",
|
||||||
"chunk_system.EntityMixin",
|
"chunk_system.EntityMixin",
|
||||||
"chunk_system.EntityTickListMixin",
|
"chunk_system.EntityTickListMixin",
|
||||||
|
|||||||
Reference in New Issue
Block a user