Added the dyeable recipes for the Sigil of Holding to the Alchemy Table.

This commit is contained in:
WayofTime 2016-06-09 21:43:37 -04:00
parent 4eda0d6caa
commit 5388dbf883
5 changed files with 165 additions and 10 deletions

View file

@ -74,7 +74,15 @@ public class AlchemyTableRecipe
return input.size();
}
public ItemStack getRecipeOutput()
/**
* Returns the output of the recipe, sensitive to the input list provided.
* If the input list does not technically match, the recipe should return
* the default output.
*
* @param inputList
* @return
*/
public ItemStack getRecipeOutput(List<ItemStack> inputList)
{
return output.copy();
}

View file

@ -42,7 +42,7 @@ public class AlchemyTableRecipeJEI extends BlankRecipeWrapper
@Nonnull
public List<ItemStack> getOutputs()
{
return Collections.singletonList(recipe.getRecipeOutput());
return Collections.singletonList(recipe.getRecipeOutput(new ArrayList<ItemStack>()));
}
@Nullable

View file

@ -0,0 +1,144 @@
package WayofTime.bloodmagic.recipe.alchemyTable;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemBanner;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe;
public class AlchemyTableDyeableRecipe extends AlchemyTableRecipe
{
private ItemStack inputItem;
public AlchemyTableDyeableRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem)
{
super(inputItem, lpDrained, ticksRequired, tierRequired);
ArrayList<ItemStack> validDyes = new ArrayList<ItemStack>();
validDyes.add(new ItemStack(Items.NAME_TAG));
validDyes.add(new ItemStack(Items.DYE, 1, OreDictionary.WILDCARD_VALUE));
ArrayList<Object> recipe = new ArrayList<Object>();
recipe.add(inputItem);
recipe.add(validDyes);
this.input = recipe;
this.inputItem = inputItem;
}
@Override
public ItemStack getRecipeOutput(List<ItemStack> inputList)
{
int nameTagOrDyeLocation = -1;
int inputItemLocation = -1;
for (int x = 0; x < inputList.size(); x++)
{
ItemStack slot = inputList.get(x);
if (slot != null)
{
boolean match = OreDictionary.itemMatches(inputItem, slot, false);
if (match)
{
inputItemLocation = x;
continue;
} else
{
if (slot.getItem() == Items.NAME_TAG || slot.getItem() == Items.DYE)
{
nameTagOrDyeLocation = x;
continue;
}
}
}
}
if (nameTagOrDyeLocation != -1 && inputItemLocation != -1)
{
ItemStack tagOrDyeStack = inputList.get(nameTagOrDyeLocation);
ItemStack inputStack = inputList.get(inputItemLocation);
if (inputStack == null || tagOrDyeStack == null)
{
return output.copy();
}
ItemStack outputStack = inputStack.copy();
if (tagOrDyeStack.getItem() == Items.NAME_TAG)
{
if (!outputStack.hasTagCompound())
{
outputStack.setTagCompound(new NBTTagCompound());
}
outputStack.getTagCompound().setString(Constants.NBT.COLOR, tagOrDyeStack.getDisplayName());
return outputStack;
} else
{
EnumDyeColor dyeColor = ItemBanner.getBaseColor(tagOrDyeStack);
if (!outputStack.hasTagCompound())
{
outputStack.setTagCompound(new NBTTagCompound());
}
outputStack.getTagCompound().setString(Constants.NBT.COLOR, String.valueOf(dyeColor.getMapColor().colorValue));
return outputStack;
}
}
return output.copy();
}
@Override
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos)
{
boolean hasNameTagOrDye = false;
boolean hasInputItem = false;
for (int x = 0; x < checkedList.size(); x++)
{
ItemStack slot = checkedList.get(x);
if (slot != null)
{
boolean match = OreDictionary.itemMatches(inputItem, slot, false);
if (match && hasInputItem)
{
return false;
} else if (match)
{
hasInputItem = true;
continue;
} else
{
if (slot.getItem() == Items.NAME_TAG || slot.getItem() == Items.DYE)
{
if (hasNameTagOrDye)
{
return false;
} else
{
hasNameTagOrDye = true;
}
}
}
}
}
return hasNameTagOrDye && hasInputItem;
}
}

View file

@ -1,6 +1,5 @@
package WayofTime.bloodmagic.registry;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@ -15,6 +14,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectBinding;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
import WayofTime.bloodmagic.api.compress.CompressionRegistry;
@ -36,6 +36,7 @@ import WayofTime.bloodmagic.item.ItemComponent;
import WayofTime.bloodmagic.item.ItemDemonCrystal;
import WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid;
import WayofTime.bloodmagic.item.soul.ItemSoulGem;
import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTableDyeableRecipe;
import com.google.common.base.Stopwatch;
@ -313,5 +314,7 @@ public class ModRecipes
AlchemyTableRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.PLANT_OIL), 100, 100, 1, Items.POTATO, Items.POTATO, new ItemStack(Items.DYE, 1, 15));
AlchemyTableRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.PLANT_OIL), 100, 100, 1, Items.WHEAT, Items.WHEAT, new ItemStack(Items.DYE, 1, 15));
AlchemyTableRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.PLANT_OIL), 100, 100, 1, Items.BEETROOT, Items.BEETROOT, Items.BEETROOT, new ItemStack(Items.DYE, 1, 15));
AlchemyTableRecipeRegistry.registerRecipe(new AlchemyTableDyeableRecipe(0, 100, 0, new ItemStack(ModItems.sigilHolding)));
}
}

View file

@ -254,7 +254,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
worldObj.notifyBlockUpdate(getPos(), state, state, 3);
}
if (canCraft(recipe))
if (canCraft(inputList, recipe))
{
ticksRequired = recipe.getTicksRequired();
burnTime++;
@ -274,7 +274,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
if (!worldObj.isRemote)
{
craftItem(recipe);
craftItem(inputList, recipe);
}
}
@ -301,14 +301,14 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
return ((double) burnTime) / ticksRequired;
}
private boolean canCraft(AlchemyTableRecipe recipe)
private boolean canCraft(List<ItemStack> inputList, AlchemyTableRecipe recipe)
{
if (recipe == null)
{
return false;
}
ItemStack outputStack = recipe.getRecipeOutput();
ItemStack outputStack = recipe.getRecipeOutput(inputList);
ItemStack currentOutputStack = getStackInSlot(outputSlot);
if (outputStack == null)
return false;
@ -365,11 +365,11 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
return 0;
}
public void craftItem(AlchemyTableRecipe recipe)
public void craftItem(List<ItemStack> inputList, AlchemyTableRecipe recipe)
{
if (this.canCraft(recipe))
if (this.canCraft(inputList, recipe))
{
ItemStack outputStack = recipe.getRecipeOutput();
ItemStack outputStack = recipe.getRecipeOutput(inputList);
ItemStack currentOutputStack = getStackInSlot(outputSlot);
if (currentOutputStack == null)