custom blocks
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package net.kaupenjoe.tutorialmod;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.kaupenjoe.tutorialmod.block.ModBlocks;
|
||||
import net.kaupenjoe.tutorialmod.item.ModCreativeModTabs;
|
||||
import net.kaupenjoe.tutorialmod.item.ModItems;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
@@ -28,6 +29,7 @@ public class TutorialMod {
|
||||
ModCreativeModTabs.register(modEventBus);
|
||||
|
||||
ModItems.register(modEventBus);
|
||||
ModBlocks.register(modEventBus);
|
||||
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
|
||||
|
||||
40
src/main/java/net/kaupenjoe/tutorialmod/block/ModBlocks.java
Normal file
40
src/main/java/net/kaupenjoe/tutorialmod/block/ModBlocks.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package net.kaupenjoe.tutorialmod.block;
|
||||
|
||||
import net.kaupenjoe.tutorialmod.TutorialMod;
|
||||
import net.kaupenjoe.tutorialmod.item.ModItems;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ModBlocks {
|
||||
public static final DeferredRegister<Block> BLOCKS =
|
||||
DeferredRegister.create(ForgeRegistries.BLOCKS, TutorialMod.MOD_ID);
|
||||
|
||||
public static final RegistryObject<Block> SAPPHIRE_BLOCK = registerBlock("sapphire_block",
|
||||
() -> new Block(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK).sound(SoundType.AMETHYST)));
|
||||
public static final RegistryObject<Block> RAW_SAPPHIRE_BLOCK = registerBlock("raw_sapphire_block",
|
||||
() -> new Block(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK).sound(SoundType.AMETHYST)));
|
||||
|
||||
private static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block) {
|
||||
RegistryObject<T> toReturn = BLOCKS.register(name, block);
|
||||
registerBlockItem(name, toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private static <T extends Block> RegistryObject<Item> registerBlockItem(String name, RegistryObject<T> block) {
|
||||
return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
|
||||
}
|
||||
|
||||
public static void register(IEventBus eventBus) {
|
||||
BLOCKS.register(eventBus);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.kaupenjoe.tutorialmod.item;
|
||||
|
||||
import net.kaupenjoe.tutorialmod.TutorialMod;
|
||||
import net.kaupenjoe.tutorialmod.block.ModBlocks;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
@@ -23,6 +24,8 @@ public class ModCreativeModTabs {
|
||||
|
||||
pOutput.accept(Items.DIAMOND);
|
||||
|
||||
pOutput.accept(ModBlocks.SAPPHIRE_BLOCK.get());
|
||||
pOutput.accept(ModBlocks.RAW_SAPPHIRE_BLOCK.get());
|
||||
|
||||
})
|
||||
.build());
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "tutorialmod:block/raw_sapphire_block"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "tutorialmod:block/sapphire_block"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,8 @@
|
||||
"item.tutorialmod.sapphire": "Sapphire",
|
||||
"item.tutorialmod.raw_sapphire": "Raw Sapphire",
|
||||
|
||||
"block.tutorialmod.sapphire_block": "Block of Sapphire",
|
||||
"block.tutorialmod.raw_sapphire_block": "Block of Raw Sapphire",
|
||||
|
||||
"creativetab.tutorial_tab": "Sapphire Tutorial Tab"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:block/cube_all",
|
||||
"textures": {
|
||||
"all": "tutorialmod:block/raw_sapphire_block"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:block/cube_all",
|
||||
"textures": {
|
||||
"all": "tutorialmod:block/sapphire_block"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"parent": "tutorialmod:block/raw_sapphire_block"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"parent": "tutorialmod:block/sapphire_block"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 897 B |
Binary file not shown.
|
After Width: | Height: | Size: 459 B |
Reference in New Issue
Block a user