mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-11-18 11:19:11 +00:00
fix render bug
This commit is contained in:
1 parent
2dcead8ebe
commit
3c579e24ab
4 files changed
+19
-5
No files matched your search
@@ -17,6 +17,7 @@ import net.minecraft.client.gui.*;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -175,10 +176,17 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler {
|
||||
IngredientTracker tracker = new IngredientTracker(firstGui, ingredients);
|
||||
|
||||
//check stacks in player's inventory and crafting grid
|
||||
List<ItemStack> inventoryStacks = new ArrayList<>();
|
||||
for (Slot slot : (List<Slot>) firstGui.inventorySlots.inventorySlots) {
|
||||
boolean canGetStack = slot != null && slot.getHasStack() && slot.getStack().stackSize > 0 && slot.isItemValid(slot.getStack()) && slot.canTakeStack(Minecraft.getMinecraft().thePlayer);
|
||||
if (canGetStack) {
|
||||
tracker.addIngredientStack(slot.getStack());
|
||||
inventoryStacks.add(slot.getStack().copy());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < tracker.getIngredients().size(); i++) {
|
||||
for (ItemStack stack : inventoryStacks) {
|
||||
tracker.addAvailableStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class NEECraftingHelper implements IOverlayHandler {
|
||||
for (Slot slot : (List<Slot>) firstGui.inventorySlots.inventorySlots) {
|
||||
boolean canGetStack = slot != null && slot.getHasStack() && slot.getStack().stackSize > 0 && slot.isItemValid(slot.getStack()) && slot.canTakeStack(Minecraft.getMinecraft().thePlayer);
|
||||
if (canGetStack) {
|
||||
tracker.addIngredientStack(slot.getStack());
|
||||
tracker.addAvailableStack(slot.getStack());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -124,12 +124,18 @@ public class IngredientTracker {
|
||||
return requireToCraftStacks;
|
||||
}
|
||||
|
||||
public void addIngredientStack(ItemStack stack) {
|
||||
public void addAvailableStack(ItemStack stack) {
|
||||
for (Ingredient ingredient : this.ingredients) {
|
||||
if (ingredient.requiresToCraft()) {
|
||||
ItemStack craftableStack = ingredient.getCraftableIngredient();
|
||||
if (craftableStack != null && craftableStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(craftableStack, stack)) {
|
||||
if (craftableStack != null && craftableStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(craftableStack, stack) && stack.stackSize > 0) {
|
||||
int missingCount = (int) ingredient.getMissingCount();
|
||||
ingredient.addCurrentCount(stack.stackSize);
|
||||
if (ingredient.requiresToCraft()) {
|
||||
stack.stackSize = 0;
|
||||
} else {
|
||||
stack.stackSize -= missingCount;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user