mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-22 21:09:43 +00:00
3da14b3bbe
* Replace ore dictionary bus Extra Cells ore dict bus -> export bus w/ ore dict card (retains ore filter setting, not verified they are 1:1) * Add OpenComputer migration Moves migration to postInit, and migrates OC upgrades. * Remap wireless w/ correct encryption key + power Basically now works without needing to relink in security term * Update buildscript * spotless apply * spotlessApply (#125) Co-authored-by: GitHub GTNH Actions <> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
77 lines
3.4 KiB
Java
77 lines
3.4 KiB
Java
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 com.glodblock.github.client.gui.GuiFluidCraftingWireless;
|
|
|
|
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;
|
|
|
|
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;
|
|
}
|
|
}
|