InventoryTweaks Support 1.12 (#1405)
* Added support for sorting with InventoryTweaks if it exists * Cleaned up formatting * Requested fixes. * Style updates * No logging
This commit is contained in:
@@ -47,6 +47,10 @@ repositories {
|
|||||||
maven {
|
maven {
|
||||||
url "https://dl.bintray.com/jaquadro/dev"
|
url "https://dl.bintray.com/jaquadro/dev"
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
name = "CurseForge"
|
||||||
|
url = "https://minecraft.curseforge.com/api/maven/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -55,6 +59,7 @@ dependencies {
|
|||||||
deobfCompile "MCMultiPart2:MCMultiPart:2.2.2"
|
deobfCompile "MCMultiPart2:MCMultiPart:2.2.2"
|
||||||
// deobfCompile "li.cil.oc:OpenComputers:MC1.11.2-1.7.0.28:api"
|
// deobfCompile "li.cil.oc:OpenComputers:MC1.11.2-1.7.0.28:api"
|
||||||
deobfCompile "com.jaquadro.minecraft.storagedrawers:StorageDrawers:1.12-5.2.9:api"
|
deobfCompile "com.jaquadro.minecraft.storagedrawers:StorageDrawers:1.12-5.2.9:api"
|
||||||
|
compile "inventory-tweaks:InventoryTweaks:1.63+beta.107:api"
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public interface IGrid {
|
|||||||
int SORTING_TYPE_QUANTITY = 0;
|
int SORTING_TYPE_QUANTITY = 0;
|
||||||
int SORTING_TYPE_NAME = 1;
|
int SORTING_TYPE_NAME = 1;
|
||||||
int SORTING_TYPE_ID = 2;
|
int SORTING_TYPE_ID = 2;
|
||||||
|
int SORTING_TYPE_INVENTORYTWEAKS = 3;
|
||||||
|
|
||||||
int SEARCH_BOX_MODE_NORMAL = 0;
|
int SEARCH_BOX_MODE_NORMAL = 0;
|
||||||
int SEARCH_BOX_MODE_NORMAL_AUTOSELECTED = 1;
|
int SEARCH_BOX_MODE_NORMAL_AUTOSELECTED = 1;
|
||||||
@@ -214,7 +215,7 @@ public interface IGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean isValidSortingType(int type) {
|
static boolean isValidSortingType(int type) {
|
||||||
return type == SORTING_TYPE_QUANTITY || type == SORTING_TYPE_NAME || type == SORTING_TYPE_ID;
|
return type == SORTING_TYPE_QUANTITY || type == SORTING_TYPE_NAME || type == SORTING_TYPE_ID || type == SORTING_TYPE_INVENTORYTWEAKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isValidSortingDirection(int direction) {
|
static boolean isValidSortingDirection(int direction) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import com.raoulvdberge.refinedstorage.gui.Scrollbar;
|
|||||||
import com.raoulvdberge.refinedstorage.gui.grid.filtering.GridFilterParser;
|
import com.raoulvdberge.refinedstorage.gui.grid.filtering.GridFilterParser;
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSorting;
|
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSorting;
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSortingID;
|
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSortingID;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSortingInventoryTweaks;
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSortingName;
|
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSortingName;
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSortingQuantity;
|
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSortingQuantity;
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackFluid;
|
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackFluid;
|
||||||
@@ -53,6 +54,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
|||||||
private static final GridSorting SORTING_QUANTITY = new GridSortingQuantity();
|
private static final GridSorting SORTING_QUANTITY = new GridSortingQuantity();
|
||||||
private static final GridSorting SORTING_NAME = new GridSortingName();
|
private static final GridSorting SORTING_NAME = new GridSortingName();
|
||||||
private static final GridSorting SORTING_ID = new GridSortingID();
|
private static final GridSorting SORTING_ID = new GridSortingID();
|
||||||
|
private static final GridSorting SORTING_INVENTORYTWEAKS = new GridSortingInventoryTweaks();
|
||||||
|
|
||||||
private static final List<String> SEARCH_HISTORY = new ArrayList<>();
|
private static final List<String> SEARCH_HISTORY = new ArrayList<>();
|
||||||
|
|
||||||
@@ -206,6 +208,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
|||||||
SORTING_NAME.setSortingDirection(grid.getSortingDirection());
|
SORTING_NAME.setSortingDirection(grid.getSortingDirection());
|
||||||
SORTING_QUANTITY.setSortingDirection(grid.getSortingDirection());
|
SORTING_QUANTITY.setSortingDirection(grid.getSortingDirection());
|
||||||
SORTING_ID.setSortingDirection(grid.getSortingDirection());
|
SORTING_ID.setSortingDirection(grid.getSortingDirection());
|
||||||
|
SORTING_INVENTORYTWEAKS.setSortingDirection(grid.getSortingDirection());
|
||||||
|
|
||||||
stacks.sort(SORTING_NAME);
|
stacks.sort(SORTING_NAME);
|
||||||
|
|
||||||
@@ -213,6 +216,8 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
|||||||
stacks.sort(SORTING_QUANTITY);
|
stacks.sort(SORTING_QUANTITY);
|
||||||
} else if (grid.getSortingType() == IGrid.SORTING_TYPE_ID) {
|
} else if (grid.getSortingType() == IGrid.SORTING_TYPE_ID) {
|
||||||
stacks.sort(SORTING_ID);
|
stacks.sort(SORTING_ID);
|
||||||
|
} else if (grid.getSortingType() == IGrid.SORTING_TYPE_INVENTORYTWEAKS) {
|
||||||
|
stacks.sort(SORTING_INVENTORYTWEAKS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.gui.grid.sorting;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||||
|
import invtweaks.api.InvTweaksAPI;
|
||||||
|
import net.minecraftforge.fml.common.Loader;
|
||||||
|
|
||||||
|
public class GridSortingInventoryTweaks extends GridSorting {
|
||||||
|
private InvTweaksAPI api = null;
|
||||||
|
|
||||||
|
public GridSortingInventoryTweaks() {
|
||||||
|
try {
|
||||||
|
api = (InvTweaksAPI) Class.forName("invtweaks.forge.InvTweaksMod", true, Loader.instance().getModClassLoader()).getField("instance").get(null);
|
||||||
|
} catch (Exception ex) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(IGridStack o1, IGridStack o2) {
|
||||||
|
if (api != null && o1 instanceof GridStackItem && o2 instanceof GridStackItem) {
|
||||||
|
if (sortingDirection == NetworkNodeGrid.SORTING_DIRECTION_DESCENDING) {
|
||||||
|
return api.compareItems(((GridStackItem) o1).getStack(), ((GridStackItem) o2).getStack());
|
||||||
|
} else if (sortingDirection == NetworkNodeGrid.SORTING_DIRECTION_ASCENDING) {
|
||||||
|
return api.compareItems(((GridStackItem) o2).getStack(), ((GridStackItem) o1).getStack());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,10 @@ package com.raoulvdberge.refinedstorage.gui.sidebutton;
|
|||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraftforge.fml.common.Loader;
|
||||||
|
|
||||||
public class SideButtonGridSortingType extends SideButton {
|
public class SideButtonGridSortingType extends SideButton {
|
||||||
private IGrid grid;
|
private IGrid grid;
|
||||||
@@ -37,6 +39,12 @@ public class SideButtonGridSortingType extends SideButton {
|
|||||||
type = IGrid.SORTING_TYPE_ID;
|
type = IGrid.SORTING_TYPE_ID;
|
||||||
}
|
}
|
||||||
} else if (type == IGrid.SORTING_TYPE_ID) {
|
} else if (type == IGrid.SORTING_TYPE_ID) {
|
||||||
|
if (grid.getType() == GridType.FLUID || !Loader.isModLoaded("inventorytweaks")) {
|
||||||
|
type = IGrid.SORTING_TYPE_QUANTITY;
|
||||||
|
} else {
|
||||||
|
type = IGrid.SORTING_TYPE_INVENTORYTWEAKS;
|
||||||
|
}
|
||||||
|
} else if (type == NetworkNodeGrid.SORTING_TYPE_INVENTORYTWEAKS) {
|
||||||
type = IGrid.SORTING_TYPE_QUANTITY;
|
type = IGrid.SORTING_TYPE_QUANTITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ sidebutton.refinedstorage:grid.sorting.type=Sorting type
|
|||||||
sidebutton.refinedstorage:grid.sorting.type.0=Quantity
|
sidebutton.refinedstorage:grid.sorting.type.0=Quantity
|
||||||
sidebutton.refinedstorage:grid.sorting.type.1=Name
|
sidebutton.refinedstorage:grid.sorting.type.1=Name
|
||||||
sidebutton.refinedstorage:grid.sorting.type.2=ID
|
sidebutton.refinedstorage:grid.sorting.type.2=ID
|
||||||
|
sidebutton.refinedstorage:grid.sorting.type.3=InventoryTweaks
|
||||||
sidebutton.refinedstorage:grid.search_box_mode=Search box mode
|
sidebutton.refinedstorage:grid.search_box_mode=Search box mode
|
||||||
sidebutton.refinedstorage:grid.search_box_mode.0=Normal
|
sidebutton.refinedstorage:grid.search_box_mode.0=Normal
|
||||||
sidebutton.refinedstorage:grid.search_box_mode.1=Normal (autoselected)
|
sidebutton.refinedstorage:grid.search_box_mode.1=Normal (autoselected)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Reference in New Issue
Block a user