Jump to content

Registering Items


Animus_Surge

Recommended Posts

I'm still pretty much new to making mods for MC.

 

I start working on a mod that adds real life TGCs into minecraft, I try registering items the vanilla way, and run into this:

[13:01:12] [main/INFO] [GradleStart]: Extra: []
[13:01:12] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/swag100107/.gradle/caches/minecraft/assets, --assetIndex, 1.12, --accessToken{REDACTED}, --version, 1.12.2, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
[13:01:12] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[13:01:12] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[13:01:12] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[13:01:12] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[13:01:12] [main/INFO] [FML]: Forge Mod Loader version 14.23.4.2749 for Minecraft 1.12.2 loading
[13:01:12] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_172, running on Windows 10:amd64:10.0, installed at C:\Program Files\Java\jre1.8.0_172
[13:01:12] [main/ERROR] [FML]: Apache Maven library folder was not in the format expected. Using default libraries directory.
[13:01:12] [main/ERROR] [FML]: Full: C:\Users\swag100107\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-artifact\3.5.3\7dc72b6d6d8a6dced3d294ed54c2cc3515ade9f4\maven-artifact-3.5.3.jar
[13:01:12] [main/ERROR] [FML]: Trimmed: c:/users/swag100107/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-artifact/3.5.3/
[13:01:12] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[13:01:12] [main/INFO] [FML]: Detected deobfuscated environment, loading log configs for colored console logs.
2018-09-15 13:01:13,623 main WARN Disabling terminal, you're running in an unsupported environment.
[13:01:13] [main/INFO] [FML]: Ignoring missing certificate for coremod FMLCorePlugin (net.minecraftforge.fml.relauncher.FMLCorePlugin), we are in deobf and it's a forge core plugin
[13:01:13] [main/INFO] [FML]: Ignoring missing certificate for coremod FMLForgePlugin (net.minecraftforge.classloading.FMLForgePlugin), we are in deobf and it's a forge core plugin
[13:01:13] [main/INFO] [FML]: Searching C:\Users\swag100107\Desktop\ccmtg-001\run\.\mods for mods
[13:01:13] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
[13:01:13] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
[13:01:13] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
[13:01:13] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[13:01:13] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[13:01:13] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[13:01:13] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[13:01:13] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[13:01:13] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[13:01:15] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[13:01:15] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[13:01:15] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[13:01:16] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[13:01:16] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[13:01:16] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[13:01:16] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[13:01:17] [main/INFO] [minecraft/Minecraft]: Setting user: Player261
[13:01:23] [main/INFO] [minecraft/Minecraft]: LWJGL Version: 2.9.4
[13:01:24] [main/INFO] [FML]: -- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_172, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 751935912 bytes (717 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: 
	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'Intel' Version: '4.5.0 - Build 22.20.16.4836' Renderer: 'Intel(R) HD Graphics 620'
[13:01:24] [main/INFO] [FML]: MinecraftForge v14.23.4.2749 Initialized
[13:01:24] [main/INFO] [FML]: Starts to replace vanilla recipe ingredients with ore ingredients.
[13:01:24] [main/INFO] [FML]: Replaced 1036 ore ingredients
[13:01:25] [main/INFO] [FML]: Searching C:\Users\swag100107\Desktop\ccmtg-001\run\.\mods for mods
[13:01:26] [main/INFO] [FML]: Forge Mod Loader has identified 5 mods to load
[13:01:26] [Thread-3/INFO] [FML]: Using sync timing. 200 frames of Display.update took 115069582 nanos
[13:01:27] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, ccmtg] at CLIENT
[13:01:27] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, ccmtg] at SERVER
[13:01:28] [main/INFO] [minecraft/SimpleReloadableResourceManager]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:CardCraft: Magic the Gathering
[13:01:29] [main/INFO] [FML]: Processing ObjectHolder annotations
[13:01:29] [main/INFO] [FML]: Found 1168 ObjectHolder annotations
[13:01:29] [main/INFO] [FML]: Identifying ItemStackHolder annotations
[13:01:29] [main/INFO] [FML]: Found 0 ItemStackHolder annotations
[13:01:29] [main/INFO] [FML]: Configured a dormant chunk cache size of 0
[13:01:29] [Forge Version Check/INFO] [forge.VersionCheck]: [forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[13:01:29] [main/INFO] [FML]: Applying holder lookups
[13:01:29] [main/INFO] [FML]: Holder lookups applied
[13:01:29] [main/INFO] [FML]: Applying holder lookups
[13:01:29] [main/INFO] [FML]: Holder lookups applied
[13:01:29] [main/INFO] [FML]: Applying holder lookups
[13:01:29] [main/INFO] [FML]: Holder lookups applied
[13:01:29] [main/INFO] [FML]: Applying holder lookups
[13:01:29] [main/INFO] [FML]: Holder lookups applied
[13:01:29] [main/INFO] [FML]: Injecting itemstacks
[13:01:29] [main/INFO] [FML]: Itemstack injection complete
[13:01:29] [Forge Version Check/INFO] [forge.VersionCheck]: [forge] Found status: OUTDATED Target: 14.23.4.2759
[13:01:34] [Sound Library Loader/INFO] [minecraft/SoundManager]: Starting up SoundSystem...
[13:01:35] [Thread-5/INFO] [minecraft/SoundManager]: Initializing LWJGL OpenAL
[13:01:35] [Thread-5/INFO] [minecraft/SoundManager]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[13:01:35] [Thread-5/INFO] [minecraft/SoundManager]: OpenAL initialized.
[13:01:35] [Sound Library Loader/INFO] [minecraft/SoundManager]: Sound engine started
[13:01:42] [main/INFO] [FML]: Max texture size: 16384
[13:01:43] [main/INFO] [minecraft/TextureMap]: Created: 512x512 textures-atlas
[13:01:45] [main/INFO] [FML]: Applying holder lookups
[13:01:45] [main/INFO] [FML]: Holder lookups applied
[13:01:45] [main/INFO] [STDOUT]: [com.ccmtg.fml.CCMTG:init:30]: [CCMTG] Loading cards...
[13:01:45] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ----
// Sorry :(

Time: 9/15/18 1:01 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from CardCraft: Magic the Gathering (ccmtg)
Caused by: java.lang.IllegalStateException: Can not register to a locked registry. Modder should use Forge Register methods.
	at net.minecraftforge.registries.NamespacedWrapper.register(NamespacedWrapper.java:52)
	at net.minecraftforge.registries.NamespacedWrapper.register(NamespacedWrapper.java:38)
	at com.ccmtg.common.item.ModItems.registerItem(ModItems.java:20)
	at com.ccmtg.common.item.ModItems.registerItem(ModItems.java:15)
	at com.ccmtg.common.item.ModItems.registerItems(ModItems.java:10)
	at com.ccmtg.fml.CCMTG.init(CCMTG.java:31)
	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.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:629)
	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 com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196)
	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 com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135)
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:744)
	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336)
	at net.minecraft.client.Minecraft.init(Minecraft.java:581)
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	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.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)


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

-- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_172, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 615985392 bytes (587 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.42 Powered by Forge 14.23.4.2749 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 |
	|:----- |:--------- |:------------ |:-------------------------------- |:--------- |
	| UCHI  | minecraft | 1.12.2       | minecraft.jar                    | None      |
	| UCHI  | mcp       | 9.42         | minecraft.jar                    | None      |
	| UCHI  | FML       | 8.0.99.99    | forgeSrc-1.12.2-14.23.4.2749.jar | None      |
	| UCHI  | forge     | 14.23.4.2749 | forgeSrc-1.12.2-14.23.4.2749.jar | None      |
	| UCHEE | ccmtg     | DEV          | bin                              | None      |

	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'Intel' Version: '4.5.0 - Build 22.20.16.4836' Renderer: 'Intel(R) HD Graphics 620'
[13:01:45] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\swag100107\Desktop\ccmtg-001\run\.\crash-reports\crash-2018-09-15_13.01.45-client.txt
AL lib: (EE) alc_cleanup: 1 device not closed
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

 

The code is as follows:

 

the custom item, Red Coal:

Spoiler

package com.ccmtg.common.item;

import net.minecraft.item.Item;
import net.minecraft.creativetab.CreativeTabs;

public class ItemRedCoal extends Item {

	public ItemRedCoal() {
		this.setMaxStackSize(16);
		this.setCreativeTab(CreativeTabs.MISC);
	}
	
}

**NOTE: I started to make a custom item to see how it was done, so no cards yet...

The ModItems class:

Spoiler

package com.ccmtg.common.item;

import com.ccmtg.common.item.*;

import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;

public class ModItems extends Item {
	public static void registerItems() {
		registerItem(10000, "red_coal", (new ItemRedCoal().setUnlocalizedName("red_coal")));
	}
	
    private static void registerItem(int id, String textualID, Item itemIn)
    {
        registerItem(id, new ResourceLocation(textualID), itemIn);
    }

    private static void registerItem(int id, ResourceLocation textualID, Item itemIn)
    {
        REGISTRY.register(id, textualID, itemIn);
    }
}

 

the main mod class:

Spoiler

package com.ccmtg.fml;


import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.Logger;

import com.ccmtg.common.item.ModItems;

@Mod(modid = CCMTG.MODID, name = CCMTG.NAME, version = CCMTG.VERSION)
public class CCMTG
{
    public static final String MODID = "ccmtg";
    public static final String NAME = "CardCraft: Magic the Gathering";
    public static final String VERSION = "DEV";

    private static Logger logger;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        logger = event.getModLog();
    }

    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    	System.out.println("[CCMTG] Loading cards...");
    	ModItems.registerItems();
    }
}

 

 

Can somebody help me with this?

 

Thanks!

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

Link to comment
Share on other sites

Fixed the crash, new class named ModItemsInit:

package com.ccmtg.init;

import com.ccmtg.common.item.ModItems;
import com.ccmtg.common.item.*;

import net.minecraft.init.Bootstrap;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;

import com.ccmtg.common.item.*;

public class ModItemsInit {
	public static final Item RED_COAL;
	
	private static Item getRegisteredItem(String name)
    {
        Item item = Item.REGISTRY.getObject(new ResourceLocation(name));

        if (item == null)
        {
            throw new IllegalStateException("Invalid Item requested: " + name);
        }
        else
        {
            return item;
        }
    }

    static
    {
        if (!Bootstrap.isRegistered())
        {
            throw new RuntimeException("Accessed Items before Bootstrap!");
        }
        else
        {
        	RED_COAL = getRegisteredItem("red_coal");
        }
    }
}

However, the item does not appear in the desired tab

Edited by Animus_Surge

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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