Initial Git
This commit is contained in:
parent
e1d8dcff07
commit
a12f6ddce8
347 changed files with 16443 additions and 0 deletions
30
common/thaumcraft/api/crafting/IArcaneRecipe.java
Normal file
30
common/thaumcraft/api/crafting/IArcaneRecipe.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package thaumcraft.api.crafting;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IArcaneRecipe
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
* @param player
|
||||
*/
|
||||
boolean matches(IInventory var1, EntityPlayer player);
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
ItemStack getCraftingResult(IInventory var1);
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
int getRecipeSize();
|
||||
|
||||
ItemStack getRecipeOutput();
|
||||
int getCost();
|
||||
String getKey();
|
||||
}
|
||||
30
common/thaumcraft/api/crafting/IInfusionRecipe.java
Normal file
30
common/thaumcraft/api/crafting/IInfusionRecipe.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package thaumcraft.api.crafting;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import thaumcraft.api.ObjectTags;
|
||||
|
||||
public interface IInfusionRecipe
|
||||
{
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
* @param player
|
||||
*/
|
||||
boolean matches(IInventory var1, EntityPlayer player);
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
ItemStack getCraftingResult(IInventory var1);
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
int getRecipeSize();
|
||||
|
||||
ItemStack getRecipeOutput();
|
||||
int getCost();
|
||||
ObjectTags getTags();
|
||||
String getKey();
|
||||
}
|
||||
51
common/thaumcraft/api/crafting/RecipeCrucible.java
Normal file
51
common/thaumcraft/api/crafting/RecipeCrucible.java
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
package thaumcraft.api.crafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import thaumcraft.api.EnumTag;
|
||||
import thaumcraft.api.ObjectTags;
|
||||
|
||||
public class RecipeCrucible {
|
||||
|
||||
public ItemStack recipeOutput;
|
||||
public ObjectTags tags;
|
||||
public String key;
|
||||
public String researchKey;
|
||||
public int cost;
|
||||
|
||||
public RecipeCrucible(String researchKey, String key, ItemStack result, ObjectTags tags, int cost) {
|
||||
recipeOutput = result;
|
||||
this.tags = tags;
|
||||
this.key = key;
|
||||
this.researchKey = researchKey;
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
public RecipeCrucible(String key, ItemStack result, ObjectTags tags, int cost) {
|
||||
recipeOutput = result;
|
||||
this.tags = tags;
|
||||
this.key = key;
|
||||
this.researchKey = key;
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
public boolean matches(ObjectTags itags) {
|
||||
if (itags==null) return false;
|
||||
for (EnumTag tag:tags.getAspects()) {
|
||||
if (itags.getAmount(tag)<tags.getAmount(tag)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ObjectTags removeMatching(ObjectTags itags) {
|
||||
ObjectTags temptags = new ObjectTags();
|
||||
temptags.tags.putAll(itags.tags);
|
||||
|
||||
for (EnumTag tag:tags.getAspects()) {
|
||||
if (!temptags.reduceAmount(tag, tags.getAmount(tag))) return null;
|
||||
}
|
||||
|
||||
itags = temptags;
|
||||
return itags;
|
||||
}
|
||||
|
||||
}
|
||||
167
common/thaumcraft/api/crafting/ShapedArcaneCraftingRecipes.java
Normal file
167
common/thaumcraft/api/crafting/ShapedArcaneCraftingRecipes.java
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
package thaumcraft.api.crafting;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
|
||||
public class ShapedArcaneCraftingRecipes implements IArcaneRecipe
|
||||
{
|
||||
/** How many horizontal slots this recipe is wide. */
|
||||
public int recipeWidth;
|
||||
|
||||
/** How many vertical slots this recipe uses. */
|
||||
public int recipeHeight;
|
||||
|
||||
public String key;
|
||||
|
||||
public int cost;
|
||||
|
||||
/** Is a array of ItemStack that composes the recipe. */
|
||||
public ItemStack[] recipeItems;
|
||||
|
||||
/** Is the ItemStack that you get when craft the recipe. */
|
||||
private ItemStack recipeOutput;
|
||||
|
||||
/** Is the itemID of the output item that you get when craft the recipe. */
|
||||
public final int recipeOutputItemID;
|
||||
|
||||
public ShapedArcaneCraftingRecipes(String key, int par1, int par2, ItemStack[] par3ArrayOfItemStack, ItemStack par4ItemStack, int cost)
|
||||
{
|
||||
this.recipeOutputItemID = par4ItemStack.itemID;
|
||||
this.recipeWidth = par1;
|
||||
this.recipeHeight = par2;
|
||||
this.recipeItems = par3ArrayOfItemStack;
|
||||
this.recipeOutput = par4ItemStack;
|
||||
this.key = key;
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return this.recipeOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
public boolean matches(IInventory par1InventoryCrafting, EntityPlayer player)
|
||||
{
|
||||
if (key.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.username, key)) {
|
||||
return false;
|
||||
}
|
||||
for (int var2 = 0; var2 <= 3 - this.recipeWidth; ++var2)
|
||||
{
|
||||
for (int var3 = 0; var3 <= 3 - this.recipeHeight; ++var3)
|
||||
{
|
||||
if (this.checkMatch(par1InventoryCrafting, var2, var3, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.checkMatch(par1InventoryCrafting, var2, var3, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the region of a crafting inventory is match for the recipe.
|
||||
*/
|
||||
private boolean checkMatch(IInventory par1InventoryCrafting, int par2, int par3, boolean par4)
|
||||
{
|
||||
for (int var5 = 0; var5 < 3; ++var5)
|
||||
{
|
||||
for (int var6 = 0; var6 < 3; ++var6)
|
||||
{
|
||||
int var7 = var5 - par2;
|
||||
int var8 = var6 - par3;
|
||||
ItemStack var9 = null;
|
||||
|
||||
if (var7 >= 0 && var8 >= 0 && var7 < this.recipeWidth && var8 < this.recipeHeight)
|
||||
{
|
||||
if (par4)
|
||||
{
|
||||
var9 = this.recipeItems[this.recipeWidth - var7 - 1 + var8 * this.recipeWidth];
|
||||
}
|
||||
else
|
||||
{
|
||||
var9 = this.recipeItems[var7 + var8 * this.recipeWidth];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack var10 = ThaumcraftApiHelper.getStackInRowAndColumn(par1InventoryCrafting, var5, var6);
|
||||
|
||||
if (var10 != null || var9 != null)
|
||||
{
|
||||
if (var10 == null && var9 != null || var10 != null && var9 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (var9.itemID != var10.itemID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (var9.getItemDamage() != OreDictionary.WILDCARD_VALUE && var9.getItemDamage() != var10.getItemDamage())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (var9.hasTagCompound()) {
|
||||
NBTTagCompound tc = var9.getTagCompound();
|
||||
for (Object tag:tc.getTags().toArray()) {
|
||||
NBTBase base = (NBTBase)tag;
|
||||
Class nc = NBTBase.newTag(base.getId(), base.getName()).getClass();
|
||||
if (!(var10.hasTagCompound() &&
|
||||
nc.cast(var10.getTagCompound().getTag(base.getName())).equals(nc.cast(base)))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
public ItemStack getCraftingResult(IInventory par1InventoryCrafting)
|
||||
{
|
||||
return new ItemStack(this.recipeOutput.itemID, this.recipeOutput.stackSize, this.recipeOutput.getItemDamage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return this.recipeWidth * this.recipeHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
package thaumcraft.api.crafting;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import thaumcraft.api.ObjectTags;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
|
||||
public class ShapedInfusionCraftingRecipes implements IInfusionRecipe
|
||||
{
|
||||
/** How many horizontal slots this recipe is wide. */
|
||||
public int recipeWidth;
|
||||
|
||||
/** How many vertical slots this recipe uses. */
|
||||
public int recipeHeight;
|
||||
|
||||
public String key;
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public int cost;
|
||||
|
||||
public ObjectTags tags;
|
||||
|
||||
/** Is a array of ItemStack that composes the recipe. */
|
||||
public ItemStack[] recipeItems;
|
||||
|
||||
/** Is the ItemStack that you get when craft the recipe. */
|
||||
private ItemStack recipeOutput;
|
||||
|
||||
/** Is the itemID of the output item that you get when craft the recipe. */
|
||||
public final int recipeOutputItemID;
|
||||
|
||||
public ShapedInfusionCraftingRecipes(String key, int par1, int par2, ItemStack[] par3ArrayOfItemStack, ItemStack par4ItemStack, int cost, ObjectTags tags)
|
||||
{
|
||||
this.recipeOutputItemID = par4ItemStack.itemID;
|
||||
this.recipeWidth = par1;
|
||||
this.recipeHeight = par2;
|
||||
this.recipeItems = par3ArrayOfItemStack;
|
||||
this.recipeOutput = par4ItemStack;
|
||||
this.key = key;
|
||||
this.cost = cost;
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return this.recipeOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
public boolean matches(IInventory par1InventoryCrafting, EntityPlayer player)
|
||||
{
|
||||
if (key.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.username, key)) {
|
||||
return false;
|
||||
}
|
||||
for (int var2 = 0; var2 <= 3 - this.recipeWidth; ++var2)
|
||||
{
|
||||
for (int var3 = 0; var3 <= 3 - this.recipeHeight; ++var3)
|
||||
{
|
||||
if (this.checkMatch(par1InventoryCrafting, var2, var3, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.checkMatch(par1InventoryCrafting, var2, var3, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the region of a crafting inventory is match for the recipe.
|
||||
*/
|
||||
private boolean checkMatch(IInventory par1InventoryCrafting, int par2, int par3, boolean par4)
|
||||
{
|
||||
for (int var5 = 0; var5 < 3; ++var5)
|
||||
{
|
||||
for (int var6 = 0; var6 < 3; ++var6)
|
||||
{
|
||||
int var7 = var5 - par2;
|
||||
int var8 = var6 - par3;
|
||||
ItemStack var9 = null;
|
||||
|
||||
if (var7 >= 0 && var8 >= 0 && var7 < this.recipeWidth && var8 < this.recipeHeight)
|
||||
{
|
||||
if (par4)
|
||||
{
|
||||
var9 = this.recipeItems[this.recipeWidth - var7 - 1 + var8 * this.recipeWidth];
|
||||
}
|
||||
else
|
||||
{
|
||||
var9 = this.recipeItems[var7 + var8 * this.recipeWidth];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack var10 = ThaumcraftApiHelper.getStackInRowAndColumn(par1InventoryCrafting, var5, var6);
|
||||
|
||||
if (var10 != null || var9 != null)
|
||||
{
|
||||
if (var10 == null && var9 != null || var10 != null && var9 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (var9.itemID != var10.itemID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (var9.getItemDamage() != OreDictionary.WILDCARD_VALUE && var9.getItemDamage() != var10.getItemDamage())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (var9.hasTagCompound()) {
|
||||
NBTTagCompound tc = var9.getTagCompound();
|
||||
for (Object tag:tc.getTags().toArray()) {
|
||||
NBTBase base = (NBTBase)tag;
|
||||
Class nc = NBTBase.newTag(base.getId(), base.getName()).getClass();
|
||||
if (!(var10.hasTagCompound() &&
|
||||
nc.cast(var10.getTagCompound().getTag(base.getName())).equals(nc.cast(base)))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
public ItemStack getCraftingResult(IInventory par1InventoryCrafting)
|
||||
{
|
||||
return new ItemStack(this.recipeOutput.itemID, this.recipeOutput.stackSize, this.recipeOutput.getItemDamage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return this.recipeWidth * this.recipeHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectTags getTags() {
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
package thaumcraft.api.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
|
||||
public class ShapelessArcaneCraftingRecipes implements IArcaneRecipe
|
||||
{
|
||||
/** Is the ItemStack that you get when craft the recipe. */
|
||||
private final ItemStack recipeOutput;
|
||||
|
||||
/** Is a List of ItemStack that composes the recipe. */
|
||||
public final List recipeItems;
|
||||
|
||||
public String key;
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public int cost;
|
||||
|
||||
public ShapelessArcaneCraftingRecipes(String key, ItemStack par1ItemStack, List par2List, int cost)
|
||||
{
|
||||
this.recipeOutput = par1ItemStack;
|
||||
this.recipeItems = par2List;
|
||||
this.key = key;
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return this.recipeOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
public boolean matches(IInventory par1InventoryCrafting, EntityPlayer player)
|
||||
{
|
||||
if (key.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.username, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ArrayList var2 = new ArrayList(this.recipeItems);
|
||||
|
||||
for (int var3 = 0; var3 < 3; ++var3)
|
||||
{
|
||||
for (int var4 = 0; var4 < 3; ++var4)
|
||||
{
|
||||
ItemStack var5 = ThaumcraftApiHelper.getStackInRowAndColumn(par1InventoryCrafting, var4, var3);
|
||||
|
||||
if (var5 != null)
|
||||
{
|
||||
boolean var6 = false;
|
||||
Iterator var7 = var2.iterator();
|
||||
|
||||
while (var7.hasNext())
|
||||
{
|
||||
ItemStack var8 = (ItemStack)var7.next();
|
||||
|
||||
if (var5.itemID == var8.itemID && (var8.getItemDamage() == OreDictionary.WILDCARD_VALUE || var5.getItemDamage() == var8.getItemDamage()))
|
||||
{
|
||||
boolean matches=true;
|
||||
if (var8.hasTagCompound()) {
|
||||
NBTTagCompound tc = var8.getTagCompound();
|
||||
for (Object tag:tc.getTags().toArray()) {
|
||||
NBTBase base = (NBTBase)tag;
|
||||
Class nc = NBTBase.newTag(base.getId(), base.getName()).getClass();
|
||||
if (!(var5.hasTagCompound() &&
|
||||
nc.cast(var5.getTagCompound().getTag(base.getName())).equals(nc.cast(base)))) {
|
||||
matches=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (matches) {
|
||||
var6 = true;
|
||||
var2.remove(var8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!var6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return var2.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
public ItemStack getCraftingResult(IInventory par1InventoryCrafting)
|
||||
{
|
||||
return this.recipeOutput.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return this.recipeItems.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
package thaumcraft.api.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import thaumcraft.api.ObjectTags;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
|
||||
public class ShapelessInfusionCraftingRecipes implements IInfusionRecipe
|
||||
{
|
||||
/** Is the ItemStack that you get when craft the recipe. */
|
||||
private final ItemStack recipeOutput;
|
||||
|
||||
/** Is a List of ItemStack that composes the recipe. */
|
||||
public final List recipeItems;
|
||||
|
||||
public String key;
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public int cost;
|
||||
|
||||
public ObjectTags tags;
|
||||
|
||||
public ShapelessInfusionCraftingRecipes(String key, ItemStack par1ItemStack, List par2List, int cost, ObjectTags tags)
|
||||
{
|
||||
this.recipeOutput = par1ItemStack;
|
||||
this.recipeItems = par2List;
|
||||
this.key = key;
|
||||
this.cost = cost;
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return this.recipeOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
public boolean matches(IInventory par1InventoryCrafting, EntityPlayer player)
|
||||
{
|
||||
if (key.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.username, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ArrayList var2 = new ArrayList(this.recipeItems);
|
||||
|
||||
for (int var3 = 0; var3 < 3; ++var3)
|
||||
{
|
||||
for (int var4 = 0; var4 < 3; ++var4)
|
||||
{
|
||||
ItemStack var5 = ThaumcraftApiHelper.getStackInRowAndColumn(par1InventoryCrafting, var4, var3);
|
||||
|
||||
if (var5 != null)
|
||||
{
|
||||
boolean var6 = false;
|
||||
Iterator var7 = var2.iterator();
|
||||
|
||||
while (var7.hasNext())
|
||||
{
|
||||
ItemStack var8 = (ItemStack)var7.next();
|
||||
|
||||
if (var5.itemID == var8.itemID && (var8.getItemDamage() == OreDictionary.WILDCARD_VALUE || var5.getItemDamage() == var8.getItemDamage()))
|
||||
{
|
||||
boolean matches=true;
|
||||
if (var8.hasTagCompound()) {
|
||||
NBTTagCompound tc = var8.getTagCompound();
|
||||
for (Object tag:tc.getTags().toArray()) {
|
||||
NBTBase base = (NBTBase)tag;
|
||||
Class nc = NBTBase.newTag(base.getId(), base.getName()).getClass();
|
||||
if (!(var5.hasTagCompound() &&
|
||||
nc.cast(var5.getTagCompound().getTag(base.getName())).equals(nc.cast(base)))) {
|
||||
matches=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (matches) {
|
||||
var6 = true;
|
||||
var2.remove(var8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!var6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return var2.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
public ItemStack getCraftingResult(IInventory par1InventoryCrafting)
|
||||
{
|
||||
return this.recipeOutput.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return this.recipeItems.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectTags getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
package thaumcraft.api.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import thaumcraft.api.ObjectTags;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
|
||||
public class ShapelessInfusionCraftingWithNBTRecipes implements IInfusionRecipe
|
||||
{
|
||||
/** Is the ItemStack that you get when craft the recipe. */
|
||||
private final ItemStack recipeOutput;
|
||||
|
||||
/** Is a List of ItemStack that composes the recipe. */
|
||||
public final List recipeItems;
|
||||
|
||||
/** Is a List of nbt key/value pairs. */
|
||||
public final List<NBTBase> nbtList;
|
||||
|
||||
public String key;
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public int cost;
|
||||
|
||||
public ObjectTags tags;
|
||||
|
||||
public ShapelessInfusionCraftingWithNBTRecipes(String key,
|
||||
ItemStack par1ItemStack,
|
||||
List par2List, int cost, ObjectTags tags,
|
||||
List<NBTBase> nbtList)
|
||||
{
|
||||
this.recipeOutput = par1ItemStack;
|
||||
this.recipeItems = par2List;
|
||||
this.key = key;
|
||||
this.cost = cost;
|
||||
this.tags = tags;
|
||||
this.nbtList = nbtList;
|
||||
}
|
||||
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return this.recipeOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
public boolean matches(IInventory par1InventoryCrafting, EntityPlayer player)
|
||||
{
|
||||
if (key.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.username, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ArrayList var2 = new ArrayList(this.recipeItems);
|
||||
|
||||
for (int var3 = 0; var3 < 3; ++var3)
|
||||
{
|
||||
for (int var4 = 0; var4 < 3; ++var4)
|
||||
{
|
||||
ItemStack var5 = ThaumcraftApiHelper.getStackInRowAndColumn(par1InventoryCrafting, var4, var3);
|
||||
|
||||
if (var5 != null)
|
||||
{
|
||||
boolean var6 = false;
|
||||
Iterator var7 = var2.iterator();
|
||||
b1:
|
||||
while (var7.hasNext())
|
||||
{
|
||||
ItemStack var8 = (ItemStack)var7.next();
|
||||
|
||||
if (var5.itemID == var8.itemID && (var8.getItemDamage() == OreDictionary.WILDCARD_VALUE || var5.getItemDamage() == var8.getItemDamage()))
|
||||
{
|
||||
for (NBTBase nbt:nbtList) {
|
||||
try {
|
||||
Class nc = NBTBase.newTag(nbt.getId(), nbt.getName()).getClass();
|
||||
if (var5.hasTagCompound() &&
|
||||
nc.cast(var5.getTagCompound().getTag(nbt.getName())).equals(nc.cast(nbt))) {
|
||||
var6 = true;
|
||||
var2.remove(var8);
|
||||
break b1;
|
||||
}
|
||||
} catch (Exception e) {/*probably classcast*/}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!var6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return var2.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
public ItemStack getCraftingResult(IInventory par1InventoryCrafting)
|
||||
{
|
||||
return this.recipeOutput.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return this.recipeItems.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectTags getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue