Minecraft Data Packs / Tool

[NO NEED] Crafting custom NBT items for Crafter block

  • check_circle Advancements
  • check_circle Functions
  • check_circle Recipes
  • 2,540 views, 5 today
  • 145 downloads, 0 today
  • 16
  • 10
  • 2
SLT World's Avatar SLT World
Level 41 : Master Engineer
18

Mojang already gave a solution, this datapack is no longer needed

A simple datapack that makes custom NBT item outputs possible for the Crafter block.



Right now, the Crafter outputs the knowledge book for any custom crafting recipes added by datapacks. I recommend this datapack be used as a library, to prevent too many armor stands summoning for the same Crafter block in different datapacks.



[​How to add your own recipe coversion]

- To add your own recipes, create a "yourrecipe.mcfunction" in your datapack, and inside it should be something like this.

execute as @s[nbt={ArmorItems:[{tag:{Items:[{Slot:1b,id:"minecraft:INGREDIENT"},{Slot:4b,id:"minecraft:INGREDIENT"},{Slot:7b,id:"minecraft:INGREDIENT"}]}},{},{},{}]}] run tag @s add Craft_Exampleexecute as @s[tag=Craft_Example] if block ~ ~ ~ minecraft:crafter[triggered=true] as @e[type=item,limit=1,distance=..1.1,sort=nearest,nbt={Age:1s,Item:{id:"minecraft:knowledge_book",Count:1b}}] run data merge entity @s {Item:{id:"minecraft:YOURITEM",tag:{YOURNBTHERE}}}


- Modify the code above to your recipe and NBT
- Then run "execute as @e[​type=armor_stand,tag=Crafter] at @s run function yourdp:yourrecipe"

If you know some stuff about datapack & commands, it wouldn't be much a hassle to understand how it works.

The code behind how it works is quite simple really.
- Store the Items data from the Crafter into an armor stand when the Crafter is not activated.
- After it validates the matching recipe with the "ArmorItems:[]", it adds a tag that signals that it has a matching recipe.
- When activated, it will check for a nearby item entity with Age:1s & the knowledge book (It doesn't have to be a knowledge book, it can be anything). It will then insert the NBT data into the item entity.

The bullet code in the bullet image
tag @s remove Craft_Bullet
execute if block ~ ~ ~ minecraft:crafter[​triggered=false] run data modify entity @s ArmorItems[​0].tag.Items set from block ~ ~ ~ Items
execute as @s[​nbt={ArmorItems:[{tag:{Items:[{Slot:1b,id:"minecraft:iron_nugget"},{Slot:3b,id:"minecraft:gold_nugget"},{Slot:4b,id:"minecraft:gunpowder"},{Slot:5b,id:"minecraft:gold_nugget"},{Slot:6b,id:"minecraft:gold_nugget"},{Slot:7b,id:"minecraft:redstone"},{Slot:8b,id:"minecraft:gold_nugget"}]}},{},{},{}]}] run tag @s add Craft_Bullet
execute as @s[​tag=Craft_Bullet] if block ~ ~ ~ minecraft:crafter[​triggered=true] as @e[​type=item,distance=..1.1,sort=nearest,nbt={Age:1s,Item:{id:"minecraft:knowledge_book",Count:1b}}] run data merge entity @s {Item:{id:"minecraft:clock",tag:{Tags:["Bullet"],display:{Name:'[{"text":"Bullet","italic":false,"color":"white"}]'},CustomModelData:1002}}}
CompatibilityMinecraft 1.20
Tags

Create an account or sign in to comment.

Val_F_kan
01/16/2024 9:01 pm
Level 2 : Apprentice Miner
Val_F_kan's Avatar
What data pack are the bullets from?
1
SLT World
01/17/2024 10:09 am
Level 41 : Master Engineer
SLT World's Avatar
The bullets are from an upcoming gun datapack that I'm working on
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome