Skip to content

Commit

Permalink
Added Ore Processing Page (#504)
Browse files Browse the repository at this point in the history
* only let the category register once

* added EMI support

* finalized the oreproc page

* Update GTJEIPlugin.java

* Update GTOreProcessingDisplayCategory.java

* Update GTOreProcessingInfoCategory.java

* Update GTOreProcessingEmiCategory.java

* more requested changes

* Update GTOreProcessingEmiCategory.java

* more changes
  • Loading branch information
Rundas01 authored Nov 2, 2023
1 parent 85dc81a commit 8585280
Show file tree
Hide file tree
Showing 32 changed files with 855 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ public class GuiTextures {
public static final ResourceTexture MAINTENANCE_ICON = new ResourceTexture("gtceu:textures/block/overlay/machine/overlay_maintenance.png");
public static final ResourceTexture BUTTON_MINER_MODES = new ResourceTexture("gtceu:textures/gui/widget/button_miner_modes.png");

//ORE PROCESSING
public static final ResourceTexture OREBY_BASE = new ResourceTexture("gtceu:textures/gui/arrows/oreby-base.png");
public static final ResourceTexture OREBY_CHEM = new ResourceTexture("gtceu:textures/gui/arrows/oreby-chem.png");
public static final ResourceTexture OREBY_SEP = new ResourceTexture("gtceu:textures/gui/arrows/oreby-sep.png");
public static final ResourceTexture OREBY_SIFT = new ResourceTexture("gtceu:textures/gui/arrows/oreby-sift.png");
public static final ResourceTexture OREBY_SMELT = new ResourceTexture("gtceu:textures/gui/arrows/oreby-smelt.png");


//PRIMITIVE
public static final ResourceBorderTexture PRIMITIVE_BACKGROUND = new ResourceBorderTexture("gtceu:textures/gui/primitive/primitive_background.png", 176, 166, 3, 3);
public static final ResourceBorderTexture PRIMITIVE_SLOT = new ResourceBorderTexture("gtceu:textures/gui/primitive/primitive_slot.png", 18, 18, 1, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static void init(RegistrateLangProvider provider) {
/** JEI, REI, EMI */
private static void initRecipeViewerLang(RegistrateLangProvider provider) {
provider.add("gtceu.jei.multiblock_info", "Multiblock Info");
provider.add("gtceu.jei.ore_processing_diagram", "Ore Processing Diagram");
}

/** Jade, TheOneProbe, WTHIT */
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.gregtechceu.gtceu.api.recipe.GTRecipeType;
import com.gregtechceu.gtceu.common.data.GTMachines;
import com.gregtechceu.gtceu.integration.emi.multipage.MultiblockInfoEmiCategory;
import com.gregtechceu.gtceu.integration.emi.oreprocessing.GTOreProcessingEmiCategory;
import com.gregtechceu.gtceu.integration.emi.recipe.GTRecipeTypeEmiCategory;
import dev.emi.emi.api.EmiEntrypoint;
import dev.emi.emi.api.EmiPlugin;
Expand All @@ -23,6 +24,7 @@ public class GTEMIPlugin implements EmiPlugin {
@Override
public void register(EmiRegistry registry) {
registry.addCategory(MultiblockInfoEmiCategory.CATEGORY);
registry.addCategory(GTOreProcessingEmiCategory.CATEGORY);
for (RecipeType<?> recipeType : Registry.RECIPE_TYPE) {
if (recipeType instanceof GTRecipeType gtRecipeType) {
registry.addCategory(GTRecipeTypeEmiCategory.CATEGORIES.apply(gtRecipeType));
Expand All @@ -31,9 +33,11 @@ public void register(EmiRegistry registry) {
// recipes
MultiblockInfoEmiCategory.registerDisplays(registry);
GTRecipeTypeEmiCategory.registerDisplays(registry);
GTOreProcessingEmiCategory.registerDisplays(registry);
// workstations
MultiblockInfoEmiCategory.registerWorkStations(registry);
GTRecipeTypeEmiCategory.registerWorkStations(registry);
GTOreProcessingEmiCategory.registerWorkStations(registry);
for (MachineDefinition definition : GTMachines.ELECTRIC_FURNACE) {
if (definition != null) {
registry.addWorkstation(VanillaEmiRecipeCategories.SMELTING, EmiStack.of(definition.asStack()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gregtechceu.gtceu.integration.emi.oreprocessing;

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.integration.GTOreProcessingWidget;
import com.lowdragmc.lowdraglib.emi.ModularEmiRecipe;
import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup;
import dev.emi.emi.api.recipe.EmiRecipeCategory;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;

public class GTEmiOreProcessing extends ModularEmiRecipe<WidgetGroup> {
final Material material;

public GTEmiOreProcessing(Material material) {
super(() -> new GTOreProcessingWidget(material));
this.material = material;
}

@Override
public EmiRecipeCategory getCategory() {
return GTOreProcessingEmiCategory.CATEGORY;
}

@Override
public @Nullable ResourceLocation getId() {
return GTCEu.id(material.getName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.gregtechceu.gtceu.integration.emi.oreprocessing;

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.api.machine.MachineDefinition;
import com.gregtechceu.gtceu.api.recipe.GTRecipeType;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.integration.rei.oreprocessing.GTOreProcessingDisplayCategory;
import com.lowdragmc.lowdraglib.emi.ModularUIEmiRecipeCategory;
import dev.emi.emi.api.EmiRegistry;
import dev.emi.emi.api.stack.EmiStack;
import me.shedaniel.rei.api.common.util.EntryStacks;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;

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

import static com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey.ORE;
import static com.gregtechceu.gtceu.common.data.GTRecipeTypes.*;

public class GTOreProcessingEmiCategory extends ModularUIEmiRecipeCategory {
public static final GTOreProcessingEmiCategory CATEGORY = new GTOreProcessingEmiCategory();
public GTOreProcessingEmiCategory() {
super(GTCEu.id("ore_processing_diagram"), EmiStack.of(Items.IRON_ORE));
}

public static void registerDisplays(EmiRegistry registry) {
for (Material mat : GTRegistries.MATERIALS) {
if (mat.hasProperty(ORE)) {
registry.addRecipe(new GTEmiOreProcessing(mat));
}
}
}

public static void registerWorkStations(EmiRegistry registry) {
List<MachineDefinition> registeredMachines = new ArrayList<>();
GTRecipeType[] validTypes = new GTRecipeType[] {
MACERATOR_RECIPES,ORE_WASHER_RECIPES,THERMAL_CENTRIFUGE_RECIPES,CENTRIFUGE_RECIPES,CHEMICAL_BATH_RECIPES,ELECTROMAGNETIC_SEPARATOR_RECIPES,SIFTER_RECIPES
};
for (MachineDefinition machine : GTRegistries.MACHINES) {
if (machine.getRecipeTypes() != null) {
for (GTRecipeType type : machine.getRecipeTypes()){
for (GTRecipeType validType : validTypes){
if (type == validType && !registeredMachines.contains(machine)) {
registry.addWorkstation(CATEGORY, EmiStack.of(machine.asStack()));
registeredMachines.add(machine);
}
}
}
}
}
}

@Override
public Component getName() {
return Component.translatable("gtceu.jei.ore_processing_diagram");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.gregtechceu.gtceu.api.recipe.GTRecipeType;
import com.gregtechceu.gtceu.common.data.GTMachines;
import com.gregtechceu.gtceu.integration.jei.multipage.MultiblockInfoCategory;
import com.gregtechceu.gtceu.integration.jei.oreprocessing.GTOreProcessingInfoCategory;
import com.gregtechceu.gtceu.integration.jei.recipe.GTRecipeTypeCategory;
import com.lowdragmc.lowdraglib.LDLib;
import mezz.jei.api.IModPlugin;
Expand Down Expand Up @@ -43,6 +44,7 @@ public void registerCategories(@Nonnull IRecipeCategoryRegistration registry) {
GTCEu.LOGGER.info("JEI register categories");
IJeiHelpers jeiHelpers = registry.getJeiHelpers();
registry.addRecipeCategories(new MultiblockInfoCategory(jeiHelpers));
registry.addRecipeCategories(new GTOreProcessingInfoCategory(jeiHelpers));
for (RecipeType<?> recipeType : Registry.RECIPE_TYPE) {
if (recipeType instanceof GTRecipeType gtRecipeType) {
registry.addRecipeCategories(new GTRecipeTypeCategory(jeiHelpers, gtRecipeType));
Expand All @@ -55,6 +57,7 @@ public void registerRecipeCatalysts(@Nonnull IRecipeCatalystRegistration registr
if (LDLib.isReiLoaded() || LDLib.isEmiLoaded()) return;
MultiblockInfoCategory.registerRecipeCatalysts(registration);
GTRecipeTypeCategory.registerRecipeCatalysts(registration);
GTOreProcessingInfoCategory.registerRecipeCatalysts(registration);
for (MachineDefinition definition : GTMachines.ELECTRIC_FURNACE) {
if (definition != null) {
registration.addRecipeCatalyst(definition.asStack(), RecipeTypes.SMELTING);
Expand All @@ -72,6 +75,7 @@ public void registerRecipes(@Nonnull IRecipeRegistration registration) {
GTCEu.LOGGER.info("JEI register");
MultiblockInfoCategory.registerRecipes(registration);
GTRecipeTypeCategory.registerRecipes(registration);
GTOreProcessingInfoCategory.registerRecipes(registration);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.gregtechceu.gtceu.integration.jei.oreprocessing;

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper;
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.lowdragmc.lowdraglib.jei.ModularUIRecipeCategory;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.registration.IRecipeCatalystRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

import javax.annotation.Nonnull;

import static com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey.DUST;
import static com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey.ORE;
import static com.gregtechceu.gtceu.api.data.tag.TagPrefix.*;
import static com.gregtechceu.gtceu.common.data.GTMaterials.Aluminium;
import static com.gregtechceu.gtceu.common.data.GTMaterials.Iron;

public class GTOreProcessingInfoCategory extends ModularUIRecipeCategory<GTOreProcessingInfoWrapper> {
public final static RecipeType<GTOreProcessingInfoWrapper> RECIPE_TYPE = new RecipeType<>(GTCEu.id("ore_processing_diagram"), GTOreProcessingInfoWrapper.class);
private final IDrawable background;
private final IDrawable icon;

public GTOreProcessingInfoCategory(IJeiHelpers helpers) {
IGuiHelper guiHelper = helpers.getGuiHelper();
this.background = guiHelper.createBlankDrawable(186, 174);
this.icon = helpers.getGuiHelper().createDrawableItemStack(ChemicalHelper.get(ore,Iron));
}

public static void registerRecipes(IRecipeRegistration registry) {
registry.addRecipes(RECIPE_TYPE, GTRegistries.MATERIALS.values().stream()
.filter((material) -> material.hasProperty(PropertyKey.ORE))
.map(GTOreProcessingInfoWrapper::new)
.toList());
}

public static void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
for (Material mat : GTRegistries.MATERIALS) {
if (mat.hasProperty(ORE)) {
registration.addRecipeCatalyst(ChemicalHelper.get(ore, mat), RECIPE_TYPE);
registration.addRecipeCatalyst(ChemicalHelper.get(rawOre, mat), RECIPE_TYPE);
registration.addRecipeCatalyst(ChemicalHelper.get(crushed, mat), RECIPE_TYPE);
registration.addRecipeCatalyst(ChemicalHelper.get(crushedPurified, mat), RECIPE_TYPE);
registration.addRecipeCatalyst(ChemicalHelper.get(crushedRefined, mat), RECIPE_TYPE);
registration.addRecipeCatalyst(ChemicalHelper.get(ore, mat), RECIPE_TYPE);
if (mat.hasProperty(DUST)) {
registration.addRecipeCatalyst(ChemicalHelper.get(dust, mat), RECIPE_TYPE);
}
}
}
}


@Override
@Nonnull
public RecipeType<GTOreProcessingInfoWrapper> getRecipeType() {
return RECIPE_TYPE;
}

@Nonnull
@Override
public Component getTitle() {
return Component.translatable("gtceu.jei.ore_processing_info");
}

@Nonnull
@Override
public IDrawable getBackground() {
return background;
}

@Nonnull
@Override
public IDrawable getIcon() {
return icon;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.gregtechceu.gtceu.integration.jei.oreprocessing;

import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.integration.GTOreProcessingWidget;
import com.lowdragmc.lowdraglib.jei.ModularWrapper;

public class GTOreProcessingInfoWrapper extends ModularWrapper<GTOreProcessingWidget> {
public final Material material;

public GTOreProcessingInfoWrapper(Material mat) {
super(new GTOreProcessingWidget(mat));
this.material = mat;
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.gregtechceu.gtceu.integration.rei;

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.api.item.tool.GTToolType;
import com.gregtechceu.gtceu.api.machine.MachineDefinition;
import com.gregtechceu.gtceu.api.recipe.GTRecipeType;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.common.data.GTMachines;
import com.gregtechceu.gtceu.integration.rei.multipage.MultiblockInfoDisplayCategory;
import com.gregtechceu.gtceu.integration.rei.oreprocessing.GTOreProcessingDisplayCategory;
import com.gregtechceu.gtceu.integration.rei.recipe.GTRecipeTypeDisplayCategory;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
Expand All @@ -28,6 +31,7 @@ public class GTREIPlugin implements REIClientPlugin {
@Override
public void registerCategories(CategoryRegistry registry) {
registry.add(new MultiblockInfoDisplayCategory());
registry.add(new GTOreProcessingDisplayCategory());
for (RecipeType<?> recipeType : Registry.RECIPE_TYPE) {
if (recipeType instanceof GTRecipeType gtRecipeType) {
registry.add(new GTRecipeTypeDisplayCategory(gtRecipeType));
Expand All @@ -36,6 +40,7 @@ public void registerCategories(CategoryRegistry registry) {
// workstations
MultiblockInfoDisplayCategory.registerWorkStations(registry);
GTRecipeTypeDisplayCategory.registerWorkStations(registry);
GTOreProcessingDisplayCategory.registerWorkstations(registry);
for (MachineDefinition definition : GTMachines.ELECTRIC_FURNACE) {
if (definition != null) {
registry.addWorkstations(SMELTING, EntryStacks.of(definition.asStack()));
Expand All @@ -51,6 +56,7 @@ public void registerCategories(CategoryRegistry registry) {
public void registerDisplays(DisplayRegistry registry) {
GTRecipeTypeDisplayCategory.registerDisplays(registry);
MultiblockInfoDisplayCategory.registerDisplays(registry);
GTOreProcessingDisplayCategory.registerDisplays(registry);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.gregtechceu.gtceu.integration.rei.oreprocessing;

import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper;
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.integration.GTOreProcessingWidget;
import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup;
import com.lowdragmc.lowdraglib.rei.ModularDisplay;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes;
import me.shedaniel.rei.api.common.util.EntryIngredients;

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

import static com.gregtechceu.gtceu.api.data.tag.TagPrefix.*;

public class GTOreProcessingDisplay extends ModularDisplay<WidgetGroup> {

private final Material material;

public GTOreProcessingDisplay(Material material) {
super(() -> new GTOreProcessingWidget(material), GTOreProcessingDisplayCategory.CATEGORY);
this.material = material;
}

@Override
public List<EntryIngredient> getInputEntries() {
List<EntryIngredient> ingredients = new ArrayList<>();
ingredients.add(EntryIngredients.ofItemTag(ChemicalHelper.getTag(ore, material)));
ingredients.add(EntryIngredients.ofItemTag(ChemicalHelper.getTag(rawOre, material)));
return ingredients;
}

@Override
public List<EntryIngredient> getOutputEntries() {
List<EntryIngredient> outputs = new ArrayList<>();
outputs.add(EntryIngredients.ofItemTag(ChemicalHelper.getTag(crushed, material)));
outputs.add(EntryIngredients.ofItemTag(ChemicalHelper.getTag(crushedPurified, material)));
outputs.add(EntryIngredients.ofItemTag(ChemicalHelper.getTag(crushedRefined, material)));
outputs.add(EntryIngredients.ofItemTag(ChemicalHelper.getTag(dust, material)));
outputs.add(EntryIngredients.ofItemTag(ChemicalHelper.getTag(dustImpure, material)));
outputs.add(EntryIngredients.ofItemTag(ChemicalHelper.getTag(dustPure, material)));
return outputs;
}
}
Loading

0 comments on commit 8585280

Please sign in to comment.