diff --git a/build.gradle b/build.gradle index 5e3800a..ac2da67 100644 --- a/build.gradle +++ b/build.gradle @@ -1,88 +1,64 @@ plugins { - id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "1.10-SNAPSHOT" apply false - id "io.github.pacifistmc.forgix" version "1.2.9" - id "org.ajoberstar.grgit" version "5.3.0" + id "java" + id "maven-publish" + id "net.fabricmc.fabric-loom" version "1.16.3" } -architectury { - minecraft = rootProject.minecraft_version +base.archivesName = rootProject.archives_base_name +version = rootProject.mod_version +group = rootProject.maven_group + +repositories { + maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.terraformersmc.com/releases/" } } -subprojects { - apply plugin: "dev.architectury.loom" +dependencies { + minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - loom { - silentMojangMappingsLicense() + implementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + api "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" + + api("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") { + exclude(group: "net.fabricmc.fabric-api") } - - dependencies { - minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - // The following line declares the mojmap mappings, you may use other mappings as well - mappings loom.officialMojangMappings() - // The following line declares the yarn mappings you may select this one as well. - // mappings "net.fabricmc:yarn:1.19.4+build.2:v2" + api("com.terraformersmc:modmenu:${rootProject.modmenu_version}") { + exclude(group: "net.fabricmc.fabric-api") } - - build.finalizedBy(mergeJars) - assemble.finalizedBy(mergeJars) } -allprojects { - apply plugin: "java" - apply plugin: "architectury-plugin" - apply plugin: "maven-publish" +tasks.withType(JavaCompile).configureEach { + options.encoding = "UTF-8" + options.release = 25 +} - archivesBaseName = rootProject.archives_base_name - version = rootProject.mod_version - group = rootProject.maven_group +java { + toolchain { + languageVersion = JavaLanguageVersion.of(25) + } + withSourcesJar() +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version, + "description": rootProject.mod_description, + "minecraft_version_range": rootProject.minecraft_version_range, + "cloth_config_version": rootProject.cloth_config_version + } +} + +publishing { + publications { + mavenJava(MavenPublication) { + artifactId = rootProject.archives_base_name + from components.java + } + } repositories { - // Add repositories to retrieve artifacts from in here. - // You should only use this when depending on other mods because - // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. - // See https://docs.gradle.org/current/userguide/declaring_repositories.html - // for more information about repositories. - maven { url "https://maven.shedaniel.me/" } - maven { url "https://maven.terraformersmc.com/releases/" } - } - - tasks.withType(JavaCompile) { - options.encoding = "UTF-8" - options.release = 21 - } - - java { - withSourcesJar() + // Add repositories to publish to here. } } - -forgix { - group = "com.mrmelon54.DraggableLists" - mergedJarName = "${project.archivesBaseName}-mc${project.minecraft_version}-${project.mod_version}-${getVersionMetadata()}.jar" - outputDir = "build/libs/merged" -} - -def getVersionMetadata() { - def build_id = System.getenv("GITHUB_RUN_NUMBER") - - // CI builds only - if (build_id != null) { - return "build.${build_id}" - } - - if (grgit != null) { - def head = grgit.head() - def id = head.abbreviatedId - - // Flag the build if the build tree is not clean - if (!grgit.status().clean) { - id += "-dirty" - } - - return "rev.${id}" - } - - // No tracking information could be found about the build - return "unknown" -} diff --git a/common/build.gradle b/common/build.gradle deleted file mode 100644 index 6a9f7c4..0000000 --- a/common/build.gradle +++ /dev/null @@ -1,33 +0,0 @@ -architectury { - common(rootProject.enabled_platforms.split(",")) -} - -loom { - accessWidenerPath = file("src/main/resources/draggable_lists.accesswidener") -} - -dependencies { - // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies - // Do NOT use other classes from fabric loader - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - // Remove the next line if you don't want to depend on the API - modApi "dev.architectury:architectury:${rootProject.architectury_version}" - - modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") { - exclude(group: "net.fabricmc.fabric-api") - } -} - -publishing { - publications { - mavenCommon(MavenPublication) { - artifactId = rootProject.archives_base_name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/duck/ResourcePackOrganizerDuckProvider.java b/common/src/main/java/com/mrmelon54/DraggableLists/duck/ResourcePackOrganizerDuckProvider.java deleted file mode 100644 index b01a81d..0000000 --- a/common/src/main/java/com/mrmelon54/DraggableLists/duck/ResourcePackOrganizerDuckProvider.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.mrmelon54.DraggableLists.duck; - -public interface ResourcePackOrganizerDuckProvider { - void draggable_lists$updateSelectedList(); -} diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionList_PackEntryMixin.java b/common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionList_PackEntryMixin.java deleted file mode 100644 index c06570e..0000000 --- a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionList_PackEntryMixin.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.mrmelon54.DraggableLists.mixin.packs; - -import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import com.mojang.blaze3d.pipeline.RenderPipeline; -import com.mrmelon54.DraggableLists.DragItem; -import com.mrmelon54.DraggableLists.DraggableLists; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.components.ObjectSelectionList; -import net.minecraft.client.gui.screens.packs.PackSelectionModel; -import net.minecraft.client.gui.screens.packs.TransferableSelectionList; -import net.minecraft.resources.ResourceLocation; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(TransferableSelectionList.PackEntry.class) -public abstract class TransferableSelectionList_PackEntryMixin extends ObjectSelectionList.Entry implements DragItem { - @Shadow - @Final - private TransferableSelectionList parent; - - @Shadow - @Final - private PackSelectionModel.Entry pack; - - @Unique - private boolean draggable_lists$isBeingDragged = false; - - @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 4)) - public boolean removeOnUpArrowButtons(GuiGraphics instance, RenderPipeline renderPipeline, ResourceLocation resourceLocation, int i, int j, int k, int l) { - return !DraggableLists.CONFIG.disableResourcePackArrows; - } - - @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 5)) - public boolean removeOffUpArrowButtons(GuiGraphics instance, RenderPipeline renderPipeline, ResourceLocation resourceLocation, int i, int j, int k, int l) { - return !DraggableLists.CONFIG.disableResourcePackArrows; - } - - @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 6)) - public boolean removeOnDownArrowButtons(GuiGraphics instance, RenderPipeline renderPipeline, ResourceLocation resourceLocation, int i, int j, int k, int l) { - return !DraggableLists.CONFIG.disableResourcePackArrows; - } - - @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 7)) - public boolean removeOffDownArrowButtons(GuiGraphics instance, RenderPipeline renderPipeline, ResourceLocation resourceLocation, int i, int j, int k, int l) { - return !DraggableLists.CONFIG.disableResourcePackArrows; - } - - @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) - public void removeMoveTowardEnd(double d, double e, int i, CallbackInfoReturnable cir) { - if (!DraggableLists.CONFIG.disableResourcePackArrows) return; - - // Allow using the whole pack selection button - if (pack.canSelect()) return; - - double f = d - (double) parent.getRowLeft(); - if (f < 16 || f > 32) return; - - cir.setReturnValue(true); - cir.cancel(); - } - - @Override - public PackSelectionModel.Entry draggable_lists$getUnderlyingData() { - return pack; - } - - @Override - public TransferableSelectionList.PackEntry draggable_lists$getUnderlyingEntry() { - return (TransferableSelectionList.PackEntry) (Object) this; - } - - @Override - public void draggable_lists$render(GuiGraphics guiGraphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { - if (!draggable_lists$isBeingDragged) return; - render(guiGraphics, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta); - } - - @Override - public void draggable_lists$setBeingDragged(boolean v) { - draggable_lists$isBeingDragged = v; - } -} diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/server/OnlineServerEntryMixin.java b/common/src/main/java/com/mrmelon54/DraggableLists/mixin/server/OnlineServerEntryMixin.java deleted file mode 100644 index 6dc4fb6..0000000 --- a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/server/OnlineServerEntryMixin.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.mrmelon54.DraggableLists.mixin.server; - -import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import com.mojang.blaze3d.pipeline.RenderPipeline; -import com.mrmelon54.DraggableLists.DragItem; -import com.mrmelon54.DraggableLists.DraggableLists; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.components.ObjectSelectionList; -import net.minecraft.client.gui.screens.multiplayer.ServerSelectionList; -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.resources.ResourceLocation; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.function.Function; - -@Mixin(ServerSelectionList.OnlineServerEntry.class) -public abstract class OnlineServerEntryMixin extends ObjectSelectionList.Entry implements DragItem { - @Shadow - @Final - private ServerData serverData; - - @Shadow - public abstract void render(GuiGraphics guiGraphics, int i, int j, int k, int l, int m, int n, int o, boolean bl, float f); - - @Shadow - @Final - ServerSelectionList field_19117; - - @Shadow - public abstract boolean mouseClicked(double d, double e, int i); - - @Unique - private boolean draggable_lists$isBeingDragged; - - @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 3)) - public boolean removeUpOnButton(GuiGraphics instance, RenderPipeline renderPipeline, ResourceLocation resourceLocation, int i, int j, int k, int l) { - return !DraggableLists.CONFIG.disableServerArrows; - } - - @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 4)) - public boolean removeUpButton(GuiGraphics instance, RenderPipeline renderPipeline, ResourceLocation resourceLocation, int i, int j, int k, int l) { - return !DraggableLists.CONFIG.disableServerArrows; - } - - @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 5)) - public boolean removeDownOnButton(GuiGraphics instance, RenderPipeline renderPipeline, ResourceLocation resourceLocation, int i, int j, int k, int l) { - return !DraggableLists.CONFIG.disableServerArrows; - } - - @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 6)) - public boolean removeDownButton(GuiGraphics instance, RenderPipeline renderPipeline, ResourceLocation resourceLocation, int i, int j, int k, int l) { - return !DraggableLists.CONFIG.disableServerArrows; - } - - @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) - public void removeSwapEntries(double d, double e, int i, CallbackInfoReturnable cir) { - double l = field_19117.getRowLeft(); - double f = d - l; - - // don't click buttons left of 16 pixels - if (f <= 16) { - mouseClicked(l + 32, e, i); - cir.setReturnValue(true); - cir.cancel(); - } - } - - @Override - public ServerData draggable_lists$getUnderlyingData() { - return serverData; - } - - @Override - public ServerSelectionList.OnlineServerEntry draggable_lists$getUnderlyingEntry() { - return (ServerSelectionList.OnlineServerEntry) (Object) this; - } - - @Override - public void draggable_lists$render(GuiGraphics guiGraphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { - if (!draggable_lists$isBeingDragged) return; - render(guiGraphics, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta); - } - - @Override - public void draggable_lists$setBeingDragged(boolean v) { - draggable_lists$isBeingDragged = v; - } -} diff --git a/common/src/main/resources/architectury.common.json b/common/src/main/resources/architectury.common.json deleted file mode 100644 index 07cf8a0..0000000 --- a/common/src/main/resources/architectury.common.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "accessWidener": "draggable_lists.accesswidener" -} diff --git a/fabric-like/build.gradle b/fabric-like/build.gradle deleted file mode 100644 index 9856a49..0000000 --- a/fabric-like/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -architectury { - common(rootProject.enabled_platforms.split(",")) -} - -loom { - accessWidenerPath = project(":common").loom.accessWidenerPath -} - -dependencies { - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" - // Remove the next line if you don't want to depend on the API - modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}" - - modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") { - exclude(group: "net.fabricmc.fabric-api") - } - modApi("com.terraformersmc:modmenu:${rootProject.modmenu_version}") { - exclude(group: "net.fabricmc.fabric-api") - } - - compileOnly(project(path: ":common", configuration: "namedElements")) { transitive false } -} diff --git a/fabric-like/src/main/java/com/mrmelon54/DraggableLists/fabriclike/DraggableListsFabricLike.java b/fabric-like/src/main/java/com/mrmelon54/DraggableLists/fabriclike/DraggableListsFabricLike.java deleted file mode 100644 index 0ed6387..0000000 --- a/fabric-like/src/main/java/com/mrmelon54/DraggableLists/fabriclike/DraggableListsFabricLike.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.mrmelon54.DraggableLists.fabriclike; - -import com.mrmelon54.DraggableLists.DraggableLists; - -public class DraggableListsFabricLike { - public static void init() { - DraggableLists.init(); - } -} diff --git a/fabric/build.gradle b/fabric/build.gradle deleted file mode 100644 index 83fd4d6..0000000 --- a/fabric/build.gradle +++ /dev/null @@ -1,95 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" -} - -architectury { - platformSetupLoomIde() - fabric() -} - -loom { - accessWidenerPath = project(":common").loom.accessWidenerPath -} - -configurations { - common - shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentFabric.extendsFrom common -} - -dependencies { - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" - // Remove the next line if you don't want to depend on the API - modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}" - - modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") { - exclude(group: "net.fabricmc.fabric-api") - } - modApi("com.terraformersmc:modmenu:${rootProject.modmenu_version}") { - exclude(group: "net.fabricmc.fabric-api") - } - - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } - common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":fabric-like", configuration: "transformProductionFabric")) { transitive false } -} - -processResources { - inputs.property "version", project.version - - filesMatching("fabric.mod.json") { - expand "version": project.version, - "description": rootProject.mod_description, - "minecraft_version": rootProject.minecraft_version, - "architectury_version": rootProject.architectury_version, - "cloth_config_version": rootProject.cloth_config_version - } -} - -shadowJar { - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - archiveClassifier.set "dev-shadow" -} - -remapJar { - injectAccessWidener = true - input.set shadowJar.archiveFile - dependsOn shadowJar - archiveClassifier.set null -} - -jar { - archiveClassifier.set "dev-shadow" -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenFabric(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} diff --git a/fabric/src/main/resources/draggable_lists.mixins.json b/fabric/src/main/resources/draggable_lists.mixins.json deleted file mode 100644 index a18fe2c..0000000 --- a/fabric/src/main/resources/draggable_lists.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "package": "com.mrmelon54.DraggableLists.mixin.fabric", - "compatibilityLevel": "JAVA_21", - "minVersion": "0.8", - "client": [ - ], - "mixins": [ - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json deleted file mode 100644 index 867f657..0000000 --- a/fabric/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "schemaVersion": 1, - "id": "draggable_lists", - "version": "${version}", - "name": "Draggable Lists", - "description": "${description}", - "authors": [ - "MrMelon54" - ], - "contact": { - "homepage": "https://mrmelon54.com/minecraft/draggable-lists", - "sources": "https://github.com/mrmelon54/draggable_lists", - "issues": "https://github.com/mrmelon54/draggable_lists/issues" - }, - "license": "GPL-3.0-only", - "icon": "icon.png", - "environment": "client", - "entrypoints": { - "main": [ - "com.mrmelon54.DraggableLists.fabric.DraggableListsFabric" - ], - "modmenu": [ - "com.mrmelon54.DraggableLists.fabriclike.ModMenuIntegration" - ] - }, - "mixins": [ - "draggable_lists.mixins.json", - "draggable_lists-common.mixins.json" - ], - "depends": { - "fabric": "*", - "minecraft": ">=${minecraft_version}", - "architectury": ">=${architectury_version}", - "cloth-config": ">=${cloth_config_version}" - } -} diff --git a/gradle.properties b/gradle.properties index 845ef1a..9d01e6e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ org.gradle.jvmargs=-Xmx4096M -minecraft_version=1.21.6 -enabled_platforms=quilt,fabric,neoforge +minecraft_version=26.1.2 +minecraft_version_range=>=26.1 <26.2 archives_base_name=draggable_lists mod_id=draggable_lists @@ -10,16 +10,8 @@ mod_version=1.0.15 mod_description=Draggable resource packs, datapacks, servers and worlds maven_group=com.mrmelon54.DraggableLists -architectury_version=17.0.6 +fabric_loader_version=0.19.1 +fabric_api_version=0.151.0+26.1.2 -fabric_loader_version=0.17.2 -fabric_api_version=0.128.2+1.21.6 - -neoforge_version=21.6.20-beta - -quilt_loader_version=0.29.2-beta.1 -quilt_qsl_version=9.0.0-alpha.1+1.20.6 -quilt_fabric_api_version=10.0.0-alpha.3+0.100.4-1.20.6 - -cloth_config_version=19.0.147 -modmenu_version=15.0.0-beta.3 +cloth_config_version=26.1.154 +modmenu_version=18.0.0-beta.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 94113f2..c61a118 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/neoforge/build.gradle b/neoforge/build.gradle deleted file mode 100644 index 2604612..0000000 --- a/neoforge/build.gradle +++ /dev/null @@ -1,91 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" -} - -repositories { - maven { url "https://maven.neoforged.net/releases/" } -} - -architectury { - platformSetupLoomIde() - neoForge() -} - -loom { - accessWidenerPath = project(":common").loom.accessWidenerPath -} - -configurations { - common - shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentNeoforge.extendsFrom common -} - -dependencies { - neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}" - // Remove the next line if you don't want to depend on the API - modApi "dev.architectury:architectury-neoforge:${rootProject.architectury_version}" - - modApi "me.shedaniel.cloth:cloth-config-neoforge:${rootProject.cloth_config_version}" - - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false } -} - -processResources { - inputs.property "version", project.version - - filesMatching("META-INF/neoforge.mods.toml") { - expand "version": project.version, - "description": rootProject.mod_description, - "minecraft_version": rootProject.minecraft_version, - "architectury_version": rootProject.architectury_version, - "cloth_config_version": rootProject.cloth_config_version - } -} - -shadowJar { - exclude "fabric.mod.json" - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - archiveClassifier.set "dev-shadow" -} - -remapJar { - input.set shadowJar.archiveFile - dependsOn shadowJar - archiveClassifier.set null -} - -jar { - archiveClassifier.set "dev-shadow" -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenNeoforge(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} diff --git a/neoforge/gradle.properties b/neoforge/gradle.properties deleted file mode 100644 index 2914393..0000000 --- a/neoforge/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform=neoforge \ No newline at end of file diff --git a/neoforge/src/main/java/com/mrmelon54/DraggableLists/neoforge/DraggableListsNeoforge.java b/neoforge/src/main/java/com/mrmelon54/DraggableLists/neoforge/DraggableListsNeoforge.java deleted file mode 100644 index f993a66..0000000 --- a/neoforge/src/main/java/com/mrmelon54/DraggableLists/neoforge/DraggableListsNeoforge.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.mrmelon54.DraggableLists.neoforge; - -import com.mrmelon54.DraggableLists.DraggableLists; -import net.neoforged.fml.ModLoadingContext; -import net.neoforged.fml.common.Mod; -import net.neoforged.fml.loading.FMLEnvironment; -import net.neoforged.neoforge.client.gui.IConfigScreenFactory; - -@Mod(DraggableLists.MOD_ID) -public class DraggableListsNeoforge { - public DraggableListsNeoforge() { - if (!FMLEnvironment.dist.isClient()) - return; - - ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory.class, () -> (client, parent) -> DraggableLists.createConfigScreen(parent).get()); - DraggableLists.init(); - } -} diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml deleted file mode 100644 index 6d934f0..0000000 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ /dev/null @@ -1,39 +0,0 @@ -modLoader = "javafml" -loaderVersion = "*" -issueTrackerURL = "https://github.com/mrmelon54/draggable_lists/issues" -license = "GPL-3.0-only" - -[[mods]] -modId = "draggable_lists" -version = "${version}" -displayName = "Draggable Lists" -authors = "MrMelon54" -description = "${description}" -logoFile = "/icon.png" - -[[dependencies.draggable_lists]] -modId = "minecraft" -mandatory = true -versionRange = "${minecraft_version}" -ordering = "NONE" -side = "BOTH" - -[[dependencies.draggable_lists]] -modId = "architectury" -mandatory = true -versionRange = "[${architectury_version},)" -ordering = "AFTER" -side = "BOTH" - -[[dependencies.draggable_lists]] -modId = "cloth_config" -mandatory = true -versionRange = "[${cloth_config_version},)" -ordering = "AFTER" -side = "BOTH" - -[[mixins]] -config = "draggable_lists-common.mixins.json" - -[[mixins]] -config = "draggable_lists.mixins.json" diff --git a/neoforge/src/main/resources/draggable_lists.mixins.json b/neoforge/src/main/resources/draggable_lists.mixins.json deleted file mode 100644 index 6970d63..0000000 --- a/neoforge/src/main/resources/draggable_lists.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "package": "com.mrmelon54.DraggableLists.mixin.neoforge", - "compatibilityLevel": "JAVA_21", - "minVersion": "0.8", - "client": [ - ], - "mixins": [ - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/neoforge/src/main/resources/pack.mcmeta b/neoforge/src/main/resources/pack.mcmeta deleted file mode 100644 index 8f3017c..0000000 --- a/neoforge/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "Draggable Lists", - "pack_format": 15 - } -} diff --git a/quilt/build.gradle b/quilt/build.gradle deleted file mode 100644 index fc3644c..0000000 --- a/quilt/build.gradle +++ /dev/null @@ -1,108 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" -} - -repositories { - maven { url "https://maven.quiltmc.org/repository/release/" } -} - -architectury { - platformSetupLoomIde() - loader("quilt") -} - -loom { - accessWidenerPath = project(":common").loom.accessWidenerPath -} - -configurations { - common - shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentQuilt.extendsFrom common -} - -dependencies { - modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}" - modApi "org.quiltmc:qsl:${rootProject.quilt_qsl_version}" - modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}" - // Remove the next few lines if you don't want to depend on the API - modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") { - // We must not pull Fabric Loader from Architectury Fabric - exclude group: "net.fabricmc" - exclude group: "net.fabricmc.fabric-api" - } - - modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") { - exclude(group: "net.fabricmc") - exclude(group: "net.fabricmc.fabric-api") - } - modApi("com.terraformersmc:modmenu:${rootProject.modmenu_version}") { - exclude(group: "net.fabricmc") - exclude(group: "net.fabricmc.fabric-api") - } - - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false } - common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":fabric-like", configuration: "transformProductionQuilt")) { transitive false } -} - -processResources { - inputs.property "group", rootProject.maven_group - inputs.property "version", project.version - - filesMatching("quilt.mod.json") { - expand "group": rootProject.maven_group, - "version": project.version, - "description": rootProject.mod_description, - "minecraft_version": rootProject.minecraft_version, - "architectury_version": rootProject.architectury_version, - "cloth_config_version": rootProject.cloth_config_version - } -} - -shadowJar { - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - archiveClassifier.set "dev-shadow" -} - -remapJar { - injectAccessWidener = true - input.set shadowJar.archiveFile - dependsOn shadowJar - archiveClassifier.set null -} - -jar { - archiveClassifier.set "dev-shadow" -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenQuilt(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} diff --git a/quilt/gradle.properties b/quilt/gradle.properties deleted file mode 100644 index 96758ce..0000000 --- a/quilt/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform=quilt \ No newline at end of file diff --git a/quilt/src/main/java/com/mrmelon54/DraggableLists/quilt/DraggableListsQuilt.java b/quilt/src/main/java/com/mrmelon54/DraggableLists/quilt/DraggableListsQuilt.java deleted file mode 100644 index f2cc038..0000000 --- a/quilt/src/main/java/com/mrmelon54/DraggableLists/quilt/DraggableListsQuilt.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.mrmelon54.DraggableLists.quilt; - -import com.mrmelon54.DraggableLists.fabriclike.DraggableListsFabricLike; -import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; - -public class DraggableListsQuilt implements ModInitializer { - @Override - public void onInitialize(ModContainer mod) { - DraggableListsFabricLike.init(); - } -} diff --git a/quilt/src/main/resources/draggable_lists.mixins.json b/quilt/src/main/resources/draggable_lists.mixins.json deleted file mode 100644 index a18fe2c..0000000 --- a/quilt/src/main/resources/draggable_lists.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "package": "com.mrmelon54.DraggableLists.mixin.fabric", - "compatibilityLevel": "JAVA_21", - "minVersion": "0.8", - "client": [ - ], - "mixins": [ - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json deleted file mode 100644 index 3367e1f..0000000 --- a/quilt/src/main/resources/quilt.mod.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "schema_version": 1, - "mixin": [ - "draggable_lists.mixins.json", - "draggable_lists-common.mixins.json" - ], - "quilt_loader": { - "group": "${group}", - "id": "draggable_lists", - "version": "${version}", - "metadata": { - "name": "Draggable Lists", - "description": "${description}", - "contributors": { - "MrMelon54": "Owner" - }, - "contact": { - "homepage": "https://mrmelon54.com/minecraft/draggable-lists", - "sources": "https://github.com/mrmelon54/draggable_lists", - "issues": "https://github.com/mrmelon54/draggable_lists/issues" - }, - "license": "GPL-3.0-only", - "icon": "icon.png" - }, - "intermediate_mappings": "net.fabricmc:intermediary", - "entrypoints": { - "init": [ - "com.mrmelon54.DraggableLists.quilt.DraggableListsQuilt" - ], - "modmenu": [ - "com.mrmelon54.DraggableLists.fabriclike.ModMenuIntegration" - ] - }, - "depends": [ - { - "id": "quilt_loader", - "version": "*" - }, - { - "id": "quilt_base", - "version": "*" - }, - { - "id": "minecraft", - "version": ">=${minecraft_version}" - }, - { - "id": "architectury", - "version": ">=${architectury_version}" - }, - { - "id": "cloth-config", - "version": ">=${cloth_config_version}" - } - ] - }, - "minecraft": { - "environment": "client" - } -} diff --git a/settings.gradle b/settings.gradle index 7093621..3d8a736 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,18 +1,13 @@ pluginManagement { repositories { maven { url "https://maven.fabricmc.net/" } - maven { url "https://maven.architectury.dev/" } - maven { url "https://maven.minecraftforge.net/" } - maven { url "https://maven.neoforged.net/releases/" } gradlePluginPortal() mavenCentral() } } -include("common") -include("fabric-like") -include("fabric") -include("quilt") -include("neoforge") +plugins { + id "org.gradle.toolchains.foojay-resolver-convention" version "1.0.0" +} rootProject.name = "draggable_lists" diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/Cursor.java b/src/main/java/com/mrmelon54/DraggableLists/Cursor.java similarity index 56% rename from common/src/main/java/com/mrmelon54/DraggableLists/Cursor.java rename to src/main/java/com/mrmelon54/DraggableLists/Cursor.java index 2934434..566c0f4 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/Cursor.java +++ b/src/main/java/com/mrmelon54/DraggableLists/Cursor.java @@ -8,12 +8,12 @@ public class Cursor { public static void setDragging() { isDragging = true; - GLFW.glfwSetCursor(Minecraft.getInstance().getWindow().getWindow(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_VRESIZE_CURSOR)); + GLFW.glfwSetCursor(Minecraft.getInstance().getWindow().handle(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_VRESIZE_CURSOR)); } public static void reset() { if (!isDragging) return; isDragging = false; - GLFW.glfwSetCursor(Minecraft.getInstance().getWindow().getWindow(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR)); + GLFW.glfwSetCursor(Minecraft.getInstance().getWindow().handle(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR)); } } diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/DragItem.java b/src/main/java/com/mrmelon54/DraggableLists/DragItem.java similarity index 58% rename from common/src/main/java/com/mrmelon54/DraggableLists/DragItem.java rename to src/main/java/com/mrmelon54/DraggableLists/DragItem.java index d3c83bd..0c0203b 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/DragItem.java +++ b/src/main/java/com/mrmelon54/DraggableLists/DragItem.java @@ -1,6 +1,6 @@ package com.mrmelon54.DraggableLists; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.components.ObjectSelectionList; public interface DragItem> { @@ -8,7 +8,7 @@ public interface DragItem> { E draggable_lists$getUnderlyingEntry(); - void draggable_lists$render(GuiGraphics guiGraphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta); + void draggable_lists$render(GuiGraphicsExtractor guiGraphics, int x, int y, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta); void draggable_lists$setBeingDragged(boolean v); } diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/DragList.java b/src/main/java/com/mrmelon54/DraggableLists/DragList.java similarity index 77% rename from common/src/main/java/com/mrmelon54/DraggableLists/DragList.java rename to src/main/java/com/mrmelon54/DraggableLists/DragList.java index 75a915b..f617b2f 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/DragList.java +++ b/src/main/java/com/mrmelon54/DraggableLists/DragList.java @@ -1,6 +1,6 @@ package com.mrmelon54.DraggableLists; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.components.ObjectSelectionList; public interface DragList> { @@ -10,8 +10,6 @@ public interface DragList> { void draggable_lists$setDragging(boolean b); - int draggable_lists$getHeaderHeight(); - int draggable_lists$getY(); int draggable_lists$getBottom(); @@ -34,5 +32,5 @@ public interface DragList> { int draggable_lists$getItemCount(); - void draggable_lists$renderItem(GuiGraphics guiGraphics, int mouseX, int mouseY, float tickDelta, int i, int rowLeft, int rowTop, int rowWidth, int rowHeight); + void draggable_lists$renderItem(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float tickDelta, int i, int rowLeft, int rowTop, int rowWidth, int rowHeight); } diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/DragManager.java b/src/main/java/com/mrmelon54/DraggableLists/DragManager.java similarity index 91% rename from common/src/main/java/com/mrmelon54/DraggableLists/DragManager.java rename to src/main/java/com/mrmelon54/DraggableLists/DragManager.java index b708aa3..757a2fc 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/DragManager.java +++ b/src/main/java/com/mrmelon54/DraggableLists/DragManager.java @@ -1,10 +1,10 @@ package com.mrmelon54.DraggableLists; -import net.minecraft.Util; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.components.ObjectSelectionList; import net.minecraft.util.ARGB; import net.minecraft.util.Mth; +import net.minecraft.util.Util; public class DragManager> { private final DragList dragList; @@ -77,7 +77,7 @@ public class DragManager> { return selectedItem != null; } - public void renderListItems(GuiGraphics guiGraphics, int mouseX, int mouseY, float tickDelta) { + public void renderListItems(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float tickDelta) { int rowLeft = (int) dragList.draggable_lists$getRowLeft(); int rowWidth = dragList.draggable_lists$getRowWidth(); int rowHeight = dragList.draggable_lists$getItemHeight() - 4; @@ -105,7 +105,7 @@ public class DragManager> { } - public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { + public void renderWidget(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float delta) { if (selectedItem == null) return; int z = Mth.floor(mouseY + draggingOffsetY); @@ -117,7 +117,7 @@ public class DragManager> { guiGraphics.pose().pushMatrix(); float shaderColorValue = 191f / 255f; guiGraphics.fill(x - 1, y - 1, x + entryWidth - 2, y + entryHeight + 1, ARGB.colorFromFloat(0.5f, shaderColorValue, shaderColorValue, shaderColorValue)); - selectedItem.draggable_lists$render(guiGraphics, 0, y, x, entryWidth, entryHeight, mouseX, mouseY, false, delta); + selectedItem.draggable_lists$render(guiGraphics, x, y, entryWidth, entryHeight, mouseX, mouseY, false, delta); guiGraphics.pose().popMatrix(); if (y < z) { @@ -156,8 +156,11 @@ public class DragManager> { } private int getIndexFromMouseY(double mouseY) { - int m = Mth.floor(mouseY - (double) dragList.draggable_lists$getY()) - dragList.draggable_lists$getHeaderHeight() + (int) dragList.draggable_lists$getScrollAmount() - 4; - return m / dragList.draggable_lists$getItemHeight(); + int n = dragList.draggable_lists$getItemCount(); + for (int i = 0; i < n; i++) { + if (mouseY < dragList.draggable_lists$getRowBottom(i)) return i; + } + return n; } private boolean dragServerItem(DragItem item, double mouseY) { diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/DraggableLists.java b/src/main/java/com/mrmelon54/DraggableLists/DraggableLists.java similarity index 61% rename from common/src/main/java/com/mrmelon54/DraggableLists/DraggableLists.java rename to src/main/java/com/mrmelon54/DraggableLists/DraggableLists.java index 4c37ec7..1ce91b5 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/DraggableLists.java +++ b/src/main/java/com/mrmelon54/DraggableLists/DraggableLists.java @@ -2,6 +2,9 @@ package com.mrmelon54.DraggableLists; import com.mrmelon54.DraggableLists.config.ConfigStructure; import me.shedaniel.autoconfig.AutoConfig; +import me.shedaniel.autoconfig.ConfigManager; +import me.shedaniel.autoconfig.gui.ConfigScreenProvider; +import me.shedaniel.autoconfig.gui.registry.DefaultGuiRegistryAccess; import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; import net.minecraft.client.gui.screens.Screen; @@ -15,6 +18,7 @@ public class DraggableLists { } public static Supplier createConfigScreen(Screen screen) { - return AutoConfig.getConfigScreen(ConfigStructure.class, screen); + ConfigManager manager = (ConfigManager) AutoConfig.getConfigHolder(ConfigStructure.class); + return new ConfigScreenProvider<>(manager, new DefaultGuiRegistryAccess(), screen); } } diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/config/ConfigStructure.java b/src/main/java/com/mrmelon54/DraggableLists/config/ConfigStructure.java similarity index 100% rename from common/src/main/java/com/mrmelon54/DraggableLists/config/ConfigStructure.java rename to src/main/java/com/mrmelon54/DraggableLists/config/ConfigStructure.java diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/config/EnabledMode.java b/src/main/java/com/mrmelon54/DraggableLists/config/EnabledMode.java similarity index 70% rename from common/src/main/java/com/mrmelon54/DraggableLists/config/EnabledMode.java rename to src/main/java/com/mrmelon54/DraggableLists/config/EnabledMode.java index 46a2883..dead9b3 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/config/EnabledMode.java +++ b/src/main/java/com/mrmelon54/DraggableLists/config/EnabledMode.java @@ -1,6 +1,6 @@ package com.mrmelon54.DraggableLists.config; -import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.Minecraft; public enum EnabledMode { DISABLED, @@ -10,7 +10,7 @@ public enum EnabledMode { public boolean isEnabled() { return switch (this) { case DISABLED -> false; - case REQUIRES_MODIFIER -> Screen.hasShiftDown(); + case REQUIRES_MODIFIER -> Minecraft.getInstance().hasShiftDown(); case ENABLED -> true; }; } diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/duck/AbstractPackDuckProvider.java b/src/main/java/com/mrmelon54/DraggableLists/duck/AbstractPackDuckProvider.java similarity index 100% rename from common/src/main/java/com/mrmelon54/DraggableLists/duck/AbstractPackDuckProvider.java rename to src/main/java/com/mrmelon54/DraggableLists/duck/AbstractPackDuckProvider.java diff --git a/src/main/java/com/mrmelon54/DraggableLists/duck/ResourcePackOrganizerDuckProvider.java b/src/main/java/com/mrmelon54/DraggableLists/duck/ResourcePackOrganizerDuckProvider.java new file mode 100644 index 0000000..f0697ef --- /dev/null +++ b/src/main/java/com/mrmelon54/DraggableLists/duck/ResourcePackOrganizerDuckProvider.java @@ -0,0 +1,7 @@ +package com.mrmelon54.DraggableLists.duck; + +import net.minecraft.client.gui.screens.packs.PackSelectionModel; + +public interface ResourcePackOrganizerDuckProvider { + void draggable_lists$updateSelectedList(PackSelectionModel.EntryBase entry); +} diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/duck/ServerListDuckProvider.java b/src/main/java/com/mrmelon54/DraggableLists/duck/ServerListDuckProvider.java similarity index 100% rename from common/src/main/java/com/mrmelon54/DraggableLists/duck/ServerListDuckProvider.java rename to src/main/java/com/mrmelon54/DraggableLists/duck/ServerListDuckProvider.java diff --git a/fabric/src/main/java/com/mrmelon54/DraggableLists/fabric/DraggableListsFabric.java b/src/main/java/com/mrmelon54/DraggableLists/fabric/DraggableListsFabric.java similarity index 64% rename from fabric/src/main/java/com/mrmelon54/DraggableLists/fabric/DraggableListsFabric.java rename to src/main/java/com/mrmelon54/DraggableLists/fabric/DraggableListsFabric.java index d2ed175..4ed90e3 100644 --- a/fabric/src/main/java/com/mrmelon54/DraggableLists/fabric/DraggableListsFabric.java +++ b/src/main/java/com/mrmelon54/DraggableLists/fabric/DraggableListsFabric.java @@ -1,11 +1,11 @@ package com.mrmelon54.DraggableLists.fabric; -import com.mrmelon54.DraggableLists.fabriclike.DraggableListsFabricLike; +import com.mrmelon54.DraggableLists.DraggableLists; import net.fabricmc.api.ModInitializer; public class DraggableListsFabric implements ModInitializer { @Override public void onInitialize() { - DraggableListsFabricLike.init(); + DraggableLists.init(); } } diff --git a/fabric-like/src/main/java/com/mrmelon54/DraggableLists/fabriclike/ModMenuIntegration.java b/src/main/java/com/mrmelon54/DraggableLists/fabric/ModMenuIntegration.java similarity index 59% rename from fabric-like/src/main/java/com/mrmelon54/DraggableLists/fabriclike/ModMenuIntegration.java rename to src/main/java/com/mrmelon54/DraggableLists/fabric/ModMenuIntegration.java index dc2700b..480f5a4 100644 --- a/fabric-like/src/main/java/com/mrmelon54/DraggableLists/fabriclike/ModMenuIntegration.java +++ b/src/main/java/com/mrmelon54/DraggableLists/fabric/ModMenuIntegration.java @@ -1,9 +1,8 @@ -package com.mrmelon54.DraggableLists.fabriclike; +package com.mrmelon54.DraggableLists.fabric; -import com.mrmelon54.DraggableLists.config.ConfigStructure; +import com.mrmelon54.DraggableLists.DraggableLists; import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ModMenuApi; -import me.shedaniel.autoconfig.AutoConfig; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -11,6 +10,6 @@ import net.fabricmc.api.Environment; public class ModMenuIntegration implements ModMenuApi { @Override public ConfigScreenFactory getModConfigScreenFactory() { - return parent -> AutoConfig.getConfigScreen(ConfigStructure.class, parent).get(); + return parent -> DraggableLists.createConfigScreen(parent).get(); } } diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/MinecraftMixin.java b/src/main/java/com/mrmelon54/DraggableLists/mixin/MinecraftMixin.java similarity index 100% rename from common/src/main/java/com/mrmelon54/DraggableLists/mixin/MinecraftMixin.java rename to src/main/java/com/mrmelon54/DraggableLists/mixin/MinecraftMixin.java diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModelMixin.java b/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModelMixin.java similarity index 69% rename from common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModelMixin.java rename to src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModelMixin.java index 720511c..b66005f 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModelMixin.java +++ b/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModelMixin.java @@ -6,14 +6,16 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import java.util.function.Consumer; + @Mixin(PackSelectionModel.class) public abstract class PackSelectionModelMixin implements ResourcePackOrganizerDuckProvider { @Shadow @Final - Runnable onListChanged; + Consumer onListChanged; @Override - public void draggable_lists$updateSelectedList() { - onListChanged.run(); + public void draggable_lists$updateSelectedList(PackSelectionModel.EntryBase entry) { + onListChanged.accept(entry); } } diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModel_EntryBaseMixin.java b/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModel_EntryBaseMixin.java similarity index 79% rename from common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModel_EntryBaseMixin.java rename to src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModel_EntryBaseMixin.java index 338b10d..5396fef 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModel_EntryBaseMixin.java +++ b/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionModel_EntryBaseMixin.java @@ -4,7 +4,6 @@ import com.mrmelon54.DraggableLists.duck.AbstractPackDuckProvider; import com.mrmelon54.DraggableLists.duck.ResourcePackOrganizerDuckProvider; import net.minecraft.client.gui.screens.packs.PackSelectionModel; import net.minecraft.server.packs.repository.Pack; -import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -22,9 +21,8 @@ public abstract class PackSelectionModel_EntryBaseMixin implements AbstractPackD private Pack pack; @Shadow - @Dynamic("field_25460 is provided by PackSelectionModel.EntryBase but has no mapping") @Final - private PackSelectionModel field_25460; + private PackSelectionModel this$0; @Override public void draggable_lists$moveTo(int j) { @@ -40,8 +38,8 @@ public abstract class PackSelectionModel_EntryBaseMixin implements AbstractPackD list.removeAll(list1); list.addAll(list1); - if (field_25460 instanceof ResourcePackOrganizerDuckProvider duckProvider) - duckProvider.draggable_lists$updateSelectedList(); + if (this$0 instanceof ResourcePackOrganizerDuckProvider duckProvider) + duckProvider.draggable_lists$updateSelectedList((PackSelectionModel.EntryBase) (Object) this); } } diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionScreenMixin.java b/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionScreenMixin.java similarity index 83% rename from common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionScreenMixin.java rename to src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionScreenMixin.java index 44d1ad2..639cffe 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionScreenMixin.java +++ b/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/PackSelectionScreenMixin.java @@ -4,6 +4,8 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.packs.PackSelectionModel; import net.minecraft.client.gui.screens.packs.PackSelectionScreen; import net.minecraft.client.gui.screens.packs.TransferableSelectionList; +import net.minecraft.client.input.MouseButtonEvent; +import net.minecraft.client.input.MouseButtonInfo; import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -27,8 +29,8 @@ public abstract class PackSelectionScreenMixin extends Screen { @Override public void onClose() { - if (selectedPackList.isDragging()) selectedPackList.mouseReleased(0, 0, 0); - if (availablePackList.isDragging()) availablePackList.mouseReleased(0, 0, 0); + if (selectedPackList.isDragging()) selectedPackList.mouseReleased(new MouseButtonEvent(0, 0, new MouseButtonInfo(0, 0))); + if (availablePackList.isDragging()) availablePackList.mouseReleased(new MouseButtonEvent(0, 0, new MouseButtonInfo(0, 0))); // from PackSelectionScreen::onClose() this.model.commit(); diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionListMixin.java b/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionListMixin.java similarity index 63% rename from common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionListMixin.java rename to src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionListMixin.java index edd4d6b..8717a01 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionListMixin.java +++ b/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionListMixin.java @@ -8,20 +8,17 @@ import com.mrmelon54.DraggableLists.duck.AbstractPackDuckProvider; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.components.ObjectSelectionList; import net.minecraft.client.gui.screens.packs.PackSelectionModel; import net.minecraft.client.gui.screens.packs.TransferableSelectionList; +import net.minecraft.client.input.MouseButtonEvent; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @Mixin(TransferableSelectionList.class) @Environment(EnvType.CLIENT) -public abstract class TransferableSelectionListMixin extends ObjectSelectionList implements DragList { - @Shadow - protected abstract int scrollBarX(); - +public abstract class TransferableSelectionListMixin extends ObjectSelectionList implements DragList { @Unique private final DragManager draggable_lists$dragManager = new DragManager<>(this); @@ -30,25 +27,20 @@ public abstract class TransferableSelectionListMixin extends ObjectSelectionList } @Override - protected void renderListItems(GuiGraphics guiGraphics, int mouseX, int mouseY, float tickDelta) { + protected void extractListItems(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float tickDelta) { draggable_lists$dragManager.renderListItems(guiGraphics, mouseX, mouseY, tickDelta); } - @Unique - private boolean draggable_lists$isMouseOverScrollbar(double mouseX) { - return scrollbarVisible() && mouseX >= scrollBarX(); + @Override + public boolean mouseReleased(MouseButtonEvent event) { + if (draggable_lists$dragManager.mouseReleased(event.x(), event.y(), event.button())) return true; + return super.mouseReleased(event); } @Override - public boolean mouseReleased(double mouseX, double mouseY, int button) { - if (draggable_lists$dragManager.mouseReleased(mouseX, mouseY, button)) return true; - return super.mouseReleased(mouseX, mouseY, button); - } - - @Override - public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { - if (DraggableLists.CONFIG.resourcePackDraggingEnabled.isEnabled() && !draggable_lists$isMouseOverScrollbar(mouseX) && draggable_lists$dragManager.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)) return true; - return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); + public boolean mouseDragged(MouseButtonEvent event, double deltaX, double deltaY) { + if (DraggableLists.CONFIG.resourcePackDraggingEnabled.isEnabled() && !isOverScrollbar(event.x(), event.y()) && draggable_lists$dragManager.mouseDragged(event.x(), event.y(), event.button(), deltaX, deltaY)) return true; + return super.mouseDragged(event, deltaX, deltaY); } @Override @@ -58,15 +50,18 @@ public abstract class TransferableSelectionListMixin extends ObjectSelectionList } @Override - public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { - super.renderWidget(guiGraphics, mouseX, mouseY, delta); + public void extractWidgetRenderState(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float delta) { + super.extractWidgetRenderState(guiGraphics, mouseX, mouseY, delta); draggable_lists$dragManager.renderWidget(guiGraphics, mouseX, mouseY, delta); } @Override public DragItem draggable_lists$getEntryAtPosition(double mouseX, double mouseY) { - TransferableSelectionList.PackEntry entryAtPosition = getEntryAtPosition(mouseX, mouseY); - return (DragItem) entryAtPosition; + TransferableSelectionList.Entry entryAtPosition = getEntryAtPosition(mouseX, mouseY); + if (entryAtPosition instanceof TransferableSelectionList.PackEntry packEntry) { + return (DragItem) packEntry; + } + return null; } @Override @@ -79,11 +74,6 @@ public abstract class TransferableSelectionListMixin extends ObjectSelectionList super.setDragging(b); } - @Override - public int draggable_lists$getHeaderHeight() { - return headerHeight; - } - @Override public int draggable_lists$getY() { return getY(); @@ -96,7 +86,7 @@ public abstract class TransferableSelectionListMixin extends ObjectSelectionList @Override public int draggable_lists$getItemHeight() { - return itemHeight; + return defaultEntryHeight; } @Override @@ -142,7 +132,20 @@ public abstract class TransferableSelectionListMixin extends ObjectSelectionList } @Override - public void draggable_lists$renderItem(GuiGraphics guiGraphics, int mouseX, int mouseY, float tickDelta, int i, int rowLeft, int rowTop, int rowWidth, int rowHeight) { - renderItem(guiGraphics, mouseX, mouseY, tickDelta, i, rowLeft, rowTop, rowWidth, rowHeight); + public void draggable_lists$renderItem(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float tickDelta, int i, int rowLeft, int rowTop, int rowWidth, int rowHeight) { + TransferableSelectionList.Entry entry = children().get(i); + int oldX = entry.getX(); + int oldY = entry.getY(); + int oldWidth = entry.getWidth(); + int oldHeight = entry.getHeight(); + entry.setX(rowLeft); + entry.setY(rowTop); + entry.setWidth(rowWidth); + entry.setHeight(rowHeight); + extractItem(guiGraphics, mouseX, mouseY, tickDelta, entry); + entry.setX(oldX); + entry.setY(oldY); + entry.setWidth(oldWidth); + entry.setHeight(oldHeight); } -} \ No newline at end of file +} diff --git a/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionList_PackEntryMixin.java b/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionList_PackEntryMixin.java new file mode 100644 index 0000000..39a907d --- /dev/null +++ b/src/main/java/com/mrmelon54/DraggableLists/mixin/packs/TransferableSelectionList_PackEntryMixin.java @@ -0,0 +1,103 @@ +package com.mrmelon54.DraggableLists.mixin.packs; + +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import com.mojang.blaze3d.pipeline.RenderPipeline; +import com.mrmelon54.DraggableLists.DragItem; +import com.mrmelon54.DraggableLists.DraggableLists; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.client.gui.screens.packs.PackSelectionModel; +import net.minecraft.client.gui.screens.packs.TransferableSelectionList; +import net.minecraft.client.input.MouseButtonEvent; +import net.minecraft.resources.Identifier; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(TransferableSelectionList.PackEntry.class) +public abstract class TransferableSelectionList_PackEntryMixin extends ObjectSelectionList.Entry implements DragItem { + @Shadow + @Final + private TransferableSelectionList parent; + + @Shadow + @Final + private PackSelectionModel.Entry pack; + + @Shadow + public abstract void extractContent(GuiGraphicsExtractor graphics, int mouseX, int mouseY, boolean hovered, float a); + + @Unique + private boolean draggable_lists$isBeingDragged = false; + + @WrapWithCondition(method = "extractContent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIII)V", ordinal = 4)) + public boolean removeOnUpArrowButtons(GuiGraphicsExtractor instance, RenderPipeline renderPipeline, Identifier identifier, int i, int j, int k, int l) { + return !DraggableLists.CONFIG.disableResourcePackArrows; + } + + @WrapWithCondition(method = "extractContent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIII)V", ordinal = 5)) + public boolean removeOffUpArrowButtons(GuiGraphicsExtractor instance, RenderPipeline renderPipeline, Identifier identifier, int i, int j, int k, int l) { + return !DraggableLists.CONFIG.disableResourcePackArrows; + } + + @WrapWithCondition(method = "extractContent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIII)V", ordinal = 6)) + public boolean removeOnDownArrowButtons(GuiGraphicsExtractor instance, RenderPipeline renderPipeline, Identifier identifier, int i, int j, int k, int l) { + return !DraggableLists.CONFIG.disableResourcePackArrows; + } + + @WrapWithCondition(method = "extractContent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIII)V", ordinal = 7)) + public boolean removeOffDownArrowButtons(GuiGraphicsExtractor instance, RenderPipeline renderPipeline, Identifier identifier, int i, int j, int k, int l) { + return !DraggableLists.CONFIG.disableResourcePackArrows; + } + + @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) + public void removeMoveTowardEnd(MouseButtonEvent event, boolean doubleClick, CallbackInfoReturnable cir) { + if (!DraggableLists.CONFIG.disableResourcePackArrows) return; + + // Allow using the whole pack selection button + if (pack.canSelect()) return; + + double f = event.x() - (double) parent.getRowLeft(); + if (f < 16 || f > 32) return; + + cir.setReturnValue(true); + cir.cancel(); + } + + @Override + public PackSelectionModel.Entry draggable_lists$getUnderlyingData() { + return pack; + } + + @Override + public TransferableSelectionList.PackEntry draggable_lists$getUnderlyingEntry() { + return (TransferableSelectionList.PackEntry) (Object) this; + } + + @Override + public void draggable_lists$render(GuiGraphicsExtractor guiGraphics, int x, int y, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { + if (!draggable_lists$isBeingDragged) return; + int oldX = getX(); + int oldY = getY(); + int oldWidth = getWidth(); + int oldHeight = getHeight(); + setX(x); + setY(y); + setWidth(entryWidth); + setHeight(entryHeight); + extractContent(guiGraphics, mouseX, mouseY, hovered, tickDelta); + setX(oldX); + setY(oldY); + setWidth(oldWidth); + setHeight(oldHeight); + } + + @Override + public void draggable_lists$setBeingDragged(boolean v) { + draggable_lists$isBeingDragged = v; + } +} diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/server/JoinMultiplayerScreenMixin.java b/src/main/java/com/mrmelon54/DraggableLists/mixin/server/JoinMultiplayerScreenMixin.java similarity index 66% rename from common/src/main/java/com/mrmelon54/DraggableLists/mixin/server/JoinMultiplayerScreenMixin.java rename to src/main/java/com/mrmelon54/DraggableLists/mixin/server/JoinMultiplayerScreenMixin.java index e52e977..6a9a4ca 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/server/JoinMultiplayerScreenMixin.java +++ b/src/main/java/com/mrmelon54/DraggableLists/mixin/server/JoinMultiplayerScreenMixin.java @@ -3,6 +3,9 @@ package com.mrmelon54.DraggableLists.mixin.server; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; import net.minecraft.client.gui.screens.multiplayer.ServerSelectionList; +import net.minecraft.client.input.MouseButtonEvent; +import net.minecraft.client.input.MouseButtonInfo; +import net.minecraft.client.multiplayer.ServerData; import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -19,20 +22,20 @@ public abstract class JoinMultiplayerScreenMixin extends Screen { super(component); } - @Inject(method = "joinSelectedServer", at = @At("HEAD")) - private void injectedConnect(CallbackInfo info) { - if (serverSelectionList.isDragging()) serverSelectionList.mouseReleased(0, 0, 0); + @Inject(method = "join", at = @At("HEAD")) + private void injectedConnect(ServerData serverData, CallbackInfo info) { + if (serverSelectionList.isDragging()) serverSelectionList.mouseReleased(new MouseButtonEvent(0, 0, new MouseButtonInfo(0, 0))); } @Override - public boolean mouseReleased(double mouseX, double mouseY, int button) { - if (serverSelectionList.isDragging()) serverSelectionList.mouseReleased(mouseX, mouseY, button); - return super.mouseReleased(mouseX, mouseY, button); + public boolean mouseReleased(MouseButtonEvent event) { + if (serverSelectionList.isDragging()) serverSelectionList.mouseReleased(event); + return super.mouseReleased(event); } @Override public void onClose() { - if (serverSelectionList.isDragging()) serverSelectionList.mouseReleased(0, 0, 0); + if (serverSelectionList.isDragging()) serverSelectionList.mouseReleased(new MouseButtonEvent(0, 0, new MouseButtonInfo(0, 0))); super.onClose(); } } diff --git a/src/main/java/com/mrmelon54/DraggableLists/mixin/server/OnlineServerEntryMixin.java b/src/main/java/com/mrmelon54/DraggableLists/mixin/server/OnlineServerEntryMixin.java new file mode 100644 index 0000000..9b09767 --- /dev/null +++ b/src/main/java/com/mrmelon54/DraggableLists/mixin/server/OnlineServerEntryMixin.java @@ -0,0 +1,105 @@ +package com.mrmelon54.DraggableLists.mixin.server; + +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import com.mojang.blaze3d.pipeline.RenderPipeline; +import com.mrmelon54.DraggableLists.DragItem; +import com.mrmelon54.DraggableLists.DraggableLists; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.client.gui.screens.multiplayer.ServerSelectionList; +import net.minecraft.client.input.MouseButtonEvent; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.resources.Identifier; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ServerSelectionList.OnlineServerEntry.class) +public abstract class OnlineServerEntryMixin extends ObjectSelectionList.Entry implements DragItem { + @Shadow + @Final + private ServerData serverData; + + @Shadow + public abstract void extractContent(GuiGraphicsExtractor graphics, int mouseX, int mouseY, boolean hovered, float a); + + @Shadow + @Final + ServerSelectionList this$0; + + @Shadow + public abstract boolean mouseClicked(MouseButtonEvent event, boolean doubleClick); + + @Unique + private boolean draggable_lists$isBeingDragged; + + @WrapWithCondition(method = "extractContent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIII)V", ordinal = 3)) + public boolean removeUpOnButton(GuiGraphicsExtractor instance, RenderPipeline renderPipeline, Identifier identifier, int i, int j, int k, int l) { + return !DraggableLists.CONFIG.disableServerArrows; + } + + @WrapWithCondition(method = "extractContent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIII)V", ordinal = 4)) + public boolean removeUpButton(GuiGraphicsExtractor instance, RenderPipeline renderPipeline, Identifier identifier, int i, int j, int k, int l) { + return !DraggableLists.CONFIG.disableServerArrows; + } + + @WrapWithCondition(method = "extractContent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIII)V", ordinal = 5)) + public boolean removeDownOnButton(GuiGraphicsExtractor instance, RenderPipeline renderPipeline, Identifier identifier, int i, int j, int k, int l) { + return !DraggableLists.CONFIG.disableServerArrows; + } + + @WrapWithCondition(method = "extractContent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIII)V", ordinal = 6)) + public boolean removeDownButton(GuiGraphicsExtractor instance, RenderPipeline renderPipeline, Identifier identifier, int i, int j, int k, int l) { + return !DraggableLists.CONFIG.disableServerArrows; + } + + @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) + public void removeSwapEntries(MouseButtonEvent event, boolean doubleClick, CallbackInfoReturnable cir) { + double l = this$0.getRowLeft(); + double f = event.x() - l; + + // don't click buttons left of 16 pixels + if (f <= 16) { + mouseClicked(new MouseButtonEvent(l + 32, event.y(), event.buttonInfo()), doubleClick); + cir.setReturnValue(true); + cir.cancel(); + } + } + + @Override + public ServerData draggable_lists$getUnderlyingData() { + return serverData; + } + + @Override + public ServerSelectionList.OnlineServerEntry draggable_lists$getUnderlyingEntry() { + return (ServerSelectionList.OnlineServerEntry) (Object) this; + } + + @Override + public void draggable_lists$render(GuiGraphicsExtractor guiGraphics, int x, int y, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { + if (!draggable_lists$isBeingDragged) return; + int oldX = getX(); + int oldY = getY(); + int oldWidth = getWidth(); + int oldHeight = getHeight(); + setX(x); + setY(y); + setWidth(entryWidth); + setHeight(entryHeight); + extractContent(guiGraphics, mouseX, mouseY, hovered, tickDelta); + setX(oldX); + setY(oldY); + setWidth(oldWidth); + setHeight(oldHeight); + } + + @Override + public void draggable_lists$setBeingDragged(boolean v) { + draggable_lists$isBeingDragged = v; + } +} diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/server/ServerListMixin.java b/src/main/java/com/mrmelon54/DraggableLists/mixin/server/ServerListMixin.java similarity index 100% rename from common/src/main/java/com/mrmelon54/DraggableLists/mixin/server/ServerListMixin.java rename to src/main/java/com/mrmelon54/DraggableLists/mixin/server/ServerListMixin.java diff --git a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/server/ServerSelectionListMixin.java b/src/main/java/com/mrmelon54/DraggableLists/mixin/server/ServerSelectionListMixin.java similarity index 73% rename from common/src/main/java/com/mrmelon54/DraggableLists/mixin/server/ServerSelectionListMixin.java rename to src/main/java/com/mrmelon54/DraggableLists/mixin/server/ServerSelectionListMixin.java index 10e2fc3..4710470 100644 --- a/common/src/main/java/com/mrmelon54/DraggableLists/mixin/server/ServerSelectionListMixin.java +++ b/src/main/java/com/mrmelon54/DraggableLists/mixin/server/ServerSelectionListMixin.java @@ -8,10 +8,11 @@ import com.mrmelon54.DraggableLists.duck.ServerListDuckProvider; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.components.ObjectSelectionList; import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; import net.minecraft.client.gui.screens.multiplayer.ServerSelectionList; +import net.minecraft.client.input.MouseButtonEvent; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.multiplayer.ServerList; import org.jetbrains.annotations.Nullable; @@ -44,20 +45,20 @@ public abstract class ServerSelectionListMixin extends ObjectSelectionList=0.18.4", + "minecraft": "${minecraft_version_range}", + "cloth-config": ">=${cloth_config_version}" + } +} diff --git a/common/src/main/resources/icon.png b/src/main/resources/icon.png similarity index 100% rename from common/src/main/resources/icon.png rename to src/main/resources/icon.png