-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf2498f
commit 836bf0b
Showing
8 changed files
with
297 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
sidebar_position: 13 | ||
--- | ||
|
||
# Configuration | ||
|
||
Curios has various configuration files that can be used to change settings related to the user interface, curios | ||
behavior, and more. | ||
|
||
## Slot Configuration | ||
|
||
Although the datapack method described in the [slot types](./slots/slot-register.md) page is the recommended method for | ||
all consumers, users who are not familiar with datapacks or do not need the features of the format are able to create | ||
and modify slots through the Curios configuration file. | ||
|
||
This configuration is located in the `curios-common.toml` configuration file found in the `config` folder of the user's | ||
root Minecraft instance. | ||
|
||
```toml | ||
#List of slots to create or modify. | ||
slots = [] | ||
``` | ||
|
||
The slots list will be empty at first. Users can define a slot entry by inputting a string entry into the array. All | ||
slots that are defined in this setting will automatically be assigned to players if they are not already assigned. | ||
|
||
:::note | ||
This setting is loaded server-side only and synced to clients. Servers can change this setting without updating clients | ||
and clients will receive the proper slots upon joining. | ||
::: | ||
|
||
### Syntax | ||
|
||
Each entry must include an `id` field that represents the identifier of the slot type, and fields in the entry must be | ||
separated by semicolons. The following fields are available for use through the configuration file: | ||
|
||
#### **id** (string, *required*) | ||
The identifier for the slot type to create or modify. | ||
|
||
#### **size** (integer) | ||
The number of slots of this slot type to give by default. | ||
|
||
#### **operation** (`"SET"`\|`"ADD"`\|`"REMOVE"`) | ||
Whether to use `size` to set, add, or remove from the total number of slots. | ||
|
||
#### **order** (integer) | ||
The order the slots will appear in the native Curios GUI, lower numbers appear first. | ||
|
||
#### **icon** (string) | ||
The location of the icon to use for the slot type. | ||
|
||
#### **add_cosmetic** (boolean) | ||
The location of the icon to use for the slot type. | ||
|
||
#### **use_native_gui** (boolean) | ||
When `false`, does not add the slot type to the native Curios GUI. | ||
|
||
#### **render_toggle** (boolean) | ||
When `false`, does not allow the slot type to toggle its rendering. | ||
|
||
#### **drop_rule** (`"DEFAULT"`\|`"ALWAYS_DROP"`\|`"ALWAYS_KEEP"`\|`"DESTROY"`) | ||
Whether to drop, keep, destroy, or follow the `keepCurios` configuration setting. | ||
|
||
### Example | ||
|
||
```toml | ||
slots = ["id=ring;size=10", "id=charm;size=3;add_cosmetic=true"] | ||
``` | ||
|
||
This setting will create or modify two slot types, `"ring"` and `"charm"`, and assign both of them to all players. The | ||
ring slot type will be created at size 10, and the charm slot type will be created at size 3 while also adding cosmetic | ||
slots for them. These settings will override any settings from the datapack configurations as described in the main | ||
[slot types page](./slots/slot-register.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "Inventory", | ||
"position": 3, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "All about the curio inventory and how to manage it." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
# Basic Inventory Management | ||
|
||
Learn how to access and manage the Curios inventory attached to an entity. | ||
|
||
## Overview | ||
--- | ||
Each entity that has been assigned any number of slot types based on [entity registration](../slots/entity-register.md) | ||
will automatically gain a Curios inventory, initialized with a sub-inventory for each slot type that has been assigned. | ||
This inventory can be used for a variety of purposes, such as finding out which items are held in the inventory or | ||
modifying the number of slots that are in each sub-inventory. | ||
|
||
The interface for the Curios inventory can be found as `top.theillusivec4.curios.api.type.capability.ICuriosItemHandler`, | ||
which holds all of the methods that developers can use to access and manage the inventory. | ||
|
||
## Using the inventory | ||
--- | ||
To begin using the inventory, developers will need to grab the instance associated with each entity. The | ||
`top.theillusivec4.curios.api.CuriosApi` class has a `getCuriosInventory` method that can be used: | ||
|
||
<Tabs groupId="modloader"> | ||
<TabItem value="forge" label="Forge" default> | ||
```java | ||
LazyOptional<ICuriosItemHandler> maybeCuriosInventory = CuriosApi.getCuriosInventory(livingEntity); | ||
``` | ||
The query returns a `LazyOptional` as the specified entity may not have a curios inventory. If the result is certain to | ||
exist, then the optionality can be disregarded and simplified to: | ||
```java | ||
ICuriosItemHandler curiosInventory = CuriosApi.getCuriosInventory(livingEntity).resolve().get(); | ||
``` | ||
</TabItem> | ||
<TabItem value="neoforge-2" label="NeoForge 1.20.3+"> | ||
```java | ||
Optional<ICuriosItemHandler> maybeCuriosInventory = CuriosApi.getCuriosInventory(livingEntity); | ||
``` | ||
The query returns a `Optional` as the specified entity may not have a curios inventory. If the result is certain to | ||
exist, then the optionality can be disregarded and simplified to: | ||
```java | ||
ICuriosItemHandler curiosInventory = CuriosApi.getCuriosInventory(livingEntity).get(); | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
|
||
Since the method returns an `Optional` by default, developers will need to make sure to use `Optional#ifPresent` first | ||
in order to check that the inventory actually exists: | ||
|
||
```java | ||
CuriosApi.getCuriosInventory(livingEntity).ifPresent(curiosInventory -> { | ||
// code here - with access to the inventory instance that now definitely exists | ||
}); | ||
``` | ||
|
||
Once a developer has the `ICuriosItemHandler` instance, they can use the methods from that instance to interact with the | ||
Curios inventory. | ||
|
||
## Accessing the inventory | ||
--- | ||
|
||
As mentioned previously, each slot type assigned to an entity is given a sub-inventory in the Curios inventory to | ||
provide easy and categorical access. There are two main ways to interact with these slot inventories, depending on | ||
whether the developer wants to access all of the slot inventories or just a particular one. | ||
|
||
### Accessing the entire inventory | ||
|
||
The entire Curios inventory exists as a `Map<String, ICurioStackHandler>`, with the slot type identifiers acting as each | ||
key and the `ICurioStackHandler` acting as the inventory attached to the slot type. To access this, the `getCurios` | ||
method can be used: | ||
|
||
```java | ||
Map<String, ICurioStackHandler> curios = curiosInventory.getCurios(); | ||
``` | ||
:::caution | ||
This returns an **unmodifiable** map so attempts to change the structure of the map directly through this method, such | ||
as adding or removing slot inventories, will not work. Any changes to the structure needs to be done through other | ||
methods, this method is primarily for accessing the list of slot inventories on the entity. | ||
::: | ||
|
||
From here, developers can either iterate through the entire map: | ||
|
||
```java | ||
curios.forEach((identifier, slotInventory) -> { | ||
// code here - with the identifier and slot inventory access | ||
}) | ||
``` | ||
|
||
Or developers can access a particular sub-inventory, such as a slot type with the `"ring"` identifier: | ||
|
||
```java | ||
ICurioStackHandler slotInventory = curios.get("ring"); | ||
|
||
// null check to ensure that the slot inventory exists | ||
if (slotInventory != null) { | ||
// code here | ||
} | ||
``` | ||
|
||
However, if all a developer wants is to access a particular sub-inventory, there's a more straightforward method | ||
outlined in the next section that can be used instead. | ||
|
||
### Accessing an inventory for a slot type | ||
|
||
In order to access a particular inventory for slot type, developers can either access the whole inventory as outlined | ||
in the preceding section or skip straight to a sub-inventory for that slot type: | ||
|
||
```java | ||
Optional<ICurioStackHandler> slotInventory = curiosInventory.getStacksHandler("ring"); | ||
``` | ||
|
||
The above code will retrive an `Optional` for the slot inventory with the `"ring"` identifier passed into the | ||
parameter. This is an `Optional` because the slot inventory being queried may not exist on the entity, which is a | ||
possibility that developers must consider because higher-priority datapacks are capable of removing slot types from | ||
entities. For that reason, be sure to use `ifPresent` before accessing the inventory: | ||
|
||
```java | ||
curiosInventory.getStacksHandler("ring").ifPresent(slotInventory -> { | ||
// code here - with access to the slot inventory with the "ring" identifier | ||
}); | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.