Add config options, remove debug prints

This commit is contained in:
Richard Hendricks committed 2019-12-14 13:44:27 -06:00
1 parent fa5c4c0218
commit 93aa429cf2
3 files changed
+67 -47

No files matched your search

@@ -21,6 +21,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import forestry.core.config.Config;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.core.inventory.wrappers.InventoryMapper;
import forestry.core.network.DataInputStreamForestry;
@@ -44,9 +45,6 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
private long savedTick = 0;
private long savedSystemTimeExpiration = 0;
// Maximum crafting time of 750ms before ejecting out and stop hard-locking the server
static long WORKTABLE_MAX_CRAFT_TIME = 750 * 1000 * 1000;
public TileWorktable() {
super("worktable");
setInternalInventory(new InventoryWorktable(this));
@@ -126,18 +124,20 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
return false;
}
long currentTick = worldObj.getTotalWorldTime();
if (currentTick == savedTick){
// Processing in the same tick, second call, check expiration timer
long currentTime = System.nanoTime();
if(currentTime > savedSystemTimeExpiration) {
// Time to craft has expired, stop crafting loop
return false;
if( Config.enableCraftingTimeout ) {
long currentTick = worldObj.getTotalWorldTime();
if (currentTick == savedTick){
// Processing in the same tick, second call, check expiration timer
long currentTime = System.nanoTime();
if(currentTime > savedSystemTimeExpiration) {
// Time to craft has expired, stop crafting loop
return false;
}
} else {
// New tick has arrived, so reset timer data
savedTick=currentTick;
savedSystemTimeExpiration = System.nanoTime() + Config.craftingTimeout * 1000000;
}
} else {
// New tick has arrived, so reset timer data
savedTick=currentTick;
savedSystemTimeExpiration = System.nanoTime() + WORKTABLE_MAX_CRAFT_TIME;
}
ItemStack[] recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix());