Jump to content

@SideOnly usage info


FLUFFY2

Recommended Posts

Hello everyone,

I tought i make this simple info because i saw a lot of people using @SideOnly to make their code only run on one side.

Thats a bad idea!

@SideOnly is for making a code only VISIBLE for one side. Feel the difference?

Its good for registration purposes, but you have your Common and ClientProxy, right?

 

You might ask now, than what can we use???

If in your code you have a World as argument or instance you can use: if(world.isRemote)

-world.isRemote = CLIENT

-!world.isRemote = SERVER

Its that simple!

 

Or if you cannot get world for some reason use SIDE checking:

Side side = FMLCommonHandler.instance().getEffectiveSide();

if(side == Side.CLIENT) {

System.out.println("CLIENT");

}else{

System.out.println("SERVER");

}

 

Hope you now not gonna mess up your code and be suprised why is it not working!

Link to comment
Share on other sites

Im just trying to write that for modders who don't understand it.

It not what i don't understand its for others :)

You probably getting sick by seeing how everyone use @SideOnly even if they dont know what it is for.

Well they can know it now.

 

 

Link to comment
Share on other sites

i must admit i have been wondering why use proxys when you can tell what side code to be with "side only" but then i have never fully understood the proxy classes, most guides will tell you how to create them but not how to effectively use them, they along with packet handlers remain a bit of a mystery to me.

I have always taken the approach that if my code works then im happy, im sure if many seasoned modders looked at my source code they would hunt me down with pitchforks :), but then im only modding for the fun of getting something working in game not for the masses(will be released as always for those that may want it but im not planning to be the next calclavia/xcompwizard/dan200 etc etc)

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.