This commit is contained in:
2024-12-14 15:03:03 -06:00
parent e2bb2a7121
commit 3655550fe0
11 changed files with 79 additions and 3 deletions

View File

@@ -16,6 +16,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.Logger;
import xyz.sillyangel.nugget.item.ModItems;
import xyz.sillyangel.nugget.block.ModBlocks;
// Very important Comment
// The value here should match an entry in the META-INF/mods.toml file
@@ -33,6 +34,7 @@ public class NuggetMod {
MinecraftForge.EVENT_BUS.register(this);
ModItems.register(modEventBus);
ModBlocks.register(modEventBus);
// Register the item to a creative tab
modEventBus.addListener(this::addCreative);
@@ -49,6 +51,10 @@ public class NuggetMod {
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS) {
event.accept(ModItems.NUGGET);
}
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS) {
event.accept(ModBlocks.NUGGET_BLOCK);
event.accept(ModBlocks.RAW_NUGGET_BLOCK);
}
}
// You can use SubscribeEvent and let the Event Bus discover methods to call

View File

@@ -1,3 +1,43 @@
package xyz.sillyangel.nugget.block;
import net.sillyangel.nugget.NuggetMod;
import net.sillyangel.nugget.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.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, NuggetMod.MOD_ID);
public static final RegistryObject<Block> NUGGET_BLOCK = registerBlock("nugget_block",
() -> new Block(BlockBehaviour.Properties.of()
.strength(4f).requiresCorrectToolForDrops().sound(SoundType.AMETHYST)));
public static final RegistryObject<Block> RAW_NUGGET_BLOCK = registerBlock("raw_nugget_block",
() -> new Block(BlockBehaviour.Properties.of()
.strength(3f).requiresCorrectToolForDrops()));
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> void registerBlockItem(String name, RegistryObject<T> block) {
ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
}
public static void register(IEventBus eventBus) {
BLOCKS.register(eventBus);
}
}

View File

@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "nuggetmod:nugget_block" }
}
}

View File

@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "nuggetmod:raw_nugget_block" }
}
}

View File

@@ -1,3 +1,5 @@
{
"item.nuggetmod.nugget": "nugget"
"item.nuggetmod.nugget": "nugget",
"block.nuggetmod.nugget_block": "Nugget Block",
"block.nuggetmod.raw_nugget_block": "Raw Nugget Block"
}

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraf:block/cube_all",
"textures": {
"all": "nuggetmod:block/nugget_block"
}
}

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraf:block/cube_all",
"textures": {
"all": "nuggetmod:block/raw_nugget_block"
}
}

View File

@@ -0,0 +1,3 @@
{
"parent": "nuggetmod:block/nugget_block"
}

View File

@@ -0,0 +1,3 @@
{
"parent": "nuggetmod:block/raw_nugget_block"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB