Jump to content

Need help understanding Metadata items using @SideOnly


Recommended Posts

I'm new to modding and I'm starting with 1.7.10 because I bought Wuppy's book (http://www.amazon.com/Teach-Yourself-Development-Minecraft-Hours/dp/0672337193).


Anyways, in the section that talks about creating multiple items using one ID by using metadata, he ends up using the IIcon object which uses @SideOnly(Side.CLIENT).


I understand the code and how it works, however, i'm a little lost in the understanding of how this works if I were to run this mod on a dedicated server. Can I run it on a dedicated server? Will the server crash?


According to diesieben07 and what he wrote here, it WILL crash.


How would I get this to run on a dedicated server then?


Any help in understanding this would be greatly appreciated.



Link to comment
Share on other sites

If you're using @SideOnly for any methods fields dealing with IIcon or anything related to textures/rendering then @SideOnly is good. Any of this sort of method will never get called on the server, so using @SideOnly will not cause any problems.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Link to comment
Share on other sites

Why won't it get called on the server? I guess my problem is that I don't have ANY experience with client/server programming. Shouldn't everything that gets called on the client, also be called on the server?


Here's one method that he uses in the book:

    public void registerIcons(IIconRegister par1IconRegister)
        icons = new IIcon[this.keyNames.length];

        for (int i = 0; i < this.keyNames.length; i++)
            icons[i] = par1IconRegister.registerIcon(SamsMod.MODID + ":" + "key" + " " + keyNames[i]);



Don't the icons also need to be "registered" on the server too? How else does the server know what texture/icon goes to what item?

Link to comment
Share on other sites

The vanilla Item class already has SideOnly (client) on it.  Redeclaring it isn't going to fuck up anything, and neither will leaving it off.  Nothing in vanilla code calls getIcon when running a dedicated server.  There is NO rendering code on the server, so all rendering related calls are client-side-only and marked as such.

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.

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.

  • Create New...

Important Information

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