Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class Serializer extends ForgeRegistryEntry<RecipeSerializer<?>> implements RecipeSerializer<TankCrafterRecipe> {
- public static final Serializer INSTANCE = new Serializer();
- public static final String ID = "crafter";
- @Override
- public TankCrafterRecipe fromJson(ResourceLocation id, JsonObject json) {
- ItemStack output = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "output"));
- JsonArray ingredients = GsonHelper.getAsJsonArray(json, "ingredients");
- NonNullList<Ingredient> inputs = NonNullList.withSize(8, Ingredient.EMPTY);
- for (int i = 0; i < inputs.size(); i++) {
- inputs.set(i, Ingredient.fromJson(ingredients.get(i)));
- }
- return new TankCrafterRecipe(id, output, inputs);
- }
- @Override
- public TankCrafterRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) {
- NonNullList<Ingredient> inputs = NonNullList.withSize(buf.readInt(), Ingredient.EMPTY);
- for (int i = 0; i < inputs.size(); i++) {
- inputs.set(i, Ingredient.fromNetwork(buf));
- }
- ItemStack output = buf.readItem();
- return new TankCrafterRecipe(id, output,
- inputs);
- }
- @Override
- public void toNetwork(FriendlyByteBuf buf, TankCrafterRecipe recipe) {
- buf.writeInt(recipe.getIngredients().size());
- for (Ingredient ing : recipe.getIngredients()) {
- ing.toNetwork(buf);
- }
- buf.writeItemStack(recipe.getResultItem(), false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment