Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • java.lang.IllegalArgumentException when trying to make first entity (1.8)
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 2
King_Arthur_III

java.lang.IllegalArgumentException when trying to make first entity (1.8)

By King_Arthur_III, August 11, 2015 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

King_Arthur_III    0

King_Arthur_III

King_Arthur_III    0

  • Tree Puncher
  • King_Arthur_III
  • Members
  • 0
  • 19 posts
Posted August 11, 2015

I am trying to make my first entity ( 1.8 )  but when I run the client I get this message:

 

"java.lang.IllegalArgumentException: Can not set static com.kingarthur.elementalswords.ClientProxy field com.kingarthur.elementalswords.ClientProxy.modInstance to com.kingarthur.elementalswords.Main"

 

This is the relevant code in my client proxy:

 

public class ClientProxy extends CommonProxy {

 

@Instance(Main.MODID)

public static ClientProxy modInstance;

 

@Override

public void preInit(FMLPreInitializationEvent e) {

super.preInit(e);

}

 

@Override

public void init(FMLInitializationEvent e) {

super.init(e);

ModEntities.mainRegistry();

ItemRenderRegister.registerItemRenderer();

}

 

And this is the code in my ModEntities file:

 

public class ModEntities {

 

public static void mainRegistry() {

registerEntity();

}

 

public static void registerEntity() {

 

                createEntity(EntityFireGuardian.class, "Guardian of Fire", 0xF20505, 0xD8DE31);

}

 

public static void createEntity(Class entityClass, String entityName, int solidColor, int spotColor) {

 

                int randomId = EntityRegistry.findGlobalUniqueEntityId();

 

EntityRegistry.registerGlobalEntityID(entityClass, entityName, randomId);

 

EntityRegistry.registerModEntity(entityClass, entityName, randomId,

                ClientProxy.modInstance, 80, 3, true);

 

createEgg(randomId, solidColor, spotColor);

}

 

private static void createEgg(int randomId, int solidColor, int spotColor) {

 

                EntityList.entityEggs.put(Integer.valueOf(randomId), new EntityList.EntityEggInfo(

                randomId, solidColor, spotColor));

}

}

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6671

diesieben07

diesieben07    6671

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6671
  • 45620 posts
Posted August 11, 2015

The message tells you the exact problem: You told FML to inject your mod instance into the

modInstance

field, but that field is not of the type of your main class, it is of type

ClientProxy

. Of course FML will not be able to inject it then...

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1623

Choonster

Choonster    1623

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1623
  • 5050 posts
Posted August 11, 2015

The field with the

@Instance

annotation needs to be the same type as your main mod class (the one with the

@Mod

annotation), since it holds the instance of that class.

 

Why are you doing this in

ClientProxy

? Entities need to be registered on both sides.

 

There's no reason to use global entity IDs (

EntityRegistry.registerGlobalEntityID

) or manually add spawn eggs in 1.8, if you need a spawn egg just call the

EntityRegistry.registerModEntity

overload with the two extra

int

parameters (the background and foreground colours of the egg).

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • BitNet_
      [1.12.2] Exception loading model

      By BitNet_ · Posted 10 minutes ago

      That hasn't worked for me, I still get the model registering error even when adding the code to my build.gradle
    • JMAS
      Recompile mod with newer version of Java?

      By JMAS · Posted 13 minutes ago

      Thank you for your quick and direct response.   After making the changes directed, I now receive the following error: Execution failed for task ':runClient'. > Process 'command 'C:\Program Files\Java\jdk1.8.0_231\bin\java.exe'' finished with non-zero exit value 1    No new debug.log was generated in run/logs. 😕
    • Lea9ue
      .setRepairItem not work

      By Lea9ue · Posted 27 minutes ago

      In your item class you should have something like...   @Override public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { if (toRepair.getItem().equals("YOUR ITEM") && repair.getItem().equals("WHAT REPAIRS IT")) { return true; } else { return false; } }  
    • Electrodynamite12
      .setRepairItem not work

      By Electrodynamite12 · Posted 34 minutes ago

      I made the ToolMaterial, and i add the .setRepairItem method, announced the ItemStack, where indicated the target item. Maybe i made something wrong? public static Item.ToolMaterial HLOMINITE = EnumHelper.addToolMaterial("another_test:hlominite", 5, 1000, 50.0F, 16.0F, 76).setRepairItem(new ItemStack(ItemsRegister.HLOMINGOT));
    • diesieben07
      [1.12.2] Exception loading model

      By diesieben07 · Posted 1 hour ago

  • Topics

    • BitNet_
      2
      [1.12.2] Exception loading model

      By BitNet_
      Started 8 hours ago

    • JMAS
      6
      Recompile mod with newer version of Java?

      By JMAS
      Started 10 hours ago

    • Electrodynamite12
      1
      .setRepairItem not work

      By Electrodynamite12
      Started 34 minutes ago

    • Hemeroahz
      5
      1.12.2 Crashing Upon Running Forge

      By Hemeroahz
      Started November 27, 2017

    • zhubwat
      9
      Forge not creating version .jar files?

      By zhubwat
      Started January 25, 2016

  • Who's Online (See full list)

    • saxon564
    • JMAS
    • imacatlolol
    • BitNet_
    • AJGingy
    • Lordyammer
    • ItzGenes
    • Nuparu00
    • M1ntcraft3r
    • fcelon
    • KolonilGamer
    • Choonster
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • java.lang.IllegalArgumentException when trying to make first entity (1.8)
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community