Skip to content

Commit

Permalink
Fix descending lookups for good.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaquadro committed Aug 21, 2015
1 parent dc54c29 commit adf205a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "1.7.10-1.5.14"
version = "1.7.10-1.5.15"
group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "StorageDrawers"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,17 @@ private void populateSlots (ItemStack stack) {

ItemStack uTier1 = findHigherTier(stack);
if (uTier1 != null) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Picked candidate " + uTier1.toString() + " with conv=" + lookupSizeResult);

int uCount1 = lookupSizeResult;
ItemStack uTier2 = findHigherTier(uTier1);
if (uTier2 != null)
if (uTier2 != null) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Picked candidate " + uTier2.toString() + " with conv=" + lookupSizeResult);

populateSlot(index++, uTier2, lookupSizeResult * uCount1);
}

populateSlot(index++, uTier1, uCount1);
}
Expand Down Expand Up @@ -215,8 +222,14 @@ private void populateSlot (int slot, ItemStack stack, int conversion) {
}

private ItemStack findHigherTier (ItemStack stack) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Finding ascending candidates for " + stack.toString());

CompTierRegistry.Record record = StorageDrawers.compRegistry.findHigherTier(stack);
if (record != null) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Found " + record.upper.toString() + " in registry with conv=" + record.convRate);

lookupSizeResult = record.convRate;
return record.upper;
}
Expand Down Expand Up @@ -266,6 +279,9 @@ private ItemStack findHigherTier (ItemStack stack) {
if (candidates.size() > 0)
return candidates.get(0);

if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "No candidates found");

return null;
}

Expand All @@ -288,8 +304,14 @@ private List<ItemStack> findAllMatchingRecipes (InventoryCrafting crafting) {
}

private ItemStack findLowerTier (ItemStack stack) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Finding descending candidates for " + stack.toString());

CompTierRegistry.Record record = StorageDrawers.compRegistry.findLowerTier(stack);
if (record != null) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Found " + record.lower.toString() + " in registry with conv=" + record.convRate);

lookupSizeResult = record.convRate;
return record.lower;
}
Expand Down Expand Up @@ -327,14 +349,17 @@ private ItemStack findLowerTier (ItemStack stack) {

if (match != null) {
setupLookup(lookup1, stack);
ItemStack comp = cm.findMatchingRecipe(lookup1, worldObj);
if (DrawerData.areItemsEqual(match, comp, false) && comp.stackSize == recipe.getRecipeSize()) {
lookupSizeResult = recipe.getRecipeSize();
candidates.add(match);
candidatesRate.put(match, lookupSizeResult);

if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Found descending candidate for " + stack.toString() + ": " + match.toString() + " size=" + lookupSizeResult + ", inverse=" + comp.toString());
List<ItemStack> compMatches = findAllMatchingRecipes(lookup1);
for (ItemStack comp : compMatches) {
if (DrawerData.areItemsEqual(match, comp, false) && comp.stackSize == recipe.getRecipeSize()) {
lookupSizeResult = recipe.getRecipeSize();
candidates.add(match);
candidatesRate.put(match, lookupSizeResult);

if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Found descending candidate for " + stack.toString() + ": " + match.toString() + " size=" + lookupSizeResult + ", inverse=" + comp.toString());
} else if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Back-check failed for " + match.toString() + " size=" + lookupSizeResult + ", inverse=" + comp.toString());
}
}
}
Expand All @@ -352,6 +377,9 @@ private ItemStack findLowerTier (ItemStack stack) {
return match;
}

if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "No candidates found");

return null;
}

Expand Down

0 comments on commit adf205a

Please sign in to comment.