navybofus Posted May 19, 2014 Posted May 19, 2014 I've been writing new code for the LittleHelpers mod for a few weeks, but just recently I've added another new block with a TileEntity (like all the others). BUT, every time I try to run any method, it's running twice. I used System.out.println(); and every message appears twice. I added the delay variable that I've set and it displays two different values (the delay is random) so I believe that each method within my tile entity is running twice. This is really messing with the functionality of my blocks. What am I doing different? Should I be using @SideOnly? I haven't had to use it so far and all other blocks work just fine. Just updated to 1082, but I only did that because the problem was happening in 1060. HALP! Quote http://i43.tinypic.com/95v5n9.png[/img]
MoxEmerald Posted May 19, 2014 Posted May 19, 2014 @SideOnly won't do anything for you; only use it if you @Override a method that already uses it. Instead use world.isRemote in an if statement or some-such so that you can check if the method is just running once on the client side and once on the server side. Quote
navybofus Posted May 19, 2014 Author Posted May 19, 2014 In that case, why do none of my other tile entities require isRemote checks? Quote http://i43.tinypic.com/95v5n9.png[/img]
coolboy4531 Posted May 20, 2014 Posted May 20, 2014 Maybe Forge has changed, but if seriously don't use @SideOnly unless you now what it does exactly. You should like MoxEmerald said use world.isRemote. If world.isRemote returns true that means it's on the client side. If it's returns false then that means it's on the server side. I hope you are experienced enough to figure this out. Good luck c: Quote
navybofus Posted May 20, 2014 Author Posted May 20, 2014 I know how the annotations and the side checks work. What I don't understand is why none of my blocks have problems and a lot of their code is similar. None of my blocks have required side checks so far. Quote http://i43.tinypic.com/95v5n9.png[/img]
MoxEmerald Posted May 20, 2014 Posted May 20, 2014 How did you even notice that it was running twice? Just from the System.out? What do the methods even do? It might just be that your other tilentities are running twice but you didn't notice. Without complete information I'm just throwing darts. Something that might be useful is to System.out the words "client" or "server" based on the outcome of world.isRemote. Quote
navybofus Posted May 20, 2014 Author Posted May 20, 2014 I'm doing everything in test worlds where I ensure only one tile entity is present. I'll do some checks but I'm still confused why my other tile entities are working just fine. Quote http://i43.tinypic.com/95v5n9.png[/img]
coolboy4531 Posted May 20, 2014 Posted May 20, 2014 I would probably recommend double-checking everything, seeing if there are mistakes or differences between your other tile-entities. It shouldn't happen if you construct them identically. Like said, you should go ahead and try the "println" methods, but remember one thing check whether it is coming from the client or the server. It should run twice if it's being called on both the client and the server. Quote
navybofus Posted May 20, 2014 Author Posted May 20, 2014 When I get a chance I'll toy around with it. Thanks for all of the advice. I'll let you all know if I get it pinned down or not. Quote http://i43.tinypic.com/95v5n9.png[/img]
LexManos Posted May 21, 2014 Posted May 21, 2014 Should a modder be using @SideOnly ever? NO Why is your code running twice: It's either two instances, or the client and server are ticking it. Depends on what 'code' you're talking about. Quote I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
delpi Posted May 21, 2014 Posted May 21, 2014 I'm often confused by topics like this. If you are debugging this in eclipse, it has a different window for client and server. It should be pretty clear if it is running once on each or you are somehow running it twice on one side (highly unlikely). Quote Long time Bukkit & Forge Programmer Happy to try and help
navybofus Posted May 21, 2014 Author Posted May 21, 2014 I knew that it was ticking on both sides but when The tile entity called the item storage method I received a stack overflow. I thought this was caused by my method recycling the extra items from an item stack that was too large. I've got everything working but I still get the error if the items inherent max stack size is 16 (eggs). About the @SideOnly, through tutorials I was taught to use this for graphics. Is this no longer the case? I do understand that I was confusing side only and isRemote checks when I wrote this post. Quote http://i43.tinypic.com/95v5n9.png[/img]
navybofus Posted May 21, 2014 Author Posted May 21, 2014 I'm often confused by topics like this. If you are debugging this in eclipse, it has a different window for client and server. It should be pretty clear if it is running once on each or you are somehow running it twice on one side (highly unlikely). I'll have to find out how to setup my perspective this way because mine is merged. Quote http://i43.tinypic.com/95v5n9.png[/img]
Recommended Posts
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.