Skip to content

Updating MineKhan KA Edition

MicrolemurDev edited this page Feb 23, 2022 · 3 revisions

MineKhan KA Edition has had about 1 year without updates and has many inefficiencies when trying to use it in your own projects. However, some things can be patched to improve loading times and performance. This guide will help apply patches to improve and edit MineKhan KA Edition (Alpha 0.7.1).

Why Update MineKhan KA Edition?

  • Permissive Licensing vs No License as of Feb. 23 2022

  • Platform is used for mods sometimes and many of them can be ported to a custom instance with the patches I list (They change parts of the game code on a lower level and don't really add/remove content unless it is legacy code).

  • You still want it on Khan Academy

Removing Unneeded Code

The base game has a fair amount of unneeded functions and checks that can be safely removed without breaking anything. Here is what could be removed:

  • Removing lines 5432 - 5435 will remove the spin-off popup JavaScript check. This can benefit if you are hosting outside of Khan Academy and are making a completely different game off of the code. (This as willard said, was to help have unknowing people who plagiarize not get in some hot water but may not be needed in some cases)

  • If you want to remove Legacy Save loading functionality (Or not use Alpha in your version number) you have to remove lines 4014 and 4016 and lines 4063 and 4102 to remove the function as well. (Looking up loadOldSave in the code should help to find this!)

Rebranding

If you are making your own game based on MineKhan, it is helpful to rebrand your game. Just remember not to plagiarize or steal code. I do not endorse this behavior and never will.

  • On line 1081, the version is stored. You can change the number without patches BUT you need to remove the loadOldSave function and check in order to not use Alpha in your version number. If you don't apply this patch, loading of saves will fail because it thinks you are using a very outdated version of the game.

  • On lines 5451 and 5452, you will find the Title and Subtitle Lines. These can be changed freely and have no checks in place to check their content.

  • Line 5492 has the version display text. You can also change this freely.

Optimizing

The base game also suffers in optimization in some areas to possibly micro-optimize tick speed (see this issue ). Thanks to this issue, we can improve speed (I also will be throwing in a few suggestions of my own!)

  • Lines containing var MathGlob let Math = MathGlob could be const { Math } = self; and const { min, max } = Math; respectively. (You also need to find and remove let min = Math.min; and let max = math.max;.

  • Adding const { random } = Math; and replacing all Math.random() with random() could improve performance by minimizing calls to the window scope.

  • Another useful patch merged into the willard.fun version and it should be very easy to port since it is based off of an old version of MineKhan. (I am not very knowledgeable on WebGL so I won't be much help here!)

  • var is mostly obsolete at this point and let should be used to fix making random things globals (However, MineKhan was made in a way that could cause seemingly random issues when trying to patch the game)

  • In production, creating a minified copy of the program would be advised as this would save a fair amount of bandwidth when hosting it (Faster loading times).

  • If you are fine rewriting a huge amount of code, you could try porting to AssemblyScript to have MineKhan run in WASM. (JS would be needed much less)

Known Problems

MineKhan KA Edition also suffers from problems that this guide has not addressed (or not gone into depth!) such as:

  • Window Scope is abused a lot when constants should be used much more (But again, this is hard to fix without digging into the code and fixing several other problems)

  • Using Strict Mode or type="module" causes several problems that need to be resolved before pushing the game into several modules

  • Several features (Net Code, Entities, etc.) are not implemented and will require implementing yourself

** I hope this guide helped you! (Please note, I do not own all the code here, it belongs to its respective owners) **

Clone this wiki locally