From 5bcbeca9e334d158c57daea995628b5a95ef5351 Mon Sep 17 00:00:00 2001 From: Vaas_Kahn_Grim <29955667+VaasKahnGrim@users.noreply.github.com> Date: Thu, 22 Jun 2023 14:16:11 -0400 Subject: [PATCH] Added Ancient Tab Added Obsidian Lantern item entry Added temp texture for obsidian lantern Added en_us translation file Folder structure setup Mod properties setup --- .../AncientCityEnhancement.java | 22 +++++++++---------- .../item/ModCreativeModeTabs.java | 20 +++++++++++++++++ .../ancientcityenhancement/item/ModItems.java | 19 ++++++++++++++++ .../ancientcityenhancement/lang/en_us.json | 4 ++++ .../models/item/obsidian_lantern.json | 6 +++++ 5 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 src/main/java/net/lord_of_owls/ancientcityenhancement/item/ModCreativeModeTabs.java create mode 100644 src/main/java/net/lord_of_owls/ancientcityenhancement/item/ModItems.java create mode 100644 src/main/resources/assets/ancientcityenhancement/lang/en_us.json create mode 100644 src/main/resources/assets/ancientcityenhancement/models/item/obsidian_lantern.json diff --git a/src/main/java/net/lord_of_owls/ancientcityenhancement/AncientCityEnhancement.java b/src/main/java/net/lord_of_owls/ancientcityenhancement/AncientCityEnhancement.java index a722a4a..1b28066 100644 --- a/src/main/java/net/lord_of_owls/ancientcityenhancement/AncientCityEnhancement.java +++ b/src/main/java/net/lord_of_owls/ancientcityenhancement/AncientCityEnhancement.java @@ -1,10 +1,11 @@ package net.lord_of_owls.ancientcityenhancement; import com.mojang.logging.LogUtils; +import net.lord_of_owls.ancientcityenhancement.item.ModCreativeModeTabs; +import net.lord_of_owls.ancientcityenhancement.item.ModItems; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; -import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -13,17 +14,18 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.slf4j.Logger; -// The value here should match an entry in the META-INF/mods.toml file @Mod(AncientCityEnhancement.MOD_ID) public class AncientCityEnhancement { - // Define mod id in a common place for everything to reference public static final String MOD_ID = "ancientcityenhancement"; - // Directly reference a slf4j logger private static final Logger LOGGER = LogUtils.getLogger(); public AncientCityEnhancement() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + ModCreativeModeTabs.register( modEventBus ); + + ModItems.register( modEventBus ); + modEventBus.addListener( this::commonSetup ); MinecraftForge.EVENT_BUS.register( this ); @@ -32,14 +34,12 @@ public AncientCityEnhancement() { private void commonSetup( final FMLCommonSetupEvent event ) {} - // Add the example block item to the building blocks tab - private void addCreative( BuildCreativeModeTabContentsEvent event ) {} - - // You can use SubscribeEvent and let the Event Bus discover methods to call - @SubscribeEvent - public void onServerStarting( ServerStartingEvent event ) {} + private void addCreative( BuildCreativeModeTabContentsEvent event ) { + if ( event.getTab() == ModCreativeModeTabs.ANCIENT_TAB.get() ) { + event.accept(ModItems.OBSIDIAN_LANTERN); + } + } - // You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent @Mod.EventBusSubscriber( modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT ) public static class ClientModEvents { @SubscribeEvent diff --git a/src/main/java/net/lord_of_owls/ancientcityenhancement/item/ModCreativeModeTabs.java b/src/main/java/net/lord_of_owls/ancientcityenhancement/item/ModCreativeModeTabs.java new file mode 100644 index 0000000..8ac1ca0 --- /dev/null +++ b/src/main/java/net/lord_of_owls/ancientcityenhancement/item/ModCreativeModeTabs.java @@ -0,0 +1,20 @@ +package net.lord_of_owls.ancientcityenhancement.item; + +import net.lord_of_owls.ancientcityenhancement.AncientCityEnhancement; +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; + +public class ModCreativeModeTabs { + public static final DeferredRegister CREATIVE_MODE_TABS = DeferredRegister.create( Registries.CREATIVE_MODE_TAB, AncientCityEnhancement.MOD_ID ); + + public static RegistryObject ANCIENT_TAB = CREATIVE_MODE_TABS.register( "ancient_tab", () -> CreativeModeTab.builder().icon( () -> new ItemStack( ModItems.OBSIDIAN_LANTERN.get() ) ).title( Component.translatable("creativemodetab.ancient_tab") ).build() ); + + public static void register( IEventBus eventBus ) { + CREATIVE_MODE_TABS.register( eventBus ); + } +} \ No newline at end of file diff --git a/src/main/java/net/lord_of_owls/ancientcityenhancement/item/ModItems.java b/src/main/java/net/lord_of_owls/ancientcityenhancement/item/ModItems.java new file mode 100644 index 0000000..cdfe7d2 --- /dev/null +++ b/src/main/java/net/lord_of_owls/ancientcityenhancement/item/ModItems.java @@ -0,0 +1,19 @@ +package net.lord_of_owls.ancientcityenhancement.item; + +import net.lord_of_owls.ancientcityenhancement.AncientCityEnhancement; +import net.minecraft.world.item.Item; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; + +public class ModItems { + public static final DeferredRegister ITEMS = DeferredRegister.create( ForgeRegistries.ITEMS, AncientCityEnhancement.MOD_ID ); + + public static final RegistryObject OBSIDIAN_LANTERN = ITEMS.register( "obsidian_lantern", () -> new Item( new Item.Properties() ) ); + + + public static void register( IEventBus eventBus ) { + ITEMS.register( eventBus ); + } +} \ No newline at end of file diff --git a/src/main/resources/assets/ancientcityenhancement/lang/en_us.json b/src/main/resources/assets/ancientcityenhancement/lang/en_us.json new file mode 100644 index 0000000..1096a88 --- /dev/null +++ b/src/main/resources/assets/ancientcityenhancement/lang/en_us.json @@ -0,0 +1,4 @@ +{ + "item.ancientcityenhancement.obsidian_lantern": "Obsidian Lantern", + "creativemodetab.ancient_tab": "Ancient Tab" +} \ No newline at end of file diff --git a/src/main/resources/assets/ancientcityenhancement/models/item/obsidian_lantern.json b/src/main/resources/assets/ancientcityenhancement/models/item/obsidian_lantern.json new file mode 100644 index 0000000..6ee1cea --- /dev/null +++ b/src/main/resources/assets/ancientcityenhancement/models/item/obsidian_lantern.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "ancientcityenhancement:item/obsidian_lantern" + } +} \ No newline at end of file