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 need to replace vanilla water bottle with empty bottle after craft, how can I do this?  I will give code if you will advice me something and error occurs.

EDIT: Version is 1.16.5

Edited by SuperRuper1209

it depends on wether you want the vanilla water bottle always return en empty water bottle (for any recipe that uses a water bottle), or if there is some specific recipes from your mod that you want that behaviour on

for the latter, the solution is using Special Recipes, you can look at the Book or Map cloning recipes for some example. you'll need to override the getRemainingItems method, and perform such logic there

  • Author

Parsing error loading recipe tds:marshmallow
com.google.gson.JsonSyntaxException: Invalid or unsupported recipe type 'tds:crafting_special_marshmallow'

Spoiler

public static class MarshmallowRecipe extends SpecialRecipe { public static final IRecipeSerializer<MarshmallowRecipe> SERIALIZER = new SpecialRecipeSerializer<>(MarshmallowRecipe::new); public MarshmallowRecipe(ResourceLocation p_i48169_1_) { super(p_i48169_1_); } @Override public boolean matches(CraftingInventory p_77569_1_, World p_77569_2_) { boolean foundSeeds = false; boolean foundBottle = false; boolean foundPotato = false; boolean foundSugar = false; boolean notRight = false; for (int j = 0; j < p_77569_1_.getContainerSize(); ++j) { ItemStack itemStack = p_77569_1_.getItem(j); if (!itemStack.isEmpty()) { if (itemStack.sameItem(new ItemStack(Items.POTATO)) && !foundPotato) { foundPotato = true; } else if (foundPotato && itemStack.sameItem(new ItemStack(Items.POTATO))) { notRight = true; } if (itemStack.sameItem(new ItemStack(Items.SUGAR)) && !foundSugar) { foundSugar = true; } else if (foundSugar && itemStack.sameItem(new ItemStack(Items.SUGAR))) { notRight = true; } if (PotionUtils.getPotion(itemStack) != null && PotionUtils.getPotion(itemStack) == Potions.WATER && !foundBottle) { foundBottle = true; } else if (foundBottle && PotionUtils.getPotion(itemStack) != null && PotionUtils.getPotion(itemStack) == Potions.WATER) { notRight = true; } if (Tags.Items.SEEDS.getValues().contains(itemStack.getItem()) && !foundSeeds) { foundSeeds = true; } else if (foundSeeds && Tags.Items.SEEDS.getValues().contains(itemStack.getItem())) { notRight = true; } } } if (foundSeeds && foundBottle && foundPotato && foundSugar && !notRight) { return true; } return false; } @Override public ItemStack assemble(CraftingInventory p_77572_1_) { ItemStack stack = new ItemStack(SimpleItems.MARSHALLOW); stack.setCount(1); return stack; } @Override public boolean canCraftInDimensions(int p_194133_1_, int p_194133_2_) { return true; } @Override public NonNullList<ItemStack> getRemainingItems(CraftingInventory p_179532_1_) { NonNullList<ItemStack> list = NonNullList.withSize(0, ItemStack.EMPTY); list.set(0, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.EMPTY)); return list; } @Override public IRecipeSerializer<?> getSerializer() { return SERIALIZER; } }

Spoiler

{ "type": "tds:crafting_special_marshmallow" }

Spoiler

Registry.register(Registry.RECIPE_SERIALIZER, new ResourceLocation("tds", "crafting_special_marshmallow"), Marshmallow.MarshmallowRecipe.SERIALIZER);

 

  • Author

Ok I got it, use this event to register if anyone has the same problem:

public void specialRecipesRegister(final RegistryEvent.Register<IRecipeSerializer<?>> event) { event.getRegistry().register(Marshmallow.MarshmallowRecipe.SERIALIZER.setRegistryName(new ResourceLocation("tds", "crafting_special_marshmallow"))); }

58 minutes ago, SuperRuper1209 said:

Parsing error loading recipe tds:marshmallow
com.google.gson.JsonSyntaxException: Invalid or unsupported recipe type 'tds:crafting_special_marshmallow'

  Reveal hidden contents

public static class MarshmallowRecipe extends SpecialRecipe { public static final IRecipeSerializer<MarshmallowRecipe> SERIALIZER = new SpecialRecipeSerializer<>(MarshmallowRecipe::new); public MarshmallowRecipe(ResourceLocation p_i48169_1_) { super(p_i48169_1_); } @Override public boolean matches(CraftingInventory p_77569_1_, World p_77569_2_) { boolean foundSeeds = false; boolean foundBottle = false; boolean foundPotato = false; boolean foundSugar = false; boolean notRight = false; for (int j = 0; j < p_77569_1_.getContainerSize(); ++j) { ItemStack itemStack = p_77569_1_.getItem(j); if (!itemStack.isEmpty()) { if (itemStack.sameItem(new ItemStack(Items.POTATO)) && !foundPotato) { foundPotato = true; } else if (foundPotato && itemStack.sameItem(new ItemStack(Items.POTATO))) { notRight = true; } if (itemStack.sameItem(new ItemStack(Items.SUGAR)) && !foundSugar) { foundSugar = true; } else if (foundSugar && itemStack.sameItem(new ItemStack(Items.SUGAR))) { notRight = true; } if (PotionUtils.getPotion(itemStack) != null && PotionUtils.getPotion(itemStack) == Potions.WATER && !foundBottle) { foundBottle = true; } else if (foundBottle && PotionUtils.getPotion(itemStack) != null && PotionUtils.getPotion(itemStack) == Potions.WATER) { notRight = true; } if (Tags.Items.SEEDS.getValues().contains(itemStack.getItem()) && !foundSeeds) { foundSeeds = true; } else if (foundSeeds && Tags.Items.SEEDS.getValues().contains(itemStack.getItem())) { notRight = true; } } } if (foundSeeds && foundBottle && foundPotato && foundSugar && !notRight) { return true; } return false; } @Override public ItemStack assemble(CraftingInventory p_77572_1_) { ItemStack stack = new ItemStack(SimpleItems.MARSHALLOW); stack.setCount(1); return stack; } @Override public boolean canCraftInDimensions(int p_194133_1_, int p_194133_2_) { return true; } @Override public NonNullList<ItemStack> getRemainingItems(CraftingInventory p_179532_1_) { NonNullList<ItemStack> list = NonNullList.withSize(0, ItemStack.EMPTY); list.set(0, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.EMPTY)); return list; } @Override public IRecipeSerializer<?> getSerializer() { return SERIALIZER; } }

  Reveal hidden contents

{ "type": "tds:crafting_special_marshmallow" }

  Reveal hidden contents

Registry.register(Registry.RECIPE_SERIALIZER, new ResourceLocation("tds", "crafting_special_marshmallow"), Marshmallow.MarshmallowRecipe.SERIALIZER);

 

it seems your problem is solved, but just a tip: when posting code to the forums, use the code block instead of the spoiler, it provides indendation and monospaced fonts which make the code actually readable

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.