mirror of
https://github.com/darksaid98/draggable_lists.git
synced 2026-12-01 14:38:47 +00:00
Fixes #3 - Use WrapWithCondition to improve compatibility with other mods
This commit is contained in:
11 files changed
+50
-66
No files matched your search
@@ -11,15 +11,9 @@ import java.util.function.Supplier;
|
||||
|
||||
public class DraggableLists {
|
||||
public static final String MOD_ID = "draggable_lists";
|
||||
private static ConfigStructure config;
|
||||
|
||||
public static ConfigStructure getConfig() {
|
||||
return config;
|
||||
}
|
||||
public static final ConfigStructure CONFIG = AutoConfig.register(ConfigStructure.class, JanksonConfigSerializer::new).get();
|
||||
|
||||
public static void init() {
|
||||
AutoConfig.register(ConfigStructure.class, JanksonConfigSerializer::new);
|
||||
config = AutoConfig.getConfigHolder(ConfigStructure.class).getConfig();
|
||||
}
|
||||
|
||||
public static Supplier<Screen> createConfigScreen(Screen screen) {
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(PackSelectionModel.class)
|
||||
public abstract class MixinPackSelectionModel implements ResourcePackOrganizerDuckProvider {
|
||||
public abstract class PackSelectionModelMixin implements ResourcePackOrganizerDuckProvider {
|
||||
@Shadow
|
||||
@Final
|
||||
Runnable onListChanged;
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.mrmelon54.DraggableLists.mixin.packs;
|
||||
|
||||
import com.mrmelon54.DraggableLists.DraggableLists;
|
||||
import com.mrmelon54.DraggableLists.duck.AbstractPackDuckProvider;
|
||||
import com.mrmelon54.DraggableLists.duck.ResourcePackOrganizerDuckProvider;
|
||||
import net.minecraft.client.gui.screens.packs.PackSelectionModel;
|
||||
@@ -14,7 +13,7 @@ import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Mixin(PackSelectionModel.EntryBase.class)
|
||||
public abstract class MixinPackSelectionModel_EntryBase implements AbstractPackDuckProvider {
|
||||
public abstract class PackSelectionModel_EntryBaseMixin implements AbstractPackDuckProvider {
|
||||
@Shadow
|
||||
protected abstract List<Pack> getSelfList();
|
||||
|
||||
+2
-2
@@ -8,14 +8,14 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(PackSelectionScreen.class)
|
||||
public class MixinPackSelectionScreen extends Screen {
|
||||
public class PackSelectionScreenMixin extends Screen {
|
||||
@Shadow
|
||||
private TransferableSelectionList selectedPackList;
|
||||
|
||||
@Shadow
|
||||
private TransferableSelectionList availablePackList;
|
||||
|
||||
protected MixinPackSelectionScreen(Component component) {
|
||||
protected PackSelectionScreenMixin(Component component) {
|
||||
super(component);
|
||||
}
|
||||
|
||||
+2
-3
@@ -1,6 +1,5 @@
|
||||
package com.mrmelon54.DraggableLists.mixin.packs;
|
||||
|
||||
import com.mrmelon54.DraggableLists.DraggableLists;
|
||||
import com.mrmelon54.DraggableLists.duck.AbstractPackDuckProvider;
|
||||
import com.mrmelon54.DraggableLists.duck.ResourcePackEntryDuckProvider;
|
||||
import net.fabricmc.api.EnvType;
|
||||
@@ -18,7 +17,7 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(TransferableSelectionList.class)
|
||||
@Environment(EnvType.CLIENT)
|
||||
public abstract class MixinTransferableSelectionList extends ObjectSelectionList<TransferableSelectionList.PackEntry> {
|
||||
public abstract class TransferableSelectionListMixin extends ObjectSelectionList<TransferableSelectionList.PackEntry> {
|
||||
@Unique
|
||||
private TransferableSelectionList.PackEntry draggable_lists$draggingObject = null;
|
||||
@Unique
|
||||
@@ -34,7 +33,7 @@ public abstract class MixinTransferableSelectionList extends ObjectSelectionList
|
||||
@Unique
|
||||
private double draggable_lists$softScrollingOrigin = 0;
|
||||
|
||||
public MixinTransferableSelectionList(Minecraft minecraft, int i, int j, int k, int l, int m) {
|
||||
public TransferableSelectionListMixin(Minecraft minecraft, int i, int j, int k, int l, int m) {
|
||||
super(minecraft, i, j, k, l);
|
||||
}
|
||||
|
||||
+15
-19
@@ -1,5 +1,6 @@
|
||||
package com.mrmelon54.DraggableLists.mixin.packs;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.WrapWithCondition;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mrmelon54.DraggableLists.DraggableLists;
|
||||
import com.mrmelon54.DraggableLists.duck.ResourcePackEntryDuckProvider;
|
||||
@@ -14,12 +15,11 @@ 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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(TransferableSelectionList.PackEntry.class)
|
||||
public abstract class MixinTransferableSelectionList_PackEntry extends ObjectSelectionList.Entry<TransferableSelectionList.PackEntry> implements ResourcePackEntryDuckProvider {
|
||||
public abstract class TransferableSelectionList_PackEntryMixin extends ObjectSelectionList.Entry<TransferableSelectionList.PackEntry> implements ResourcePackEntryDuckProvider {
|
||||
@Shadow
|
||||
@Final
|
||||
private PackSelectionModel.Entry pack;
|
||||
@@ -40,33 +40,29 @@ public abstract class MixinTransferableSelectionList_PackEntry extends ObjectSel
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 4))
|
||||
public void removeOnUpArrowButtons(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
if (DraggableLists.getConfig().disableResourcePackArrows) return;
|
||||
instance.blitSprite(resourceLocation, i, j, k, l);
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 4))
|
||||
public boolean removeOnUpArrowButtons(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
return !DraggableLists.CONFIG.disableResourcePackArrows;
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 5))
|
||||
public void removeOffUpArrowButtons(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
if (DraggableLists.getConfig().disableResourcePackArrows) return;
|
||||
instance.blitSprite(resourceLocation, i, j, k, l);
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 5))
|
||||
public boolean removeOffUpArrowButtons(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
return !DraggableLists.CONFIG.disableResourcePackArrows;
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 6))
|
||||
public void removeOnDownArrowButtons(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
if (DraggableLists.getConfig().disableResourcePackArrows) return;
|
||||
instance.blitSprite(resourceLocation, i, j, k, l);
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 6))
|
||||
public boolean removeOnDownArrowButtons(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
return !DraggableLists.CONFIG.disableResourcePackArrows;
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 7))
|
||||
public void removeOffDownArrowButtons(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
if (DraggableLists.getConfig().disableResourcePackArrows) return;
|
||||
instance.blitSprite(resourceLocation, i, j, k, l);
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 7))
|
||||
public boolean removeOffDownArrowButtons(GuiGraphics instance, 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.getConfig().disableResourcePackArrows) return;
|
||||
if (!DraggableLists.CONFIG.disableResourcePackArrows) return;
|
||||
if (d > getRectangle().width() / 2f) return;
|
||||
|
||||
double f = d - (double) parent.getRowLeft();
|
||||
+2
-2
@@ -14,14 +14,14 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(JoinMultiplayerScreen.class)
|
||||
public abstract class MixinJoinMultiplayerScreen extends Screen implements MultiplayerScreenDuckProvider {
|
||||
public abstract class JoinMultiplayerScreenMixin extends Screen implements MultiplayerScreenDuckProvider {
|
||||
@Shadow
|
||||
protected ServerSelectionList serverSelectionList;
|
||||
|
||||
@Shadow
|
||||
public abstract ServerList getServers();
|
||||
|
||||
protected MixinJoinMultiplayerScreen(Component component) {
|
||||
protected JoinMultiplayerScreenMixin(Component component) {
|
||||
super(component);
|
||||
}
|
||||
|
||||
+14
-18
@@ -1,5 +1,6 @@
|
||||
package com.mrmelon54.DraggableLists.mixin.server;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.WrapWithCondition;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mrmelon54.DraggableLists.DraggableLists;
|
||||
import com.mrmelon54.DraggableLists.duck.ServerEntryDuckProvider;
|
||||
@@ -14,12 +15,11 @@ 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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ServerSelectionList.OnlineServerEntry.class)
|
||||
public abstract class MixinOnlineServerEntry extends ObjectSelectionList.Entry<ServerSelectionList.Entry> implements ServerEntryDuckProvider {
|
||||
public abstract class OnlineServerEntryMixin extends ObjectSelectionList.Entry<ServerSelectionList.Entry> implements ServerEntryDuckProvider {
|
||||
@Shadow
|
||||
@Final
|
||||
private ServerData serverData;
|
||||
@@ -68,28 +68,24 @@ public abstract class MixinOnlineServerEntry extends ObjectSelectionList.Entry<S
|
||||
draggable_lists$isBeingDragged = v;
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 3))
|
||||
public void removeUpOnButton(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
if (DraggableLists.getConfig().disableServerArrows) return;
|
||||
instance.blitSprite(resourceLocation, i, j, k, l);
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 3))
|
||||
public boolean removeUpOnButton(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
return !DraggableLists.CONFIG.disableServerArrows;
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 4))
|
||||
public void removeUpButton(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
if (DraggableLists.getConfig().disableServerArrows) return;
|
||||
instance.blitSprite(resourceLocation, i, j, k, l);
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 4))
|
||||
public boolean removeUpButton(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
return !DraggableLists.CONFIG.disableServerArrows;
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 5))
|
||||
public void removeDownOnButton(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
if (DraggableLists.getConfig().disableServerArrows) return;
|
||||
instance.blitSprite(resourceLocation, i, j, k, l);
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 5))
|
||||
public boolean removeDownOnButton(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
return !DraggableLists.CONFIG.disableServerArrows;
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 6))
|
||||
public void removeDownButton(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
if (DraggableLists.getConfig().disableServerArrows) return;
|
||||
instance.blitSprite(resourceLocation, i, j, k, l);
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V", ordinal = 6))
|
||||
public boolean removeDownButton(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l) {
|
||||
return !DraggableLists.CONFIG.disableServerArrows;
|
||||
}
|
||||
|
||||
@Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true)
|
||||
+1
-1
@@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(ServerList.class)
|
||||
public class MixinServerList implements ServerListDuckProvider {
|
||||
public class ServerListMixin implements ServerListDuckProvider {
|
||||
@Shadow
|
||||
@Final
|
||||
private List<ServerData> serverList;
|
||||
+2
-2
@@ -22,7 +22,7 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(ServerSelectionList.class)
|
||||
public abstract class MixinServerSelectionList extends ObjectSelectionList<ServerSelectionList.Entry> {
|
||||
public abstract class ServerSelectionListMixin extends ObjectSelectionList<ServerSelectionList.Entry> {
|
||||
@Shadow
|
||||
@Final
|
||||
private JoinMultiplayerScreen screen;
|
||||
@@ -52,7 +52,7 @@ public abstract class MixinServerSelectionList extends ObjectSelectionList<Serve
|
||||
@Unique
|
||||
private double draggable_lists$softScrollingOrigin = 0;
|
||||
|
||||
public MixinServerSelectionList(Minecraft minecraftClient, int i, int j, int k, int l, int m) {
|
||||
public ServerSelectionListMixin(Minecraft minecraftClient, int i, int j, int k, int l, int m) {
|
||||
super(minecraftClient, i, j, k, l);
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"minVersion": "0.8",
|
||||
"client": [
|
||||
"packs.MixinPackSelectionModel",
|
||||
"packs.MixinPackSelectionModel_EntryBase",
|
||||
"packs.MixinPackSelectionScreen",
|
||||
"packs.MixinTransferableSelectionList",
|
||||
"packs.MixinTransferableSelectionList_PackEntry",
|
||||
"server.MixinJoinMultiplayerScreen",
|
||||
"server.MixinOnlineServerEntry",
|
||||
"server.MixinServerList",
|
||||
"server.MixinServerSelectionList"
|
||||
"packs.PackSelectionModelMixin",
|
||||
"packs.PackSelectionModel_EntryBaseMixin",
|
||||
"packs.PackSelectionScreenMixin",
|
||||
"packs.TransferableSelectionListMixin",
|
||||
"packs.TransferableSelectionList_PackEntryMixin",
|
||||
"server.JoinMultiplayerScreenMixin",
|
||||
"server.OnlineServerEntryMixin",
|
||||
"server.ServerListMixin",
|
||||
"server.ServerSelectionListMixin"
|
||||
],
|
||||
"mixins": [
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user