Skip to content

Commit

Permalink
Fix Some Recipes Being Out of Reach of CraftTweaker (#133)
Browse files Browse the repository at this point in the history
Partially addresses #84
  • Loading branch information
serenibyss authored May 6, 2021
1 parent 0e3fcf9 commit 857fd5a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 72 deletions.
13 changes: 9 additions & 4 deletions src/main/java/gregicadditions/GregicAdditions.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import forestry.api.core.ForestryAPI;
import forestry.core.config.Constants;
import forestry.modules.ForestryModuleUids;
import gregicadditions.bees.*;
import net.minecraft.util.ResourceLocation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import gregicadditions.bees.CommonProxy;
import gregicadditions.bees.GTBees;
import gregicadditions.item.GAMetaBlocks;
import gregicadditions.item.GAMetaItems;
import gregicadditions.machines.GATileEntities;
Expand Down Expand Up @@ -38,7 +37,7 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistry;

@Mod(modid = GregicAdditions.MODID, name = GregicAdditions.NAME, version = GregicAdditions.VERSION, dependencies = "required-after:gregtech@[1.14.0.689,);after:forestry;after:tconstruct")
@Mod(modid = GregicAdditions.MODID, name = GregicAdditions.NAME, version = GregicAdditions.VERSION, dependencies = "required-after:gregtech@[1.14.0.689,);after:forestry;after:tconstruct;")
public class GregicAdditions {
public static final String MODID = "gtadditions";
public static final String NAME = "Shadows of Greg";
Expand Down Expand Up @@ -77,7 +76,6 @@ public void init(FMLInitializationEvent event) {

@EventHandler
public void postInit(FMLPostInitializationEvent event) {
GARecipeAddition.generatedRecipes();
if (!isForestryBeesDisabled())
proxy.postInit();
}
Expand All @@ -94,6 +92,9 @@ public void registerItems(RegistryEvent.Register<Item> event) {
IForgeRegistry<Item> registry = event.getRegistry();
registry.register(createItemBlock(GAMetaBlocks.MUTLIBLOCK_CASING, VariantItemBlock::new));
registry.register(createItemBlock(GAMetaBlocks.TRANSPARENT_CASING, VariantItemBlock::new));
if (!isForestryBeesDisabled()) {
registry.register(GTCombs.combItem);
}
}

@SubscribeEvent(priority = EventPriority.LOW)
Expand All @@ -107,6 +108,10 @@ public void registerRecipes(RegistryEvent.Register<IRecipe> event) {
GeneratorFuels.init();
GAMetaItems.registerOreDict();
GAMetaItems.registerRecipes();
GARecipeAddition.generatedRecipes();
if (!isForestryBeesDisabled()) {
GTMachineCombRecipes.init();
}
}

private <T extends Block> ItemBlock createItemBlock(T block, Function<T, ItemBlock> producer) {
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/gregicadditions/bees/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import forestry.api.core.ForestryAPI;
import forestry.core.items.IColoredItem;
import gregicadditions.GAConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.color.ItemColors;
Expand All @@ -19,10 +18,6 @@

@Mod.EventBusSubscriber(Side.CLIENT)
public class ClientProxy extends CommonProxy {
@Override
public void preInit() {
super.preInit();
}

@Override
public void postInit() {
Expand Down
61 changes: 0 additions & 61 deletions src/main/java/gregicadditions/bees/CommonProxy.java
Original file line number Diff line number Diff line change
@@ -1,73 +1,12 @@
package gregicadditions.bees;

import forestry.api.recipes.ICentrifugeRecipe;
import forestry.api.recipes.ISqueezerRecipe;
import forestry.api.recipes.RecipeManagers;
import forestry.core.items.ItemFluidContainerForestry;
import gregicadditions.GAConfig;
import gregicadditions.GregicAdditions;
import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.RecipeMaps;
import gregtech.api.recipes.builders.SimpleRecipeBuilder;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistry;

import java.util.Collections;

import static gregicadditions.GregicAdditions.isForestryBeesDisabled;

@Mod.EventBusSubscriber(modid = GregicAdditions.MODID)
public class CommonProxy {

public void preInit() {

}

public void postInit() {
if (GAConfig.GTBees.GenerateCentrifugeRecipes) for (ICentrifugeRecipe recipe : RecipeManagers.centrifugeManager.recipes()) {
SimpleRecipeBuilder builder = RecipeMaps.CENTRIFUGE_RECIPES.recipeBuilder();
builder.inputs(recipe.getInput().copy());
for (ItemStack stack : recipe.getAllProducts().keySet()) {
builder.chancedOutput(stack.copy(), (int) (recipe.getAllProducts().get(stack) * Recipe.getMaxChancedValue()), 1000);
}
builder.EUt(5);
builder.duration(128);
builder.buildAndRegister();
}

if (GAConfig.GTBees.GenerateExtractorRecipes) for (ISqueezerRecipe recipe : RecipeManagers.squeezerManager.recipes()) {
if (recipe.getResources().size() != 1 || recipe.getResources().get(0).getItem() instanceof ItemFluidContainerForestry) continue;
if (RecipeMaps.FLUID_EXTRACTION_RECIPES.findRecipe(Integer.MAX_VALUE, recipe.getResources(), Collections.emptyList(), Integer.MAX_VALUE) != null) continue;
SimpleRecipeBuilder builder = RecipeMaps.FLUID_EXTRACTION_RECIPES.recipeBuilder();
builder.inputs(recipe.getResources().get(0).copy());
if (!recipe.getRemnants().isEmpty()) builder.chancedOutput(recipe.getRemnants().copy(), (int) (recipe.getRemnantsChance() * Recipe.getMaxChancedValue()), 1000);
if (recipe.getFluidOutput() != null) builder.fluidOutputs(recipe.getFluidOutput());
builder.EUt(5);
builder.duration(128);
builder.buildAndRegister();
}

GTMachineRecipes.postInit();
}

@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
if (isForestryBeesDisabled())
return;
IForgeRegistry<Item> registry = event.getRegistry();
registry.register(GTCombs.combItem);
}

@SubscribeEvent(priority = EventPriority.LOWEST)
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
if (isForestryBeesDisabled())
return;
ForestryMachineRecipes.init();
}
}
34 changes: 34 additions & 0 deletions src/main/java/gregicadditions/bees/ForestryMachineRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,50 @@

import com.google.common.collect.ImmutableMap;

import forestry.api.recipes.ICentrifugeRecipe;
import forestry.api.recipes.ISqueezerRecipe;
import forestry.api.recipes.RecipeManagers;
import forestry.apiculture.ModuleApiculture;
import forestry.core.ModuleCore;
import forestry.core.items.ItemFluidContainerForestry;
import gregicadditions.GAConfig;
import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.RecipeMaps;
import gregtech.api.recipes.builders.SimpleRecipeBuilder;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.common.items.MetaItems;
import net.minecraft.item.ItemStack;

import java.util.Collections;

public class ForestryMachineRecipes {
public static void init() {

if (GAConfig.GTBees.GenerateCentrifugeRecipes) for (ICentrifugeRecipe recipe : RecipeManagers.centrifugeManager.recipes()) {
SimpleRecipeBuilder builder = RecipeMaps.CENTRIFUGE_RECIPES.recipeBuilder();
builder.inputs(recipe.getInput().copy());
for (ItemStack stack : recipe.getAllProducts().keySet()) {
builder.chancedOutput(stack.copy(), (int) (recipe.getAllProducts().get(stack) * Recipe.getMaxChancedValue()), 1000);
}
builder.EUt(5);
builder.duration(128);
builder.buildAndRegister();
}

if (GAConfig.GTBees.GenerateExtractorRecipes) for (ISqueezerRecipe recipe : RecipeManagers.squeezerManager.recipes()) {
if (recipe.getResources().size() != 1 || recipe.getResources().get(0).getItem() instanceof ItemFluidContainerForestry) continue;
if (RecipeMaps.FLUID_EXTRACTION_RECIPES.findRecipe(Integer.MAX_VALUE, recipe.getResources(), Collections.emptyList(), Integer.MAX_VALUE) != null) continue;
SimpleRecipeBuilder builder = RecipeMaps.FLUID_EXTRACTION_RECIPES.recipeBuilder();
builder.inputs(recipe.getResources().get(0).copy());
if (!recipe.getRemnants().isEmpty()) builder.chancedOutput(recipe.getRemnants().copy(), (int) (recipe.getRemnantsChance() * Recipe.getMaxChancedValue()), 1000);
if (recipe.getFluidOutput() != null) builder.fluidOutputs(recipe.getFluidOutput());
builder.EUt(5);
builder.duration(128);
builder.buildAndRegister();
}

RecipeManagers.centrifugeManager.addRecipe(20, ModuleApiculture.getItems().propolis.getItemStack(), ImmutableMap.of(MetaItems.RUBBER_DROP.getStackForm(), 1.0f));

//Combs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.ore.OrePrefix;

public class GTMachineRecipes {
public static void postInit() {
public class GTMachineCombRecipes {
public static void init() {

//Impregnated Recipes
if (GAConfig.GTBees.AssemblerRecipes) {
RecipeMaps.ASSEMBLER_RECIPES.recipeBuilder().EUt(8).duration(16).circuitMeta(1).input(OrePrefix.log, Materials.Wood, 8).fluidInputs(Fluids.SEED_OIL.getFluid(250)).outputs(ModuleCore.getItems().impregnatedCasing.getItemStack()).buildAndRegister();
Expand Down

0 comments on commit 857fd5a

Please sign in to comment.