Last active
January 6, 2019 17:10
-
-
Save Juuxel/946536e67264ca735c2046429871738e to your computer and use it in GitHub Desktop.
Fabric block example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.mod; | |
import net.minecraft.block.Block; | |
import net.minecraft.block.Material; | |
import net.minecraft.item.ItemGroup; | |
import net.minecraft.item.block.BlockItem; | |
/* The block class. | |
* This does not include models, translation files, loot tables or textures (those have to be defined in | |
/data and /assets). | |
* The item will be in the Decorations tab of the creative menu. | |
*/ | |
public class ExampleBlock extends Block { | |
public ExampleBlock() { | |
super(Block.Settings.of(Material.STONE)); | |
} | |
public static class Item extends BlockItem { | |
public Item(Block block) { | |
// The item is put in the decoration creative tab | |
super(block, new Item.Settings().itemGroup(ItemGroup.DECORATIONS)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.mod; | |
import net.fabricmc.api.ModInitializer; | |
import net.minecraft.block.Block; | |
import net.minecraft.registry.Registry; | |
/* The mod class. | |
* You should clone the Fabric example repository to get all of the required files. | |
*/ | |
public class ExampleMod implements ModInitializer { | |
@Override | |
public void onInitialize() { | |
Block block = new ExampleBlock(); | |
Registry.register(Registry.BLOCK, "modid:test_block", block); | |
Registry.register(Registry.ITEM, "modid:test_block", new ExampleBlock.Item(block)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "modid", | |
"name": "ExampleMod", | |
"description": "NOTE: This file must be in /src/main/resources", | |
"version": "1.0.0", | |
"side": "universal", | |
"initializer": "com.example.mod.ExampleMod", | |
"requires": { | |
"fabric": "*" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for making this!! It is working!!