Skip to content

Commit 95d0091

Browse files
authored
Fix incorrect output amount when using Pyrotheum (#338)
1 parent edbd33f commit 95d0091

File tree

3 files changed

+85
-152
lines changed

3 files changed

+85
-152
lines changed

src/main/java/com/github/gtexpert/core/integration/deda/recipes/DraconicMaterialsRecipe.java

Lines changed: 0 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,21 @@
1616

1717
import com.brandon3055.draconicevolution.DEFeatures;
1818

19-
import gregtech.api.GTValues;
2019
import gregtech.api.GregTechAPI;
2120
import gregtech.api.metatileentity.multiblock.CleanroomType;
2221
import gregtech.api.recipes.ModHandler;
2322
import gregtech.api.recipes.RecipeBuilder;
2423
import gregtech.api.recipes.RecipeMaps;
25-
import gregtech.api.recipes.builders.BlastRecipeBuilder;
26-
import gregtech.api.recipes.ingredients.IntCircuitIngredient;
2724
import gregtech.api.unification.OreDictUnifier;
2825
import gregtech.api.unification.material.Material;
2926
import gregtech.api.unification.material.Materials;
3027
import gregtech.api.unification.material.properties.BlastProperty;
3128
import gregtech.api.unification.material.properties.PropertyKey;
32-
import gregtech.api.unification.ore.OrePrefix;
33-
import gregtech.api.unification.stack.MaterialStack;
3429
import gregtech.common.ConfigHolder;
3530
import gregtech.common.blocks.MetaBlocks;
3631
import gregtech.common.items.MetaItems;
3732

3833
import gregicality.multiblocks.api.fluids.GCYMFluidStorageKeys;
39-
import gregicality.multiblocks.api.recipes.GCYMRecipeMaps;
40-
import gregicality.multiblocks.api.unification.GCYMMaterialFlags;
4134
import gregicality.multiblocks.api.unification.properties.GCYMPropertyKey;
4235

4336
import com.github.gtexpert.core.api.GTEValues;
@@ -154,7 +147,6 @@ public static void init() {
154147
// Extended recipes
155148
List<Material> materials = new ArrayList<>(GregTechAPI.materialManager.getRegisteredMaterials());
156149
materials.forEach(DraconicMaterialsRecipe::vacuumFreezerExtended);
157-
materials.forEach(DraconicMaterialsRecipe::alloyBlastFurnaceExtended);
158150
}
159151

160152
/**
@@ -242,149 +234,6 @@ private static void vacuumFreezerExtended(@NotNull Material material) {
242234
}
243235
}
244236

245-
private static void alloyBlastFurnaceExtended(Material material) {
246-
// Do not generate for disabled materials
247-
if (material.hasFlag(GCYMMaterialFlags.NO_ALLOY_BLAST_RECIPES)) return;
248-
249-
// Check if the material has a blast recipe
250-
if (!material.hasProperty(GCYMPropertyKey.ALLOY_BLAST)) return;
251-
252-
// Check if the material has a molten fluid
253-
Fluid molten = material.getFluid(GCYMFluidStorageKeys.MOLTEN);
254-
if (molten == null) return;
255-
256-
// Get the vacuum freezer EUt and duration
257-
BlastProperty property = material.getProperty(PropertyKey.BLAST);
258-
259-
produce(material, property);
260-
}
261-
262-
/**
263-
* Generates alloy blast recipes for a material
264-
*
265-
* @param material the material to generate for
266-
* @param blastProperty the blast property of the material
267-
*/
268-
private static void produce(@NotNull Material material, @NotNull BlastProperty blastProperty) {
269-
final int componentAmount = material.getMaterialComponents().size();
270-
271-
// ignore non-alloys
272-
if (componentAmount < 2) return;
273-
274-
// get the output fluid
275-
Fluid molten = material.getFluid(GCYMFluidStorageKeys.MOLTEN);
276-
if (molten == null) return;
277-
278-
RecipeBuilder<BlastRecipeBuilder> builder = createBuilder(blastProperty, material);
279-
280-
int outputAmount = addInputs(material, builder);
281-
if (outputAmount <= 0) return;
282-
283-
buildRecipes(blastProperty, molten, outputAmount, componentAmount, builder);
284-
}
285-
286-
/**
287-
* Creates the recipeBuilder with duration and EUt
288-
*
289-
* @param property the blast property of the material
290-
* @param material the material
291-
* @return the builder
292-
*/
293-
@SuppressWarnings("MethodMayBeStatic")
294-
private static @NotNull BlastRecipeBuilder createBuilder(@NotNull BlastProperty property,
295-
@NotNull Material material) {
296-
BlastRecipeBuilder builder = GCYMRecipeMaps.ALLOY_BLAST_RECIPES.recipeBuilder();
297-
// apply the duration override
298-
int duration = property.getDurationOverride();
299-
if (duration < 0) duration = Math.max(1, (int) (material.getMass() * property.getBlastTemperature() / 100L));
300-
builder.duration(duration);
301-
302-
// apply the EUt override
303-
int EUt = property.getEUtOverride();
304-
if (EUt < 0) EUt = GTValues.VA[GTValues.MV];
305-
builder.EUt(EUt);
306-
307-
return builder.blastFurnaceTemp(property.getBlastTemperature());
308-
}
309-
310-
/**
311-
* @param material the material to start recipes for
312-
* @param builder the recipe builder to append to
313-
* @return the outputAmount if the recipe is valid, otherwise -1
314-
*/
315-
private static int addInputs(@NotNull Material material, @NotNull RecipeBuilder<BlastRecipeBuilder> builder) {
316-
// calculate the output amount and add inputs
317-
int outputAmount = 0;
318-
int fluidAmount = 0;
319-
int dustAmount = 0;
320-
for (MaterialStack materialStack : material.getMaterialComponents()) {
321-
final Material msMat = materialStack.material;
322-
final int msAmount = (int) materialStack.amount;
323-
324-
if (msMat.hasProperty(PropertyKey.DUST)) {
325-
if (dustAmount >= 9) return -1; // more than 9 dusts won't fit in the machine
326-
dustAmount++;
327-
builder.input(OrePrefix.dust, msMat, msAmount);
328-
} else if (msMat.hasProperty(PropertyKey.FLUID)) {
329-
if (fluidAmount >= 2) return -1; // more than 2 fluids won't fit in the machine
330-
fluidAmount++;
331-
// assume all fluids have 1000mB/mol, since other quantities should be as an item input
332-
builder.fluidInputs(msMat.getFluid(1000 * msAmount));
333-
} else return -1; // no fluid or item prop means no valid recipe
334-
outputAmount += msAmount;
335-
}
336-
return outputAmount;
337-
}
338-
339-
/**
340-
* Builds the alloy blast recipes
341-
*
342-
* @param property the blast property to utilize
343-
* @param molten the molten fluid
344-
* @param outputAmount the amount of material to output
345-
* @param componentAmount the amount of different components in the material
346-
* @param builder the builder to continue
347-
*/
348-
private static void buildRecipes(@NotNull BlastProperty property, @NotNull Fluid molten, int outputAmount,
349-
int componentAmount,
350-
@NotNull RecipeBuilder<BlastRecipeBuilder> builder) {
351-
// add the fluid output with the correct amount
352-
builder.fluidOutputs(new FluidStack(molten, GTValues.L * outputAmount));
353-
354-
// apply alloy blast duration reduction: 3/4
355-
int duration = builder.getDuration() * outputAmount * 3 / 4;
356-
357-
// build the gas recipe if it exists
358-
if (property.getGasTier() != null) {
359-
RecipeBuilder<BlastRecipeBuilder> builderGas = builder.copy();
360-
builderGas.notConsumable(new IntCircuitIngredient(getGasCircuitNum(componentAmount)))
361-
.fluidInputs(GTEMaterials.Pyrotheum.getFluid(GCYMFluidStorageKeys.MOLTEN, ABFPyrotheumAmount))
362-
.duration((int) (duration * 0.67 * ABFDurationMultiplier))
363-
.buildAndRegister();
364-
}
365-
366-
// build the non-gas recipe
367-
builder.notConsumable(new IntCircuitIngredient(getCircuitNum(componentAmount)))
368-
.duration(duration)
369-
.buildAndRegister();
370-
}
371-
372-
/**
373-
* @param componentAmount the amount of different components in the material
374-
* @return the circuit number for the regular recipe
375-
*/
376-
private static int getCircuitNum(int componentAmount) {
377-
return componentAmount;
378-
}
379-
380-
/**
381-
* @param componentAmount the amount of different components in the material
382-
* @return the circuit number for the gas-boosted recipe
383-
*/
384-
private static int getGasCircuitNum(int componentAmount) {
385-
return componentAmount + 11;
386-
}
387-
388237
public static void remove() {
389238
// Draconium Ore
390239
ModHandler.removeFurnaceSmelting(Mods.DraconicEvolution.getItem("draconium_ore", 1));
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.github.gtexpert.core.mixins.gcym;
2+
3+
import static com.github.gtexpert.core.integration.deda.recipes.DraconicMaterialsRecipe.ABFDurationMultiplier;
4+
import static com.github.gtexpert.core.integration.deda.recipes.DraconicMaterialsRecipe.ABFPyrotheumAmount;
5+
6+
import net.minecraftforge.fluids.Fluid;
7+
import net.minecraftforge.fluids.FluidStack;
8+
9+
import org.jetbrains.annotations.NotNull;
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.injection.At;
12+
import org.spongepowered.asm.mixin.injection.Inject;
13+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
14+
15+
import gregtech.api.recipes.RecipeBuilder;
16+
import gregtech.api.recipes.builders.BlastRecipeBuilder;
17+
import gregtech.api.recipes.ingredients.IntCircuitIngredient;
18+
import gregtech.api.unification.material.properties.BlastProperty;
19+
import gregtech.loaders.recipe.CraftingComponent;
20+
21+
import gregicality.multiblocks.api.fluids.GCYMFluidStorageKeys;
22+
import gregicality.multiblocks.api.recipes.alloyblast.AlloyBlastRecipeProducer;
23+
24+
import com.github.gtexpert.core.api.unification.material.GTEMaterials;
25+
import com.github.gtexpert.core.api.util.Mods;
26+
27+
@Mixin(value = AlloyBlastRecipeProducer.class, remap = false)
28+
public abstract class AlloyBlastRecipeProducerMixin {
29+
30+
@Inject(
31+
method = "buildRecipes",
32+
at = @At(
33+
value = "INVOKE",
34+
target = "Lgregtech/api/unification/material/properties/BlastProperty;getGasTier()Lgregtech/api/unification/material/properties/BlastProperty$GasTier;"),
35+
cancellable = true)
36+
private void buildRecipesMixin(@NotNull BlastProperty property, @NotNull Fluid molten, int outputAmount,
37+
int componentAmount, @NotNull RecipeBuilder<BlastRecipeBuilder> builder,
38+
CallbackInfo ci) {
39+
int duration = builder.getDuration() * outputAmount * 3 / 4;
40+
41+
if (property.getGasTier() != null) {
42+
RecipeBuilder<BlastRecipeBuilder> builderGas = builder.copy();
43+
FluidStack gas = CraftingComponent.EBF_GASES.get(property.getGasTier());
44+
builderGas.notConsumable(new IntCircuitIngredient(getGasCircuitNum(componentAmount)))
45+
.fluidInputs(new FluidStack(gas, gas.amount * outputAmount))
46+
.duration((int) (duration * 0.67))
47+
.buildAndRegister();
48+
49+
if (Mods.DraconicEvolution.isModLoaded()) {
50+
RecipeBuilder<BlastRecipeBuilder> builderPyrotheum = builder.copy();
51+
builderPyrotheum.notConsumable(new IntCircuitIngredient(getPyrotheumCircuitNum(componentAmount)))
52+
.fluidInputs(GTEMaterials.Pyrotheum.getFluid(GCYMFluidStorageKeys.MOLTEN, ABFPyrotheumAmount))
53+
.duration((int) (duration * 0.67 * ABFDurationMultiplier))
54+
.buildAndRegister();
55+
}
56+
}
57+
// build the non-gas recipe
58+
builder.notConsumable(new IntCircuitIngredient(getCircuitNum(componentAmount)))
59+
.duration(duration)
60+
.buildAndRegister();
61+
ci.cancel();
62+
}
63+
64+
/**
65+
* @param componentAmount the amount of different components in the material
66+
* @return the circuit number for the regular recipe
67+
*/
68+
protected int getCircuitNum(int componentAmount) {
69+
return componentAmount;
70+
}
71+
72+
/**
73+
* @param componentAmount the amount of different components in the material
74+
* @return the circuit number for the gas-boosted recipe
75+
*/
76+
protected int getGasCircuitNum(int componentAmount) {
77+
return componentAmount + 10;
78+
}
79+
80+
protected int getPyrotheumCircuitNum(int componentAmount) {
81+
return componentAmount + 11;
82+
}
83+
}

src/main/resources/mixins.gtexpert.gcym.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"compatibilityLevel": "JAVA_8",
77
"mixins": [
88
"MetaTileEntityMegaBlastFurnaceMixin",
9-
"MetaTileEntityMegaVacuumFreezerMixin"
9+
"MetaTileEntityMegaVacuumFreezerMixin",
10+
"AlloyBlastRecipeProducerMixin"
1011
],
1112
"server": [
1213
],

0 commit comments

Comments
 (0)