Hello everyone!
I've got a problem with creating blocks in MC.
I've tried both options from the official Forge Docs and
also some other suggestions from other forums and
videos. I really don't know what's the error here.
Items work ingame, blocks don't.
I created a class called 'Blocks', which extends
net.minecraft.block.Block. Here's the code:
public class Blocks extends Block {
public static final List<Block> blocks = new ArrayList<Block>();
public Blocks(String name) {
super(Properties.of(Material.STONE, MaterialColor.STONE).strength(60f, 120f).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.METAL));
setRegistryName(Info.MODID, name); // Info is basically another class with lots of info for the mod, such as credits, modid, version etc.
blocks.add(this);
}
}
In my 'Main' I have:
public class Main {
public Main() {
new Blocks("block_x");
}
@SubscribeEvent
public void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegE) {
blockRegE.getRegistry().registerAll(Blocks.blocks.toArray(new Block[0]));
}
}
Ingame no block is there. Also of course I have 'block_x' as .json files in
assets.(MODID).blockstates,
assets.(MODID).models.block,
assets.(MODID).models.item
I've also got the texture in the assets.(MODID).textures folder.
Does anybody know why the block isn't registering?