mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
86 lines
1.7 KiB
Java
86 lines
1.7 KiB
Java
package com.hbm.inventory;
|
|
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraftforge.oredict.OreDictionary;
|
|
|
|
public class RecipesCommon {
|
|
|
|
public static class ComparableStack {
|
|
|
|
Item item;
|
|
int stacksize;
|
|
int meta;
|
|
|
|
public ComparableStack(Item item) {
|
|
this.item = item;
|
|
this.stacksize = 1;
|
|
this.meta = 0;
|
|
}
|
|
|
|
public ComparableStack(Item item, int stacksize) {
|
|
this(item);
|
|
this.stacksize = stacksize;
|
|
}
|
|
|
|
public ComparableStack(Item item, int stacksize, int meta) {
|
|
this(item, stacksize);
|
|
this.meta = meta;
|
|
}
|
|
|
|
public ItemStack toStack() {
|
|
|
|
return new ItemStack(item, stacksize, meta);
|
|
}
|
|
|
|
public String[] getDictKeys() {
|
|
|
|
int[] ids = OreDictionary.getOreIDs(toStack());
|
|
|
|
if(ids == null || ids.length == 0)
|
|
return new String[0];
|
|
|
|
String[] entries = new String[ids.length];
|
|
|
|
for(int i = 0; i < ids.length; i++) {
|
|
|
|
entries[i] = OreDictionary.getOreName(ids[i]);
|
|
}
|
|
|
|
return entries;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
final int prime = 31;
|
|
int result = 1;
|
|
result = prime * result + Item.getIdFromItem(item);
|
|
result = prime * result + meta;
|
|
result = prime * result + stacksize;
|
|
return result;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (this == obj)
|
|
return true;
|
|
if (obj == null)
|
|
return false;
|
|
if (getClass() != obj.getClass())
|
|
return false;
|
|
ComparableStack other = (ComparableStack) obj;
|
|
if (item == null) {
|
|
if (other.item != null)
|
|
return false;
|
|
} else if (!item.equals(other.item))
|
|
return false;
|
|
if (meta != other.meta)
|
|
return false;
|
|
if (stacksize != other.stacksize)
|
|
return false;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
}
|