2015-11-02 20:39:44 +00:00
|
|
|
package WayofTime.bloodmagic.api.registry;
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2016-03-17 20:00:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
|
|
|
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
|
|
|
import WayofTime.bloodmagic.api.orb.BloodOrb;
|
|
|
|
import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
|
|
|
import com.google.common.collect.ArrayListMultimap;
|
|
|
|
import net.minecraft.client.renderer.block.model.ModelBakery;
|
|
|
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
2016-01-19 10:34:49 +00:00
|
|
|
import net.minecraft.item.Item;
|
2015-10-30 03:22:14 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-01-10 22:34:01 +00:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
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;
|
|
|
|
|
2016-03-17 20:00:44 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
2015-10-30 03:22:14 +00:00
|
|
|
|
|
|
|
/**
|
2015-12-30 20:34:40 +00:00
|
|
|
* 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.
|
2015-10-30 03:22:14 +00:00
|
|
|
*/
|
2015-12-30 20:34:40 +00:00
|
|
|
public class OrbRegistry
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
private static List<BloodOrb> orbs = new ArrayList<BloodOrb>();
|
2016-02-17 04:48:42 +00:00
|
|
|
private static ArrayListMultimap<Integer, ItemStack> tierMap = ArrayListMultimap.create();
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2016-01-19 10:34:49 +00:00
|
|
|
private static Item orbItem = Constants.BloodMagicItem.BLOOD_ORB.getItem();
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public static void registerOrb(BloodOrb orb)
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
if (!orbs.contains(orb))
|
2016-02-17 04:48:42 +00:00
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
orbs.add(orb);
|
2016-02-17 04:48:42 +00:00
|
|
|
registerOrbForTier(orb.getTier(), getOrbStack(orb));
|
2016-03-16 22:41:06 +00:00
|
|
|
} 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
|
|
|
}
|
|
|
|
|
2016-02-17 04:48:42 +00:00
|
|
|
public static void registerOrbForTier(int tier, ItemStack stack)
|
|
|
|
{
|
|
|
|
if (stack.getItem() instanceof IBloodOrb)
|
|
|
|
tierMap.put(tier, stack);
|
|
|
|
}
|
|
|
|
|
2015-10-30 03:22:14 +00:00
|
|
|
@SideOnly(Side.CLIENT)
|
2016-01-10 22:34:01 +00:00
|
|
|
public static void registerOrbTexture(BloodOrb orb, ResourceLocation resourceLocation)
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
int meta = getIndexOf(orb);
|
|
|
|
|
2016-01-19 10:34:49 +00:00
|
|
|
ModelBakery.registerItemVariants(orbItem, resourceLocation);
|
|
|
|
ModelLoader.setCustomModelResourceLocation(orbItem, meta, new ModelResourceLocation(resourceLocation, "inventory"));
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public static BloodOrb getOrb(int index)
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
return orbs.get(index);
|
|
|
|
}
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public static int getIndexOf(BloodOrb orb)
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
return orbs.indexOf(orb);
|
|
|
|
}
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public static boolean isEmpty()
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
return orbs.isEmpty();
|
|
|
|
}
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public static int getSize()
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
return orbs.size();
|
|
|
|
}
|
|
|
|
|
2016-02-17 04:48:42 +00:00
|
|
|
public static List<ItemStack> getOrbsForTier(int tier)
|
|
|
|
{
|
|
|
|
if (getTierMap().containsKey(tier))
|
|
|
|
return getTierMap().get(tier);
|
|
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static List<ItemStack> getOrbsUpToTier(int tier)
|
|
|
|
{
|
|
|
|
List<ItemStack> ret = new ArrayList<ItemStack>();
|
|
|
|
|
|
|
|
for (int i = 1; i <= tier; i++)
|
|
|
|
ret.addAll(getOrbsForTier(i));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static List<ItemStack> getOrbsDownToTier(int tier)
|
|
|
|
{
|
|
|
|
List<ItemStack> ret = new ArrayList<ItemStack>();
|
|
|
|
|
|
|
|
for (int i = EnumAltarTier.MAXTIERS; i >= tier; i--)
|
|
|
|
ret.addAll(getOrbsForTier(i));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public static ItemStack getOrbStack(BloodOrb orb)
|
|
|
|
{
|
2016-01-19 10:34:49 +00:00
|
|
|
return new ItemStack(orbItem, 1, getIndexOf(orb));
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
2016-02-18 17:49:12 +00:00
|
|
|
|
2016-03-16 22:41:06 +00:00
|
|
|
public static List<BloodOrb> getOrbs()
|
|
|
|
{
|
2016-02-18 17:49:12 +00:00
|
|
|
return new ArrayList<BloodOrb>(orbs);
|
|
|
|
}
|
|
|
|
|
2016-03-16 22:41:06 +00:00
|
|
|
public static ArrayListMultimap<Integer, ItemStack> getTierMap()
|
|
|
|
{
|
2016-02-18 17:49:12 +00:00
|
|
|
return ArrayListMultimap.create(tierMap);
|
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|