Skip to content

Commit

Permalink
Fix compat with MidnightControls 1.5.0+1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrptonaught committed Aug 9, 2022
1 parent 6c38dfd commit eb0267c
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
maven { url 'https://maven.gegy.dev/releases/' }
maven { url 'https://aperlambda.github.io/maven' }
maven { url 'https://maven.terraformersmc.com/' }
maven { url = "https://maven.kyrptonaught.dev" }

//midnight controls
mavenLocal()
mavenCentral()
maven { url 'https://aperlambda.github.io/maven' }
maven {
name 'Gegy'
url 'https://maven.gegy.dev'
}
maven {
name 'CottonMC'
url 'https://server.bbkr.space/artifactory/libs-snapshot'
name = "CottonMC"
url = "https://server.bbkr.space/artifactory/libs-release"
}
maven { url "https://maven.terraformersmc.com/releases/" }
maven { url 'https://maven.kosmx.dev' }
maven { url 'https://maven.shedaniel.me/' }
maven { url 'https://jitpack.io' }
Expand All @@ -38,18 +41,18 @@ loom {
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

//modImplementation "dev.lambdaurora:lambdacontrols:1.7.1+1.17"
optionalDependency('eu.midnightdust:midnightcontrols:1.0.0-1.18')
optionalDependency('eu.midnightdust:midnightcontrols:1.5.0-1.19')


modImplementation('net.kyrptonaught:kyrptconfig:1.4.4-1.18')
include('net.kyrptonaught:kyrptconfig:1.4.4-1.18')
modImplementation('net.kyrptonaught:kyrptconfig:1.4.14-1.19')
include('net.kyrptonaught:kyrptconfig:1.4.14-1.19')
}

def optionalDependency(String dep) {
Expand Down
13 changes: 6 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
org.gradle.jvmargs=-Xmx4G

minecraft_version=1.18.2
yarn_mappings=1.18.2+build.3:v2
loader_version=0.14.6
minecraft_version=1.19
yarn_mappings=1.19+build.4
loader_version=0.14.9

#Fabric api
fabric_version=0.53.0+1.18.2
fabric_version=0.58.0+1.19

# Mod Properties
mod_version=0.0.8-1.18
mod_version=0.0.9-1.19
maven_group=net.kyrptonaught
archives_base_name=lemclienthelper

archives_base_name=lemclienthelper
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ProgressListener;

import java.io.File;
Expand Down Expand Up @@ -43,7 +42,7 @@ public void setTitle(Text title) {

public void setTitleAndTask(Text title) {
this.title = title;
this.setTask(new TranslatableText("progress.working"));
this.setTask(Text.translatable("progress.working"));
}

@Override
Expand All @@ -62,7 +61,7 @@ public void skip(Text title) {

@Override
public void setDone() {
done(new TranslatableText("key.lemclienthelper.downloadcomplete"), this.task);
done(Text.translatable("key.lemclienthelper.downloadcomplete"), this.task);
}

private void done(Text title, Text task) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
import net.minecraft.client.toast.SystemToast;
import net.minecraft.client.util.NetworkUtils;
import net.minecraft.resource.ResourceType;
import net.minecraft.text.LiteralText;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Locale;
Expand Down Expand Up @@ -81,7 +81,7 @@ static void downloadNextPack() {

static void downloadComplete(AllPacks.RPOption rpOption) {
if (getConfig().toastComplete)
SystemToast.show(MinecraftClient.getInstance().getToastManager(), SystemToast.Type.TUTORIAL_HINT, rpOption.progressListener.title, new LiteralText(rpOption.packname));
SystemToast.show(MinecraftClient.getInstance().getToastManager(), SystemToast.Type.TUTORIAL_HINT, rpOption.progressListener.title, Text.literal(rpOption.packname));
if (!getConfig().multiDownload)
downloadNextPack();
if (verifyFile(rpOption.hash, rpOption.downloadedFile)) {
Expand All @@ -98,7 +98,7 @@ private static void checkIfComplete() {
}
}
downloadsComplete = true;
SystemToast.add(MinecraftClient.getInstance().getToastManager(), SystemToast.Type.TUTORIAL_HINT, new TranslatableText("key.lemclienthelper.alldownloadcomplete"), new LiteralText("Took: " + (System.currentTimeMillis() - startTime) + " milliseconds"));
//SystemToast.add(MinecraftClient.getInstance().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.translatable("key.lemclienthelper.alldownloadcomplete"), Text.literal("Took: " + (System.currentTimeMillis() - startTime) + " milliseconds"));
}

private static void download(AllPacks.RPOption rpOption, boolean previewOnly) {
Expand All @@ -108,12 +108,16 @@ private static void download(AllPacks.RPOption rpOption, boolean previewOnly) {
rpOption.downloadedFile = file;
if ((getConfig().allowOptifine && rpOption.packCompatibility == AllPacks.RPOption.PACKCOMPATIBILITY.VANILLA) ||
(!getConfig().allowOptifine && rpOption.packCompatibility == AllPacks.RPOption.PACKCOMPATIBILITY.OPTIFINE)) {
rpOption.progressListener.skip(new TranslatableText("key.lemclienthelper.wrongpackcompatibility"));
rpOption.progressListener.skip(Text.translatable("key.lemclienthelper.wrongpackcompatibility"));
} else if (file.exists()) {
rpOption.progressListener.skip(new TranslatableText("key.lemclienthelper.alreadydownloaded"));
rpOption.progressListener.skip(Text.translatable("key.lemclienthelper.alreadydownloaded"));
} else if (!previewOnly) {
Map<String, String> map = getDownloadHeaders();
NetworkUtils.downloadResourcePack(file, rpOption.url, map, Integer.MAX_VALUE, rpOption.progressListener, minecraftClient.getNetworkProxy());
try {
NetworkUtils.downloadResourcePack(file, new URL(rpOption.url), map, Integer.MAX_VALUE, rpOption.progressListener, minecraftClient.getNetworkProxy());
} catch (MalformedURLException exception) {
System.out.println("Bad URL detected: " + rpOption.url);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static SmallInvConfig getConfig() {
}

public static boolean isSmallInv(PlayerEntity player) {
//if (true) return true;
//if (true) return true; // force enabling for testing
if (!getConfig().enabled) return false;

//give @p knowledge_book{display:{Name:'{"text":" "}'},SmallInv:1,CustomModelData:1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.screen.PlayerScreenHandler;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public class SmallInvScreen extends AbstractInventoryScreen<PlayerScreenHandler> {
Expand All @@ -17,7 +17,7 @@ public class SmallInvScreen extends AbstractInventoryScreen<PlayerScreenHandler>
private float mouseY;

public SmallInvScreen(PlayerEntity player) {
super(player.playerScreenHandler, player.getInventory(), new TranslatableText("container.inventory"));
super(player.playerScreenHandler, player.getInventory(), Text.translatable("container.inventory"));
this.passEvents = false;
this.titleY = 86;
this.backgroundHeight = 124;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import eu.midnightdust.midnightcontrols.client.controller.PressAction;
import net.kyrptonaught.lemclienthelper.LEMClientHelperMod;
import net.minecraft.screen.PlayerScreenHandler;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;



public class LambdControlsCompat implements CompatHandler {

public static void register() {
Expand All @@ -29,7 +27,7 @@ public static void register() {

@Override
public void handle(@NotNull MidnightControlsClient mod) {
new ButtonBinding.Builder(LEMClientHelperMod.MOD_ID+".takeeverything")
new ButtonBinding.Builder(LEMClientHelperMod.MOD_ID + ".takeeverything")
.buttons(GLFW.GLFW_GAMEPAD_BUTTON_LEFT_THUMB)
.onlyInInventory()
.action(TAKE_EVERYTHING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,40 @@
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

public class ModMenuIntegration implements ModMenuApi {

@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return (screen) -> {
ResourcePreloaderConfig config = ResourcePreloader.getConfig();
ConfigScreen configScreen = new ConfigScreen(screen, new TranslatableText("key.lemclienthelper.title"));
ConfigScreen configScreen = new ConfigScreen(screen, Text.translatable("key.lemclienthelper.title"));
configScreen.setSavingEvent(() -> {
LEMClientHelperMod.configManager.save();
});

ConfigSection rplSection = new ConfigSection(configScreen, new TranslatableText("key.lemclienthelper.resourcepreloader"));
ConfigSection rplSection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.resourcepreloader"));

rplSection.addConfigItem(new TextItem(new TranslatableText("key.lemclienthelper.downloadurl"), config.URL, ResourcePreloaderConfig.DEFAULT_URL).setMaxLength(1024).setSaveConsumer(val -> config.URL = val));
rplSection.addConfigItem(new BooleanItem(new TranslatableText("key.lemclienthelper.allowOptifine"), config.allowOptifine, false).setSaveConsumer(val -> config.allowOptifine = val));
rplSection.addConfigItem(new BooleanItem(new TranslatableText("key.lemclienthelper.multiDownload"), config.multiDownload, true).setSaveConsumer(val -> config.multiDownload = val));
rplSection.addConfigItem(new BooleanItem(new TranslatableText("key.lemclienthelper.toastcomplete"), config.toastComplete, true).setSaveConsumer(val -> config.toastComplete = val));
rplSection.addConfigItem(new TextItem(Text.translatable("key.lemclienthelper.downloadurl"), config.URL, ResourcePreloaderConfig.DEFAULT_URL).setMaxLength(1024).setSaveConsumer(val -> config.URL = val));
rplSection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.allowOptifine"), config.allowOptifine, false).setSaveConsumer(val -> config.allowOptifine = val));
rplSection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.multiDownload"), config.multiDownload, true).setSaveConsumer(val -> config.multiDownload = val));
rplSection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.toastcomplete"), config.toastComplete, true).setSaveConsumer(val -> config.toastComplete = val));

rplSection.addConfigItem(new ButtonItem(new TranslatableText("key.lemclienthelper.deletePacks")).setClickEvent(() -> {
rplSection.addConfigItem(new ButtonItem(Text.translatable("key.lemclienthelper.deletePacks")).setClickEvent(() -> {
configScreen.save();
ResourcePreloader.deletePacks();
}));

SubItem<?> sub = new SubItem<>(new TranslatableText("key.lemclienthelper.packdownloads"), true);
SubItem<?> sub = new SubItem<>(Text.translatable("key.lemclienthelper.packdownloads"), true);

rplSection.addConfigItem(new ButtonItem(new TranslatableText("key.lemclienthelper.previewList")).setClickEvent(() -> {
rplSection.addConfigItem(new ButtonItem(Text.translatable("key.lemclienthelper.previewList")).setClickEvent(() -> {
configScreen.save();
ResourcePreloader.getPackList();
addPacksToSub(sub);
}));

rplSection.addConfigItem(new ButtonItem(new TranslatableText("key.lemclienthelper.startdownload")).setClickEvent(() -> {
rplSection.addConfigItem(new ButtonItem(Text.translatable("key.lemclienthelper.startdownload")).setClickEvent(() -> {
configScreen.save();
ResourcePreloader.getPackList();
ResourcePreloader.downloadPacks();
Expand All @@ -59,8 +57,8 @@ public ConfigScreenFactory<?> getModConfigScreenFactory() {
rplSection.addConfigItem(sub);
addPacksToSub(sub);

ConfigSection smallInvSection = new ConfigSection(configScreen, new TranslatableText("key.lemclienthelper.smallinv"));
smallInvSection.addConfigItem(new BooleanItem(new TranslatableText("key.lemclienthelper.smallinv.enabled"), SmallInvInit.getConfig().enabled, true).setSaveConsumer(val -> SmallInvInit.getConfig().enabled = val));
ConfigSection smallInvSection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.smallinv"));
smallInvSection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.smallinv.enabled"), SmallInvInit.getConfig().enabled, true).setSaveConsumer(val -> SmallInvInit.getConfig().enabled = val));

return configScreen;
};
Expand All @@ -70,7 +68,7 @@ public void addPacksToSub(SubItem<?> sub) {
if (ResourcePreloader.allPacks != null && ResourcePreloader.allPacks.packs.size() > 0) {
sub.clearConfigItems();
ResourcePreloader.allPacks.packs.forEach(rpOption -> {
sub.addConfigItem(new RPDownloadItem(rpOption).setToolTip(new LiteralText(rpOption.url)));
sub.addConfigItem(new RPDownloadItem(rpOption).setToolTip(Text.literal(rpOption.url)));
});
}
}
Expand All @@ -79,7 +77,7 @@ public static class RPDownloadItem extends ConfigItem<Object> {
private final AllPacks.RPOption rpOption;

public RPDownloadItem(AllPacks.RPOption option) {
super(new LiteralText(option.packname), null, null);
super(Text.literal(option.packname), null, null);
this.rpOption = option;
}

Expand All @@ -98,7 +96,7 @@ public void render(MatrixStack matrices, int x, int y, int mouseX, int mouseY, f
Screen.drawCenteredText(matrices, textRenderer, progressListener.title, titleX, y, 16777215);

if (rpOption.progressListener.task != null) {
Text task = (new LiteralText("")).append(progressListener.task).append(" " + progressListener.progress + "%");
Text task = (Text.literal("")).append(progressListener.task).append(" " + progressListener.progress + "%");
Screen.drawCenteredText(matrices, textRenderer, task, titleX, y + 10, 16777215);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Mixin(InputHandlers.class)
public class MidnightControlsMixin {

@Inject(method = "lambda$handleInventorySlotPad$5", at = @At(value = "HEAD"), cancellable = true)
@Inject(method = "lambda$handleInventorySlotPad$16", at = @At(value = "HEAD"), cancellable = true)
private static void skipDisabledSlots(int guiLeft, int guiTop, double mouseX, double mouseY, Slot mouseSlot, int direction, Pair<Slot, Double> entry, CallbackInfoReturnable<Boolean> cir) {
if (!entry.key.isEnabled()) cir.setReturnValue(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class ClientBuiltInResourcePackProviderMixin {

@ModifyConstant(method = "deleteOldServerPack", constant = @Constant(intValue = 10))
private int dontDeleteLEMPacks(int constant) {
return 25;
return 30;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.kyrptonaught.lemclienthelper.ResourcePreloader.AllPacks;
import net.minecraft.client.util.NetworkUtils;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;
import net.minecraft.util.ProgressListener;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -18,7 +18,7 @@ public class NetworkUtilsMixin {
@Redirect(method = "method_15303", at = @At(value = "INVOKE", target = "Ljava/io/InputStream;read([B)I"))
private static int catch404(InputStream instance, byte[] b, ProgressListener progressListener) throws IOException {
if (progressListener instanceof AllPacks.Progress && instance == null) {
((AllPacks.Progress) progressListener).skip(new TranslatableText("key.lemclienthelper.downloaderror"));
((AllPacks.Progress) progressListener).skip(Text.translatable("key.lemclienthelper.downloaderror"));
return -1;
}
return instance.read(b);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "lemclienthelper",
"version": "0.0.8-1.18",
"version": "0.0.9-1.19",
"name": "LEM Client Helper",
"description": "LEM Client Helper",
"authors": [
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/lemclienthelper.accesswidener
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
accessWidener v1 named

# small inv
mutable field net/minecraft/screen/slot/Slot x I
mutable field net/minecraft/screen/slot/Slot y I
mutable field net/minecraft/screen/slot/Slot y I

# legacy ui
mutable field net/minecraft/client/gui/screen/TitleScreen backgroundRenderer Lnet/minecraft/client/gui/RotatingCubeMapRenderer;
accessible field net/minecraft/client/gui/screen/TitleScreen backgroundRenderer Lnet/minecraft/client/gui/RotatingCubeMapRenderer;
2 changes: 1 addition & 1 deletion src/main/resources/lemclienthelper.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"resourcepreloader.NetworkUtilsMixin",
"SmallInv.GenericContainerScreenMixin",
"SmallInv.HandledScreenMixin",
"SmallInv.MidnightControlsMixin",
"SmallInv.MinecraftClientMixin",
"SmallInv.ScreenHandlerMixin",
"SmallInv.MidnightControlsMixin",
"takeeverything.ScreenHandlerMixin"
],
"injectors": {
Expand Down

0 comments on commit eb0267c

Please sign in to comment.