Mekanism-tilera-Edition/common/buildcraft/api/core/StackWrapper.java

51 lines
1.2 KiB
Java
Raw Normal View History

2013-08-08 19:10:11 +02:00
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.core;
import net.minecraft.item.ItemStack;
/**
2013-12-26 21:00:08 +01:00
*
2013-08-08 19:10:11 +02:00
* @author CovertJaguar <http://www.railcraft.info/>
*/
2013-12-26 21:00:08 +01:00
public class StackWrapper {
2013-08-08 19:10:11 +02:00
public final ItemStack stack;
2013-12-26 21:00:08 +01:00
public StackWrapper(ItemStack stack) {
2013-08-08 19:10:11 +02:00
this.stack = stack;
}
@Override
2013-12-26 21:00:08 +01:00
public int hashCode() {
2013-08-08 19:10:11 +02:00
int hash = 5;
hash = 67 * hash + stack.itemID;
hash = 67 * hash + stack.getItemDamage();
if (stack.stackTagCompound != null)
hash = 67 * hash + stack.stackTagCompound.hashCode();
return hash;
}
@Override
2013-12-26 21:00:08 +01:00
public boolean equals(Object obj) {
2013-08-08 19:10:11 +02:00
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final StackWrapper other = (StackWrapper) obj;
if (stack.itemID != other.stack.itemID)
return false;
if (stack.getHasSubtypes() && stack.getItemDamage() != other.stack.getItemDamage())
return false;
if (stack.stackTagCompound != null && !stack.stackTagCompound.equals(other.stack.stackTagCompound))
return false;
return true;
}
}