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
141
142
|
package pers.gwyog.gtneioreplugin.plugin;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect;
import gregtech.api.GregTech_API;
import gregtech.api.util.GT_LanguageManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import pers.gwyog.gtneioreplugin.plugin.PluginVeinStat.CachedVeinStatRecipe;
import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper;
import pers.gwyog.gtneioreplugin.util.GTSmallOreHelper;
import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper.OreLayerWrapper;
public class PluginAsteroidStat extends PluginBase {
public class CachedAsteroidStatRecipe extends CachedRecipe {
public String veinName;
public PositionedStack positionedStackPrimary;
public PositionedStack positionedStackSecondary;
public PositionedStack positionedStackBetween;
public PositionedStack positionedStackSporadic;
public CachedAsteroidStatRecipe(String veinName, ItemStack stackListPrimary, ItemStack stackListSecondary,
ItemStack stackListBetween, ItemStack stackListSporadic) {
this.veinName = veinName;
positionedStackPrimary = new PositionedStack(stackListPrimary, 2, 0);
positionedStackSecondary = new PositionedStack(stackListSecondary, 22, 0);
positionedStackBetween = new PositionedStack(stackListBetween, 42, 0);
positionedStackSporadic = new PositionedStack(stackListSporadic, 62, 0);
}
@Override
public List<PositionedStack> getIngredients() {
List<PositionedStack> ingredientsList = new ArrayList<PositionedStack>();
ingredientsList.add(positionedStackPrimary);
ingredientsList.add(positionedStackSecondary);
ingredientsList.add(positionedStackBetween);
ingredientsList.add(positionedStackSporadic);
return ingredientsList;
}
@Override
public PositionedStack getResult() {
return null;
}
}
@Override
public void drawExtras(int recipe) {
CachedAsteroidStatRecipe crecipe = (CachedAsteroidStatRecipe) this.arecipes.get(recipe);
OreLayerWrapper oreLayer = GTOreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedAsteroidName(oreLayer.veinName), 2, 18, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidPrimary") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.primaryMeta)), 2, 31, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidSecondary") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.secondaryMeta)), 2, 44, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidBetween") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.betweenMeta)), 2, 57, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidSporadic") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.sporadicMeta)), 2, 70, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genEndAsteroid, oreLayer.genGCAsteroid), 2, 83, 0x404040, false);
GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false);
}
public String getWorldNameTranslated(boolean genEndAsteroid, boolean genGCAsteroid) {
String worldNameTranslatedAsteroid = "";
if (genEndAsteroid) {
if (!worldNameTranslatedAsteroid.isEmpty())
worldNameTranslatedAsteroid += ", ";
worldNameTranslatedAsteroid += I18n.format("gtnop.world.end.name");
}
if (genGCAsteroid) {
if (!worldNameTranslatedAsteroid.isEmpty())
worldNameTranslatedAsteroid += ", ";
worldNameTranslatedAsteroid += I18n.format("gtnop.world.asteroid.name");
}
return worldNameTranslatedAsteroid;
}
public String getLocalizedAsteroidName(String unlocalizedName) {
if (unlocalizedName.startsWith("ore.mix.custom."))
return I18n.format("gtnop.ore.custom.name") + I18n.format("gtnop.ore.asteroid.name") + unlocalizedName.substring(15);
else
return I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.asteroid.name");
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(getOutputId())) {
OreLayerWrapper oreLayerWrapper;
for (String veinName: GTOreLayerHelper.mapOreLayerWrapper.keySet()) {
oreLayerWrapper = GTOreLayerHelper.mapOreLayerWrapper.get(veinName);
if (oreLayerWrapper.genEndAsteroid || oreLayerWrapper.genGCAsteroid) {
ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.primaryMeta+2000);
ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.secondaryMeta+2000);
ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.betweenMeta+2000);
ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.sporadicMeta+2000);
this.arecipes.add(new CachedAsteroidStatRecipe(veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic));
}
}
}
else
super.loadCraftingRecipes(outputId, results);
}
@Override
public void loadCraftingRecipes(ItemStack stack) {
if (stack.getUnlocalizedName().startsWith("gt.blockores")) {
if (stack.getItemDamage()>16000) {
super.loadCraftingRecipes(stack);
return;
}
short baseMeta = (short)(stack.getItemDamage() % 1000);
for (OreLayerWrapper worldGen: GTOreLayerHelper.mapOreLayerWrapper.values()) {
if (worldGen.primaryMeta == baseMeta || worldGen.secondaryMeta == baseMeta || worldGen.betweenMeta == baseMeta || worldGen.sporadicMeta == baseMeta) {
if (worldGen.genEndAsteroid || worldGen.genGCAsteroid) {
ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.primaryMeta+2000);
ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.secondaryMeta+2000);
ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.betweenMeta+2000);
ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.sporadicMeta+2000);
this.arecipes.add(new CachedAsteroidStatRecipe(worldGen.veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic));
}
}
}
}
else
super.loadCraftingRecipes(stack);
}
@Override
public String getOutputId() {
return "GTOrePluginAsteroid";
}
@Override
public String getRecipeName() {
return I18n.format("gtnop.gui.asteroidStat.name");
}
}
|