Lootr Internals - LootrMinecraft/Lootr GitHub Wiki
Lootr consists of a number of individual pieces, regardless of which mod loader it uses.
Lootr has its own configuration. [In progress]
Lootr creates several blocks that act as alternatives for vanilla blocks:
- Lootr Chest [Complete]
- Lootr Trapped Chest [Complete?]
- Lootr Barrel [Complete]
- Lootr Shulker Box [Complete?]
- Trophy [Complete?]
These are used as replacements for vanilla blocks when suitable.
Lootr creates several block entities for its alternate blocks:
- Lootr Chest Block Entity [Complete]
- Lootr Trapped Chest Block Entity [Complete]
- Lootr Barrel Block Entity [Complete]
- Lootr Shulker Box Block Entity [Complete]
Lootr creates one entity as an alternative to the vanilla minecart-with-chest:
- Lootr Minecart-with-Chest [Complete]
Lootr uses a number of events to handle some replacement functionality.
Break Events are intercepted and Lootr prevents its own containers from being destroyed unless the entity performing the break is sneaking.
When configured, all breaking is prevented unless the player doing so is sneaking while in creative mode.
[Required]
The EntityJoinedWorldEvent
is used to capture information about vanilla minecarts-with-chest being spawned.
As this event can occur asynchronously during world generation, the information from these events is passed into the EntityTicker
.
This event is canceled to prevent a vanilla minecart-with-chest from being spawned, where relevant.
[Complete]
Chunk Events track whenever chunks are fully loaded, storing dimension
and chunkpos
values.
This information is stored in a synchronized
fashion, allowing for the TileTicker
to determine if a replacement should go ahead or not.
Note: As of 1.18, getBlockState
and setBlock
now cause up to 25 chunks to be loaded in a 5x5 area. Replacements are deferred until those chunks have been registered as loaded when fully generated to prevent the main thread from becoming blocked waiting on world generation.
[Complete]
Lootr creates the following block items:
- Lootr Chest Block Item [Complete]
- Lootr Shulker Block Item [Complete]
These specific block items are used when rendering chests and trapped chests and shulker boxes in inventories and GUIs.
The following network packets are curated by Lootr:
- Close Cart
- Open Cart
These packets are specifically sent from the server to the client whenever a player opens a Lootr Minecart-with-Chest and ensures that they properly render with the correct color: gold for unopened, blue for opened.
[Complete]
Three sets of utility functions exist.
The code in this section is used whenever a player interacts with a Lootr container.
This either handles containers being marked as unopened, or handles the actual functionality of containers being opened, including fetching the relevant menu for the specific player for the specific container.
In addition, this code handles refreshing and decaying containers.
[Complete]
This code should be deprecated in favor of ConfiguredStructureFeature<?, ?>
tags.
Currently it is used to determine whether the location of a container that is being replaced is within the confines of any structure.
[Required]
This code provides access to all of the ChestData
instances, along with all scores, statistics, advancements, refreshing and decaying containers.
[Complete]
Lootr creates the lootr
command.
[Required]
Lootr has three separate "types" of SavedData
:
- Advancement data, which stores whether or not an advancement has been granted to a player for opening a specific chest.
- Ticking data, which is used both to store information about decaying chests, as well as storing information about refreshing chests.
- Chest data, which is used to store the data for each individual container.
Note: ChestData
functions as follows:
-
ChestData
is created for each container based off of its Universally Unique Identifier (UUID). - Each
ChestData
contains a correlative map consisting of a player's UUID, along with theSpecialChestInventory
instance that contains whatever items the player has stored.
Note: ChestData
uses subdirectories within the world's data
folder:
- Subfolder
data/lootr
contains theScoreData
,AdvancementData
, as well as the ticking and refreshing data. - Subfolder
data/lootr/X
contains all directories relating to containers whose UUID start with the characterX
- Subfolder
data/lootr/X/XY
contains all serializedChestData
files relating to containers whose UUID start with the charactersXY
.
This system ensures that the data
folder is never filled and that the lootr
subfolder will only ever contain a maximum of 46 (A through Z, 0 through 9) subdirectories. This should ensure that accessing Lootr's data never causes "overflow" or "only displaying first X entries" that some browser-based control panels use.
[Complete]
The Entity Ticker contains essential information to spawn Lootr Minecarts-with-Chest. This process takes place at the end of the server tick to ensure that crashes do not occur.
The Entity Ticker is synchronized
to ensure thread safety.
[Complete]
The Tile Ticker contains essential information used to replace relevant containers with their Lootr equivalents.
The Tile Ticker is synchronzied
to ensure thread safety, both in adding new entries, as well as when performing replacements. This synchronization ensures that world generation threads do not become blocked waiting on the main thread to process, and that the main thread does not become blocked waiting on world generation threads to process.
[Complete]
Lootr for Forge for 1.18.2 uses the following mixins:
- MixinCatSitOnBlockGoal
- MixinLevel
- MixinLevelChunk
MixinCatSitOnBlockGoal causes cats to treat Lootr chests as they would a vanilla chest.
The other two mixins are specifically focus on the addBlockEntity
method, and use the information provided to this method to populate the TileTicker.
[Complete]
- Lootr Chest Block Entity Renderer [Complete]
- Lootr Shulker Box Block Entity Renderer [Complete]
- Lootr Barrel Baked Model [Complete]
- Lootr Minecart-with-Chest Renderer [Complete]
- Lootr Chest Item Renderer [Complete]
- Lootr Shulker Box Item Renderer [Complete]