Skip to content

Commit

Permalink
1.1.1 !!!
Browse files Browse the repository at this point in the history
ingame wiki fix
  • Loading branch information
Dolu1990 committed Mar 21, 2014
1 parent 1276ec6 commit 1e0314d
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 95 deletions.
4 changes: 3 additions & 1 deletion mods/eln/Eln.java
Original file line number Diff line number Diff line change
Expand Up @@ -2159,10 +2159,11 @@ void registerIntelligentTransformer(int id) {
}

}

public ArrayList<ItemStack> furnaceList = new ArrayList<ItemStack>();
void registerElectricalFurnace(int id) {
int subId, completId;
String name;
furnaceList.add(new ItemStack(Block.furnaceIdle));
{
subId = 0;
name = "Electrical furnace";
Expand All @@ -2188,6 +2189,7 @@ void registerElectricalFurnace(int id) {
);

transparentNodeItem.addDescriptor(subId + (id << 6), desc);
furnaceList.add(desc.newItemStack());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void process(double time) {
}
}
}
System.out.println(output);
//System.out.println(output);
element.outputGateProcess.setOutputNormalized(output);
}

Expand Down
4 changes: 2 additions & 2 deletions mods/eln/electricalfurnace/ElectricalFurnaceProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ElectricalFurnaceProcess(ElectricalFurnaceElement furnace) {
this.inventory = (TransparentNodeElementInventory) furnace.getInventory();
}


public static double energyNeededPerSmelt = 1000;



Expand Down Expand Up @@ -118,7 +118,7 @@ public void smeltInit()
else
{
smeltInProcess = true;
energyNeeded = 1000;
energyNeeded = energyNeededPerSmelt;
energyCounter = 0.0;
}
}
Expand Down
35 changes: 35 additions & 0 deletions mods/eln/misc/RecipesList.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;

import mods.eln.Eln;
import mods.eln.electricalfurnace.ElectricalFurnaceProcess;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.oredict.OreDictionary;

public class RecipesList {
Expand Down Expand Up @@ -63,6 +68,23 @@ public static ArrayList<Recipe> getGlobalRecipeWithOutput(ItemStack output)
for(RecipesList recipesList : listOfList){
list.addAll(recipesList.getRecipeFromOutput(output));
}
FurnaceRecipes furnaceRecipes = FurnaceRecipes.smelting();
for(Entry<List<Integer>, ItemStack> entry : furnaceRecipes.getMetaSmeltingList().entrySet()){
Recipe recipe;
if(Utils.areSame(output,entry.getValue())){
list.add(recipe = new Recipe(new ItemStack(entry.getKey().get(0),1,entry.getKey().get(1)), output, ElectricalFurnaceProcess.energyNeededPerSmelt));
recipe.setMachineList(Eln.instance.furnaceList);
}
}
for(Object entry : furnaceRecipes.getSmeltingList().entrySet()){
Recipe recipe = null;
Entry<Integer, Object> e = (Entry<Integer, Object>)entry;
if(((ItemStack)e.getValue()).itemID == output.itemID){
list.add(recipe = new Recipe(new ItemStack(e.getKey(),1,0), output, ElectricalFurnaceProcess.energyNeededPerSmelt));
recipe.setMachineList(Eln.instance.furnaceList);
}
}

return list;
}
public static ArrayList<Recipe> getGlobalRecipeWithInput(ItemStack input)
Expand All @@ -75,6 +97,19 @@ public static ArrayList<Recipe> getGlobalRecipeWithInput(ItemStack input)
if(r != null)
list.add(r);
}

FurnaceRecipes furnaceRecipes = FurnaceRecipes.smelting();
ItemStack smeltResult = furnaceRecipes.getSmeltingResult(input);
Recipe smeltRecipe;
if(smeltResult != null) {
ItemStack input1 = input.copy();
input1.stackSize = 1;
list.add(smeltRecipe = new Recipe(input1, smeltResult, ElectricalFurnaceProcess.energyNeededPerSmelt));
smeltRecipe.machineList.addAll(Eln.instance.furnaceList);
}

return list;
}
}
/* FurnaceRecipes.smelting().addSmelting(in.itemID, in.getItemDamage(),
findItemStack("Copper ingot"), 0);*/
137 changes: 137 additions & 0 deletions mods/eln/misc/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
Expand Down Expand Up @@ -37,6 +39,7 @@
import mods.eln.node.NodeElectricalGateInput;
import mods.eln.node.SixNodeEntity;
import mods.eln.sim.PhysicalConstant;
import mods.eln.wiki.GuiItemStack;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -70,6 +73,9 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.packet.Packet250CustomPayload;
Expand All @@ -86,6 +92,8 @@
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;


public class Utils {
Expand Down Expand Up @@ -1349,6 +1357,135 @@ public static double getLength( double x, double y,
dx = tx-x;dy = ty-y;dz = tz-z;
double norm = (Math.sqrt(dx*dx+dy*dy+dz*dz));
return norm;
}
public static <T> int readPrivateInt(Object o,String feildName){
try {
Field f = o.getClass().getDeclaredField(feildName);
f.setAccessible(true);
return f.getInt(o);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
public static ItemStack[][] getItemStackGrid(IRecipe r) {
ItemStack[][] stacks = new ItemStack[3][3];



if(r instanceof ShapedRecipes){
ShapedRecipes s = (ShapedRecipes)r;
for(int idx2 = 0;idx2 < 3;idx2++){
for(int idx = 0;idx < 3;idx++){
ItemStack rStack = null;
if(idx < s.recipeWidth && idx2 < s.recipeHeight){
rStack = s.recipeItems[idx + idx2*s.recipeWidth];
}
stacks[idx2][idx] = rStack;
}
}
return stacks;
}
if(r instanceof ShapedOreRecipe){
ShapedOreRecipe s = (ShapedOreRecipe)r;
int width = readPrivateInt(s, "width");
int height = readPrivateInt(s, "height");
Object[] inputs = s.getInput();

for(int idx2 = 0;idx2 < height;idx2++){
for(int idx = 0;idx < width;idx++){
Object o = inputs[idx+idx2*width];
ItemStack stack = null;
if(o instanceof List){
stack = (ItemStack) ((List)o).get(0);
}

if(o instanceof ItemStack){
stack = (ItemStack) o;
}
stacks[idx2][idx] = stack;
}
}

return stacks;
}
if(r instanceof ShapelessRecipes){
ShapelessRecipes s = (ShapelessRecipes)r;
int idx = 0;
for(Object o : s.recipeItems){
ItemStack stack = (ItemStack)o;
stacks[idx/3][idx%3] = stack;
idx++;
}
return stacks;
}
if(r instanceof ShapelessOreRecipe){
ShapelessOreRecipe s = (ShapelessOreRecipe)r;
int idx = 0;
for(Object o : s.getInput()){
ItemStack stack = null;
if(o instanceof List){
stack = (ItemStack) ((List)o).get(0);
}

if(o instanceof ItemStack){
stack = (ItemStack) o;
}
stacks[idx/3][idx%3] = stack;
idx++;
}
return stacks;
}
return null;
}

public static ArrayList<ItemStack> getRecipeInputs(IRecipe r) {
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
if(r instanceof ShapedRecipes){
for(ItemStack stack : ((ShapedRecipes)r).recipeItems){
stacks.add(stack);
}
}
if(r instanceof ShapelessRecipes){
for(Object stack : ((ShapelessRecipes)r).recipeItems){
stacks.add((ItemStack)stack);
}
}
if(r instanceof ShapedOreRecipe){
ShapedOreRecipe rr = (ShapedOreRecipe)r;
for(Object o : ((ShapedOreRecipe) r).getInput()){
if(o instanceof List){
stacks.addAll(((List)o));
}

if(o instanceof ItemStack){
stacks.add((ItemStack)o);
}
}
}
if(r instanceof ShapelessOreRecipe){
ShapelessOreRecipe rr = (ShapelessOreRecipe)r;
for(Object o : ((ShapelessOreRecipe) r).getInput()){
if(o instanceof List){
stacks.addAll(((List)o));
}

if(o instanceof ItemStack){
stacks.add((ItemStack)o);
}
}
}
return stacks;
}

}
6 changes: 4 additions & 2 deletions mods/eln/wiki/GuiItemStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ public void idraw(int x, int y, float f) {

if(stack != null){
// RenderHelper.enableStandardItemLighting();
RenderHelper.enableStandardItemLighting();
RenderHelper.enableGUIStandardItemLighting();

Utils.drawItemStack(stack, posX, posY, null,true);
// RenderHelper.disableStandardItemLighting();

RenderHelper.disableStandardItemLighting();
// GL11.glEnable(GL11.GL_LIGHTING);
// GL11.glEnable(GL11.GL_DEPTH_TEST);
// RenderHelper.enableStandardItemLighting();
Expand Down
Loading

0 comments on commit 1e0314d

Please sign in to comment.