Unicopia/src/main/java/com/minelittlepony/unicopia/item/GlowingRecipe.java

47 lines
1.3 KiB
Java
Raw Normal View History

2021-02-03 21:25:42 +01:00
package com.minelittlepony.unicopia.item;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
2021-02-14 21:15:30 +01:00
public class GlowingRecipe extends ItemCombinationRecipe {
2021-02-03 21:25:42 +01:00
public GlowingRecipe(Identifier id) {
super(id);
}
@Override
2021-02-14 21:15:30 +01:00
public final ItemStack craft(CraftingInventory inventory) {
2021-02-03 21:25:42 +01:00
Pair<ItemStack, ItemStack> pair = runMatch(inventory);
ItemStack result = pair.getLeft().copy();
2021-02-14 21:15:30 +01:00
2021-02-03 21:25:42 +01:00
((GlowableItem)result.getItem()).setGlowing(result, pair.getRight().getItem() == Items.GLOWSTONE_DUST);
return result;
}
2021-02-14 21:15:30 +01:00
@Override
protected boolean isContainerItem(ItemStack stack) {
return stack.getItem() instanceof GlowableItem;
}
2021-02-03 21:25:42 +01:00
2021-02-14 21:15:30 +01:00
@Override
protected boolean isInsertItem(ItemStack stack) {
return stack.getItem() == Items.GLOWSTONE_DUST || stack.getItem() == Items.INK_SAC;
2021-02-03 21:25:42 +01:00
}
@Override
2021-02-14 21:15:30 +01:00
protected boolean isCombinationInvalid(ItemStack bangle, ItemStack dust) {
return (dust.getItem() == Items.GLOWSTONE_DUST) == ((GlowableItem)bangle.getItem()).isGlowing(bangle);
2021-02-03 21:25:42 +01:00
}
@Override
public RecipeSerializer<?> getSerializer() {
return URecipes.GLOWING_SERIALIZER;
}
}