fixed Anvil JEI
This commit is contained in:
@@ -3,6 +3,7 @@ package nmd.primal.forgecraft.blocks.Anvil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
@@ -34,9 +35,9 @@ public class AnvilIron extends AnvilBase implements AnvilHandler {
|
||||
TileAnvil tile = (TileAnvil) world.getTileEntity(pos);
|
||||
if (tile != null) {
|
||||
if ((pItem.getItem() instanceof Gallagher) || (pItem.getItem() == ModItems.forgehammer)) {
|
||||
String[] tempArray = new String[25];
|
||||
ItemStack[] tempArray = new ItemStack[25];
|
||||
for (int i = 0; i < 25; i++) {
|
||||
tempArray[i] = tile.getSlotStack(i).getItem().getRegistryName().toString();
|
||||
tempArray[i] = tile.getSlotStack(i);
|
||||
}
|
||||
/*for (int i = 0; i < 25; i++) {
|
||||
if (tile.getSlotStack(i).getItem() instanceof BaseMultiItem) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package nmd.primal.forgecraft.blocks.Anvil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -108,21 +109,10 @@ public class AnvilStone extends AnvilBase {
|
||||
}
|
||||
}
|
||||
if ((pItem.getItem() instanceof Gallagher) || (pItem.getItem() == ModItems.forgehammer)) {
|
||||
String[] tempArray = new String[25];
|
||||
ItemStack[] tempArray = new ItemStack[25];
|
||||
for (int i = 0; i < 25; i++) {
|
||||
tempArray[i] = tile.getSlotStack(i).getItem().getRegistryName().toString();
|
||||
tempArray[i] = tile.getSlotStack(i);
|
||||
}
|
||||
/*for (int i = 0; i < 25; i++) {
|
||||
if (tile.getSlotStack(i).getItem() instanceof BaseMultiItem) {
|
||||
if (((BaseMultiItem) tile.getSlotStack(i).getItem()).getMaterial(tile.getSlotStack(i).getItem()) != PrimalMaterials.TOOL_WROUGHT_IRON) {
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
|
||||
CommonUtils.spawnItemEntityFromWorld(world, pos, new ItemStack(PrimalItems.ROCK_STONE, 3));
|
||||
CommonUtils.spawnItemEntityFromWorld(world, pos, new ItemStack(ModBlocks.ironball, 1));
|
||||
this.breakBlock(world, pos, state);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
doAnvilRecipe(pItem, tempArray, world, tile, pos, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -72,9 +72,9 @@ public class ModJEI implements IModPlugin
|
||||
// ***************************************************************************** //
|
||||
// Info
|
||||
// ***************************************************************************** //
|
||||
registry.addIngredientInfo(ItemStack.EMPTY, ItemStack.class, "jei.info.forgecraft.crucible");
|
||||
//registry.addIngredientInfo(ItemStack.EMPTY, ItemStack.class, "jei.info.forgecraft.crucible");
|
||||
registry.addIngredientInfo(new ItemStack(ModBlocks.nbtCrucible, 1, OreDictionary.WILDCARD_VALUE), ItemStack.class, "jei.info.forgecraft.crucible");
|
||||
registry.addIngredientInfo(new OreIngredient("oreIron"), OreIngredient.class, "jei.info.forgecraft.oreiron");
|
||||
//registry.addIngredientInfo(new OreIngredient("oreIron"), OreIngredient.class, "jei.info.forgecraft.oreiron");
|
||||
|
||||
registry.addIngredientInfo(new ItemStack(ModBlocks.stoneanvil, 1, OreDictionary.WILDCARD_VALUE), ItemStack.class, "jei.info.forgecraft.anvil");
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import nmd.primal.core.common.helper.CommonUtils;
|
||||
import nmd.primal.forgecraft.ModInfo;
|
||||
import nmd.primal.forgecraft.compat.JEI.AbstractCategory;
|
||||
import nmd.primal.forgecraft.init.ModBlocks;
|
||||
import nmd.primal.forgecraft.init.ModItems;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -23,13 +24,13 @@ public class AnvilRecipeCategory extends AbstractCategory<AnvilRecipeWrapper>
|
||||
{
|
||||
public static String CATEGORY = CommonUtils.prefix("anvil");
|
||||
|
||||
private static ResourceLocation gui_background = new ResourceLocation(ModInfo.MOD_ID,"textures/gui/jei/crucible.png");
|
||||
private static ResourceLocation gui_background = new ResourceLocation(ModInfo.MOD_ID,"textures/gui/jei/anvil.png");
|
||||
private final IDrawable background;
|
||||
|
||||
public AnvilRecipeCategory(IGuiHelper guiHelper)
|
||||
{
|
||||
//background = guiHelper.createDrawable(gui_background, 0, 0, 134, 144, 0, 0, 0, 0);
|
||||
background = guiHelper.createDrawable(gui_background, 0,0,160,134);
|
||||
background = guiHelper.createDrawable(gui_background, 0,0,160,96);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -98,17 +99,17 @@ public class AnvilRecipeCategory extends AbstractCategory<AnvilRecipeWrapper>
|
||||
//items.set(0, recipe.getIngredient(0));
|
||||
|
||||
for(int i =0; i < 25; i++){
|
||||
items.set(i, new ItemStack(recipe.getIngredient(i), 1));
|
||||
items.set(i, recipe.getIngredient(i));
|
||||
}
|
||||
|
||||
/***OUTPUTS***/
|
||||
items.init(25, false, 115, 96);
|
||||
items.init(25, false, 133, 40);
|
||||
items.set(25, recipe.output);
|
||||
|
||||
/***EXTRAS***/
|
||||
//items.init(6, false, 1, 96);
|
||||
//ItemStack crucibleStack = new ItemStack(ModBlocks.nbtCrucible, 1, 0);
|
||||
//items.set(6, crucibleStack);
|
||||
items.init(26, false, 105, 28);
|
||||
ItemStack hammerStack = new ItemStack(ModItems.forgehammer, 1);
|
||||
items.set(26, hammerStack);
|
||||
|
||||
//items.init(7, false, 58, 96);
|
||||
//ItemStack bloomeryStack = new ItemStack(ModBlocks.bloomery_brick, 1, 0);
|
||||
|
||||
@@ -2,6 +2,7 @@ package nmd.primal.forgecraft.compat.JEI.anvil;
|
||||
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -12,6 +13,8 @@ import nmd.primal.core.api.PrimalAPI;
|
||||
import nmd.primal.forgecraft.crafting.AnvilCrafting;
|
||||
import nmd.primal.forgecraft.init.ModItems;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,7 +25,7 @@ public class AnvilRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
protected final AnvilCrafting recipe;
|
||||
|
||||
protected String[] input;
|
||||
protected ItemStack[] input;
|
||||
protected String upgradeType;
|
||||
protected ItemStack output;
|
||||
|
||||
@@ -39,21 +42,22 @@ public class AnvilRecipeWrapper implements IRecipeWrapper {
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
|
||||
for(int i =0; i < input.length; i++){
|
||||
ResourceLocation name = new ResourceLocation(input[i]);
|
||||
ingredients.setInput(ItemStack.class, ForgeRegistries.ITEMS.getValue(name));
|
||||
for(int i =0; i < 25; i++){
|
||||
//if(this.input[i] != new ItemStack(Items.AIR, 1) {
|
||||
ingredients.setInput(ItemStack.class, this.input[i]);
|
||||
//}
|
||||
}
|
||||
ingredients.setOutput(ItemStack.class, this.output);
|
||||
}
|
||||
|
||||
public Item getIngredient(int a){
|
||||
public ItemStack getIngredient(int a){
|
||||
return input[a];
|
||||
}
|
||||
|
||||
Item[] tempArray = new Item[25];
|
||||
for(int i =0; i < input.length; i++){
|
||||
ResourceLocation name = new ResourceLocation(input[i]);
|
||||
tempArray[i] = ForgeRegistries.ITEMS.getValue(name);
|
||||
}
|
||||
List<Item> stackList = Arrays.asList(tempArray);
|
||||
return stackList.get(a);
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY)
|
||||
{
|
||||
//minecraft.fontRenderer.drawString(recipe.getDropsCooked().getDisplayName() + " Recipe", 20, 5, Color.black.getRGB());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package nmd.primal.forgecraft.crafting;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -20,13 +21,13 @@ public class AnvilCrafting {
|
||||
|
||||
private static ArrayList<AnvilCrafting> anvilRecipes = new ArrayList<>();
|
||||
|
||||
private String[] input = new String[25];
|
||||
private ItemStack[] input = new ItemStack[25];
|
||||
|
||||
private String upgradeType;
|
||||
|
||||
private ItemStack output;
|
||||
|
||||
public AnvilCrafting(String[] input, ItemStack output, String upgrade){
|
||||
public AnvilCrafting(ItemStack[] input, ItemStack output, String upgrade){
|
||||
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
@@ -38,33 +39,47 @@ public class AnvilCrafting {
|
||||
// Recipe Methods
|
||||
// ***************************************************************************** //
|
||||
|
||||
public static void addRecipe(String[] input, ItemStack output, String upgrade)
|
||||
public static void addRecipe(ItemStack[] input, ItemStack output, String upgrade)
|
||||
{
|
||||
anvilRecipes.add(new AnvilCrafting(input, output, upgrade));
|
||||
}
|
||||
|
||||
public static boolean isRecipe(String[] array)
|
||||
public static boolean isRecipe(ItemStack[] array)
|
||||
{
|
||||
for(AnvilCrafting recipe : anvilRecipes) {
|
||||
if (Arrays.equals(array, recipe.input))
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static AnvilCrafting getRecipe(String[] array)
|
||||
public static AnvilCrafting getRecipe(ItemStack[] array)
|
||||
{
|
||||
for(AnvilCrafting recipe : anvilRecipes) {
|
||||
if (Arrays.equals(array, recipe.input))
|
||||
if(checkArrays(recipe.getInput(), array)){
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String[] getInput() {return this.input;}
|
||||
public static boolean checkArrays (ItemStack[] leftArray, ItemStack[] rightArray){
|
||||
int a =0;
|
||||
for(int i=0; i<leftArray.length; i++){
|
||||
if( (leftArray[i].isEmpty() && rightArray[i].isEmpty()) ||
|
||||
((leftArray[i].isItemEqualIgnoreDurability(rightArray[i]))) ) {
|
||||
a++;
|
||||
}
|
||||
if(a == 25){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {return this.output;}
|
||||
public ItemStack[] getInput() {return this.input;}
|
||||
|
||||
public ItemStack getOutput() {return this.output.copy();}
|
||||
|
||||
public String getUpgrade() {return this.upgradeType; }
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -54,7 +55,7 @@ public interface AnvilHandler {
|
||||
return reverseMax[x];
|
||||
}
|
||||
|
||||
default boolean doAnvilRecipe(ItemStack pItem, String[] tempArray, World world, TileAnvil tile, BlockPos pos, EntityPlayer player) {
|
||||
default boolean doAnvilRecipe(ItemStack pItem, ItemStack[] tempArray, World world, TileAnvil tile, BlockPos pos, EntityPlayer player) {
|
||||
AnvilCrafting recipe = AnvilCrafting.getRecipe(tempArray);
|
||||
if (recipe != null) {
|
||||
if (pItem.getItem() instanceof Gallagher) {
|
||||
|
||||
@@ -128,3 +128,4 @@ forgecraft.compatibility=Compatibility
|
||||
forgecraft.compatibility.tooltip=Compatibility Features
|
||||
|
||||
jei.category.forgecraft.crucible=Crucible Crafting
|
||||
jei.category.forgecraft.anvil=Anvil Crafting
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 794 B |
Reference in New Issue
Block a user