> For the complete documentation index, see [llms.txt](https://docs.jackf.red/jackfredlib/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jackf.red/jackfredlib/jackfredlib-base/overview.md).

# Overview

Codecs and small utility classes.

The base module contains some small utility classes used elsewhere:

## `Ephemeral2`

An object that can hold a single value and return them a certain amount of times. Used by my mods to pass arguments between functions in mixins. Example use case:

{% code fullWidth="true" %}

```java
public void dropItems(List<ItemStack> items, BlockPos pos, ServerPlayer player) {
    for (ItemStack item : items) {
         dropItem(item);   
    }
}

public void dropItem(ItemStack item, BlockPos pos) {
     level.createItem(item, pos);
}
```

{% endcode %}

If we wanted to change `level.createItem()` so that it depends on `player`:

{% code fullWidth="true" %}

```java
@Unique
private final Ephemeral2<ServerPlayer> SAVED_PLAYER = new Ephemeral2<>();

@Inject(method="dropItems", at = @At("HEAD"))
private void recordPlayer(List<ItemStack> items, BlockPos pos, ServerPlayer player, CallbackInfo ci) {
    SAVED_PLAYER.push(player, items.size());
}

@Inject(method="dropItem", at = @At("HEAD"), cancellable = true)
private void usePlayer(ItemStack item, BlockPos pos, CallbackInfo ci) {
    ServerPlayer player = SAVED_PLAYER.pop();
    
    // here we'd use the player
}
```

{% endcode %}

## `ResultHolder`

Object that can hold a result from an event, designed to be used with cancellable events from Fabric API.

## Memoizer

Small class to lazily initialize an object.

## `ServerTracker`

Static access to the currently running `MinecraftServer` object.
