Advertisement
Guest User

Untitled

a guest
Feb 1st, 2021
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. package com.nick.humlands.common.recipe;
  2.  
  3. import com.google.gson.JsonObject;
  4.  
  5. import net.minecraft.item.ItemStack;
  6. import net.minecraft.item.crafting.IRecipeSerializer;
  7. import net.minecraft.item.crafting.Ingredient;
  8. import net.minecraft.network.PacketBuffer;
  9. import net.minecraft.util.JSONUtils;
  10. import net.minecraft.util.ResourceLocation;
  11. import net.minecraftforge.common.crafting.CraftingHelper;
  12. import net.minecraftforge.registries.ForgeRegistryEntry;
  13.  
  14. public class SculptorRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>>
  15. implements IRecipeSerializer<SculptorRecipe> {
  16.  
  17. @Override
  18. public SculptorRecipe read(ResourceLocation recipeId, JsonObject json) {
  19. ItemStack output = CraftingHelper.getItemStack(JSONUtils.getJsonObject(json, "output"), true);
  20. Ingredient input = Ingredient.deserialize(JSONUtils.getJsonObject(json, "input"));
  21.  
  22. return new SculptorRecipe(recipeId, input, output);
  23. }
  24.  
  25. @Override
  26. public SculptorRecipe read(ResourceLocation recipeId, PacketBuffer buffer) {
  27. ItemStack output = buffer.readItemStack();
  28. Ingredient input = Ingredient.read(buffer);
  29.  
  30. return new SculptorRecipe(recipeId, input, output);
  31. }
  32.  
  33. @Override
  34. public void write(PacketBuffer buffer, SculptorRecipe recipe) {
  35. Ingredient input = recipe.getIngredients().get(0);
  36. input.write(buffer);
  37.  
  38. buffer.writeItemStack(recipe.getRecipeOutput(), false);
  39. }
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement