some improvements to tick time
This commit is contained in:
parent
f9a99feee0
commit
f92f67232a
3 changed files with 18 additions and 3 deletions
|
@ -106,6 +106,8 @@ public class RecipeCrafter {
|
||||||
*/
|
*/
|
||||||
double powerMultiplier = 1;
|
double powerMultiplier = 1;
|
||||||
|
|
||||||
|
int ticksSinceLastChange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this on the tile tick
|
* Call this on the tile tick
|
||||||
*/
|
*/
|
||||||
|
@ -113,7 +115,12 @@ public class RecipeCrafter {
|
||||||
if(parentTile.getWorldObj().isRemote){
|
if(parentTile.getWorldObj().isRemote){
|
||||||
return;
|
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;
|
currentTickTime = 0;
|
||||||
for (IBaseRecipeType recipe : RecipeHandler.getRecipeClassFromName(recipeName)) {
|
for (IBaseRecipeType recipe : RecipeHandler.getRecipeClassFromName(recipeName)) {
|
||||||
if (recipe.canCraft(parentTile) && hasAllInputs(recipe)) {//This checks to see if it has all of the inputs
|
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 {
|
} 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;
|
currentRecipe = null;
|
||||||
currentTickTime = 0;
|
currentTickTime = 0;
|
||||||
syncIsActive();
|
syncIsActive();
|
||||||
|
@ -166,6 +173,9 @@ public class RecipeCrafter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(inventory.hasChanged){
|
||||||
|
inventory.hasChanged = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAllInputs() {
|
public boolean hasAllInputs() {
|
||||||
|
|
|
@ -191,7 +191,7 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.amplifier > 0) {
|
if (this.amplifier > 0) {
|
||||||
if (this.amplifier > this.energy.getEnergyStored()) {
|
if (this.amplifier > this.energy.getEnergyStored()) {
|
||||||
this.progresstime += this.energy.getEnergyStored();
|
this.progresstime += this.energy.getEnergyStored();
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class Inventory implements IInventory {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final int stackLimit;
|
private final int stackLimit;
|
||||||
private TileEntity tile = new TileEntity();
|
private TileEntity tile = new TileEntity();
|
||||||
|
public boolean hasChanged = false;
|
||||||
|
|
||||||
public Inventory(int size, String invName, int invStackLimit)
|
public Inventory(int size, String invName, int invStackLimit)
|
||||||
{
|
{
|
||||||
|
@ -43,10 +44,12 @@ public class Inventory implements IInventory {
|
||||||
{
|
{
|
||||||
ItemStack result = contents[slotId].splitStack(count);
|
ItemStack result = contents[slotId].splitStack(count);
|
||||||
markDirty();
|
markDirty();
|
||||||
|
hasChanged = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
ItemStack stack = contents[slotId];
|
ItemStack stack = contents[slotId];
|
||||||
setInventorySlotContents(slotId, null);
|
setInventorySlotContents(slotId, null);
|
||||||
|
hasChanged = true;
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -67,6 +70,7 @@ public class Inventory implements IInventory {
|
||||||
itemstack.stackSize = this.getInventoryStackLimit();
|
itemstack.stackSize = this.getInventoryStackLimit();
|
||||||
}
|
}
|
||||||
markDirty();
|
markDirty();
|
||||||
|
hasChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -124,6 +128,7 @@ public class Inventory implements IInventory {
|
||||||
ItemStack.loadItemStackFromNBT(slot));
|
ItemStack.loadItemStackFromNBT(slot));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
hasChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound data)
|
public void writeToNBT(NBTTagCompound data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue