Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.kup.burgercraft.crafting.recipe;
- import com.google.gson.JsonObject;
- import com.kup.burgercraft.setup.ModRecipes;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.crafting.*;
- import net.minecraft.network.PacketBuffer;
- import net.minecraft.util.JSONUtils;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.world.World;
- import net.minecraftforge.registries.ForgeRegistries;
- import net.minecraftforge.registries.ForgeRegistryEntry;
- import javax.annotation.Nullable;
- public class MeatGrindingRecipe extends SingleItemRecipe{
- public MeatGrindingRecipe(ResourceLocation recipeId,
- Ingredient ingredient,
- ItemStack result) {
- super(ModRecipes.Types.MEAT_GRINDING_TYPE, ModRecipes.Serializers.MEAT_GRINDING.get(), recipeId, "", ingredient, result);
- }
- @Override
- public boolean matches(IInventory inventory, World world) {
- return this.ingredient.test(inventory.getItem(0));
- }
- public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<MeatGrindingRecipe> {
- @Override
- public MeatGrindingRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
- Ingredient ingredient = Ingredient.fromJson(json.get("ingredient"));
- ResourceLocation itemId = new ResourceLocation(JSONUtils.getAsString(json, "result"));
- int count = JSONUtils.getAsInt(json, "count", 1);
- ItemStack result = new ItemStack(ForgeRegistries.ITEMS.getValue(itemId), count);
- return new MeatGrindingRecipe(recipeId, ingredient, result);
- }
- @Nullable
- @Override
- public MeatGrindingRecipe fromNetwork(ResourceLocation recipeId, PacketBuffer buffer) {
- Ingredient ingredient = Ingredient.fromNetwork(buffer);
- ItemStack result = buffer.readItem();
- return new MeatGrindingRecipe(recipeId, ingredient, result);
- }
- @Override
- public void toNetwork(PacketBuffer buffer, MeatGrindingRecipe recipe) {
- recipe.ingredient.toNetwork(buffer);
- buffer.writeItem(recipe.result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement