mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 10:44:45 +00:00
Backport some of REI bookmark features (#296)
* add placeholder bookmark drop * add item panel to bookmark panel injection support * fix outofboundsexception * fix drag'n drop voids bookmark * add itemstack moving animation * implement pop animation * fix crashes * disable ItemPanel Animation * disable pop animation on bookmark load * spotlessapply * disable move animation on gui scale * add config option
This commit is contained in:
1 parent
617ac0600d
commit
6d9ec0c0da
7 files changed
+303
-60
No files matched your search
@@ -9,7 +9,9 @@ import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
@@ -31,7 +33,7 @@ public class ItemsGrid {
|
||||
|
||||
protected int paddingLeft;
|
||||
|
||||
protected ArrayList<ItemStack> realItems = new ArrayList<>();
|
||||
protected ArrayList<AnimatedItemStack> realItems = new ArrayList<>();
|
||||
|
||||
protected int page;
|
||||
protected int perPage;
|
||||
@@ -49,11 +51,27 @@ public class ItemsGrid {
|
||||
protected boolean refreshBuffer = true;
|
||||
|
||||
public ArrayList<ItemStack> getItems() {
|
||||
return realItems;
|
||||
return realItems.stream().map(e -> e.itemStack).collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
public ItemStack getItem(int idx) {
|
||||
return realItems.get(idx);
|
||||
return realItems.get(idx).itemStack;
|
||||
}
|
||||
|
||||
protected void addRealItems(Collection<ItemStack> itemStack, boolean doMoveAnim, boolean doPopAnim) {
|
||||
itemStack.forEach(e -> addRealItem(e, doMoveAnim, doPopAnim));
|
||||
}
|
||||
|
||||
protected void addRealItem(ItemStack itemStack, boolean doMoveAnim, boolean doPopAnim) {
|
||||
realItems.add(new AnimatedItemStack(itemStack, doMoveAnim, doPopAnim));
|
||||
}
|
||||
|
||||
protected void addRealItem(int index, ItemStack itemStack, boolean doMoveAnim, boolean doPopAnim) {
|
||||
realItems.add(index, new AnimatedItemStack(itemStack, doMoveAnim, doPopAnim));
|
||||
}
|
||||
|
||||
protected void setRealItem(int index, ItemStack itemStack, boolean doMoveAnim, boolean doPopAnim) {
|
||||
realItems.set(index, new AnimatedItemStack(itemStack, doMoveAnim, doPopAnim));
|
||||
}
|
||||
|
||||
public int size() {
|
||||
@@ -63,7 +81,7 @@ public class ItemsGrid {
|
||||
public int indexOf(ItemStack stackA, boolean useNBT) {
|
||||
|
||||
for (int idx = 0; idx < realItems.size(); idx++) {
|
||||
if (StackInfo.equalItemAndNBT(stackA, realItems.get(idx), useNBT)) {
|
||||
if (StackInfo.equalItemAndNBT(stackA, getItem(idx), useNBT)) {
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
@@ -317,7 +335,7 @@ public class ItemsGrid {
|
||||
}
|
||||
|
||||
protected void drawItem(Rectangle4i rect, int idx) {
|
||||
GuiContainerManager.drawItem(rect.x + 1, rect.y + 1, getItem(idx));
|
||||
realItems.get(idx).drawItem(rect.x + 1, rect.y + 1);
|
||||
}
|
||||
|
||||
public ItemPanelSlot getSlotMouseOver(int mousex, int mousey) {
|
||||
|
||||
Reference in new issue
Block a user