Fixing compression glitches

This commit is contained in:
WayofTime 2014-11-20 10:49:21 -05:00
parent 174d56b8ff
commit 5224b808c3
7 changed files with 45 additions and 5 deletions

View file

@ -7,6 +7,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.compress.CompressionHandler;
import WayofTime.alchemicalWizardry.api.compress.CompressionRegistry;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class AdvancedCompressionHandler extends CompressionHandler
{
@ -30,13 +32,15 @@ public class AdvancedCompressionHandler extends CompressionHandler
continue;
}
int threshold = CompressionRegistry.getItemThreshold(invStack);
for(int i=2; i<=3; i++)
{
ItemStack stacky = getRecipe(invStack, world, i);
if(isResultStackReversible(stacky, i, world))
{
int needed = i*i;
int neededLeft = iterateThroughInventory(invStack, 0, inv, needed, false);
int neededLeft = iterateThroughInventory(invStack, threshold, inv, needed, false);
if(neededLeft <= 0)
{
iterateThroughInventory(invStack, 0, inv, needed, true);
@ -132,7 +136,7 @@ public class AdvancedCompressionHandler extends CompressionHandler
return false;
}else
{
return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? compressedStack.getTagCompound() == null : stack.getTagCompound().equals(compressedStack.getTagCompound()));
return SpellHelper.areItemStacksEqual(stack, compressedStack);
}
}

View file

@ -81,7 +81,6 @@ public class BaseCompressionHandler extends CompressionHandler
if(kept <= 0 && needed > 0)
{
int remainingFromStack = Math.max(stackSize - used - needed, 0);
needed -= (stackSize - used - remainingFromStack);
if(doDrain)
{
invStack.stackSize = remainingFromStack;
@ -90,6 +89,8 @@ public class BaseCompressionHandler extends CompressionHandler
inv[i] = null;
}
}
needed -= (stackSize - used - remainingFromStack);
}
if(needed <= 0)

View file

@ -14,7 +14,6 @@ import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.compress.CompressionRegistry;
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
import WayofTime.alchemicalWizardry.api.items.interfaces.IHolding;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -562,4 +562,9 @@ public class SpellHelper
}
return null;
}
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack)
{
return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? compressedStack.getTagCompound() == null : stack.getTagCompound().equals(compressedStack.getTagCompound()));
}
}