From 88bb735ed8dad2c375e461ddf546c508a3374578 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Mon, 6 Jan 2014 00:55:16 -0600 Subject: [PATCH] Fixed Weird fuzzy business --- util/inv/AdaptorIInventory.java | 1 + util/item/AEItemDef.java | 7 +++++++ util/item/AEItemStack.java | 29 +++++++++++++---------------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/util/inv/AdaptorIInventory.java b/util/inv/AdaptorIInventory.java index 4c406ef30..927cfc6ac 100644 --- a/util/inv/AdaptorIInventory.java +++ b/util/inv/AdaptorIInventory.java @@ -128,6 +128,7 @@ public class AdaptorIInventory extends InventoryAdaptor if ( rv == null ) { rv = is.copy(); + filter = rv; rv.stackSize = lhow_many; how_many -= lhow_many; } diff --git a/util/item/AEItemDef.java b/util/item/AEItemDef.java index 74336eb68..aa8aad9a2 100644 --- a/util/item/AEItemDef.java +++ b/util/item/AEItemDef.java @@ -39,6 +39,7 @@ public class AEItemDef t.damageValue = damageValue; t.dspDamage = dspDamage; t.maxDamage = maxDamage; + t.tagCompound = tagCompound; return t; } @@ -71,4 +72,10 @@ public class AEItemDef } return false; } + + public void reHash() + { + def = item.itemID << Platform.DEF_OFFSET | damageValue; + myHash = def ^ (tagCompound == null ? 0 : System.identityHashCode( tagCompound )); + } } diff --git a/util/item/AEItemStack.java b/util/item/AEItemStack.java index 8a8f85d89..1bc3bac03 100644 --- a/util/item/AEItemStack.java +++ b/util/item/AEItemStack.java @@ -73,8 +73,6 @@ public final class AEItemStack extends AEStack implements IAEItemS * Kinda Hacky */ def.damageValue = def.getDamageValueHack( is ); - def.def = is.itemID << Platform.DEF_OFFSET | def.damageValue; - def.dspDamage = is.getItemDamageForDisplay(); def.maxDamage = is.getMaxDamage(); @@ -86,7 +84,7 @@ public final class AEItemStack extends AEStack implements IAEItemS setCraftable( false ); setCountRequestable( 0 ); - def.myHash = def.def ^ (def.tagCompound == null ? 0 : System.identityHashCode( def.tagCompound )); + def.reHash(); } public static AEItemStack create(Object a) @@ -243,9 +241,6 @@ public final class AEItemStack extends AEStack implements IAEItemS int dv = def.damageValue - b.def.damageValue; int dspv = def.dspDamage - b.def.dspDamage; - int dif = id == 0 ? (dv == 0 ? (dspv == 0 ? ((def.tagCompound == null ? 0 : def.tagCompound.hashCode()) - (b.def.tagCompound == null ? 0 - : b.def.tagCompound.hashCode())) : dspv) : dv) : id; - return id == 0 ? (dv == 0 ? (dspv == 0 ? ((def.tagCompound == null ? 0 : def.tagCompound.hashCode()) - (b.def.tagCompound == null ? 0 : b.def.tagCompound.hashCode())) : dspv) : dv) : id; } @@ -476,42 +471,44 @@ public final class AEItemStack extends AEStack implements IAEItemS public IAEItemStack getLow(FuzzyMode fuzzy) { AEItemStack bottom = new AEItemStack( this ); - bottom.def = bottom.def.copy(); + AEItemDef newDef = bottom.def = bottom.def.copy(); if ( fuzzy == FuzzyMode.IGNORE_ALL ) { - bottom.def.dspDamage = 0; + newDef.dspDamage = 0; } else { int low = fuzzy.calculateBreakPoint( def.maxDamage ); - bottom.def.dspDamage = low < def.dspDamage ? low : 0; + newDef.dspDamage = low < def.dspDamage ? low : 0; } - if ( bottom.def.item.isDamageable() ) - bottom.def.damageValue = bottom.def.dspDamage; + if ( newDef.item.isDamageable() ) + newDef.damageValue = newDef.dspDamage; + newDef.reHash(); return bottom; } public IAEItemStack getHigh(FuzzyMode fuzzy) { AEItemStack top = new AEItemStack( this ); - top.def = top.def.copy(); + AEItemDef newDef = top.def = top.def.copy(); if ( fuzzy == FuzzyMode.IGNORE_ALL ) { - top.def.dspDamage = def.maxDamage + 1; + newDef.dspDamage = def.maxDamage + 1; } else { int high = fuzzy.calculateBreakPoint( def.maxDamage ) + 1; - top.def.dspDamage = high > def.dspDamage ? high : def.maxDamage + 1; + newDef.dspDamage = high > def.dspDamage ? high : def.maxDamage + 1; } - if ( top.def.item.isDamageable() ) - top.def.damageValue = top.def.dspDamage; + if ( newDef.item.isDamageable() ) + newDef.damageValue = top.def.dspDamage; + newDef.reHash(); return top; }