Fixed Bug: #0210 - Fuzzy on an export bus do not ignore NBT data and metadata.

Fixed Serious issue with items with the same hashes merging.
This commit is contained in:
AlgorithmX2
2014-03-21 22:58:03 -05:00
parent 2751a1467f
commit 0bfded7bbf
4 changed files with 34 additions and 10 deletions
+2 -2
View File
@@ -463,7 +463,7 @@ public class Platform
while (i.hasNext())
{
String name = i.next();
hash += NBTOrderlessHash( ctA.getTag( name ) );
hash += name.hashCode() ^ NBTOrderlessHash( ctA.getTag( name ) );
}
return hash;
@@ -477,7 +477,7 @@ public class Platform
List<NBTBase> l = tagList( lA );
for (int x = 0; x < l.size(); x++)
{
hash += NBTOrderlessHash( l.get( x ) );
hash += ((Integer) x).hashCode() ^ NBTOrderlessHash( l.get( x ) );
}
return hash;
+3
View File
@@ -34,6 +34,9 @@ public class AEItemDef
public OreRefrence isOre;
static AESharedNBT lowTag = new AESharedNBT( Integer.MIN_VALUE );
static AESharedNBT highTag = new AESharedNBT( Integer.MAX_VALUE );
public AEItemDef copy()
{
AEItemDef t = new AEItemDef();
+19 -5
View File
@@ -229,12 +229,24 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
@Override
public int compareTo(AEItemStack b)
{
int id = def.item.hashCode() - b.def.item.hashCode();
int dv = def.damageValue - b.def.damageValue;
int dspv = def.dspDamage - b.def.dspDamage;
int id = compare( def.item.hashCode(), b.def.item.hashCode() );
int dv = compare( def.damageValue, b.def.damageValue );
int dspv = compare( def.dspDamage, b.def.dspDamage );
// AELog.info( "NBT: " + nbt );
return id == 0 ? (dv == 0 ? (dspv == 0 ? compareNBT( b.def ) : dspv) : dv) : id;
}
return id == 0 ? (dv == 0 ? (dspv == 0 ? ((def.tagCompound == null ? 0 : def.tagCompound.getHash()) - (b.def.tagCompound == null ? 0
: b.def.tagCompound.getHash())) : dspv) : dv) : id;
private int compareNBT(AEItemDef b)
{
int nbt = compare( (def.tagCompound == null ? 0 : def.tagCompound.getHash()), (b.tagCompound == null ? 0 : b.tagCompound.getHash()) );
if ( nbt == 0 )
return compare( System.identityHashCode( def.tagCompound ), System.identityHashCode( b.tagCompound ) );
return nbt;
}
private int compare(int l, long m)
{
return l < m ? -1 : (l > m ? 1 : 0);
}
@SideOnly(Side.CLIENT)
@@ -485,6 +497,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
if ( newDef.item.isDamageable() )
newDef.damageValue = newDef.dspDamage;
newDef.tagCompound = newDef.lowTag;
newDef.reHash();
return bottom;
}
@@ -514,6 +527,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
if ( newDef.item.isDamageable() )
newDef.damageValue = top.def.dspDamage;
newDef.tagCompound = newDef.highTag;
newDef.reHash();
return top;
}
+10 -3
View File
@@ -18,7 +18,7 @@ import appeng.util.Platform;
public class AESharedNBT extends NBTTagCompound implements IAETagCompound
{
private Item itemid;
private Item item;
private int meta, hash;
public SharedSearchObject sso;
private IItemComparison comp;
@@ -36,10 +36,17 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound
private AESharedNBT(Item itemID, int damageValue) {
super();
itemid = itemID;
item = itemID;
meta = damageValue;
}
public AESharedNBT(int fakeValue) {
super();
item = null;
meta = 0;
hash = fakeValue;
}
@Override
public NBTTagCompound getNBTTagCompoundCopy()
{
@@ -78,7 +85,7 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound
public boolean matches(Item itemid2, int meta2, int orderlessHash)
{
return itemid2 == itemid && meta == meta2 && hash == orderlessHash;
return itemid2 == item && meta == meta2 && hash == orderlessHash;
}
public boolean comparePreciseWithRegistry(AESharedNBT tagCompound)