Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Add gt++ recipe exporter
Browse files Browse the repository at this point in the history
squash
  • Loading branch information
wlghdu97 committed Jun 9, 2020
1 parent 4ad1662 commit c12c41e
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/bigbass/recex/recipes/RecipeExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.bigbass.recex.RecipeExporterMod;
import com.bigbass.recex.recipes.exporters.ForestryRecipeExporter;
import com.bigbass.recex.recipes.exporters.GTPPRecipeExporter;
import com.bigbass.recex.recipes.gregtech.GregtechRecipe;
import com.bigbass.recex.recipes.gregtech.RecipeUtil;
import com.bigbass.recex.recipes.renderer.IconRenderer;
Expand Down Expand Up @@ -64,7 +65,8 @@ public void run(){

List<Object> sources = new ArrayList<Object>();
sources.add(getGregtechRecipes());
sources.add(new ForestryRecipeExporter().getForestryRecipes());
sources.add(new GTPPRecipeExporter().getRecipes());
sources.add(new ForestryRecipeExporter().getRecipes());
sources.add(getShapedRecipes());
sources.add(getShapelessRecipes());
sources.add(getOreDictShapedRecipes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
import java.util.List;
import java.util.Map;

public class ForestryRecipeExporter {
public class ForestryRecipeExporter implements RecipeExporter {

public Mod getForestryRecipes() {
@Override
public Mod getRecipes() {
List<Machine> machines = new ArrayList<>();
machines.add(getCarpenterRecipes());
machines.add(getCentrifugeRecipes());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.bigbass.recex.recipes.exporters;

import com.bigbass.recex.recipes.Fluid;
import com.bigbass.recex.recipes.Item;
import com.bigbass.recex.recipes.Machine;
import com.bigbass.recex.recipes.Mod;
import com.bigbass.recex.recipes.gregtech.GregtechRecipe;
import com.bigbass.recex.recipes.gregtech.RecipeUtil;
import gregtech.api.util.GTPP_Recipe;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Recipe;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;

import java.util.ArrayList;
import java.util.List;

public class GTPPRecipeExporter implements RecipeExporter {

@Override
public Mod getRecipes() {
List<Machine> machines = new ArrayList<>();
for (GTPP_Recipe.GTPP_Recipe_Map map : GTPP_Recipe.GTPP_Recipe_Map.sMappings) {
Machine machine = new Machine(GT_LanguageManager.getTranslation(map.mUnlocalizedName));

// machine name retrieval
if (machine.name == null || machine.name.isEmpty()) {
machine.name = map.mUnlocalizedName;
}

for (GT_Recipe rec : map.mRecipeList) {
GregtechRecipe gtr = new GregtechRecipe();
gtr.en = rec.mEnabled;
gtr.dur = rec.mDuration;
gtr.eut = rec.mEUt;

// item inputs
for(ItemStack stack : rec.mInputs){
Item item = RecipeUtil.formatGregtechItemStack(stack);
if(item == null){
continue;
}
gtr.iI.add(item);
}

// item outputs
for(ItemStack stack : rec.mOutputs){
Item item = RecipeUtil.formatGregtechItemStack(stack);
if(item == null){
continue;
}
gtr.iO.add(item);
}

// fluid inputs
for(FluidStack stack : rec.mFluidInputs){
Fluid fluid = RecipeUtil.formatGregtechFluidStack(stack);
if(fluid == null){
continue;
}
gtr.fI.add(fluid);
}

// fluid outputs
for(FluidStack stack : rec.mFluidOutputs){
Fluid fluid = RecipeUtil.formatGregtechFluidStack(stack);
if(fluid == null){
continue;
}
gtr.fO.add(fluid);
}
machine.recipes.add(gtr);
}
machines.add(machine);
}
return new Mod("gt++", machines);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.bigbass.recex.recipes.exporters;

import com.bigbass.recex.recipes.Mod;

public interface RecipeExporter {
Mod getRecipes();
}

0 comments on commit c12c41e

Please sign in to comment.