Added Binding Rituals for NEI
This commit is contained in:
parent
a5f0d1bc0a
commit
e37691fec4
3 changed files with 139 additions and 0 deletions
|
@ -0,0 +1,137 @@
|
||||||
|
package WayofTime.alchemicalWizardry.client.nei;
|
||||||
|
|
||||||
|
import WayofTime.alchemicalWizardry.api.bindingRegistry.BindingRecipe;
|
||||||
|
import WayofTime.alchemicalWizardry.api.bindingRegistry.BindingRegistry;
|
||||||
|
import codechicken.nei.NEIServerUtils;
|
||||||
|
import codechicken.nei.PositionedStack;
|
||||||
|
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.ScaledResolution;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binding Ritual Handler by Arcaratus
|
||||||
|
*/
|
||||||
|
public class NEIBindingRitualHandler extends TemplateRecipeHandler
|
||||||
|
{
|
||||||
|
public class CachedBindingRecipe extends CachedRecipe
|
||||||
|
{
|
||||||
|
PositionedStack input;
|
||||||
|
PositionedStack 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.binding") && 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.areStacksSameTypeCrafting(recipe.outputItem, result))
|
||||||
|
{
|
||||||
|
if (recipe != null && recipe.outputItem != null)
|
||||||
|
{
|
||||||
|
arecipes.add(new CachedBindingRecipe(recipe));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadUsageRecipes(ItemStack ingredient)
|
||||||
|
{
|
||||||
|
for (BindingRecipe recipe: BindingRegistry.bindingRecipes)
|
||||||
|
{
|
||||||
|
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.requiredItem, ingredient))
|
||||||
|
{
|
||||||
|
if (recipe != null && recipe.outputItem != null)
|
||||||
|
{
|
||||||
|
arecipes.add(new CachedBindingRecipe(recipe));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOverlayIdentifier()
|
||||||
|
{
|
||||||
|
return "bindingritual";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadTransferRects()
|
||||||
|
{
|
||||||
|
transferRects.add(new RecipeTransferRect(new Rectangle(90, 32, 22, 16), "alchemicalwizardry.bindingritual"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeName()
|
||||||
|
{
|
||||||
|
return "Binding Ritual";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGuiTexture()
|
||||||
|
{
|
||||||
|
return new ResourceLocation("alchemicalwizardry", "gui/nei/bindingRitual.png").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point getMousePosition()
|
||||||
|
{
|
||||||
|
Dimension size = displaySize();
|
||||||
|
Dimension res = displayRes();
|
||||||
|
return new Point(Mouse.getX() * size.width / res.width, size.height - Mouse.getY() * size.height / res.height - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dimension displaySize()
|
||||||
|
{
|
||||||
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||||
|
return new Dimension(res.getScaledWidth(), res.getScaledHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dimension displayRes()
|
||||||
|
{
|
||||||
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
return new Dimension(mc.displayWidth, mc.displayHeight);
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,8 @@ public class NEIConfig implements IConfigureNEI {
|
||||||
API.registerUsageHandler(new NEIBloodOrbShapedHandler());
|
API.registerUsageHandler(new NEIBloodOrbShapedHandler());
|
||||||
API.registerRecipeHandler(new NEIBloodOrbShapelessHandler());
|
API.registerRecipeHandler(new NEIBloodOrbShapelessHandler());
|
||||||
API.registerUsageHandler(new NEIBloodOrbShapelessHandler());
|
API.registerUsageHandler(new NEIBloodOrbShapelessHandler());
|
||||||
|
API.registerRecipeHandler(new NEIBindingRitualHandler());
|
||||||
|
API.registerUsageHandler(new NEIBindingRitualHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1,008 B |
Loading…
Add table
Add a link
Reference in a new issue