mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-22 21:09:43 +00:00
fix crafting terminal
This commit is contained in:
1 parent
e8e27d421a
commit
2632a9b1cd
6 files changed
+112
-70
No files matched your search
@@ -0,0 +1,76 @@
|
||||
package com.glodblock.github.nei;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketNEIRecipe;
|
||||
import appeng.util.Platform;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
import com.glodblock.github.client.gui.GuiFluidCraftingWireless;
|
||||
|
||||
public class FluidCraftingTransferHandler implements IOverlayHandler {
|
||||
|
||||
public static final FluidCraftingTransferHandler INSTANCE = new FluidCraftingTransferHandler();
|
||||
|
||||
@Override
|
||||
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
|
||||
try {
|
||||
final List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
|
||||
if (firstGui instanceof GuiFluidCraftingWireless
|
||||
&& FluidPatternTerminalRecipeTransferHandler.craftSet.contains(recipe.getOverlayIdentifier())) {
|
||||
PacketNEIRecipe packet = new PacketNEIRecipe(packIngredients(firstGui, ingredients));
|
||||
NetworkHandler.instance.sendToServer(packet);
|
||||
}
|
||||
} catch (final Exception | Error ignored) {
|
||||
// NO-OP
|
||||
}
|
||||
}
|
||||
|
||||
private NBTTagCompound packIngredients(GuiContainer gui, List<PositionedStack> ingredients) throws IOException {
|
||||
final NBTTagCompound recipe = new NBTTagCompound();
|
||||
for (final PositionedStack positionedStack : ingredients) {
|
||||
final int col = (positionedStack.relx - 25) / 18;
|
||||
final int row = (positionedStack.rely - 6) / 18;
|
||||
if (positionedStack.items != null && positionedStack.items.length > 0) {
|
||||
for (final Object o : gui.inventorySlots.inventorySlots) {
|
||||
if (o instanceof SlotCraftingMatrix || o instanceof SlotFakeCraftingMatrix) {
|
||||
Slot slot = (Slot) o;
|
||||
if (slot.getSlotIndex() == col + row * 3) {
|
||||
final NBTTagList tags = new NBTTagList();
|
||||
final List<ItemStack> list = new LinkedList<ItemStack>();
|
||||
// prefer pure crystals.
|
||||
for (int x = 0; x < positionedStack.items.length; x++) {
|
||||
if (Platform.isRecipePrioritized(positionedStack.items[x])) {
|
||||
list.add(0, positionedStack.items[x]);
|
||||
} else {
|
||||
list.add(positionedStack.items[x]);
|
||||
}
|
||||
}
|
||||
for (final ItemStack is : list) {
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
is.writeToNBT(tag);
|
||||
tags.appendTag(tag);
|
||||
}
|
||||
recipe.setTag("#" + slot.getSlotIndex(), tags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
+2
-4
@@ -10,7 +10,6 @@ import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiFluidCraftingWireless;
|
||||
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
|
||||
import com.glodblock.github.nei.object.OrderStack;
|
||||
import com.glodblock.github.nei.recipes.FluidRecipe;
|
||||
@@ -31,9 +30,8 @@ public class FluidPatternTerminalRecipeTransferHandler implements IOverlayHandle
|
||||
|
||||
@Override
|
||||
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
|
||||
if (firstGui instanceof FCGuiEncodeTerminal || firstGui instanceof GuiFluidCraftingWireless) {
|
||||
boolean priority = !(firstGui instanceof GuiFluidCraftingWireless)
|
||||
&& ((FCGuiEncodeTerminal) firstGui).container.prioritize;
|
||||
if (firstGui instanceof FCGuiEncodeTerminal) {
|
||||
boolean priority = ((FCGuiEncodeTerminal) firstGui).container.prioritize;
|
||||
List<OrderStack<?>> in = FluidRecipe.getPackageInputs(recipe, recipeIndex, priority);
|
||||
List<OrderStack<?>> out = FluidRecipe.getPackageOutputs(recipe, recipeIndex, !notUseOther(recipe));
|
||||
boolean craft = shouldCraft(recipe);
|
||||
|
||||
@@ -19,7 +19,7 @@ public class NEI_FC_Config implements IConfigureNEI {
|
||||
for (String identifier : FluidRecipe.getSupportRecipes()) {
|
||||
API.registerGuiOverlayHandler(
|
||||
GuiFluidCraftingWireless.class,
|
||||
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
|
||||
FluidCraftingTransferHandler.INSTANCE,
|
||||
identifier);
|
||||
API.registerGuiOverlayHandler(
|
||||
GuiFluidPatternWireless.class,
|
||||
|
||||
Reference in new issue
Block a user