File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import * as mc from "@minecraft/server" ;
2+
3+ const obj = "feed" ;
4+
5+ if ( ! mc . world . scoreboard . getObjective ( obj ) ) {
6+ mc . world . scoreboard . addObjective ( obj , obj ) ;
7+ }
8+
9+ mc . world . afterEvents . itemStartUse . subscribe ( ( { source, itemStack : item } ) => {
10+ mc . system . run ( ( ) => {
11+ if ( ! ( source instanceof mc . Player ) ) return ;
12+
13+ const stop = mc . world . afterEvents . itemStopUse . subscribe ( ( ) => {
14+ mc . world . afterEvents . itemCompleteUse . unsubscribe ( comp ) ;
15+ mc . world . afterEvents . itemStopUse . unsubscribe ( stop ) ;
16+ return ;
17+ } ) ;
18+
19+ const comp = mc . world . afterEvent . itemCompleteUse . subscribe ( ( ) => {
20+ const add = ( ply , score ) => mc . world . getObjective ( obj ) . addScore ( ply , score ) ;
21+
22+ add ( source , 1 ) ;
23+
24+ mc . world . afterEvents . itemCompleteUse . unsubscribe ( comp ) ;
25+ mc . world . afterEvents . itemStopUse . unsubscribe ( stop ) ;
26+ } ) ;
27+ } ) ;
28+ } ) ;
You can’t perform that action at this time.
0 commit comments