generated from natanfudge/fabric-example-mod-kotlin
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
75 lines (67 loc) · 3.1 KB
/
script.js
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
// priority: 0
/******************************************************************************
* Here we have prepared a sample script for you.
*
* As an example we add a seed,
* which drops cobblestone when harvested.
* Then we add a potato whose plant drops itself when
* harvested and is edible.
*
* If something is still unclear, just write us an issue on GitHub.
*****************************************************************************/
// The first thing we do is check if our mod is loaded. You can
// also leave that out if you want.
if (mod.isLoaded('owncrops')) {
// This waits for the crop register event.
// In these, all crops and foods are later described and registered.
events.listen('owncrops.crop.registry', event => {
// This creates a new item called "dark_seed"
// the asset loader looks for "dark_seed.png" in
// "*INSTANCEFOLDER*/kubejs/assets/owncrops/textures/item/"
// All things are defined via builders. However, a final command is not
// necessary. All builders will be executed automatically after the
// script is finished.
event.create('dark_seed')
// ".plantable(<dropOnMature>)"
// This makes "dark_seed" as a new crop, which also
// drops cobblestone, when fully grown
.plantable('minecraft:cobblestone')
// ".addGrowthStage(<plantHeight>)" adds a new growthstage to the
// crop which has a height of plantHeight bits.
// A block consists of 16x16x16 bits.
// A crop needs to be "plantable" to obtain growthstages
.addGrowthStage(2)
// so this crop has 2 growthstages in total.
// Textures a named "dark_seed_X.png", where X is the stage
// witch starts with 0
.addGrowthStage(16);
// There could be problems with more than 8 growthstages.
// This has not been tested yet.
// The textures are located at
// "*INSTANCEFOLDER*/kubejs/assets/owncrops/textures/block/"
// Now our first plant is ready.
// Next we want to add a potato. This consists of only one item.
// This can be planted as well as eaten.
// This creates a new item called "dark_potato"
event.create('dark_potato')
// This makes "dark_potato" a new crop, which only drops
// itself, when harvested. If you do not specify a parameter,
// the crop drops itself as the end product.
.plantable()
// ".edible(<hunger>, <saturation>)" turns "dark_potato" into a
// food source with 2 hunger regeneration and 3 saturation
.edible(2,3)
// This time the crop has 4 growthstages
.addGrowthStage(2)
.addGrowthStage(4)
.addGrowthStage(6)
.addGrowthStage(8)
// Now, this allows the fully grown crop to be
// harvested by right-clicking it.
// For compatibility reasons, you must specify this separately.
// If you omit this, then you have to break the plant like in vanilla.
.harvestOnUse();
// Now we can close the function block with '}' and
// the event.listen function with ')'.
});
} // close if (mod.isLoaded('owncrops'))