arturkr Posted January 4, 2021 Posted January 4, 2021 I have a recipe in which I use a vanilla item from minecraft. But when crafting, this item disappears, how to make sure that the vanilla item does not disappear when crafting?😅 Quote
arturkr Posted January 4, 2021 Author Posted January 4, 2021 5 minutes ago, diesieben07 said: You need a custom crafting recipe implementation and override getRemainingItems. And where can I see the documentation for getRemainingItems? Quote
arturkr Posted January 4, 2021 Author Posted January 4, 2021 19 minutes ago, diesieben07 said: There is none, as it is a vanilla method and nobody has written docs for it yet. Then you can tell me where the getRemainingItems method is located, so that I can study it Quote
arturkr Posted January 4, 2021 Author Posted January 4, 2021 Really? You have an inflated sense of self-importance thx for hepl😒 Quote
Beethoven92 Posted January 4, 2021 Posted January 4, 2021 Dieseben07 already told you what to do..if you want a more specific suggestion, some classes you may find helpful to look at are the SpecialRecipe class and its subclasses. In particular you can see how vanilla uses the getRemainingItems method in BannerDuplicateRecipe and BookCloningRecipe classes Quote Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port
arturkr Posted January 4, 2021 Author Posted January 4, 2021 10 minutes ago, Beethoven92 said: Dieseben07 already told you what to do..if you want a more specific suggestion, some classes you may find helpful to look at are the SpecialRecipe class and its subclasses. In particular you can see how vanilla uses the getRemainingItems method in BannerDuplicateRecipe and BookCloningRecipe classes I don't know where to define getRemainingItems and how to make it "work" later Quote
Beethoven92 Posted January 4, 2021 Posted January 4, 2021 5 hours ago, diesieben07 said: You need a custom crafting recipe implementation and override getRemainingItems. You override the method getRemainingItems in your custom recipe class.. if you looked at the classes i suggested you you would see exactly how vanilla does that Quote Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port
arturkr Posted January 4, 2021 Author Posted January 4, 2021 1 hour ago, Beethoven92 said: You override the method getRemainingItems in your custom recipe class.. if you looked at the classes i suggested you you would see exactly how vanilla does that Will I need to add a recipe using code and not a json file? Quote
arturkr Posted January 4, 2021 Author Posted January 4, 2021 1 hour ago, Beethoven92 said: You override the method getRemainingItems in your custom recipe class.. if you looked at the classes i suggested you you would see exactly how vanilla does that God, how difficult. Why is there no documentation? public class White_dust extends SpecialRecipe{ public White_dust(ResourceLocation idIn) { super(idIn); } public boolean matches(CraftingInventory inv, World worldIn) { DyeColor dyecolor = null; ItemStack itemstack = null; ItemStack itemstack1 = null; for(int i = 0; i < inv.getSizeInventory(); ++i) { ItemStack itemstack2 = inv.getStackInSlot(i); Item item = itemstack2.getItem(); if (item instanceof BannerItem) { BannerItem banneritem = (BannerItem)item; if (dyecolor == null) { dyecolor = banneritem.getColor(); } else if (dyecolor != banneritem.getColor()) { return false; } int j = BannerTileEntity.getPatterns(itemstack2); if (j > 6) { return false; } if (j > 0) { if (itemstack != null) { return false; } itemstack = itemstack2; } else { if (itemstack1 != null) { return false; } itemstack1 = itemstack2; } } } return itemstack != null && itemstack1 != null; } /** * Returns an Item that is the result of this recipe */ public ItemStack getCraftingResult(CraftingInventory inv) { for(int i = 0; i < inv.getSizeInventory(); ++i) { ItemStack itemstack = inv.getStackInSlot(i); if (!itemstack.isEmpty()) { int j = BannerTileEntity.getPatterns(itemstack); if (j > 0 && j <= 6) { ItemStack itemstack1 = itemstack.copy(); itemstack1.setCount(1); return itemstack1; } } } return ItemStack.EMPTY; } public NonNullList<ItemStack> getRemainingItems(CraftingInventory inv) { NonNullList<ItemStack> nonnulllist = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY); for(int i = 0; i < nonnulllist.size(); ++i) { ItemStack itemstack = inv.getStackInSlot(i); if (!itemstack.isEmpty()) { if (itemstack.hasContainerItem()) { nonnulllist.set(i, itemstack.getContainerItem()); } else if (itemstack.hasTag() && BannerTileEntity.getPatterns(itemstack) > 0) { ItemStack itemstack1 = itemstack.copy(); itemstack1.setCount(1); nonnulllist.set(i, itemstack1); } } } return nonnulllist; } public IRecipeSerializer<?> getSerializer() { return IRecipeSerializer.CRAFTING_SPECIAL_BANNERDUPLICATE; } public boolean canFit(int width, int height) { return width * height >= 2; } } I just look and do not understand what and why it causes? What are all these methods for? I only figured out "public IRecipeSerializer <?> GetSerializer ()", then it seems that I should return not CRAFTING_SPECIAL_BANNERDUPLICATE, but CRAFTING_SHAPELESS. But I'm not sure about that either Quote
ChampionAsh5357 Posted January 4, 2021 Posted January 4, 2021 15 minutes ago, arturkr said: Will I need to add a recipe using code and not a json file? Depends on the complexity of the recipe. If there is no requirement for dynamic manipulation, you can get away with making a custom recipe with serializer and building a json off of that. 2 minutes ago, arturkr said: I just look and do not understand what and why it causes? What are all these methods for? I only figured out "public IRecipeSerializer <?> GetSerializer ()", then it seems that I should return not CRAFTING_SPECIAL_BANNERDUPLICATE, but CRAFTING_SHAPELESS. But I'm not sure about that either You haven't created the recipe serializer. Take a look at ShapedRecipe for that. Also, every method within IRecipe except for basically two (I'm not counting the getters) has documentation associated with it. The other two gets the items that are supposed to be left over in the inventory using container items while the other gets the recipe ingredients. Quote
arturkr Posted January 4, 2021 Author Posted January 4, 2021 1 minute ago, ChampionAsh5357 said: Depends on the complexity of the recipe. If there is no requirement for dynamic manipulation, you can get away with making a custom recipe with serializer and building a json off of that. What is a complex recipe? I have a simple craft on the workbench Quote
arturkr Posted January 4, 2021 Author Posted January 4, 2021 2 minutes ago, loordgek said: dont use that font size plz ( Quote
ChampionAsh5357 Posted January 4, 2021 Posted January 4, 2021 7 minutes ago, arturkr said: What is a complex recipe? I have a simple craft on the workbench You have to answer that question yourself. What are you attempting to do in a generic form? I see you trying to keep a specific item in the crafting table and not be used. Is that the only case or does this expand to any item for a specific recipe? These are questions that need to be answered. Quote
arturkr Posted January 4, 2021 Author Posted January 4, 2021 36 minutes ago, ChampionAsh5357 said: You have to answer that question yourself. What are you attempting to do in a generic form? I see you trying to keep a specific item in the crafting table and not be used. Is that the only case or does this expand to any item for a specific recipe? These are questions that need to be answered. I'll tell you in detail: I added three items to the game - 1.pounder 2.Ore 3.milled ore I also made a recipe: 1.bowl 2.Ore 3.pounder Result: 1.milled ore The recipe is shapeless. I have implemented functions so that when crafting the pestle is not wasted, but -1 damage. It remains to make sure that the bowl does not disappear. Quote
arturkr Posted January 5, 2021 Author Posted January 5, 2021 13 hours ago, diesieben07 said: You need an IRecipeSerializer. This is a normal registry entry. Refer to the documentation as for how to register them. Then in your recipe json file you need to set the type property to the resource location of your serializer. Your serializer will then be called with the JSON of your recipe and needs to return an ICraftingRecipe instance. WHERE? IN WHICH PLACE? Where does this documentation refer to the IRecipeSerializer? Maybe I'm blind, but I haven't read the worse documentation yet Quote
arturkr Posted January 5, 2021 Author Posted January 5, 2021 (edited) Is it real? Only three Google pages? 99.9% of the results are not about what is needed, but 0.1% is the CLICK, and they did not help him... Really worst help. How are they recruited into the forum team? It's the same as if you ask "How to put the door?" And I answer "Put the door" Edited January 5, 2021 by arturkr Quote
arturkr Posted January 5, 2021 Author Posted January 5, 2021 - How to solve quantum entanglement? - Solve quantum entanglement - THX!!!!!!!!!!!!!!!!!!!!!!!!!! 😒 Quote
arturkr Posted January 5, 2021 Author Posted January 5, 2021 4 minutes ago, diesieben07 said: Dude. You asked "how to register IRecipeSerializer"? I linked you the documentation that explains you how to register any registry entry. Yes, but I don't even know where and how to build the "register IRecipeSerializer" correctly Quote
arturkr Posted January 5, 2021 Author Posted January 5, 2021 4 minutes ago, diesieben07 said: I don't know what you mean by that. Have you even tried following the documentation? Yes, but the only thing I came up with is this: public static final RegistryObject<IRecipeSerializer<IRecipe<?>>> WHITE_DUST = IRecipeSerializer.CRAFTING_SHAPELESS.IDK(((; But I understand that this is nonsense Quote
arturkr Posted January 5, 2021 Author Posted January 5, 2021 3 minutes ago, diesieben07 said: You need to start out by making a DeferredRegister instance for it. It works exactly the same as for blocks and items, which you have already done. This is why I am having a hard time understanding your struggle. public static final DeferredRegister<IRecipeSerializer<?>> RECIPE = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, Main.MOD_ID); public static final RegistryObject<IRecipeSerializer<IRecipe<?>>> WHITE_DUST_RECIPE = RECIPE.register("white_dust_recipe", () -> new NEXT IDK Quote
arturkr Posted January 5, 2021 Author Posted January 5, 2021 8 minutes ago, diesieben07 said: You need to implement IRecipeSerializer. Then? public class Mortar implements IRecipeSerializer<IRecipe<?>>{ @Override public IRecipeSerializer<?> setRegistryName(ResourceLocation name) { // TODO Auto-generated method stub return null; } @Override public ResourceLocation getRegistryName() { // TODO Auto-generated method stub return null; } @Override public Class<IRecipeSerializer<?>> getRegistryType() { // TODO Auto-generated method stub return null; } @Override public IRecipe<?> read(ResourceLocation recipeId, JsonObject json) { // TODO Auto-generated method stub return null; } @Override public IRecipe<?> read(ResourceLocation recipeId, PacketBuffer buffer) { // TODO Auto-generated method stub return null; } @Override public void write(PacketBuffer buffer, IRecipe<?> recipe) { // TODO Auto-generated method stub } } Quote
Draco18s Posted January 5, 2021 Posted January 5, 2021 Start by making the stubs not-stubs. You can look at the other recipe implementations for help. Heck, you may even want to extend one of them to make your life easier. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
arturkr Posted January 5, 2021 Author Posted January 5, 2021 23 minutes ago, Draco18s said: Start by making the stubs not-stubs. You can look at the other recipe implementations for help. Heck, you may even want to extend one of them to make your life easier. I still don't know what to do ( You speak as if it is very easy. So if it's easy, just show where and what to write. I will understand how IRecipeSerializer works faster Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.