diff --git a/src/client/java/com/adamcalculator/dynamicpack/Compat.java b/src/client/java/com/adamcalculator/dynamicpack/Compat.java deleted file mode 100644 index f24e674..0000000 --- a/src/client/java/com/adamcalculator/dynamicpack/Compat.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.adamcalculator.dynamicpack; - -import net.minecraft.client.gui.Drawable; -import net.minecraft.client.gui.Element; -import net.minecraft.client.gui.Selectable; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.text.Text; - -public class Compat { - public static T createButton(Text text, Runnable press, int w, int h, int x, int y) { - return (T) ButtonWidget.builder(text, button -> press.run()).size(w, h).position(x, y).build(); - } -} diff --git a/src/client/java/com/adamcalculator/dynamicpack/DebugScreen.java b/src/client/java/com/adamcalculator/dynamicpack/DebugScreen.java deleted file mode 100644 index ebe975c..0000000 --- a/src/client/java/com/adamcalculator/dynamicpack/DebugScreen.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.adamcalculator.dynamicpack; - -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.text.Text; - -public class DebugScreen extends Screen { - protected DebugScreen() { - super(Text.literal("DebugScreen")); - } - - @Override - public void render(DrawContext context, int mouseX, int mouseY, float delta) { - renderBackground(context); - super.render(context, mouseX, mouseY, delta); - } - - @Override - protected void init() { - addDrawableChild(ButtonWidget.builder(Text.of("Re-Scan & Re-sync normally"), button -> DynamicPackModBase.INSTANCE.startManuallySync()).size(120, 20).position(this.width / 2, this.height / 2).build()); - } -} diff --git a/src/client/java/com/adamcalculator/dynamicpack/DynamicPackScreen.java b/src/client/java/com/adamcalculator/dynamicpack/DynamicPackScreen.java deleted file mode 100644 index 24491b9..0000000 --- a/src/client/java/com/adamcalculator/dynamicpack/DynamicPackScreen.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.adamcalculator.dynamicpack; - -import com.adamcalculator.dynamicpack.pack.Pack; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.screen.ScreenTexts; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; - -import java.util.Date; - -public class DynamicPackScreen extends Screen { - private final Screen parent; - private final Pack pack; - private final Text screenDescText; - - public DynamicPackScreen(Screen parent, Pack pack) { - super(Text.literal(pack.getName()).formatted(Formatting.BOLD)); - this.pack = pack; - this.client = MinecraftClient.getInstance(); - this.parent = parent; - this.screenDescText = Text.translatable("dynamicpack.screen.pack.description"); - } - - @Override - public void render(DrawContext context, int mouseX, int mouseY, float delta) { - renderBackground(context); - context.drawTextWithShadow(this.textRenderer, this.title, 20, 8, 16777215); - context.drawTextWithShadow(this.textRenderer, screenDescText, 20, 20, 16777215); - context.drawTextWithShadow(this.textRenderer, Text.translatable("dynamicpack.screen.pack.remote_type", pack.getRemoteType()), 20, 36, 16777215); - context.drawTextWithShadow(this.textRenderer, Text.translatable("dynamicpack.screen.pack.latestUpdated", pack.getLatestUpdated() < 0 ? "-" : new Date(pack.getLatestUpdated() * 1000)), 20, 52, 16777215); - - super.render(context, mouseX, mouseY, delta); - } - - @Override - protected void init() { - addDrawableChild(Compat.createButton( - Text.of("Manually sync"), - () -> { - DynamicPackModBase.INSTANCE.startManuallySync(); - close(); - }, - 100, 20, width - 120, 10 - )); - - addDrawableChild(Compat.createButton(ScreenTexts.DONE, this::close, 150, 20, this.width / 2 + 4, this.height - 48)); - } - - @Override - public void close() { - this.client.setScreen(parent); - } -} diff --git a/src/client/java/com/adamcalculator/dynamicpack/FabricDynamicMod.java b/src/client/java/com/adamcalculator/dynamicpack/FabricDynamicMod.java deleted file mode 100644 index d253bd6..0000000 --- a/src/client/java/com/adamcalculator/dynamicpack/FabricDynamicMod.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.adamcalculator.dynamicpack; - -import com.adamcalculator.dynamicpack.pack.Pack; -import com.adamcalculator.dynamicpack.sync.SyncThread; -import com.adamcalculator.dynamicpack.sync.SyncingTask; -import com.adamcalculator.dynamicpack.sync.state.StateDownloading; -import com.adamcalculator.dynamicpack.sync.state.StateFileDeleted; -import com.adamcalculator.dynamicpack.sync.state.SyncProgressState; -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.SharedConstants; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.toast.SystemToast; -import net.minecraft.client.toast.ToastManager; -import net.minecraft.resource.metadata.PackResourceMetadataReader; -import net.minecraft.text.Text; -import net.minecraft.util.JsonHelper; - -public class FabricDynamicMod extends DynamicPackModBase implements ClientModInitializer { - private static final boolean SHOW_STATE = false; - private SystemToast toast = null; - private long toastUpdated = 0; - - public void setToastContent(Text title, Text text) { - if (!isMinecraftInitialized()) { - return; - } - - if (toast == null || (System.currentTimeMillis() - toastUpdated > 1000*5)) { - ToastManager toastManager = MinecraftClient.getInstance().getToastManager(); - toastManager.add(toast = new SystemToast(SystemToast.Type.NARRATOR_TOGGLE, title, text)); - } else { - toast.setContent(title, text); - } - toastUpdated = System.currentTimeMillis(); - } - - - @Override - public void onInitializeClient() { - var gameDir = FabricLoader.getInstance().getGameDir().toFile(); - init(gameDir); - } - - @Override - public void startSyncThread() { - new SyncThread(() -> createSyncTask(false)).start(); - } - - @Override - public void startManuallySync() { - Thread thread = new Thread(() -> createSyncTask(true).run()); - thread.setName("DynamicPack-ManuallySyncThread" + (DynamicPackModBase.manuallySyncThreadCounter++)); - thread.start(); - } - - private SyncingTask createSyncTask(boolean manually) { - return new SyncingTask(manually) { - @Override - public void onSyncStart() { - if (manually) setToastContent(Text.literal("DynamicPack"), Text.translatable("dynamicpack.toast.syncStarted")); - } - - @Override - public void onSyncDone(boolean reloadRequired) { - if (manually || reloadRequired) { - setToastContent(Text.literal("DynamicPack"), Text.translatable("dynamicpack.toast.done")); - } - if (reloadRequired) { - tryToReloadResources(); - } - } - - @Override - public void onStateChanged(Pack pack, SyncProgressState state) { - if (!manually) return; - - if (state instanceof StateDownloading downloading) { - setToastContent(Text.translatable("dynamicpack.toast.pack.state.downloading.title", pack.getName()), Text.translatable("dynamicpack.toast.pack.state.downloading.description", downloading.getPercentage(), downloading.getName())); - - } else if (state instanceof StateFileDeleted deleted) { - setToastContent(Text.translatable("dynamicpack.toast.pack.state.deleting.title", pack.getName()), Text.translatable("dynamicpack.toast.pack.state.deleting.description", deleted.getPath().getFileName().toString())); - - } else { - setToastContent(Text.translatable("dynamicpack.toast.pack.state.unknown.title"), Text.translatable("dynamicpack.toast.pack.state.unknown.description")); - } - } - }; - } - - @Override - public String getCurrentGameVersion() { - return SharedConstants.getGameVersion().getId(); - } - - @Override - public boolean checkResourcePackMetaValid(String s) { - new PackResourceMetadataReader().fromJson(JsonHelper.deserialize(s).getAsJsonObject("pack")); - return true; - } - - private void tryToReloadResources() { - MinecraftClient client = MinecraftClient.getInstance(); - if (client != null) { - if (client.world == null) { - client.send(client::reloadResources); - - } else { - setToastContent(Text.translatable("dynamicpack.toast.needReload"), - Text.translatable("dynamicpack.toast.needReload.description")); - } - } - } -} diff --git a/src/client/java/com/adamcalculator/dynamicpack/ModMenu.java b/src/client/java/com/adamcalculator/dynamicpack/ModMenu.java deleted file mode 100644 index b06ef16..0000000 --- a/src/client/java/com/adamcalculator/dynamicpack/ModMenu.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.adamcalculator.dynamicpack; - -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import com.terraformersmc.modmenu.api.ModMenuApi; - -public class ModMenu implements ModMenuApi { - @Override - public ConfigScreenFactory getModConfigScreenFactory() { - return Mod.isDebugScreenAllowed() ? parent -> new DebugScreen() : null; - } -} \ No newline at end of file diff --git a/src/client/java/com/adamcalculator/dynamicpack/PackMixinHelper.java b/src/client/java/com/adamcalculator/dynamicpack/PackMixinHelper.java deleted file mode 100644 index ea19f41..0000000 --- a/src/client/java/com/adamcalculator/dynamicpack/PackMixinHelper.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.adamcalculator.dynamicpack; - -import com.adamcalculator.dynamicpack.pack.Pack; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.pack.PackListWidget; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -public class PackMixinHelper { - private static final Identifier BUTTON_TEXTURE = Identifier.of("dynamicpack", "select_button.png"); - - public static void renderResourcePackEntry(Object resourcePackEntryMixin, DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta, CallbackInfo ci) { - PackListWidget.ResourcePackEntry entry = (PackListWidget.ResourcePackEntry) resourcePackEntryMixin; - if (DynamicPackModBase.INSTANCE.isNameIsDynamic(entry.getName())) { - int i = mouseX - x; - int j = mouseY - y; - context.drawTexture(BUTTON_TEXTURE, x + 174, y+16, 0.0F, ((i >= 174 && j >= 16 && hovered) ? 16f : 0f), 16, 16, 16, 32); - } - } - - public static void mouseClicked(Object resourcePackEntryMixin, PackListWidget widget, double mouseX, double mouseY, int button, CallbackInfoReturnable cir) { - PackListWidget.ResourcePackEntry entry = (PackListWidget.ResourcePackEntry) resourcePackEntryMixin; - Pack pack = DynamicPackModBase.INSTANCE.getDynamicPackByMinecraftName(entry.getName()); - if (pack != null) { - double d = mouseX - (double)widget.getRowLeft(); - double e = mouseY - (double)widget.getRowTop(widget.children().indexOf(entry)); - - if (d >= 174) { - if (e >= 16) { - openPackScreen(pack); - } - } - } - } - - private static void openPackScreen(Pack pack) { - MinecraftClient.getInstance().setScreen(new DynamicPackScreen(MinecraftClient.getInstance().currentScreen, pack)); - } -} diff --git a/src/client/java/com/adamcalculator/dynamicpack/mixin/client/MinecraftClientMixin.java b/src/client/java/com/adamcalculator/dynamicpack/mixin/client/MinecraftClientMixin.java deleted file mode 100644 index e9e71c3..0000000 --- a/src/client/java/com/adamcalculator/dynamicpack/mixin/client/MinecraftClientMixin.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.adamcalculator.dynamicpack.mixin.client; - -import com.adamcalculator.dynamicpack.DynamicPackModBase; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.RunArgs; -import net.minecraft.client.realms.RealmsClient; -import net.minecraft.resource.ResourceReload; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(MinecraftClient.class) -public class MinecraftClientMixin { - @Inject(at = @At("RETURN"), method = "onInitFinished") - private void dynamicpack$initCheck(RealmsClient realms, ResourceReload reload, RunArgs.QuickPlay quickPlay, CallbackInfo ci) { - DynamicPackModBase.INSTANCE.minecraftInitialized(); - } -} diff --git a/src/client/java/com/adamcalculator/dynamicpack/mixin/client/ResourcePackEntryMixin.java b/src/client/java/com/adamcalculator/dynamicpack/mixin/client/ResourcePackEntryMixin.java deleted file mode 100644 index f2047bf..0000000 --- a/src/client/java/com/adamcalculator/dynamicpack/mixin/client/ResourcePackEntryMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.adamcalculator.dynamicpack.mixin.client; - -import com.adamcalculator.dynamicpack.PackMixinHelper; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.pack.PackListWidget; -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; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(PackListWidget.ResourcePackEntry.class) -public abstract class ResourcePackEntryMixin { - @Shadow @Final private PackListWidget widget; - - @Inject(at = @At("RETURN"), method = "render") - private void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta, CallbackInfo ci) { - PackMixinHelper.renderResourcePackEntry(this, context, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta, ci); - } - - @Inject(at = @At("RETURN"), method = "mouseClicked") - private void mouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable cir) { - PackMixinHelper.mouseClicked(this, widget, mouseX, mouseY, button, cir); - } -} diff --git a/src/client/java/com/adamcalculator/dynamicpack/mixin/client/ResourcePackScreenMixin.java b/src/client/java/com/adamcalculator/dynamicpack/mixin/client/ResourcePackScreenMixin.java deleted file mode 100644 index 4109d1b..0000000 --- a/src/client/java/com/adamcalculator/dynamicpack/mixin/client/ResourcePackScreenMixin.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.adamcalculator.dynamicpack.mixin.client; - -import com.adamcalculator.dynamicpack.DynamicPackModBase; -import net.minecraft.client.gui.screen.pack.PackScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(PackScreen.class) -public class ResourcePackScreenMixin { - @Inject(at = @At("RETURN"), method = "updatePackLists") - private void updatePackLists(CallbackInfo ci) { - DynamicPackModBase.INSTANCE.rescanPacks(); - } -} diff --git a/src/client/resources/dynamicpack.client.mixins.json b/src/client/resources/dynamicpack.client.mixins.json deleted file mode 100644 index b2855b1..0000000 --- a/src/client/resources/dynamicpack.client.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "package": "com.adamcalculator.dynamicpack.mixin.client", - "compatibilityLevel": "JAVA_17", - "client": [ - "MinecraftClientMixin", - "ResourcePackEntryMixin", - "ResourcePackScreenMixin" - ], - "injectors": { - "defaultRequire": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/assets/dynamicpack/icon.png b/src/main/resources/assets/dynamicpack/icon.png deleted file mode 100644 index 57e7f86..0000000 Binary files a/src/main/resources/assets/dynamicpack/icon.png and /dev/null differ diff --git a/src/main/resources/assets/dynamicpack/lang/en_us.json b/src/main/resources/assets/dynamicpack/lang/en_us.json deleted file mode 100644 index 042f466..0000000 --- a/src/main/resources/assets/dynamicpack/lang/en_us.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "dynamicpack.toast.needReload": "Packs updated!", - "dynamicpack.toast.needReload.description": "For update: F3 + T", - "dynamicpack.toast.syncStarted": "Sync started", - "dynamicpack.toast.done": "Sync done", - "dynamicpack.toast.pack.done.success.title": "Pack %s", - "dynamicpack.toast.pack.done.success.description": "Done!", - "dynamicpack.toast.pack.error.title": "Pack %s", - "dynamicpack.toast.pack.error.description": "Error while sync...", - "dynamicpack.toast.pack.state.downloading.title": "Pack %s", - "dynamicpack.toast.pack.state.downloading.description": "[%s%%] %s", - "dynamicpack.toast.pack.state.deleting.title": "Pack %s", - "dynamicpack.toast.pack.state.deleting.description": "Delete %s", - "dynamicpack.toast.pack.state.unknown.title": "Pack %s", - "dynamicpack.toast.pack.state.unknown.description": "Processing...", - "dynamicpack.screen.pack.description": "This resource pack support DynamicPack features!", - "dynamicpack.screen.pack.remote_type": "Remote type: %s", - "dynamicpack.screen.pack.latestUpdated": "Latest updated at: %s" -} \ No newline at end of file diff --git a/src/main/resources/assets/dynamicpack/lang/ru_ru.json b/src/main/resources/assets/dynamicpack/lang/ru_ru.json deleted file mode 100644 index 0f4e7cd..0000000 --- a/src/main/resources/assets/dynamicpack/lang/ru_ru.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "dynamicpack.toast.needReload": "Паки обновлены!", - "dynamicpack.toast.needReload.description": "Чтобы обновить: F3 + T", - "dynamicpack.toast.syncStarted": "Процесс начат!", - "dynamicpack.toast.done": "Успешно!", - "dynamicpack.toast.pack.done.success.title": "Пак %s", - "dynamicpack.toast.pack.done.success.description": "Успешно!", - "dynamicpack.toast.pack.error.title": "Пак %s", - "dynamicpack.toast.pack.error.description": "Ошибка...", - "dynamicpack.toast.pack.state.downloading.title": "Пак %s", - "dynamicpack.toast.pack.state.downloading.description": "[%s%%] %s", - "dynamicpack.toast.pack.state.deleting.title": "Пак %s", - "dynamicpack.toast.pack.state.deleting.description": "Удаление %s", - "dynamicpack.toast.pack.state.unknown.title": "Пак %s", - "dynamicpack.toast.pack.state.unknown.description": "Обработка...", - "dynamicpack.screen.pack.description": "Этот ресурспак поддерживает возможности мода DynamicPack!", - "dynamicpack.screen.pack.remote_type": "Тип: %s", - "dynamicpack.screen.pack.latestUpdated": "Обновлён: %s" -} \ No newline at end of file diff --git a/src/main/resources/assets/dynamicpack/select_button.png b/src/main/resources/assets/dynamicpack/select_button.png deleted file mode 100644 index 4810abf..0000000 Binary files a/src/main/resources/assets/dynamicpack/select_button.png and /dev/null differ diff --git a/src/main/resources/dynamicpack.accesswidener b/src/main/resources/dynamicpack.accesswidener deleted file mode 100644 index c2e25c3..0000000 --- a/src/main/resources/dynamicpack.accesswidener +++ /dev/null @@ -1,2 +0,0 @@ -accessWidener v2 named -accessible method net/minecraft/client/gui/widget/EntryListWidget getRowTop (I)I \ No newline at end of file diff --git a/src/main/resources/dynamicpack.mixins.json b/src/main/resources/dynamicpack.mixins.json deleted file mode 100644 index 4f731db..0000000 --- a/src/main/resources/dynamicpack.mixins.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "required": true, - "package": "com.adamcalculator.dynamicpack.mixin", - "compatibilityLevel": "JAVA_17", - "mixins": [ - ], - "injectors": { - "defaultRequire": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json deleted file mode 100644 index a0a6031..0000000 --- a/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "schemaVersion": 1, - "id": "dynamicpack", - "version": "${version}", - "name": "DynamicPack", - "description": "Automatically sync resource packs with a remote server", - "authors": [ - "AdamCalculator" - ], - "contact": { - "homepage": "https://modrinth.com/mod/dynamicpack", - "sources": "https://github.com/AdamCalculator/DynamicPack" - }, - "license": "MIT", - "icon": "assets/dynamicpack/icon.png", - "environment": "client", - "accessWidener": "dynamicpack.accesswidener", - "entrypoints": { - "modmenu": [ - "com.adamcalculator.dynamicpack.ModMenu" - ], - "client": [ - "com.adamcalculator.dynamicpack.FabricDynamicMod" - ] - }, - "mixins": [ - "dynamicpack.mixins.json", - { - "config": "dynamicpack.client.mixins.json", - "environment": "client" - } - ], - "depends": { - "fabricloader": ">=0.14.0", - "minecraft": ">=1.20.1", - "java": ">=17" - } -} \ No newline at end of file