Readded the Alchemy Table

Finished adding the Alchemy Table with JEI compatability. Also added recipes for the ARC block and the Alchemy Table.
This commit is contained in:
WayofTime 2020-10-31 13:42:28 -04:00
parent 37c5e807b0
commit bf6250272c
41 changed files with 1915 additions and 29 deletions

View file

@ -0,0 +1,22 @@
package wayoftime.bloodmagic.common.recipe;
import java.util.function.Consumer;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tags.ItemTags;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.common.data.recipe.builder.AlchemyTableRecipeBuilder;
public class AlchemyTableRecipeProvider implements ISubRecipeProvider
{
@Override
public void addRecipes(Consumer<IFinishedRecipe> consumer)
{
String basePath = "alchemytable/";
AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(Items.STRING, 4), 0, 100, 0).addIngredient(Ingredient.fromTag(ItemTags.WOOL)).addIngredient(Ingredient.fromItems(Items.FLINT)).build(consumer, BloodMagic.rl(basePath + "string"));
}
}

View file

@ -3,6 +3,7 @@ package wayoftime.bloodmagic.common.recipe;
import net.minecraft.item.crafting.IRecipeType;
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyTable;
import wayoftime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
import wayoftime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
@ -12,4 +13,5 @@ public class BloodMagicRecipeType
public static final IRecipeType<RecipeAlchemyArray> ARRAY = IRecipeType.register("array");
public static final IRecipeType<RecipeTartaricForge> TARTARICFORGE = IRecipeType.register("soulforge");
public static final IRecipeType<RecipeARC> ARC = IRecipeType.register("arc");
public static final IRecipeType<RecipeAlchemyTable> ALCHEMYTABLE = IRecipeType.register("alchemytable");
}

View file

@ -0,0 +1,122 @@
package wayoftime.bloodmagic.common.recipe.serializer;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistryEntry;
import wayoftime.bloodmagic.api.SerializerHelper;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyTable;
import wayoftime.bloodmagic.util.Constants;
public class AlchemyTableRecipeSerializer<RECIPE extends RecipeAlchemyTable>
extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<RECIPE>
{
private final IFactory<RECIPE> factory;
public AlchemyTableRecipeSerializer(IFactory<RECIPE> factory)
{
this.factory = factory;
}
@Nonnull
@Override
public RECIPE read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json)
{
List<Ingredient> inputList = new ArrayList<Ingredient>();
if (json.has(Constants.JSON.INPUT) && JSONUtils.isJsonArray(json, Constants.JSON.INPUT))
{
JsonArray mainArray = JSONUtils.getJsonArray(json, Constants.JSON.INPUT);
arrayLoop: for (JsonElement element : mainArray)
{
if (inputList.size() >= RecipeAlchemyTable.MAX_INPUTS)
{
break arrayLoop;
}
if (element.isJsonArray())
{
element = element.getAsJsonArray();
} else
{
element.getAsJsonObject();
}
inputList.add(Ingredient.deserialize(element));
}
}
ItemStack output = SerializerHelper.getItemStack(json, Constants.JSON.OUTPUT);
int syphon = JSONUtils.getInt(json, Constants.JSON.SYPHON);
int ticks = JSONUtils.getInt(json, Constants.JSON.TICKS);
int minimumTier = JSONUtils.getInt(json, Constants.JSON.ALTAR_TIER);
return this.factory.create(recipeId, inputList, output, syphon, ticks, minimumTier);
}
@Override
public RECIPE read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer)
{
try
{
int size = buffer.readInt();
List<Ingredient> input = new ArrayList<Ingredient>(size);
for (int i = 0; i < size; i++)
{
input.add(i, Ingredient.read(buffer));
}
buffer.writeInt(input.size());
for (int i = 0; i < input.size(); i++)
{
input.get(i).write(buffer);
}
ItemStack output = buffer.readItemStack();
int syphon = buffer.readInt();
int ticks = buffer.readInt();
int minimumTier = buffer.readInt();
return this.factory.create(recipeId, input, output, syphon, ticks, minimumTier);
} catch (Exception e)
{
//Mekanism.logger.error("Error reading electrolysis recipe from packet.", e);
throw e;
}
}
@Override
public void write(@Nonnull PacketBuffer buffer, @Nonnull RECIPE recipe)
{
try
{
recipe.write(buffer);
} catch (Exception e)
{
//Mekanism.logger.error("Error writing electrolysis recipe to packet.", e);
throw e;
}
}
@FunctionalInterface
public interface IFactory<RECIPE extends RecipeAlchemyTable>
{
RECIPE create(ResourceLocation id, List<Ingredient> input, ItemStack output, int syphon, int ticks, int minimumTier);
}
}