mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-25 14:24:37 +00:00
138 lines
4.5 KiB
Java
138 lines
4.5 KiB
Java
package WayofTime.alchemicalWizardry.client.nei;
|
|
|
|
import java.awt.Point;
|
|
import java.awt.Rectangle;
|
|
import java.util.List;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import net.minecraft.util.StatCollector;
|
|
|
|
import WayofTime.alchemicalWizardry.api.bindingRegistry.BindingRecipe;
|
|
import WayofTime.alchemicalWizardry.api.bindingRegistry.BindingRegistry;
|
|
import WayofTime.alchemicalWizardry.client.nei.widgets.ReagentInfo;
|
|
import WayofTime.alchemicalWizardry.client.nei.widgets.RitualInfo;
|
|
import codechicken.lib.gui.GuiDraw;
|
|
import codechicken.nei.NEIServerUtils;
|
|
import codechicken.nei.PositionedStack;
|
|
import codechicken.nei.guihook.GuiContainerManager;
|
|
import codechicken.nei.recipe.GuiRecipe;
|
|
import codechicken.nei.recipe.TemplateRecipeHandler;
|
|
|
|
/**
|
|
* Binding Ritual Handler by Arcaratus
|
|
*/
|
|
public class NEIBindingRitualHandler extends TemplateRecipeHandler {
|
|
|
|
private static final RitualInfo ritualInfo = new RitualInfo("AW006Binding", 1f);
|
|
private static final ReagentInfo reagentInfo = new ReagentInfo(1f);
|
|
|
|
public class CachedBindingRecipe extends CachedRecipe {
|
|
|
|
PositionedStack input, output;
|
|
|
|
public CachedBindingRecipe(BindingRecipe recipe) {
|
|
input = new PositionedStack(recipe.requiredItem, 37, 21, false);
|
|
output = new PositionedStack(recipe.outputItem, 110, 21, false);
|
|
}
|
|
|
|
@Override
|
|
public PositionedStack getIngredient() {
|
|
return input;
|
|
}
|
|
|
|
@Override
|
|
public PositionedStack getResult() {
|
|
return output;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void loadCraftingRecipes(String outputId, Object... results) {
|
|
if (outputId.equals("alchemicalwizardry.bindingritual") && getClass() == NEIBindingRitualHandler.class) {
|
|
for (BindingRecipe recipe : BindingRegistry.bindingRecipes) {
|
|
if (recipe != null && recipe.outputItem != null) {
|
|
arecipes.add(new CachedBindingRecipe(recipe));
|
|
}
|
|
}
|
|
} else {
|
|
super.loadCraftingRecipes(outputId, results);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void loadCraftingRecipes(ItemStack result) {
|
|
for (BindingRecipe recipe : BindingRegistry.bindingRecipes) {
|
|
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(recipe.outputItem, result)) {
|
|
if (recipe.outputItem != null) {
|
|
arecipes.add(new CachedBindingRecipe(recipe));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void loadUsageRecipes(ItemStack ingredient) {
|
|
for (BindingRecipe recipe : BindingRegistry.bindingRecipes) {
|
|
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(recipe.requiredItem, ingredient)) {
|
|
if (recipe.outputItem != null) {
|
|
arecipes.add(new CachedBindingRecipe(recipe));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draws for every recipe, but it should really just do it once per page.
|
|
*
|
|
* @param recipe The recipeIndex being drawn
|
|
*/
|
|
@Override
|
|
public void drawExtras(int recipe) {
|
|
super.drawExtras(recipe);
|
|
ritualInfo.onDraw(0, 0);
|
|
reagentInfo.onDraw(150, 0);
|
|
}
|
|
|
|
@Override
|
|
public List<String> handleTooltip(GuiRecipe<?> gui, List<String> list, int recipeIndex) {
|
|
if (GuiContainerManager.shouldShowTooltip(gui) && list.isEmpty()) {
|
|
CachedRecipe cRecipe = arecipes.get(recipeIndex);
|
|
Point mousePos = GuiDraw.getMousePosition();
|
|
|
|
if (cRecipe instanceof NEIBindingRitualHandler.CachedBindingRecipe) {
|
|
Rectangle rect = ritualInfo.getRect(gui);
|
|
if (rect.contains(mousePos)) {
|
|
ritualInfo.onHover(list);
|
|
}
|
|
|
|
rect = reagentInfo.getRect(gui);
|
|
if (rect.contains(mousePos)) {
|
|
list.add(StatCollector.translateToLocal("nei.recipe.reagent.none"));
|
|
}
|
|
}
|
|
}
|
|
return super.handleTooltip(gui, list, recipeIndex);
|
|
}
|
|
|
|
@Override
|
|
public String getOverlayIdentifier() {
|
|
return "alchemicalwizardry.bindingritual";
|
|
}
|
|
|
|
@Override
|
|
public void loadTransferRects() {
|
|
transferRects.add(new RecipeTransferRect(new Rectangle(68, 20, 22, 16), "alchemicalwizardry.bindingritual"));
|
|
}
|
|
|
|
@Override
|
|
public String getRecipeName() {
|
|
return "Binding Ritual";
|
|
}
|
|
|
|
@Override
|
|
public String getGuiTexture() {
|
|
return new ResourceLocation("alchemicalwizardry", "gui/nei/bindingRitual.png").toString();
|
|
}
|
|
}
|