2015-11-02 20:39:44 +00:00
|
|
|
package WayofTime.bloodmagic.api.registry;
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-02 20:39:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
|
|
|
import WayofTime.bloodmagic.api.orb.BloodOrb;
|
2015-10-30 03:22:14 +00:00
|
|
|
import lombok.Getter;
|
|
|
|
import net.minecraft.client.resources.model.ModelBakery;
|
|
|
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2015-10-30 05:06:18 +00:00
|
|
|
import net.minecraftforge.client.model.ModelLoader;
|
2015-10-30 03:22:14 +00:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is only for those who wish to add a basic {@link BloodOrb}. If you need custom handling,
|
|
|
|
* you will need your own item class.
|
|
|
|
*/
|
|
|
|
public class OrbRegistry {
|
|
|
|
|
|
|
|
@Getter
|
|
|
|
private static List<BloodOrb> orbs = new ArrayList<BloodOrb>();
|
|
|
|
|
|
|
|
public static void registerOrb(BloodOrb orb) {
|
|
|
|
if (!orbs.contains(orb))
|
|
|
|
orbs.add(orb);
|
|
|
|
else
|
2015-12-23 17:41:59 +00:00
|
|
|
BloodMagicAPI.getLogger().error("Error adding orb %s. Orb already exists!", orb.toString());
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public static void registerOrbTexture(BloodOrb orb, String resourceLocation) {
|
|
|
|
int meta = getIndexOf(orb);
|
|
|
|
|
2015-12-23 17:41:59 +00:00
|
|
|
ModelBakery.addVariantName(BloodMagicAPI.getItem(BloodMagicAPI.ORB), resourceLocation);
|
|
|
|
ModelLoader.setCustomModelResourceLocation(BloodMagicAPI.getItem(BloodMagicAPI.ORB), meta, new ModelResourceLocation(resourceLocation, "inventory"));
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static BloodOrb getOrb(int index) {
|
|
|
|
return orbs.get(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getIndexOf(BloodOrb orb) {
|
|
|
|
return orbs.indexOf(orb);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isEmpty() {
|
|
|
|
return orbs.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getSize() {
|
|
|
|
return orbs.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ItemStack getOrbStack(BloodOrb orb) {
|
2015-12-23 17:41:59 +00:00
|
|
|
return new ItemStack(BloodMagicAPI.getItem(BloodMagicAPI.ORB), 1, getIndexOf(orb));
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
}
|