Added custom blocks for sapphire

This commit is contained in:
Chris Toph 2025-02-16 03:43:24 -05:00
parent c704a6ba51
commit 38925892fd
13 changed files with 95 additions and 4 deletions

View file

@ -14,5 +14,9 @@
"gradlew": "build.gradle, gradle.properties, gradlew.bat, settings.gradle",
".gitignore": ".gitattributes, .tool-versions, LICENSE.txt, README.md"
},
"workbench.iconTheme": "mc-dp-icons"
"workbench.iconTheme": "material-icon-theme",
"editor.fontSize": 15,
"editor.cursorStyle": "block",
"editor.fontLigatures": true,
"editor.fontFamily": "'Monocraft Nerd Font', 'monospace', monospace"
}

View file

@ -4,10 +4,10 @@ import org.slf4j.Logger;
import com.mojang.logging.LogUtils;
import cc.toph.tutorialmod.block.ModBlocks;
import cc.toph.tutorialmod.item.ModCreativeTabs;
import cc.toph.tutorialmod.item.ModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.api.distmarker.Dist;
@ -38,9 +38,9 @@ public class TutorialMod {
// Register the commonSetup method for modloading
modEventBus.addListener(this::commonSetup);
// Register the ModItems and CreativeModeTabs class to the modEventBus
ModItems.register(modEventBus);
ModCreativeTabs.register(modEventBus);
ModItems.register(modEventBus);
ModBlocks.register(modEventBus);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);

View file

@ -0,0 +1,48 @@
package cc.toph.tutorialmod.block;
import java.util.function.Supplier;
import cc.toph.tutorialmod.TutorialMod;
import cc.toph.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;
public class ModBlocks {
// Deferrer //
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS,
TutorialMod.MODID);
// Blocks //
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.RAW_IRON_BLOCK).sound(SoundType.AMETHYST)));
// Methods //
public static void register(IEventBus eventBus) {
BLOCKS.register(eventBus);
}
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()));
}
}

View file

@ -1,6 +1,7 @@
package cc.toph.tutorialmod.item;
import cc.toph.tutorialmod.TutorialMod;
import cc.toph.tutorialmod.block.ModBlocks;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
@ -22,5 +23,7 @@ public class ModCreativeTabs {
.title(Component.translatable("creativetab.tutorial_tab")).displayItems((pParams, pOut) -> {
pOut.accept(ModItems.SAPPHIRE.get());
pOut.accept(ModItems.RAW_SAPPHIRE.get());
pOut.accept(ModBlocks.SAPPHIRE_BLOCK.get());
pOut.accept(ModBlocks.RAW_SAPPHIRE_BLOCK.get());
}).build());
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "tutorialmod:block/raw_sapphire_block"
}
}
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "tutorialmod:block/sapphire_block"
}
}
}

View file

@ -1,5 +1,9 @@
{
"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 Tab"
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "tutorialmod:block/raw_sapphire_block"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "tutorialmod:block/sapphire_block"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "tutorialmod:block/raw_sapphire_block"
}

View file

@ -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