More EMC work - now there's a dumb bug to work out!

This commit is contained in:
pahimar 2013-10-27 17:42:29 -04:00
parent 6f8faf09db
commit f2284af0d2
10 changed files with 109 additions and 71 deletions

View file

@ -1,5 +1,5 @@
#Mon, 23 Sep 2013 15:00:03 -0400
#Sun, 27 Oct 2013 15:30:35 -0400
minecraft_version=1.6.4
forge_version=9.11.1.935
mod_version=pre2a
build_number=26
build_number=28

View file

@ -2,10 +2,13 @@ package com.pahimar.ee3;
import java.io.File;
import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.common.MinecraftForge;
@ -26,8 +29,9 @@ import com.pahimar.ee3.core.helper.LogHelper;
import com.pahimar.ee3.core.helper.VersionHelper;
import com.pahimar.ee3.core.proxy.CommonProxy;
import com.pahimar.ee3.creativetab.CreativeTabEE3;
import com.pahimar.ee3.emc.EmcRegistry;
import com.pahimar.ee3.item.CustomWrappedStack;
import com.pahimar.ee3.item.ModItems;
import com.pahimar.ee3.item.crafting.RecipeRegistry;
import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes;
import com.pahimar.ee3.lib.InterModComms;
import com.pahimar.ee3.lib.Reference;
@ -164,6 +168,7 @@ public class EquivalentExchange3 {
// recipe registry works
FMLInterModComms.sendMessage(Reference.MOD_ID, InterModComms.ADD_RECIPE, NBTHelper.encodeRecipeAsNBT(Item.bucketWater, Arrays.asList(Item.bucketEmpty, Block.waterStill)));
FMLInterModComms.sendMessage(Reference.MOD_ID, InterModComms.ADD_RECIPE, NBTHelper.encodeRecipeAsNBT(Item.bucketLava, Arrays.asList(Item.bucketEmpty, Block.lavaStill)));
FMLInterModComms.sendMessage(Reference.MOD_ID, InterModComms.ADD_RECIPE, NBTHelper.encodeRecipeAsNBT(new ItemStack(Item.glassBottle.itemID, 3, 0), Arrays.asList(Block.glass, Block.glass, Block.glass)));
}
@EventHandler
@ -172,8 +177,11 @@ public class EquivalentExchange3 {
// Initialize the Addon Handler
AddonHandler.init();
EmcRegistry.printStackValueMappings();
//EmcRegistry.printUnmappedStacks();
Set<CustomWrappedStack> recipeOutputs = new TreeSet<CustomWrappedStack>(RecipeRegistry.getRecipeMappings().keySet());
for (CustomWrappedStack recipeOutput : recipeOutputs) {
LogHelper.debug(String.format("Recipe Output: %s, Recipe Inputs: %s", recipeOutput, RecipeRegistry.getRecipeMappings().get(recipeOutput)));
}
}
@EventHandler

View file

@ -43,12 +43,12 @@ public class ItemTooltipEventHandler {
event.toolTip.add("");
if (emcValue != null) {
event.toolTip.add("EMC: " + stack.getStackSize() * emcValue.getValue());
event.toolTip.add("EMC: " + String.format("%.3f", stack.getStackSize() * emcValue.getValue()));
if (debug) {
for (EmcType emcType : EmcType.TYPES) {
if (emcValue.components[emcType.ordinal()] > 0) {
event.toolTip.add(" * " + emcType + ": " + stack.getStackSize() * emcValue.components[emcType.ordinal()]);
event.toolTip.add(" * " + emcType + ": " + String.format("%.3f", stack.getStackSize() * emcValue.components[emcType.ordinal()]));
}
}
}

View file

@ -33,20 +33,21 @@ public class EmcDefaultValues {
private void init() {
valueMap.put(new CustomWrappedStack(Block.stone), new EmcValue(1, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(new OreStack(new ItemStack(Block.stone))), new EmcValue(1, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Block.waterStill), new EmcValue(0.1f, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 9), new EmcComponent(EmcType.AMORPHOUS, 1))));
valueMap.put(new CustomWrappedStack(Block.grass), new EmcValue(1, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 9), new EmcComponent(EmcType.ESSENTIA, 1))));
valueMap.put(new CustomWrappedStack(Block.dirt), new EmcValue(1, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Block.cobblestone), new EmcValue(1, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Block.sand), new EmcValue(1, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 9), new EmcComponent(EmcType.AMORPHOUS, 1))));
valueMap.put(new CustomWrappedStack(new ItemStack(Block.sand.blockID, 1, OreDictionary.WILDCARD_VALUE)), new EmcValue(1, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 9), new EmcComponent(EmcType.AMORPHOUS, 1))));
valueMap.put(new CustomWrappedStack(Block.leaves), new EmcValue(1, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 9), new EmcComponent(EmcType.ESSENTIA, 1))));
valueMap.put(new CustomWrappedStack(Block.glass), new EmcValue(1, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(new ItemStack(Block.glass.blockID, 1, OreDictionary.WILDCARD_VALUE)), new EmcValue(1, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Block.tallGrass), new EmcValue(1, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 9), new EmcComponent(EmcType.ESSENTIA, 1))));
for (int meta = 0; meta < 16; meta++) {
valueMap.put(new CustomWrappedStack(new ItemStack(Block.tallGrass.blockID, 1, meta)), new EmcValue(1, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 9), new EmcComponent(EmcType.ESSENTIA, 1))));
}
valueMap.put(new CustomWrappedStack(new ItemStack(Block.tallGrass.blockID, 1, OreDictionary.WILDCARD_VALUE)), new EmcValue(1, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 9), new EmcComponent(EmcType.ESSENTIA, 1))));
valueMap.put(new CustomWrappedStack(Block.deadBush), new EmcValue(1, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Block.ice), new EmcValue(1, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(new ItemStack(Block.sandStone.blockID, 1, OreDictionary.WILDCARD_VALUE)), new EmcValue(4, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(new ItemStack(Block.anvil.blockID, 1, OreDictionary.WILDCARD_VALUE)), new EmcValue(2, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(new OreStack(new ItemStack(Block.wood))), new EmcValue(32, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 4), new EmcComponent(EmcType.ESSENTIA, 1))));
valueMap.put(new CustomWrappedStack(new OreStack(new ItemStack(Block.planks))), new EmcValue(8, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(new OreStack(new ItemStack(Item.stick))), new EmcValue(4, EmcType.CORPOREAL));
@ -57,6 +58,29 @@ public class EmcDefaultValues {
valueMap.put(new CustomWrappedStack(Block.oreDiamond), new EmcValue(8192, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Item.diamond), new EmcValue(8192, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Block.oreCoal), new EmcValue(32, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 4), new EmcComponent(EmcType.KINETIC, 1))));
valueMap.put(new CustomWrappedStack(new ItemStack(Item.dyePowder, 1, 4)), new EmcValue(864, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(new OreStack(new ItemStack(Item.dyePowder, 1, 0))), new EmcValue(8, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Item.silk), new EmcValue(12, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(new ItemStack(Block.cloth.blockID, 1, OreDictionary.WILDCARD_VALUE)), new EmcValue(48, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Block.gravel), new EmcValue(4, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 9), new EmcComponent(EmcType.AMORPHOUS, 1))));
valueMap.put(new CustomWrappedStack(Item.reed), new EmcValue(32, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Item.paper), new EmcValue(32, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Item.redstone), new EmcValue(32, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Block.oreRedstone), new EmcValue(32, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Block.oreRedstoneGlowing), new EmcValue(32, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Item.flint), new EmcValue(4, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Item.clay), new EmcValue(64, EmcType.CORPOREAL));
// Potion reagents
//valueMap.put(new CustomWrappedStack(Item.glassBottle), new EmcValue(1, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Item.spiderEye), new EmcValue(128, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Item.appleRed), new EmcValue(128, EmcType.CORPOREAL));
valueMap.put(new CustomWrappedStack(Item.fermentedSpiderEye), new EmcValue(192, EmcType.CORPOREAL));
// Single slabs
valueMap.put(new CustomWrappedStack(new ItemStack(Block.stoneSingleSlab, 1, 0)), new EmcValue(0.5f, EmcType.CORPOREAL));
}

View file

@ -55,10 +55,10 @@ public class EmcRegistry {
passNumber++;
computedStackValues = computeStackMappings();
LogHelper.debug(String.format("pass number=%s, count=%s", passNumber, computedStackValues.size()));
for (CustomWrappedStack key : computedStackValues.keySet()) {
LogHelper.debug(String.format("Pass = %s, Stack = %s, Computed Value = %s", passNumber, key, computedStackValues.get(key)));
}
// LogHelper.debug(String.format("pass number=%s, count=%s", passNumber, computedStackValues.size()));
// for (CustomWrappedStack key : computedStackValues.keySet()) {
// LogHelper.debug(String.format("Pass = %s, Stack = %s, Computed Value = %s", passNumber, key, computedStackValues.get(key)));
// }
stackMappingsBuilder = ImmutableSortedMap.naturalOrder();
stackMappingsBuilder.putAll(stackMappings);
@ -135,6 +135,7 @@ public class EmcRegistry {
ItemStack wrappedItemStack = (ItemStack) stack.getWrappedStack();
// If its an OreDictionary item, scan its siblings for values
if (OreDictionary.getOreID(wrappedItemStack) != -1) {
OreStack oreStack = new OreStack(wrappedItemStack);
@ -150,6 +151,20 @@ public class EmcRegistry {
}
}
}
// Else, scan for if there is a wildcard value for it
else {
for (CustomWrappedStack valuedStack : emcRegistry.stackMappings.keySet()) {
if (valuedStack.getWrappedStack() instanceof ItemStack) {
ItemStack valuedItemStack = (ItemStack) valuedStack.getWrappedStack();
if (valuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE && valuedItemStack.itemID == wrappedItemStack.itemID) {
return true;
}
}
}
}
}
}
}
@ -178,6 +193,7 @@ public class EmcRegistry {
if (stack.getWrappedStack() instanceof ItemStack) {
ItemStack wrappedItemStack = (ItemStack) stack.getWrappedStack();
EmcValue lowestValue = null;
if (OreDictionary.getOreID(wrappedItemStack) != -1) {
@ -187,7 +203,6 @@ public class EmcRegistry {
return emcRegistry.stackMappings.get(new CustomWrappedStack(oreStack));
}
else {
EmcValue lowestValue = null;
for (ItemStack itemStack : OreDictionary.getOres(OreDictionary.getOreID(wrappedItemStack))) {
@ -208,6 +223,27 @@ public class EmcRegistry {
return lowestValue;
}
}
else {
for (CustomWrappedStack valuedStack : emcRegistry.stackMappings.keySet()) {
EmcValue stackValue = emcRegistry.stackMappings.get(valuedStack);
if (valuedStack.getWrappedStack() instanceof ItemStack) {
ItemStack valuedItemStack = (ItemStack) valuedStack.getWrappedStack();
if (valuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE && valuedItemStack.itemID == wrappedItemStack.itemID) {
if (stackValue.compareTo(lowestValue) < 0) {
lowestValue = stackValue;
}
}
}
}
return lowestValue;
}
}
}
}
@ -290,4 +326,24 @@ public class EmcRegistry {
}
}
public static List<CustomWrappedStack> printDebugStats() {
lazyInit();
List<CustomWrappedStack> couldBeMapped = new ArrayList<CustomWrappedStack>();
for (CustomWrappedStack stack : RecipeRegistry.getRecipeMappings().keySet()) {
CustomWrappedStack unitStack = new CustomWrappedStack(stack.getWrappedStack());
if (!couldBeMapped.contains(unitStack)) {
if (!EmcRegistry.hasEmcValue(unitStack)) {
couldBeMapped.add(unitStack);
}
}
}
return couldBeMapped;
}
}

View file

@ -45,10 +45,7 @@ public class RecipeRegistry {
ImmutableMultimap.Builder<CustomWrappedStack, List<CustomWrappedStack>> immutableRecipeMap = ImmutableMultimap.builder();
// Add potion recipes
//immutableRecipeMap.putAll(RecipesPotions.getPotionRecipes());
// Add smelting recipes in the vanilla smelting manager
//immutableRecipeMap.putAll(RecipesSmelting.getSmeltingRecipes());
immutableRecipeMap.putAll(RecipesPotions.getPotionRecipes());
// Add recipes in the vanilla crafting manager
immutableRecipeMap.putAll(RecipesVanilla.getVanillaRecipes());

View file

@ -28,5 +28,4 @@ public class RecipesIMC {
imcRecipes.put(recipeOutput, RecipeHelper.collateInputStacks(recipeInputs));
}
}

View file

@ -29,6 +29,7 @@ public class RecipesPotions {
private static CustomWrappedStack reagentFermentedSpiderEye = new CustomWrappedStack(new ItemStack(Item.fermentedSpiderEye));
private static CustomWrappedStack reagentBlazePowder = new CustomWrappedStack(new ItemStack(Item.blazePowder));
private static CustomWrappedStack bottleEmpty = new CustomWrappedStack(Item.glassBottle);
private static CustomWrappedStack bottleWater = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 0));
private static CustomWrappedStack potionAwkward = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16));
@ -114,7 +115,7 @@ public class RecipesPotions {
potionRecipes = HashMultimap.create();
potionRecipes.put(bottleWater, Arrays.asList(reagentWater));
potionRecipes.put(bottleWater, Arrays.asList(bottleEmpty, reagentWater));
potionRecipes.put(potionAwkward, Arrays.asList(bottleWater, reagentNetherWart));

View file

@ -1,48 +0,0 @@
package com.pahimar.ee3.item.crafting;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.pahimar.ee3.item.CustomWrappedStack;
import com.pahimar.ee3.item.EnergyStack;
public class RecipesSmelting {
private static Multimap<CustomWrappedStack, List<CustomWrappedStack>> smeltingRecipes = null;
private static final CustomWrappedStack smeltingEnergy = new CustomWrappedStack(new EnergyStack(EnergyStack.VANILLA_SMELTING_ENERGY_NAME, EnergyStack.VANILLA_SMELTING_ENERGY_THRESHOLD));
public static Multimap<CustomWrappedStack, List<CustomWrappedStack>> getSmeltingRecipes() {
if (smeltingRecipes == null) {
init();
}
return smeltingRecipes;
}
private static void init() {
smeltingRecipes = HashMultimap.create();
@SuppressWarnings("unchecked")
Map<Integer, ItemStack> smeltingList = FurnaceRecipes.smelting().getSmeltingList();
Map<List<Integer>, ItemStack> metaSmeltingList = FurnaceRecipes.smelting().getMetaSmeltingList();
for (Integer i : smeltingList.keySet()) {
smeltingRecipes.put(new CustomWrappedStack(smeltingList.get(i)), Arrays.asList(smeltingEnergy, new CustomWrappedStack(new ItemStack(i, 1, 0))));
}
for (List<Integer> idMetaPair : metaSmeltingList.keySet()) {
if (idMetaPair.size() == 2) {
smeltingRecipes.put(new CustomWrappedStack(metaSmeltingList.get(idMetaPair)), Arrays.asList(smeltingEnergy, new CustomWrappedStack(new ItemStack(idMetaPair.get(0), 1, idMetaPair.get(1)))));
}
}
}
}

View file

@ -190,6 +190,7 @@ public class NBTHelper {
if (wrappedStack.getWrappedStack() instanceof ItemStack) {
ItemStack itemStack = (ItemStack) wrappedStack.getWrappedStack();
itemStack.stackSize = wrappedStack.getStackSize();
encodedStack.setString(Strings.NBT_ENCODED_ATTR_TYPE, Strings.NBT_ENCODED_ATTR_TYPE_ITEM);
itemStack.writeToNBT(encodedStack);
}