mirror of
https://github.com/darksaid98/draggable_lists.git
synced 2026-12-01 14:38:47 +00:00
build(loader): collapse multi-loader project to fabric-only for mc 26.1.x
Drop quilt, neoforge, and architectury fabric-like modules and merge the shared common module directly into a single fabric source set targeting minecraft 26.1.x via official mappings.
This commit is contained in:
1 parent
c6fb52e7f0
commit
840ba648df
53 files changed
+415
-948
No files matched your search
+49
-73
@@ -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"
|
||||
}
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package com.mrmelon54.DraggableLists.duck;
|
||||
|
||||
public interface ResourcePackOrganizerDuckProvider {
|
||||
void draggable_lists$updateSelectedList();
|
||||
}
|
||||
-87
@@ -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<TransferableSelectionList.PackEntry> implements DragItem<PackSelectionModel.Entry, TransferableSelectionList.PackEntry> {
|
||||
@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<Boolean> 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;
|
||||
}
|
||||
}
|
||||
-94
@@ -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<ServerSelectionList.Entry> implements DragItem<ServerData, ServerSelectionList.OnlineServerEntry> {
|
||||
@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<Boolean> 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;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"accessWidener": "draggable_lists.accesswidener"
|
||||
}
|
||||
@@ -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 }
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package com.mrmelon54.DraggableLists.fabriclike;
|
||||
|
||||
import com.mrmelon54.DraggableLists.DraggableLists;
|
||||
|
||||
public class DraggableListsFabricLike {
|
||||
public static void init() {
|
||||
DraggableLists.init();
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "com.mrmelon54.DraggableLists.mixin.fabric",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"minVersion": "0.8",
|
||||
"client": [
|
||||
],
|
||||
"mixins": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
@@ -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}"
|
||||
}
|
||||
}
|
||||
+6
-14
@@ -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
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
loom.platform=neoforge
|
||||
-18
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "com.mrmelon54.DraggableLists.mixin.neoforge",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"minVersion": "0.8",
|
||||
"client": [
|
||||
],
|
||||
"mixins": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "Draggable Lists",
|
||||
"pack_format": 15
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
loom.platform=quilt
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "com.mrmelon54.DraggableLists.mixin.fabric",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"minVersion": "0.8",
|
||||
"client": [
|
||||
],
|
||||
"mixins": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
+3
-8
@@ -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"
|
||||
+2
-2
@@ -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));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -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<T, E extends ObjectSelectionList.Entry<?>> {
|
||||
@@ -8,7 +8,7 @@ public interface DragItem<T, E extends ObjectSelectionList.Entry<?>> {
|
||||
|
||||
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);
|
||||
}
|
||||
+2
-4
@@ -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<T, E extends ObjectSelectionList.Entry<?>> {
|
||||
@@ -10,8 +10,6 @@ public interface DragList<T, E extends ObjectSelectionList.Entry<?>> {
|
||||
|
||||
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<T, E extends ObjectSelectionList.Entry<?>> {
|
||||
|
||||
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);
|
||||
}
|
||||
+10
-7
@@ -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<T, E extends ObjectSelectionList.Entry<?>> {
|
||||
private final DragList<T, E> dragList;
|
||||
@@ -77,7 +77,7 @@ public class DragManager<T, E extends ObjectSelectionList.Entry<?>> {
|
||||
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<T, E extends ObjectSelectionList.Entry<?>> {
|
||||
}
|
||||
|
||||
|
||||
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<T, E extends ObjectSelectionList.Entry<?>> {
|
||||
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<T, E extends ObjectSelectionList.Entry<?>> {
|
||||
}
|
||||
|
||||
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<T, E> item, double mouseY) {
|
||||
+5
-1
@@ -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<Screen> createConfigScreen(Screen screen) {
|
||||
return AutoConfig.getConfigScreen(ConfigStructure.class, screen);
|
||||
ConfigManager<ConfigStructure> manager = (ConfigManager<ConfigStructure>) AutoConfig.getConfigHolder(ConfigStructure.class);
|
||||
return new ConfigScreenProvider<>(manager, new DefaultGuiRegistryAccess(), screen);
|
||||
}
|
||||
}
|
||||
File renamed without changes.
+2
-2
@@ -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;
|
||||
};
|
||||
}
|
||||
File renamed without changes.
@@ -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);
|
||||
}
|
||||
File renamed without changes.
+2
-2
@@ -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();
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -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();
|
||||
}
|
||||
}
|
||||
File renamed without changes.
+5
-3
@@ -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<PackSelectionModel.EntryBase> onListChanged;
|
||||
|
||||
@Override
|
||||
public void draggable_lists$updateSelectedList() {
|
||||
onListChanged.run();
|
||||
public void draggable_lists$updateSelectedList(PackSelectionModel.EntryBase entry) {
|
||||
onListChanged.accept(entry);
|
||||
}
|
||||
}
|
||||
+3
-5
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
+4
-2
@@ -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();
|
||||
+35
-32
@@ -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<TransferableSelectionList.PackEntry> implements DragList<PackSelectionModel.Entry, TransferableSelectionList.PackEntry> {
|
||||
@Shadow
|
||||
protected abstract int scrollBarX();
|
||||
|
||||
public abstract class TransferableSelectionListMixin extends ObjectSelectionList<TransferableSelectionList.Entry> implements DragList<PackSelectionModel.Entry, TransferableSelectionList.PackEntry> {
|
||||
@Unique
|
||||
private final DragManager<PackSelectionModel.Entry, TransferableSelectionList.PackEntry> 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<PackSelectionModel.Entry, TransferableSelectionList.PackEntry> draggable_lists$getEntryAtPosition(double mouseX, double mouseY) {
|
||||
TransferableSelectionList.PackEntry entryAtPosition = getEntryAtPosition(mouseX, mouseY);
|
||||
return (DragItem<PackSelectionModel.Entry, TransferableSelectionList.PackEntry>) entryAtPosition;
|
||||
TransferableSelectionList.Entry entryAtPosition = getEntryAtPosition(mouseX, mouseY);
|
||||
if (entryAtPosition instanceof TransferableSelectionList.PackEntry packEntry) {
|
||||
return (DragItem<PackSelectionModel.Entry, TransferableSelectionList.PackEntry>) 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+103
@@ -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<TransferableSelectionList.Entry> implements DragItem<PackSelectionModel.Entry, TransferableSelectionList.PackEntry> {
|
||||
@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<Boolean> 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;
|
||||
}
|
||||
}
|
||||
+10
-7
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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<ServerSelectionList.Entry> implements DragItem<ServerData, ServerSelectionList.OnlineServerEntry> {
|
||||
@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<Boolean> 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;
|
||||
}
|
||||
}
|
||||
File renamed without changes.
+28
-18
@@ -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<Serve
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
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 mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
||||
if (DraggableLists.CONFIG.serverDraggingEnabled.isEnabled() && 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.serverDraggingEnabled.isEnabled() && draggable_lists$dragManager.mouseDragged(event.x(), event.y(), event.button(), deltaX, deltaY)) return true;
|
||||
return super.mouseDragged(event, deltaX, deltaY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,8 +68,8 @@ public abstract class ServerSelectionListMixin extends ObjectSelectionList<Serve
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@@ -89,10 +90,6 @@ public abstract class ServerSelectionListMixin extends ObjectSelectionList<Serve
|
||||
super.setDragging(b);
|
||||
}
|
||||
|
||||
public int draggable_lists$getHeaderHeight() {
|
||||
return headerHeight;
|
||||
}
|
||||
|
||||
public int draggable_lists$getY() {
|
||||
return getY();
|
||||
}
|
||||
@@ -102,7 +99,7 @@ public abstract class ServerSelectionListMixin extends ObjectSelectionList<Serve
|
||||
}
|
||||
|
||||
public int draggable_lists$getItemHeight() {
|
||||
return itemHeight;
|
||||
return defaultEntryHeight;
|
||||
}
|
||||
|
||||
public int draggable_lists$getRowTop(int i) {
|
||||
@@ -142,7 +139,20 @@ public abstract class ServerSelectionListMixin extends ObjectSelectionList<Serve
|
||||
return getItemCount();
|
||||
}
|
||||
|
||||
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) {
|
||||
ServerSelectionList.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,2 +1,2 @@
|
||||
accessWidener v2 named
|
||||
accessWidener v2 official
|
||||
accessible class net/minecraft/client/gui/screens/packs/PackSelectionModel$EntryBase
|
||||
File renamed without changes.
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "draggable_lists",
|
||||
"version": "${version}",
|
||||
"name": "Draggable Lists",
|
||||
"description": "${description}",
|
||||
"authors": ["MrMelon54, proxsyi"],
|
||||
"contact": {
|
||||
"homepage": "https://mrmelon54.com/minecraft/draggable-lists",
|
||||
"sources": "https://github.com/mrmelon54/draggable_lists, https://github.com/proxsyi/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.fabric.ModMenuIntegration"]
|
||||
},
|
||||
"accessWidener": "draggable_lists.accesswidener",
|
||||
"mixins": ["draggable_lists.mixins.json"],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.18.4",
|
||||
"minecraft": "${minecraft_version_range}",
|
||||
"cloth-config": ">=${cloth_config_version}"
|
||||
}
|
||||
}
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Reference in new issue
Block a user