mirror of
https://github.com/darksaid98/draggable_lists.git
synced 2026-12-02 22:16:55 +00:00
1 file changed
+10
-1
+10
-1
@@ -12,11 +12,15 @@ import net.minecraft.client.gui.components.ObjectSelectionList;
|
|||||||
import net.minecraft.client.gui.screens.packs.PackSelectionModel;
|
import net.minecraft.client.gui.screens.packs.PackSelectionModel;
|
||||||
import net.minecraft.client.gui.screens.packs.TransferableSelectionList;
|
import net.minecraft.client.gui.screens.packs.TransferableSelectionList;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
|
||||||
@Mixin(TransferableSelectionList.class)
|
@Mixin(TransferableSelectionList.class)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public abstract class TransferableSelectionListMixin extends ObjectSelectionList<TransferableSelectionList.PackEntry> implements DragList<PackSelectionModel.Entry, TransferableSelectionList.PackEntry> {
|
public abstract class TransferableSelectionListMixin extends ObjectSelectionList<TransferableSelectionList.PackEntry> implements DragList<PackSelectionModel.Entry, TransferableSelectionList.PackEntry> {
|
||||||
|
@Shadow
|
||||||
|
protected abstract int getScrollbarPosition();
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private final DragManager<PackSelectionModel.Entry, TransferableSelectionList.PackEntry> draggable_lists$dragManager = new DragManager<>(this);
|
private final DragManager<PackSelectionModel.Entry, TransferableSelectionList.PackEntry> draggable_lists$dragManager = new DragManager<>(this);
|
||||||
|
|
||||||
@@ -29,9 +33,14 @@ public abstract class TransferableSelectionListMixin extends ObjectSelectionList
|
|||||||
draggable_lists$dragManager.renderListItems(guiGraphics, mouseX, mouseY, tickDelta);
|
draggable_lists$dragManager.renderListItems(guiGraphics, mouseX, mouseY, tickDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private boolean draggable_lists$isMouseOverScrollbar(double mouseX) {
|
||||||
|
return scrollbarVisible() && mouseX >= getScrollbarPosition();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
if (draggable_lists$dragManager.mouseClicked(mouseX, mouseY, button)) return true;
|
if (!draggable_lists$isMouseOverScrollbar(mouseX) && draggable_lists$dragManager.mouseClicked(mouseX, mouseY, button)) return true;
|
||||||
return super.mouseClicked(mouseX, mouseY, button);
|
return super.mouseClicked(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user