Skip to content

Commit

Permalink
1.2.0 Update - JEI Integration
Browse files Browse the repository at this point in the history
Added jei integration
- Can now see catalysts in jei making it easier for players to know what catalysts exists
Split stone and cobble generation
- Seperated stone and cobble gens
- Can now choose whether variants generate from a stone or a cobble gen
- Can add custom catalysts seperately, letting you add mod blocks as cobble and as stone
  • Loading branch information
uberifix committed Mar 2, 2020
1 parent 05adc66 commit f5a572d
Show file tree
Hide file tree
Showing 12 changed files with 398 additions and 35 deletions.
12 changes: 10 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = "1.14.4-1.1.0"
version = "1.14.4-1.2.0"
group = "network.pxl8.stonecatalysts"
archivesBaseName = "stonecatalysts"

Expand Down Expand Up @@ -72,12 +72,20 @@ repositories {
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
maven {
name = "Progwml6 maven"
url = "https://dvs1.progwml6.com/files/maven/"
}
}

dependencies {
minecraft 'net.minecraftforge:forge:1.14.4-28.2.0'

compileOnly "quark:Quark:r2.0:210"
compileOnly fg.deobf("quark:Quark:r2.0:210")
runtimeOnly fg.deobf("quark:Quark:r2.0:210")
runtimeOnly fg.deobf("autoreglib:AutoRegLib:1.4:35")
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}")
}

jar {
Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.daemon=false

minecraft_version=1.14.4
jei_version=6.0.0.27
2 changes: 2 additions & 0 deletions src/main/java/network/pxl8/stonecatalysts/StoneCatalysts.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package network.pxl8.stonecatalysts;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
Expand All @@ -27,5 +28,6 @@ private void setup(FMLCommonSetupEvent event) { }

private void serverStart(FMLServerStartingEvent event) {
StoneGen.getCustomCatalysts();
if(ModList.get().isLoaded("jei")) { StoneGen.registerJEIRecipes(); }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package network.pxl8.stonecatalysts.compat.jei;

import com.google.common.collect.Lists;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IGuiFluidStackGroup;
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.resources.I18n;
import net.minecraft.fluid.Fluids;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import network.pxl8.stonecatalysts.lib.LibMeta;

import java.util.Collections;
import java.util.List;

public class CobblestoneCatalystCategory implements IRecipeCategory<StoneCatalystRecipe> {
private final IDrawable background;

public CobblestoneCatalystCategory(IGuiHelper guiHelper) {
this.background = guiHelper.createDrawable(new ResourceLocation(LibMeta.MOD_ID, "textures/gui/jei/cobblestone_gen.png"), 0, 0, 117, 74);
}

@Override
public ResourceLocation getUid() {
return StoneCatalystsJEIPlugin.COBBLESTONE_CATALYSTS;
}

@Override
public Class<? extends StoneCatalystRecipe> getRecipeClass() {
return StoneCatalystRecipe.class;
}

@Override
public String getTitle() {
return I18n.format("jei." + StoneCatalystsJEIPlugin.COBBLESTONE_CATALYSTS);
}

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

@Override
public IDrawable getIcon() {
return null;
}

@Override
public List<String> getTooltipStrings(StoneCatalystRecipe recipe, double mouseX, double mouseY) {
String output_tooltip = I18n.format("jei.stonecatalysts:tooltip_cobblestone_catalyst");
String arrow_tooltip = I18n.format("jei.stonecatalysts:tooltip_flowing_lava");
if (mouseX > 58 && mouseX < 81 && mouseY > 36 && mouseY < 52) {
return Lists.newArrayList(output_tooltip.split(","));
}
if (mouseX > 18 && mouseX < 35 && mouseY > 36 && mouseY < 53) {
return Lists.newArrayList(arrow_tooltip.split(","));
}
return Collections.emptyList();
}

@Override
public void setIngredients(StoneCatalystRecipe catalystRecipe, IIngredients ingredients) {
ingredients.setInput(VanillaTypes.ITEM, catalystRecipe.catalyst_in);
ingredients.setOutput(VanillaTypes.ITEM, catalystRecipe.catalyst_out);
}

@Override
public void setRecipe(IRecipeLayout layout, StoneCatalystRecipe recipe, IIngredients ingredients) {
IGuiItemStackGroup group = layout.getItemStacks();
IGuiFluidStackGroup fluid_group = layout.getFluidStacks();
//Catalyst input and output
group.init(0, false, 18, 55);
group.set(0, recipe.catalyst_in);
group.init(1, false, 94, 36);
group.set(1, recipe.catalyst_out);
//Lava and Water
fluid_group.init(0, false, 1, 37);
fluid_group.set(0, new FluidStack(Fluids.LAVA, 1000));
fluid_group.init(1, false, 37,37);
fluid_group.set(1, new FluidStack(Fluids.WATER, 1000));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package network.pxl8.stonecatalysts.compat.jei;

import com.google.common.collect.Lists;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IGuiFluidStackGroup;
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.resources.I18n;
import net.minecraft.fluid.Fluids;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import network.pxl8.stonecatalysts.lib.LibMeta;

import java.util.Collections;
import java.util.List;


public class StoneCatalystCategory implements IRecipeCategory<StoneCatalystRecipe> {
private final IDrawable background;

public StoneCatalystCategory(IGuiHelper guiHelper) {
this.background = guiHelper.createDrawable(new ResourceLocation(LibMeta.MOD_ID, "textures/gui/jei/stone_gen.png"), 0, 0, 117, 74);
}

@Override
public ResourceLocation getUid() {
return StoneCatalystsJEIPlugin.STONE_CATALYSTS;
}

@Override
public Class<? extends StoneCatalystRecipe> getRecipeClass() {
return StoneCatalystRecipe.class;
}

@Override
public String getTitle() {
return I18n.format("jei." + StoneCatalystsJEIPlugin.STONE_CATALYSTS);
}

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

@Override
public IDrawable getIcon() {
return null;
}

@Override
public List<String> getTooltipStrings(StoneCatalystRecipe recipe, double mouseX, double mouseY) {
String output_tooltip = I18n.format("jei.stonecatalysts:tooltip_stone_catalyst");
String arrow_tooltip = I18n.format("jei.stonecatalysts:tooltip_flowing_lava");
if (mouseX > 58 && mouseX < 81 && mouseY > 36 && mouseY < 52) {
return Lists.newArrayList(output_tooltip.split(","));
}
if (mouseX > 18 && mouseX < 35 && mouseY > 18 && mouseY < 35) {
return Lists.newArrayList(arrow_tooltip.split(","));
}
return Collections.emptyList();
}

@Override
public void setIngredients(StoneCatalystRecipe catalystRecipe, IIngredients ingredients) {
ingredients.setInput(VanillaTypes.ITEM, catalystRecipe.catalyst_in);
ingredients.setOutput(VanillaTypes.ITEM, catalystRecipe.catalyst_out);
}

@Override
public void setRecipe(IRecipeLayout layout, StoneCatalystRecipe recipe, IIngredients ingredients) {
IGuiItemStackGroup group = layout.getItemStacks();
IGuiFluidStackGroup fluid_group = layout.getFluidStacks();
//Catalyst input and output
group.init(0, false, 18, 55);
group.set(0, recipe.catalyst_in);
group.init(1, false, 94, 36);
group.set(1, recipe.catalyst_out);
//Lava and Water
fluid_group.init(0, false, 19, 1);
fluid_group.set(0, new FluidStack(Fluids.LAVA, 1000));
fluid_group.init(1, false, 19,37);
fluid_group.set(1, new FluidStack(Fluids.WATER, 1000));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package network.pxl8.stonecatalysts.compat.jei;

import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

public class StoneCatalystRecipe {
public final ResourceLocation name;
public final ItemStack catalyst_in;
public final ItemStack catalyst_out;

public StoneCatalystRecipe(ResourceLocation name, ItemStack catalyst) {
this(name, catalyst, catalyst);
}

public StoneCatalystRecipe(ResourceLocation name, ItemStack catalyst_in, ItemStack catalyst_out) {
this.name = name;
this.catalyst_in = catalyst_in;
this.catalyst_out = catalyst_out;
}

public StoneCatalystRecipe registerStone() {
StoneCatalystsJEIPlugin.STONE_CATALYST_RECIPES.put(this.name, this);
return this;
}

public StoneCatalystRecipe registerCobblestone() {
StoneCatalystsJEIPlugin.COBBLESTONE_CATALYST_RECIPES.put(this.name, this);
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package network.pxl8.stonecatalysts.compat.jei;

import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.registration.IRecipeCatalystRegistration;
import mezz.jei.api.registration.IRecipeCategoryRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ResourceLocation;
import network.pxl8.stonecatalysts.lib.LibMeta;

import java.util.HashMap;
import java.util.Map;

@JeiPlugin
public class StoneCatalystsJEIPlugin implements IModPlugin {
public static final ResourceLocation STONE_CATALYSTS = new ResourceLocation(LibMeta.MOD_ID, "category_stone_gen");
public static final ResourceLocation COBBLESTONE_CATALYSTS = new ResourceLocation(LibMeta.MOD_ID, "category_cobblestone_gen");
public static final Map<ResourceLocation, StoneCatalystRecipe> STONE_CATALYST_RECIPES = new HashMap<>();
public static final Map<ResourceLocation, StoneCatalystRecipe> COBBLESTONE_CATALYST_RECIPES = new HashMap<>();

@Override
public ResourceLocation getPluginUid() {
return new ResourceLocation(LibMeta.MOD_ID, "jei_plugin");
}

@Override
public void registerCategories(IRecipeCategoryRegistration registration) {
IGuiHelper guiHelper = registration.getJeiHelpers().getGuiHelper();
registration.addRecipeCategories(
new StoneCatalystCategory(guiHelper),
new CobblestoneCatalystCategory(guiHelper)
);
}

@Override
public void registerRecipes(IRecipeRegistration registration) {
registration.addRecipes(STONE_CATALYST_RECIPES.values(), STONE_CATALYSTS);
registration.addRecipes(COBBLESTONE_CATALYST_RECIPES.values(), COBBLESTONE_CATALYSTS);

registration.addIngredientInfo(new ItemStack(Items.LAVA_BUCKET), VanillaTypes.ITEM, I18n.format("jei.stonecatalysts:information_tab_desc"));
}

@Override
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
registration.addRecipeCatalyst(new ItemStack(Items.LAVA_BUCKET), STONE_CATALYSTS);
registration.addRecipeCatalyst(new ItemStack(Items.WATER_BUCKET), STONE_CATALYSTS);
registration.addRecipeCatalyst(new ItemStack(Items.LAVA_BUCKET), COBBLESTONE_CATALYSTS);
registration.addRecipeCatalyst(new ItemStack(Items.WATER_BUCKET), COBBLESTONE_CATALYSTS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ public class Configuration {
private static final ForgeConfigSpec.Builder COMMON_BUILDER = new ForgeConfigSpec.Builder();
public static ForgeConfigSpec COMMON_CONFIG;

public static ForgeConfigSpec.BooleanValue REPLACE_STONE;
public static ForgeConfigSpec.BooleanValue REPLACE_COBBLE;
public static ForgeConfigSpec.BooleanValue VANILLA_VARIANTS_AS_STONE;
public static ForgeConfigSpec.BooleanValue VANILLA_VARIANTS_AS_COBBLE;

public static ForgeConfigSpec.BooleanValue ENABLE_QUARK_COMPAT;
public static ForgeConfigSpec.BooleanValue QUARK_VARIANTS_AS_STONE;
public static ForgeConfigSpec.BooleanValue QUARK_VARIANTS_AS_COBBLE;

public static ForgeConfigSpec.ConfigValue<List<String>> CUSTOM_CATALYSTS;
public static ForgeConfigSpec.ConfigValue<List<String>> CUSTOM_STONE_CATALYSTS;
public static ForgeConfigSpec.ConfigValue<List<String>> CUSTOM_COBBLE_CATALYSTS;
public static ForgeConfigSpec.BooleanValue DEBUG_MESSAGES;

static {
Expand All @@ -34,24 +37,30 @@ public class Configuration {
}

private static void setupBaseConfig() {
REPLACE_STONE = COMMON_BUILDER.comment("Replace stone generation (Lava over Water) with the corresponding catalyst")
.define("REPLACE_STONE", true);
REPLACE_COBBLE = COMMON_BUILDER.comment("Replace cobble generation (Water into Flowing Lava) with the corresponding catalyst")
.define("REPLACE_COBBLE", true);
VANILLA_VARIANTS_AS_STONE = COMMON_BUILDER.comment("Allow vanilla stone variants as stone generator catalysts (Flowing Lava into Water Source)")
.define("VANILLA_VARIANTS_AS_STONE", true);
VANILLA_VARIANTS_AS_COBBLE = COMMON_BUILDER.comment("Allow vanilla stone variants as cobble generator catalysts (Water into Flowing Lava)")
.define("VANILLA_VARIANTS_AS_COBBLE", true);
COMMON_BUILDER.pop();
}

private static void setupCompatConfig() {
ENABLE_QUARK_COMPAT = COMMON_BUILDER.comment("Adds quark stones (Basalt, Marble, Limestone, Slate, Jasper) as catalysts")
.define("ENABLE_QUARK_COMPAT", true);
QUARK_VARIANTS_AS_STONE = COMMON_BUILDER.comment("Allow quark stone variants as stone generator catalysts (Flowing Lava into Water Source)")
.define("QUARK_VARIANTS_AS_STONE", true);
QUARK_VARIANTS_AS_COBBLE = COMMON_BUILDER.comment("Allow quark stone variants as cobble generator catalysts (Water into Flowing Lava)")
.define("QUARK_VARIANTS_AS_COBBLE", true);
COMMON_BUILDER.pop();
}

private static void setupCustomConfig() {
List<String> catalysts = new ArrayList<>();
CUSTOM_STONE_CATALYSTS = COMMON_BUILDER.comment("Add additional stone generator catalysts", "Usage: Add namespaced ids in \"\" seperated by commas", "Example: [\"minecraft:netherrack\", \"quark:brimstone\"]")
.define("CUSTOM_STONE_CATALYSTS", catalysts);
CUSTOM_COBBLE_CATALYSTS = COMMON_BUILDER.comment("Add additional cobble generator catalysts", "Usage: Add namespaced ids in \"\" seperated by commas", "Example: [\"minecraft:netherrack\", \"quark:brimstone\"]")
.define("CUSTOM_COBBLE_CATALYSTS", catalysts);

CUSTOM_CATALYSTS = COMMON_BUILDER.comment("Add additional catalysts", "Usage: Add namespaced ids in \"\" seperated by commas", "Example: [\"minecraft:netherrack\", \"quark:brimstone\"]")
.define("CUSTOM_CATALYSTS", catalysts);
DEBUG_MESSAGES = COMMON_BUILDER.comment("Prints debug messages to the log for each custom catalyst added")
.define("DEBUG_MESSAGES", true);
COMMON_BUILDER.pop();
Expand Down
Loading

0 comments on commit f5a572d

Please sign in to comment.