diff --git a/build.gradle b/build.gradle index 9fe07fc..576b9d7 100644 --- a/build.gradle +++ b/build.gradle @@ -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" @@ -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 { diff --git a/gradle.properties b/gradle.properties index 659b74c..bcf6761 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,4 @@ -org.gradle.jvmargs=-Xmx3G \ No newline at end of file +org.gradle.jvmargs=-Xmx3G + +mc_version=1.12.2 +jei_version=4.15.0.293 \ No newline at end of file diff --git a/src/main/java/network/pxl8/stonecatalysts/StoneCatalysts.java b/src/main/java/network/pxl8/stonecatalysts/StoneCatalysts.java index 9613469..cd4870c 100644 --- a/src/main/java/network/pxl8/stonecatalysts/StoneCatalysts.java +++ b/src/main/java/network/pxl8/stonecatalysts/StoneCatalysts.java @@ -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 @@ -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(); } diff --git a/src/main/java/network/pxl8/stonecatalysts/compat/jei/CobblestoneCatalystCategory.java b/src/main/java/network/pxl8/stonecatalysts/compat/jei/CobblestoneCatalystCategory.java new file mode 100644 index 0000000..f889acd --- /dev/null +++ b/src/main/java/network/pxl8/stonecatalysts/compat/jei/CobblestoneCatalystCategory.java @@ -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 { + 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 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)); + } +} diff --git a/src/main/java/network/pxl8/stonecatalysts/compat/jei/StoneCatalystCategory.java b/src/main/java/network/pxl8/stonecatalysts/compat/jei/StoneCatalystCategory.java new file mode 100644 index 0000000..3b96f72 --- /dev/null +++ b/src/main/java/network/pxl8/stonecatalysts/compat/jei/StoneCatalystCategory.java @@ -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 { + 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 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)); + } +} diff --git a/src/main/java/network/pxl8/stonecatalysts/compat/jei/StoneCatalystRecipe.java b/src/main/java/network/pxl8/stonecatalysts/compat/jei/StoneCatalystRecipe.java new file mode 100644 index 0000000..07d7cf7 --- /dev/null +++ b/src/main/java/network/pxl8/stonecatalysts/compat/jei/StoneCatalystRecipe.java @@ -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; + } +} diff --git a/src/main/java/network/pxl8/stonecatalysts/compat/jei/StoneCatalystsJEIPlugin.java b/src/main/java/network/pxl8/stonecatalysts/compat/jei/StoneCatalystsJEIPlugin.java new file mode 100644 index 0000000..efc821c --- /dev/null +++ b/src/main/java/network/pxl8/stonecatalysts/compat/jei/StoneCatalystsJEIPlugin.java @@ -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 STONE_CATALYST_RECIPES = new HashMap<>(); + public static final Map 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) + ); + } +} diff --git a/src/main/java/network/pxl8/stonecatalysts/config/Conf.java b/src/main/java/network/pxl8/stonecatalysts/config/Conf.java index 294318c..02dfaaa 100644 --- a/src/main/java/network/pxl8/stonecatalysts/config/Conf.java +++ b/src/main/java/network/pxl8/stonecatalysts/config/Conf.java @@ -1,5 +1,6 @@ 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; @@ -7,21 +8,52 @@ 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 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 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 diff --git a/src/main/java/network/pxl8/stonecatalysts/event/StoneGen.java b/src/main/java/network/pxl8/stonecatalysts/event/StoneGen.java index 52b8248..6c826b1 100644 --- a/src/main/java/network/pxl8/stonecatalysts/event/StoneGen.java +++ b/src/main/java/network/pxl8/stonecatalysts/event/StoneGen.java @@ -4,14 +4,22 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import network.pxl8.stonecatalysts.compat.jei.StoneCatalystRecipe; import network.pxl8.stonecatalysts.config.Conf; +import network.pxl8.stonecatalysts.lib.LibMeta; import network.pxl8.stonecatalysts.lib.LibTools; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + @Mod.EventBusSubscriber public class StoneGen { @SubscribeEvent @@ -21,32 +29,125 @@ public static void genStone(BlockEvent.FluidPlaceBlockEvent event) { Block oldBlock = event.getOriginalState().getBlock(); Block newBlock = event.getNewState().getBlock(); - if (Conf.base_config.REPLACE_STONE && oldBlock.equals(Blocks.WATER) && newBlock.equals(Blocks.STONE)) { + if (oldBlock.equals(Blocks.WATER) && newBlock.equals(Blocks.STONE)) { IBlockState catalyst = event.getWorld().getBlockState(new BlockPos(x, y - 2, z)); - doReplacements(event, catalyst); + doStoneReplacements(event, catalyst); } - if (Conf.base_config.REPLACE_COBBLE && oldBlock.equals(Blocks.FLOWING_LAVA) && newBlock.equals(Blocks.COBBLESTONE)) { + if (oldBlock.equals(Blocks.FLOWING_LAVA) && newBlock.equals(Blocks.COBBLESTONE)) { IBlockState catalyst = event.getWorld().getBlockState(new BlockPos(x, y - 1, z)); - doReplacements(event, catalyst); + doCobbleReplacements(event, catalyst); + } + } + + private static void replaceBlock(BlockEvent.FluidPlaceBlockEvent event, IBlockState catalyst, IBlockState replace) { + if (catalyst.equals(replace)) { event.setNewState(replace); } + } + + private static void doStoneReplacements(BlockEvent.FluidPlaceBlockEvent event, IBlockState catalyst) { + if(!StoneGen.customStoneCatalysts.isEmpty()) { + for(IBlockState block : StoneGen.customStoneCatalysts) { + replaceBlock(event, catalyst, block); + } } } - private static void replaceBlock(BlockEvent.FluidPlaceBlockEvent event, IBlockState catalyst, String replace) { - if (catalyst.equals(LibTools.getStateFromString(replace))) { event.setNewState(LibTools.getStateFromString(replace)); } + private static void doCobbleReplacements(BlockEvent.FluidPlaceBlockEvent event, IBlockState catalyst) { + if(!StoneGen.customCobbleCatalysts.isEmpty()) { + for(IBlockState block : StoneGen.customCobbleCatalysts) { + replaceBlock(event, catalyst, block); + } + } + } + + private static List customStoneCatalysts = new ArrayList<>(); + private static List customCobbleCatalysts = new ArrayList<>(); + + public static void getCustomCatalysts() { + if(!Arrays.asList(Conf.custom_config.CUSTOM_STONE_CATALYSTS).isEmpty()) { + for(String catalyst : Arrays.asList(Conf.custom_config.CUSTOM_STONE_CATALYSTS)) { + if (LibTools.getStateFromString(catalyst) == null) { + LibMeta.LOG.warn("Failed to add catalyst from: " + catalyst); + } else { + IBlockState block = LibTools.getStateFromString(catalyst); + if (!block.getBlock().equals(Blocks.AIR)) { + customStoneCatalysts.add(block); + if(Conf.custom_config.DEBUG_MESSAGES) { LibMeta.LOG.info("Added custom stone catalyst: " + block.toString()); } + } else { + LibMeta.LOG.warn("Unable to get block from string. Check if namespace and path are spelled correctly or meta is right"); + LibMeta.LOG.warn("Failed to add catalyst from: " + catalyst); + } + } + } + } + if(!Arrays.asList(Conf.custom_config.CUSTOM_COBBLE_CATALYSTS).isEmpty()) { + for(String catalyst : Arrays.asList(Conf.custom_config.CUSTOM_COBBLE_CATALYSTS)) { + if (LibTools.getStateFromString(catalyst) == null) { + LibMeta.LOG.warn("Failed to add catalyst from: " + catalyst); + } else { + IBlockState block = LibTools.getStateFromString(catalyst); + if (!block.getBlock().equals(Blocks.AIR)) { + customCobbleCatalysts.add(block); + if(Conf.custom_config.DEBUG_MESSAGES) { LibMeta.LOG.info("Added custom cobble catalyst: " + block.toString()); } + } else { + LibMeta.LOG.warn("Unable to get block from string. Check if namespace and path are spelled correctly or meta is right"); + LibMeta.LOG.warn("Failed to add catalyst from: " + catalyst); + } + } + } + } + + if (Conf.base_config.VANILLA_VARIANTS_AS_STONE) { + customStoneCatalysts.add(LibTools.getStateFromString("minecraft:stone/1")); + customStoneCatalysts.add(LibTools.getStateFromString("minecraft:stone/3")); + customStoneCatalysts.add(LibTools.getStateFromString("minecraft:stone/5")); + } + if (Conf.base_config.VANILLA_VARIANTS_AS_COBBLE) { + customCobbleCatalysts.add(LibTools.getStateFromString("minecraft:stone/1")); + customCobbleCatalysts.add(LibTools.getStateFromString("minecraft:stone/3")); + customCobbleCatalysts.add(LibTools.getStateFromString("minecraft:stone/5")); + } + + if(Loader.isModLoaded("quark") && Conf.compat_config.ENABLE_QUARK_COMPAT && Conf.compat_config.QUARK_VARIANTS_AS_STONE) { + customStoneCatalysts.add(LibTools.getStateFromString("quark:marble")); + customStoneCatalysts.add(LibTools.getStateFromString("quark:limestone")); + customStoneCatalysts.add(LibTools.getStateFromString("quark:jasper")); + customStoneCatalysts.add(LibTools.getStateFromString("quark:slate")); + customStoneCatalysts.add(LibTools.getStateFromString("quark:basalt")); + } + + if(Loader.isModLoaded("quark") && Conf.compat_config.ENABLE_QUARK_COMPAT && Conf.compat_config.QUARK_VARIANTS_AS_COBBLE) { + customCobbleCatalysts.add(LibTools.getStateFromString("quark:marble")); + customCobbleCatalysts.add(LibTools.getStateFromString("quark:limestone")); + customCobbleCatalysts.add(LibTools.getStateFromString("quark:jasper")); + customCobbleCatalysts.add(LibTools.getStateFromString("quark:slate")); + customCobbleCatalysts.add(LibTools.getStateFromString("quark:basalt")); + } } - private static void doReplacements(BlockEvent.FluidPlaceBlockEvent event, IBlockState catalyst) { - replaceBlock(event, catalyst, "minecraft:stone/1"); - replaceBlock(event, catalyst, "minecraft:stone/3"); - replaceBlock(event, catalyst, "minecraft:stone/5"); - - if(Loader.isModLoaded("quark") && Conf.compat_config.QUARK_COMPAT) { - replaceBlock(event, catalyst, "quark:basalt"); - replaceBlock(event, catalyst, "quark:marble"); - replaceBlock(event, catalyst, "quark:limestone"); - replaceBlock(event, catalyst, "quark:slate"); - replaceBlock(event, catalyst, "quark:jasper"); + public static void registerJEIRecipes() { + ItemStack noCatalyst = new ItemStack(Blocks.BARRIER).setStackDisplayName("No Catalyst"); + new StoneCatalystRecipe(new ResourceLocation(LibMeta.MOD_ID, "default_stonegen"), noCatalyst, new ItemStack(Blocks.STONE)).registerStone(); + new StoneCatalystRecipe(new ResourceLocation(LibMeta.MOD_ID, "default_cobblegen"), noCatalyst, new ItemStack(Blocks.COBBLESTONE)).registerCobblestone(); + + if(!StoneGen.customStoneCatalysts.isEmpty()) { + int count = 0; + for(IBlockState state : StoneGen.customStoneCatalysts) { + count++; + Block block = state.getBlock(); + String resource_path = block.getRegistryName().getResourceDomain() + "_" + block.getRegistryName().getResourcePath() + "_stonegen" + count; + new StoneCatalystRecipe(new ResourceLocation(LibMeta.MOD_ID, resource_path), new ItemStack(block, 1, block.getMetaFromState(state))).registerStone(); + } + } + + if(!StoneGen.customCobbleCatalysts.isEmpty()) { + int count = 0; + for(IBlockState state : StoneGen.customCobbleCatalysts) { + count++; + Block block = state.getBlock(); + String resource_path = block.getRegistryName().getResourceDomain() + "_" + block.getRegistryName().getResourcePath() + "_cobblegen" + count; + new StoneCatalystRecipe(new ResourceLocation(LibMeta.MOD_ID, resource_path), new ItemStack(block, 1, block.getMetaFromState(state))).registerCobblestone(); + } } } } diff --git a/src/main/java/network/pxl8/stonecatalysts/lib/LibMeta.java b/src/main/java/network/pxl8/stonecatalysts/lib/LibMeta.java index 7ec38d0..959333b 100644 --- a/src/main/java/network/pxl8/stonecatalysts/lib/LibMeta.java +++ b/src/main/java/network/pxl8/stonecatalysts/lib/LibMeta.java @@ -5,7 +5,7 @@ public class LibMeta { public static final String MOD_ID = "stonecatalysts"; - public static final String VERSION = "1.0.0"; + public static final String VERSION = "1.2.0"; public static final Logger LOG = LogManager.getLogger(MOD_ID); diff --git a/src/main/java/network/pxl8/stonecatalysts/lib/LibTools.java b/src/main/java/network/pxl8/stonecatalysts/lib/LibTools.java index c68eda7..0bf8104 100644 --- a/src/main/java/network/pxl8/stonecatalysts/lib/LibTools.java +++ b/src/main/java/network/pxl8/stonecatalysts/lib/LibTools.java @@ -1,17 +1,30 @@ package network.pxl8.stonecatalysts.lib; -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.ForgeRegistries; public class LibTools { public static IBlockState getStateFromString(String block) { String[] blockSplit = block.split("/"); - IBlockState blockState = null; + ResourceLocation id = new ResourceLocation(blockSplit[0]); + int meta; + IBlockState blockState; + + if (blockSplit.length > 2) { + LibMeta.LOG.warn("Improperly formatted custom catalyst, please check your config. Proper syntax is . Too many arguments found"); + return null; + } if (blockSplit.length == 2) { - blockState = Block.getBlockFromName(blockSplit[0]).getStateFromMeta(Integer.parseInt(blockSplit[1])); - } else if (blockSplit.length == 1) { - blockState = Block.getBlockFromName(blockSplit[0]).getDefaultState(); + try { meta = Integer.parseInt(blockSplit[1]); + } catch (NumberFormatException e) { + LibMeta.LOG.warn("Improperly formatted custom catalyst, please check your config. Proper syntax is . Meta needs to be an integer"); + return null; + } + blockState = ForgeRegistries.BLOCKS.getValue(id).getStateFromMeta(meta); + } else { + blockState = ForgeRegistries.BLOCKS.getValue(id).getDefaultState(); } return blockState; diff --git a/src/main/resources/assets/stonecatalysts/lang/en_us.json b/src/main/resources/assets/stonecatalysts/lang/en_us.json new file mode 100644 index 0000000..a9f4ac0 --- /dev/null +++ b/src/main/resources/assets/stonecatalysts/lang/en_us.json @@ -0,0 +1,10 @@ +{ + "jei.stonecatalysts:category_stone_gen": "Stone Catalysts", + "jei.stonecatalysts:category_cobblestone_gen": "Cobblestone Catalysts", + + "jei.stonecatalysts:tooltip_flowing_lava": "Flowing Lava", + "jei.stonecatalysts:tooltip_stone_catalyst": "Stone Catalyst, ,Replaces water source when hit by flowing lava above, ,Place catalyst below water source", + "jei.stonecatalysts:tooltip_cobblestone_catalyst": "Cobblestone Catalyst, ,Replaces lava flow when it touches water, ,Place catalyst below lava flow", + + "jei.stonecatalysts:information_tab_desc": "StoneCatalysts allows generation of alternate stone variants with a standard cobble gen. Simply place the catalyst below where the stone or cobble block would normally generate and the block will instead generate as the same block as the catalyst" +} \ No newline at end of file diff --git a/src/main/resources/assets/stonecatalysts/lang/en_us.lang b/src/main/resources/assets/stonecatalysts/lang/en_us.lang new file mode 100644 index 0000000..11c9422 --- /dev/null +++ b/src/main/resources/assets/stonecatalysts/lang/en_us.lang @@ -0,0 +1,8 @@ +jei.stonecatalysts:category_stone_gen=Stone Catalysts +jei.stonecatalysts:category_cobblestone_gen=Cobblestone Catalysts + +jei.stonecatalysts:tooltip_flowing_lava=Flowing Lava +jei.stonecatalysts:tooltip_stone_catalyst=Stone Catalyst, ,Replaces water source when hit by flowing lava above, ,Place catalyst below water source +jei.stonecatalysts:tooltip_cobblestone_catalyst=Cobblestone Catalyst, ,Replaces lava flow when it touches water, ,Place catalyst below lava flow + +jei.stonecatalysts:information_tab_desc=StoneCatalysts allows generation of alternate stone variants with a standard cobble gen. Simply place the catalyst below where the stone or cobble block would normally generate and the block will instead generate as the same block as the catalyst \ No newline at end of file diff --git a/src/main/resources/assets/stonecatalysts/textures/gui/jei/cobblestone_gen.png b/src/main/resources/assets/stonecatalysts/textures/gui/jei/cobblestone_gen.png new file mode 100644 index 0000000..827e069 Binary files /dev/null and b/src/main/resources/assets/stonecatalysts/textures/gui/jei/cobblestone_gen.png differ diff --git a/src/main/resources/assets/stonecatalysts/textures/gui/jei/stone_gen.png b/src/main/resources/assets/stonecatalysts/textures/gui/jei/stone_gen.png new file mode 100644 index 0000000..14f25fc Binary files /dev/null and b/src/main/resources/assets/stonecatalysts/textures/gui/jei/stone_gen.png differ