not working

This commit is contained in:
Richard Hendricks committed 2019-12-12 20:16:58 -06:00
1 parent 0cdaf8cff8
commit 2af41cf68d
3 files changed
+48 -9

No files matched your search

@@ -99,7 +99,6 @@ public abstract class RecipeUtil {
if (ItemStackUtil.containsSets(recipeItems, availableItems, true, true) == 0) {
return null;
}
// Check that it doesn't make a different recipe.
// For example:
// Wood Logs are all ore dictionary equivalent with each other,
@@ -140,7 +139,6 @@ public abstract class RecipeUtil {
}
}
}
List<ItemStack> outputs = findMatchingRecipes(crafting, world);
if (!ItemStackUtil.containsItemStack(outputs, recipeOutput)) {
return null;
@@ -155,7 +153,15 @@ public abstract class RecipeUtil {
}
List<ItemStack> matchingRecipes = new ArrayList<>();
List<int> matchingIndex=new ArrayList();
List matchingRecipeMap = new ArrayList();
int index = 0;
// Check across the whole cached recipe map
// Add each recipe to the matchingRecipes list
// Only do this if there were no cached recipes hit
for (Object recipe : CraftingManager.getInstance().getRecipeList()) {
IRecipe irecipe = (IRecipe) recipe;
@@ -163,10 +169,28 @@ public abstract class RecipeUtil {
ItemStack result = irecipe.getCraftingResult(inventory);
if (!ItemStackUtil.containsItemStack(matchingRecipes, result)) {
matchingRecipes.add(result);
// Add to the back of the list. That way when we cycle through the list
// moving items to the front, the index locations for the following items doesn't change
matchingRecipeMap.add(recipe);
matchingIndex.add(index);
break;
}
}
index++;
}
if (matchingIndex.size() > 0 )
{
// Only move the recipes if the last one was beyond 500 in the recipeMap (in GTNH about 57k recipes)
if (index > 500) {
System.out.println( "Highest recipe found at " + index + ", moving " + matchingIndex.size() + " to front" );
for (index = 0; index < matchingIndex.size(); index++) {
// Remove recipe and add back at the front
CraftingManager.getInstance().getRecipeList().remove(matchingIndex.get(index));
CraftingManager.getInstance().getRecipeList().add(0,matchingRecipeMap.get(index));
}
}
}
return matchingRecipes;
}
@@ -265,6 +265,7 @@ public abstract class SlotUtil {
// if mergeOnly = true, don't shift into empty slots.
private static boolean shiftToMachineInventory(List inventorySlots, ItemStack stackToShift, int numSlots, boolean mergeOnly) {
for (int machineIndex = playerInventorySize; machineIndex < numSlots; machineIndex++) {
// System.out.println("SlotUtil::shiftToMachineinventory");
Slot slot = (Slot) inventorySlots.get(machineIndex);
if (mergeOnly && slot.getStack() == null) {
continue;
@@ -44,6 +44,8 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
private long savedTick = 0;
private long savedSystemTimeExpiration = 0;
private boolean isDirty=true;
private long cleanCount = 0;
private long totalCount = 0;
// Maximum crafting time of 750ms before ejecting out and stop hard-locking the server
static long WORKTABLE_MAX_CRAFT_TIME = 750 * 1000 * 1000;
@@ -141,15 +143,25 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
savedTick=currentTick;
savedSystemTimeExpiration = System.nanoTime() + WORKTABLE_MAX_CRAFT_TIME;
isDirty = true;
System.out.println("cleanCount " + cleanCount + " totalCount " + totalCount);
cleanCount = 0;
totalCount = 0;
}
ItemStack[] recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix());
ItemStack[] inventory = InventoryUtil.getStacks(this);
InventoryCraftingForestry crafting = RecipeUtil.getCraftRecipe(recipeItems, inventory, worldObj, currentRecipe.getRecipeOutput());
totalCount++;
if (isDirty) {
ItemStack[] recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix());
ItemStack[] inventory = InventoryUtil.getStacks(this);
InventoryCraftingForestry crafting = RecipeUtil.getCraftRecipe(recipeItems, inventory, worldObj, currentRecipe.getRecipeOutput());
// Craft is validated, mark as clean
isDirty = false;
return crafting != null;
// Craft is validated, mark as clean
isDirty = false;
return crafting != null;
} else {
cleanCount++;
return true;
}
}
@Override
@@ -172,7 +184,9 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
if (removed == null) {
return false;
}
// Contents have changed, have to revalidate recipe
isDirty = true;
// update crafting display to match the ingredients that were actually used
setCraftingDisplay(crafting);
return true;