Fix moving packs and resizing the pack selection screen. It should be noted that this might cause desync between a config file and the game

This commit is contained in:
JFronny 2020-12-21 15:34:31 +01:00
parent 620f716d8e
commit 6c340d8354
3 changed files with 10 additions and 19 deletions

View File

@ -65,16 +65,6 @@ public class Respackopts implements ClientModInitializer {
} }
} }
public static void load() {
try {
for (String s : resPackMetas.keySet()) {
load(resPackMetas.get(s).id);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
public static void load(String id) { public static void load(String id) {
Path q = p.resolve(id + ".json"); Path q = p.resolve(id + ".json");
if (Files.exists(q)) { if (Files.exists(q)) {

View File

@ -38,14 +38,17 @@ public abstract class ResourcePackEntryMixin extends AlwaysSelectedEntryListWidg
} }
} }
@Inject(at = @At("TAIL"), method = "mouseClicked(DDI)Z") @Inject(at = @At("RETURN"), method = "mouseClicked(DDI)Z", cancellable = true)
public void mouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> info) { public void mouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> info) {
if (this.isSelectable()) { if (!info.getReturnValue()) {
String k = pack.getDisplayName().asString(); if (this.isSelectable()) {
if (Respackopts.resPackMetas.containsKey(k) && respackopts$selected) { String k = pack.getDisplayName().asString();
Respackmeta meta = Respackopts.resPackMetas.get(k); if (Respackopts.resPackMetas.containsKey(k) && respackopts$selected) {
MinecraftClient c = MinecraftClient.getInstance(); info.setReturnValue(true);
c.openScreen(Respackopts.factory.buildGui(meta.conf, meta.id, c.currentScreen, () -> Respackopts.forceRespackReload = true)); Respackmeta meta = Respackopts.resPackMetas.get(k);
MinecraftClient c = MinecraftClient.getInstance();
c.openScreen(Respackopts.factory.buildGui(meta.conf, meta.id, c.currentScreen, () -> Respackopts.forceRespackReload = true));
}
} }
} }
} }

View File

@ -56,8 +56,6 @@ public class ResourcePackManagerMixin {
} }
} }
}); });
Respackopts.save();
Respackopts.load();
} }
private void respackopts$registerFields(JsonObject data, String id, String keyPrefix) { private void respackopts$registerFields(JsonObject data, String id, String keyPrefix) {