51 lines
1.8 KiB
Java
51 lines
1.8 KiB
Java
package com.thebrokenrail.reliccraft.recipe;
|
|
|
|
import com.thebrokenrail.reliccraft.RelicCraft;
|
|
import net.minecraft.inventory.CraftingInventory;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.item.Items;
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.recipe.Ingredient;
|
|
import net.minecraft.recipe.RecipeSerializer;
|
|
import net.minecraft.recipe.ShapelessRecipe;
|
|
import net.minecraft.util.Identifier;
|
|
import net.minecraft.util.collection.DefaultedList;
|
|
import java.util.Random;
|
|
|
|
public class TimeDilaterRecipe extends ShapelessRecipe {
|
|
private static final DefaultedList<Ingredient> INGREDIENTS;
|
|
private static final ItemStack OUTPUT;
|
|
|
|
static {
|
|
INGREDIENTS = DefaultedList.of();
|
|
INGREDIENTS.add(Ingredient.ofItems(Items.NETHER_STAR));
|
|
INGREDIENTS.add(Ingredient.ofItems(RelicCraft.TIME_DILATER_ITEM));
|
|
INGREDIENTS.add(Ingredient.ofItems(Items.CLOCK));
|
|
|
|
OUTPUT = new ItemStack(RelicCraft.TIME_DILATER_ITEM);
|
|
CompoundTag tag = new CompoundTag();
|
|
tag.putByte("Artificial", (byte) 1);
|
|
OUTPUT.setTag(tag);
|
|
}
|
|
|
|
public TimeDilaterRecipe(Identifier id) {
|
|
super(id, "", OUTPUT, INGREDIENTS);
|
|
}
|
|
|
|
public RecipeSerializer<?> getSerializer() {
|
|
return RelicCraft.TIME_DILATER_RECIPE;
|
|
}
|
|
|
|
@Override
|
|
public DefaultedList<ItemStack> getRemainingStacks(CraftingInventory inventory) {
|
|
DefaultedList<ItemStack> defaultedList = DefaultedList.ofSize(inventory.size(), ItemStack.EMPTY);
|
|
for (int i = 0; i < defaultedList.size(); i++) {
|
|
ItemStack stack = inventory.getStack(i);
|
|
if (stack.getItem() == Items.NETHER_STAR && !stack.damage(1, new Random(), null) || stack.getItem() == RelicCraft.TIME_DILATER_ITEM) {
|
|
defaultedList.set(i, stack.copy());
|
|
}
|
|
}
|
|
return defaultedList;
|
|
}
|
|
}
|