Add Nugget Mod items, blocks, and recipes

This commit is contained in:
2024-12-15 19:00:19 -06:00
parent bb8c8a2594
commit ab3d75abcf
28 changed files with 364 additions and 10 deletions

View File

@@ -15,6 +15,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.Logger;
import xyz.sillyangel.nugget.item.ModCreativeModeTabs;
import xyz.sillyangel.nugget.item.ModItems;
import xyz.sillyangel.nugget.block.ModBlocks;
@@ -33,6 +34,8 @@ public class NuggetMod {
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
ModCreativeModeTabs.register(modEventBus);
ModItems.register(modEventBus);
ModBlocks.register(modEventBus);
@@ -48,13 +51,7 @@ public class NuggetMod {
// Add the example block item to the building blocks tab
private void addCreative(BuildCreativeModeTabContentsEvent event) {
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

@@ -2,9 +2,11 @@ package xyz.sillyangel.nugget.block;
import xyz.sillyangel.nugget.NuggetMod;
import xyz.sillyangel.nugget.item.ModItems;
import net.minecraft.util.valueproviders.UniformInt;
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.DropExperienceBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraftforge.eventbus.api.IEventBus;
@@ -25,8 +27,16 @@ public class ModBlocks {
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) {
// ores
public static final RegistryObject<Block> NUGGET_ORE = registerBlock("nugget_ore",
() -> new DropExperienceBlock(UniformInt.of(2, 4), BlockBehaviour.Properties.of()
.strength(4f).requiresCorrectToolForDrops()));
public static final RegistryObject<Block> NUGGET_DEEPSLATE_ORE = registerBlock("nugget_deepslate_ore",
() -> new DropExperienceBlock(UniformInt.of(2, 4), BlockBehaviour.Properties.of()
.strength(5f).requiresCorrectToolForDrops().sound(SoundType.DEEPSLATE)));
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;

View File

@@ -1,4 +1,43 @@
package xyz.sillyangel.nugget.item;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;
import xyz.sillyangel.nugget.NuggetMod;
import xyz.sillyangel.nugget.block.ModBlocks;
public class ModCreativeModeTabs {
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS =
DeferredRegister.create(Registries.CREATIVE_MODE_TAB, NuggetMod.MOD_ID);
public static final RegistryObject<CreativeModeTab> NUGGET_ITEMS_TAB = CREATIVE_MODE_TABS.register("nuggetmod_items_tab",
() -> CreativeModeTab.builder().icon(() -> new ItemStack(ModItems.NUGGET.get()))
.title(Component.translatable("creativetab.nuggetmod.nugget_items"))
.displayItems((itemDisplayParameters, output) -> {
output.accept(ModItems.NUGGET.get());
output.accept(ModItems.RAW_NUGGET.get());
}).build());
public static final RegistryObject<CreativeModeTab> NUGGET_BLOCKS_TAB = CREATIVE_MODE_TABS.register("nuggetmod_blocks_tab",
() -> CreativeModeTab.builder().icon(() -> new ItemStack(ModBlocks.NUGGET_BLOCK.get()))
.withTabsBefore(NUGGET_ITEMS_TAB.getId())
.title(Component.translatable("creativetab.nuggetmod.nugget_blocks"))
.displayItems((itemDisplayParameters, output) -> {
output.accept(ModBlocks.NUGGET_BLOCK.get());
output.accept(ModBlocks.RAW_NUGGET_BLOCK.get());
output.accept(ModBlocks.NUGGET_ORE.get());
output.accept(ModBlocks.NUGGET_DEEPSLATE_ORE.get());
}).build());
public static void register(IEventBus eventBus) {
CREATIVE_MODE_TABS.register(eventBus);
}
}

View File

@@ -14,6 +14,9 @@ public class ModItems {
public static final RegistryObject<Item> NUGGET = ITEMS.register("nugget",
() -> new Item(new Item.Properties()));
public static final RegistryObject<Item> RAW_NUGGET = ITEMS.register("raw_nugget",
() -> new Item(new Item.Properties()));
public static void register(IEventBus eventBus) {