JEI support for Blood Orb recipe type
We can now move all the recipes over to Shape(d/less)BloodOrbRecipe
This commit is contained in:
parent
65dd24b19b
commit
af193c3e5b
9 changed files with 384 additions and 14 deletions
|
@ -105,9 +105,15 @@ public class ShapedBloodOrbRecipe implements IRecipe
|
|||
// If the item is an instanceof IBloodOrb then save the level of
|
||||
// the orb.
|
||||
if (in instanceof ItemStack)
|
||||
itemMap.put(chr, ((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage()));
|
||||
else
|
||||
itemMap.put(chr, ((IBloodOrb) in).getOrbLevel(((ItemStack) in).getItemDamage()));
|
||||
{
|
||||
ItemStack inStack = (ItemStack) in;
|
||||
tier = ((IBloodOrb) inStack.getItem()).getOrbLevel(inStack.getItemDamage());
|
||||
itemMap.put(chr, tier);
|
||||
} else
|
||||
{
|
||||
tier = ((IBloodOrb) in).getOrbLevel(0);
|
||||
itemMap.put(chr, tier);
|
||||
}
|
||||
} else if (in instanceof ItemStack)
|
||||
{
|
||||
itemMap.put(chr, ((ItemStack) in).copy());
|
||||
|
@ -238,7 +244,6 @@ public class ShapedBloodOrbRecipe implements IRecipe
|
|||
if (slot != null && slot.getItem() instanceof IBloodOrb)
|
||||
{
|
||||
IBloodOrb orb = (IBloodOrb) slot.getItem();
|
||||
tier = (Integer) target;
|
||||
if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) target)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -40,13 +40,23 @@ public class ShapelessBloodOrbRecipe implements IRecipe
|
|||
output = result.copy();
|
||||
for (Object in : recipe)
|
||||
{
|
||||
if (in instanceof ItemStack)
|
||||
if (in instanceof IBloodOrb || (in instanceof ItemStack && ((ItemStack) in).getItem() instanceof IBloodOrb))
|
||||
{
|
||||
if (((ItemStack) in).getItem() instanceof IBloodOrb)
|
||||
// If the item is an instanceof IBloodOrb then save the level of
|
||||
// the orb.
|
||||
if (in instanceof ItemStack)
|
||||
{
|
||||
input.add(((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage()));
|
||||
ItemStack inStack = (ItemStack) in;
|
||||
tier = ((IBloodOrb) inStack.getItem()).getOrbLevel(inStack.getItemDamage());
|
||||
input.add(tier);
|
||||
} else
|
||||
input.add(((ItemStack) in).copy());
|
||||
{
|
||||
tier = ((IBloodOrb) in).getOrbLevel(0);
|
||||
input.add(tier);
|
||||
}
|
||||
}else if (in instanceof ItemStack)
|
||||
{
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item)
|
||||
{
|
||||
input.add(new ItemStack((Item) in));
|
||||
|
@ -134,7 +144,6 @@ public class ShapelessBloodOrbRecipe implements IRecipe
|
|||
if (slot.getItem() instanceof IBloodOrb)
|
||||
{
|
||||
IBloodOrb orb = (IBloodOrb) slot.getItem();
|
||||
tier = (Integer) next;
|
||||
if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) next)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -2,7 +2,10 @@ package WayofTime.bloodmagic.api.registry;
|
|||
|
||||
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 lombok.Getter;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
|
@ -14,6 +17,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -24,17 +28,28 @@ public class OrbRegistry
|
|||
{
|
||||
@Getter
|
||||
private static List<BloodOrb> orbs = new ArrayList<BloodOrb>();
|
||||
@Getter
|
||||
private static ArrayListMultimap<Integer, ItemStack> tierMap = ArrayListMultimap.create();
|
||||
|
||||
private static Item orbItem = Constants.BloodMagicItem.BLOOD_ORB.getItem();
|
||||
|
||||
public static void registerOrb(BloodOrb orb)
|
||||
{
|
||||
if (!orbs.contains(orb))
|
||||
{
|
||||
orbs.add(orb);
|
||||
registerOrbForTier(orb.getTier(), getOrbStack(orb));
|
||||
}
|
||||
else
|
||||
BloodMagicAPI.getLogger().error("Error adding orb %s. Orb already exists!", orb.toString());
|
||||
}
|
||||
|
||||
public static void registerOrbForTier(int tier, ItemStack stack)
|
||||
{
|
||||
if (stack.getItem() instanceof IBloodOrb)
|
||||
tierMap.put(tier, stack);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerOrbTexture(BloodOrb orb, ResourceLocation resourceLocation)
|
||||
{
|
||||
|
@ -64,6 +79,34 @@ public class OrbRegistry
|
|||
return orbs.size();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static ItemStack getOrbStack(BloodOrb orb)
|
||||
{
|
||||
return new ItemStack(orbItem, 1, getIndexOf(orb));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue