mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -04:00
Finally cleaned up the (almost) eternal makeshift that was handling missing recipes. Recipes can be properly disabled by assigning a boolean value to them; assigning false will also hide the item in the creative tab/NEI, true will only disable the recipe, but keep the item visible. If a recipe is broken, a warning message will now be displayed when entering a world.
This commit is contained in:
parent
86cce2502b
commit
f3e151a3ae
@ -173,6 +173,7 @@ oc:gui.Chat.WarningLuaFallback=Native Lua libraries are not available, computers
|
||||
oc:gui.Chat.WarningPower=No supported power providing mod available. Computers, screens and all other components will §lnot§f require energy. Install one of the following mods to enable power: BuildCraft, Electrical Age, IndustrialCraft2, Mekanism or Thermal Expansion. Disable power in the config to suppress this warning.
|
||||
oc:gui.Chat.TextureName=§7Texture name is §a%s§f.
|
||||
oc:gui.Chat.WarningProjectRed=You are using a version of Project: Red that is incompatible with OpenComputers. Try updating your version of Project: Red.
|
||||
oc:gui.Chat.WarningRecipes=There were errors loading one or more recipes. Some items may be uncraftable. Please check your log file for more information.
|
||||
oc:gui.Error.ComponentOverflow=Too many components connected to the computer.
|
||||
oc:gui.Error.InternalError=Internal error, please see the log file. This is probably a bug.
|
||||
oc:gui.Error.NoCPU=No CPU is installed in the computer.
|
||||
|
@ -313,6 +313,8 @@ nuggetIron {
|
||||
input: ingotIron
|
||||
output: 9
|
||||
}
|
||||
cuttingWire = false
|
||||
acid = false
|
||||
ingotIron {
|
||||
input: [[nuggetIron, nuggetIron, nuggetIron],
|
||||
[nuggetIron, nuggetIron, nuggetIron],
|
||||
@ -423,6 +425,7 @@ rawCircuitBoard {
|
||||
type: shapeless
|
||||
input: [nuggetGold, clay, dyeGreen]
|
||||
}
|
||||
circuitBoard = false
|
||||
printedCircuitBoard {
|
||||
type: furnace
|
||||
input: "oc:materialCircuitBoardRaw"
|
||||
|
@ -3,6 +3,11 @@
|
||||
# priority (i.e. included recipes simply replace the current definition for all
|
||||
# already known recipes).
|
||||
|
||||
# To disable a recipe, assign a boolean value to it. For example, to disable
|
||||
# the recipe for the transistor: `transistor = false`. This will disable the
|
||||
# recipe and hide the item in the creative tab and NEI. If you assign `true`,
|
||||
# the recipe will still be disabled, but not hidden in the creative tab/NEI.
|
||||
|
||||
include file("default.recipes")
|
||||
#include file("hardmode.recipes")
|
||||
#include file("gregtech.recipes")
|
||||
|
@ -83,6 +83,8 @@ object Localization {
|
||||
|
||||
def WarningFingerprint(event: FMLFingerprintViolationEvent) = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.WarningFingerprint", event.expectedFingerprint, event.fingerprints.toArray.mkString(", ")))
|
||||
|
||||
def WarningRecipes = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.WarningRecipes"))
|
||||
|
||||
def InfoNewVersion(version: String) = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.NewVersion", version))
|
||||
|
||||
def TextureName(name: String) = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.TextureName", name))
|
||||
|
@ -17,6 +17,7 @@ import li.cil.oc.client.{PacketSender => ClientPacketSender}
|
||||
import li.cil.oc.common.item.data.MicrocontrollerData
|
||||
import li.cil.oc.common.item.data.RobotData
|
||||
import li.cil.oc.common.item.data.TabletData
|
||||
import li.cil.oc.common.recipe.Recipes
|
||||
import li.cil.oc.common.tileentity.Robot
|
||||
import li.cil.oc.common.tileentity.traits.power
|
||||
import li.cil.oc.integration.Mods
|
||||
@ -156,6 +157,9 @@ object EventHandler {
|
||||
if (!Settings.get.pureIgnorePower && Settings.get.ignorePower) {
|
||||
player.addChatMessage(Localization.Chat.WarningPower)
|
||||
}
|
||||
if (Recipes.hadErrors) {
|
||||
player.addChatMessage(Localization.Chat.WarningRecipes)
|
||||
}
|
||||
ServerPacketSender.sendPetVisibility(None, Some(player))
|
||||
// Do update check in local games and for OPs.
|
||||
if (!Mods.VersionChecker.isAvailable && (!MinecraftServer.getServer.isDedicatedServer || MinecraftServer.getServer.getConfigurationManager.func_152596_g(player.getGameProfile))) {
|
||||
|
@ -31,6 +31,7 @@ import scala.collection.mutable
|
||||
object Recipes {
|
||||
val list = mutable.LinkedHashMap.empty[ItemStack, String]
|
||||
val oreDictEntries = mutable.LinkedHashMap.empty[String, ItemStack]
|
||||
var hadErrors = false
|
||||
|
||||
def addBlock(instance: Block, name: String, oreDict: String = null) = {
|
||||
Items.registerBlock(instance, name)
|
||||
@ -206,41 +207,53 @@ object Recipes {
|
||||
|
||||
private def addRecipe(output: ItemStack, list: Config, name: String) = try {
|
||||
if (list.hasPath(name)) {
|
||||
val recipe = list.getConfig(name)
|
||||
val recipeType = tryGetType(recipe)
|
||||
try {
|
||||
recipeType match {
|
||||
case "shaped" => addShapedRecipe(output, recipe)
|
||||
case "shapeless" => addShapelessRecipe(output, recipe)
|
||||
case "furnace" => addFurnaceRecipe(output, recipe)
|
||||
case "gt_assembler" =>
|
||||
if (Mods.GregTech.isAvailable) {
|
||||
addGTAssemblingMachineRecipe(output, recipe)
|
||||
val value = list.getValue(name)
|
||||
value.valueType match {
|
||||
case ConfigValueType.OBJECT =>
|
||||
val recipe = list.getConfig(name)
|
||||
val recipeType = tryGetType(recipe)
|
||||
try {
|
||||
recipeType match {
|
||||
case "shaped" => addShapedRecipe(output, recipe)
|
||||
case "shapeless" => addShapelessRecipe(output, recipe)
|
||||
case "furnace" => addFurnaceRecipe(output, recipe)
|
||||
case "gt_assembler" =>
|
||||
if (Mods.GregTech.isAvailable) {
|
||||
addGTAssemblingMachineRecipe(output, recipe)
|
||||
}
|
||||
else {
|
||||
OpenComputers.log.error(s"Skipping GregTech assembler recipe for '$name' because GregTech is not present, you will not be able to craft this item.")
|
||||
hadErrors = true
|
||||
}
|
||||
case other =>
|
||||
OpenComputers.log.error(s"Failed adding recipe for '$name', you will not be able to craft this item. The error was: Invalid recipe type '$other'.")
|
||||
hadErrors = true
|
||||
}
|
||||
else {
|
||||
OpenComputers.log.warn(s"Skipping GregTech assembler recipe for '$name' because GregTech is not present, you will not be able to craft this item!")
|
||||
hide(output)
|
||||
}
|
||||
case other =>
|
||||
OpenComputers.log.warn(s"Failed adding recipe for '$name', you will not be able to craft this item! The error was: Invalid recipe type '$other'.")
|
||||
}
|
||||
catch {
|
||||
case e: RecipeException =>
|
||||
OpenComputers.log.error(s"Failed adding $recipeType recipe for '$name', you will not be able to craft this item! The error was: ${e.getMessage}")
|
||||
hadErrors = true
|
||||
}
|
||||
case ConfigValueType.BOOLEAN =>
|
||||
// Explicitly disabled, keep in NEI if true.
|
||||
if (!value.unwrapped.asInstanceOf[Boolean]) {
|
||||
hide(output)
|
||||
}
|
||||
}
|
||||
catch {
|
||||
case e: RecipeException =>
|
||||
OpenComputers.log.warn(s"Failed adding $recipeType recipe for '$name', you will not be able to craft this item! The error was: ${e.getMessage}")
|
||||
hide(output)
|
||||
}
|
||||
case _ =>
|
||||
OpenComputers.log.error(s"Failed adding recipe for '$name', you will not be able to craft this item. The error was: Invalid value for recipe.")
|
||||
hadErrors = true
|
||||
}
|
||||
}
|
||||
else {
|
||||
OpenComputers.log.info(s"No recipe for '$name', you will not be able to craft this item.")
|
||||
hide(output)
|
||||
OpenComputers.log.warn(s"No recipe for '$name', you will not be able to craft this item. To suppress this warning, disable the recipe (assign `false` to it).")
|
||||
hadErrors = true
|
||||
}
|
||||
}
|
||||
catch {
|
||||
case e: Throwable =>
|
||||
OpenComputers.log.error(s"Failed adding recipe for '$name', you will not be able to craft this item!", e)
|
||||
hide(output)
|
||||
OpenComputers.log.error(s"Failed adding recipe for '$name', you will not be able to craft this item.", e)
|
||||
hadErrors = true
|
||||
}
|
||||
|
||||
private def addShapedRecipe(output: ItemStack, recipe: Config) {
|
||||
@ -269,7 +282,6 @@ object Recipes {
|
||||
if (input.size > 0 && output.stackSize > 0) {
|
||||
GameRegistry.addRecipe(new ExtendedShapedOreRecipe(output, shape ++ input: _*))
|
||||
}
|
||||
else hide(output)
|
||||
}
|
||||
|
||||
private def addShapelessRecipe(output: ItemStack, recipe: Config) {
|
||||
@ -282,7 +294,6 @@ object Recipes {
|
||||
if (input.size > 0 && output.stackSize > 0) {
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(output, input: _*))
|
||||
}
|
||||
else hide(output)
|
||||
}
|
||||
|
||||
private def addGTAssemblingMachineRecipe(output: ItemStack, recipe: Config) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user