-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathitem.d.ts
More file actions
351 lines (301 loc) · 10.4 KB
/
item.d.ts
File metadata and controls
351 lines (301 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
import type { MtColorSpec } from "./color";
import { MtInvRef } from "./inventory";
import type { AfterUseCallback, MtNodeMetaRef, MtNodeName, MtNodePlacementPrediction, OnDropCallback, OnPlaceCallback, OnUseCallback } from "./node";
import type { MtSoundDefs } from "./sound";
import type { MtVec3 } from "./vector";
/** key = name, value = rating; rating = 1..3*/
export interface MtItemGroups {
[key: string]: number;
wool: number;
fluffy: number;
soil: number;
outerspace: number;
crumbly: number;
bendy: number;
snappy: number;
hard: number;
metal: number;
spikes: number;
armor_head: number;
armor_torso: number;
armor_fire: number;
armor_legs: number;
armor_feet: number;
armor_shield: number;
not_in_creative_inventory: number;
armor_heal: number;
armor_use: number;
flammable: number;
cracky: number;
level: number;
choppy: number;
}
export interface MetaDataRef {
set_string(k: string, v: string): void;
get_string(k: string): string;
set_int(k: string, n: number): void;
get_int(k: string): number;
set_float(k: string, f: number): void;
get_float(k: string): number;
to_table(): undefined|any;
from_table(t: any): void|true;
equals(other: MetaDataRef): boolean;
}
export interface MtItemStackMetaRef extends MetaDataRef {
}
export interface MtItemStack {
get_name(): string;
get_meta(): MtItemStackMetaRef;
name: string;
count: number;
wear: number;
metadata: string;
}
export interface MtItemDef {
description?: string;
groups?: Partial<MtItemGroups>;
inventory_image?: string;
wield_image?: string;
/** An image file containing the palette of a node.
* You can set the currently used color as the
* "palette_index" field of the item stack metadata.
* The palette is always stretched to fit indices
* between 0 and 255, to ensure compatibility with
* "colorfacedir" and "colorwallmounted" nodes.
*/
palette?: string;
/** "0xFFFFFFFF"
* The color of the item. The palette overrides this
*/
color?: MtColorSpec;
/**{x = 1, y = 1, z = 1} */
wield_scale?: MtVec3;
stack_max?: number;
range?: number;
liquids_pointable?: boolean;
tool_capabilities?: MtToolCapabilities;
/**
If nil and item is node, prediction is made automatically
If nil and item is not a node, no prediction is made
If "" and item is anything, no prediction is made
Otherwise should be name of node which the client immediately places
on ground when the player places the item. Server will always update
actual result to client in a short moment.
*/
node_placement_prediction?: MtNodePlacementPrediction;
sound?: Partial<MtSoundDefs>;
/**
* Shall place item and return the leftover itemstack
* The placer may be any ObjectRef or nil.
* default: minetest.item_place
*/
on_place?: OnPlaceCallback;
/**Same as on_place but called when pointing at nothing.
* pointed_thing : always { type = "nothing" }
*/
on_secondary_use?: OnPlaceCallback;
/**Defaults to minetest.item_drop*/
on_drop?: OnDropCallback;
/** default: nil
* Function must return either nil if no item shall be removed from
* inventory, or an itemstack to replace the original itemstack.
* e.g. itemstack:take_item(); return itemstack
* Otherwise, the function is free to do what it wants
*/
on_use?: OnUseCallback;
/**
* default: nil
* If defined, should return an itemstack and will be called instead of
* wearing out the tool. If returns nil, does nothing.
* If after_use doesn't exist, it is the same as:
```ts
function (itemstack: MtItemStack, user: MtPlayer|undefined, node: MtNode, digparams: MtDigParams) {
itemstack.add_wear(digparams.wear);
return itemstack;
}
```
*/
after_use?: AfterUseCallback;
/**
* Add your own custom fields. By convention, all custom field names
* should start with `_` to avoid naming collisions with future engine
* usage
*/
[_custom_field: string]: any;
}
export interface MtGroupCapability {
times: Array<number>;
uses: number;
maxlevel: number;
}
export interface MtGroupCapabilities {
[key: string]: MtGroupCapability;
choppy: MtGroupCapability;
}
export interface MtGroupDamages {
[groupname: string]: number;
}
export interface MtToolCapabilities {
full_punch_interval: number;// = 1.0,
max_drop_level: number; // = 0,
groupcaps: Partial<MtGroupCapabilities>;
damage_groups: MtGroupDamages; // = {groupname = damage},
}
export type MtItemName = string;
export interface CraftRecipeCommon<T extends keyof CraftRecipeTypeMap> {
type: T;
output: MtItemName;
/**
* optional list of item pairs,
* replace one input item with another item on crafting
*/
replacements?: CraftConfigReplacements;
}
export type CraftConfigReplacements = Array<string>;
export interface CraftRecipeShaped extends CraftRecipeCommon<"shaped"> {
// type: "shaped";
/**
* Also groups; e.g. 'group:crumbly'
```ts
[
['default:cobble', 'default:cobble', 'default:cobble'],
['', 'default:stick', '' ],
['', 'default:stick', '' ]
]
```
}
*/
recipe: Array<Array<string>>;
}
export interface CraftRecipeShapeless extends CraftRecipeCommon<"shapeless"> {
// type: "shapeless";
recipe: Array<string>;
}
export interface CraftRecipeToolRepair extends CraftRecipeCommon<"toolrepair"> {
// type: "toolrepair";
/**-0.02*/
additional_wear: number;
}
export interface CraftRecipeCooking extends CraftRecipeCommon<"cooking"> {
// type: "cooking";
recipe: MtItemName;
cooktime: number;
}
export interface CraftRecipeFurnaceFuel extends CraftRecipeCommon<"fuel"> {
// type: "fuel";
recipe: MtItemName;
/**seconds*/
burntime: number;
}
export interface CraftRecipeTypeMap {
shapeless: CraftRecipeShapeless;
cooking: CraftRecipeCooking;
fuel: CraftRecipeFurnaceFuel;
shaped: CraftRecipeShaped;
toolrepair: CraftRecipeToolRepair;
}
/**
* ## scatter
* Randomly chooses a location and generates a cluster of ore.
* If noise_params is specified, the ore will be placed if the 3D perlin noise at that point is greater than the noise_threshold, giving the ability to create a non-equal distribution of ore.
*
* ## sheet
* Creates a sheet of ore in a blob shape according to the 2D perlin noise
* described by noise_params and noise_threshold.
* This is essentially an improved version of the so-called "stratus" ore seen in some unofficial mods.
* This sheet consists of vertical columns of uniform randomly distributed height,
* varying between the inclusive range column_height_min and column_height_max.
* If column_height_min is not specified, this parameter defaults to 1.
* If column_height_max is not specified, this parameter defaults to clust_size for reverse compatibility.
* New code should prefer column_height_max.
* The column_midpoint_factor parameter controls the position of the column at which ore eminates from.
* If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow equally starting from each direction.
* column_midpoint_factor is a decimal number ranging in value from 0 to 1.
* If this parameter is not specified, the default is 0.5.
* The ore parameters clust_scarcity and clust_num_ores are ignored for this ore type.
*
* ## puff
* Creates a sheet of ore in a cloud-like puff shape
* As with the sheet ore type, the size and shape of puffs are
* described by noise_params and noise_threshold and
* are placed at random vertical positions within the currently generated chunk
* The vertical top and bottom displacement of each puff are
* determined by the noise parameters np_puff_top and np_puff_bottom, respectively.
*
* ## blob
* Creates a deformed sphere of ore according to 3d perlin noise described by noise_params.
* The maximum size of the blob is clust_size, and clust_scarcity has the same meaning as with the scatter type.
*
* ## vein
* Creates veins of ore varying in density by according to the intersection
* of two instances of 3d perlin noise with diffferent seeds,
* both described by noise_params. random_factor varies the influence
* random chance has on placement of an ore inside the vein, which is 1 by default.
*
* Note that modifying this parameter may require adjusting noise_threshold.
* The parameters clust_scarcity, clust_num_ores, and clust_size are ignored by this ore type.
* This ore type is difficult to control since it is sensitive to small changes.
* The following is a decent set of parameters to work from:
* ### WARNING: Use this ore type very sparingly since it is ~200x more computationally expensive than any other ore
*/
export type OreType = "scatter" | "sheet" | "puff" | "blob" | "vein";
export interface OreNoiseParams {
offset: number;
scale: number;
spread: MtVec3;
seed: number;
octaves: number;
persist: number;
}
export interface MtOreDef {
ore_type: OreType;
/**`default:stone_with_coal`*/
ore: MtItemName;
/**`default:stone`
* a list of nodenames is supported too
*/
wherein: MtNodeName | Array<MtNodeName>;
/**8 * 8 * 8
* Ore has a 1 out of clust_scarcity chance of spawning in a node
* This value should be * MUCH * higher than your intuition might tell you!
*/
clust_scarcity: number;
/**
* 8
* Number of ores in a cluster
*/
clust_num_ores: number;
/**Size of the bounding box of the cluster
* In this example, there is a 3x3x3 cluster where 8 out of the 27 nodes are coal ore
*/
clust_size: number;
/**
* -31000
*/
y_min: number;
/**64*/
y_max: number;
/**Attributes for this ore generation*/
flags: string;
/**0.5
* If noise is above this threshold, ore is placed.Not needed for a uniform distribution
*/
noise_threshold: number;
/**
* NoiseParams structure describing the perlin noise used for ore distribution.
* Needed for sheet ore_type.Omit from scatter ore_type for a uniform ore distribution
*/
noise_params: OreNoiseParams;
/**
* Multiplier of the randomness contribution to the noise value at any
* given point to decide if ore should be placed.Set to 0 for solid veins
* This parameter is only valid for ore_type == "vein"
*/
random_factor: number;
/**
* List of biomes in which this decoration occurs.Occurs in all biomes if this is omitted,
* and ignored if the Mapgen being used does not support biomes.
* can be a list of(or a single) biome names, IDs, or definitions
*/
biomes: Array<string>;
}