make solderer save state, tweak duration for recipes and add sided inv

This commit is contained in:
Raoul Van den Berge
2015-12-23 14:31:04 +01:00
parent 06fa4555cb
commit 683249da92
5 changed files with 79 additions and 6 deletions

View File

@@ -35,7 +35,7 @@ public class GuiSolderer extends GuiBase
if (solderer.isWorking())
{
drawTexturedModalRect(x + 83, y + 40 - 1, 177, 0, solderer.getProgressScaled(21), 14);
drawTexturedModalRect(x + 83, y + 40 - 1, 177, 0, solderer.getProgressScaled(22), 15);
}
}

View File

@@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import storagecraft.inventory.InventorySimple;
@@ -12,9 +13,11 @@ import storagecraft.tile.solderer.ISoldererRecipe;
import storagecraft.tile.solderer.SoldererRegistry;
import storagecraft.util.InventoryUtils;
// @TODO: Write working and progress to NBT
public class TileSolderer extends TileMachine implements IInventory
public class TileSolderer extends TileMachine implements IInventory, ISidedInventory
{
public static final String NBT_WORKING = "Working";
public static final String NBT_PROGRESS = "Progress";
private InventorySimple inventory = new InventorySimple("solderer", 4);
private ISoldererRecipe recipe;
private boolean working = false;
@@ -151,12 +154,57 @@ public class TileSolderer extends TileMachine implements IInventory
return inventory.isItemValidForSlot(slot, stack);
}
@Override
public int[] getAccessibleSlotsFromSide(int side)
{
// On all sides, but not the bottom we can reach the slots
if (side > 0)
{
return new int[]
{
0, 1, 2
};
}
// On the bottom we can only reach the output slot
return new int[]
{
3
};
}
@Override
public boolean canInsertItem(int slot, ItemStack stack, int side)
{
// We can insert in all slots, but not the output slot or via the output side
return side != 0 && slot != 3;
}
@Override
public boolean canExtractItem(int slot, ItemStack stack, int side)
{
// We can only extract from the buttom in the last slot
return side == 0 && slot == 3;
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
InventoryUtils.restoreInventory(this, nbt);
recipe = SoldererRegistry.getRecipe(inventory);
if (nbt.hasKey(NBT_WORKING))
{
working = nbt.getBoolean(NBT_WORKING);
}
if (nbt.hasKey(NBT_PROGRESS))
{
progress = nbt.getInteger(NBT_PROGRESS);
}
}
@Override
@@ -165,6 +213,9 @@ public class TileSolderer extends TileMachine implements IInventory
super.writeToNBT(nbt);
InventoryUtils.saveInventory(this, nbt);
nbt.setBoolean(NBT_WORKING, working);
nbt.setInteger(NBT_PROGRESS, progress);
}
@Override

View File

@@ -36,6 +36,6 @@ public class SoldererRecipeDrive implements ISoldererRecipe
@Override
public int getDuration()
{
return 400;
return 500;
}
}

View File

@@ -44,6 +44,18 @@ public class SoldererRecipePrintedProcessor implements ISoldererRecipe
@Override
public int getDuration()
{
return 100;
switch (type)
{
case ItemProcessor.TYPE_PRINTED_BASIC:
return 100;
case ItemProcessor.TYPE_PRINTED_IMPROVED:
return 150;
case ItemProcessor.TYPE_PRINTED_ADVANCED:
return 200;
case ItemProcessor.TYPE_PRINTED_SILICON:
return 90;
}
return 0;
}
}

View File

@@ -50,6 +50,16 @@ public class SoldererRecipeProcessor implements ISoldererRecipe
@Override
public int getDuration()
{
return 200;
switch (type)
{
case ItemProcessor.TYPE_BASIC:
return 250;
case ItemProcessor.TYPE_IMPROVED:
return 300;
case ItemProcessor.TYPE_ADVANCED:
return 350;
}
return 0;
}
}