Finished Imprinter

This commit is contained in:
Henry Mao 2013-01-12 22:57:46 +08:00
parent cab2361358
commit 10312d6110
4 changed files with 47 additions and 53 deletions

View file

@ -1 +1 @@
51
52

View file

@ -45,3 +45,4 @@ Minecraft 1.4.5
@ AssemblyLine_v0.2.3.49.jar AssemblyLine_v0.2.3.49_api.zip
@ AssemblyLine_v0.2.3.50.jar AssemblyLine_v0.2.3.50_api.zip
@ AssemblyLine_v0.2.3.51.jar AssemblyLine_v0.2.3.51_api.zip
@ AssemblyLine_v0.2.3.52.jar AssemblyLine_v0.2.3.52_api.zip

View file

@ -9,9 +9,9 @@ public class SlotCraftingResult extends Slot
{
private ContainerImprinter container;
public SlotCraftingResult(ContainerImprinter container, IInventory par1iInventory, int par2, int par3, int par4)
public SlotCraftingResult(ContainerImprinter container, IInventory inventory, int par2, int par3, int par4)
{
super(par1iInventory, par2, par3, par4);
super(inventory, par2, par3, par4);
this.container = container;
}
@ -24,8 +24,7 @@ public class SlotCraftingResult extends Slot
@Override
public boolean canTakeStack(EntityPlayer player)
{
return playerHasRequiredIngredients(player, getStack());
// return true;
return this.container.tileEntity.getIdealRecipe(this.getStack()) != null;
}
@Override
@ -41,15 +40,15 @@ public class SlotCraftingResult extends Slot
{
for (ItemStack searchStack : requiredItems)
{
for (int i = 0; i < entityPlayer.inventory.getSizeInventory(); i++)
for (int i = 0; i < this.container.tileEntity.getSizeInventory(); i++)
{
ItemStack checkStack = entityPlayer.inventory.getStackInSlot(i);
ItemStack checkStack = this.container.tileEntity.getStackInSlot(i);
if (checkStack != null)
{
if (searchStack.isItemEqual(checkStack))
{
entityPlayer.inventory.decrStackSize(i, 1);
this.container.tileEntity.decrStackSize(i, 1);
break;
}
}
@ -59,39 +58,18 @@ public class SlotCraftingResult extends Slot
}
}
private boolean playerHasRequiredIngredients(EntityPlayer player, ItemStack desiredItem)
{
if (this.getStack() != null)
{
ItemStack[] idealRecipe = this.container.tileEntity.getIdealRecipe(this.getStack()).getValue();
if (idealRecipe != null)
{
ItemStack[] requiredItems = idealRecipe.clone();
int foundItems = 0;
if (requiredItems != null)
{
for (ItemStack searchStack : requiredItems)
{
for (int i = 0; i < player.inventory.getSizeInventory(); i++)
{
ItemStack checkStack = player.inventory.getStackInSlot(i);
if (checkStack != null)
{
if (searchStack.isItemEqual(checkStack))
{
foundItems++;
}
}
}
}
}
if (foundItems >= requiredItems.length)
return true;
}
}
return false;
}
/*
* private boolean playerHasRequiredIngredients(EntityPlayer player, ItemStack desiredItem) { if
* (this.getStack() != null) { ItemStack[] idealRecipe =
* this.container.tileEntity.getIdealRecipe(this.getStack()).getValue(); if (idealRecipe !=
* null) { ItemStack[] requiredItems = idealRecipe.clone(); int foundItems = 0;
*
* if (requiredItems != null) { for (ItemStack searchStack : requiredItems) { for (int i = 0; i
* < player.inventory.getSizeInventory(); i++) { ItemStack checkStack =
* player.inventory.getStackInSlot(i);
*
* if (checkStack != null) { if (searchStack.isItemEqual(checkStack)) { foundItems++; } } } } }
*
* if (foundItems >= requiredItems.length) return true; } } return false; }
*/
}

View file

@ -67,13 +67,29 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
* returns them in a new stack.
*/
@Override
public ItemStack decrStackSize(int slot, int amount)
public ItemStack decrStackSize(int i, int amount)
{
if (this.containingItems[slot] != null)
if (this.containingItems[i] != null)
{
ItemStack var3 = this.containingItems[slot];
this.containingItems[slot] = null;
return var3;
ItemStack var3;
if (this.containingItems[i].stackSize <= amount)
{
var3 = this.containingItems[i];
this.containingItems[i] = null;
return var3;
}
else
{
var3 = this.containingItems[i].splitStack(amount);
if (this.containingItems[i].stackSize == 0)
{
this.containingItems[i] = null;
}
return var3;
}
}
else
{
@ -196,10 +212,8 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
{
ArrayList<ItemStack> filters = ItemImprinter.getFilters(this.getStackInSlot(3));
if (filters.size() > 0)
for (ItemStack outputStack : filters)
{
ItemStack outputStack = filters.get(0);
if (outputStack != null)
{
Pair<ItemStack, ItemStack[]> idealRecipe = this.getIdealRecipe(outputStack);
@ -212,6 +226,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
{
this.setInventorySlotContents(4, recipeOutput);
didCraft = true;
break;
}
}
}
@ -275,11 +290,11 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
}
/**
* Returns if players has the following resource required.
* Returns if the following inventory has the following resource required.
*
* @param recipeItems - The items to be checked for the recipes.
*/
private ArrayList<ItemStack> hasResource(Object[] recipeItems)
public ArrayList<ItemStack> hasResource(Object[] recipeItems)
{
/**
* The actual amount of resource required. Each ItemStack will only have stacksize of 1.