Sorry, I also just started with learning coding. But the documentation don't solve the problem!
(The Problem is what I underline here: "new DeferredRegister<>(ForgeRegistries.ITEMS, TestMod ..."
public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, TestMod.MOD_ID);
Hole Code:
package com.NotHeizer.TestMod.util;
import com.NotHeizer.TestMod.TestMod;
import com.NotHeizer.TestMod.items.ItemBase;
import net.minecraft.item.Item;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
public class RegisteryHandler {
public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, TestMod.MOD_ID);
public static void init() {
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
//Items
public static final RegistryObject<Item> RUBY = ITEMS.register("ruby", ItemBase::new)
}
This was my "util" package. If I go into my TestMod (the Name of my Mod) Package there is 1 related Problem:
package com.NotHeizer.TestMod;
import com.NotHeizer.TestMod.util.RegisteryHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@Mod("TMod")
public class TestMod {
private static final Logger LOGGER = LogManager.getLogger();
public static final String MOD_ID = "TestMod";
public TestMod() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
RegisteryHandler.init();
MinecraftForge.EVENT_BUS.register(this);
}
private void setup(final FMLCommonSetupEvent event) { }
private void doClientStuff(final FMLClientSetupEvent event) { }
}
You can't see it, but after:
@Mod("TMod")
public class TestMod {
private static final Logger LOGGER = LogManager.getLogger();
and Befor:
public static final String MOD_ID = "TestMod";
there stands: "1 related Problem" in red and if I klick on it, it sends me to: "new DeferredRegister<>(ForgeRegistries.ITEMS, TestMod ..." (btw"DeferredRegister<>" is than marked. I am a beginner, and I am not good at it, but I read through the documentation and could not find something that could help me, or I am still not good enough. Can you help me?
Sorry for my bad englisch And I saw your Name, it sounds German, so if you are German, I am too so pleas write me in German if you can so that I could understand easily!
Tanks in advanced!