Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?😅

  • Author
5 minutes ago, diesieben07 said:

You need a custom crafting recipe implementation and override getRemainingItems.

And where can I see the documentation for getRemainingItems?

  • Author
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

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

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

  • Author
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

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

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

  • Author
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?

  • Author
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

 

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.

  • Author
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

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.

  • Author
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.

 

1357791503_.png.3130b0f177e58019d4d74a3fb4709ef8.png

 

382355769_.png.5b33d459e1133ff9ef090d08b85a058f.png

 

 

  • Author
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

  • Author

1351843699_.thumb.png.7ed05e1df81ea947d8dec01431159cf8.png

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 by arturkr

  • Author

- How to solve quantum entanglement?
- Solve quantum entanglement

- THX!!!!!!!!!!!!!!!!!!!!!!!!!!

😒

  • Author
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

  • Author
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

  • Author
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

 

  • Author
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
				
			}
	
}

 

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.

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.

  • Author
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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.