Messing around

This commit is contained in:
pahimar 2013-10-05 22:46:29 -04:00
parent b9b2e131fe
commit a3cfc4d0e0
7 changed files with 86 additions and 47 deletions

View file

@ -1,5 +1,5 @@
#Mon, 23 Sep 2013 15:00:03 -0400 #Mon, 23 Sep 2013 15:00:03 -0400
minecraft_version=1.6.4 minecraft_version=1.6.4
forge_version=9.11.0.901 forge_version=9.11.1.917
mod_version=pre2a mod_version=pre2a
build_number=26 build_number=26

View file

@ -23,13 +23,10 @@ import com.pahimar.ee3.core.handlers.PlayerDestroyItemHandler;
import com.pahimar.ee3.core.handlers.VersionCheckTickHandler; import com.pahimar.ee3.core.handlers.VersionCheckTickHandler;
import com.pahimar.ee3.core.handlers.WorldTransmutationHandler; import com.pahimar.ee3.core.handlers.WorldTransmutationHandler;
import com.pahimar.ee3.core.proxy.CommonProxy; import com.pahimar.ee3.core.proxy.CommonProxy;
import com.pahimar.ee3.core.util.EnergyStack;
import com.pahimar.ee3.core.util.LogHelper; import com.pahimar.ee3.core.util.LogHelper;
import com.pahimar.ee3.core.util.VersionHelper; import com.pahimar.ee3.core.util.VersionHelper;
import com.pahimar.ee3.creativetab.CreativeTabEE3; import com.pahimar.ee3.creativetab.CreativeTabEE3;
import com.pahimar.ee3.emc.DynEMC; import com.pahimar.ee3.emc.DynEMC;
import com.pahimar.ee3.emc.EmcRegistry;
import com.pahimar.ee3.item.CustomWrappedStack;
import com.pahimar.ee3.item.ModItems; import com.pahimar.ee3.item.ModItems;
import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes; import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes;
import com.pahimar.ee3.lib.InterModComms; import com.pahimar.ee3.lib.InterModComms;
@ -178,8 +175,7 @@ public class EquivalentExchange3 {
// Initialize the DynEMC system // Initialize the DynEMC system
DynEMC dynEMC = DynEMC.getInstance(); DynEMC dynEMC = DynEMC.getInstance();
dynEMC.printDebugDump();
LogHelper.debug(EmcRegistry.getInstance().getEmcValue(new CustomWrappedStack(new EnergyStack(EnergyStack.VANILLA_SMELTING_ENERGY_NAME))));
} }
@EventHandler @EventHandler

View file

@ -32,41 +32,41 @@ public class LogHelper {
public static void severe(Object object) { public static void severe(Object object) {
log(Level.SEVERE, object); log(Level.SEVERE, object.toString());
} }
public static void debug(Object object) { public static void debug(Object object) {
log(Level.WARNING, "[DEBUG] " + object); log(Level.WARNING, "[DEBUG] " + object.toString());
} }
public static void warning(Object object) { public static void warning(Object object) {
log(Level.WARNING, object); log(Level.WARNING, object.toString());
} }
public static void info(Object object) { public static void info(Object object) {
log(Level.INFO, object); log(Level.INFO, object.toString());
} }
public static void config(Object object) { public static void config(Object object) {
log(Level.CONFIG, object); log(Level.CONFIG, object.toString());
} }
public static void fine(Object object) { public static void fine(Object object) {
log(Level.FINE, object); log(Level.FINE, object.toString());
} }
public static void finer(Object object) { public static void finer(Object object) {
log(Level.FINER, object); log(Level.FINER, object.toString());
} }
public static void finest(Object object) { public static void finest(Object object) {
log(Level.FINEST, object); log(Level.FINEST, object.toString());
} }
} }

View file

@ -1,19 +1,19 @@
package com.pahimar.ee3.emc; package com.pahimar.ee3.emc;
import net.minecraft.block.Block; import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import com.pahimar.ee3.core.util.EnergyStack; import com.pahimar.ee3.core.util.EnergyStack;
import com.pahimar.ee3.item.CustomWrappedStack; import com.pahimar.ee3.item.CustomWrappedStack;
public class EmcDefaultValues { public class EmcDefaultValues {
private static EmcDefaultValues defaultValues = null; private static EmcDefaultValues defaultValues = null;
private Map<CustomWrappedStack, EmcValue> defaultValueMap;
private ImmutableMap<CustomWrappedStack, EmcValue> defaultValueMap;
private EmcDefaultValues() { private EmcDefaultValues() {
defaultValueMap = new HashMap<CustomWrappedStack, EmcValue>();
} }
public static EmcDefaultValues getInstance() { public static EmcDefaultValues getInstance() {
@ -28,21 +28,13 @@ public class EmcDefaultValues {
private void init() { private void init() {
ImmutableMap.Builder<CustomWrappedStack, EmcValue> valueMapBuilder = ImmutableMap.builder(); defaultValueMap.put(
new CustomWrappedStack(new EnergyStack(EnergyStack.VANILLA_SMELTING_ENERGY_NAME, 1)),
valueMapBuilder.put(new CustomWrappedStack(new EnergyStack(EnergyStack.VANILLA_SMELTING_ENERGY_NAME)), new EmcValue(1, EmcComponent.KINETIC_UNIT_COMPONENT)
new EmcValue((32 * 0.2F / 1600), EmcComponent.KINETIC_UNIT_COMPONENT)); );
valueMapBuilder.put(new CustomWrappedStack(Block.cobblestone), new EmcValue(1, EmcComponent.CORPOREAL_UNIT_COMPONENT));
valueMapBuilder.put(new CustomWrappedStack(Block.wood), new EmcValue(32, EmcComponent.CORPOREAL_UNIT_COMPONENT));
valueMapBuilder.put(new CustomWrappedStack(Block.oreIron), new EmcValue(256, EmcComponent.CORPOREAL_UNIT_COMPONENT));
valueMapBuilder.put(new CustomWrappedStack(Block.oreGold), new EmcValue(2048, EmcComponent.CORPOREAL_UNIT_COMPONENT));
valueMapBuilder.put(new CustomWrappedStack(Block.oreDiamond), new EmcValue(8192, EmcComponent.CORPOREAL_UNIT_COMPONENT));
defaultValueMap = valueMapBuilder.build();
} }
public ImmutableMap<CustomWrappedStack, EmcValue> getDefaultValueMap() { public Map<CustomWrappedStack, EmcValue> getDefaultValueMap() {
return defaultValueMap; return defaultValueMap;
} }

View file

@ -1,20 +1,33 @@
package com.pahimar.ee3.emc; package com.pahimar.ee3.emc;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import com.pahimar.ee3.core.util.EnergyStack;
import com.pahimar.ee3.item.CustomWrappedStack; import com.pahimar.ee3.item.CustomWrappedStack;
public class EmcRegistry { public class EmcRegistry {
private static EmcRegistry emcRegistry = null; private static EmcRegistry emcRegistry = null;
private ImmutableMap<CustomWrappedStack, EmcValue> stackMappings; private Map<CustomWrappedStack, EmcValue> stackMappings;
private ImmutableSortedMap<EmcValue, List<CustomWrappedStack>> valueMappings; private TreeMap<EmcValue, List<CustomWrappedStack>> valueMappings;
private ImmutableMap<CustomWrappedStack, EmcValue> immutableStackMappings;
private ImmutableSortedMap<EmcValue, List<CustomWrappedStack>> immutableValueMappings;
private EmcRegistry() { private EmcRegistry() {
stackMappings = new HashMap<CustomWrappedStack, EmcValue>();
valueMappings = new TreeMap<EmcValue, List<CustomWrappedStack>>();
} }
public static EmcRegistry getInstance() { public static EmcRegistry getInstance() {
@ -30,9 +43,23 @@ public class EmcRegistry {
private void init() { private void init() {
// Grab the default value map // Grab the default value map
ImmutableMap.Builder<CustomWrappedStack, EmcValue> stackMappingsBuilder = ImmutableMap.builder(); Map<CustomWrappedStack, EmcValue> defaultValueMap = EmcDefaultValues.getInstance().getDefaultValueMap();
stackMappingsBuilder.putAll(EmcDefaultValues.getInstance().getDefaultValueMap());
stackMappings = stackMappingsBuilder.build(); // 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));
} }
public boolean hasEmcValue(CustomWrappedStack wrappedStack) { public boolean hasEmcValue(CustomWrappedStack wrappedStack) {
@ -63,9 +90,5 @@ public class EmcRegistry {
public void addEmcValueMapping(CustomWrappedStack wrappedStack, EmcValue emcValue) { public void addEmcValueMapping(CustomWrappedStack wrappedStack, EmcValue emcValue) {
}
private void printDebugDump() {
} }
} }

View file

@ -2,4 +2,6 @@ package com.pahimar.ee3.emc;
public enum EmcType { public enum EmcType {
OMNI, CORPOREAL, KINETIC, TEMPORAL, ESSENTIA, AMORPHOUS, VOID; OMNI, CORPOREAL, KINETIC, TEMPORAL, ESSENTIA, AMORPHOUS, VOID;
public static final EmcType[] TYPES = EmcType.values();
} }

View file

@ -21,6 +21,7 @@ public class EmcValue implements Comparable<EmcValue> {
public final float value; public final float value;
public final float recoveryPercent; public final float recoveryPercent;
private final List<EmcComponent> components; private final List<EmcComponent> components;
public final int sumComponentRatios;
public EmcValue() { public EmcValue() {
@ -52,6 +53,13 @@ public class EmcValue implements Comparable<EmcValue> {
this.value = value; this.value = value;
this.recoveryPercent = recoveryPercent; this.recoveryPercent = recoveryPercent;
this.components = collateComponents(components); this.components = collateComponents(components);
int count = 0;
for (EmcComponent component : components) {
count += component.getRatioWeight();
}
this.sumComponentRatios = count;
} }
public List<EmcComponent> getComponents() { public List<EmcComponent> getComponents() {
@ -61,9 +69,25 @@ public class EmcValue implements Comparable<EmcValue> {
public EmcComponent getComponentByType(EmcType type) { public EmcComponent getComponentByType(EmcType type) {
EmcComponent[] componentArray = (EmcComponent[]) components.toArray(); for (EmcComponent component : components) {
Arrays.sort(componentArray); if (component.getType().equals(type)) {
return componentArray[type.ordinal()]; return component;
}
}
return null;
}
public float getComponentValueByType(EmcType type) {
EmcComponent emcComponent = getComponentByType(type);
if (emcComponent != null) {
if (sumComponentRatios > 0) {
return value * (emcComponent.getRatioWeight() / (float)this.sumComponentRatios);
}
}
return 0f;
} }
@Override @Override
@ -155,12 +179,14 @@ public class EmcValue implements Comparable<EmcValue> {
List<EmcComponent> collatedComponents = new ArrayList<EmcComponent>(); List<EmcComponent> collatedComponents = new ArrayList<EmcComponent>();
for (int i = 0; i < 7; i++) { for (int i = 0; i < EmcType.TYPES.length; i++) {
if (componentCount[i] != null) { if (componentCount[i] != null) {
collatedComponents.add(new EmcComponent(EmcType.values()[i], componentCount[i].intValue())); collatedComponents.add(new EmcComponent(EmcType.TYPES[i], componentCount[i].intValue()));
} }
} }
Collections.sort(collatedComponents);
return collatedComponents; return collatedComponents;
} }
} }