Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,21 @@

import com.brandon3055.draconicevolution.DEFeatures;

import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.api.metatileentity.multiblock.CleanroomType;
import gregtech.api.recipes.ModHandler;
import gregtech.api.recipes.RecipeBuilder;
import gregtech.api.recipes.RecipeMaps;
import gregtech.api.recipes.builders.BlastRecipeBuilder;
import gregtech.api.recipes.ingredients.IntCircuitIngredient;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.material.properties.BlastProperty;
import gregtech.api.unification.material.properties.PropertyKey;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.unification.stack.MaterialStack;
import gregtech.common.ConfigHolder;
import gregtech.common.blocks.MetaBlocks;
import gregtech.common.items.MetaItems;

import gregicality.multiblocks.api.fluids.GCYMFluidStorageKeys;
import gregicality.multiblocks.api.recipes.GCYMRecipeMaps;
import gregicality.multiblocks.api.unification.GCYMMaterialFlags;
import gregicality.multiblocks.api.unification.properties.GCYMPropertyKey;

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

/**
Expand Down Expand Up @@ -242,149 +234,6 @@ private static void vacuumFreezerExtended(@NotNull Material material) {
}
}

private static void alloyBlastFurnaceExtended(Material material) {
// Do not generate for disabled materials
if (material.hasFlag(GCYMMaterialFlags.NO_ALLOY_BLAST_RECIPES)) return;

// Check if the material has a blast recipe
if (!material.hasProperty(GCYMPropertyKey.ALLOY_BLAST)) return;

// Check if the material has a molten fluid
Fluid molten = material.getFluid(GCYMFluidStorageKeys.MOLTEN);
if (molten == null) return;

// Get the vacuum freezer EUt and duration
BlastProperty property = material.getProperty(PropertyKey.BLAST);

produce(material, property);
}

/**
* Generates alloy blast recipes for a material
*
* @param material the material to generate for
* @param blastProperty the blast property of the material
*/
private static void produce(@NotNull Material material, @NotNull BlastProperty blastProperty) {
final int componentAmount = material.getMaterialComponents().size();

// ignore non-alloys
if (componentAmount < 2) return;

// get the output fluid
Fluid molten = material.getFluid(GCYMFluidStorageKeys.MOLTEN);
if (molten == null) return;

RecipeBuilder<BlastRecipeBuilder> builder = createBuilder(blastProperty, material);

int outputAmount = addInputs(material, builder);
if (outputAmount <= 0) return;

buildRecipes(blastProperty, molten, outputAmount, componentAmount, builder);
}

/**
* Creates the recipeBuilder with duration and EUt
*
* @param property the blast property of the material
* @param material the material
* @return the builder
*/
@SuppressWarnings("MethodMayBeStatic")
private static @NotNull BlastRecipeBuilder createBuilder(@NotNull BlastProperty property,
@NotNull Material material) {
BlastRecipeBuilder builder = GCYMRecipeMaps.ALLOY_BLAST_RECIPES.recipeBuilder();
// apply the duration override
int duration = property.getDurationOverride();
if (duration < 0) duration = Math.max(1, (int) (material.getMass() * property.getBlastTemperature() / 100L));
builder.duration(duration);

// apply the EUt override
int EUt = property.getEUtOverride();
if (EUt < 0) EUt = GTValues.VA[GTValues.MV];
builder.EUt(EUt);

return builder.blastFurnaceTemp(property.getBlastTemperature());
}

/**
* @param material the material to start recipes for
* @param builder the recipe builder to append to
* @return the outputAmount if the recipe is valid, otherwise -1
*/
private static int addInputs(@NotNull Material material, @NotNull RecipeBuilder<BlastRecipeBuilder> builder) {
// calculate the output amount and add inputs
int outputAmount = 0;
int fluidAmount = 0;
int dustAmount = 0;
for (MaterialStack materialStack : material.getMaterialComponents()) {
final Material msMat = materialStack.material;
final int msAmount = (int) materialStack.amount;

if (msMat.hasProperty(PropertyKey.DUST)) {
if (dustAmount >= 9) return -1; // more than 9 dusts won't fit in the machine
dustAmount++;
builder.input(OrePrefix.dust, msMat, msAmount);
} else if (msMat.hasProperty(PropertyKey.FLUID)) {
if (fluidAmount >= 2) return -1; // more than 2 fluids won't fit in the machine
fluidAmount++;
// assume all fluids have 1000mB/mol, since other quantities should be as an item input
builder.fluidInputs(msMat.getFluid(1000 * msAmount));
} else return -1; // no fluid or item prop means no valid recipe
outputAmount += msAmount;
}
return outputAmount;
}

/**
* Builds the alloy blast recipes
*
* @param property the blast property to utilize
* @param molten the molten fluid
* @param outputAmount the amount of material to output
* @param componentAmount the amount of different components in the material
* @param builder the builder to continue
*/
private static void buildRecipes(@NotNull BlastProperty property, @NotNull Fluid molten, int outputAmount,
int componentAmount,
@NotNull RecipeBuilder<BlastRecipeBuilder> builder) {
// add the fluid output with the correct amount
builder.fluidOutputs(new FluidStack(molten, GTValues.L * outputAmount));

// apply alloy blast duration reduction: 3/4
int duration = builder.getDuration() * outputAmount * 3 / 4;

// build the gas recipe if it exists
if (property.getGasTier() != null) {
RecipeBuilder<BlastRecipeBuilder> builderGas = builder.copy();
builderGas.notConsumable(new IntCircuitIngredient(getGasCircuitNum(componentAmount)))
.fluidInputs(GTEMaterials.Pyrotheum.getFluid(GCYMFluidStorageKeys.MOLTEN, ABFPyrotheumAmount))
.duration((int) (duration * 0.67 * ABFDurationMultiplier))
.buildAndRegister();
}

// build the non-gas recipe
builder.notConsumable(new IntCircuitIngredient(getCircuitNum(componentAmount)))
.duration(duration)
.buildAndRegister();
}

/**
* @param componentAmount the amount of different components in the material
* @return the circuit number for the regular recipe
*/
private static int getCircuitNum(int componentAmount) {
return componentAmount;
}

/**
* @param componentAmount the amount of different components in the material
* @return the circuit number for the gas-boosted recipe
*/
private static int getGasCircuitNum(int componentAmount) {
return componentAmount + 11;
}

public static void remove() {
// Draconium Ore
ModHandler.removeFurnaceSmelting(Mods.DraconicEvolution.getItem("draconium_ore", 1));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.github.gtexpert.core.mixins.gcym;

import static com.github.gtexpert.core.integration.deda.recipes.DraconicMaterialsRecipe.ABFDurationMultiplier;
import static com.github.gtexpert.core.integration.deda.recipes.DraconicMaterialsRecipe.ABFPyrotheumAmount;

import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;

import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import gregtech.api.recipes.RecipeBuilder;
import gregtech.api.recipes.builders.BlastRecipeBuilder;
import gregtech.api.recipes.ingredients.IntCircuitIngredient;
import gregtech.api.unification.material.properties.BlastProperty;
import gregtech.loaders.recipe.CraftingComponent;

import gregicality.multiblocks.api.fluids.GCYMFluidStorageKeys;
import gregicality.multiblocks.api.recipes.alloyblast.AlloyBlastRecipeProducer;

import com.github.gtexpert.core.api.unification.material.GTEMaterials;
import com.github.gtexpert.core.api.util.Mods;

@Mixin(value = AlloyBlastRecipeProducer.class, remap = false)
public abstract class AlloyBlastRecipeProducerMixin {

@Inject(
method = "buildRecipes",
at = @At(
value = "INVOKE",
target = "Lgregtech/api/unification/material/properties/BlastProperty;getGasTier()Lgregtech/api/unification/material/properties/BlastProperty$GasTier;"),
cancellable = true)
private void buildRecipesMixin(@NotNull BlastProperty property, @NotNull Fluid molten, int outputAmount,
int componentAmount, @NotNull RecipeBuilder<BlastRecipeBuilder> builder,
CallbackInfo ci) {
int duration = builder.getDuration() * outputAmount * 3 / 4;

if (property.getGasTier() != null) {
RecipeBuilder<BlastRecipeBuilder> builderGas = builder.copy();
FluidStack gas = CraftingComponent.EBF_GASES.get(property.getGasTier());
builderGas.notConsumable(new IntCircuitIngredient(getGasCircuitNum(componentAmount)))
.fluidInputs(new FluidStack(gas, gas.amount * outputAmount))
.duration((int) (duration * 0.67))
.buildAndRegister();

if (Mods.DraconicEvolution.isModLoaded()) {
RecipeBuilder<BlastRecipeBuilder> builderPyrotheum = builder.copy();
builderPyrotheum.notConsumable(new IntCircuitIngredient(getPyrotheumCircuitNum(componentAmount)))
.fluidInputs(GTEMaterials.Pyrotheum.getFluid(GCYMFluidStorageKeys.MOLTEN, ABFPyrotheumAmount))
.duration((int) (duration * 0.67 * ABFDurationMultiplier))
.buildAndRegister();
}
}
// build the non-gas recipe
builder.notConsumable(new IntCircuitIngredient(getCircuitNum(componentAmount)))
.duration(duration)
.buildAndRegister();
ci.cancel();
}

/**
* @param componentAmount the amount of different components in the material
* @return the circuit number for the regular recipe
*/
protected int getCircuitNum(int componentAmount) {
return componentAmount;
}

/**
* @param componentAmount the amount of different components in the material
* @return the circuit number for the gas-boosted recipe
*/
protected int getGasCircuitNum(int componentAmount) {
return componentAmount + 10;
}

protected int getPyrotheumCircuitNum(int componentAmount) {
return componentAmount + 11;
}
}
3 changes: 2 additions & 1 deletion src/main/resources/mixins.gtexpert.gcym.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"MetaTileEntityMegaBlastFurnaceMixin",
"MetaTileEntityMegaVacuumFreezerMixin"
"MetaTileEntityMegaVacuumFreezerMixin",
"AlloyBlastRecipeProducerMixin"
],
"server": [
],
Expand Down