Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ItamarCohen

Members
  • Joined

  • Last visited

  1. Do I need to call the initiates function?
  2. But, how do I get the item now? and add texture to it?
  3. I changed the registration file to: package com.lightning.lightningmod.setup; import com.lightning.lightningmod.Main; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class Registration { public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Main.MODID); public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Main.MODID); public static final DeferredRegister<Item> SILVER_INGOT = Registration.ITEMS.register("silver_ingot", () -> new Item(new Item.Properties().tab(ItemGroup.MATERIALS))); public static void register() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); BLOCKS.register(modEventBus); ITEMS.register(modEventBus); } }
  4. Main: package com.lightning.lightningmod; import com.lightning.lightningmod.setup.Registration; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; 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.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.fmlserverevents.FMLServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.stream.Collectors; // The value here should match an entry in the META-INF/mods.toml file @Mod("lightningmod") public class Main { // Directly reference a log4j logger. private static final Logger LOGGER = LogManager.getLogger(); public static final String MODID = "lightningmod"; public Main() { Registration.register(); // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); // Register the enqueueIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); // Register the processIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { // some preinit code LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } private void enqueueIMC(final InterModEnqueueEvent event) { // some example code to dispatch IMC to another mod InterModComms.sendTo("lightningmod", "helloworld", () -> { LOGGER.info("Hello world from the MDK and Itamar"); return "Hello world";}); } private void processIMC(final InterModProcessEvent event) { // some example code to receive and process InterModComms from other mods LOGGER.info("Got IMC {}", event.getIMCStream(). map(m->m.messageSupplier().get()). collect(Collectors.toList())); } // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { // do something when the server starts LOGGER.info("HELLO from server starting"); } // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD // Event bus for receiving Registry Events) @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) { // register a new block here LOGGER.info("HELLO from Register Block"); } } } Registration: package com.lightning.lightningmod.setup; import com.lightning.lightningmod.Main; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class Registration { public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Main.MODID); public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Main.MODID); public static void register() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); BLOCKS.register(modEventBus); ITEMS.register(modEventBus); } } ModItems: package com.lightning.lightningmod.setup; import net.minecraft.world.item.Item; import net.minecraft.world.item.*; import net.minecraft.world.level.block.Block; import net.minecraftforge.registries.DeferredRegister; public class ModItems { public static final DeferredRegister<Item> SILVER_INGOT = Registration.ITEMS.register("silver_ingot", () -> new Item(new Item.Properties().tab(ItemGroup.MATERIALS))); } The error is in the ModItems Class. Cannot resolve symbol 'ItemGroup' It's not giving an option to import it.
  5. I sent you a collaborating link
  6. I referred to the documentation, and tried the example with blocks, didn't work, I 'm using IntelliJ, so I can let you collaborate
  7. I referred to the documentation, and tried the example with blocks, didn't work, I 'm using IntelliJ, so I can let you collaborate
  8. Still not working
  9. And how do you know that?
  10. So I need to change the item to be in registration?
  11. I'm just following a tutorial...
  12. Hi I'm creating a Minecraft mode, andI'm trying to add silver ingot to the game as a test. Unfortunately it doesn't work. package com.lightning.lightningmod.setup; import net.minecraft.world.item.Item; import net.minecraftforge.registries.DeferredRegister; public class ModItems { public static final DeferredRegister<Item> SILVER_INGOT = Registration.ITEMS.register("silver_ingot", () -> new Item(new Item.Properties().tab(ItemGroup.MATERIALS))); } It just doesn't recognize it as a class, with no option to import, any solutions?

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.