mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
This will allow to click plus-sign in NEI and NEI will select recipe on Anvil automatically.
38 lines
1.3 KiB
Java
38 lines
1.3 KiB
Java
package com.hbm.handler.nei;
|
|
|
|
import com.hbm.inventory.gui.GUIAnvil;
|
|
import com.hbm.inventory.recipes.anvil.AnvilRecipes.AnvilConstructionRecipe;
|
|
|
|
import codechicken.nei.api.IOverlayHandler;
|
|
import codechicken.nei.recipe.IRecipeHandler;
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
/**
|
|
* Links NEI overlay interactions with the {@link GUIAnvil} so selecting a recipe focuses the anvil view.
|
|
*/
|
|
public class AnvilOverlayHandler implements IOverlayHandler {
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*
|
|
* <p>When the NEI overlay is opened for the Nuclear Tech anvil, the GUI is instructed to focus the selected recipe.</p>
|
|
* <p>It will not craft the recepie. Only select it.</p>
|
|
*
|
|
* @param firstGui the GUI currently displaying the overlay
|
|
* @param recipe the NEI recipe handler backing the overlay
|
|
* @param recipeIndex index of the recipe within the handler
|
|
* @param maxTransfer whether NEI is performing a maximal transfer (ignored)
|
|
*/
|
|
@Override
|
|
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean maxTransfer) {
|
|
if(!(firstGui instanceof GUIAnvil) || !(recipe instanceof AnvilRecipeHandler)) {
|
|
return;
|
|
}
|
|
|
|
AnvilConstructionRecipe construction = ((AnvilRecipeHandler) recipe).getConstructionRecipe(recipeIndex);
|
|
if(construction != null) {
|
|
((GUIAnvil) firstGui).focusRecipe(construction);
|
|
}
|
|
}
|
|
}
|