Search in sources :

Example 1 with ScepterItem

use of moriyashiine.bewitchment.common.item.ScepterItem in project bewitchment by MoriyaShiine.

the class ScepterCraftingRecipe method craft.

@Override
public ItemStack craft(CraftingInventory inv) {
    ItemStack scepter = null, potion = null;
    for (int i = 0; i < inv.size(); i++) {
        ItemStack stack = inv.getStack(i);
        if (stack.getItem() instanceof ScepterItem) {
            scepter = stack.copy();
        } else if (stack.getItem() instanceof SplashPotionItem) {
            potion = stack.copy();
        }
    }
    scepter.getOrCreateNbt().putInt("PotionUses", 4);
    PotionUtil.setCustomPotionEffects(scepter, !PotionUtil.getCustomPotionEffects(potion).isEmpty() ? PotionUtil.getCustomPotionEffects(potion) : PotionUtil.getPotionEffects(potion));
    if (potion.getOrCreateNbt().contains("PolymorphUUID")) {
        scepter.getOrCreateNbt().putUuid("PolymorphUUID", potion.getOrCreateNbt().getUuid("PolymorphUUID"));
        scepter.getOrCreateNbt().putString("PolymorphName", potion.getOrCreateNbt().getString("PolymorphName"));
    }
    return scepter;
}
Also used : SplashPotionItem(net.minecraft.item.SplashPotionItem) ItemStack(net.minecraft.item.ItemStack) ScepterItem(moriyashiine.bewitchment.common.item.ScepterItem)

Example 2 with ScepterItem

use of moriyashiine.bewitchment.common.item.ScepterItem in project bewitchment by MoriyaShiine.

the class ScepterCraftingRecipe method matches.

@Override
public boolean matches(CraftingInventory inv, World world) {
    boolean foundScepter = false, foundPotion = false;
    int foundItems = 0;
    for (int i = 0; i < inv.size(); i++) {
        ItemStack stack = inv.getStack(i);
        if (stack.getItem() instanceof ScepterItem) {
            if (!foundScepter) {
                foundScepter = true;
            }
            foundItems++;
        } else if (stack.getItem() instanceof SplashPotionItem && (!PotionUtil.getPotionEffects(stack).isEmpty() || !PotionUtil.getCustomPotionEffects(stack).isEmpty())) {
            if (!foundPotion) {
                foundPotion = true;
            }
            foundItems++;
        }
    }
    return foundScepter && foundPotion && foundItems == 2;
}
Also used : SplashPotionItem(net.minecraft.item.SplashPotionItem) ItemStack(net.minecraft.item.ItemStack) ScepterItem(moriyashiine.bewitchment.common.item.ScepterItem)

Aggregations

ScepterItem (moriyashiine.bewitchment.common.item.ScepterItem)2 ItemStack (net.minecraft.item.ItemStack)2 SplashPotionItem (net.minecraft.item.SplashPotionItem)2