-
Notifications
You must be signed in to change notification settings - Fork 756
/
RecipeHandlerMelting.java
140 lines (118 loc) · 3.86 KB
/
RecipeHandlerMelting.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package tconstruct.plugins.nei;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import mantle.utils.ItemMetaWrapper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import net.minecraft.util.StatCollector;
import tconstruct.library.crafting.Smeltery;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
public class RecipeHandlerMelting extends RecipeHandlerBase
{
public static final Rectangle MOLTEN_TANK = new Rectangle(115, 20, 18, 18);
public class CachedMeltingRecipe extends CachedBaseRecipe
{
private PositionedStack input;
private int temperature;
private FluidTankElement output;
public CachedMeltingRecipe(ItemStack input)
{
this.input = new PositionedStack(input, 28, 21);
this.temperature = Smeltery.getLiquifyTemperature(input);
this.output = new FluidTankElement(MOLTEN_TANK, 1, Smeltery.getSmelteryResult(input));
this.output.capacity = this.output.fluid != null ? this.output.fluid.amount : 1000;
}
@Override
public PositionedStack getIngredient ()
{
return this.input;
}
@Override
public PositionedStack getResult ()
{
return null;
}
@Override
public List<FluidTankElement> getFluidTanks ()
{
List<FluidTankElement> tanks = new ArrayList<FluidTankElement>();
tanks.add(this.output);
return tanks;
}
}
@Override
public String getRecipeName ()
{
return StatCollector.translateToLocal("tconstruct.nei.melting");
}
@Override
public String getRecipeID ()
{
return "tconstruct.smeltery.melting";
}
@Override
public String getGuiTexture ()
{
return "tinker:textures/gui/nei/smeltery.png";
}
@Override
public void loadTransferRects ()
{
this.transferRects.add(new RecipeTransferRect(new Rectangle(72, 20, 16, 34), this.getRecipeID(), new Object[0]));
}
@Override
public void drawBackground (int recipe)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(this.getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 160, 55);
}
@Override
public void drawExtras (int recipe)
{
int temperature = ((CachedMeltingRecipe) this.arecipes.get(recipe)).temperature;
GuiDraw.drawStringC(temperature + " C", 81, 9, 0x808080, false);
}
@Override
public void loadCraftingRecipes (String outputId, Object... results)
{
if (outputId.equals(getRecipeID()))
{
for (ItemMetaWrapper key : Smeltery.getSmeltingList().keySet())
{
this.arecipes.add(new CachedMeltingRecipe(new ItemStack(key.item, 1, key.meta)));
}
}
else
{
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes (FluidStack result)
{
for (Entry<ItemMetaWrapper, FluidStack> pair : Smeltery.getSmeltingList().entrySet())
{
if (areFluidsEqual(pair.getValue(), result))
{
this.arecipes.add(new CachedMeltingRecipe(new ItemStack(pair.getKey().item, 1, pair.getKey().meta)));
}
}
}
@Override
public void loadUsageRecipes (ItemStack ingred)
{
for (ItemMetaWrapper key : Smeltery.getSmeltingList().keySet())
{
if (NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(key.item, 1, key.meta), ingred))
{
this.arecipes.add(new CachedMeltingRecipe(new ItemStack(key.item, 1, key.meta)));
}
}
}
}