some improvements to tick time

This commit is contained in:
modmuss50 2015-06-25 08:28:29 +01:00
parent f9a99feee0
commit f92f67232a
3 changed files with 18 additions and 3 deletions

View file

@ -106,6 +106,8 @@ public class RecipeCrafter {
*/
double powerMultiplier = 1;
int ticksSinceLastChange;
/**
* Call this on the tile tick
*/
@ -113,7 +115,12 @@ public class RecipeCrafter {
if(parentTile.getWorldObj().isRemote){
return;
}
if (currentRecipe == null) {//It will now look for new recipes.
ticksSinceLastChange ++;
if(ticksSinceLastChange == 20){//Force a has chanced every second
inventory.hasChanged = true;
ticksSinceLastChange = 0;
}
if (currentRecipe == null && inventory.hasChanged) {//It will now look for new recipes.
currentTickTime = 0;
for (IBaseRecipeType recipe : RecipeHandler.getRecipeClassFromName(recipeName)) {
if (recipe.canCraft(parentTile) && hasAllInputs(recipe)) {//This checks to see if it has all of the inputs
@ -135,7 +142,7 @@ public class RecipeCrafter {
}
}
} else {
if (!hasAllInputs()) {//If it doesn't have all the inputs reset
if (inventory.hasChanged && !hasAllInputs()) {//If it doesn't have all the inputs reset
currentRecipe = null;
currentTickTime = 0;
syncIsActive();
@ -166,6 +173,9 @@ public class RecipeCrafter {
}
}
}
if(inventory.hasChanged){
inventory.hasChanged = false;
}
}
public boolean hasAllInputs() {

View file

@ -191,7 +191,7 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
}
}
}
if (this.amplifier > 0) {
if (this.amplifier > this.energy.getEnergyStored()) {
this.progresstime += this.energy.getEnergyStored();

View file

@ -14,6 +14,7 @@ public class Inventory implements IInventory {
private final String name;
private final int stackLimit;
private TileEntity tile = new TileEntity();
public boolean hasChanged = false;
public Inventory(int size, String invName, int invStackLimit)
{
@ -43,10 +44,12 @@ public class Inventory implements IInventory {
{
ItemStack result = contents[slotId].splitStack(count);
markDirty();
hasChanged = true;
return result;
}
ItemStack stack = contents[slotId];
setInventorySlotContents(slotId, null);
hasChanged = true;
return stack;
}
return null;
@ -67,6 +70,7 @@ public class Inventory implements IInventory {
itemstack.stackSize = this.getInventoryStackLimit();
}
markDirty();
hasChanged = true;
}
@Override
@ -124,6 +128,7 @@ public class Inventory implements IInventory {
ItemStack.loadItemStackFromNBT(slot));
}
}
hasChanged = true;
}
public void writeToNBT(NBTTagCompound data)