Skip to content

Commit

Permalink
Fix: possible crash when registering anvil recipes and OptiFine is no…
Browse files Browse the repository at this point in the history
…t installed.
  • Loading branch information
Aleksey-Terzi committed Jul 31, 2015
1 parent d90cd61 commit 594ca86
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 20 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildscript {
}

configurations {
runtime.exclude group: "[1.7.10]TerraFirmaCraft-0.79.18.673"
runtime.exclude group: "[1.7.10]TerraFirmaCraft-0.79.21.741"
}

// define the properties file
Expand Down Expand Up @@ -64,7 +64,7 @@ task copyJar(type: Copy) {
tasks.build.dependsOn('copyJar')

dependencies {
// Copy "[1.7.10]TerraFirmaCraft-0.79.18.673.jar" file
// Copy "[1.7.10]TerraFirmaCraft-0.79.21.741.jar" file
// into the ./libs directory
}

Expand Down
2 changes: 1 addition & 1 deletion build.prop
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
minecraft_version=1.7.10
forge_version=10.13.2.1291
forge_version=10.13.4.1448-1.7.10
mod_version=1.0.19
group_name=com.aleksey.decorations
archive_name=[1.7.10]Decorations
31 changes: 17 additions & 14 deletions src/com/aleksey/decorations/Core/Recipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.ShapelessOreRecipe;

Expand Down Expand Up @@ -134,22 +135,24 @@ public static boolean areAnvilRecipesRegistered()
return map.containsKey(_lanternCorePlan);
}

public static void registerAnvilRecipes()
public static void registerAnvilRecipes(World world)
{
if(DecorationsMod.isLanternsEnabled)
if(!DecorationsMod.isLanternsEnabled)
return;

AnvilManager manager = AnvilManager.getInstance();
//We need to set the world ref so that all anvil recipes can generate correctly
AnvilManager.world = world;

manager.addPlan(_lanternCorePlan, new PlanRecipe(new RuleEnum[] { RuleEnum.HITLAST, RuleEnum.PUNCHNOTLAST, RuleEnum.HITNOTLAST }));

for(int i = 0; i < Constants.Lanterns.length; i++)
{
AnvilManager manager = AnvilManager.getInstance();

manager.addPlan(_lanternCorePlan, new PlanRecipe(new RuleEnum[] { RuleEnum.HITLAST, RuleEnum.PUNCHNOTLAST, RuleEnum.HITNOTLAST }));

for(int i = 0; i < Constants.Lanterns.length; i++)
{
LanternInfo info = Constants.Lanterns[i];
Item sheetItem = GameRegistry.findItem("terrafirmacraft", info.SheetName);
ItemStack lanternCore = new ItemStack(ItemList.LanternCores[i], 1, 0);

manager.addRecipe(new AnvilRecipe(new ItemStack(sheetItem), null, _lanternCorePlan, false, info.Anvil, lanternCore).addRecipeSkill(Global.SKILL_GENERAL_SMITHING));
}
LanternInfo info = Constants.Lanterns[i];
Item sheetItem = GameRegistry.findItem("terrafirmacraft", info.SheetName);
ItemStack lanternCore = new ItemStack(ItemList.LanternCores[i], 1, 0);

manager.addRecipe(new AnvilRecipe(new ItemStack(sheetItem), null, _lanternCorePlan, false, info.Anvil, lanternCore).addRecipeSkill(Global.SKILL_GENERAL_SMITHING));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void onLoadWorld(WorldEvent.Load event)
{
if(!event.world.isRemote && event.world.provider.dimensionId == 0 && !Recipes.areAnvilRecipesRegistered())
{
Recipes.registerAnvilRecipes();
Recipes.registerAnvilRecipes(event.world);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer)
public void handleClientSide(EntityPlayer player)
{
if(!Recipes.areAnvilRecipesRegistered())
Recipes.registerAnvilRecipes();
Recipes.registerAnvilRecipes(player.worldObj);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void onServerWorldTick(WorldTickEvent event)
{
if(world.provider.dimensionId == 0 && !Recipes.areAnvilRecipesRegistered())
{
Recipes.registerAnvilRecipes();
Recipes.registerAnvilRecipes(world);
}
}
}
Expand Down

0 comments on commit 594ca86

Please sign in to comment.