mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-26 23:13:03 +00:00
Added custom honey drops
This commit is contained in:
1 parent
b07f04907e
commit
1aba2aeff5
3 files changed
+86
-6
No files matched your search
@@ -14,7 +14,7 @@ import net.bdew.gendustry.items.{IndustrialScoop, IndustrialGrafter, GeneTemplat
|
||||
import net.bdew.gendustry.machines.apiary.upgrades.ItemApiaryUpgrade
|
||||
import net.bdew.lib.config.ItemManager
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.custom.CustomHoneyComb
|
||||
import net.bdew.gendustry.custom.{CustomHoneyDrop, CustomHoneyComb}
|
||||
|
||||
object Items extends ItemManager(Config.IDs) {
|
||||
val labware = regSimpleItem("Labware")
|
||||
@@ -32,7 +32,8 @@ object Items extends ItemManager(Config.IDs) {
|
||||
val scoop = regItemCls(classOf[IndustrialScoop], "IndustrialScoop", false)
|
||||
GameRegistry.registerCustomItemStack("IndustrialScoop", scoop.stackWithCharge(0))
|
||||
|
||||
regItem(new CustomHoneyComb(ids.getItemId("BeeComb")))
|
||||
regItem(new CustomHoneyComb(ids.getItemId("HoneyComb")))
|
||||
regItem(new CustomHoneyDrop(ids.getItemId("HoneyDrop")))
|
||||
|
||||
regSimpleItem("MutagenTank")
|
||||
regSimpleItem("BeeReceptacle")
|
||||
|
||||
@@ -22,6 +22,9 @@ import java.util
|
||||
import cpw.mods.fml.common.registry.GameRegistry
|
||||
|
||||
class CustomHoneyComb(id: Int) extends SimpleItem(id, "HoneyComb") {
|
||||
|
||||
case class CombInfo(name: String, color1: Int, color2: Int)
|
||||
|
||||
var icons: Array[Icon] = null
|
||||
|
||||
setHasSubtypes(true)
|
||||
@@ -62,7 +65,7 @@ class CustomHoneyComb(id: Int) extends SimpleItem(id, "HoneyComb") {
|
||||
}
|
||||
|
||||
override def getUnlocalizedName(stack: ItemStack) =
|
||||
getData(stack).map(x => "%s.comb.%s".format(Gendustry.modId, x.name)).getOrElse("invalid")
|
||||
getData(stack).map(x => "%s.honeycomb.%s".format(Gendustry.modId, x.name)).getOrElse("invalid")
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def registerIcons(reg: IconRegister) {
|
||||
@@ -71,6 +74,4 @@ class CustomHoneyComb(id: Int) extends SimpleItem(id, "HoneyComb") {
|
||||
reg.registerIcon("forestry:beeCombs.1")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
case class CombInfo(name: String, color1: Int, color2: Int)
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2014
|
||||
* https://github.com/bdew/gendustry
|
||||
*
|
||||
* This mod is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package net.bdew.gendustry.custom
|
||||
|
||||
import net.bdew.lib.items.SimpleItem
|
||||
import net.minecraft.client.renderer.texture.IconRegister
|
||||
import cpw.mods.fml.relauncher.{SideOnly, Side}
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.minecraft.util.Icon
|
||||
import net.minecraft.creativetab.CreativeTabs
|
||||
import java.util
|
||||
import net.bdew.gendustry.config.Tuning
|
||||
import net.bdew.lib.recipes.gencfg.ConfigSection
|
||||
import cpw.mods.fml.common.registry.GameRegistry
|
||||
|
||||
class CustomHoneyDrop(id: Int) extends SimpleItem(id, "HoneyDrop") {
|
||||
|
||||
case class HoneyDropInfo(name: String, color1: Int, color2: Int)
|
||||
|
||||
var icons: Array[Icon] = null
|
||||
|
||||
setHasSubtypes(true)
|
||||
setMaxDamage(-1)
|
||||
|
||||
override def requiresMultipleRenderPasses() = true
|
||||
|
||||
val data = (Tuning.getOrAddSection("HoneyDrops").filterType(classOf[ConfigSection]) map {
|
||||
case (ident, cfg) => cfg.getInt("ID") -> HoneyDropInfo(
|
||||
ident,
|
||||
cfg.getColor("PrimaryColor").asRGB,
|
||||
cfg.getColor("SecondaryColor").asRGB
|
||||
)
|
||||
}).toMap
|
||||
|
||||
for ((id, comb) <- data)
|
||||
GameRegistry.registerCustomItemStack("HoneyDrop." + comb.name, new ItemStack(this, 1, id))
|
||||
|
||||
def getData(stack: ItemStack) = data.get(stack.getItemDamage)
|
||||
|
||||
override def getIconFromDamageForRenderPass(damage: Int, pass: Int) = pass match {
|
||||
case 0 => icons(1)
|
||||
case _ => icons(0)
|
||||
}
|
||||
|
||||
override def getColorFromItemStack(stack: ItemStack, pass: Int): Int = {
|
||||
val data = getData(stack).getOrElse(return 0)
|
||||
pass match {
|
||||
case 0 => data.color1
|
||||
case _ => data.color2
|
||||
}
|
||||
}
|
||||
|
||||
override def getSubItems(par1: Int, par2CreativeTabs: CreativeTabs, list: util.List[_]) {
|
||||
val l = list.asInstanceOf[util.List[ItemStack]]
|
||||
for ((id, name) <- data)
|
||||
l.add(new ItemStack(this, 1, id))
|
||||
}
|
||||
|
||||
override def getUnlocalizedName(stack: ItemStack) =
|
||||
getData(stack).map(x => "%s.honeydrop.%s".format(Gendustry.modId, x.name)).getOrElse("invalid")
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def registerIcons(reg: IconRegister) {
|
||||
icons = Array(
|
||||
reg.registerIcon("forestry:honeyDrop.0"),
|
||||
reg.registerIcon("forestry:honeyDrop.1")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user