Finished Imprinter
This commit is contained in:
parent
cab2361358
commit
10312d6110
4 changed files with 47 additions and 53 deletions
|
@ -1 +1 @@
|
||||||
51
|
52
|
||||||
|
|
1
info.txt
1
info.txt
|
@ -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.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.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.51.jar AssemblyLine_v0.2.3.51_api.zip
|
||||||
|
@ AssemblyLine_v0.2.3.52.jar AssemblyLine_v0.2.3.52_api.zip
|
||||||
|
|
|
@ -9,9 +9,9 @@ public class SlotCraftingResult extends Slot
|
||||||
{
|
{
|
||||||
private ContainerImprinter container;
|
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;
|
this.container = container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,7 @@ public class SlotCraftingResult extends Slot
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(EntityPlayer player)
|
public boolean canTakeStack(EntityPlayer player)
|
||||||
{
|
{
|
||||||
return playerHasRequiredIngredients(player, getStack());
|
return this.container.tileEntity.getIdealRecipe(this.getStack()) != null;
|
||||||
// return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,15 +40,15 @@ public class SlotCraftingResult extends Slot
|
||||||
{
|
{
|
||||||
for (ItemStack searchStack : requiredItems)
|
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 (checkStack != null)
|
||||||
{
|
{
|
||||||
if (searchStack.isItemEqual(checkStack))
|
if (searchStack.isItemEqual(checkStack))
|
||||||
{
|
{
|
||||||
entityPlayer.inventory.decrStackSize(i, 1);
|
this.container.tileEntity.decrStackSize(i, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,39 +58,18 @@ public class SlotCraftingResult extends Slot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean playerHasRequiredIngredients(EntityPlayer player, ItemStack desiredItem)
|
/*
|
||||||
{
|
* private boolean playerHasRequiredIngredients(EntityPlayer player, ItemStack desiredItem) { if
|
||||||
if (this.getStack() != null)
|
* (this.getStack() != null) { ItemStack[] idealRecipe =
|
||||||
{
|
* this.container.tileEntity.getIdealRecipe(this.getStack()).getValue(); if (idealRecipe !=
|
||||||
ItemStack[] idealRecipe = this.container.tileEntity.getIdealRecipe(this.getStack()).getValue();
|
* null) { ItemStack[] requiredItems = idealRecipe.clone(); int foundItems = 0;
|
||||||
if (idealRecipe != null)
|
*
|
||||||
{
|
* if (requiredItems != null) { for (ItemStack searchStack : requiredItems) { for (int i = 0; i
|
||||||
ItemStack[] requiredItems = idealRecipe.clone();
|
* < player.inventory.getSizeInventory(); i++) { ItemStack checkStack =
|
||||||
int foundItems = 0;
|
* player.inventory.getStackInSlot(i);
|
||||||
|
*
|
||||||
if (requiredItems != null)
|
* if (checkStack != null) { if (searchStack.isItemEqual(checkStack)) { foundItems++; } } } } }
|
||||||
{
|
*
|
||||||
for (ItemStack searchStack : requiredItems)
|
* if (foundItems >= requiredItems.length) return true; } } return false; }
|
||||||
{
|
*/
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,13 +67,29 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
* returns them in a new stack.
|
* returns them in a new stack.
|
||||||
*/
|
*/
|
||||||
@Override
|
@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];
|
ItemStack var3;
|
||||||
this.containingItems[slot] = null;
|
|
||||||
return 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
|
else
|
||||||
{
|
{
|
||||||
|
@ -196,10 +212,8 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
{
|
{
|
||||||
ArrayList<ItemStack> filters = ItemImprinter.getFilters(this.getStackInSlot(3));
|
ArrayList<ItemStack> filters = ItemImprinter.getFilters(this.getStackInSlot(3));
|
||||||
|
|
||||||
if (filters.size() > 0)
|
for (ItemStack outputStack : filters)
|
||||||
{
|
{
|
||||||
ItemStack outputStack = filters.get(0);
|
|
||||||
|
|
||||||
if (outputStack != null)
|
if (outputStack != null)
|
||||||
{
|
{
|
||||||
Pair<ItemStack, ItemStack[]> idealRecipe = this.getIdealRecipe(outputStack);
|
Pair<ItemStack, ItemStack[]> idealRecipe = this.getIdealRecipe(outputStack);
|
||||||
|
@ -212,6 +226,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
{
|
{
|
||||||
this.setInventorySlotContents(4, recipeOutput);
|
this.setInventorySlotContents(4, recipeOutput);
|
||||||
didCraft = true;
|
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.
|
* @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.
|
* The actual amount of resource required. Each ItemStack will only have stacksize of 1.
|
||||||
|
|
Loading…
Reference in a new issue