Recipes can now show in the recipe book

This commit is contained in:
modmuss50 2017-06-15 11:01:33 +01:00
parent bdcb8bf327
commit 5536a6cd94
No known key found for this signature in database
GPG key ID: 203A5ED4D3E48BEA
4 changed files with 43 additions and 7 deletions

View file

@ -51,6 +51,7 @@ import techreborn.compat.ICompatModule;
import techreborn.dispenser.BehaviorDispenseScrapbox; import techreborn.dispenser.BehaviorDispenseScrapbox;
import techreborn.entities.EntityNukePrimed; import techreborn.entities.EntityNukePrimed;
import techreborn.events.BlockBreakHandler; import techreborn.events.BlockBreakHandler;
import techreborn.events.TREventHandler;
import techreborn.events.TRTickHandler; import techreborn.events.TRTickHandler;
import techreborn.init.*; import techreborn.init.*;
import techreborn.lib.ModInfo; import techreborn.lib.ModInfo;
@ -118,6 +119,8 @@ public class Core {
versionChecker = new VersionChecker("TechReborn", new ModInfo()); versionChecker = new VersionChecker("TechReborn", new ModInfo());
versionChecker.checkVersionThreaded(); versionChecker.checkVersionThreaded();
ModRecipes.init();
logHelper.info("PreInitialization Complete"); logHelper.info("PreInitialization Complete");
} }
@ -135,11 +138,11 @@ public class Core {
} }
MinecraftForge.EVENT_BUS.register(new StackWIPHandler()); MinecraftForge.EVENT_BUS.register(new StackWIPHandler());
MinecraftForge.EVENT_BUS.register(new BlockBreakHandler()); MinecraftForge.EVENT_BUS.register(new BlockBreakHandler());
MinecraftForge.EVENT_BUS.register(new TREventHandler());
// Recipes // Recipes
StopWatch watch = new StopWatch(); StopWatch watch = new StopWatch();
watch.start(); watch.start();
ModRecipes.init();
logHelper.all(watch + " : main recipes"); logHelper.all(watch + " : main recipes");
watch.stop(); watch.stop();
// Client only init, needs to be done before parts system // Client only init, needs to be done before parts system

View file

@ -0,0 +1,32 @@
package techreborn.events;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import techreborn.lib.ModInfo;
import java.util.ArrayList;
import java.util.List;
public class TREventHandler {
@SubscribeEvent
public void pickupEvent(EntityItemPickupEvent entityItemPickupEvent){
if(entityItemPickupEvent.getEntityPlayer() instanceof EntityPlayerMP){
if(entityItemPickupEvent.getItem().getItem().getItem().getRegistryName().getResourceDomain().equals(ModInfo.MOD_ID)){
List<IRecipe> recipeList = new ArrayList<>();
for(IRecipe recipe : CraftingManager.REGISTRY){
if(recipe.getRegistryName() != null && recipe.getRegistryName().getResourceDomain().equals(ModInfo.MOD_ID)){
if(recipe.getRecipeOutput().getItem().getRegistryName().getResourceDomain().equals(ModInfo.MOD_ID)){
recipeList.add(recipe);
}
}
}
entityItemPickupEvent.getEntityPlayer().unlockRecipes(recipeList);
}
}
}
}

View file

@ -52,4 +52,5 @@ public class TRTickHandler {
previouslyWearing = chestslot; previouslyWearing = chestslot;
} }
} }

View file

@ -319,9 +319,9 @@ public class CraftingTableRecipes extends RecipeMethods {
registerShaped(axe, "GG ", "GS ", " S ", 'S', Items.STICK, 'G', material); registerShaped(axe, "GG ", "GS ", " S ", 'S', Items.STICK, 'G', material);
registerShaped(hoe, "GG ", " S ", " S ", 'S', Items.STICK, 'G', material); registerShaped(hoe, "GG ", " S ", " S ", 'S', Items.STICK, 'G', material);
registerShaped(spade, " G ", " S ", " S ", 'S', Items.STICK, 'G', material); registerShaped(spade, " G ", " S ", " S ", 'S', Items.STICK, 'G', material);
registerShaped(helmet, "GGG", "G G", 'G', material); registerShaped(helmet, "GGG", "G G", " ", 'G', material);
registerShaped(chestplate, "G G", "GGG", "GGG", 'G', material); registerShaped(chestplate, "G G", "GGG", "GGG", 'G', material);
registerShaped(leggings, "GGG", "G G", "G G", 'G', material); registerShaped(leggings, "GGG", "G G", "G G", 'G', material);
registerShaped(boots, "G G", "G G", 'G', material); registerShaped(boots, " ", "G G", "G G", 'G', material);
} }
} }