Skip to content

Just a small script that generates custom data-driven blocks only using Minecraft datapacks.

Notifications You must be signed in to change notification settings

StateusY/block-builder-mc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

block-builder-mc

Just a small script that generates custom Minecraft blocks using datapacks.

The block configuration is inspired by maybejakes's Crop and Kettle block implementation.

The block is made up of three main parts:

  • The texture (an item display)
  • The interaction (interaction entities)
  • The collision (a barrier block)

Breaking it down, each block is really an item frame. There is an advancement that detects when the item frame is placed and then runs a series of commands to kill the item frame, spawn in the item display, interations, and barrier block along with playing a sound and particles. There are other advancements detecting when the interactions are hit, and once they are, a 'health' will diminish until the block is broken (this is a counter that allows for repeated punching to break the block). Once that happens, the item display, interactions, and barrier are all removed and the block's item is spawned in its place.

USER GUIDE

To have your very own custom blocks, you need to clone the repo - the important thing is just the block_generator.py script. The other datapack is optional:

  • example_pack is an example datapack generated by the script

Steps:

  1. Open up the script and find the CONFIG section near the top.

  2. Change the default_namespace to your desired namespace.

  3. Duplicate the example sandstone_table to get the desired quantity of blocks (one entry ber block).

  4. Edit each block entry to your choosing.

    • Name: this is the display name
    • ID: this is what the block will be refered to in the datapack. Keep it all lowercase and no spaces or funky characters.
    • Interact: toggle this to true for the block to be interactable.
    • Interaction Function: set this to a function you want to trigger when the block is interacted with.
    • Can Float: set this to true if you want your block to not be able to float.
    • Hit Count: set this to the number of hits your block can take before it breaks.
    • Place Block Sound: set this to a sound you want to play when the block is placed.
    • Hit Block Sound: set this to a sound you want to play when the block is hit.
    • Hit Block Particle: set this to a particle you want to display when the block is broken.
    • Break Block Sound: set this to a sound you want to play when the block is hit.
    • Break Block Particle: set this to a particle you want to display when the block is broken.
    • Has Recipe: set this to true if you want your block to be craftable.
    • Recipe Output Quantity: set this to the number of blocks created by the recipe
    • Recipe Key: give each ingredient in your recipe a symbol or letter to act as a key.
    • Recipe Pattern: arrange the keys in a pattern to mimic a crafting recipe - spaces are empty slots.
  5. Now run the script and GENERATE! If you input everything above correctly it should work - use the example (sandstone_table) to work off of.

    WARNING! GENERATING DELETES THE OLD DATAPACK, EITHER COPY THE FILES ELSEWARE OR CHANGE THE NAME OF THE ROOT DATAPACK FOLDER TO SOMETHING BESIDES "bb-output"

  6. The final step is to insert your textures and block models into the datapack

    • Upload the block's textures to NAMESPACE/assets/NAMESPACE/textures/blocks/BLOCKNAME"
    • If the block has a seperate item texture, upload the block's item texture to NAMESPACE/assets/NAMESPACE/textures/items/BLOCKNAME"
    • Upload the block's model to NAMESPACE/assets/NAMESPACE/models/item/blocks/BLOCKNAME" - Note: only the block model needs uploading, the item model is pregenerated. Also, don't forget to link the textures in the model to the directories of the textures, use the sandstone_table as example. Also also, I reccomend to set the display settings to the 'block' preset in BlockBench if you don't have a seperate item texture.

You are done! You can either use this datapack as is or copy the files into a pre-existing datapack.

Extras

Known Limitations

  • If someone runs /kill @e, there will be a bunch of barriers left over. Solution is to use shulkers instead.
  • The blocks don't diminish tool durability or base the 'health' on the tool type. Solution is to implement checks and degrade durability.
  • Currently you can't place blocks on the custom block because they just trigger the interaction instead of placing it. Solution is unknown. (Well actually I could detect when someone right-clicks, raycast to the block face they are looking at, get the currently held block, /setblock it on the targeted face, and remove one item of the the player's hand, but that is a bit much for this small script.)

Future Plans:

  • Fix the aformentioned limitations
  • Add support for non-colliding blocks
  • Add support for light source blocks
  • Add support for Lore
  • Build-in GUI interfaces

About

Just a small script that generates custom data-driven blocks only using Minecraft datapacks.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published