diff --git a/build.gradle b/build.gradle index 1c1b219..2f1f2bd 100644 --- a/build.gradle +++ b/build.gradle @@ -132,8 +132,6 @@ dependencies { minecraft '@FORGE_GROUP@:@FORGE_NAME@:@FORGE_VERSION@' // Real mod deobf dependency examples - these get remapped to your current mappings - // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency - // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency // Examples using mod jars from ./libs diff --git a/src/main/java/com/example/examplemod/ExampleMod.java b/src/main/java/com/example/examplemod/ExampleMod.java index 803db87..e4013ff 100644 --- a/src/main/java/com/example/examplemod/ExampleMod.java +++ b/src/main/java/com/example/examplemod/ExampleMod.java @@ -3,7 +3,7 @@ package com.example.examplemod; import com.mojang.logging.LogUtils; import net.minecraft.client.Minecraft; import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; @@ -11,15 +11,13 @@ import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.Material; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.CreativeModeTabEvent; +import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; -import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; -import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -42,7 +40,7 @@ public class ExampleMod // Creates a new Block with the id "examplemod:example_block", combining the namespace and path public static final RegistryObject EXAMPLE_BLOCK = BLOCKS.register("example_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); // Creates a new BlockItem with the id "examplemod:example_block", combining the namespace and path - public static final RegistryObject EXAMPLE_BLOCK_ITEM = ITEMS.register("example_block", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS))); + public static final RegistryObject EXAMPLE_BLOCK_ITEM = ITEMS.register("example_block", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties())); public ExampleMod() { @@ -58,6 +56,10 @@ public class ExampleMod // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); + + // Register the item to a creative tab + modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, + EXAMPLE_BLOCK_ITEM.get())); } private void commonSetup(final FMLCommonSetupEvent event) diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index b643e13..aa7bb5d 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,8 +1,8 @@ { "pack": { "description": "examplemod resources", - "pack_format": 9, - "forge:resource_pack_format": 9, + "pack_format": 12, + "forge:resource_pack_format": 12, "forge:data_pack_format": 10 } }