After getting sick of getting random bugs in the ender client I started to after hundred years of dreaded bug crashes look in the code to figure out where things go wrong. In this thread I will try and address a few bug fixes I have found. If you provide a printout of the crash you get I might be able to fix other bugs you might encounter as well.
Goal is to make the original Ender client more stable and maybe improve on it. Hopefully Ender might show up here on the forums and add it to his update thingy and make the update public. Until then bug fixes might only be available to the people that have the ability to compile there own client from the source code found with the git provided by Ender.
Bug number one. Random crash when trying to load a new area:
This bug shows up along with the show player lines in the client when you walk into a new area, for example in and out of a house or minehole, and immediately try and walk in any direction. You get a nullpointer exception in the console if you have yours open and the client freezes. Other players see you as logged in but on your end everything appears to have frozen up.
The bug is found in src/haven/MapView.java.
Line 1478
relating to this line: g.line(player.sc, pc, 2);
player.sc on some instances shows up as null and causes this bug. To remedy this issue you can simply add a null check before this line changing the line 1478 from what it is to this line.
if(player.sc != null && pc != null) g.line(player.sc, pc, 2);
just to make extra sure you could add a null check on the variable "pc" to assure this bug doesn't show up again.
Bug number two. Clint crash but still shows up as logged in.
This is the most frustrating bug as it is related to the recent bug the server is throwing around where it randomly kicks you from the server. You show up as logged out to other players but you don't know if you are logged out or if its just simply lag. What is actually happening is that you have been kicked by the server but on your end you show up as your logged in. The same bug shows up when you go to the options menu and click log out. Your client freezes up completely and you don't know if your logged out or not.
This was a tricky bug to hammer out. Its related to the main clients startup loop.
src/haven/HavenApplet.java runs a loop at line 159 where it constantly loops from the start screen into the game and if the game ends back to the start screen. The big issue in all of this is that the game never ends in some instances. Even if you try and log out the game keeps going.
By game I mean the line 166 rui.run(h.newui(sess));
To fix this issue you have to look into the Session class as it is this loop that never break.
src/haven/Session.java
This class has 3 loops running the main client.
private class Ticker extends HackThread {
private class RWorker extends HackThread {
private class SWorker extends HackThread {
These subclasses are run in a magical loop that even I am not fully familiar with. But it is clear that the variable boolean alive; is mostly responsible for keeping these loops going. From first glance this variable is set to false when the funtion interrupt(); is called in the subclass SWorker. But something goes wrong somewhere and the interrupt(); function is never called. As a quick fix I forced the client to interrupt by adding these interrupt function in the function close() found on line 677 public void close() {
By simply adding these 2 lines I made the client force the alive variable to false and actually break the loops that never were stopping to loop.
ticker.interrupt();
rworker.interrupt();
line 677 changed from:
public void close() {
sworker.interrupt();
}
to:
public void close() {
ticker.interrupt();
rworker.interrupt();
sworker.interrupt();
}
Mysteriesly the bug disappeared on my end when doing this change. Now the client actually does log out and go into the login screen when I crash or if I click the log out button. As I am not fully familiar with the inner workings of the sworker function I am unsure of the exact reasons why this actually works and I don't get 50 errors when interruptions are made prior to them actually be made by the sworker function. But it works as intended so that makes me happy and hopefully wont make my pc explode. I can't say I know why exactly it works but I know it is stable and been working reliably for 2-3 weeks now.
Bug number three. Mouse item buggering up your zoom.
The Ender client added a very nice feacher where you could zoom in and out compared to the original client. But a small bug came along with it. When you pick up an item all world actions are disabled until the mouse item is dropped on the ground or into the inventory. No move action or object interaction, not even zoom works. The zoom feacher is fixable to make you able to zoom in and out while holding a mouse item. You can also scroll items in and out of your inventory holding mouse items. This bug is easily fixable.
There is also a way to make the client interact with the world when holding mouse items but its buggy to implement and honestly I would not suggest to add this feacher unless you know what your doing. You wont get a client crash or anything but you might have the mouse item bug out and force you to drop the item to fix the different client codes from competing over the mouse item.
Zoom fix:
The client code was made so if in the future mouse wheal action connecting to the item you are holding on the mouse cursor was added the code would be already implemented. But as of now there are no mouse cursor and mouse scroll interactions. This whole feacher can be disabled freeing the mouse scroll from the mouse item and , enabling you to use scroll wheal even while holding a mouse item.
To fix this bug / adding of feacher you need to look into src/haven/UI.java
lines 331 to 335 shows you the code you need to edit to make this work.
if(mousegrab == null)
root.mousewheel(c, amount);
else
mousegrab.mousewheel(wdgxlate(c, mousegrab), amount);
}
to fix this simply edit all lines except "root.mousewheel(c, amount);"
makeing it look like this
//if(mousegrab == null)
root.mousewheel(c, amount);
//else
// mousegrab.mousewheel(wdgxlate(c, mousegrab), amount);
//}
This should enable mouse scroll action even when mouse items are held and its honestly stable as I have been using it for over a month.
The ability to move around with mouse items is a bit more complicated. I will only show this feacher if its requested in this thread as its tricky and honestly not stable at all. It also requires a bit of extra code to be added into UI.java, RootWidget.java and Config.java. With a bit of finesse and tinkering it could become more stable and honestly added into the client as a complete feacher but as of now I have no idea how to add it in a way so its intuitive and stable enough.
I hope someone finds this info useful and can add it to there client. If requested I will try and help fix more common bugs.