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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
package tectech.recipe;
import static java.lang.Math.pow;
import static tectech.recipe.EyeOfHarmonyRecipe.processHelper;
import static tectech.recipe.TecTechRecipeMaps.eyeOfHarmonyRecipes;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.math.LongMath;
import gregtech.api.enums.GTValues;
import gregtech.api.enums.Materials;
import gregtech.api.enums.MaterialsUEVplus;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GTOreDictUnificator;
import gtneioreplugin.plugin.block.BlockDimensionDisplay;
import gtneioreplugin.plugin.block.ModBlocks;
import gtneioreplugin.util.DimensionHelper;
import gtneioreplugin.util.GT5OreLayerHelper;
import gtneioreplugin.util.GT5OreSmallHelper;
import tectech.util.FluidStackLong;
import tectech.util.ItemStackLong;
public class EyeOfHarmonyRecipeStorage {
public static final long BILLION = LongMath.pow(10, 9);
private static final double CHANCE_DECREASE_PER_DIMENSION = 0.05;
// Map is unique so this is fine.
HashMap<Block, String> blocksMapInverted = new HashMap<>() {
private static final long serialVersionUID = -1634011860327553337L;
{
ModBlocks.blocks.forEach((dimString, dimBlock) -> { put(dimBlock, dimString); });
}
};
private final HashMap<String, EyeOfHarmonyRecipe> recipeHashMap = new HashMap<String, EyeOfHarmonyRecipe>() {
private static final long serialVersionUID = -3501819612517400500L;
{
for (String dimAbbreviation : DimensionHelper.DimNameDisplayed) {
BlockDimensionDisplay blockDimensionDisplay = (BlockDimensionDisplay) ModBlocks.blocks
.get(dimAbbreviation);
if (dimAbbreviation.equals("DD")) {
specialDeepDarkRecipe(this, blockDimensionDisplay);
} else {
GT5OreLayerHelper.NormalOreDimensionWrapper normalOre = GT5OreLayerHelper.dimToOreWrapper
.getOrDefault(dimAbbreviation, null);
GT5OreSmallHelper.SmallOreDimensionWrapper smallOre = GT5OreSmallHelper.dimToSmallOreWrapper
.getOrDefault(dimAbbreviation, null);
if (normalOre == null && smallOre == null) {
// No ores are generated in this dimension. Fail silently.
continue;
}
long spacetimeTier = blockDimensionDisplay.getDimensionRocketTier();
if (spacetimeTier == 0) {
spacetimeTier += 1;
}
put(
dimAbbreviation,
new EyeOfHarmonyRecipe(
normalOre,
smallOre,
blockDimensionDisplay,
0.6 + blockDimensionDisplay.getDimensionRocketTier() / 10.0,
BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1),
BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1),
timeCalculator(blockDimensionDisplay.getDimensionRocketTier()),
spacetimeTier - 1,
1.0 - CHANCE_DECREASE_PER_DIMENSION * blockDimensionDisplay.getDimensionRocketTier()));
}
}
}
};
public EyeOfHarmonyRecipe recipeLookUp(final ItemStack aStack) {
String dimAbbreviation = blocksMapInverted.get(Block.getBlockFromItem(aStack.getItem()));
return recipeHashMap.get(dimAbbreviation);
}
public EyeOfHarmonyRecipeStorage() {
for (EyeOfHarmonyRecipe recipe : recipeHashMap.values()) {
ArrayList<ItemStack> outputItems = new ArrayList<>();
for (ItemStackLong itemStackLong : recipe.getOutputItems()) {
outputItems.add(itemStackLong.itemStack);
}
ArrayList<FluidStack> outputFluids = new ArrayList<>();
for (FluidStackLong fluidStackLong : recipe.getOutputFluids()) {
outputFluids.add(fluidStackLong.fluidStack);
}
ItemStack planetItem = recipe.getRecipeTriggerItem()
.copy();
planetItem.stackSize = 0;
GTValues.RA.stdBuilder()
.itemInputs(planetItem)
.itemOutputs(outputItems.toArray(new ItemStack[0]))
.fluidInputs(
Materials.Hydrogen.getGas(0),
Materials.Helium.getGas(0),
MaterialsUEVplus.RawStarMatter.getFluid(0))
.fluidOutputs(outputFluids.toArray(new FluidStack[0]))
.duration(recipe.getRecipeTimeInTicks())
.eut(0)
.special(recipe)
.noOptimize()
.addTo(eyeOfHarmonyRecipes);
}
}
private void specialDeepDarkRecipe(final HashMap<String, EyeOfHarmonyRecipe> hashMap,
final BlockDimensionDisplay planetItem) {
HashSet<Materials> validMaterialSet = new HashSet<>();
for (Materials material : Materials.values()) {
ItemStack normalOre = GTOreDictUnificator.get(OrePrefixes.ore, material, 1);
if ((normalOre != null)) {
validMaterialSet.add(material);
}
ItemStack smallOre = GTOreDictUnificator.get(OrePrefixes.oreSmall, material, 1);
if ((smallOre != null)) {
validMaterialSet.add(material);
}
}
ArrayList<Materials> validMaterialList = new ArrayList<>(validMaterialSet);
long rocketTier = 9;
hashMap.put(
"DD",
new EyeOfHarmonyRecipe(
processDD(validMaterialList),
planetItem,
0.6 + rocketTier / 10.0,
BILLION * (rocketTier + 1),
BILLION * (rocketTier + 1),
timeCalculator(rocketTier),
rocketTier, // -1 so that we avoid out of bounds exception on NEI render.
1.0 - rocketTier * CHANCE_DECREASE_PER_DIMENSION));
}
private static long timeCalculator(final long rocketTier) {
return (long) (18_000L * pow(1.4, rocketTier));
}
private ArrayList<Pair<Materials, Long>> processDD(final ArrayList<Materials> validMaterialList) {
EyeOfHarmonyRecipe.HashMapHelper outputMap = new EyeOfHarmonyRecipe.HashMapHelper();
// 10 from rocketTier + 1, 6 * 64 = VM3 + Og, 1.4 = time increase per tier.
double mainMultiplier = (timeCalculator(10) * (6 * 64));
double probability = 1.0 / validMaterialList.size();
validMaterialList.forEach((material) -> { processHelper(outputMap, material, mainMultiplier, probability); });
ArrayList<Pair<Materials, Long>> outputList = new ArrayList<>();
outputMap.forEach((material, quantity) -> outputList.add(Pair.of(material, (long) Math.floor(quantity))));
return outputList;
}
}
|