-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathplugin-docs.html
More file actions
1245 lines (1028 loc) · 38.4 KB
/
Copy pathplugin-docs.html
File metadata and controls
1245 lines (1028 loc) · 38.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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DeathClient JS Plugin API Documentation</title>
<style>
:root{
--bg:#0d0d0d;--bg2:#141414;--bg3:#1a1a1a;--bg4:#202020;
--border:#2a2a2a;--red:#cc0000;--green:#00cc66;--blue:#3399ff;
--yellow:#ffcc00;--purple:#aa66ff;--cyan:#00cccc;--orange:#ff9933;
--text:#e0e0e0;--text2:#bdbdbd;--muted:#777;--code-bg:#101010;
}
*{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
body{
background:var(--bg);color:var(--text);
font-family:'Segoe UI',system-ui,sans-serif;
font-size:15px;line-height:1.65;
}
.shell{display:flex;min-height:100vh}
nav{
width:270px;background:var(--bg2);border-right:1px solid var(--border);
padding:20px;position:fixed;height:100vh;overflow-y:auto;z-index:10;
}
nav h1{font-size:19px;margin-bottom:4px;color:var(--red)}
nav .nav-version{color:var(--muted);font-size:11px;margin-bottom:20px}
nav a{display:block;color:var(--muted);text-decoration:none;padding:6px 0;font-size:13px}
nav a:hover,nav a.active{color:var(--text)}
nav ul{list-style:none;margin-bottom:15px;padding-left:10px;border-left:2px solid var(--border)}
nav .section-title{
color:var(--text2);font-size:11px;text-transform:uppercase;
letter-spacing:.08em;margin:16px 0 6px;
}
main{flex:1;margin-left:270px;padding:40px;max-width:1120px}
h2{
font-size:25px;margin:46px 0 15px;border-bottom:1px solid var(--border);
padding-bottom:9px;color:var(--blue);scroll-margin-top:20px;
}
h2:first-child{margin-top:0}
h3{font-size:18px;margin:26px 0 10px;color:var(--text);scroll-margin-top:20px}
h4{font-size:15px;margin:20px 0 8px;color:var(--text2)}
p{margin-bottom:15px}
ul,ol{margin:0 0 18px 22px}
li{margin-bottom:6px}
code{
background:var(--code-bg);padding:2px 6px;border-radius:4px;
font-family:Consolas,monospace;font-size:13px;color:var(--cyan);
}
pre{
background:var(--bg3);padding:16px;border-radius:7px;
border:1px solid var(--border);overflow-x:auto;margin-bottom:20px;
line-height:1.55;
}
pre code{background:transparent;padding:0;color:#cdd6f4}
table{width:100%;border-collapse:collapse;margin-bottom:22px}
th,td{text-align:left;vertical-align:top;padding:10px;border-bottom:1px solid var(--border)}
th{color:var(--blue);font-weight:600}
td:first-child{white-space:nowrap}
.badge{
display:inline-block;font-size:10px;font-weight:700;padding:2px 6px;
border-radius:999px;margin-left:6px;vertical-align:middle;
}
.badge-core{background:rgba(51,153,255,.15);color:var(--blue)}
.badge-new{background:rgba(0,204,102,.15);color:var(--green)}
.badge-advanced{background:rgba(170,102,255,.15);color:var(--purple)}
.badge-warn{background:rgba(255,204,0,.15);color:var(--yellow)}
.callout{padding:15px 16px;margin-bottom:20px;border-radius:0 6px 6px 0}
.callout-tip{background:rgba(0,204,102,.09);border-left:4px solid var(--green)}
.callout-warning{background:rgba(255,204,0,.09);border-left:4px solid var(--yellow)}
.callout-info{background:rgba(51,153,255,.09);border-left:4px solid var(--blue)}
.callout-danger{background:rgba(204,0,0,.10);border-left:4px solid var(--red)}
.hero{
background:linear-gradient(135deg,rgba(204,0,0,.13),rgba(51,153,255,.05));
border:1px solid var(--border);border-radius:10px;padding:22px;margin-bottom:25px;
}
.hero h3{margin-top:0}
.two-col{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:15px;margin-bottom:20px}
.two-col>div{background:var(--bg2);border:1px solid var(--border);border-radius:7px;padding:14px}
.two-col h4{margin-top:0}
.muted{color:var(--muted)}
.good{color:var(--green)}
.bad{color:#ff6666}
.accent{color:var(--cyan)}
.api-card{background:var(--bg2);border:1px solid var(--border);border-radius:8px;padding:15px;margin-bottom:15px}
.api-card h4{margin-top:0;color:var(--cyan)}
.mini-code{
background:var(--bg4);border:1px solid var(--border);border-radius:6px;
padding:10px 12px;margin:9px 0 12px;font:13px Consolas,monospace;
overflow-x:auto;white-space:pre;
}
.footer{color:var(--muted);font-size:12px;border-top:1px solid var(--border);padding-top:18px;margin-top:50px}
@media(max-width:850px){
nav{display:none} main{margin-left:0;padding:22px}
.two-col{grid-template-columns:1fr}
}
</style>
</head>
<body>
<div class="shell">
<nav>
<h1>DeathClient JS</h1>
<div class="nav-version">Plugin API 3.0 · EaglerCraft 1.8</div>
<div class="section-title">Learn</div>
<a href="#getting-started">Getting Started</a>
<a href="#javascript-basics">JavaScript Basics</a>
<a href="#plugin-structure">Plugin Structure</a>
<div class="section-title">Build</div>
<a href="#mods">Mods</a>
<a href="#settings">Settings</a>
<a href="#commands">Commands</a>
<a href="#callbacks">Callbacks</a>
<a href="#hud">HUD Mods</a>
<div class="section-title">API</div>
<a href="#chat">Chat</a>
<a href="#mod-control">Mod Control</a>
<a href="#player-world">Player & World</a>
<a href="#events">Events</a>
<a href="#storage">Storage</a>
<a href="#resources">Resources</a>
<a href="#timers">Timers</a>
<a href="#audio">Audio & Titles</a>
<a href="#debug">Debug</a>
<div class="section-title">Advanced</div>
<a href="#models">Runtime Models</a>
<a href="#entities">Runtime Entities</a>
<a href="#textures">Runtime Textures</a>
<a href="#items">Runtime Items</a>
<div class="section-title">Examples</div>
<a href="#examples">Working Examples</a>
<a href="#troubleshooting">Troubleshooting</a>
</nav>
<main>
<h2 id="getting-started">Getting Started</h2>
<div class="hero">
<h3>What is a DeathClient JavaScript plugin?</h3>
<p>
A DeathClient plugin is a <code>.js</code> file executed by DeathClient's
built-in JavaScript runtime. Plugins can register mods, settings, local
commands, HUD modules, event handlers, runtime models, client-side entities,
runtime items, textures, storage, timers, sounds, and player/world actions.
</p>
<p>
The JavaScript API is exposed as <code>window.DeathClient</code>.
The current bridge identifies itself as JavaScript bridge version
<code>1.5.0</code> and API version <code>3.0.0</code>.
</p>
</div>
<div class="callout callout-info">
<strong>Important:</strong> This reference documents the API exposed by the current
DeathClient bridge. It intentionally does not document older methods that are not
present in the current bridge, such as <code>dc.getAllMods()</code>,
<code>dc.pickResource()</code>, remote resource fetch helpers, or
<code>dc.storage.clear()</code>.
</div>
<h3>Your first plugin</h3>
<pre><code>const dc = window.DeathClient;
dc.createMod({
name: "Hello World",
displayName: "Hello World",
description: "My first DeathClient plugin",
category: "PLAYER",
isCheat: false,
onEnable: function() {
dc.chat("§aHello from my plugin!");
},
onUpdate: function() {
// Called by DeathClient's normal mod update path.
}
});</code></pre>
<h3>Basic plugin workflow</h3>
<ol>
<li>Get the API with <code>const dc = window.DeathClient;</code>.</li>
<li>Register one or more mods with <code>dc.createMod()</code>.</li>
<li>Add settings, callbacks, commands, or other APIs as needed.</li>
<li>Use client-side APIs such as <code>dc.chat()</code>, <code>dc.player</code>,
<code>dc.storage</code>, and the advanced runtime systems.</li>
</ol>
<h2 id="javascript-basics">JavaScript Basics</h2>
<p>Only normal JavaScript is required for the core API.</p>
<h3>Variables</h3>
<pre><code>let coins = 10;
let playerName = "Steve";
let enabled = true;</code></pre>
<h3>Conditions</h3>
<pre><code>if (dc.player.health < 5) {
dc.chat("§cLow health!");
}</code></pre>
<h3>Functions</h3>
<pre><code>function sayHello(name) {
dc.chat("Hello " + name);
}
sayHello("Steve");</code></pre>
<h3>Loops</h3>
<pre><code>for (let i = 0; i < 5; i++) {
dc.chat("Count: " + i);
}</code></pre>
<h3>Objects</h3>
<pre><code>const config = {
damage: 10,
enabled: true,
mode: "normal"
};
dc.log(config.mode);</code></pre>
<h3>Useful operators</h3>
<table>
<tr><th>Operator</th><th>Example</th><th>Meaning</th></tr>
<tr><td><code>===</code></td><td><code>x === 10</code></td><td>Exactly equal.</td></tr>
<tr><td><code>!==</code></td><td><code>x !== 10</code></td><td>Not equal.</td></tr>
<tr><td><code>></code></td><td><code>x > 10</code></td><td>Greater than.</td></tr>
<tr><td><code><</code></td><td><code>x < 10</code></td><td>Less than.</td></tr>
<tr><td><code>&&</code></td><td><code>a && b</code></td><td>Both conditions must be true.</td></tr>
<tr><td><code>||</code></td><td><code>a || b</code></td><td>At least one condition is true.</td></tr>
<tr><td><code>!</code></td><td><code>!enabled</code></td><td>Invert a boolean.</td></tr>
</table>
<h2 id="plugin-structure">Plugin Structure</h2>
<p>
A single plugin file can contain multiple mods, HUDs, commands, global events,
settings, runtime assets, and helper functions.
</p>
<pre><code>const dc = window.DeathClient;
// Shared state
const state = {
count: 0
};
// Main mod
dc.createMod({
name: "Example",
description: "Example plugin",
category: "PLAYER",
settings: [],
onEnable: function(settings) {},
onDisable: function(settings) {},
onUpdate: function(settings) {},
onChat: function(message) {}
});
// Local command
dc.createCommand({
name: "example",
prefix: ".",
execute: function(args) {}
});</code></pre>
<div class="callout callout-warning">
The current command API uses <code>name</code>, not <code>command</code>,
when passing the object to <code>dc.createCommand()</code>.
</div>
<h2 id="mods">Mod Registration <span class="badge badge-core">CORE</span></h2>
<h3><code>dc.createMod(config)</code></h3>
<table>
<tr><th>Property</th><th>Type</th><th>Description</th></tr>
<tr><td><code>name</code></td><td>String</td><td>Required internal mod name.</td></tr>
<tr><td><code>displayName</code></td><td>String</td><td>Optional GUI display name. Defaults to <code>name</code>.</td></tr>
<tr><td><code>description</code></td><td>String</td><td>Description shown for the mod.</td></tr>
<tr><td><code>category</code></td><td>String</td><td>Common categories include PLAYER, MOVEMENT, COMBAT, RENDER, WORLD, HUD.</td></tr>
<tr><td><code>isCheat</code></td><td>Boolean</td><td>Marks the module as a cheat in the mod system.</td></tr>
<tr><td><code>settings</code></td><td>Array</td><td>Settings created with <code>dc.createSetting()</code>.</td></tr>
<tr><td><code>onEnable</code></td><td>Function</td><td>Runs when the Java-side module is enabled.</td></tr>
<tr><td><code>onDisable</code></td><td>Function</td><td>Runs when the Java-side module is disabled.</td></tr>
<tr><td><code>onUpdate</code></td><td>Function</td><td>Called from the Java mod update path.</td></tr>
<tr><td><code>onRender2D</code></td><td>Function</td><td>Called from the 2D rendering path when wired by the client.</td></tr>
<tr><td><code>onChat</code></td><td>Function</td><td>Receives chat text delivered to the JS mod.</td></tr>
</table>
<h3>Example</h3>
<pre><code>dc.createMod({
name: "Welcome",
displayName: "Welcome",
description: "Shows a message when enabled.",
category: "PLAYER",
isCheat: false,
onEnable: function() {
dc.chat("§aWelcome!");
},
onDisable: function() {
dc.chat("§cGoodbye!");
}
});</code></pre>
<h2 id="settings">Settings <span class="badge badge-core">CORE</span></h2>
<p>
Settings are serialized into the mod registration payload and synchronized into
the mod's <code>settingsCache</code>.
</p>
<h3>Toggle / Boolean</h3>
<pre><code>const enabled = dc.createSetting(
"Toggle",
"Enabled",
true
);</code></pre>
<h3>Slider / Number</h3>
<pre><code>const delay = dc.createSetting(
"Slider",
"Delay",
50,
0,
1000,
1
);</code></pre>
<h3>Mode</h3>
<pre><code>const mode = dc.createSetting(
"Mode",
"Mode",
"Normal",
["Normal", "Aggressive", "Passive"]
);</code></pre>
<h3>String</h3>
<pre><code>const message = dc.createSetting(
"String",
"Message",
"Hello!"
);</code></pre>
<h3>Complete example</h3>
<pre><code>dc.createMod({
name: "Message Mod",
settings: [
dc.createSetting("Toggle", "Spam", false),
dc.createSetting("Slider", "Delay", 1000, 100, 5000, 100),
dc.createSetting("Mode", "Style",
"Friendly",
["Friendly", "Funny", "Serious"]
),
dc.createSetting("String", "Message", "Hello!")
],
onUpdate: function(settings) {
if (!settings["Spam"].value) {
return;
}
const delay = settings["Delay"].value;
const style = settings["Style"].value;
const message = settings["Message"].value;
// Plugin logic here.
}
});</code></pre>
<h2 id="commands">Commands <span class="badge badge-new">CURRENT</span></h2>
<p>
DeathClient commands are <strong>local client commands</strong>. They are intercepted
before ordinary chat handling when the typed message begins with the command prefix.
</p>
<h3><code>dc.registerCommand(name, prefix, execute)</code></h3>
<pre><code>dc.registerCommand(
"hello",
".",
function(args) {
dc.chat("§aHello!");
dc.chat("Arguments: §f" + args);
}
);</code></pre>
<h3><code>dc.createCommand(config)</code></h3>
<p>This is the object-style equivalent.</p>
<pre><code>dc.createCommand({
name: "hello",
prefix: ".",
execute: function(args) {
dc.chat("§aHello " + (args || "world"));
}
});</code></pre>
<p>Typing:</p>
<pre><code>.hello test something</code></pre>
<p>passes this string to the callback:</p>
<pre><code>args === "test something"</code></pre>
<h3>Command with multiple arguments</h3>
<pre><code>dc.createCommand({
name: "teleport",
prefix: ".",
execute: function(args) {
const parts = String(args || "").trim().split(/\s+/);
if (parts.length < 3) {
dc.chat("§cUsage: .teleport <x> <y> <z>");
return;
}
const x = Number(parts[0]);
const y = Number(parts[1]);
const z = Number(parts[2]);
if (!Number.isFinite(x) ||
!Number.isFinite(y) ||
!Number.isFinite(z)) {
dc.chat("§cInvalid coordinates.");
return;
}
dc.player.x = x;
dc.player.y = y;
dc.player.z = z;
}
});</code></pre>
<h3>Unregistering the JavaScript callback</h3>
<pre><code>dc.unregisterCommand("hello");</code></pre>
<div class="callout callout-info">
Local command interception is part of the client-side command system. A registered
command uses its prefix exactly as provided, so a command registered with
<code>"."</code> responds to <code>.hello</code>.
</div>
<h2 id="callbacks">Callbacks <span class="badge badge-core">CORE</span></h2>
<table>
<tr><th>Callback</th><th>Purpose</th></tr>
<tr><td><code>onEnable(settings)</code></td><td>Runs when the mod is enabled.</td></tr>
<tr><td><code>onDisable(settings)</code></td><td>Runs when the mod is disabled.</td></tr>
<tr><td><code>onUpdate(settings)</code></td><td>Runs from the normal mod update path.</td></tr>
<tr><td><code>onRender2D(settings)</code></td><td>Runs from the 2D render path when used by the client.</td></tr>
<tr><td><code>onChat(message)</code></td><td>Receives incoming chat text.</td></tr>
</table>
<div class="callout callout-warning">
Do not perform expensive work every tick. Avoid large allocations, repeated JSON
parsing, huge entity loops, or unnecessary resource operations in update callbacks.
</div>
<h2 id="hud">HUD Mods <span class="badge badge-core">CORE</span></h2>
<h3><code>dc.createHudMod(config)</code></h3>
<pre><code>dc.createHudMod({
name: "My HUD",
displayName: "My HUD",
description: "A custom HUD element",
category: "HUD",
width: 120,
height: 24,
onRender2D: function() {
// HUD position is exposed through this.x / this.y / this.scale.
}
});</code></pre>
<table>
<tr><th>HUD property</th><th>Description</th></tr>
<tr><td><code>this.x</code></td><td>Current X position.</td></tr>
<tr><td><code>this.y</code></td><td>Current Y position.</td></tr>
<tr><td><code>this.scale</code></td><td>Current HUD scale.</td></tr>
</table>
<div class="callout callout-info">
The bridge synchronizes HUD position and scale between JavaScript and the Java
HUD system. The current bridge does not expose a JavaScript <code>drawString()</code>
helper.
</div>
<h2 id="chat">Chat API <span class="badge badge-core">CORE</span></h2>
<table>
<tr><th>API</th><th>Description</th></tr>
<tr><td><code>dc.chat(message)</code></td><td>Displays local client-side chat text. It is not sent to the server.</td></tr>
<tr><td><code>dc.sendChat(message)</code></td><td>Sends chat text through the normal client send-chat path.</td></tr>
<tr><td><code>dc.sendCommand(command)</code></td><td>Sends a slash command. A leading <code>/</code> is added automatically.</td></tr>
</table>
<pre><code>dc.chat("§aLocal message");
dc.sendChat("hello server");
dc.sendCommand("spawn");
dc.sendCommand("/spawn");</code></pre>
<h2 id="mod-control">Mod Control <span class="badge badge-core">CORE</span></h2>
<table>
<tr><th>API</th><th>Description</th></tr>
<tr><td><code>dc.enableMod(name)</code></td><td>Requests that a mod be enabled.</td></tr>
<tr><td><code>dc.disableMod(name)</code></td><td>Requests that a mod be disabled.</td></tr>
<tr><td><code>dc.toggleMod(name)</code></td><td>Toggles a mod.</td></tr>
<tr><td><code>dc.isEnabled(name)</code></td><td>Reads the JavaScript-side toggle state.</td></tr>
<tr><td><code>dc.getMods()</code></td><td>Returns names from the JavaScript mod registry.</td></tr>
<tr><td><code>dc.getMod(name)</code></td><td>Returns the JavaScript mod object or <code>null</code>.</td></tr>
</table>
<pre><code>dc.createCommand({
name: "flight",
prefix: ".",
execute: function() {
if (dc.isEnabled("Fly")) {
dc.disableMod("Fly");
dc.chat("§cFly disabled.");
} else {
dc.enableMod("Fly");
dc.chat("§aFly enabled.");
}
}
});</code></pre>
<h2 id="player-world">Player & World <span class="badge badge-core">CORE</span></h2>
<h3>Player properties</h3>
<table>
<tr><th>Property</th><th>Read</th><th>Write</th></tr>
<tr><td><code>dc.player.x</code></td><td>Yes</td><td>Yes</td></tr>
<tr><td><code>dc.player.y</code></td><td>Yes</td><td>Yes</td></tr>
<tr><td><code>dc.player.z</code></td><td>Yes</td><td>Yes</td></tr>
<tr><td><code>dc.player.motionX</code></td><td>Yes</td><td>Yes</td></tr>
<tr><td><code>dc.player.motionY</code></td><td>Yes</td><td>Yes</td></tr>
<tr><td><code>dc.player.motionZ</code></td><td>Yes</td><td>Yes</td></tr>
<tr><td><code>dc.player.yaw</code></td><td>Yes</td><td>Yes</td></tr>
<tr><td><code>dc.player.pitch</code></td><td>Yes</td><td>Yes</td></tr>
<tr><td><code>dc.player.name</code></td><td>Yes</td><td>No</td></tr>
<tr><td><code>dc.player.health</code></td><td>Yes</td><td>No</td></tr>
<tr><td><code>dc.player.maxHealth</code></td><td>Yes</td><td>No</td></tr>
<tr><td><code>dc.player.onGround</code></td><td>Yes</td><td>No</td></tr>
</table>
<h3>Jump</h3>
<pre><code>dc.player.jump();</code></pre>
<h3>Movement</h3>
<pre><code>dc.player.motionX = 1.0;
dc.player.motionY = 0.0;
dc.player.motionZ = 0.0;</code></pre>
<h3>Rotation</h3>
<pre><code>dc.player.yaw += 45;
dc.player.pitch = 10;</code></pre>
<h3>World properties</h3>
<table>
<tr><th>Property</th><th>Read</th><th>Write</th></tr>
<tr><td><code>dc.world.time</code></td><td>Yes</td><td>Yes</td></tr>
<tr><td><code>dc.world.raining</code></td><td>Yes</td><td>No</td></tr>
</table>
<pre><code>dc.world.time = 6000;</code></pre>
<div class="callout callout-warning">
Player position and motion writes are client actions. Server-side movement correction,
anti-cheat checks, or rubberbanding can still override them.
</div>
<h2 id="events">Events <span class="badge badge-core">CORE</span></h2>
<h3><code>dc.on(event, callback)</code></h3>
<pre><code>dc.on("chat_receive", function(data) {
dc.chat("Received: " + data.message);
});</code></pre>
<h3><code>dc.off(event, callback)</code></h3>
<pre><code>function handleChat(data) {
dc.log(data.message);
}
dc.on("chat_receive", handleChat);
dc.off("chat_receive", handleChat);</code></pre>
<h3><code>dc.once(event, callback)</code></h3>
<pre><code>dc.once("chat_receive", function(data) {
dc.chat("This callback runs once.");
});</code></pre>
<h3><code>dc.emit(event, data)</code></h3>
<p>
Plugins can emit local JavaScript events to listeners registered through the same
JavaScript event registry.
</p>
<pre><code>dc.on("my_event", function(data) {
dc.log("Value: " + data.value);
});
dc.emit("my_event", {
value: 42
});</code></pre>
<h3>Event names used by the current system</h3>
<table>
<tr><th>Event</th><th>Payload</th><th>Description</th></tr>
<tr><td><code>tick</code></td><td>State object</td><td>Client tick event when emitted by the Java side.</td></tr>
<tr><td><code>chat_receive</code></td><td><code>{ message }</code></td><td>Incoming chat text.</td></tr>
<tr><td><code>mod_enable</code></td><td>Module data</td><td>Module enable event when emitted.</td></tr>
<tr><td><code>mod_disable</code></td><td>Module data</td><td>Module disable event when emitted.</td></tr>
<tr><td>Custom names</td><td>Any value</td><td>Usable entirely within the JavaScript event system.</td></tr>
</table>
<div class="callout callout-info">
Event availability depends on whether the Java client path emits that event.
<code>dc.on()</code>, <code>dc.off()</code>, <code>dc.once()</code>, and
<code>dc.emit()</code> themselves are part of the bridge.
</div>
<h2 id="storage">Persistent Storage <span class="badge badge-core">CORE</span></h2>
<p>
The current bridge exposes browser local-storage persistence under
<code>dc.storage</code>.
</p>
<h3>Save</h3>
<pre><code>dc.storage.set("coins", 250);</code></pre>
<h3>Objects and arrays</h3>
<pre><code>dc.storage.set("settings", {
price: 10,
enabled: true,
modes: ["A", "B", "C"]
});</code></pre>
<h3>Load</h3>
<pre><code>const coins = dc.storage.get("coins", 0);
dc.chat("Coins: " + coins);</code></pre>
<h3>Remove</h3>
<pre><code>dc.storage.remove("coins");</code></pre>
<table>
<tr><th>API</th><th>Purpose</th></tr>
<tr><td><code>dc.storage.get(key, fallback)</code></td><td>Reads JSON data, returning the fallback when absent or invalid.</td></tr>
<tr><td><code>dc.storage.set(key, value)</code></td><td>Serializes and stores a value.</td></tr>
<tr><td><code>dc.storage.remove(key)</code></td><td>Removes a stored key.</td></tr>
</table>
<div class="callout callout-warning">
The current bridge does <strong>not</strong> expose <code>dc.storage.clear()</code>.
Remove keys individually with <code>dc.storage.remove()</code>.
</div>
<h2 id="resources">In-Memory Resources <span class="badge badge-core">CORE</span></h2>
<p>
The current bridge provides an in-memory resource cache. It does not expose the
older remote fetch helpers.
</p>
<table>
<tr><th>API</th><th>Description</th></tr>
<tr><td><code>dc.resources.set(id, value)</code></td><td>Stores a value in the JavaScript resource cache and returns it.</td></tr>
<tr><td><code>dc.resources.get(id)</code></td><td>Returns the cached value or <code>undefined</code>.</td></tr>
<tr><td><code>dc.resources.has(id)</code></td><td>Returns whether the cache contains the ID.</td></tr>
<tr><td><code>dc.resources.remove(id)</code></td><td>Deletes the cached ID.</td></tr>
</table>
<pre><code>dc.resources.set("score", 100);
const score = dc.resources.get("score");
if (dc.resources.has("score")) {
dc.chat("Score: " + score);
}
dc.resources.remove("score");</code></pre>
<div class="callout callout-warning">
The current bridge does not expose <code>fetchText()</code>, <code>fetchJSON()</code>,
<code>fetchBlob()</code>, <code>image()</code>, or <code>pickResource()</code> under
<code>dc.resources</code>.
</div>
<h2 id="timers">Timers <span class="badge badge-core">CORE</span></h2>
<h3>Timeout</h3>
<pre><code>const id = dc.setTimeout(function() {
dc.chat("Two seconds passed.");
}, 2000);
dc.clearTimeout(id);</code></pre>
<h3>Interval</h3>
<pre><code>const id = dc.setInterval(function() {
dc.chat("Repeating...");
}, 1000);
dc.clearInterval(id);</code></pre>
<table>
<tr><th>API</th><th>Description</th></tr>
<tr><td><code>dc.setTimeout(fn, ms)</code></td><td>Runs a function once.</td></tr>
<tr><td><code>dc.clearTimeout(id)</code></td><td>Cancels a timeout.</td></tr>
<tr><td><code>dc.setInterval(fn, ms)</code></td><td>Runs a function repeatedly.</td></tr>
<tr><td><code>dc.clearInterval(id)</code></td><td>Cancels an interval.</td></tr>
</table>
<h2 id="audio">Audio & Titles <span class="badge badge-core">CORE</span></h2>
<h3>Sound</h3>
<pre><code>dc.playSound(
"random.orb",
1.0,
1.0
);</code></pre>
<table>
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td><code>soundName</code></td><td>Sound resource identifier.</td></tr>
<tr><td><code>volume</code></td><td>Volume. Defaults to <code>1</code>.</td></tr>
<tr><td><code>pitch</code></td><td>Pitch. Defaults to <code>1</code>.</td></tr>
</table>
<h3>Title</h3>
<pre><code>dc.showTitle(
"§cWARNING",
"§7Something happened!"
);</code></pre>
<h2 id="debug">Debugging <span class="badge badge-core">CORE</span></h2>
<table>
<tr><th>API</th><th>Description</th></tr>
<tr><td><code>dc.log(message)</code></td><td>Writes a normal console log.</td></tr>
<tr><td><code>dc.warn(message)</code></td><td>Writes a warning console log.</td></tr>
<tr><td><code>dc.error(message)</code></td><td>Writes an error console log.</td></tr>
</table>
<pre><code>dc.log("Plugin started");
dc.warn("Something may be wrong");
dc.error("Something failed");</code></pre>
<h2 id="models">Runtime Models <span class="badge badge-advanced">ADVANCED</span></h2>
<p>
The current bridge exposes runtime model registration through
<code>dc.models.register()</code>. Models are supplied as JSON strings.
</p>
<h3><code>dc.models.register(id, json)</code></h3>
<pre><code>const model = {
texture_size: [64, 32],
elements: [
{
from: [-4, 0, -3],
to: [ 4, 10, 3]
},
{
from: [-3, 10, -3],
to: [ 3, 16, 3]
}
]
};
dc.models.register(
"beast",
JSON.stringify(model)
);</code></pre>
<h3>Alias</h3>
<pre><code>dc.entities.registerModel(
"beast",
JSON.stringify(model)
);</code></pre>
<p>
The alias above forwards to the same model registration queue.
</p>
<h3>Model structure</h3>
<table>
<tr><th>Field</th><th>Description</th></tr>
<tr><td><code>texture_size</code></td><td>Texture width and height.</td></tr>
<tr><td><code>elements</code></td><td>Array of cuboid model elements.</td></tr>
<tr><td><code>from</code></td><td>Minimum corner of the cuboid.</td></tr>
<tr><td><code>to</code></td><td>Maximum corner of the cuboid.</td></tr>
<tr><td><code>faces</code></td><td>Optional per-face texture/UV information supported by the runtime parser.</td></tr>
<tr><td><code>rotation</code></td><td>Optional rotation information for an element.</td></tr>
<tr><td><code>origin</code></td><td>Optional rotation point for a rotated element.</td></tr>
</table>
<div class="callout callout-info">
The runtime model parser is intended for Blockbench-style cuboid model data,
but the exact JSON accepted is determined by the Java runtime model parser.
</div>
<h2 id="entities">Runtime Entities <span class="badge badge-advanced">ADVANCED</span></h2>
<p>
The bridge exposes a runtime entity system built around registered entity
configurations and queued Java-side spawning/removal/query operations.
</p>
<h3><code>dc.entities.create(config)</code></h3>
<p>
The canonical creation API is an alias of <code>dc.entities.register()</code>.
</p>
<pre><code>const e = dc.entities.create({
id: "beast",
displayName: "Death Beast",
width: 1.0,
height: 2.0,
health: 100,
damage: 8,
speed: 0.30,
gravity: true,
ai: true,
model: "beast",
texture: "beast"
});</code></pre>
<h3>Entity configuration</h3>
<table>
<tr><th>Field</th><th>Default</th><th>Description</th></tr>
<tr><td><code>id</code></td><td>Required</td><td>Unique entity identifier within the plugin.</td></tr>
<tr><td><code>displayName</code></td><td><code>id</code></td><td>Display name.</td></tr>
<tr><td><code>width</code></td><td>0.8</td><td>Entity width.</td></tr>
<tr><td><code>height</code></td><td>1.8</td><td>Entity height.</td></tr>
<tr><td><code>health</code></td><td>20</td><td>Maximum/runtime health configuration.</td></tr>
<tr><td><code>damage</code></td><td>2</td><td>Configured damage value.</td></tr>
<tr><td><code>speed</code></td><td>0.2</td><td>Configured movement speed.</td></tr>
<tr><td><code>gravity</code></td><td><code>true</code></td><td>Whether the runtime entity uses gravity.</td></tr>
<tr><td><code>ai</code></td><td><code>true</code></td><td>Whether runtime AI is requested.</td></tr>
<tr><td><code>model</code></td><td><code>id</code></td><td>Runtime model identifier.</td></tr>
<tr><td><code>texture</code></td><td><code>id</code></td><td>Runtime texture identifier.</td></tr>
</table>
<h3>Spawn</h3>
<pre><code>dc.entities.spawn(
e,
dc.player.x + 5,
dc.player.y,
dc.player.z + 5
);</code></pre>
<p>Equivalent method on the returned entity configuration:</p>
<pre><code>e.spawn(
dc.player.x + 5,
dc.player.y,
dc.player.z + 5
);</code></pre>
<h3>Get an entity</h3>
<pre><code>const entity = dc.entities.get(nativeEntityId);
if (entity) {
dc.chat("Found runtime entity.");
}</code></pre>
<h3>Remove an entity</h3>
<pre><code>dc.entities.remove(entity);</code></pre>
<p>or:</p>
<pre><code>dc.entities.remove(nativeEntityId);</code></pre>
<p>An entity configuration also exposes:</p>
<pre><code>e.remove();</code></pre>
<h3>Entity tick callback</h3>
<pre><code>dc.entities.onTick(entity, function(runtimeEntity) {
dc.log("Runtime entity tick");
});</code></pre>
<p>Or through the entity object:</p>
<pre><code>e.onTick(function(runtimeEntity) {
dc.log("Ticking " + runtimeEntity.id);
});</code></pre>
<h3>Nearby entity query</h3>
<pre><code>const nearby = dc.entities.nearby(
dc.player.x,
dc.player.y,
dc.player.z,
16
);</code></pre>
<p>Alias:</p>
<pre><code>const nearby = dc.entities.getNearby(
dc.player.x,
dc.player.y,
dc.player.z,
16
);</code></pre>
<div class="callout callout-warning">
Runtime entity methods are an advanced bridge feature. They depend on the
Java-side queue consumers and runtime entity manager being present in the
client build. The JavaScript methods themselves are exposed by the current
bridge.
</div>
<h2 id="textures">Runtime Textures <span class="badge badge-advanced">ADVANCED</span></h2>
<p>
Runtime textures are loaded from an image URL and converted into ARGB pixel data
for the Java-side runtime texture system.
</p>
<h3><code>dc.entities.registerTexture(id, url, callback)</code></h3>
<pre><code>dc.entities.registerTexture(
"beast",
"https://example.com/beast.png",
function(error, success) {
if (error) {
dc.error(String(error));
return;
}
dc.chat("§aEntity texture submitted.");
}
);</code></pre>
<p>
The browser loads the image asynchronously. The callback is invoked after the
image is successfully decoded or after an image loading error.
</p>
<h3>Requirements</h3>
<ul>
<li>The URL must resolve to an image the browser can load.</li>
<li>The image is read through an HTML canvas.</li>
<li>The final data is queued as width, height, and integer pixel values.</li>
</ul>
<h3>Typical runtime asset sequence</h3>
<pre><code>const model = {
texture_size: [64, 32],
elements: [
{ from: [-4, 0, -3], to: [4, 10, 3] }
]
};
dc.models.register(
"beast",
JSON.stringify(model)
);
dc.entities.registerTexture(
"beast",
"https://example.com/beast.png",
function(error) {
if (error) {
dc.error(error);
return;
}
const entity = dc.entities.create({
id: "beast",
displayName: "Death Beast",
model: "beast",
texture: "beast"
});
dc.entities.spawn(
entity,
dc.player.x + 5,
dc.player.y,
dc.player.z + 5
);
}
);</code></pre>