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;
}
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;
}
Aggregations