A place for me to share what's on my mind.

Progress Update for FrexBox #1

It’s been around 4 days since I’ve worked on FrexBox, the box server. So far I have solely been working on getting the generation of the boxes to work using our own system. I have made quite a bit of progress, with a ton of extra features on top.

One of the problems I had with existing solutions is, they didn’t offer the level of customizability and efficiency which I aspire to integrate into many of the systems behind FrexBox. Sure, there are plugins which are made for Prison servers that offer generating boxes like CataMines, and many servers use this, but I wanted more.

The Interface

I love integrating GUI interfaces into my projects, that’s why I have worked on one for managing the boxes for my server. This menu lists all of the existing boxes which have been created.

What are boxes you may ask? They’re regions in which a composition of materials spawn inside of a cube


Viewing all boxes

Each box we create appears in the list using the block that is the base material, defaults to stone. I will talk about base materials later.

Some details such as the id, name and timer are shown when hovering over the box. It’s also clickable which opens up the box management panel, more on that soon.

In the bottom right is the button for creating a new box, this opens up a chat input screen where we can type in the id and name of the box. ID’s must be unique as they are used to create bounding boxes.


Viewing a box

This is the panel for managing a box. From here you can change the location, regen timer, how and when it’s spawned, the compositions, and more.

Changing Location

I included the ability to change the location for any box, and by doing this it will move the box to the new location. This is done similarly to the WorldEdit wand, but instead a blaze rod which needs two positions for each corner of the box.

After a new location has been set, the box will either spawn there directly, or be moved from an old location. This is useful when you want to test different locations for a box, without having to redefine it again in the new location.

Spawn Box

This handles how the box is spawned. You don’t always want a box to appear in a world, especially if it’s only for testing purposes, or perhaps events.. So this allows you to despawn it without destroying it, simply removing the physical box from the world. Similarly, you can spawn it again by left clicking.

By middle clicking, this initiates a regen of the blocks within the box. You can either regen as normal, or do a force regen. I will talk about why there is two different options for this later, but there is good reason.

Regen Timer

The regen timer for a box dictates how long in seconds until the box should regenerate its blocks. This can be changed to anything through a chat prompt.

Lock Status

Locking a box would not allow anybody to mine any of the blocks within it. I haven’t gotten around to implement this yet, but I have a pretty good idea how I can go about doing it.

Renaming Box

This simply allows you to rename the box, which is useful if you change your mind. The name will show up in different locations, primarily in front of the mine as a hologram, and in the menus. ID’s and names are different, because then we can have mines with the same name, maybe for testing purposes.

Deleting Box

Of course we need to be able to delete a mine if it’s no longer in use. This will handle deleting of all data about the mine, and remove it from the world. This action is irreversible.

Modifying Compositions

Compositions are arguably the most important feature for a box. This tells it which blocks should generate within the box, and at which rates. This is where we handle that, and it’s the subject for the next section.


Viewing Compositions

This is the composition section, and it’s where you can view all of the blocks which make up a box. Each block will appear here, allowing with some options for each one. You can change the spawn rates, view box info and compositions, and add new ones under the Modify Compositions panel.

Spawn rates changes how frequently blocks appear in the box’s generation. So a value of 10 means that it has a 10% chance of spawning on the given block being generated. All blocks have a chance of spawning, before resulting to the base block. If any value is 100%, the base block won’t be spawned.

Any new blocks added to the composition will be defaulted to having a spawn rate of 10%. This can be modified of course by clicking on the block to change the values.


Viewing Composition Editor

The composition editor allows you to pick and choose the blocks which generate within the box.

The bar at the top of the GUI is all of the current blocks within the composition. Any you add will appear here. You can add more than the 7 spaces, and arrows will appear either side to scroll the list.

The central menu is all of the blocks you can add, and they are all categorized, from stones, ores, to miscellaneous. You can change the category by clicking on the brewing stand icon at the bottom. This allows you to quickly find the blocks you want to add. The arrows either side are for pages, as you can’t display every block in such a limited space.

The numbers at the top of the GUI indicate how many you have in your composition currently, and how many blocks are within the category. All is the default category, showing all available solid blocks.


I think were done talking about the interface, so lets show some actual boxes in action, and talk a bit about how they work, and the approach I took.

The Boxes

This is our box, generated with no composition. When there is no composition, a base block is used instead. This defaults to stone. A base block is used when no other block could be chosen to spawn.

Box Floor

Boxes have a floor, which is the ground the box sits upon. On many servers, they use bedrock to indicate that you can’t mine below the box, the same concept is applied here. The floor generates under where the box does.

The unique thing about this box system is it remembers which blocks used to be where the floor is. So when you delete or despawn the box, the blocks which used to be there will be returned. This allows you to change the boxes location or delete it without needing to fix the hole it made when creating the floor.

Blocks Remember

Each block in a box knows which box it belongs to. This approach allows us to track which block was broken in which box, without having to check if it was broken in a box first by location. We also use this system to only regenerate blocks which belong to the box. This way, we can add blocks inside of the box which aren’t affected by the regeneration, and won’t be replaced.

You’re probably thinking how the block stores this data. Well we use a custom nbt tag applied onto the block which has the box’s id as the value. The only thing which needs to be checked, is the blocks themselves.

Composition

Now lets add some composition.

As you can see, I have added some blocks from within the composition panel showed earlier. Forcing a regen now generates the blocks from the composition. As you remember, each block added defaults to a 10% spawn rate.

If we increase this number to lets say, cobblestone = 40%, and mossy cobblestone = 30%, we get something like this.

As you can see, there’s a more higher rate for the blocks to appear.

Block Determination

So how are these blocks chosen, and when does it default to the base block.

What we do is add all of the blocks into a list, then one by one we run its chance of spawning, and if it missed its changed, it will carry on down the list. This way, all blocks in a composition have a chance of spawning. Until all blocks fail their chance, and it instead choses the base block, which is stone.

This may not be true RNG for the blocks, but it has good enough results.


Future Plans

There is still a lot to add to this whole system, most notably loot tables per block, with multi preset support.


Well that’s all from me this session, still a lot to do and I plan on having some kind of alpha release in 2 months. Until then, it’s back to working on the core systems and mechanics.