From 4f7ddb700575cb91e487e2a590942541e4b3894d Mon Sep 17 00:00:00 2001 From: Chicken Bones Date: Mon, 19 Aug 2013 08:04:34 +1000 Subject: [PATCH] Added method to replace micro materials --- codechicken/microblock/MicroMaterialRegistry.scala | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/codechicken/microblock/MicroMaterialRegistry.scala b/codechicken/microblock/MicroMaterialRegistry.scala index bbc25cc..8070e25 100644 --- a/codechicken/microblock/MicroMaterialRegistry.scala +++ b/codechicken/microblock/MicroMaterialRegistry.scala @@ -73,7 +73,7 @@ object MicroMaterialRegistry def registerMaterial(material:IMicroMaterial, name:String) { if(MultiPartRegistry.loaded) - throw new IllegalStateException("You must register your parts in the init methods.") + throw new IllegalStateException("You must register your materials in the init methods.") if(typeMap.contains(name)) throw new IllegalStateException("Material with id "+name+" is already registered.") @@ -83,6 +83,18 @@ object MicroMaterialRegistry typeMap.put(name, material) } + def replaceMaterial(material:IMicroMaterial, name:String) { + if(MultiPartRegistry.loaded) + throw new IllegalStateException("You must register your materials in the init methods.") + + if(typeMap.remove(name).isEmpty) + System.err.println("Material with id "+name+" is was not registered.") + + System.out.println("Replaced micro material: "+name) + + typeMap.put(name, material) + } + def registerHighlightRenderer(handler:IMicroHighlightRenderer) { highlightRenderers+=handler