mirror of
https://github.com/GTNewHorizons/JustEnoughCalculation.git
synced 2026-11-21 20:42:19 +00:00
Rebuilt gui framework
This commit is contained in:
1 parent
11d6c296d7
commit
b8a51edbdf
52 files changed
+771
-3662
No files matched your search
@@ -0,0 +1,50 @@
|
||||
package me.towdium.jecalculation.nei;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import me.towdium.jecalculation.core.ItemStackHelper;
|
||||
import me.towdium.jecalculation.gui.guis.GuiEditor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class JecaOverlayHandler implements IOverlayHandler {
|
||||
@Override
|
||||
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
|
||||
if(firstGui instanceof GuiEditor) {
|
||||
List<ItemStack> inputStacks = new ArrayList<>();
|
||||
LOOP:
|
||||
for (PositionedStack positionedStack : recipe.getIngredientStacks(recipeIndex)) {
|
||||
ItemStack itemStack = positionedStack.items[0];
|
||||
for (ItemStack exist : inputStacks) {
|
||||
if (ItemStackHelper.isTypeEqual(exist, itemStack)) {
|
||||
exist.stackSize += itemStack.stackSize;
|
||||
continue LOOP;
|
||||
}
|
||||
}
|
||||
inputStacks.add(itemStack.copy());
|
||||
}
|
||||
ItemStack outputStack = recipe.getResultStack(recipeIndex).items[0];
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.displayGuiScreen(new GuiEditor(firstGui));
|
||||
GuiContainer myGuiContainer = (GuiContainer) mc.currentScreen;
|
||||
if (myGuiContainer != null) {
|
||||
myGuiContainer.inventorySlots.getSlot(0).putStack(outputStack);
|
||||
for (int i = 8; i <= 8 + inputStacks.size() - 1 && i <= 19; i++) {
|
||||
myGuiContainer.inventorySlots.getSlot(i).putStack(inputStacks.get(i - 8));
|
||||
}
|
||||
//crafting item, nei may not have
|
||||
// myGuiContainer.inventorySlots.getSlot(4).putStack();
|
||||
}
|
||||
|
||||
} else {
|
||||
System.out.println(firstGui.getClass().toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user