Jump to content

Lang file and item texture not working [1.12]


Kitsune_Ultima

Recommended Posts

Make a class called EventHandler and write this:

	@SubscribeEvent
	public void onModelRegistry(ModelRegistryEvent event)
	{
		ModItems.registerRenders();
	}

 

Then, during the Init phase, call 

		MinecraftForge.EVENT_BUS.register(new EventHandler());

 

Your registerRender() method in your ModItems class needs to look like this:

private static void registerRender(Item item)
{
	ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}

 

Link to comment
Share on other sites

2 minutes ago, Kitsune_Ultima said:

error Cannot instantiate the type Mod.EventHandler
 

You imported the wrong EventHandler. You need to import the one that you created, or just rename yours to something that isn't already used. To rename a class, right click it in the Package explorer, hit Refactor and then rename.

Edited by Tschipp
Link to comment
Share on other sites

3 minutes ago, Tschipp said:

You imported the wrong EventHandler. You need to import the one that you created, or just rename yours to something that isn't already used.

Main class

package com.kitsune_ultima.extraarmor;

import com.kitsune_ultima.extraarmor.init.InitEventHandler;
import com.kitsune_ultima.extraarmor.init.ModItems;
import com.kitsune_ultima.extraarmor.proxy.CommonProxy;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = Reference.ACCEPTED_VERSIONS)
public class ExtraArmor {

	@Instance
	public static ExtraArmor instance;
	
	@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
	public static CommonProxy proxy;
	
	@EventHandler
	public void preInit(FMLPreInitializationEvent event) 
	{
		
		ModItems.init();
		
	}
	
	@EventHandler
	public void Init(FMLInitializationEvent event) 
	{
		proxy.init();
		MinecraftForge.EVENT_BUS.register(new InitEventHandler());
	}
	
	@EventHandler
	public void postInit(FMLPostInitializationEvent event) 
	{
		
	}
	
}

InitEventHandler.java

Quote

package com.kitsune_ultima.extraarmor.init;

import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@EventBusSubscriber
public class InitEventHandler {
    @SubscribeEvent
    public void onModelRegistry(ModelRegistryEvent event)
    {
        ModItems.registerRenders();
    }
}
 

 

still throws the error : Cannot instantiate the type Mod.EventHandler

Link to comment
Share on other sites

...Or he could simply make the onModelRegistry method static and let forge automatically subscribe his InitEventHandler to the event bus without having to do this explicidly as he already has the EventBusSubscriber annotation...

Additionally ModelRegistryEvent is fired before init, registering an event handler for it in init makes no sense.

Link to comment
Share on other sites

2 minutes ago, Kitsune_Ultima said:

I'm Confused

 

12 minutes ago, V0idWa1k3r said:

...Or he could simply make the onModelRegistry method static and let forge automatically subscribe his InitEventHandler to the event bus without having to do this explicidly as he already has the EventBusSubscriber annotation...

 

Link to comment
Share on other sites

2 hours ago, V0idWa1k3r said:

...Or he could simply make the onModelRegistry method static and let forge automatically subscribe his InitEventHandler to the event bus without having to do this explicidly as he already has the EventBusSubscriber annotation..

2

still didn't work

Edited by Kitsune_Ultima
Link to comment
Share on other sites

41 minutes ago, V0idWa1k3r said:

We still need to see your ModItems class where you do most of the registering related things.

ok

ModItems.java

package com.kitsune_ultima.extraarmor.init;

import com.kitsune_ultima.extraarmor.Reference;
import com.kitsune_ultima.extraarmor.items.Obsidian_ingot;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

@EventBusSubscriber
public class ModItems {
	
	public static Item obsidianingot;
	
	public static void init() {
		obsidianingot = new Obsidian_ingot();
	}
	
	public static void registerRenders() {
		registerRender(obsidianingot);
	}
	
	private static void registerRender(Item item)
	{
		ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
	}
}

 

log-latest

2017-07-03 18:09:52,149 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2017-07-03 18:09:52,152 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
[18:09:52] [main/INFO] [GradleStart]: Extra: []
[18:09:52] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/ryanh/.gradle/caches/minecraft/assets, --assetIndex, 1.12, --accessToken{REDACTED}, --version, 1.12, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
[18:09:52] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[18:09:52] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[18:09:52] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[18:09:52] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[18:09:52] [main/INFO] [FML]: Forge Mod Loader version 14.21.1.2387 for Minecraft 1.12 loading
[18:09:52] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_131, running on Windows 10:amd64:10.0, installed at C:\Program Files\Java\jre1.8.0_131
[18:09:52] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[18:09:52] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
[18:09:52] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
[18:09:52] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
[18:09:52] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:09:52] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[18:09:52] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[18:09:52] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:09:52] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:09:52] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
2017-07-03 18:09:53,180 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2017-07-03 18:09:53,634 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2017-07-03 18:09:53,635 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
[18:09:53] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
[18:09:56] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[18:09:56] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[18:09:56] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[18:09:58] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[18:09:58] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[18:09:58] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[18:09:58] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[18:09:59] [main/INFO]: Setting user: Player417
[18:10:05] [main/WARN]: Skipping bad option: lastServer:
[18:10:05] [main/INFO]: LWJGL Version: 2.9.4
[18:10:07] [main/INFO] [FML]: -- System Details --
Details:
	Minecraft Version: 1.12
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_131, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 713361912 bytes (680 MB) / 1038876672 bytes (990 MB) up to 2112618496 bytes (2014 MB)
	JVM Flags: 3 total; -Xincgc -Xmx2G -Xms1G
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: 
	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'Intel' Version: '4.4.0 - Build 21.20.16.4542' Renderer: 'Intel(R) HD Graphics 620'
[18:10:07] [main/INFO] [FML]: MinecraftForge v14.21.1.2387 Initialized
[18:10:07] [main/INFO] [FML]: Replaced 921 ore ingredients
[18:10:07] [main/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer
[18:10:07] [main/INFO] [FML]: Searching C:\Users\ryanh\Mod Creation\Test mod\run\mods for mods
[18:10:09] [Thread-3/INFO] [FML]: Using sync timing. 200 frames of Display.update took 114200186 nanos
[18:10:09] [main/INFO] [FML]: Forge Mod Loader has identified 5 mods to load
[18:10:10] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, kuexam] at CLIENT
[18:10:10] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, kuexam] at SERVER
[18:10:11] [main/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Extra Armor Mod
[18:10:11] [main/INFO] [FML]: Processing ObjectHolder annotations
[18:10:11] [main/INFO] [FML]: Found 1168 ObjectHolder annotations
[18:10:11] [main/INFO] [FML]: Identifying ItemStackHolder annotations
[18:10:11] [main/INFO] [FML]: Found 0 ItemStackHolder annotations
[18:10:11] [main/INFO] [FML]: Configured a dormant chunk cache size of 0
[18:10:11] [Forge Version Check/INFO] [ForgeVersionCheck]: [forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[18:10:11] [main/INFO] [FML]: Applying holder lookups
[18:10:11] [main/INFO] [FML]: Holder lookups applied
[18:10:11] [main/INFO] [FML]: Applying holder lookups
[18:10:11] [main/INFO] [FML]: Holder lookups applied
[18:10:11] [main/INFO] [FML]: Applying holder lookups
[18:10:11] [main/INFO] [FML]: Holder lookups applied
[18:10:11] [main/INFO] [FML]: Applying holder lookups
[18:10:11] [main/INFO] [FML]: Holder lookups applied
[18:10:11] [main/INFO] [FML]: Injecting itemstacks
[18:10:11] [main/INFO] [FML]: Itemstack injection complete
[18:10:11] [Forge Version Check/INFO] [ForgeVersionCheck]: [forge] Found status: UP_TO_DATE Target: null
[18:10:17] [Sound Library Loader/INFO]: Starting up SoundSystem...
[18:10:17] [Thread-5/INFO]: Initializing LWJGL OpenAL
[18:10:17] [Thread-5/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[18:10:17] [Thread-5/INFO]: OpenAL initialized.
[18:10:17] [Sound Library Loader/INFO]: Sound engine started
[18:10:24] [main/INFO] [FML]: Max texture size: 16384
[18:10:25] [main/INFO]: Created: 512x512 textures-atlas
[18:10:27] [main/INFO] [FML]: Injecting itemstacks
[18:10:27] [main/INFO] [FML]: Itemstack injection complete
[18:10:27] [main/INFO] [FML]: Forge Mod Loader has successfully loaded 5 mods
[18:10:27] [main/WARN]: Skipping bad option: lastServer:
[18:10:28] [main/INFO]: Narrator library for x64 successfully loaded
[18:10:33] [Server thread/INFO]: Starting integrated minecraft server version 1.12
[18:10:33] [Server thread/INFO]: Generating keypair
[18:10:33] [Server thread/INFO] [FML]: Injecting existing registry data into this server instance
[18:10:34] [Server thread/INFO] [FML]: Applying holder lookups
[18:10:34] [Server thread/INFO] [FML]: Holder lookups applied
[18:10:34] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id
[18:10:34] [Server thread/INFO] [FML]: Loading dimension 0 (Mod Test World) (net.minecraft.server.integrated.IntegratedServer@2b66430a)
[18:10:35] [Server thread/INFO]: Loaded 488 advancements
[18:10:35] [Server thread/INFO] [FML]: Loading dimension 1 (Mod Test World) (net.minecraft.server.integrated.IntegratedServer@2b66430a)
[18:10:35] [Server thread/INFO] [FML]: Loading dimension -1 (Mod Test World) (net.minecraft.server.integrated.IntegratedServer@2b66430a)
[18:10:35] [Server thread/INFO]: Preparing start region for level 0
[18:10:36] [Server thread/INFO]: Preparing spawn area: 1%
[18:10:37] [Server thread/INFO]: Preparing spawn area: 49%
[18:10:38] [Server thread/INFO]: Changing view distance to 12, from 10
[18:10:40] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 2
[18:10:40] [Netty Server IO #1/INFO] [FML]: Client protocol version 2
[18:10:40] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 5 mods : [email protected],[email protected],[email protected],[email protected],[email protected]
[18:10:40] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established
[18:10:40] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established
[18:10:40] [Server thread/INFO]: Player417[local:E:a15c9e16] logged in with entity id 332 at (-260.79880041414555, 71.0, 272.18641483454326)
[18:10:40] [Server thread/INFO]: Player417 joined the game
[18:10:42] [Server thread/INFO]: Saving and pausing game...
[18:10:42] [Server thread/INFO]: Saving chunks for level 'Mod Test World'/overworld
[18:10:42] [Server thread/INFO]: Saving chunks for level 'Mod Test World'/the_nether
[18:10:42] [Server thread/INFO]: Saving chunks for level 'Mod Test World'/the_end
[18:10:43] [Server thread/WARN]: Can't keep up! Did the system time change, or is the server overloaded? Running 2236ms behind, skipping 44 tick(s)
[18:10:58] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@d41320f[id=c97b21a8-25e6-37ce-8a04-8d5bcf6f4c4d,name=Player417,properties={},legacy=false]
com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time
	at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:79) ~[YggdrasilAuthenticationService.class:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:180) [YggdrasilMinecraftSessionService.class:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:60) [YggdrasilMinecraftSessionService$1.class:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:57) [YggdrasilMinecraftSessionService$1.class:?]
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3716) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2424) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2298) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2211) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache.get(LocalCache.java:4154) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4158) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5147) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:5153) [guava-21.0.jar:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:170) [YggdrasilMinecraftSessionService.class:?]
	at net.minecraft.client.Minecraft.getProfileProperties(Minecraft.java:3156) [Minecraft.class:?]
	at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:138) [SkinManager$3.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_131]
	at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_131]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
[18:10:58] [Server thread/INFO]: Saving and pausing game...
[18:10:59] [Server thread/INFO]: Saving chunks for level 'Mod Test World'/overworld
[18:10:59] [Server thread/INFO]: Saving chunks for level 'Mod Test World'/the_nether
[18:10:59] [Server thread/INFO]: Saving chunks for level 'Mod Test World'/the_end
[18:11:00] [Server thread/INFO]: Stopping server
[18:11:00] [Server thread/INFO]: Saving players
[18:11:00] [Server thread/INFO]: Player417 lost connection: Disconnected
[18:11:00] [Server thread/INFO]: Player417 left the game
[18:11:00] [Server thread/INFO]: Stopping singleplayer server as player logged out
[18:11:00] [Server thread/INFO]: Saving worlds
[18:11:00] [Server thread/INFO]: Saving chunks for level 'Mod Test World'/overworld
[18:11:00] [Server thread/INFO]: Saving chunks for level 'Mod Test World'/the_nether
[18:11:00] [Server thread/INFO]: Saving chunks for level 'Mod Test World'/the_end
[18:11:01] [Server thread/INFO] [FML]: Unloading dimension 0
[18:11:01] [Server thread/INFO] [FML]: Unloading dimension -1
[18:11:01] [Server thread/INFO] [FML]: Unloading dimension 1
[18:11:02] [Server thread/INFO] [FML]: Applying holder lookups
[18:11:02] [Server thread/INFO] [FML]: Holder lookups applied
[18:11:07] [main/INFO]: Stopping!
[18:11:07] [main/INFO]: SoundSystem shutting down...
[18:11:07] [main/WARN]: Author: Paul Lamb, www.paulscode.com
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

 

Link to comment
Share on other sites

You are still not registering your item correctly. You need to use ObjectHolders as I've described earlier in this thread otherwise you are registering a model for a completely separate Item object that has nothing to do with the item you have registered.

Additionally this is not all your updated code. The Item's class itself would be nice to see, or at least it's constructor, and your class that registers the items.

Link to comment
Share on other sites

1 minute ago, V0idWa1k3r said:

You are still not registering your item correctly. You need to use ObjectHolders as I've described earlier in this thread otherwise you are registering a model for a completely separate Item object that has nothing to do with the item you have registered.

Additionally this is not all your updated code. The Item's class itself would be nice to see, or at least it's constructor, and your class that registers the items.

ok

Obsidian_ingot.java

package com.kitsune_ultima.extraarmor.items;

import com.kitsune_ultima.extraarmor.Reference;

import net.minecraft.item.Item;

public class Obsidian_ingot extends Item {
	
	public Obsidian_ingot() {
		setUnlocalizedName(Reference.ExtraArmorItems.OBSIDIAN_INGOT.getUnlocalizedName());
		setRegistryName(Reference.ExtraArmorItems.OBSIDIAN_INGOT.getRegistryName());
	}
}

 

Reference.java

package com.kitsune_ultima.extraarmor;

public class Reference {

	//Mod id information
	public static final String MOD_ID = "kuexam";
	public static final String NAME = "Extra Armor Mod";
	public static final String VERSION = "DEV-0.0.1";
	public static final String ACCEPTED_VERSIONS = "[1.12]";
	
	//Proxy information
	public static final String CLIENT_PROXY_CLASS = "com.kitsune_ultima.extraarmor.proxy.ClientProxy";
	public static final String SERVER_PROXY_CLASS = "com.kitsune_ultima.extraarmor.proxy.ServerProxy";
	
	//Item information
	public static enum ExtraArmorItems {
		OBSIDIAN_INGOT("obsidian_ingot", "ItemObsidian_ingot");
		
		private String unlocalizedName;
		private String registryName;
		
		ExtraArmorItems(String unlocalizedName, String registryName) {
		this.unlocalizedName = unlocalizedName;
		this.registryName = registryName;
		}
		public String getUnlocalizedName() {
			return unlocalizedName;
		}
		public String getRegistryName() {
			return registryName;
		}
	}
}

 

Link to comment
Share on other sites

Well, there are docs but they are currently being worked on and might feel a bit vague in some parts. The idea is that you never have to manualy set any fields yourself. Create any class, annotate it with ObjectHolder and give that annotation your modid. In that class you then can declare any amount of fields annotated with ObjectHolder with those annotations having a value of a ragistry name. The field must be public(or private) static final %Type% %name% = null. The =null and final part ensures that you do not put anything into this field on your own. The name can be any name you want, obviously and the Type is the class of the thing that is registered with the registry name specified in the annotation for the field. For your obsidian item the field could look like

@ObjectHolder("ItemObsidian_ingot")
public static final Item OBSIDIAN_INGOT = null;

 

Then you would just reference this field anywhere you need to get an instance of your item. In your model registration as an example. 

The field gets populated by forge automatically after you've registered all your things in the appropriate registry event.

Edited by V0idWa1k3r
Link to comment
Share on other sites

1 hour ago, Kitsune_Ultima said:

how do I reference it

Is very new to modding

This is not a modding question, this is a Java question.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

3 hours ago, V0idWa1k3r said:

Create any class, annotate it with ObjectHolder and give that annotation your modid.

causes a "kuexam cannot be resolved to a variable" error 

class: ItemLoader.java

package com.kitsune_ultima.extraarmor.init;

import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;

@ObjectHolder(kuexam)
public class ItemLoader {
	
	@ObjectHolder("ItemObsidian_ingot")
	public static final Item OBSIDIAN_INGOT = null;
	
}

 

Link to comment
Share on other sites

3 hours ago, Kitsune_Ultima said:

causes a "kuexam cannot be resolved to a variable" error 

class: ItemLoader.java


package com.kitsune_ultima.extraarmor.init;

import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;

@ObjectHolder(kuexam)
public class ItemLoader {
	
	@ObjectHolder("ItemObsidian_ingot")
	public static final Item OBSIDIAN_INGOT = null;
	
}

 

You are basically calling for a variable that does not exist. Instead, you should be enclosing kuexam in "modid".

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

7 hours ago, Kitsune_Ultima said:

causes a "kuexam cannot be resolved to a variable" error 

class: ItemLoader.java


package com.kitsune_ultima.extraarmor.init;

import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;

@ObjectHolder(kuexam)
public class ItemLoader {
	
	@ObjectHolder("ItemObsidian_ingot")
	public static final Item OBSIDIAN_INGOT = null;
	
}

 

 

Your modid is a string, so it should be enclosed in quotes as a literal, or referenced as a field. This is again not a modding problem, it's a fairly basic Java problem.

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.