mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-25 14:24:40 +00:00
Add Item+Meta, Item+Meta+Stacksize and Item+Meta+Stacksize+NBT wrappers for use in maps and other stuff
This commit is contained in:
1 parent
48d853df0b
commit
2c680a4ea9
3 files changed
+108
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package mantle.utils;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemMetaWrapper {
|
||||
public final Item item;
|
||||
public final Integer meta;
|
||||
|
||||
public ItemMetaWrapper(Item item, Integer meta) {
|
||||
this.item = item;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public ItemMetaWrapper(ItemStack stack)
|
||||
{
|
||||
this.item = stack.getItem();
|
||||
this.meta = stack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ItemMetaWrapper itemMeta = (ItemMetaWrapper) o;
|
||||
|
||||
if (item != null ? !(item == itemMeta.item) : itemMeta.item != null) return false;
|
||||
if (meta != null ? !meta.equals(itemMeta.meta) : itemMeta.meta != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = item != null ? item.hashCode() : 0;
|
||||
result = 31 * result + (meta != null ? meta.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package mantle.utils;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemStackNBTWrapper {
|
||||
public final ItemStack stack;
|
||||
|
||||
public ItemStackNBTWrapper(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ItemStackNBTWrapper that = (ItemStackNBTWrapper) o;
|
||||
|
||||
return ItemStack.areItemStacksEqual(this.stack, that.stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = stack.getItem() != null ? stack.getItem().hashCode() : 0;
|
||||
result = 31 * result + stack.getItemDamage();
|
||||
result = 31 * result + (stack.getTagCompound() != null ? stack.getTagCompound().hashCode() : 0);
|
||||
result = 31 * result + stack.stackSize;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package mantle.utils;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemStackWrapper extends ItemMetaWrapper {
|
||||
public final Integer stacksize;
|
||||
|
||||
public ItemStackWrapper(Item item, Integer meta, Integer stacksize) {
|
||||
super(item, meta);
|
||||
this.stacksize = stacksize;
|
||||
}
|
||||
|
||||
public ItemStackWrapper(ItemStack stack, Integer stacksize) {
|
||||
super(stack);
|
||||
this.stacksize = stacksize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
ItemStackWrapper that = (ItemStackWrapper) o;
|
||||
|
||||
if (stacksize != null ? !stacksize.equals(that.stacksize) : that.stacksize != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (stacksize != null ? stacksize.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user