Jump to content

Recommended Posts

Posted

My mod (like many) introduces a new gem to use for tools and armor. I've got single-player working. However, when I try my mod on a server, I run into a paradox.

 

My armor classes constructor calls its super, and the super constructor demands an index that it can assign to renderIndex. I could simply pass a literal '5', but then my mod would collide with every other armor mod in the universe that does the same thing.

 

So I would like to pass the result of a method instead of simply '5'. The method I found is addNewArmourRendererPrefix (prefix). Unfortunately, like others before me, my call to that method blows sky high on the server side. The reason is immediately obvious: The method uses members of the RenderBiped class, and the server doesn't load it.

 

But my problem remains: I don't want to use a literal 5 that is guaranteed to collide with other armor mods. So how do I resolve this dilemma? How do I get a unique "next" armor index for my super() call without upsetting the server?

 

EDIT: I'm now investigating enum ArmorMaterial for some way to arrive at the same number that render would have given me.

   

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.

Posted

First of all +100 for the use of the word Conundrum :P

 

Then: Easiest solution would be to make a method in your proxies that returns an int. In the client proxy make it call the newArmorRendererPrefix method, on the server just use -1, the server doesn't care about the value.

I'm using Forge 1.7.2, so I don't know squat about proxies.

 

However, I found another route via the ordinal() method of enum ArmorMaterial. As long as every armor registers a new material, this works:

 

      private static final String prefix = "ruby";

      public static final ArmorMaterial armorRuby = EnumHelper.addArmorMaterial (prefix, 33, new int[] { 3, 8, 6, 3 }, 25);

      private static final int ARMOR_INDEX = armorRuby.ordinal ();

 

That frees me to use addNewArmourRendererPrefix(prefix) only on the client side, and I just have to hope that the indices will align (or not matter) if there are ever multiple mods.

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.

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.