Created
June 25, 2014 17:19
-
-
Save marchermans/ff6c0e01776b3cff1e75 to your computer and use it in GitHub Desktop.
MultiLayeredArmor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Orion on 08/06/2014. | |
*/ | |
import com.Orion.OrionsBelt.Client.CustomResource; | |
import cpw.mods.fml.relauncher.Side; | |
import cpw.mods.fml.relauncher.SideOnly; | |
import net.minecraft.client.renderer.texture.IIconRegister; | |
import net.minecraft.item.ItemArmor; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.nbt.NBTTagCompound; | |
import net.minecraft.util.IIcon; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import java.util.Map; | |
public abstract class MultiLayeredArmor extends ItemArmor { | |
//TODO: Implement JavaDoc documentation. | |
public final int iArmorPart; | |
public String iInternalName; | |
//Hashmaps for storing the Resources needed for rendering. | |
@SideOnly(Side.CLIENT) | |
public HashMap<String, CustomResource> iResources = new HashMap<String, CustomResource>(); | |
public MultiLayeredArmor(String pInternalName, int pArmorPart, ArmorMaterial pMaterial) { | |
super(pMaterial, 0, pArmorPart); | |
this.setUnlocalizedName(pInternalName); | |
this.setMaxStackSize(1); | |
this.iInternalName = pInternalName; | |
this.iArmorPart = pArmorPart; | |
} | |
//Function for registering a rescource to the object. | |
@SideOnly(Side.CLIENT) | |
public void registerResource(CustomResource pResource) { | |
iResources.put(pResource.iInternalName, pResource); | |
} | |
//Function called when registering the item to register the Icons. | |
@Override | |
@SideOnly(Side.CLIENT) | |
public void registerIcons(IIconRegister pIconRegister) { | |
Iterator tResourceIterator = iResources.entrySet().iterator(); | |
while (tResourceIterator.hasNext()) { | |
Map.Entry<String, CustomResource> tResource = (Map.Entry<String, CustomResource>) tResourceIterator.next(); | |
tResource.getValue().addIcon(pIconRegister.registerIcon(tResource.getValue().getIconLocation())); | |
} | |
} | |
//Function for getting the Icon from a render pass. | |
@Override | |
@SideOnly(Side.CLIENT) | |
public IIcon getIcon(ItemStack pStack, int pRenderPass) { | |
return this.getResource(pStack, pRenderPass).getIcon(); | |
} | |
//Function to get the IIcon for rendering Icons, the modeltexturelocation for models and the colors for combining. | |
@SideOnly(Side.CLIENT) | |
public CustomResource getResource(String pResourceID) { | |
return iResources.get(pResourceID); | |
} | |
@SideOnly(Side.CLIENT) | |
public CustomResource getResource(NBTTagCompound pRenderCompound) { | |
String tResourceID = pRenderCompound.getString("ResourceID"); | |
return iResources.get(tResourceID); | |
} | |
@SideOnly(Side.CLIENT) | |
public CustomResource getResource(ItemStack pStack, int pRenderPass) { | |
NBTTagCompound tRenderCompound = pStack.getTagCompound().getCompoundTag("RenderCompound").getCompoundTag("RenderPass - " + pRenderPass); | |
CustomResource tResource = this.getResource(tRenderCompound); | |
return tResource; | |
} | |
//Function to get the amount of renderpasses for the given ItemStack | |
@SideOnly(Side.CLIENT) | |
public int getRenderPasses(ItemStack pStack) { | |
NBTTagCompound tRenderCompound = pStack.getTagCompound().getCompoundTag("RenderCompound"); | |
return tRenderCompound.getInteger("RenderPasses"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment