mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-19 19:59:40 +00:00
Adding invalid or duplicate micro materials will warning instead of crash.
This commit is contained in:
1 parent
4f571ebc94
commit
bcfe499556
3 files changed
+28
-7
No files matched your search
@@ -118,6 +118,8 @@ class BlockMicroMaterial(val block:Block, val meta:Int = 0) extends IMicroMateri
|
||||
*/
|
||||
object BlockMicroMaterial
|
||||
{
|
||||
def materialKey(block:Block, meta:Int) = block.getUnlocalizedName+(if(meta > 0) "_"+meta else "")
|
||||
|
||||
def createAndRegister(block:Block)
|
||||
{
|
||||
createAndRegister(block, 0)
|
||||
@@ -125,8 +127,7 @@ object BlockMicroMaterial
|
||||
|
||||
def createAndRegister(block:Block, meta:Int)
|
||||
{
|
||||
MicroMaterialRegistry.registerMaterial(new BlockMicroMaterial(block, meta),
|
||||
block.getUnlocalizedName+(if(meta > 0) "_"+meta else ""))
|
||||
MicroMaterialRegistry.registerMaterial(new BlockMicroMaterial(block, meta), materialKey(block, meta))
|
||||
}
|
||||
|
||||
def createAndRegister(block:Block, meta:Seq[Int])
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.lang.Exception
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage
|
||||
import net.minecraft.item.ItemStack
|
||||
import BlockMicroMaterial.createAndRegister
|
||||
import BlockMicroMaterial.materialKey
|
||||
|
||||
object ConfigContent
|
||||
{
|
||||
@@ -132,8 +133,20 @@ object ConfigContent
|
||||
val value = nameMap.get(name)
|
||||
if(value.isDefined)
|
||||
{
|
||||
createAndRegister(block, value.get)
|
||||
nameMap.remove(name)
|
||||
nameMap.remove(name)
|
||||
value.get.foreach{m =>
|
||||
try {
|
||||
createAndRegister(block, m)
|
||||
}
|
||||
catch {
|
||||
case e:IllegalStateException => System.err.println("Unable to register micro material: "+
|
||||
materialKey(block, m)+"\n\t"+e.getMessage)
|
||||
case e:Exception => {
|
||||
System.err.println("Unable to register micro material: "+materialKey(block, m))
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,8 +169,15 @@ object ConfigContent
|
||||
System.err.println("Invalid blockID: "+stack.itemID)
|
||||
else if(stack.getItemDamage < 0 || stack.getItemDamage >= 16)
|
||||
System.err.println("Invalid metadata: "+stack.getItemDamage)
|
||||
else
|
||||
createAndRegister(Block.blocksList(stack.itemID), stack.getItemDamage)
|
||||
else {
|
||||
try {
|
||||
createAndRegister(Block.blocksList(stack.itemID), stack.getItemDamage)
|
||||
}
|
||||
catch {
|
||||
case e:IllegalStateException => System.err.println("Unable to register micro material: "+
|
||||
materialKey(Block.blocksList(stack.itemID), stack.getItemDamage)+"\n\t"+e.getMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ object ItemMicroPart
|
||||
{
|
||||
checkTagCompound(stack)
|
||||
if(!stack.getTagCompound().hasKey("mat"))
|
||||
return -1;
|
||||
return 0;
|
||||
|
||||
return MicroMaterialRegistry.materialID(stack.getTagCompound().getString("mat"))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user