diff --git a/src/main/resources/assets/opencomputers/textures/items/disk_floppy.png b/src/main/resources/assets/opencomputers/textures/items/disk_floppy.png deleted file mode 100644 index 40d15fa4e..000000000 Binary files a/src/main/resources/assets/opencomputers/textures/items/disk_floppy.png and /dev/null differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_black.png b/src/main/resources/assets/opencomputers/textures/items/floppy_black.png new file mode 100644 index 000000000..666f4b612 Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_black.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_blue.png b/src/main/resources/assets/opencomputers/textures/items/floppy_blue.png new file mode 100644 index 000000000..afad4760e Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_blue.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_brown.png b/src/main/resources/assets/opencomputers/textures/items/floppy_brown.png new file mode 100644 index 000000000..be515838f Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_brown.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_cyan.png b/src/main/resources/assets/opencomputers/textures/items/floppy_cyan.png new file mode 100644 index 000000000..39d00697f Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_cyan.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_gray.png b/src/main/resources/assets/opencomputers/textures/items/floppy_gray.png new file mode 100644 index 000000000..414cb22df Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_gray.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_green.png b/src/main/resources/assets/opencomputers/textures/items/floppy_green.png new file mode 100644 index 000000000..c460db9e8 Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_green.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_lightBlue.png b/src/main/resources/assets/opencomputers/textures/items/floppy_lightBlue.png new file mode 100644 index 000000000..1b5b48ec3 Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_lightBlue.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_lightGray.png b/src/main/resources/assets/opencomputers/textures/items/floppy_lightGray.png new file mode 100644 index 000000000..439e9fa63 Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_lightGray.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_lime.png b/src/main/resources/assets/opencomputers/textures/items/floppy_lime.png new file mode 100644 index 000000000..4d72c6f13 Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_lime.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_magenta.png b/src/main/resources/assets/opencomputers/textures/items/floppy_magenta.png new file mode 100644 index 000000000..c719bc171 Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_magenta.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_orange.png b/src/main/resources/assets/opencomputers/textures/items/floppy_orange.png new file mode 100644 index 000000000..2c606189f Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_orange.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_pink.png b/src/main/resources/assets/opencomputers/textures/items/floppy_pink.png new file mode 100644 index 000000000..e743807b9 Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_pink.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_purple.png b/src/main/resources/assets/opencomputers/textures/items/floppy_purple.png new file mode 100644 index 000000000..ac3748eaa Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_purple.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_red.png b/src/main/resources/assets/opencomputers/textures/items/floppy_red.png new file mode 100644 index 000000000..6f728619a Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_red.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_white.png b/src/main/resources/assets/opencomputers/textures/items/floppy_white.png new file mode 100644 index 000000000..f51564d17 Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_white.png differ diff --git a/src/main/resources/assets/opencomputers/textures/items/floppy_yellow.png b/src/main/resources/assets/opencomputers/textures/items/floppy_yellow.png new file mode 100644 index 000000000..7e6fdf71a Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/items/floppy_yellow.png differ diff --git a/src/main/scala/li/cil/oc/common/item/Delegate.scala b/src/main/scala/li/cil/oc/common/item/Delegate.scala index 3892e4ab4..ad05246c6 100644 --- a/src/main/scala/li/cil/oc/common/item/Delegate.scala +++ b/src/main/scala/li/cil/oc/common/item/Delegate.scala @@ -59,6 +59,8 @@ trait Delegate { } } + def color(stack: ItemStack, pass: Int) = 0xFFFFFF + def displayName(stack: ItemStack): Option[String] = None @SideOnly(Side.CLIENT) diff --git a/src/main/scala/li/cil/oc/common/item/Delegator.scala b/src/main/scala/li/cil/oc/common/item/Delegator.scala index f3639b158..f3cef751c 100644 --- a/src/main/scala/li/cil/oc/common/item/Delegator.scala +++ b/src/main/scala/li/cil/oc/common/item/Delegator.scala @@ -81,6 +81,12 @@ class Delegator(id: Int) extends Item(id) { case _ => EnumRarity.common } + override def getColorFromItemStack(stack: ItemStack, pass: Int) = + subItem(stack) match { + case Some(subItem) => subItem.color(stack, pass) + case _ => super.getColorFromItemStack(stack, pass) + } + override def getChestGenBase(chest: ChestGenHooks, rnd: Random, original: WeightedRandomChestContent) = original override def shouldPassSneakingClickToBlock(world: World, x: Int, y: Int, z: Int) = { @@ -166,6 +172,9 @@ class Delegator(id: Int) extends Item(id) { case _ => super.getIcon(stack, pass) } + @SideOnly(Side.CLIENT) + override def getIconIndex(stack: ItemStack) = getIcon(stack, 0) + @SideOnly(Side.CLIENT) override def getIconFromDamage(damage: Int): Icon = subItem(damage) match { diff --git a/src/main/scala/li/cil/oc/common/item/FloppyDisk.scala b/src/main/scala/li/cil/oc/common/item/FloppyDisk.scala index 3d81c76bf..719b8700e 100644 --- a/src/main/scala/li/cil/oc/common/item/FloppyDisk.scala +++ b/src/main/scala/li/cil/oc/common/item/FloppyDisk.scala @@ -2,14 +2,25 @@ package li.cil.oc.common.item import java.util +import cpw.mods.fml.relauncher.{SideOnly, Side} import li.cil.oc.Settings import net.minecraft.client.renderer.texture.IconRegister import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack +import net.minecraft.util.Icon class FloppyDisk(val parent: Delegator) extends Delegate { val unlocalizedName = "FloppyDisk" + val icons = Array.fill[Icon](16)(null) + + @SideOnly(Side.CLIENT) + override def icon(stack: ItemStack, pass: Int) = + if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "color")) + Some(icons(stack.getTagCompound.getInteger(Settings.namespace + "color") max 0 min 15)) + else + Some(icons(8)) + override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) = { if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) { val nbt = stack.getTagCompound.getCompoundTag(Settings.namespace + "data") @@ -23,6 +34,21 @@ class FloppyDisk(val parent: Delegator) extends Delegate { override def registerIcons(iconRegister: IconRegister) { super.registerIcons(iconRegister) - icon = iconRegister.registerIcon(Settings.resourceDomain + ":disk_floppy") + icons(0) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_black") + icons(1) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_red") + icons(2) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_green") + icons(3) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_brown") + icons(4) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_blue") + icons(5) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_purple") + icons(6) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_cyan") + icons(7) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_lightGray") + icons(8) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_gray") + icons(9) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_pink") + icons(10) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_lime") + icons(11) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_yellow") + icons(12) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_lightBlue") + icons(13) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_magenta") + icons(14) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_orange") + icons(15) = iconRegister.registerIcon(Settings.resourceDomain + ":floppy_white") } } diff --git a/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala b/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala index 5c62675e5..943af74e8 100644 --- a/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala +++ b/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala @@ -3,14 +3,17 @@ package li.cil.oc.common.recipe import java.util.UUID import cpw.mods.fml.common.FMLCommonHandler +import li.cil.oc.util.Color import li.cil.oc.util.ExtendedNBT._ import li.cil.oc.{Settings, api} import net.minecraft.inventory.InventoryCrafting import net.minecraft.item.{Item, ItemStack} +import net.minecraft.nbt.NBTTagCompound object ExtendedRecipe { private lazy val navigationUpgrade = api.Items.get("navigationUpgrade") private lazy val linkedCard = api.Items.get("linkedCard") + private lazy val floppy = api.Items.get("floppy") def addNBTToResult(craftedStack: ItemStack, inventory: InventoryCrafting) = { if (api.Items.get(craftedStack) == navigationUpgrade) { @@ -32,6 +35,21 @@ object ExtendedRecipe { }) } + if (api.Items.get(craftedStack) == floppy) { + if (!craftedStack.hasTagCompound) { + craftedStack.setTagCompound(new NBTTagCompound("tag")) + } + val nbt = craftedStack.getTagCompound + for (i <- 0 until inventory.getSizeInventory) { + val stack = inventory.getStackInSlot(i) + if (stack != null) Color.findDye(stack) match { + case Some(oreDictName) => + nbt.setInteger(Settings.namespace + "color", Color.dyes.indexOf(oreDictName)) + case _ => + } + } + } + craftedStack } } diff --git a/src/main/scala/li/cil/oc/common/recipe/Recipes.scala b/src/main/scala/li/cil/oc/common/recipe/Recipes.scala index 8e7dc5982..13fbbb656 100644 --- a/src/main/scala/li/cil/oc/common/recipe/Recipes.scala +++ b/src/main/scala/li/cil/oc/common/recipe/Recipes.scala @@ -6,6 +6,7 @@ import java.util.logging.Level import com.typesafe.config._ import cpw.mods.fml.common.Loader import cpw.mods.fml.common.registry.GameRegistry +import li.cil.oc.util.Color import li.cil.oc.util.mods.GregTech import li.cil.oc.{Items, OpenComputers, api, common} import net.minecraft.block.Block @@ -97,6 +98,12 @@ object Recipes { // Navigation upgrade recrafting. val navigationUpgrade = api.Items.get("navigationUpgrade").createItemStack(1) GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(navigationUpgrade, navigationUpgrade, new ItemStack(Item.map, 1, OreDictionary.WILDCARD_VALUE))) + + // Floppy disk coloring. + val floppy = api.Items.get("floppy").createItemStack(1) + for (dye <- Color.dyes) { + GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(floppy, floppy, dye)) + } } catch { case e: Throwable => OpenComputers.log.log(Level.SEVERE, "Error parsing recipes, you may not be able to craft any items from this mod!", e) diff --git a/src/main/scala/li/cil/oc/util/Color.scala b/src/main/scala/li/cil/oc/util/Color.scala index eb7363cae..6ae500f36 100644 --- a/src/main/scala/li/cil/oc/util/Color.scala +++ b/src/main/scala/li/cil/oc/util/Color.scala @@ -31,6 +31,24 @@ object Color { val Orange = 0xEB8844 val White = 0xF0F0F0 + val dyes = Array( + "dyeBlack", + "dyeRed", + "dyeGreen", + "dyeBrown", + "dyeBlue", + "dyePurple", + "dyeCyan", + "dyeLightGray", + "dyeGray", + "dyePink", + "dyeLime", + "dyeYellow", + "dyeLightBlue", + "dyeMagenta", + "dyeOrange", + "dyeWhite") + val byOreName = Map( "dyeBlack" -> Black, "dyeRed" -> Red,