Update to 1.20
This commit is contained in:
parent
42891f36c4
commit
0dad978c11
|
@ -6,14 +6,14 @@ plugins {
|
|||
|
||||
repositories {
|
||||
maven("https://maven.shedaniel.me/") { name = "Cloth Config" }
|
||||
maven("https://maven.vram.io/") { name = "vram" }
|
||||
maven("https://quantumfusion.dev/maven/") {
|
||||
maven("https://maven.vram.io/") { name = "FREX/Canvas" }
|
||||
maven("https://notalpha.dev/maven/releases") {
|
||||
name = "DashLoader"
|
||||
content {
|
||||
includeGroup("dev.notalpha")
|
||||
includeGroup("dev.quantumfusion")
|
||||
includeGroup("dev.quantumfusion.dashloader")
|
||||
}
|
||||
}
|
||||
maven("https://jitpack.io") { name = "jitpack (for StarScript)" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -22,22 +22,22 @@ dependencies {
|
|||
modImplementation("io.gitlab.jfronny.libjf:libjf-data-manipulation-v0:${prop("libjf_version")}")
|
||||
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v1:${prop("libjf_version")}")
|
||||
modImplementation("io.gitlab.jfronny.libjf:libjf-config-ui-tiny-v1:${prop("libjf_version")}")
|
||||
modClientCompileOnly("io.vram:frex-fabric-mc119:+")
|
||||
|
||||
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:${prop("libjf_version")}") {
|
||||
exclude("net.fabricmc") // required to work around duplicate fabric loaders
|
||||
}
|
||||
modLocalRuntime("com.terraformersmc:modmenu:6.1.0-rc.1") {
|
||||
modLocalRuntime("com.terraformersmc:modmenu:7.0.1") {
|
||||
exclude("net.fabricmc") // required to work around duplicate fabric loaders
|
||||
}
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.9.0")
|
||||
modClientCompileOnly("io.vram:frex-fabric:20.0.+")
|
||||
modClientCompileOnly("dev.notalpha:dashloader:5.0.0-beta.1+1.20.0")
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.9.3")
|
||||
|
||||
// Canvas for FREX testing
|
||||
// modRuntimeOnly("io.vram:canvas-fabric-mc118:+") {
|
||||
// exclude(group: "me.shedaniel.cloth")
|
||||
// }
|
||||
// modClientRuntimeOnly("io.vram:canvas-fabric:20.0.+")
|
||||
|
||||
// DashLoader "compatibility"
|
||||
// clientRuntimeOnly("dev.quantumfusion.dashloader:dashloader-definitions:3.0-rc14-1.18")
|
||||
// modClientRuntimeOnly("dev.notalpha:dashloader:5.0.0-beta.1+1.20.0")
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# https://fabricmc.net/develop/
|
||||
minecraft_version=1.19.4
|
||||
minecraft_version=1.20
|
||||
yarn_mappings=build.1
|
||||
loader_version=0.14.17
|
||||
loader_version=0.14.21
|
||||
|
||||
maven_group=io.gitlab.jfronny
|
||||
archives_base_name=respackopts
|
||||
|
@ -13,6 +13,6 @@ curseforge_id=430090
|
|||
curseforge_required_dependencies=fabric-api, libjf
|
||||
curseforge_optional_dependencies=modmenu
|
||||
|
||||
fabric_version=0.75.3+1.19.4
|
||||
libjf_version=3.6.0
|
||||
muscript_version=1.2-SNAPSHOT
|
||||
fabric_version=0.83.0+1.20
|
||||
libjf_version=3.8.0
|
||||
muscript_version=1.3-SNAPSHOT
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package io.gitlab.jfronny.respackopts.integration;
|
||||
|
||||
import dev.notalpha.dashloader.client.DashLoaderClient;
|
||||
import io.gitlab.jfronny.respackopts.Respackopts;
|
||||
import io.gitlab.jfronny.respackopts.RespackoptsConfig;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
public class DashLoaderCompat {
|
||||
public static void requestForceReload() {
|
||||
if (!FabricLoader.getInstance().isModLoaded("dashloader"))
|
||||
|
@ -17,21 +14,9 @@ public class DashLoaderCompat {
|
|||
try {
|
||||
if (RespackoptsConfig.debugLogs)
|
||||
Respackopts.LOGGER.info("Removing DashCache to force dashloader to reload");
|
||||
Class<?> loaderClass = Class.forName("dev.quantumfusion.dashloader.def.DashLoader");
|
||||
Path loaderPath = (Path) loaderClass.getDeclaredField("DASH_CACHE_FOLDER").get(null);
|
||||
Files.walkFileTree(loaderPath, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
Files.delete(file);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
|
||||
Files.delete(dir);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
DashLoaderClient.CACHE.remove();
|
||||
DashLoaderClient.NEEDS_RELOAD = true;
|
||||
} catch (Throwable e) {
|
||||
Respackopts.LOGGER.error("Failed to remove dashloader data, try disabling dashloaderCompat if this keeps happening", e);
|
||||
}
|
||||
|
|
|
@ -6,10 +6,9 @@ import io.gitlab.jfronny.libjf.config.api.v1.ui.tiny.ConfigScreen;
|
|||
import io.gitlab.jfronny.respackopts.model.cache.CacheKey;
|
||||
import io.gitlab.jfronny.respackopts.util.MetaCache;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.pack.PackListWidget;
|
||||
import net.minecraft.client.gui.screen.pack.ResourcePackOrganizer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -26,14 +25,14 @@ public abstract class ResourcePackEntryMixin {
|
|||
@Shadow @Final private ResourcePackOrganizer.Pack pack;
|
||||
boolean rpo$selected;
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "render(Lnet/minecraft/client/util/math/MatrixStack;IIIIIIIZF)V")
|
||||
private void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta, CallbackInfo info) {
|
||||
@Inject(at = @At("TAIL"), method = "render(Lnet/minecraft/client/gui/DrawContext;IIIIIIIZF)V")
|
||||
private void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta, CallbackInfo info) {
|
||||
if (this.isSelectable() && MetaCache.getKeyByDisplayName(pack.getDisplayName().getString()) != null) {
|
||||
int d = mouseX - x;
|
||||
d = widget.getRowWidth() - d;
|
||||
int e = mouseY - y;
|
||||
rpo$selected = d <= 32 && d >= 12 && e <= entryHeight / 2 + 10 && e >= entryHeight / 2 - 10;
|
||||
rpo$renderButton(matrices, rpo$selected, new Identifier("modmenu", "textures/gui/configure_button.png"), x + entryWidth - 30, y + entryHeight / 2 - 10);
|
||||
rpo$renderButton(context, rpo$selected, new Identifier("modmenu", "textures/gui/configure_button.png"), x + entryWidth - 30, y + entryHeight / 2 - 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,11 +51,10 @@ public abstract class ResourcePackEntryMixin {
|
|||
}
|
||||
}
|
||||
|
||||
private void rpo$renderButton(MatrixStack matrices, boolean hovered, Identifier texture, int x, int y) {
|
||||
private void rpo$renderButton(DrawContext context, boolean hovered, Identifier texture, int x, int y) {
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1f);
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
RenderSystem.disableDepthTest();
|
||||
DrawableHelper.drawTexture(matrices, x, y, 0, hovered ? 20 : 0, 20, 20, 32, 64);
|
||||
context.drawTexture(texture, x, y, 0, hovered ? 20 : 0, 20, 20, 32, 64);
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public enum DirFilterEvents implements UserResourceEvents.Open, UserResourceEven
|
|||
if (is == null) return null;
|
||||
try (Reader w = new InputStreamReader(is.get())) {
|
||||
drp = AttachmentHolder.deserialize(state.metadata().version, w, DirRpo.class);
|
||||
drp.path = name;
|
||||
drp.hydrate(name);
|
||||
if (drp.fallback != null && !drp.fallback.endsWith("/"))
|
||||
drp.fallback += "/";
|
||||
drpReg.put(name, drp);
|
||||
|
|
|
@ -37,7 +37,7 @@ public class FileRpoSearchProvider {
|
|||
if (is == null) return defaultValue;
|
||||
try (Reader w = new InputStreamReader(is.get())) {
|
||||
FileRpo frp = AttachmentHolder.deserialize(state.metadata().version, w, FileRpo.class);
|
||||
frp.path = rpoPathS;
|
||||
frp.hydrate(rpoPathS);
|
||||
rpoCache.put(rpoPathS, frp);
|
||||
return action.run(frp);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import io.gitlab.jfronny.muscript.ast.*;
|
|||
import io.gitlab.jfronny.muscript.ast.bool.*;
|
||||
import io.gitlab.jfronny.muscript.ast.compare.Equal;
|
||||
import io.gitlab.jfronny.muscript.ast.dynamic.*;
|
||||
import io.gitlab.jfronny.muscript.compiler.CodeLocation;
|
||||
import io.gitlab.jfronny.muscript.compiler.Token;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -29,7 +30,7 @@ public class BoolExprDeserializer implements JsonDeserializer<BoolExpr> {
|
|||
return switch (entry.getKey().toLowerCase(Locale.ROOT)) {
|
||||
case "and", "add", "&" -> merge(context.deserialize(entry.getValue(), conditionListType), Token.And);
|
||||
case "==", "=", "equal", "eq" -> merge(context.deserialize(entry.getValue(), conditionListType), Token.EqualEqual);
|
||||
case "not", "nor", "!" -> new Not(-1, -1, merge(context.deserialize(entry.getValue(), conditionListType), Token.Or));
|
||||
case "not", "nor", "!" -> new Not(CodeLocation.NONE, merge(context.deserialize(entry.getValue(), conditionListType), Token.Or));
|
||||
case "or", "|" -> merge(context.deserialize(entry.getValue(), conditionListType), Token.Or);
|
||||
case "^", "xor" -> merge(context.deserialize(entry.getValue(), conditionListType), Token.BangEqual);
|
||||
default -> throw new JsonParseException("Unknown condition type: " + entry.getKey());
|
||||
|
@ -58,13 +59,13 @@ public class BoolExprDeserializer implements JsonDeserializer<BoolExpr> {
|
|||
|
||||
private BoolExpr merge(List<BoolExpr> expressions, Token token) {
|
||||
if (token == Token.BangEqual)
|
||||
return new Not(-1, -1, merge(expressions, Token.EqualEqual));
|
||||
return new Not(CodeLocation.NONE, merge(expressions, Token.EqualEqual));
|
||||
BoolExpr current = expressions.get(0);
|
||||
for (BoolExpr expr : expressions.subList(1, expressions.size())) {
|
||||
current = switch (token) {
|
||||
case EqualEqual -> new Equal(-1, -1, current, expr);
|
||||
case And -> new And(-1, -1, current, expr);
|
||||
case Or -> new Or(-1, -1, current, expr);
|
||||
case EqualEqual -> new Equal(CodeLocation.NONE, current, expr);
|
||||
case And -> new And(CodeLocation.NONE, current, expr);
|
||||
case Or -> new Or(CodeLocation.NONE, current, expr);
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
@ -76,16 +77,16 @@ public class BoolExprDeserializer implements JsonDeserializer<BoolExpr> {
|
|||
String code = name.substring("modversion:".length());
|
||||
String mod = code.substring(0, code.indexOf(':'));
|
||||
String predicate = code.substring(code.indexOf(':') + 1);
|
||||
return new Call(-1, -1, new Variable(-1, -1, "version"), List.of(
|
||||
new Call.Arg(Expr.literal(-1, -1, mod).asDynamicExpr(), false),
|
||||
new Call.Arg(Expr.literal(-1, -1, predicate).asDynamicExpr(), false)
|
||||
return new Call(CodeLocation.NONE, new Variable(CodeLocation.NONE, "version"), List.of(
|
||||
new Call.Arg(Expr.literal(mod).asDynamicExpr(), false),
|
||||
new Call.Arg(Expr.literal(predicate).asDynamicExpr(), false)
|
||||
)).asBoolExpr();
|
||||
}
|
||||
DynamicExpr e = null;
|
||||
String[] arr = name.split("[:.]");
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
if (i == 0) e = new Variable(-1, -1, arr[i]);
|
||||
else e = new Get(-1, -1, e, Expr.literal(arr[i]));
|
||||
if (i == 0) e = new Variable(CodeLocation.NONE, arr[i]);
|
||||
else e = new Get(CodeLocation.NONE, e, Expr.literal(arr[i]));
|
||||
}
|
||||
if (e == null) throw new JsonParseException("Invalid RPO condition: \"" + name + "\"");
|
||||
return e.asBoolExpr();
|
||||
|
|
|
@ -14,6 +14,6 @@ public class ConditionDeserializer implements JsonDeserializer<Condition> {
|
|||
JsonPrimitive primitive = json.getAsJsonPrimitive();
|
||||
if (primitive.isString()) source = primitive.getAsString();
|
||||
}
|
||||
return new Condition(source, context.deserialize(json, BoolExpr.class));
|
||||
return new Condition(source, null, context.deserialize(json, BoolExpr.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,30 @@
|
|||
package io.gitlab.jfronny.respackopts.model;
|
||||
|
||||
import io.gitlab.jfronny.muscript.ast.BoolExpr;
|
||||
import io.gitlab.jfronny.muscript.compiler.CodeLocation;
|
||||
import io.gitlab.jfronny.muscript.data.Scope;
|
||||
import io.gitlab.jfronny.muscript.error.LocationalError;
|
||||
import io.gitlab.jfronny.muscript.error.LocationalException;
|
||||
import io.gitlab.jfronny.muscript.error.PrettyPrintError;
|
||||
|
||||
public record Condition(String source, BoolExpr expr) {
|
||||
public record Condition(String source, String sourceFile, BoolExpr expr) {
|
||||
public boolean get(Scope dataRoot) throws ConditionException {
|
||||
try {
|
||||
return expr.get(dataRoot);
|
||||
} catch (LocationalException e) {
|
||||
throw new ConditionException(e.asPrintable(source), e);
|
||||
throw new ConditionException(e.asPrintable(), e);
|
||||
} catch (RuntimeException e) {
|
||||
throw new ConditionException(LocationalError.create(source, 0, e.getMessage()), e);
|
||||
throw new ConditionException(PrettyPrintError.builder(new CodeLocation(0, 0, source, sourceFile)).setMessage(e.getMessage()).build(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConditionException extends Exception {
|
||||
public final LocationalError error;
|
||||
public Condition withSourceFile(String sourceFile) {
|
||||
return new Condition(source, sourceFile, expr);
|
||||
}
|
||||
|
||||
public ConditionException(LocationalError error, Throwable cause) {
|
||||
public static class ConditionException extends Exception {
|
||||
public final PrettyPrintError error;
|
||||
|
||||
public ConditionException(PrettyPrintError error, Throwable cause) {
|
||||
super(error.toString(), cause);
|
||||
this.error = error;
|
||||
}
|
||||
|
|
|
@ -11,4 +11,9 @@ public class DirRpo {
|
|||
|
||||
@Ignore
|
||||
public String path;
|
||||
|
||||
public void hydrate(String path) {
|
||||
this.path = path;
|
||||
if (condition != null) condition = condition.withSourceFile(path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,4 +17,9 @@ public class FileRpo {
|
|||
|
||||
@Ignore
|
||||
public String path;
|
||||
|
||||
public void hydrate(String path) {
|
||||
this.path = path;
|
||||
if (condition != null) condition = condition.withSourceFile(path);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue