Files
MagicBees/src/main/java/magicbees/bees/BeeIconProvider.java
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.6 KiB
Java
Raw Normal View History

2022-10-12 21:09:18 +02:00
package magicbees.bees;
2022-10-12 21:09:45 +02:00
import java.util.Locale;
2022-10-12 21:09:18 +02:00
import magicbees.main.CommonProxy;
2022-10-12 21:09:45 +02:00
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
2022-10-12 21:09:18 +02:00
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBeeIconProvider;
2022-10-12 21:09:18 +02:00
public enum BeeIconProvider implements IBeeIconProvider {
2022-10-12 21:09:45 +02:00
SKULKING(CommonProxy.DOMAIN + ":bees/skulking/"),
DOCTORAL(CommonProxy.DOMAIN + ":bees/doctoral/");
@SideOnly(Side.CLIENT)
private IIcon[][] icons;
2022-10-12 21:09:18 +02:00
2022-10-12 21:09:45 +02:00
private final String iconPath;
2022-10-12 21:09:18 +02:00
2022-10-12 21:09:45 +02:00
BeeIconProvider(String iconPath) {
this.iconPath = iconPath;
}
2022-10-12 21:09:18 +02:00
2022-10-12 21:09:45 +02:00
@Override
public void registerIcons(IIconRegister itemMap) {
this.icons = new IIcon[EnumBeeType.VALUES.length][3];
2022-10-12 21:09:18 +02:00
2022-10-12 21:09:45 +02:00
IIcon body1 = itemMap.registerIcon(iconPath + "body1");
2022-10-12 21:09:18 +02:00
2022-10-12 21:09:45 +02:00
for (int i = 0; i < EnumBeeType.VALUES.length; i++) {
EnumBeeType beeType = EnumBeeType.VALUES[i];
if (beeType == EnumBeeType.NONE) continue;
2022-10-12 21:09:18 +02:00
2022-10-12 21:09:45 +02:00
String beeTypeIconPath = iconPath + beeType.toString().toLowerCase(Locale.ENGLISH);
2022-10-12 21:09:18 +02:00
2022-10-12 21:09:45 +02:00
icons[i][0] = itemMap.registerIcon(beeTypeIconPath + ".outline");
icons[i][1] = (beeType != EnumBeeType.LARVAE) ? body1 : itemMap.registerIcon(beeTypeIconPath + ".body");
icons[i][2] = itemMap.registerIcon(beeTypeIconPath + ".body2");
}
}
2022-10-12 21:09:18 +02:00
2022-10-12 21:09:45 +02:00
@Override
public IIcon getIcon(EnumBeeType type, int renderPass) {
return icons[type.ordinal()][Math.min(renderPass, 2)];
}
2022-10-12 21:09:18 +02:00
}