Skip to content

Commit

Permalink
Material Tree JEI page returns (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumquat-ir authored Aug 21, 2021
1 parent 0f6c8b7 commit 98e3bef
Show file tree
Hide file tree
Showing 31 changed files with 452 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/gregtech/integration/jei/GTJeiPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void registerCategories(IRecipeCategoryRegistration registry) {
}
registry.addRecipeCategories(new OreByProductCategory(registry.getJeiHelpers().getGuiHelper()));
registry.addRecipeCategories(new GTOreCategory(registry.getJeiHelpers().getGuiHelper()));
registry.addRecipeCategories(new MaterialTreeCategory(registry.getJeiHelpers().getGuiHelper()));
}

@Override
Expand Down Expand Up @@ -187,6 +188,15 @@ public void register(IModRegistry registry) {
registry.addRecipeCatalyst(machine.getStackForm(), oreByProductId);
}

//Material Tree
List<MaterialTree> materialTreeList = new CopyOnWriteArrayList<>();
for (Material material : MaterialRegistry.MATERIAL_REGISTRY) {
if (material.hasProperty(PropertyKey.DUST)) {
materialTreeList.add(new MaterialTree(material));
}
}
registry.addRecipes(materialTreeList, GTValues.MODID + ":" + "material_tree");

//Ore Veins
List<OreDepositDefinition> oreVeins = WorldGenRegistry.getOreDeposits();
List<GTOreInfo> oreInfoList = new CopyOnWriteArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package gregtech.integration.jei.recipe.primitive;

import com.google.common.collect.ImmutableList;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.properties.PropertyKey;
import gregtech.api.unification.ore.OrePrefix;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;

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

public class MaterialTree implements IRecipeWrapper {
private final static ImmutableList<OrePrefix> PREFIXES = ImmutableList.of(
OrePrefix.dustTiny,
OrePrefix.dust,
OrePrefix.dustSmall,
OrePrefix.cableGtSingle,
OrePrefix.ingotHot,
OrePrefix.ingot,
OrePrefix.gem,
OrePrefix.block,
OrePrefix.wireGtSingle,
OrePrefix.stick,
OrePrefix.nugget,
OrePrefix.plate,
OrePrefix.wireFine,
OrePrefix.frameGt,
OrePrefix.round,
OrePrefix.pipeNormalFluid,
OrePrefix.pipeNormalItem,
OrePrefix.screw,
OrePrefix.bolt,
OrePrefix.gear,
OrePrefix.plateDouble,
OrePrefix.spring,
OrePrefix.stickLong,
OrePrefix.gearSmall,
OrePrefix.plateDense,
OrePrefix.springSmall,
OrePrefix.ring,
// fluid,
OrePrefix.lens,
OrePrefix.foil
);

private final List<List<ItemStack>> itemInputs = new ArrayList<>();
private final List<List<FluidStack>> fluidInputs = new ArrayList<>();

private final String name;
private final String formula;
private final int blastTemp;
private final long avgM;
private final long avgP;
private final long avgN;

public MaterialTree(Material material) {
// adding an empty list to itemInputs/fluidInputs makes checking if a prefix exists later much easier
List<ItemStack> inputDusts = new ArrayList<>();
for (OrePrefix prefix : PREFIXES) {
inputDusts.add(OreDictUnifier.get(prefix, material));
}
for (ItemStack stack : inputDusts) {
List<ItemStack> matItemsStack = new ArrayList<>();
matItemsStack.add(stack);
this.itemInputs.add(matItemsStack);
}

List<FluidStack> matFluidsStack = new ArrayList<>();
if (material.hasProperty(PropertyKey.FLUID)) {
matFluidsStack.add(material.getFluid(1000));
}
this.fluidInputs.add(matFluidsStack);

name = material.getLocalizedName();
formula = material.getChemicalFormula();
avgM = material.getAverageMass();
avgP = material.getAverageProtons();
avgN = material.getAverageNeutrons();
if (material.hasProperty(PropertyKey.BLAST)) {
blastTemp = material.getBlastTemperature();
} else {
blastTemp = 0;
}
}

@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInputLists(VanillaTypes.ITEM, this.itemInputs);
ingredients.setInputLists(VanillaTypes.FLUID, this.fluidInputs);
// these don't get displayed, but allow the material tree to show up on left *or* right click
ingredients.setOutputLists(VanillaTypes.ITEM, this.itemInputs);
ingredients.setOutputLists(VanillaTypes.FLUID, this.fluidInputs);
}

public String getMaterialName() {
return name;
}

public String getMaterialFormula() {
return formula;
}

public long getAvgM() {
return avgM;
}

public long getAvgP() {
return avgP;
}

public long getAvgN() {
return avgN;
}

public int getBlastTemp() {
return blastTemp;
}
}
Loading

0 comments on commit 98e3bef

Please sign in to comment.