promotional bannermobile promotional banner

CraftByCommand

Craft items using commands, even when it's a lot of resources !

Craft items with commands !

Fully customizable command recipe mod!

For players

To craft, do /craft or /c, then put the recipe id. They will be suggested.

To check a recipe's resources, do /seeRecipe, /resourcesFor or /sr, then the recipe id. They will be suggested.

For server owners

The recipe making system is really technical. Here is an exemple recipe :

{
  "id": "normal:milk_bucket",
  "result": {
    "id": "minecraft:bucket",
    "count": 1
  },
  "ingredients": [
    {
      "id": "minecraft:milk_bucket",
      "count": 1
    }
  ]
}

This takes a milk bucket and turns it into an empty bucket. It ignores the orginial bucket data.

Here is an exemple with the same bucket, but with a custom name (how to add minecraft data) :

{
  "id": "normal:milk_bucket",
  "result": {
    "id": "minecraft:milk_bucket",
    "count": 1,
    "components": {
      "minecraft:custom_name": {
        "text": "",
        "extra": [
          {
            "text": "M",
            "color": "#424242",
            "italic": false
          },
          {
            "text": "i",
            "color": "#818181",
            "italic": false
          },
          {
            "text": "l",
            "color": "#C0C0C0",
            "italic": false
          },
          {
            "text": "k",
            "color": "white",
            "italic": false
          }
        ]
      }
    }
  },
  "ingredients": [
    {
      "id": "minecraft:milk_bucket",
      "count": 1
    }
  ]
}

Then, you have the custom items, like this one :

{
  "id": "osc:fixed_stab",
  "result": {
    "id": "custom:stab_fixed",
    "extra": {}
  },
  "ingredients": [
    {
      "id": "minecraft:tnt",
      "count": 500
    },
    {
      "id": "minecraft:fishing_rod",
      "match": {
        "forbidden": [
          "components.minecraft:custom_data.oc_type"
        ]
      }
    }
  ]
}

This does two things. First, the 'custom:' for the result item will be explained in the For developpers section. The 'match' is what is interesting here : 'forbidden' means that the ingredient should not have 'components.minecraft:custom_data.oc_type' (whatever it's data is). If it was 'required', then the item would have to have this data. This is used to restrain which items can be used (here, don't use orbitals fishing rods to craft other orbitals)

 

For developpers

Here, we'll speak about our 'custom:' flag. It means the mod will take the other part of the id (for custom:myitem it will take myitem) and pass it to all executors registered. You register it by giving a modid and a BiFunction<Recipe.ResultContainer, ServerPlayerEntity, ItemStack> to the registerExecutor method in the Registry class. The result container gives you access to that id and the extra data (empty in our previous exemple) which can be used for extra customization, the player is the crafter and the itemstack is what you return (given to player).

The mod applies the recipe container to all mod's functions and returns the first non-null stack found. So, if your executor recieves an unknown id, you should return null. To avoid duped id (where the same mod would return it's stack, depending on who is first in the map), consider using somthing like custom:mymod_myitem. Avoid using two colons.

CraftByCommand Team

profile avatar
  • 2
    Followers
  • 13
    Projects
  • 4.5K
    Downloads

More from minheur2000View all