Skip to content

Commit

Permalink
Add ore vein diagram. (#556)
Browse files Browse the repository at this point in the history
* Ore Vein Diagram.

* Ore Vein Diagram.

* Ore Vein Diagram.

* Ore Vein Diagram.

* Ore Vein Diagram.

* Ore Vein Diagram.

* Ore Vein Diagram.

* Fix Ore Processing Diagram

Signed-off-by: Arborsm <[email protected]>

* Fix Ore Processing Diagram

Signed-off-by: Arborsm <[email protected]>

---------

Signed-off-by: Arborsm <[email protected]>
Co-authored-by: Arborsm <[email protected]>
  • Loading branch information
Arborsm and Arborsm authored Nov 20, 2023
1 parent f294ee9 commit b157c6a
Show file tree
Hide file tree
Showing 22 changed files with 888 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.gregtechceu.gtceu.data.lang;

import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition;
import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.common.data.GTBedrockFluids;
import com.gregtechceu.gtceu.common.data.GTOres;
import com.tterrag.registrate.providers.RegistrateLangProvider;

public class IntegrationLang {
Expand All @@ -13,6 +18,22 @@ public static void init(RegistrateLangProvider provider) {
private static void initRecipeViewerLang(RegistrateLangProvider provider) {
provider.add("gtceu.jei.multiblock_info", "Multiblock Info");
provider.add("gtceu.jei.ore_processing_diagram", "Ore Processing Diagram");
provider.add("gtceu.jei.ore_vein_diagram", "Ore Vein Diagram");
provider.add("gtceu.jei.bedrock_fluid_diagram", "Bedrock Fluid Diagram");
provider.add("gtceu.jei.ore_vein_diagram.chance", "§eChance: %s§r");
provider.add("gtceu.jei.ore_vein_diagram.spawn_range", "Spawn Range:");
provider.add("gtceu.jei.ore_vein_diagram.weight", "Weight: %s");
provider.add("gtceu.jei.ore_vein_diagram.dimensions", "Dimensions:");
GTOres.init();
for (GTOreDefinition oreDefinition:GTRegistries.ORE_VEINS){
String name = GTRegistries.ORE_VEINS.getKey(oreDefinition).getPath();
provider.add("gtceu.jei.ore_vein." + name, RegistrateLangProvider.toEnglishName(name));
}
GTBedrockFluids.init();
for (BedrockFluidDefinition fluid:GTRegistries.BEDROCK_FLUID_DEFINITIONS){
String name = GTRegistries.BEDROCK_FLUID_DEFINITIONS.getKey(fluid).getPath();
provider.add("gtceu.jei.bedrock_fluid." + name, RegistrateLangProvider.toEnglishName(name));
}
}

/** Jade, TheOneProbe, WTHIT */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package com.gregtechceu.gtceu.integration;

import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition;
import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.lowdragmc.lowdraglib.gui.texture.TextTexture;
import com.lowdragmc.lowdraglib.gui.widget.*;
import com.lowdragmc.lowdraglib.jei.IngredientIO;
import com.lowdragmc.lowdraglib.misc.FluidStorage;
import com.lowdragmc.lowdraglib.misc.ItemStackTransfer;
import com.lowdragmc.lowdraglib.side.fluid.FluidStack;
import com.lowdragmc.lowdraglib.utils.LocalizationUtils;
import lombok.Getter;
import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.heightproviders.HeightProvider;
import net.minecraft.world.level.levelgen.heightproviders.UniformHeight;
import net.minecraft.world.level.material.Fluid;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
* @author Arbor
* @implNote GTOreVeinWidget
*/
@Getter
public class GTOreVeinWidget extends WidgetGroup {
private final String name;
private final int weight;
private final String range;
private final String dimensions;
private final Set<ResourceKey<Level>> dimensionFilter;
public final static int width = 120;

public GTOreVeinWidget(GTOreDefinition oreDefinition) {
super(0, 0, width, 160);
this.name = getOreName(oreDefinition);
this.weight = oreDefinition.getWeight();
this.dimensionFilter = oreDefinition.getDimensionFilter();
this.dimensions = dimensions();
this.range = range(oreDefinition);
setClientSideWidget();
setupBaseGui(oreDefinition);
setupText(oreDefinition);
}

public GTOreVeinWidget(BedrockFluidDefinition fluid) {
super(0, 0, width, 140);
this.name = getFluidName(fluid);
this.weight = fluid.getWeight();
this.dimensionFilter = fluid.getDimensionFilter();
this.dimensions = dimensions();
this.range = "NULL";
setClientSideWidget();
setupBaseGui(fluid);
setupText(fluid);
}

private String range(GTOreDefinition oreDefinition) {
HeightProvider height = oreDefinition.getRange().height;
int minHeight = 0, maxHeight = 0;
if (height instanceof UniformHeight uniform) {
minHeight = uniform.minInclusive.resolveY(null);
maxHeight = uniform.maxInclusive.resolveY(null);
}
return String.format("%d - %d", minHeight, maxHeight);
}

private void setupBaseGui(GTOreDefinition oreDefinition){
NonNullList<ItemStack> containedOresAsItemStacks = NonNullList.create();
List<BlockState> blocks = oreDefinition.getVeinGenerator().getAllBlocks();
List<Integer> chances = oreDefinition.getVeinGenerator().getAllChances();
blocks.forEach(block -> containedOresAsItemStacks.add(block.getBlock().asItem().getDefaultInstance()));
int n = containedOresAsItemStacks.size();
int x = (width - 18 * n) / 2;
for (int i = 0; i < n; i++) {
SlotWidget oreSlot = new SlotWidget(new ItemStackTransfer(containedOresAsItemStacks), i, x, 18, false, false);
int finalI = i;
oreSlot.setOnAddedTooltips((stack, tooltips) ->
tooltips.add(Component.nullToEmpty(LocalizationUtils.format("gtceu.jei.ore_vein_diagram.chance", chances.get(finalI)))));
oreSlot.setIngredientIO(IngredientIO.OUTPUT);
addWidget(oreSlot);
x += 18;
}
}

private void setupBaseGui(BedrockFluidDefinition fluid){
Fluid storedFluid = fluid.getStoredFluid().get();
TankWidget fluidSlot = new TankWidget(
new FluidStorage(FluidStack.create(storedFluid, 1000)), 51, 18, false, false);
fluidSlot.setIngredientIO(IngredientIO.OUTPUT);
addWidget(fluidSlot);
}

private void setupText(GTOreDefinition oreDefinition){
addWidget(new ImageWidget(5, 0, width - 10, 16,
new TextTexture("gtceu.jei.ore_vein." + name).setType(TextTexture.TextType.LEFT_ROLL).setWidth(width - 10)));
addWidget(new LabelWidget(5, 40,
LocalizationUtils.format("gtceu.jei.ore_vein_diagram.spawn_range")));
addWidget(new LabelWidget(5, 50, range));

addWidget(new LabelWidget(5, 60,
LocalizationUtils.format("gtceu.jei.ore_vein_diagram.weight", weight)));
addWidget(new LabelWidget(5, 70,
LocalizationUtils.format("gtceu.jei.ore_vein_diagram.dimensions")));
addWidget(new LabelWidget(5, 80, dimensions));
}

private void setupText(BedrockFluidDefinition fluid){
addWidget(new ImageWidget(5, 0, width - 10, 16,
new TextTexture("gtceu.jei.bedrock_fluid." + name).setType(TextTexture.TextType.LEFT_ROLL).setWidth(width - 10)));
addWidget(new LabelWidget(5, 40,
LocalizationUtils.format("gtceu.jei.ore_vein_diagram.weight", weight)));
addWidget(new LabelWidget(5, 50,
LocalizationUtils.format("gtceu.jei.ore_vein_diagram.dimensions")));
addWidget(new LabelWidget(5, 60, dimensions));
}

private String dimensions() {
if (dimensionFilter == null) return "Any";
return dimensionFilter.stream()
.map(dimension -> dimension.location().toString())
.collect(Collectors.joining("\n"));
}


public String getOreName(GTOreDefinition oreDefinition) {
ResourceLocation id = GTRegistries.ORE_VEINS.getKey(oreDefinition);
return id.getPath();
}

public String getFluidName(BedrockFluidDefinition fluid) {
ResourceLocation id = GTRegistries.BEDROCK_FLUID_DEFINITIONS.getKey(fluid);
return id.getPath();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
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.orevein.GTBedrockFluid;
import com.gregtechceu.gtceu.integration.emi.orevein.GTBedrockFluidEmiCategory;
import com.gregtechceu.gtceu.integration.emi.orevein.GTOreVeinEmiCategory;
import com.gregtechceu.gtceu.integration.emi.recipe.GTRecipeTypeEmiCategory;
import dev.emi.emi.api.EmiEntrypoint;
import dev.emi.emi.api.EmiPlugin;
Expand All @@ -25,6 +28,8 @@ public class GTEMIPlugin implements EmiPlugin {
public void register(EmiRegistry registry) {
registry.addCategory(MultiblockInfoEmiCategory.CATEGORY);
registry.addCategory(GTOreProcessingEmiCategory.CATEGORY);
registry.addCategory(GTOreVeinEmiCategory.CATEGORY);
registry.addCategory(GTBedrockFluidEmiCategory.CATEGORY);
for (RecipeType<?> recipeType : BuiltInRegistries.RECIPE_TYPE) {
if (recipeType instanceof GTRecipeType gtRecipeType) {
registry.addCategory(GTRecipeTypeEmiCategory.CATEGORIES.apply(gtRecipeType));
Expand All @@ -34,10 +39,14 @@ public void register(EmiRegistry registry) {
MultiblockInfoEmiCategory.registerDisplays(registry);
GTRecipeTypeEmiCategory.registerDisplays(registry);
GTOreProcessingEmiCategory.registerDisplays(registry);
GTOreVeinEmiCategory.registerDisplays(registry);
GTBedrockFluidEmiCategory.registerDisplays(registry);
// workstations
MultiblockInfoEmiCategory.registerWorkStations(registry);
GTRecipeTypeEmiCategory.registerWorkStations(registry);
GTOreProcessingEmiCategory.registerWorkStations(registry);
GTOreVeinEmiCategory.registerWorkStations(registry);
GTBedrockFluidEmiCategory.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,28 @@
package com.gregtechceu.gtceu.integration.emi.orevein;

import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.integration.GTOreVeinWidget;
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 GTBedrockFluid extends ModularEmiRecipe<WidgetGroup> {
private final BedrockFluidDefinition fluid;
public GTBedrockFluid(BedrockFluidDefinition fluid) {
super(() -> new GTOreVeinWidget(fluid));
this.fluid = fluid;
}

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

@Override
public @Nullable ResourceLocation getId() {
return GTRegistries.BEDROCK_FLUID_DEFINITIONS.getKey(fluid);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.gregtechceu.gtceu.integration.emi.orevein;

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.common.data.GTItems;
import com.gregtechceu.gtceu.common.data.GTMaterials;
import com.lowdragmc.lowdraglib.emi.ModularUIEmiRecipeCategory;
import dev.emi.emi.api.EmiRegistry;
import dev.emi.emi.api.stack.EmiStack;
import net.minecraft.network.chat.Component;

public class GTBedrockFluidEmiCategory extends ModularUIEmiRecipeCategory {
public static final GTBedrockFluidEmiCategory CATEGORY = new GTBedrockFluidEmiCategory();

public GTBedrockFluidEmiCategory() {
super(GTCEu.id("bedrock_fluid_diagram"), EmiStack.of(GTMaterials.Oil.getFluid().getBucket().asItem()));
}

public static void registerDisplays(EmiRegistry registry) {
for (BedrockFluidDefinition fluid : GTRegistries.BEDROCK_FLUID_DEFINITIONS) {
registry.addRecipe(new GTBedrockFluid(fluid));
}
}

public static void registerWorkStations(EmiRegistry registry) {
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LV.asStack()));
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_HV.asStack()));
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LUV.asStack()));
}

@Override
public Component getName() {
return Component.translatable("gtceu.jei.bedrock_fluid_diagram");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gregtechceu.gtceu.integration.emi.orevein;

import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.integration.GTOreVeinWidget;
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 GTEmiOreVein extends ModularEmiRecipe<WidgetGroup> {
private final GTOreDefinition oreDefinition;

public GTEmiOreVein(GTOreDefinition oreDefinition){
super(() -> new GTOreVeinWidget(oreDefinition));
this.oreDefinition = oreDefinition;
}

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

@Override
public @Nullable ResourceLocation getId() {
return GTRegistries.ORE_VEINS.getKey(oreDefinition);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.gregtechceu.gtceu.integration.emi.orevein;

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.common.data.GTItems;
import com.lowdragmc.lowdraglib.emi.ModularUIEmiRecipeCategory;
import dev.emi.emi.api.EmiRegistry;
import dev.emi.emi.api.stack.EmiStack;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Items;


public class GTOreVeinEmiCategory extends ModularUIEmiRecipeCategory {
public static final GTOreVeinEmiCategory CATEGORY = new GTOreVeinEmiCategory();

public GTOreVeinEmiCategory() {
super(GTCEu.id("ore_vein_diagram"), EmiStack.of(Items.IRON_INGOT));
}

public static void registerDisplays(EmiRegistry registry) {
for (GTOreDefinition oreDefinition : GTRegistries.ORE_VEINS){
registry.addRecipe(new GTEmiOreVein(oreDefinition));
}
}

public static void registerWorkStations(EmiRegistry registry) {
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LV.asStack()));
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_HV.asStack()));
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LUV.asStack()));
}

@Override
public Component getName() {
return Component.translatable("gtceu.jei.ore_vein_diagram");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
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.orevein.GTBedrockFluidInfoCategory;
import com.gregtechceu.gtceu.integration.jei.orevein.GTOreVeinInfoCategory;
import com.gregtechceu.gtceu.integration.jei.recipe.GTRecipeTypeCategory;
import com.lowdragmc.lowdraglib.LDLib;
import mezz.jei.api.IModPlugin;
Expand Down Expand Up @@ -45,6 +47,8 @@ public void registerCategories(@Nonnull IRecipeCategoryRegistration registry) {
IJeiHelpers jeiHelpers = registry.getJeiHelpers();
registry.addRecipeCategories(new MultiblockInfoCategory(jeiHelpers));
registry.addRecipeCategories(new GTOreProcessingInfoCategory(jeiHelpers));
registry.addRecipeCategories(new GTOreVeinInfoCategory(jeiHelpers));
registry.addRecipeCategories(new GTBedrockFluidInfoCategory(jeiHelpers));
for (RecipeType<?> recipeType : BuiltInRegistries.RECIPE_TYPE) {
if (recipeType instanceof GTRecipeType gtRecipeType) {
registry.addRecipeCategories(new GTRecipeTypeCategory(jeiHelpers, gtRecipeType));
Expand All @@ -58,6 +62,8 @@ public void registerRecipeCatalysts(@Nonnull IRecipeCatalystRegistration registr
MultiblockInfoCategory.registerRecipeCatalysts(registration);
GTRecipeTypeCategory.registerRecipeCatalysts(registration);
GTOreProcessingInfoCategory.registerRecipeCatalysts(registration);
GTOreVeinInfoCategory.registerRecipeCatalysts(registration);
GTBedrockFluidInfoCategory.registerRecipeCatalysts(registration);
for (MachineDefinition definition : GTMachines.ELECTRIC_FURNACE) {
if (definition != null) {
registration.addRecipeCatalyst(definition.asStack(), RecipeTypes.SMELTING);
Expand All @@ -76,6 +82,8 @@ public void registerRecipes(@Nonnull IRecipeRegistration registration) {
MultiblockInfoCategory.registerRecipes(registration);
GTRecipeTypeCategory.registerRecipes(registration);
GTOreProcessingInfoCategory.registerRecipes(registration);
GTOreVeinInfoCategory.registerRecipes(registration);
GTBedrockFluidInfoCategory.registerRecipes(registration);
}

@Override
Expand Down
Loading

0 comments on commit b157c6a

Please sign in to comment.