2012-10-16 03:42:57 +02:00
|
|
|
package ee3.common.emc;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2012-12-13 16:01:41 +01:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2012-10-16 03:56:50 +02:00
|
|
|
|
2012-10-27 23:41:02 +02:00
|
|
|
/**
|
|
|
|
* EMCRegistry
|
|
|
|
*
|
|
|
|
* Registry containing all EMC entries for objects
|
|
|
|
*
|
|
|
|
* @author pahimar
|
|
|
|
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
|
|
|
*
|
|
|
|
*/
|
2012-10-16 03:42:57 +02:00
|
|
|
public class EMCRegistry {
|
|
|
|
|
|
|
|
private static final EMCRegistry emcRegistry = new EMCRegistry();
|
2012-10-16 16:38:31 +02:00
|
|
|
|
2012-10-16 03:42:57 +02:00
|
|
|
private HashMap<Integer, HashMap<Integer, EMCEntry>> emcMap = new HashMap<Integer, HashMap<Integer, EMCEntry>>();
|
2012-10-16 16:38:31 +02:00
|
|
|
|
2012-10-17 22:01:43 +02:00
|
|
|
public static EMCRegistry instance() {
|
2012-10-16 03:42:57 +02:00
|
|
|
return emcRegistry;
|
|
|
|
}
|
2012-10-16 19:31:27 +02:00
|
|
|
|
|
|
|
public EMCEntry getEMCValue(Block block) {
|
|
|
|
if (block != null) {
|
|
|
|
return getEMCValue(block.blockID, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public EMCEntry getEMCValue(Item item) {
|
|
|
|
if (item != null) {
|
|
|
|
return getEMCValue(item.shiftedIndex, 0);
|
|
|
|
}
|
|
|
|
|
2012-10-16 03:56:50 +02:00
|
|
|
return null;
|
|
|
|
}
|
2012-10-16 19:31:27 +02:00
|
|
|
|
|
|
|
public EMCEntry getEMCValue(ItemStack itemStack) {
|
|
|
|
if (itemStack != null) {
|
|
|
|
return getEMCValue(itemStack.itemID, itemStack.getItemDamage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public EMCEntry getEMCValue(int id) {
|
|
|
|
return getEMCValue(id, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public EMCEntry getEMCValue(int id, int meta) {
|
|
|
|
if (emcMap.containsKey(id)) {
|
|
|
|
if (emcMap.get(id).containsKey(meta)) {
|
|
|
|
return emcMap.get(id).get(meta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addEMCValue(Block block, EMCEntry emcEntry) {
|
|
|
|
addEMCValue(block.blockID, 0, emcEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addEMCValue(Block block, int meta, EMCEntry emcEntry) {
|
|
|
|
addEMCValue(block.blockID, meta, emcEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addEMCValue(Item item, EMCEntry emcEntry) {
|
|
|
|
addEMCValue(item.shiftedIndex, 0, emcEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addEMCValue(ItemStack itemStack, EMCEntry emcEntry) {
|
|
|
|
addEMCValue(itemStack.itemID, itemStack.getItemDamage(), emcEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addEMCValue(int id, EMCEntry emcEntry) {
|
|
|
|
addEMCValue(id, 0, emcEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addEMCValue(int id, int meta, EMCEntry emcEntry) {
|
|
|
|
HashMap<Integer, EMCEntry> tempMap = new HashMap<Integer, EMCEntry>();
|
|
|
|
|
|
|
|
if (emcMap.containsKey(id)) {
|
|
|
|
tempMap = emcMap.get(id);
|
|
|
|
|
|
|
|
if (tempMap.containsKey(meta)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tempMap.put(meta, emcEntry);
|
|
|
|
emcMap.put(id, tempMap);
|
|
|
|
}
|
2012-10-16 16:38:31 +02:00
|
|
|
|
2012-10-16 03:42:57 +02:00
|
|
|
}
|