Skip to content

Commit

Permalink
v1.4.2 hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
DRKV333 committed Nov 30, 2017
1 parent 1762b22 commit c852d4a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
36 changes: 33 additions & 3 deletions Tiles/TransferAssemblerTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace MechTransfer.Tiles
public class TransferAssemblerTile : ModTile
{
private ItemInventory inventory = new ItemInventory();
private Item stockpile = new Item();

private Dictionary<int, int[]> tileRemap = new Dictionary<int, int[]>() {
{ 302, new int[]{ 17 } },
Expand Down Expand Up @@ -67,6 +68,18 @@ public override void HitWire(int i, int j)

private bool TryMakeRecipe(Recipe recipe, TransferAssemblerTileEntity entity)
{

while (stockpile.stack > 0)
{
Item safeCLone = stockpile.Clone();
safeCLone.stack = 1;
if(!TransferUtils.InjectItem(entity.Position.X, entity.Position.Y, safeCLone))
{
return true;
}
stockpile.stack--;
}

for (int i = 0; i < Recipe.maxRequirements && !recipe.requiredItem[i].IsAir; i++)
{
if (!inventory.TryTakeIngredient(recipe, recipe.requiredItem[i]))
Expand All @@ -93,10 +106,27 @@ private bool TryMakeRecipe(Recipe recipe, TransferAssemblerTileEntity entity)
ItemLoader.OnCraft(clone, recipe);
}

if (!TransferUtils.InjectItem(entity.Position.X, entity.Position.Y, clone))
if (clone.stack == 1)
{
if (!TransferUtils.InjectItem(entity.Position.X, entity.Position.Y, clone))
{
entity.Status = TransferAssemblerTileEntity.StatusKind.MissingSpace;
return true; //returning with success, so we don't try alternate recipes
}
}
else
{
entity.Status = TransferAssemblerTileEntity.StatusKind.MissingSpace;
return true; //returning with success, so we don't try alternate recipes
stockpile = clone;
while (stockpile.stack > 0)
{
Item safeCLone = stockpile.Clone();
safeCLone.stack = 1;
if (!TransferUtils.InjectItem(entity.Position.X, entity.Position.Y, safeCLone))
{
break;
}
stockpile.stack--;
}
}

inventory.Commit(alchemy);
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = DRKV
version = 1.4.1
version = 1.4.2
displayName = MechTransfer
includePDB = false
buildIgnore = .gitignore, description.txt, *.csproj*, *.sln, .git/*, .vs/*, bin/*, obj/*, *.xcf
Expand Down
5 changes: 4 additions & 1 deletion description.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ v1.4
- Added reflection based adapter loading

v1.4.1
- Fixed modded chest support
- Fixed modded chest support

v1.4.2
- Quick fix to stop assembler from eating items

0 comments on commit c852d4a

Please sign in to comment.