Skip to content

Commit

Permalink
feat: make storage much more efficient (#1122)
Browse files Browse the repository at this point in the history
* feat: add map based stack handler

* feat: add more features to map stack handler

* feat: add data fixer for storage controller stack handler

* feat: update usages of stack handler

* fix: various small fixes

* chore: use manual nbt mapping

* feat: storage percentage display improvements

* feat: improve display

* feat: switch to codec

* feat: update documentation
  • Loading branch information
klikli-dev authored Jun 6, 2024
1 parent 5badf52 commit ab8d5f5
Show file tree
Hide file tree
Showing 20 changed files with 819 additions and 142 deletions.
20 changes: 11 additions & 9 deletions src/generated/resources/assets/occultism/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_soul_gem.usage.text": "To capture an entity, [#](ad03fc)right-click[#]() it with the soul gem. \\\n[#](ad03fc)Right-click[#]() again to release the entity.\n\\\n\\\nBosses cannot be captured.\n",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_soul_gem.usage.title": "Usage",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier1.name": "Storage Stabilizer Tier 1",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier1.spotlight.text": "This simple storage stabilizer is inhabited by a [#](ad03fc)Foliot[#]() that supports the dimensional matrix in keeping the storage dimension stable, thus allowing to store more items.\n\\\n\\\nBy default each Tier 1 Stabilizer adds **256** slots.\n",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier1.spotlight.text": "This simple storage stabilizer is inhabited by a [#](ad03fc)Foliot[#]() that supports the dimensional matrix in keeping the storage dimension stable, thus allowing to store more items.\n\\\n\\\nBy default each Tier 1 Stabilizer adds **64** item types and 512000 items storage capacity.\n",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier2.name": "Storage Stabilizer Tier 2",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier2.spotlight.text": "This improved stabilizer is inhabited by a [#](ad03fc)Djinni[#]() that supports the dimensional matrix in keeping the storage dimension stable, thus allowing to store even more items.\n\\\n\\\nBy default each Tier 2 Stabilizer adds **512** slots.\n",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier2.spotlight.text": "This improved stabilizer is inhabited by a [#](ad03fc)Djinni[#]() that supports the dimensional matrix in keeping the storage dimension stable, thus allowing to store even more items.\n\\\n\\\nBy default each Tier 2 Stabilizer adds **128** item types and 1024000 items storage capacity.\n",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier3.name": "Storage Stabilizer Tier 3",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier3.spotlight.text": "This advanced stabilizer is inhabited by an [#](ad03fc)Afrit[#]() that supports the dimensional matrix in keeping the storage dimension stable, thus allowing to store even more items.\n\\\n\\\nBy default each Tier 3 Stabilizer adds **1024** slots.\n",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier3.spotlight.text": "This advanced stabilizer is inhabited by an [#](ad03fc)Afrit[#]() that supports the dimensional matrix in keeping the storage dimension stable, thus allowing to store even more items.\n\\\n\\\nBy default each Tier 3 Stabilizer adds **256** item types and 2048000 items storage capacity.\n",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier4.name": "Storage Stabilizer Tier 4",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier4.spotlight.text": "This highly advanced stabilizer is inhabited by a [#](ad03fc)Marid[#]() that supports the dimensional matrix in keeping the storage dimension stable, thus allowing to store even more items.\n\\\n\\\nBy default each Tier 4 Stabilizer adds **2048** slots.\n",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stabilizer_tier4.spotlight.text": "This highly advanced stabilizer is inhabited by a [#](ad03fc)Marid[#]() that supports the dimensional matrix in keeping the storage dimension stable, thus allowing to store even more items.\n\\\n\\\nBy default each Tier 4 Stabilizer adds **512** item types and 4098000 items storage capacity.\n",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stable_wormhole.name": "Stable Wormhole",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_stable_wormhole.spotlight.text": "The stable wormhole allows access to a dimensional matrix from a remote destination.\n\\\n\\\nShift-click a [](item://occultism:storage_controller) to link it, then place the wormhole in the world to use it as a remote access point.\n",
"book.occultism.dictionary_of_spirits.crafting_rituals.craft_storage_controller_base.name": "Storage Actuator Base",
Expand Down Expand Up @@ -672,19 +672,19 @@
"book.occultism.dictionary_of_spirits.storage.overview.intro.title": "Magic Storage",
"book.occultism.dictionary_of_spirits.storage.overview.intro2.text": "Follow the steps shown in this category to get your own storage system!\nThe steps related to storage in [Binding Rituals](category://crafting_rituals/) show only the rituals, while here **all required steps** including crafting are shown.\n",
"book.occultism.dictionary_of_spirits.storage.overview.name": "Magic Storage",
"book.occultism.dictionary_of_spirits.storage.storage_controller.config.text": "Slot amount and slot size can be configured in the \"[#](ad03fc)occultism-server.toml[#]()\" config file in the save directory of your world.\n\\\n\\\nIncreasing slot size does not impact performance, increasing slot amount (by a lot) can have a negative impact on performance.\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.config.text": "The item type amount and storage size can be configured in the \"[#](ad03fc)occultism-server.toml[#]()\" config file in the save directory of your world.\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.config.title": "Configurablity",
"book.occultism.dictionary_of_spirits.storage.storage_controller.intro.text": "The [](item://occultism:storage_controller) consists of a [Dimensional Matrix](entry://crafting_rituals/craft_dimensional_matrix) inhabited by a [#](ad03fc)Djinni[#]() that creates and manages a storage dimension, and a [Base](entry://crafting_rituals/craft_storage_controller_base) infused with a [#](ad03fc)Foliot[#]() that moves items in and out of the storage dimension.\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.intro.title": "Storage Actuator",
"book.occultism.dictionary_of_spirits.storage.storage_controller.mods.text": "For other mods the storage controller behaves like a shulker box, anything that can interact with vanilla chests and shulker boxes can interact with the storage controller.\nDevices that count storage contents may have trouble with the stack sizes, if you run into this issue have your server admin set [this option](https://github.com/klikli-dev/occultism/issues/221#issuecomment-944904459).\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.mods.text": "For other mods the storage controller behaves like a shulker box, anything that can interact with vanilla chests and shulker boxes can interact with the storage controller.\nDevices that count storage contents may have trouble with the stack sizes.\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.mods.title": "Interaction with Mods",
"book.occultism.dictionary_of_spirits.storage.storage_controller.name": "Storage Actuator",
"book.occultism.dictionary_of_spirits.storage.storage_controller.recipe.text": "This is the actual block that works as a storage, make sure to craft it!\nPlacing just the [](item://occultism:storage_controller_base) from the previous step won't work.\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.safety.text": "Breaking the storage controller will store all contained items in the dropped item, you will not lose anything.\nThe same applies to breaking or replacing Storage Stabilizers (you will learn about these later).\n\\\n\\\nLike in a shulker box, your items are safe!\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.safety.title": "Safety first!",
"book.occultism.dictionary_of_spirits.storage.storage_controller.size.text": "The storage controller by default provides **128** slots (_You will learn later how to increase that_). Each slot can hold up to **1024** items, even items that usually have smaller stack sizes or are not stackable at all.\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.size.text": "The storage controller holds up to **128** different types of items (_You will learn later how to increase that_). Additionally it is limited to 256000 items in total. It does not matter if you have 256000 different items or 256000 of one item, or any mix.\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.size.title": "So much storage!",
"book.occultism.dictionary_of_spirits.storage.storage_controller.unique_items.text": "The only exception to the increased stack size are **items with unique properties** (\"NBT data\"), such as damaged equipment, which cannot stack at all and will take up a full slot. For optimal storage results you should limit the amount of these items in your system.\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.unique_items.text": "Items with unique properties (\"NBT data\"), such as damaged or enchanted equipment will take up one item type for each variation. For example two wooden swords with two different damage values take up two item types. Two wooden swords with the same (or no) damage take up one item type.\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.unique_items.title": "Unique Items",
"book.occultism.dictionary_of_spirits.storage.storage_controller.usage.text": "After crafting the [](item://occultism:storage_controller) (see following pages), place it in the world and [#](ad03fc)right-click[#]() it with an empty hand. This will open the GUI of the storage controller, from there on it will work much like a very big shulker box.\n",
"book.occultism.dictionary_of_spirits.storage.storage_controller.usage.title": "Usage",
Expand All @@ -693,7 +693,7 @@
"book.occultism.dictionary_of_spirits.storage.storage_stabilizer.demo.text": "**Note:** You do not need all 4 stabilizers, even one will increase your storage.\n",
"book.occultism.dictionary_of_spirits.storage.storage_stabilizer.demo.title": "Storage Stabilizer Setup",
"book.occultism.dictionary_of_spirits.storage.storage_stabilizer.name": "Extending Storage",
"book.occultism.dictionary_of_spirits.storage.storage_stabilizer.spotlight.text": "Storage Stabilizers increase the storage space in the storage dimension of the storage actuator. The higher the tier of the stabilizer, the more additional storage slots it provides. The following entries will show you how to craft each tier.\n\\\n\\\n",
"book.occultism.dictionary_of_spirits.storage.storage_stabilizer.spotlight.text": "Storage Stabilizers increase the storage space in the storage dimension of the storage actuator. The higher the tier of the stabilizer, the more additional storage it provides. The following entries will show you how to craft each tier.\n\\\n\\\n",
"book.occultism.dictionary_of_spirits.storage.storage_stabilizer.upgrade.text": "It is **safe to destroy a storage stabilizer** to upgrade it. The items in the [Storage Actuator](entry://storage/storage_controller) will not be lost or dropped - you simply cannot add new items until you add enough storage stabilizers to have free slots again.\n",
"book.occultism.dictionary_of_spirits.storage.storage_stabilizer.upgrade.title": "Upgrading",
"book.occultism.dictionary_of_spirits.summoning_rituals.afrit_essence.intro.text": "[](item://occultism:afrit_essence) is required to safely call on the more powerful spirits, commonly used in the form of red chalk. To obtain the essence, an [#](ad03fc)Afrit[#]() needs to be summoned unbound into this plane, and killed. Be warned that this is no simple endeavour, and unbound spirit presents great danger to all nearby.\n",
Expand Down Expand Up @@ -882,6 +882,8 @@
"gui.occultism.storage_controller.search.tooltip_sort_type_name": "Sort by item name.",
"gui.occultism.storage_controller.shift": "Hold shift for more information.",
"gui.occultism.storage_controller.space_info_label": "%d/%d",
"gui.occultism.storage_controller.space_info_label_new": "%s%% filled",
"gui.occultism.storage_controller.space_info_label_types": "%s%% of types",
"item.minecraft.diamond_sword.occultism_spirit_tooltip": "%s is bound to this sword. May your foes tremor before its glory.",
"item.occultism.afrit_essence": "Afrit Essence",
"item.occultism.awakened_feather": "Awakened Feather",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"background_parallax_layers": [],
"background_texture_zoom_multiplier": 1.0,
"background_width": 512,
"condition": {
"type": "modonomicon:entry_read",
"entry_id": "occultism:getting_started/intro"
},
"entry_textures": "modonomicon:textures/gui/entry_textures.png",
"icon": {
"height": 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"background_parallax_layers": [],
"background_texture_zoom_multiplier": 1.0,
"background_width": 512,
"condition": {
"type": "modonomicon:entry_read",
"entry_id": "occultism:getting_started/intro"
},
"entry_textures": "modonomicon:textures/gui/entry_textures.png",
"icon": {
"height": 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"background_parallax_layers": [],
"background_texture_zoom_multiplier": 1.0,
"background_width": 512,
"condition": {
"type": "modonomicon:entry_read",
"entry_id": "occultism:getting_started/intro"
},
"entry_textures": "modonomicon:textures/gui/entry_textures.png",
"icon": {
"height": 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"background_parallax_layers": [],
"background_texture_zoom_multiplier": 1.0,
"background_width": 512,
"condition": {
"type": "modonomicon:entry_read",
"entry_id": "occultism:getting_started/intro"
},
"entry_textures": "modonomicon:textures/gui/entry_textures.png",
"icon": {
"height": 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"background_parallax_layers": [],
"background_texture_zoom_multiplier": 1.0,
"background_width": 512,
"condition": {
"type": "modonomicon:entry_read",
"entry_id": "occultism:getting_started/intro"
},
"entry_textures": "modonomicon:textures/gui/entry_textures.png",
"icon": {
"height": 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public interface IStorageControllerGui {
//region Getter / Setter
void setStacks(List<ItemStack> stacks);

void setUsedSlots(int slots);
void setUsedStorageSize(int usedItemTypes, long usedTotalItemCount);

void setMaxSlots(int slots);
void setMaxStorageSize(int maxItemTypes, long maxTotalItemCount);

void markDirty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,19 @@ public interface IStorageController {
/**
* @return the max slots available in this storage controller.
*/
int getMaxSlots();
int getMaxItemTypes();

/**
* @param slots the max slots available in the storage controller.
*
* @param maxItemTypes the maximum amount of different items the controller can hold.
* @param maxTotalItemCount the maximum total amount of items (all item types added up) the controller can hold.
*/
void setMaxSlots(int slots);
void setStorageLimits(int maxItemTypes, long maxTotalItemCount);

/**
* @return the used up slots. Usually lazily updated when calling getStacks.
*/
int getUsedSlots();
int getUsedItemTypes();

/**
* @return a list of block entity references for the machines liked for autocrafting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ public abstract class StorageControllerGuiBase<T extends StorageControllerContai
public List<ItemStack> stacks;
public List<MachineReference> linkedMachines;
public IStorageControllerContainer storageControllerContainer;
public int usedSlots;
public int maxSlots;
protected int maxItemTypes;
protected int usedItemTypes;
protected long maxTotalItemCount;
protected long usedTotalItemCount;
public StorageControllerGuiMode guiMode = StorageControllerGuiMode.INVENTORY;
protected ItemStack stackUnderMouse = ItemStack.EMPTY;
protected EditBox searchBar;
Expand All @@ -96,6 +98,7 @@ public abstract class StorageControllerGuiBase<T extends StorageControllerContai
protected Button autocraftingModeButton;
protected Button inventoryModeButton;
protected LabelWidget storageSpaceLabel;
protected LabelWidget storageTypesLabel;
protected int rows;
protected int columns;

Expand Down Expand Up @@ -198,20 +201,23 @@ public void setStacks(List<ItemStack> stacks) {
}

@Override
public void setUsedSlots(int slots) {
this.usedSlots = slots;
public void setMaxStorageSize(int maxItemTypes, long maxTotalItemCount) {
this.maxItemTypes = maxItemTypes;
this.maxTotalItemCount = maxTotalItemCount;
}

@Override
public void markDirty() {
this.init();
public void setUsedStorageSize(int usedItemTypes, long usedTotalItemCount) {
this.usedItemTypes = usedItemTypes;
this.usedTotalItemCount = usedTotalItemCount;
}

@Override
public void setMaxSlots(int slots) {
this.maxSlots = slots;
public void markDirty() {
this.init();
}


@Override
public void setLinkedMachines(List<MachineReference> machines) {
this.linkedMachines = machines;
Expand Down Expand Up @@ -258,8 +264,18 @@ public void init() {
new LabelWidget(this.leftPos + storageSpaceInfoLabelLeft, this.topPos + storageSpaceInfoLabelTop, true,
-1, 2, 0x404040);
this.storageSpaceLabel
.addLine(I18n.get(TRANSLATION_KEY_BASE + ".space_info_label", this.usedSlots, this.maxSlots), false);
.addLine(I18n.get(TRANSLATION_KEY_BASE + ".space_info_label_new",
String.format("%.2f", (double)this.usedTotalItemCount / (double)this.maxTotalItemCount * 100)

), false);
this.addRenderableWidget(this.storageSpaceLabel);

this.storageTypesLabel =
new LabelWidget(this.leftPos + storageSpaceInfoLabelLeft - 7, this.topPos + storageSpaceInfoLabelTop + 40, true,
-1, 2, 0x404040);
this.storageTypesLabel
.addLine(I18n.get(TRANSLATION_KEY_BASE + ".space_info_label_types", String.format("%.0f", (double)this.usedItemTypes / (double)this.maxItemTypes * 100)), false);
this.addRenderableWidget(this.storageTypesLabel);
this.initButtons();
}

Expand Down
Loading

0 comments on commit ab8d5f5

Please sign in to comment.