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()) while (i.hasNext())
{ {
String name = i.next(); String name = i.next();
hash += NBTOrderlessHash( ctA.getTag( name ) ); hash += name.hashCode() ^ NBTOrderlessHash( ctA.getTag( name ) );
} }
return hash; return hash;
@@ -477,7 +477,7 @@ public class Platform
List<NBTBase> l = tagList( lA ); List<NBTBase> l = tagList( lA );
for (int x = 0; x < l.size(); x++) for (int x = 0; x < l.size(); x++)
{ {
hash += NBTOrderlessHash( l.get( x ) ); hash += ((Integer) x).hashCode() ^ NBTOrderlessHash( l.get( x ) );
} }
return hash; return hash;
+3
View File
@@ -34,6 +34,9 @@ public class AEItemDef
public OreRefrence isOre; public OreRefrence isOre;
static AESharedNBT lowTag = new AESharedNBT( Integer.MIN_VALUE );
static AESharedNBT highTag = new AESharedNBT( Integer.MAX_VALUE );
public AEItemDef copy() public AEItemDef copy()
{ {
AEItemDef t = new AEItemDef(); AEItemDef t = new AEItemDef();
+19 -5
View File
@@ -229,12 +229,24 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
@Override @Override
public int compareTo(AEItemStack b) public int compareTo(AEItemStack b)
{ {
int id = def.item.hashCode() - b.def.item.hashCode(); int id = compare( def.item.hashCode(), b.def.item.hashCode() );
int dv = def.damageValue - b.def.damageValue; int dv = compare( def.damageValue, b.def.damageValue );
int dspv = def.dspDamage - b.def.dspDamage; 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 private int compareNBT(AEItemDef b)
: b.def.tagCompound.getHash())) : dspv) : dv) : id; {
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) @SideOnly(Side.CLIENT)
@@ -485,6 +497,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
if ( newDef.item.isDamageable() ) if ( newDef.item.isDamageable() )
newDef.damageValue = newDef.dspDamage; newDef.damageValue = newDef.dspDamage;
newDef.tagCompound = newDef.lowTag;
newDef.reHash(); newDef.reHash();
return bottom; return bottom;
} }
@@ -514,6 +527,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
if ( newDef.item.isDamageable() ) if ( newDef.item.isDamageable() )
newDef.damageValue = top.def.dspDamage; newDef.damageValue = top.def.dspDamage;
newDef.tagCompound = newDef.highTag;
newDef.reHash(); newDef.reHash();
return top; return top;
} }
+10 -3
View File
@@ -18,7 +18,7 @@ import appeng.util.Platform;
public class AESharedNBT extends NBTTagCompound implements IAETagCompound public class AESharedNBT extends NBTTagCompound implements IAETagCompound
{ {
private Item itemid; private Item item;
private int meta, hash; private int meta, hash;
public SharedSearchObject sso; public SharedSearchObject sso;
private IItemComparison comp; private IItemComparison comp;
@@ -36,10 +36,17 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound
private AESharedNBT(Item itemID, int damageValue) { private AESharedNBT(Item itemID, int damageValue) {
super(); super();
itemid = itemID; item = itemID;
meta = damageValue; meta = damageValue;
} }
public AESharedNBT(int fakeValue) {
super();
item = null;
meta = 0;
hash = fakeValue;
}
@Override @Override
public NBTTagCompound getNBTTagCompoundCopy() public NBTTagCompound getNBTTagCompoundCopy()
{ {
@@ -78,7 +85,7 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound
public boolean matches(Item itemid2, int meta2, int orderlessHash) 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) public boolean comparePreciseWithRegistry(AESharedNBT tagCompound)