GT5-Unofficial/main/java/gregtech/api/objects/MaterialStack.java

41 lines
1.2 KiB
Java
Raw Normal View History

2015-04-23 16:14:22 +00:00
package gregtech.api.objects;
import gregtech.api.enums.Materials;
public class MaterialStack implements Cloneable {
public long mAmount;
public Materials mMaterial;
public MaterialStack(Materials aMaterial, long aAmount) {
mMaterial = aMaterial==null?Materials._NULL:aMaterial;
mAmount = aAmount;
}
public MaterialStack copy(long aAmount) {
return new MaterialStack(mMaterial, aAmount);
}
@Override
public MaterialStack clone() {
return new MaterialStack(mMaterial, mAmount);
}
@Override
public boolean equals(Object aObject) {
if (aObject == this) return true;
if (aObject == null) return false;
if (aObject instanceof Materials) return aObject == mMaterial;
if (aObject instanceof MaterialStack) return ((MaterialStack)aObject).mMaterial == mMaterial && (mAmount < 0 || ((MaterialStack)aObject).mAmount < 0 || ((MaterialStack)aObject).mAmount == mAmount);
return false;
}
@Override
public String toString() {
return (mMaterial.mMaterialList.size() > 1 && mAmount > 1 ? "(" : "") + mMaterial.getToolTip(true) + (mMaterial.mMaterialList.size() > 1 && mAmount > 1 ? ")" : "") + (mAmount > 1 ? mAmount : "");
}
@Override
public int hashCode() {
return mMaterial.hashCode();
}
}