Skip to content

Commit

Permalink
add missing items to bookmark (AppliedEnergistics#232)
Browse files Browse the repository at this point in the history
* crafting preview screen hold shift to add missing items to bookmark

* change io speed

* Revert "change io speed"

This reverts commit cb30a25.

* fix bug

* Update dependencies.gradle

Co-authored-by: Martin Robertz <[email protected]>
  • Loading branch information
asdflj and Dream-Master authored Jan 24, 2023
1 parent accc4fc commit f22c43b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 17 deletions.
5 changes: 2 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

dependencies {
compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.6:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.20-GTNH:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.21-GTNH:dev')
compile('curse.maven:cofh-core-69162:2388751')

compile('com.github.GTNewHorizons:BuildCraft:7.1.28:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.2.8:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.41.18:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:Jabba:1.2.21:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.5.15:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.32-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:waila:1.5.21:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:waila:1.5.21:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.13.10:api') {transitive = false}

compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:api')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.integration.modules.NEI;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartPatternTerminalEx;
Expand Down Expand Up @@ -527,6 +528,7 @@ protected void actionPerformed(final GuiButton btn) {
}

if (btn == this.cancel) {
this.addMissingItemsToBookMark();
switchToOriginalGUI();
}

Expand Down Expand Up @@ -578,4 +580,24 @@ public void handleMouseInput() {
public boolean hideItemPanelSlot(int x, int y, int w, int h) {
return cpuTable.hideItemPanelSlot(x - guiLeft, y - guiTop, w, h);
}

protected void addMissingItemsToBookMark() {
if (!this.missing.isEmpty() && isShiftKeyDown()) {
for (IAEItemStack iaeItemStack : this.missing) {
NEI.instance.addItemToBookMark(iaeItemStack.getItemStack());
}
}
}

public IItemList<IAEItemStack> getStorage() {
return this.storage;
}

public IItemList<IAEItemStack> getPending() {
return this.pending;
}

public IItemList<IAEItemStack> getMissing() {
return this.missing;
}
}
14 changes: 11 additions & 3 deletions src/main/java/appeng/integration/modules/NEI.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.INEI;
import appeng.integration.modules.NEIHelpers.*;
import codechicken.nei.ItemsGrid;
import codechicken.nei.LayoutManager;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.IStackPositioner;
import codechicken.nei.guihook.GuiContainerManager;
Expand Down Expand Up @@ -60,9 +62,9 @@ public class NEI implements INEI, IContainerTooltipHandler, IIntegrationModule,
@Reflected
public NEI() throws ClassNotFoundException {
IntegrationHelper.testClassExistence(this, codechicken.nei.api.API.class);
IntegrationHelper.testClassExistence(this, codechicken.nei.api.IStackPositioner.class);
IntegrationHelper.testClassExistence(this, codechicken.nei.guihook.GuiContainerManager.class);
IntegrationHelper.testClassExistence(this, codechicken.nei.guihook.IContainerTooltipHandler.class);
IntegrationHelper.testClassExistence(this, IStackPositioner.class);
IntegrationHelper.testClassExistence(this, GuiContainerManager.class);
IntegrationHelper.testClassExistence(this, IContainerTooltipHandler.class);
IntegrationHelper.testClassExistence(this, codechicken.nei.recipe.ICraftingHandler.class);
IntegrationHelper.testClassExistence(this, codechicken.nei.recipe.IUsageHandler.class);

Expand Down Expand Up @@ -205,4 +207,10 @@ public boolean shouldShowTooltip(GuiContainer gui) {
if (gui instanceof GuiCraftingCPU) return ((GuiCraftingCPU) gui).getHoveredStack() == null;
return true;
}

public void addItemToBookMark(ItemStack itemStack) {
ItemsGrid grid = LayoutManager.bookmarkPanel.getGrid();
grid.setPage(grid.getNumPages() - 1);
LayoutManager.bookmarkPanel.addItem(itemStack);
}
}
23 changes: 12 additions & 11 deletions src/main/java/appeng/util/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -1306,23 +1306,23 @@ public static <StackType extends IAEStack> StackType poweredInsert(
return input;
}

@SuppressWarnings("unchecked")
public static void postChanges(
final IStorageGrid gs, final ItemStack removed, final ItemStack added, final BaseActionSource src) {
final IItemList<IAEItemStack> itemChanges = AEApi.instance().storage().createItemList();
final IItemList<IAEFluidStack> fluidChanges = AEApi.instance().storage().createFluidList();

IMEInventory<IAEItemStack> myItems = null;
IMEInventory<IAEFluidStack> myFluids = null;
if (removed != null) {
final IMEInventory<IAEItemStack> myItems =
AEApi.instance().registries().cell().getCellInventory(removed, null, StorageChannel.ITEMS);
myItems = AEApi.instance().registries().cell().getCellInventory(removed, null, StorageChannel.ITEMS);

if (myItems != null) {
for (final IAEItemStack is : myItems.getAvailableItems(itemChanges)) {
is.setStackSize(-is.getStackSize());
}
}

final IMEInventory<IAEFluidStack> myFluids =
AEApi.instance().registries().cell().getCellInventory(removed, null, StorageChannel.FLUIDS);
myFluids = AEApi.instance().registries().cell().getCellInventory(removed, null, StorageChannel.FLUIDS);

if (myFluids != null) {
for (final IAEFluidStack is : myFluids.getAvailableItems(fluidChanges)) {
Expand All @@ -1332,22 +1332,23 @@ public static void postChanges(
}

if (added != null) {
final IMEInventory<IAEItemStack> myItems =
AEApi.instance().registries().cell().getCellInventory(added, null, StorageChannel.ITEMS);
myItems = AEApi.instance().registries().cell().getCellInventory(added, null, StorageChannel.ITEMS);

if (myItems != null) {
myItems.getAvailableItems(itemChanges);
}

final IMEInventory<IAEFluidStack> myFluids =
AEApi.instance().registries().cell().getCellInventory(added, null, StorageChannel.FLUIDS);
myFluids = AEApi.instance().registries().cell().getCellInventory(added, null, StorageChannel.FLUIDS);

if (myFluids != null) {
myFluids.getAvailableItems(fluidChanges);
}
}

gs.postAlterationOfStoredItems(StorageChannel.ITEMS, itemChanges, src);
if (myItems == null) {
gs.postAlterationOfStoredItems(StorageChannel.FLUIDS, fluidChanges, src);
} else {
gs.postAlterationOfStoredItems(StorageChannel.ITEMS, itemChanges, src);
}
}

public static <T extends IAEStack<T>> void postListChanges(
Expand Down

0 comments on commit f22c43b

Please sign in to comment.