By popular demand, floppy disks can now be dyed by crafting them together with the according dye. Closes #388.
Before Width: | Height: | Size: 467 B |
After Width: | Height: | Size: 413 B |
After Width: | Height: | Size: 457 B |
After Width: | Height: | Size: 407 B |
After Width: | Height: | Size: 456 B |
After Width: | Height: | Size: 438 B |
After Width: | Height: | Size: 437 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 456 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 456 B |
After Width: | Height: | Size: 442 B |
After Width: | Height: | Size: 447 B |
After Width: | Height: | Size: 457 B |
After Width: | Height: | Size: 450 B |
@ -59,6 +59,8 @@ trait Delegate {
|
||||
}
|
||||
}
|
||||
|
||||
def color(stack: ItemStack, pass: Int) = 0xFFFFFF
|
||||
|
||||
def displayName(stack: ItemStack): Option[String] = None
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
@ -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 {
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|