2. History
• Created in October 2020
• Named Rayon since it uses the Fabric API
• Rigid body dynamics for entities
• Acts as a library
3. JBullet vs LibBulletJME
• JBullet
• Written only in Java
• Dead project
• Missing features
• LibBulletJME (from the JMonkeyEngine
project)
• Native wrapper for original C++ Bullet
• Actively maintained
• Access to every feature in C++ Bullet
• Faster execution due to native code
4. Sides (Client vs Server)
• Minecraft has two logical sides:
Client and Server
• Rayon runs on both
• Server synchronizes clients
• Ensures a consistent game state
between servers and clients
5. Multithreading
• Introduced after the replacement of JBullet
• Spawns new thread for each logical client
and server
• 10x Performance Boost
• Sleeping rigid bodies
Physical Client
(containing rendering code)
Physical Server
(purely game logic)
Client Physics Thread
and/or
Server Physics Thread
Logical Client
and/or
Logical Server
Logical Server
Server Physics Thread
6. Transporter
• Allows rendered model information to be
“beamed” to the server
• Generates accurate rigid body collision
shapes
7. Applications
• Quadz
• FPV drone racing in Minecraft
• Original purpose of Rayon
• Dropz
• All dropped items are now rigid bodies
• Items can be thrown or just tossed
• Thinking with Portatos
• Created by another group
• Adds portal guns to the game
• Uses Rayon for cubes
I started Rayon last October as a fun side project, but it became apparent to me that this is something I’m able to present at the student academic conference. The reason it is called Rayon is because rayon is a type of fabric and it makes use of an API called the Fabric API which is designed with Minecraft modding in mind. It generally allows Minecraft modifications to be compatible with one another. Rayon only makes use of fabric’s networking and event handling modules, but there are other facets of it which are useful as well which I won’t get into here.
The main purpose of Rayon, as you may have guessed, is to integrate physics in Minecraft. More specifically, Rayon allows what are called rigid bodies to be paired with in-game entities (for example, pigs, cows, or other non-living entities such as boats). A rigid body will behave more or less according to the laws of physics inside of the physics space set up by Rayon. There are some configurable settings for any given physics space as well such as gravity and air density (for air resistance).
It’s also worth noting that Rayon by itself doesn’t really do anything since it is just a library. Its intended purpose is to be used by other mod authors for their own projects
The physics engine that Rayon integrates into the game is called Bullet. Bullet is a physics engine written in C++ that has been ported to several other languages including python and java. In this case, JBullet was the original library chosen for Rayon (which is the java port of bullet). After its initial implementation, it became apparent that JBullet was not the only option, let alone the best option. I came across another implementation of Bullet called LibBulletJME, a sub-project of jMonkeyEngine, which served as a wrapper for the original C++ Bullet library. What this means is that LibBulletJME runs C++ code under the hood instead of pure java which results in greater performance (and performance was an issue with JBullet, originally).
Just as a comparison, some negative aspects of JBullet were that it was written in pure java, it hasn’t been maintained for over ten years, and due to its stagnation, it is missing a lot of features which are present in the latest Bullet. LibBulletJME overcomes all of these issues since it is written only partially in java, it is actively maintained, and it provides access to every feature within Bullet. The only real downside to using LibBulletJME is that bullet natives must be included with Rayon in order to have cross-platform compatibility. The main side effect is that the project files take up much more space.
This part is worth explaining because it will help explain the next step in Rayon’s development. So, some of you may already know that Minecraft has two “sides” to the game, but there is more to it than that. Generally speaking, there are really four sides: the physical client, the logical client, the physical server, and the logical server. In the diagram shown, the game client and dedicated server would be the physical client and server while the client and server threads are the logical client and servers. There is also some interchangeability as to where the logical server is located: it can be on the physical client or the physical server. Rayon runs its physics simulation on both the logical client and the logical server. In order to make sure they share the same physics state, the server synchronizes the position, rotation, velocity, etc. of every rigid body to the client. That way every player sees the same thing and cheating is not possible.
Since LibBulletJME was quick to implement, I went on and implemented multithreaded physics as well. What happens is when the player enters a world, a new thread is spawned from both the logical client and server threads. Then these newly spawned threads step the simulation asynchronously along with normal game logic. What I found after doing some load testing was that it introduced a staggering 10x performance boost. Instead of being able to spawn 200 entities before the game becomes unplayable, I was able to spawn over 2000. Of course, a typical mod which uses Rayon would never spawn that many entities in the first place. Another huge performance boost came from allowing rigid bodies to “sleep” when their position does not change for a certain amount of time. This saves lots of computation time by skipping those rigid bodies in the simulation update process.
The graphic on the right models the relationship between the physical client and server, the logical client and server, and the associated physics thread.
Another part of Rayon is loading the Minecraft world into the simulation. All rigid bodies added to the world will automatically generate rigid bodies for each block within a certain radius. The reason it doesn’t just add every single block is because it would be much too resource intensive.
A subsystem of block loading that Rayon has is a separate project I created called Transporter. It is responsible for generating collision shapes which are more accurate to the block it represents. So instead of just making a cube like most blocks, it can generate a shape for stairs, fences, beds, etc. It is able to create these shapes by rendering them using the client renderer and then sending that information to the server. Since Transporter is star trek themed (as you can see by the logo in the top left), it is possible to explain the process it follows where it generates a “pattern” and stores it in the “pattern buffer” which is “beamed” to the server.
So you might be wondering what a library like Rayon might be used for.
One example would be another project of mine called Quadz. Quadz adds flyable, remote control, first person view drones to Minecraft and it is the original reason Rayon was created. One of the main features of quadz is realistic flight characteristics and all of that is now powered by Rayon. Rayon isn’t the only library Quadz uses since it also uses a library called gecko lib for entity animation and another library called fiber for configuration serialization.
Another example is another project of mine called Dropz. Dropz is mainly a novelty mod which converts every dropped item into a physics entity. It is probably the best demonstration of Rayon’s capabilities so far as you can see on the slide.
My last example is an open-source project created by another group called Thinking with Portatos. It’s a portal gun mod which uses Rayon for their weighted storage cubes. Aside from those, I have received positive messages from others who have seen Rayon and several people have expressed interest in using it at some point in the future
Assuming zoom will cooperate, I would like to give a short demo of Rayon’s test mod which just adds a small cube entity to the game.