Jump to content

Creating an item with eclipse: Not working


HDCREEPS

Recommended Posts

I am new to modding Minecraft, and I seem to have a problem with making a custom Item named "Flash". I cannot notice a flaw in my code, except for the fact that I compiled my ItemFlash.json file with UTF-8 (not sure if that matters) language.

Here are my codes:

 

hdcreeps.modHD1.Reference.java:

package hdcreeps.modHD1;

 

public class Reference {

public static final String MODID = "hdm1";

public static final String name=%26quot%3BHDCREEPS%26%23039%3B Mod 1";

public static final String VERSION = "1.0";

 

public static final String CLIENTPROXY = "hdcreeps.modHD1.proxy.ClientProxy";

public static final String SERVERPROXY = "hdcreeps.modHD1.proxy.ServerProxy";

 

public static enum ModHD1Items{

FLASH("flash", "ItemFlash");

private String unlocalizedName;

private String registryName;

ModHD1Items(String unlocalizedName, String registryName){

this.unlocalizedname=unlocalizedName%3B

this.registryname=registryName%3B

}

public String getUnlocalizedName(){

return unlocalizedName;

}

public String getRegistryName(){

return registryName;

}

}

}

 

hdcreeps.modHD1.init.ModItems.java:

package hdcreeps.modHD1.init;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.block.model.ModelResourceLocation;

import net.minecraft.item.Item;

import net.minecraftforge.fml.common.registry.GameRegistry;

import hdcreeps.modHD1.Reference;

import hdcreeps.modHD1.items.ItemFlash;

public class ModItems {

public static Item flash;

public static void init(){

flash = new ItemFlash();

}

public static void register(){

GameRegistry.register(flash);

}

public static void registerRenders(){

registerRender(flash);

}

public static void registerRender(Item item){

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));

}

}

 

hdcreeps.modHD1.items.ItemFlash.java:

package hdcreeps.modHD1.items;

import net.minecraft.item.Item;

import hdcreeps.modHD1.Reference;

public class ItemFlash extends Item{

public ItemFlash(){

setUnlocalizedName(Reference.ModHD1Items.FLASH.getUnlocalizedName());

setRegistryName(Reference.ModHD1Items.FLASH.getRegistryName());

}

 

}

 

hdcreeps.modHD1.ModHD1.java:

package hdcreeps.modHD1;

 

import hdcreeps.modHD1.init.ModItems;

import hdcreeps.modHD1.proxy.CommonProxy;

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.Mod.Instance;

import net.minecraftforge.fml.common.SidedProxy;

import net.minecraftforge.fml.common.Mod.EventHandler;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

 

@Mod(modid=Reference.MODID,name=Reference%2ENAME%2Cversion%3DReference%2EVERSION%29

public class ModHD1 {

 

@Instance

public static ModHD1 instance;

@SidedProxy(clientSide=Reference.CLIENTPROXY,serverSide=Reference.SERVERPROXY)

public static CommonProxy proxy;

@EventHandler

public void preInit(FMLPreInitializationEvent event) {

System.out.println("Pre Init");

 

ModItems.init();

ModItems.register();

 

}

@EventHandler

public void init(FMLInitializationEvent event) {

System.out.println("Init");

 

proxy.init();

}

@EventHandler

public void postInit(FMLPostInitializationEvent event) {

System.out.println("Post Init");

}

}

 

assets.hdm1.models.item.ItemFlash.json:

{

    "parent": "builtin/generated",

    "textures": {

        "layer0": "hdm1:items/flash"

    },

"display": {

"thirdperson": {

"rotation": [ -90, 0, 0 ],

"translation": [ 0, 1, -3 ],

"scale": [ 0.55, 0.55, 0.55 ]

},

"firstperson": {

"rotation": [ 0, -135, 25 ],

"translation: [ 0, 4, 2 ],

"scale": [ 1.7, 1.7, 1.7 ]

}

}

}

 

assets.hdm1.lang.en_US_lang:

item.flash.name=Flash

Link to comment
Share on other sites

It would be nice if we actually knew the problem...

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Well....

  • You're not calling registerRenders from anywhere
  • You shouldn't be using the ModelMesher for rendering anyway (use ModelLoader.setCustomModelResourceLocation)
  • Your rendering code shouldn't be in common code, it should be in your client proxy
  • You have several spots where you're using the wrong character (you appear to be using something from UTF-8 not ASCII when ASCII is required). Namely in your @Mod annotation and here:

   ModHD1Items(String unlocalizedName, String registryName){
      //why aren't these two lines ended with ; ?
      this.unlocalizedname=unlocalizedName%3B
      this.registryname=registryName%3B
   }

  • Why are you using
    item.getUnlocalizedName().substring(5)

    ?  Use getRegistryName like you're supposed to

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

Your code is missing semicolons at the ends of some statements where Java requires semis.

 

Please clean up all syntax errors and run your program in the debugger before coming back with runtime symptoms. Example: If running results in a null-pointer exception, step up to the crash site and examine involved variables at least once before posting the crash log (inside spoiler tags).

 

PS: Please edit your OP to encapsulate the code within code tags.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

I am sorry, I think I messed up the code while moving it to the post.

Excluding the error with the semicolons and such, I seem to have an error that tells me that I have an invalid enum.

 

 

The full error code:

 

[Client thread/ERROR] [FML]: Exception loading model for variant hdm1:ItemFlash#inventory for item "hdm1:ItemFlash", normal location exception:

net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model hdm1:item/ItemFlash with loader VanillaLoader.INSTANCE, skipping

at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]

at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:317) ~[ModelLoader.class:?]

at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:170) ~[ModelBakery.class:?]

at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:147) ~[ModelLoader.class:?]

at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.Minecraft.startGame(Minecraft.java:540) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:386) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]

at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]

at GradleStart.main(GradleStart.java:26) [start/:?]

Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2

at com.google.gson.internal.Streams.parse(Streams.java:56) ~[streams.class:?]

at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:54) ~[TreeTypeAdapter.class:?]

at net.minecraft.util.JsonUtils.gsonDeserialize(JsonUtils.java:453) ~[JsonUtils.class:?]

at net.minecraft.client.renderer.block.model.ModelBlock.deserialize(ModelBlock.java:51) ~[ModelBlock.class:?]

at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:315) ~[ModelBakery.class:?]

at net.minecraftforge.client.model.ModelLoader.access$1100(ModelLoader.java:118) ~[ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:868) ~[ModelLoader$VanillaLoader.class:?]

at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]

... 20 more

Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2

at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1505) ~[JsonReader.class:?]

at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1386) ~[JsonReader.class:?]

at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:497) ~[JsonReader.class:?]

at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:403) ~[JsonReader.class:?]

at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:666) ~[TypeAdapters$25.class:?]

at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:642) ~[TypeAdapters$25.class:?]

at com.google.gson.internal.Streams.parse(Streams.java:44) ~[streams.class:?]

at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:54) ~[TreeTypeAdapter.class:?]

at net.minecraft.util.JsonUtils.gsonDeserialize(JsonUtils.java:453) ~[JsonUtils.class:?]

at net.minecraft.client.renderer.block.model.ModelBlock.deserialize(ModelBlock.java:51) ~[ModelBlock.class:?]

at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:315) ~[ModelBakery.class:?]

at net.minecraftforge.client.model.ModelLoader.access$1100(ModelLoader.java:118) ~[ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:868) ~[ModelLoader$VanillaLoader.class:?]

at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]

... 20 more

[22:43:51] [Client thread/ERROR] [FML]: Exception loading model for variant hdm1:ItemFlash#inventory for item "hdm1:ItemFlash", blockstate location exception:

net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model hdm1:ItemFlash#inventory with loader VariantLoader.INSTANCE, skipping

at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]

at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:325) ~[ModelLoader.class:?]

at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:170) ~[ModelBakery.class:?]

at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:147) ~[ModelLoader.class:?]

at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.Minecraft.startGame(Minecraft.java:540) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:386) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]

at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]

at GradleStart.main(GradleStart.java:26) [start/:?]

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

at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:78) ~[ModelBlockDefinition.class:?]

at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1184) ~[ModelLoader$VariantLoader.class:?]

at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]

... 20 more

Link to comment
Share on other sites

Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2

 

There is an error in your JSON file, at line 2. Show us your latest version of your JSON file and please put your logs, code and json in the

 tags.
 
[code][22:43:51] [Client thread/ERROR] [FML]: Exception loading model for variant hdm1:ItemFlash#inventory for item "hdm1:ItemFlash", blockstate location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model hdm1:ItemFlash#inventory with loader VariantLoader.INSTANCE

 

This error pops out meaning you made mistake in naming either naming your JSON file or setting the name in your registering class. I can barely read your code, please put them in spoiler and code tags if you are going to show multiple codes. This would make your post neat.

 

But by skimming over your code it appears your code has some resemblance to MrCrayfish's 1.9/1.10 tutorials. Are you following his tutorials?

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

[nobbc]
[/nobbc]

 

FTFY

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

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.