2013-09-07 04:44:31 +02:00
|
|
|
package com.pahimar.ee3.emc;
|
|
|
|
|
2013-10-06 04:46:29 +02:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.HashMap;
|
2013-09-07 04:44:31 +02:00
|
|
|
import java.util.List;
|
2013-10-06 04:46:29 +02:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.TreeMap;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.item.Item;
|
2013-09-10 03:48:34 +02:00
|
|
|
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
|
import com.google.common.collect.ImmutableSortedMap;
|
2013-10-06 04:46:29 +02:00
|
|
|
import com.pahimar.ee3.core.util.EnergyStack;
|
2013-09-07 04:44:31 +02:00
|
|
|
import com.pahimar.ee3.item.CustomWrappedStack;
|
|
|
|
|
|
|
|
public class EmcRegistry {
|
|
|
|
|
2013-09-07 04:47:12 +02:00
|
|
|
private static EmcRegistry emcRegistry = null;
|
2013-10-06 04:46:29 +02:00
|
|
|
|
|
|
|
private Map<CustomWrappedStack, EmcValue> stackMappings;
|
|
|
|
private TreeMap<EmcValue, List<CustomWrappedStack>> valueMappings;
|
2013-09-10 03:48:34 +02:00
|
|
|
|
2013-10-06 04:46:29 +02:00
|
|
|
private ImmutableMap<CustomWrappedStack, EmcValue> immutableStackMappings;
|
|
|
|
private ImmutableSortedMap<EmcValue, List<CustomWrappedStack>> immutableValueMappings;
|
2013-09-07 04:44:31 +02:00
|
|
|
|
2013-09-07 04:47:12 +02:00
|
|
|
private EmcRegistry() {
|
2013-09-07 04:44:31 +02:00
|
|
|
|
2013-10-06 04:46:29 +02:00
|
|
|
stackMappings = new HashMap<CustomWrappedStack, EmcValue>();
|
|
|
|
valueMappings = new TreeMap<EmcValue, List<CustomWrappedStack>>();
|
2013-09-07 04:47:12 +02:00
|
|
|
}
|
2013-09-07 04:44:31 +02:00
|
|
|
|
2013-09-07 04:47:12 +02:00
|
|
|
public static EmcRegistry getInstance() {
|
2013-09-07 04:44:31 +02:00
|
|
|
|
2013-09-07 04:47:12 +02:00
|
|
|
if (emcRegistry == null) {
|
|
|
|
emcRegistry = new EmcRegistry();
|
|
|
|
emcRegistry.init();
|
|
|
|
}
|
2013-09-07 04:44:31 +02:00
|
|
|
|
2013-09-07 04:47:12 +02:00
|
|
|
return emcRegistry;
|
|
|
|
}
|
2013-09-07 04:44:31 +02:00
|
|
|
|
2013-09-07 04:47:12 +02:00
|
|
|
private void init() {
|
|
|
|
|
2013-09-10 03:48:34 +02:00
|
|
|
// Grab the default value map
|
2013-10-06 04:46:29 +02:00
|
|
|
Map<CustomWrappedStack, EmcValue> defaultValueMap = EmcDefaultValues.getInstance().getDefaultValueMap();
|
|
|
|
|
|
|
|
// stackMappings.put(new CustomWrappedStack(), new EmcValue());
|
|
|
|
|
|
|
|
// Vanilla Smelting Energy
|
|
|
|
stackMappings.put(new CustomWrappedStack(Block.cobblestone), new EmcValue(1, EmcComponent.CORPOREAL_UNIT_COMPONENT));
|
|
|
|
stackMappings.put(new CustomWrappedStack(Block.wood), new EmcValue(32, EmcComponent.CORPOREAL_UNIT_COMPONENT));
|
|
|
|
stackMappings.put(new CustomWrappedStack(Block.oreIron), new EmcValue(256, EmcComponent.CORPOREAL_UNIT_COMPONENT));
|
|
|
|
stackMappings.put(new CustomWrappedStack(Block.oreGold), new EmcValue(2048, EmcComponent.CORPOREAL_UNIT_COMPONENT));
|
|
|
|
stackMappings.put(new CustomWrappedStack(Block.oreDiamond), new EmcValue(8192, EmcComponent.CORPOREAL_UNIT_COMPONENT));
|
|
|
|
stackMappings.put(new CustomWrappedStack(Item.coal), new EmcValue(32, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 4), new EmcComponent(EmcType.KINETIC, 1))));
|
|
|
|
|
|
|
|
stackMappings.put(
|
|
|
|
new CustomWrappedStack(new EnergyStack(EnergyStack.VANILLA_SMELTING_ENERGY_NAME)),
|
|
|
|
new EmcValue(
|
|
|
|
getEmcValue(new CustomWrappedStack(Item.coal)).getComponentValueByType(EmcType.KINETIC) / (8 * EnergyStack.VANILLA_SMELTING_ENERGY_THRESHOLD),
|
|
|
|
EmcComponent.KINETIC_UNIT_COMPONENT));
|
2013-09-10 03:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasEmcValue(CustomWrappedStack wrappedStack) {
|
|
|
|
|
2013-09-25 06:30:00 +02:00
|
|
|
return stackMappings.containsKey(wrappedStack) ? stackMappings.get(wrappedStack) instanceof EmcValue : false;
|
2013-09-10 03:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasStacksForValue(EmcValue emcValue) {
|
|
|
|
|
2013-09-25 06:30:00 +02:00
|
|
|
return valueMappings.containsKey(emcValue) ? valueMappings.get(emcValue).size() > 0 : false;
|
2013-09-10 03:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public EmcValue getEmcValue(CustomWrappedStack wrappedStack) {
|
|
|
|
|
2013-09-25 06:30:00 +02:00
|
|
|
return stackMappings.get(wrappedStack);
|
2013-09-10 03:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<CustomWrappedStack> getStacksFromValue(EmcValue emcValue) {
|
|
|
|
|
2013-09-25 06:30:00 +02:00
|
|
|
return valueMappings.get(emcValue);
|
2013-09-10 03:48:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<CustomWrappedStack> getStacksInEmcRange(EmcValue fromValue, EmcValue toValue) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addEmcValueMapping(CustomWrappedStack wrappedStack, EmcValue emcValue) {
|
|
|
|
|
|
|
|
|
2013-09-07 04:47:12 +02:00
|
|
|
}
|
2013-09-07 04:44:31 +02:00
|
|
|
}
|