Topic category: User side tutorials
In this tutorial I'll explain how to create custom wooden fences: they connect to other wooden fences, can be used as fuel and animals can be leashed to them. I'll also post a small example workspace.
1. Add a 'block' element
Pretty simple. Create a simple block and set its light opacity to 0. Aside from that, nothing else is required. Just make sure to set all procedures and properties now as the element will be locked (same if you want to change its id).
2. Lock the element and edit the code
If you open the code, you should find something like this.
Replace BlockCustom extends Block with BlockCustom extends BlockFence
Replace super(Material.MATERIAL); with super(Material.MATERIAL, MapColor.COLOR); (MATERIAL is based on the material you picked while creating the block)
Now press ctrl+w. Remove COLOR and replace it with one of the possible options (in the tutorial mod, I used MapColor.RED). If you did everything correctly, you should have something like this inside the code.
3. Editing the model files
If you double-click the locked element, 3 .json options should appear. They're used for blockstates, inventory and block.
- Open the first one (blockstates) and replace the text inside it with this. Replace fence_tutorial with the id of your mod (which you can find in your workspace settings). Replace tutorial_fence with the name of the .json file (this one). Do NOT remove the _side parts.
- Open the second one (item) and replace the stuff inside it with this. Again, replace fence_tutorial with the id of your mod, and example_planks with the name of the texture you're going to use (make sure it's saved as a texture for blocks)
- Open the third one (block) and replace the stuff with this. Replace the same stuff as step 2.
- This is the tricky part. Open Notepad and paste this stuff. Replace the same text as step 2 and 3. Now save the file as tutorial_fence_side.json (that is, the name that appears in step 1). If you did everything correctly, you should have a .json file that has the same name as the other 3, except with an extra _side. Copy the file. Open your workspace folder -> build -> resources -> main -> assets -> mod_id -> models -> block and paste the file there.
Now you can open your test client. If everything went fine, the fences should work as intended.