mirror of
https://github.com/darksaid98/draggable_lists.git
synced 2026-12-02 14:38:46 +00:00
Finish 1.20.4 port
This commit is contained in:
8 files changed
+24
-27
No files matched your search
@@ -10,7 +10,7 @@ import net.minecraft.server.packs.repository.Pack;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class DraggableLists {
|
||||
public static final String MOD_ID = "draggable";
|
||||
public static final String MOD_ID = "draggable_lists";
|
||||
private static ConfigStructure config;
|
||||
|
||||
public static ConfigStructure getConfig() {
|
||||
@@ -25,12 +25,4 @@ public class DraggableLists {
|
||||
public static Supplier<Screen> createConfigScreen(Screen screen) {
|
||||
return AutoConfig.getConfigScreen(ConfigStructure.class, screen);
|
||||
}
|
||||
|
||||
public static boolean shouldNotTouch(Pack pack) {
|
||||
return pack.isFixedPosition() || pack.isRequired() || pack.getId().equals("vanilla");
|
||||
}
|
||||
|
||||
public static boolean shouldNotTouch(PackSelectionModel.Entry pack) {
|
||||
return pack.isFixedPosition() || pack.isRequired() || pack.getId().equals("vanilla");
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -29,14 +29,14 @@ public abstract class MixinPackSelectionModel_EntryBase implements AbstractPackD
|
||||
|
||||
@Override
|
||||
public void draggable_lists$moveTo(int j) {
|
||||
if (DraggableLists.shouldNotTouch(pack)) return;
|
||||
if (pack.isFixedPosition()) return;
|
||||
|
||||
List<Pack> list = getSelfList();
|
||||
list.remove(pack);
|
||||
list.add(j, pack);
|
||||
|
||||
// get all fixed position resource packs, remove them and add them all at the end
|
||||
Stream<Pack> packStream = list.stream().filter(DraggableLists::shouldNotTouch);
|
||||
Stream<Pack> packStream = list.stream().filter(Pack::isFixedPosition);
|
||||
List<Pack> list1 = packStream.toList();
|
||||
list.removeAll(list1);
|
||||
list.addAll(list1);
|
||||
|
||||
+3
-2
@@ -123,7 +123,7 @@ public abstract class MixinTransferableSelectionList extends ObjectSelectionList
|
||||
|
||||
@Override
|
||||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
|
||||
super.render(guiGraphics, mouseX, mouseY, delta);
|
||||
super.renderWidget(guiGraphics, mouseX, mouseY, delta);
|
||||
|
||||
if (this.draggable_lists$draggingObject instanceof ResourcePackEntryDuckProvider duckProvider) {
|
||||
int z = Mth.floor(mouseY + draggable_lists$draggingOffsetY);
|
||||
@@ -188,6 +188,7 @@ public abstract class MixinTransferableSelectionList extends ObjectSelectionList
|
||||
|
||||
@Unique
|
||||
boolean draggable_lists$isValidForDragging(ResourcePackEntryDuckProvider resourcePackEntryDuckProvider) {
|
||||
return !DraggableLists.shouldNotTouch(resourcePackEntryDuckProvider.draggable_lists$getUnderlyingPack()) && resourcePackEntryDuckProvider.draggable_lists$getUnderlyingPack().isSelected();
|
||||
PackSelectionModel.Entry entry = resourcePackEntryDuckProvider.draggable_lists$getUnderlyingPack();
|
||||
return !entry.isFixedPosition() && entry.isSelected();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -173,7 +173,7 @@ public abstract class MixinServerSelectionList extends ObjectSelectionList<Serve
|
||||
|
||||
@Unique
|
||||
int draggable_lists$capYCoordinate(int y, boolean useScreenSpace) {
|
||||
int scrollableTop = y + 4;
|
||||
int scrollableTop = getY() + 4;
|
||||
int scrollableHeight = getBottom() - getY() - (useScreenSpace ? 2 : itemHeight + 2);
|
||||
if (y < scrollableTop) y = scrollableTop;
|
||||
if (y > scrollableTop + scrollableHeight) y = scrollableTop + scrollableHeight;
|
||||
|
||||
Reference in new issue
Block a user