Skip to content

Commit

Permalink
1.2.0 Backport
Browse files Browse the repository at this point in the history
Backported custom catalysts and jei compat from the 1.14 and 1.15 versions
  • Loading branch information
uberifix committed Mar 3, 2020
1 parent ad7bdd0 commit cd29336
Show file tree
Hide file tree
Showing 15 changed files with 454 additions and 32 deletions.
10 changes: 7 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "1.12.2-1.0.0"
version = "1.12.2-1.2.0"
group = "network.pxl8.stonecatalysts"
archivesBaseName = "stonecatalysts"

Expand All @@ -34,11 +34,15 @@ minecraft {
}

repositories {

maven {
name = "Progwml6 maven"
url = "https://dvs1.progwml6.com/files/maven/"
}
}

dependencies {

deobfProvided "mezz.jei:jei_${mc_version}:${jei_version}:api"
runtime "mezz.jei:jei_${mc_version}:${jei_version}"
}

processResources {
Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.jvmargs=-Xmx3G

mc_version=1.12.2
jei_version=4.15.0.293
6 changes: 6 additions & 0 deletions src/main/java/network/pxl8/stonecatalysts/StoneCatalysts.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package network.pxl8.stonecatalysts;

import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import network.pxl8.stonecatalysts.event.StoneGen;
import network.pxl8.stonecatalysts.lib.LibMeta;
import network.pxl8.stonecatalysts.proxy.Proxy;

import java.util.Arrays;

@Mod(modid = LibMeta.MOD_ID, version = LibMeta.VERSION, acceptableRemoteVersions = "*")
public class StoneCatalysts {
@Mod.Instance
Expand All @@ -23,6 +27,8 @@ public void preInit(FMLPreInitializationEvent event) {

@Mod.EventHandler
public void init(FMLInitializationEvent event) {
StoneGen.getCustomCatalysts();
if (Loader.isModLoaded("jei")) { StoneGen.registerJEIRecipes(); }
proxy.init();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package network.pxl8.stonecatalysts.compat.jei;

import com.google.common.collect.Lists;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiFluidStackGroup;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeCategory;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidRegistry;
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 String getUid() {
return StoneCatalystsJEIPlugin.COBBLESTONE_CATALYSTS.toString();
}

@Override
public String getModName() {
return "StoneCatalysts";
}

@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(int mouseX, int 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 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(FluidRegistry.LAVA, 1000));
fluid_group.init(1, false, 37,37);
fluid_group.set(1, new FluidStack(FluidRegistry.WATER, 1000));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package network.pxl8.stonecatalysts.compat.jei;

import com.google.common.collect.Lists;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiFluidStackGroup;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeCategory;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidRegistry;
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 String getUid() {
return StoneCatalystsJEIPlugin.STONE_CATALYSTS.toString();
}

@Override
public String getModName() {
return "StoneCatalysts";
}

@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(int mouseX, int 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 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(FluidRegistry.LAVA, 1000));
fluid_group.init(1, false, 19,37);
fluid_group.set(1, new FluidStack(FluidRegistry.WATER, 1000));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package network.pxl8.stonecatalysts.compat.jei;

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.minecraft.util.ResourceLocation;

public class StoneCatalystRecipe implements IRecipeWrapper {
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;
}

@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInput(VanillaTypes.ITEM, this.catalyst_in);
ingredients.setOutput(VanillaTypes.ITEM, this.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,46 @@
package network.pxl8.stonecatalysts.compat.jei;

import mezz.jei.api.IGuiHelper;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
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 void register(IModRegistry registry) {
registry.addRecipes(STONE_CATALYST_RECIPES.values(), STONE_CATALYSTS.toString());
registry.addRecipes(COBBLESTONE_CATALYST_RECIPES.values(), COBBLESTONE_CATALYSTS.toString());

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

registry.addRecipeCatalyst(new ItemStack(Items.LAVA_BUCKET), STONE_CATALYSTS.toString());
registry.addRecipeCatalyst(new ItemStack(Items.WATER_BUCKET), STONE_CATALYSTS.toString());
registry.addRecipeCatalyst(new ItemStack(Items.LAVA_BUCKET), COBBLESTONE_CATALYSTS.toString());
registry.addRecipeCatalyst(new ItemStack(Items.WATER_BUCKET), COBBLESTONE_CATALYSTS.toString());
}

@Override
public void registerCategories(IRecipeCategoryRegistration registry) {
IGuiHelper guiHelper = registry.getJeiHelpers().getGuiHelper();
registry.addRecipeCategories(
new StoneCatalystCategory(guiHelper),
new CobblestoneCatalystCategory(guiHelper)
);
}
}
42 changes: 37 additions & 5 deletions src/main/java/network/pxl8/stonecatalysts/config/Conf.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,59 @@
package network.pxl8.stonecatalysts.config;

import com.sun.org.apache.xpath.internal.operations.Bool;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import network.pxl8.stonecatalysts.lib.LibMeta;

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

@Config(modid = LibMeta.MOD_ID, name = LibMeta.MOD_ID)
public class Conf {
public static BaseConf base_config = new BaseConf();
public static CompatConf compat_config = new CompatConf();
public static CustomConf custom_config = new CustomConf();

public static class BaseConf {
@Config.Comment({"Replace stone generation (Lava over Water) with the corresponding catalyst"})
public Boolean REPLACE_STONE = true;
@Config.Comment({"Replace cobble generation (Water into Flowing Lava) with the corresponding catalyst"})
public Boolean REPLACE_COBBLE = true;
@Config.Comment("Allow vanilla stone variants as stone generator catalysts (Flowing Lava into Water Source)")
public Boolean VANILLA_VARIANTS_AS_STONE = true;
@Config.Comment("Allow vanilla stone variants as cobble generator catalysts (Water into Flowing Lava)")
public Boolean VANILLA_VARIANTS_AS_COBBLE = true;
}

public static class CompatConf {
@Config.Comment({"Adds quark stones (Basalt, Marble, Limestone, Slate, Jasper) as catalysts"})
public Boolean QUARK_COMPAT = true;
public Boolean ENABLE_QUARK_COMPAT = true;

@Config.Comment("Allow quark stone variants as stone generator catalysts (Flowing Lava into Water Source)")
public Boolean QUARK_VARIANTS_AS_STONE = true;
@Config.Comment("Allow quark stone variants as cobble generator catalysts (Water into Flowing Lava)")
public Boolean QUARK_VARIANTS_AS_COBBLE = true;
}

public static class CustomConf {
@Config.Comment("Add additional stone generator catalysts\n" +
"Usage: Add namespaced ids in the format <namespace:path/meta> as new lines\n" +
"Example: \n" +
"<\n" +
" minecraft:stone/1\n" +
" bluepower:basalt\n" +
">")
public String[] CUSTOM_STONE_CATALYSTS = new String[] {};
@Config.Comment("Add additional stone generator catalysts\n" +
"Usage: Add namespaced ids in the format <namespace:path/meta> as new lines\n" +
"Example: \n" +
"<\n" +
" minecraft:stone/1\n" +
" bluepower:basalt\n" +
">")
public String[] CUSTOM_COBBLE_CATALYSTS = new String[] {};

@Config.Comment("Prints debug messages to the log for each custom catalyst added")
public Boolean DEBUG_MESSAGES = true;
}

@Mod.EventBusSubscriber
Expand Down
Loading

0 comments on commit cd29336

Please sign in to comment.