Jump to content

Error when adding blocks in Forge 1.12.2


Rumisan

Recommended Posts

(Deepl translation is used)

I am using IntelliJ to make a mod with Forge 1.12.2. (This is my first time modding).

I was looking at the tutorial on the Japanese web page and adding blocks, but
I got an error.

---- Minecraft Crash Report ----
// I bet Cylons wouldn't have this problem.

Time: 1/7/23 12:11 AM
Description: Initializing game

java.lang.NullPointerException: Initializing game
	at net.minecraft.item.ItemBlock.getCreativeTab(ItemBlock.java:142)
	at net.minecraft.item.Item.getCreativeTabs(Item.java:691)
	at net.minecraft.item.Item.isInCreativeTab(Item.java:416)
	at net.minecraft.item.ItemBlock.getSubItems(ItemBlock.java:147)
	at net.minecraft.client.Minecraft.populateSearchTreeManager(Minecraft.java:587)
	at net.minecraft.client.Minecraft.init(Minecraft.java:529)
	at net.minecraft.client.Minecraft.run(Minecraft.java:378)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.legacydev.Main.start(Main.java:86)
	at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
	at net.minecraft.item.ItemBlock.getCreativeTab(ItemBlock.java:142)
	at net.minecraft.item.Item.getCreativeTabs(Item.java:691)
	at net.minecraft.item.Item.isInCreativeTab(Item.java:416)
	at net.minecraft.item.ItemBlock.getSubItems(ItemBlock.java:147)
	at net.minecraft.client.Minecraft.populateSearchTreeManager(Minecraft.java:587)
	at net.minecraft.client.Minecraft.init(Minecraft.java:529)

-- Initialization --
Details:
Stacktrace:
	at net.minecraft.client.Minecraft.run(Minecraft.java:378)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.legacydev.Main.start(Main.java:86)
	at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29)

-- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: Windows 11 (amd64) version 10.0
	Java Version: 1.8.0_351, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 359153200 bytes (342 MB) / 1261961216 bytes (1203 MB) up to 3799515136 bytes (3623 MB)
	JVM Flags: 0 total; 
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.42 Powered by Forge 14.23.5.2860 5 mods loaded, 5 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

	| State | ID         | Version      | Source                                                     | Signature |
	|:----- |:---------- |:------------ |:---------------------------------------------------------- |:--------- |
	| LCH   | minecraft  | 1.12.2       | minecraft.jar                                              | None      |
	| LCH   | mcp        | 9.42         | minecraft.jar                                              | None      |
	| LCH   | FML        | 8.0.99.99    | forge-1.12.2-14.23.5.2860_mapped_stable_39-1.12-recomp.jar | None      |
	| LCH   | forge      | 14.23.5.2860 | forge-1.12.2-14.23.5.2860_mapped_stable_39-1.12-recomp.jar | None      |
	| LCH   | letter_mod | 1.0-SNAPSHOT | main                                                       | None      |

	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 526.47' Renderer: 'NVIDIA GeForce RTX 3050/PCIe/SSE2'
	Launched Version: ${MC_VERSION}
	LWJGL: 2.9.4
	OpenGL: NVIDIA GeForce RTX 3050/PCIe/SSE2 GL version 4.6.0 NVIDIA 526.47, NVIDIA Corporation
	GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

	Using VBOs: Yes
	Is Modded: Definitely; Client brand changed to 'fml,forge'
	Type: Client (map_client.txt)
	Resource Packs: 
	Current Language: English (US)
	Profiler Position: N/A (disabled)
	CPU: 12x Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz

 

And in the IntelliJ console I get


 Caused by: java.io.FileNotFoundException: letter_mod:models/item/latin_letter_a.json

 Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException

 Caused by: java.lang.RuntimeException: Encountered an exception when loading model definition of model letter_mod:blockstates/latin_letter_a_block.json

 Caused by: java.io.FileNotFoundException: letter_mod:blockstates/latin_letter_a_block.json

 
FileNotFoundException, so I checked to see if the file existed, and it was firmly there.

I would appreciate it if someone could help me out.

Link to comment
Share on other sites

Sorry, I forgot to post a screenshot.

 

file structure↓

%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%

 

Program↓

package rumisystem.letter_mod.letter_mod;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.registry.GameRegistry;

import java.util.Objects;
import java.util.logging.Logger;

@Mod(
        modid = Letter_mod.MOD_ID,
        name = Letter_mod.MOD_NAME,
        version = Letter_mod.VERSION
)
public class Letter_mod {

    public static final String MOD_ID = "letter_mod";
    public static final String MOD_NAME = "Letter_mod";
    public static final String VERSION = "1.0-SNAPSHOT";

    /**
     * This is the instance of your mod as created by Forge. It will never be null.
     */
    @Mod.Instance(MOD_ID)
    public static Letter_mod INSTANCE;

    /**
     * This is the first initialization event. Register tile entities here.
     * The registry events below will have fired prior to entry to this method.
     */
    @Mod.EventHandler
    public void preinit(FMLPreInitializationEvent event) {

    }

    /**
     * This is the second initialization event. Register custom recipes
     */
    @Mod.EventHandler
    public void init(FMLInitializationEvent event) {
        System.out.println("Letter MOD By RumiSystem and Rumisan");
    }

    /**
     * This is the final initialization event. Register actions from other mods here
     */
    @Mod.EventHandler
    public void postinit(FMLPostInitializationEvent event) {

    }

    /**
     * Forge will automatically look up and bind blocks to the fields in this class
     * based on their registry name.
     */
    @GameRegistry.ObjectHolder(MOD_ID)
    public static class Blocks {
      /*
          public static final MySpecialBlock mySpecialBlock = null; // placeholder for special block below
      */
        public static Block LatinLetter_A = null;                                                 //ラテン文字のA
    }

    /**
     * Forge will automatically look up and bind items to the fields in this class
     * based on their registry name.
     */
    @GameRegistry.ObjectHolder(MOD_ID)
    public static class Items {
      /*
          public static final ItemBlock mySpecialBlock = null; // itemblock for the block above
          public static final MySpecialItem mySpecialItem = null; // placeholder for special item below
      */
      public static ItemBlock LatinLetter_A = null;                                                      //ラテン文字のA
    }

    /**
     * This is a special class that listens to registry events, to allow creation of mod blocks and items at the proper time.
     */
    @Mod.EventBusSubscriber
    public static class ObjectRegistryHandler {
        /**
         * Listen for the register event for creating custom items
         */
        @SubscribeEvent
        public static void addItems(RegistryEvent.Register<Item> event) {
           /*
             event.getRegistry().register(new ItemBlock(Blocks.myBlock).setRegistryName(MOD_ID, "myBlock"));
             event.getRegistry().register(new MySpecialItem().setRegistryName(MOD_ID, "mySpecialItem"));
            */
            event.getRegistry().registerAll(
                    new ItemBlock(Blocks.LatinLetter_A).setRegistryName("latin_letter_A")
            );
        }

        /**
         * Listen for the register event for creating custom blocks
         */
        @SubscribeEvent
        public static void addBlocks(RegistryEvent.Register<Block> event) {
           /*
             event.getRegistry().register(new MySpecialBlock().setRegistryName(MOD_ID, "mySpecialBlock"));
            */

            event.getRegistry().registerAll(
                    new Block(Material.ROCK)
                            .setRegistryName(MOD_ID, "latin_letter_A_block")/*登録名の設定*/
                            .setCreativeTab(CreativeTabs.MISC)/*クリエのタブ*/
                            .setTranslationKey("block_latin_letter_A")/*システム名の設定*/
                            .setHardness(1.5F)/*硬さ*/
                            .setResistance(1.0F)/*爆破耐性*/
            );
        }

        @SubscribeEvent
        public static void registerModels(ModelRegistryEvent event){

        }
    }

    /* EXAMPLE ITEM AND BLOCK - you probably want these in separate files
    public static class MySpecialItem extends Item {

    }

    public static class MySpecialBlock extends Block {

    }
    */
}

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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