Constructor
new ThingStorage(size, stackSizeMultiplier, blacklist)
定义一个物品储存空间
| Name | Type | Default | Description |
|---|---|---|---|
size | number | 储存容量,决定了该储存空间能储存多少组物品 | |
stackSizeMultiplier | number | 1 | 堆叠数量倍率。默认为1 |
blacklist | Array.<ItemSelectorString> | 黑名单,在黑名单内的物品不能放入该储存空间 |
- Source
Members
size :number
储存容量,决定了该储存空间能储存多少组物品
- number
- Source
stackSizeMultiplier :number
堆叠数量倍率。默认为1
- number
- Source
blacklist :Array.<ItemSelectorString>
黑名单,在黑名单内的物品不能放入该储存空间
- Array.<ItemSelectorString>
- Source
thingStorage :Array.<Tartan>
物品实际储存空间
- Array.<Tartan>
- Source
size :number
储存容量,决定了该储存空间能储存多少组物品
- number
- Source
stackSizeMultiplier :number
堆叠数量倍率。默认为1
- number
- Source
blacklist :Array.<ItemSelectorString>
黑名单,在黑名单内的物品不能放入该储存空间
- Array.<ItemSelectorString>
- Source
thingStorage :Array.<Tartan>
物品实际储存空间
- Array.<Tartan>
- Source
Methods
putTo(source, index) → (nullable) {Thing}
向该物品储存空间的指定位置放入物品
| Name | Type | Description |
|---|---|---|
source | Tartan | 要放入的物品 |
index | number | 放入物品的位置 |
- Source
剩余的物品。如果没有剩余物品,返回null
- Type:
- Thing
putInto(…sourcenullable) → {Array.<Thing>}
向该物品储存空间中放入一个(或一些)物品
| Name | Type | Attributes | Description |
|---|---|---|---|
source | Thing | <nullable> <repeatable> | 要放入的物品 |
- Source
剩余的物品
- Type:
- Array.<Thing>
takeOut(index, quantity) → (nullable) {Thing}
从该物品储存空间中拿取物品
| Name | Type | Default | Description |
|---|---|---|---|
index | number | 拿取物品的位置 | |
quantity | number | 1 | 拿取数量 |
- Source
成功拿取的物品
- Type:
- Thing
collation()
整理该物品储存空间
同时清除数量小于0的物品
- Source
includes(selector) → {boolean}
检查物品是否在该物品储存空间中
会忽略null和数量小于0的物品
| Name | Type | Description |
|---|---|---|
selector | ItemSelectorString | 一个物品选择器 |
- Source
- Type:
- boolean
querySelector(selector) → {number}
搜索满足条件的第一个物品的位置
如果没有搜索到,返回-1
会忽略null和数量小于0的物品
| Name | Type | Description |
|---|---|---|
selector | ItemSelectorString | 一个物品选择器 |
- Source
- Type:
- number
querySelectorAll(selector) → {Array.<number>}
搜索满足条件的所有物品的位置,返回一个列表
会忽略null和数量小于0的物品
| Name | Type | Description |
|---|---|---|
selector | ItemSelectorString | 一个物品选择器 |
- Source
- Type:
- Array.<number>
forEach(callbackfn)
对该物品储存空间中的每个物品调用给定的函数
会忽略null
| Name | Type | Description |
|---|---|---|
callbackfn | thingStorageForEachCallback | 回调函数 |
- Source
(async) dialog(entity, title, content, filter, otherOptions) → {number|null}
为指定玩家打开该物品储存空间的对话框
| Name | Type | Default | Description |
|---|---|---|---|
entity | Box3PlayerEntity | 打开对话框的实体 | |
title | string | 对话框的标题 | |
content | string | 对话框的正文 | |
filter | ItemSelectorString | !null | 用来筛选的选择器,默认为 |
otherOptions | object | 对话框的其他选项 |
- Source
玩家选择的物品在该物品储存空间的位置。没有选择,返回null
- Type:
- number |
null
toString() → {string}
将物品储存空间转换成字符串
空物品和数量小于0的物品会被忽略
- Source
转换结果
- Type:
- string
(static) fromString(str, size, stackSizeMultiplier)
从字符串中读取物品储存空间
| Name | Type | Default | Description |
|---|---|---|---|
str | string | 要读取的字符串 | |
size | number | 储存空间大小。如果存储空间不能放下,则剩余的数据会被舍弃 | |
stackSizeMultiplier | number | 1 | 堆叠数量倍率。默认为1 |
- Source
putTo(source, index) → (nullable) {Thing}
向该物品储存空间的指定位置放入物品
| Name | Type | Description |
|---|---|---|
source | Tartan | 要放入的物品 |
index | number | 放入物品的位置 |
- Source
剩余的物品。如果没有剩余物品,返回null
- Type:
- Thing
putInto(…sourcenullable) → {Array.<Thing>}
向该物品储存空间中放入一个(或一些)物品
| Name | Type | Attributes | Description |
|---|---|---|---|
source | Thing | <nullable> <repeatable> | 要放入的物品 |
- Source
剩余的物品
- Type:
- Array.<Thing>
takeOut(index, quantity) → (nullable) {Thing}
从该物品储存空间中拿取物品
| Name | Type | Default | Description |
|---|---|---|---|
index | number | 拿取物品的位置 | |
quantity | number | 1 | 拿取数量 |
- Source
成功拿取的物品
- Type:
- Thing
collation()
整理该物品储存空间
同时清除数量小于0的物品
- Source
includes(selector) → {boolean}
检查物品是否在该物品储存空间中
会忽略null和数量小于0的物品
| Name | Type | Description |
|---|---|---|
selector | ItemSelectorString | 一个物品选择器 |
- Source
- Type:
- boolean
querySelector(selector) → {number}
搜索满足条件的第一个物品的位置
如果没有搜索到,返回-1
会忽略null和数量小于0的物品
| Name | Type | Description |
|---|---|---|
selector | ItemSelectorString | 一个物品选择器 |
- Source
- Type:
- number
querySelectorAll(selector) → {Array.<number>}
搜索满足条件的所有物品的位置,返回一个列表
会忽略null和数量小于0的物品
| Name | Type | Description |
|---|---|---|
selector | ItemSelectorString | 一个物品选择器 |
- Source
- Type:
- Array.<number>
forEach(callbackfn)
对该物品储存空间中的每个物品调用给定的函数
会忽略null
| Name | Type | Description |
|---|---|---|
callbackfn | thingStorageForEachCallback | 回调函数 |
- Source
(async) dialog(entity, title, content, filter, otherOptions) → {number|null}
为指定玩家打开该物品储存空间的对话框
| Name | Type | Default | Description |
|---|---|---|---|
entity | Box3PlayerEntity | 打开对话框的实体 | |
title | string | 对话框的标题 | |
content | string | 对话框的正文 | |
filter | ItemSelectorString | !null | 用来筛选的选择器,默认为 |
otherOptions | object | 对话框的其他选项 |
- Source
玩家选择的物品在该物品储存空间的位置。没有选择,返回null
- Type:
- number |
null
toString() → {string}
将物品储存空间转换成字符串
空物品和数量小于0的物品会被忽略
- Source
转换结果
- Type:
- string
(static) fromString(str, size, stackSizeMultiplier)
从字符串中读取物品储存空间
| Name | Type | Default | Description |
|---|---|---|---|
str | string | 要读取的字符串 | |
size | number | 储存空间大小。如果存储空间不能放下,则剩余的数据会被舍弃 | |
stackSizeMultiplier | number | 1 | 堆叠数量倍率。默认为1 |
- Source