loonmc

Join the server!
Up on "ciomek.pl" and with web view hosted on loonmc web.
loonmc
What is loonmc?
loonmc is a mod that integrates Better Than Adventure with MQTT server and then with a web
backend. It lets you see your stats, map and logs in the web browser. Every stat is live and you
can see each item dropped or server TPS in real time. For now the features are rather limited
but still there.
You can currently see inventory, map and basic server info like TPS in real time. There is also
a new log system. Each new event is logged to the server and then admin can read them. Although
it's worth to note that this is backend and not mod functionality.




How does it work?
The logic structure works in 3 components. Babric server - MQTT server - backend bridge. Babric
mod logs every action to MQTT server. Backend retrieves all of them and then filters them out to
specific users. It also adds some internal logic like Marquee stuff. Even though for now it only
uses loon-backend, the MQTT server architecture allows any programmer to create their own apps
utilizing it.
Babric server
loonmc mod
logs every action
MQTT server
events + req / resp
backend bridge
loon-backend
local auth
filter per user + marquee
loonmc web
any other integrations you need
- Babric server to MQTT server
- MQTT server and backend bridge, both directions
- backend bridge and loonmc web, both directions
- MQTT server and any other integrations you need, both directions
Still more work to do
Right now the mod is working as MVP. There are a lot of ideas in my head but the most important
ones right now are:
- Thread safety
- Integrating other mods (like Quetzal)
- Admin views
- Allowing friends to see your stats
- Android App
- Code refactoring on some components
Current issues
@Mixin(value = WorldServer.class, remap = false)
public class WorldServerMixin {
...
@Inject(method = "tick", at = @At("TAIL"))
private void onTick(CallbackInfo ci) {
countTicks();
positionCountdown();
handleRequests();
}
...
@Unique private void handleRequests()
{
IRequest request;
while ((request = RequestManager.pollRequest()) != null) {
IRequest current = request;
if (current.requireTickThread()) {
runRequest(current);
} else {
EXECUTOR.submit(() -> runRequest(current));
}
}
}
@Unique
private void runRequest(IRequest request) {
try {
request.handle(mcServer);
} catch (Exception e) {
Loon.LOGGER.error("Failed to handle request: {}, {}", request.getClass().getSimpleName(), e);
}
}
}
The current biggest one is using the tick thread. Minecraft works through ticks to sync
everything. Because of that to be safe you should be doing everything in ticks. It works fine
for stuff like reading inventory. It becomes an issue when you want to run some long operation
between ticks. If it takes too much time then TPS becomes low and the server lags.
Reading chunks takes a lot of time as there are quite a lot of them. In the prototype it just
used a completely different thread to not lag the server. Then I just switched to not reading
chunks from Minecraft thread. Right now it reads all chunks from disk which is not only
sub-optimal but also doesn't solve the issue 100%. There still can be some issues if the app
tried to read chunks the exact time when Minecraft thread tries to write into it.
The structure allows you to set a command off Minecraft thread (at your own risk).
Links
You can check it out here:
And fully working deployment on loonmc web.
Last updated: