Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-4296

ShapedRecipe.setGroup(<string>) does not appear to work.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • General Plugin Development, attempting to group up custom items into the recipe book

    • This server is running CraftBukkit version git-Spigot-fe3ab0d-82f4b3b (MC: 1.13) (Implementing API version 1.13-R0.1-SNAPSHOT)
    • Yes

      recently Issue: https://hub.spigotmc.org/jira/browse/SPIGOT-4295 was added, allowing us to add the Group designation to recipes to group them together in the recipe book such as IronIngot's / Blocks / Nuggets

       

      Given the following code on multiple items with the same OUTPUT material (different display name though)  the items do not group regardless of setGroup being used.

       

      			ShapedRecipe sr = new ShapedRecipe(new NamespacedKey(Guns.getPlugin(), this.name().toLowerCase()), this.createAmmo(1));
      			String[] shape = new String[] {shp1, shp2,shp3};
      			sr.shape(shp1,shp2,shp3);
      			for(String s:shape)
      			{
      				if(s.contains("d"))
      					sr.setIngredient('d', Material.DIAMOND);
      				if(s.contains("e"))
      					sr.setIngredient('e', Material.ENDER_EYE);
      				if(s.contains("i"))
      					sr.setIngredient('i', Material.IRON_NUGGET);
      				if(s.contains("g"))
      					sr.setIngredient('g', Material.GOLD_NUGGET);
      				if(s.contains("r"))
      					sr.setIngredient('r', Material.ROTTEN_FLESH);
      				if(s.contains("I"))
      					sr.setIngredient('I', Material.IRON_INGOT);
      				if(s.contains("A"))
      					sr.setIngredient('A', Material.GOLD_INGOT);
      				if(s.contains("G"))
      					sr.setIngredient('G', Material.GUNPOWDER);
      			}
      			sr.setGroup("ammunition");
      			
      			this.rec = sr;
      			try {
      				Guns.getPlugin().getServer().addRecipe(sr);
      

      I have also tried setting the group to "melon seeds", "melon_seeds" and various other things, according to the wiki for recipe creation the group name should not matter just as long as they're all the same.    I added in some debug code as well to try and track down the issue:

       

      	@EventHandler
      	public void oncraft(CraftItemEvent e)
      	{
      		if(e.getRecipe() instanceof ShapedRecipe)
      		{
      			ShapedRecipe sr = (ShapedRecipe) e.getRecipe();
      			if(sr.getGroup() == null || sr.getGroup().isEmpty())
      				return;
      			
      			System.out.println("Item was: " + sr.getResult().getType().name() + " group: " + sr.getGroup());
      		}
      	}
      

      The custom items when crafted do not trigger the system.out as if they do not have a group, the only items that do trigger the system.out are the vanilla groupings such as "iron_ingot"

       

      21.08 01:33:44 [Server] INFO Item was: IRON_INGOT group: iron_ingot

      Also odd is the above system.out only triggers on the iron, if one is creating iron_ingots from nuggets, and NOT from IronBlocks

       

      I hope im not missing something obvious, thanks in advance.

            Unassigned Unassigned
            whoolieshop Shane Martin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: