Jump to content

Am i missing something when it comes to proxies?


brandon3055

Recommended Posts

My proxies don't seem to be working as i would expect. The way i thought proxies work is if i call a method in my proxy ising MainClass.proxy.someMethod() That would call ether the client side or the server side version method of that method depending on which side it is called from. However i have created a method "isClientSide" that returns true in my client proxy and false in my server proxy but for some reason when i call MainClass.proxy.isClientSide() it returns true on both the server and the client. Have i messed something up or is this not how proxies work?

I am the author of Draconic Evolution

Link to comment
Share on other sites

That's mostly how it works.  However, you need to be careful with the word "client" because when you run locally it actually runs on both sides.  So the "client" is actually an "combined client and server".  You can see some discussion on that point here:  http://greyminecraftcoder.blogspot.com/2013/11/how-forge-starts-up-your-code.html

 

Post your code. 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

No, you haven't messed something up.

Proxies are to differentiate between the client jar file and the server jar. The Integrated Server will use the ClientProxy, because it is part of the client jar.

If you want to check the "logical" side, use world.isRemote.

I suspected it was something like that. I just wanted that method in my proxy for a situation where i dont have the world object to work with but i should be able to work around it i was just a little confused.

 

That's mostly how it works.  However, you need to be careful with the word "client" because when you run locally it actually runs on both sides.  So the "client" is actually an "combined client and server".  You can see some discussion on that point here:  http://greyminecraftcoder.blogspot.com/2013/11/how-forge-starts-up-your-code.html

 

Post your code. 

I am aware that the server and client are merged in singleplayer i discovered that a while ago when i was debugging some server crashes. I dont think its worth posting the code for this but especially since diesieben already told me the problem but here it is.

 

 

Common Proxy

public abstract MinecraftServer getMCServer();

Server Proxy (extends Common Proxy)

@Override
public boolean isClientSide() {
LogHelper.info("Server Proxy");//debug
return false;
}

Client Proxy (extends Common Proxy)

@Override
public boolean isClientSide() {
LogHelper.info("Client Proxy");
return true;
}

 

I originally just had the client and the common proxies but i added the server proxy when i was trying to figure out what was going on.

 

 

 

I am the author of Draconic Evolution

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.



×
×
  • Create New...

Important Information

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