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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Sun, 28 Apr 2024 19:53:06 -0400
Subject: [PATCH] WIP DataComponent API
diff --git a/src/main/java/io/papermc/paper/block/BlockPredicate.java b/src/main/java/io/papermc/paper/block/BlockPredicate.java
new file mode 100644
index 0000000000000000000000000000000000000000..3e4feb334ba3e2b5895b2db4dc29408398f5fa0a
--- /dev/null
+++ b/src/main/java/io/papermc/paper/block/BlockPredicate.java
@@ -0,0 +1,54 @@
+package io.papermc.paper.block;
+
+import io.papermc.paper.registry.set.RegistryKeySet;
+import org.bukkit.block.BlockType;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface BlockPredicate {
+
+ @NotNull
+ static Builder predicate() {
+ record BlockPredicateImpl(@Nullable RegistryKeySet<@NotNull BlockType> blocks) implements BlockPredicate {
+
+ @Override
+ public @Nullable RegistryKeySet<@NotNull BlockType> blocks() {
+ return this.blocks;
+ }
+ }
+
+ class BuilderImpl implements Builder {
+
+ private @Nullable RegistryKeySet<@NotNull BlockType> blocks;
+
+ @Override
+ public @NotNull Builder blocks(@Nullable final RegistryKeySet<@NotNull BlockType> blocks) {
+ this.blocks = blocks;
+ return this;
+ }
+
+ @Override
+ public @NotNull BlockPredicate build() {
+ return new BlockPredicateImpl(this.blocks);
+ }
+ }
+
+ return new BuilderImpl();
+ }
+
+ @Nullable RegistryKeySet<@NotNull BlockType> blocks();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NotNull Builder blocks(@Nullable RegistryKeySet<@NotNull BlockType> blocks);
+
+ @NotNull BlockPredicate build();
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/DataComponentBuilder.java b/src/main/java/io/papermc/paper/datacomponent/DataComponentBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..e56c3b74bc22c382e7cf987e95c2f8e6bbe5611b
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/DataComponentBuilder.java
@@ -0,0 +1,23 @@
+package io.papermc.paper.datacomponent;
+
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+/**
+ * Base builder type for all component builders.
+ *
+ * @param <C> built component type
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface DataComponentBuilder<C> {
+
+ /**
+ * Builds the immutable component value.
+ *
+ * @return a new component value
+ */
+ @Contract(value = "-> new", pure = true)
+ @NonNull C build();
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/DataComponentType.java b/src/main/java/io/papermc/paper/datacomponent/DataComponentType.java
new file mode 100644
index 0000000000000000000000000000000000000000..3a0bca9f95d6f1ad2e160620bb47f7023cb40e3d
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/DataComponentType.java
@@ -0,0 +1,28 @@
+package io.papermc.paper.datacomponent;
+
+import org.bukkit.Keyed;
+import org.jetbrains.annotations.ApiStatus;
+
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface DataComponentType extends Keyed {
+
+ /**
+ * Checks if this data component type is persistent, or
+ * that it will be saved with any itemstack it's attached to.
+ *
+ * @return {@code true} if persistent, {@code false} otherwise
+ */
+ boolean isPersistent();
+
+ @SuppressWarnings("unused")
+ @ApiStatus.NonExtendable
+ interface Valued<T> extends DataComponentType {
+
+ }
+
+ @ApiStatus.NonExtendable
+ interface NonValued extends DataComponentType {
+
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java b/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java
new file mode 100644
index 0000000000000000000000000000000000000000..c3f53e5afe92c39dfce7075153d419f1b03020ac
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java
@@ -0,0 +1,321 @@
+package io.papermc.paper.datacomponent;
+
+import io.papermc.paper.datacomponent.item.BannerPatternLayers;
+import io.papermc.paper.datacomponent.item.BlockItemDataProperties;
+import io.papermc.paper.datacomponent.item.BundleContents;
+import io.papermc.paper.datacomponent.item.ChargedProjectiles;
+import io.papermc.paper.datacomponent.item.DyedItemColor;
+import io.papermc.paper.datacomponent.item.Fireworks;
+import io.papermc.paper.datacomponent.item.FoodProperties;
+import io.papermc.paper.datacomponent.item.ItemAdventurePredicate;
+import io.papermc.paper.datacomponent.item.ItemArmorTrim;
+import io.papermc.paper.datacomponent.item.ItemAttributeModifiers;
+import io.papermc.paper.datacomponent.item.ItemContainerContents;
+import io.papermc.paper.datacomponent.item.ItemEnchantments;
+import io.papermc.paper.datacomponent.item.ItemLore;
+import io.papermc.paper.datacomponent.item.JukeboxPlayable;
+import io.papermc.paper.datacomponent.item.LodestoneTracker;
+import io.papermc.paper.datacomponent.item.MapDecorations;
+import io.papermc.paper.datacomponent.item.MapItemColor;
+import io.papermc.paper.item.MapPostProcessing;
+import io.papermc.paper.datacomponent.item.PotDecorations;
+import io.papermc.paper.datacomponent.item.PotionContents;
+import io.papermc.paper.datacomponent.item.ResolvableProfile;
+import io.papermc.paper.datacomponent.item.SeededContainerLoot;
+import io.papermc.paper.datacomponent.item.SuspiciousStewEffects;
+import io.papermc.paper.datacomponent.item.Tool;
+import io.papermc.paper.datacomponent.item.Unbreakable;
+import io.papermc.paper.datacomponent.item.WritableBookContent;
+import io.papermc.paper.datacomponent.item.WrittenBookContent;
+import java.util.List;
+import net.kyori.adventure.key.Key;
+import net.kyori.adventure.text.Component;
+import org.bukkit.DyeColor;
+import org.bukkit.FireworkEffect;
+import org.bukkit.MusicInstrument;
+import org.bukkit.NamespacedKey;
+import org.bukkit.Registry;
+import org.bukkit.inventory.ItemRarity;
+import org.checkerframework.checker.index.qual.NonNegative;
+import org.checkerframework.checker.index.qual.Positive;
+import org.checkerframework.common.value.qual.IntRange;
+import org.jetbrains.annotations.ApiStatus;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * All the different types of data that {@link org.bukkit.inventory.ItemStack ItemStacks}
+ * and {@link org.bukkit.inventory.ItemType ItemTypes} can have.
+ */
+@ApiStatus.Experimental
+public final class DataComponentTypes {
+
+ // public static final DataComponentType.Valued<BinaryTagHolder> CUSTOM_DATA = valued("custom_data");
+ /**
+ * Controls the maximum stacking size of this item.
+ * <br>
+ * Values greater than 1 are mutually exclusive with the {@link #MAX_DAMAGE} component.
+ */
+ public static final DataComponentType.Valued<@IntRange(from = 1, to = 99) Integer> MAX_STACK_SIZE = valued("max_stack_size");
+ /**
+ * Controls the maximum amount of damage than an item can take,
+ * if not present, the item cannot be damaged.
+ * <br>
+ * Mutually exclusive with the {@link #MAX_STACK_SIZE} component greater than 1.
+ *
+ * @see #DAMAGE
+ */
+ public static final DataComponentType.Valued<@Positive Integer> MAX_DAMAGE = valued("max_damage");
+ /**
+ * The amount of durability removed from an item,
+ * for damageable items (with the {@link #MAX_DAMAGE} component), has an implicit default value of: {@code 0}.
+ *
+ * @see #MAX_DAMAGE
+ */
+ public static final DataComponentType.Valued<@NonNegative Integer> DAMAGE = valued("damage");
+ /**
+ * If set, the item will not lose any durability when used.
+ */
+ public static final DataComponentType.Valued<Unbreakable> UNBREAKABLE = valued("unbreakable");
+ /**
+ * Custom name override for an item (as set by renaming with an Anvil).
+ *
+ * @see #ITEM_NAME
+ */
+ public static final DataComponentType.Valued<Component> CUSTOM_NAME = valued("custom_name");
+ /**
+ * When present, replaces default item name with contained chat component.
+ * <p>
+ * Differences from {@link #CUSTOM_NAME}:
+ * <ul>
+ * <li>can't be changed or removed in Anvil</li>
+ * <li>is not styled with italics when displayed to player</li>
+ * <li>does not show labels where applicable
+ * (for example: banner markers, names in item frames)</li>
+ * </ul>
+ *
+ * @see #CUSTOM_NAME
+ */
+ public static final DataComponentType.Valued<Component> ITEM_NAME = valued("item_name");
+ /**
+ * Additional lines to include in an item's tooltip.
+ */
+ public static final DataComponentType.Valued<ItemLore> LORE = valued("lore");
+ /**
+ * Controls the color of the item name.
+ */
+ public static final DataComponentType.Valued<ItemRarity> RARITY = valued("rarity");
+ /**
+ * Controls the enchantments on an item.
+ * <br>
+ * If not present on a non-enchantment book, this item will not work in an anvil.
+ *
+ * @see #STORED_ENCHANTMENTS
+ */
+ public static final DataComponentType.Valued<ItemEnchantments> ENCHANTMENTS = valued("enchantments");
+ /**
+ * Controls which blocks a player in Adventure mode can place on with this item.
+ */
+ public static final DataComponentType.Valued<ItemAdventurePredicate> CAN_PLACE_ON = valued("can_place_on");
+ /**
+ * Controls which blocks a player in Adventure mode can break with this item.
+ */
+ public static final DataComponentType.Valued<ItemAdventurePredicate> CAN_BREAK = valued("can_break");
+ /**
+ * Holds attribute modifiers applied to any item,
+ * if not set, has an implicit default value based on the item type's
+ * default attributes (e.g. attack damage for weapons).
+ */
+ public static final DataComponentType.Valued<ItemAttributeModifiers> ATTRIBUTE_MODIFIERS = valued("attribute_modifiers");
+ /**
+ * Controls the minecraft:custom_model_data property in the item model.
+ */
+ public static final DataComponentType.Valued<Integer> CUSTOM_MODEL_DATA = valued("custom_model_data");
+ /**
+ * If set, disables 'additional' tooltip part which comes from the item type
+ * (e.g. content of a shulker).
+ */
+ public static final DataComponentType.NonValued HIDE_ADDITIONAL_TOOLTIP = unvalued("hide_additional_tooltip");
+ /**
+ * If set, it will completely hide whole item tooltip (that includes item name).
+ */
+ public static final DataComponentType.NonValued HIDE_TOOLTIP = unvalued("hide_tooltip");
+ /**
+ * The additional experience cost required to modify an item in an Anvil.
+ * If not present, has an implicit default value of: {@code 0}.
+ */
+ public static final DataComponentType.Valued<@NonNegative Integer> REPAIR_COST = valued("repair_cost");
+ /**
+ * Causes an item to not be pickable in the creative menu, currently not very useful.
+ */
+ public static final DataComponentType.NonValued CREATIVE_SLOT_LOCK = unvalued("creative_slot_lock");
+ /**
+ * Overrides the enchantment glint effect on an item.
+ * If not present, default behaviour is used.
+ */
+ public static final DataComponentType.Valued<Boolean> ENCHANTMENT_GLINT_OVERRIDE = valued("enchantment_glint_override");
+ /**
+ * Marks that a projectile item would be intangible when fired
+ * (i.e. can only be picked up by a creative mode player).
+ */
+ public static final DataComponentType.NonValued INTANGIBLE_PROJECTILE = unvalued("intangible_projectile");
+ /**
+ * When present, this item will behave as if a food (can be eaten).
+ */
+ public static final DataComponentType.Valued<FoodProperties> FOOD = valued("food");
+ /**
+ * If present, this item will not burn in fire.
+ */
+ public static final DataComponentType.NonValued FIRE_RESISTANT = unvalued("fire_resistant");
+ /**
+ * Controls the behavior of the item as a tool.
+ */
+ public static final DataComponentType.Valued<Tool> TOOL = valued("tool");
+ /**
+ * Stores list of enchantments and their levels for an Enchanted Book.
+ * Unlike {@link #ENCHANTMENTS}, the effects provided by enchantments
+ * do not apply from this component.
+ * <br>
+ * If not present on an Enchanted Book, it will not work in an anvil.
+ * <p>
+ * Has an undefined behaviour if present on an item that is not an Enchanted Book
+ * (currently the presence of this component allows enchantments from {@link #ENCHANTMENTS}
+ * to be applied as if this item was an Enchanted Book).
+ *
+ * @see #ENCHANTMENTS
+ */
+ public static final DataComponentType.Valued<ItemEnchantments> STORED_ENCHANTMENTS = valued("stored_enchantments");
+ /**
+ * Represents a color applied to a dyeable item (in the {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#DYEABLE} item tag).
+ */
+ public static final DataComponentType.Valued<DyedItemColor> DYED_COLOR = valued("dyed_color");
+ /**
+ * Represents the tint of the decorations on the Filled Map item.
+ */
+ public static final DataComponentType.Valued<MapItemColor> MAP_COLOR = valued("map_color");
+ /**
+ * References the shared map state holding map contents and markers for a Filled Map.
+ */
+ public static final DataComponentType.Valued<Integer> MAP_ID = valued("map_id");
+ /**
+ * Holds a list of markers to be placed on a Filled Map (used for Explorer Maps).
+ */
+ public static final DataComponentType.Valued<MapDecorations> MAP_DECORATIONS = valued("map_decorations");
+ /**
+ * Internal map item state used in the map crafting recipe.
+ */
+ public static final DataComponentType.Valued<MapPostProcessing> MAP_POST_PROCESSING = valued("map_post_processing");
+ /**
+ * Holds all projectiles that have been loaded into a Crossbow.
+ * If not present, the Crossbow is not charged.
+ */
+ public static final DataComponentType.Valued<ChargedProjectiles> CHARGED_PROJECTILES = valued("charged_projectiles");
+ /**
+ * Holds all items stored inside a Bundle.
+ * If removed, items cannot be added to the Bundle.
+ */
+ public static final DataComponentType.Valued<BundleContents> BUNDLE_CONTENTS = valued("bundle_contents");
+ /**
+ * Holds the contents of a potion (Potion, Splash Potion, Lingering Potion),
+ * or potion applied to a Tipped Arrow.
+ */
+ public static final DataComponentType.Valued<PotionContents> POTION_CONTENTS = valued("potion_contents");
+ /**
+ * Holds the effects that will be applied when consuming Suspicious Stew.
+ */
+ public static final DataComponentType.Valued<SuspiciousStewEffects> SUSPICIOUS_STEW_EFFECTS = valued("suspicious_stew_effects");
+ /**
+ * Holds the contents in a Book and Quill.
+ */
+ public static final DataComponentType.Valued<WritableBookContent> WRITABLE_BOOK_CONTENT = valued("writable_book_content");
+ /**
+ * Holds the contents and metadata of a Written Book.
+ */
+ public static final DataComponentType.Valued<WrittenBookContent> WRITTEN_BOOK_CONTENT = valued("written_book_content");
+ /**
+ * Holds the trims applied to an item in recipes
+ */
+ public static final DataComponentType.Valued<ItemArmorTrim> TRIM = valued("trim");
+ // debug_stick_state - Block Property API
+ // entity_data
+ // bucket_entity_data
+ // block_entity_data
+ /**
+ * Holds the instrument type used by a Goat Horn.
+ */
+ public static final DataComponentType.Valued<MusicInstrument> INSTRUMENT = valued("instrument");
+ /**
+ * Controls the amplifier amount for an Ominous Bottle's Bad Omen effect.
+ */
+ public static final DataComponentType.Valued<@IntRange(from = 0, to = 4) Integer> OMINOUS_BOTTLE_AMPLIFIER = valued("ominous_bottle_amplifier");
+ /**
+ * List of recipes that should be unlocked when using the Knowledge Book item.
+ */
+ public static final DataComponentType.Valued<JukeboxPlayable> JUKEBOX_PLAYABLE = valued("jukebox_playable");
+ public static final DataComponentType.Valued<List<Key>> RECIPES = valued("recipes");
+ /**
+ * If present, specifies that the Compass is a Lodestone Compass.
+ */
+ public static final DataComponentType.Valued<LodestoneTracker> LODESTONE_TRACKER = valued("lodestone_tracker");
+ /**
+ * Stores the explosion crafted in a Firework Star.
+ */
+ public static final DataComponentType.Valued<FireworkEffect> FIREWORK_EXPLOSION = valued("firework_explosion");
+ /**
+ * Stores all explosions crafted into a Firework Rocket, as well as flight duration.
+ */
+ public static final DataComponentType.Valued<Fireworks> FIREWORKS = valued("fireworks");
+ /**
+ * Controls the skin displayed on a Player Head.
+ */
+ public static final DataComponentType.Valued<ResolvableProfile> PROFILE = valued("profile");
+ /**
+ * Controls the sound played by a Player Head when placed on a Note Block.
+ */
+ public static final DataComponentType.Valued<Key> NOTE_BLOCK_SOUND = valued("note_block_sound");
+ /**
+ * Stores the additional patterns applied to a Banner or Shield.
+ */
+ public static final DataComponentType.Valued<BannerPatternLayers> BANNER_PATTERNS = valued("banner_patterns");
+ /**
+ * Stores the base color for a Shield.
+ */
+ public static final DataComponentType.Valued<DyeColor> BASE_COLOR = valued("base_color");
+ /**
+ * Stores the Sherds applied to each side of a Decorated Pot.
+ */
+ public static final DataComponentType.Valued<PotDecorations> POT_DECORATIONS = valued("pot_decorations");
+ /**
+ * Holds the contents of container blocks (Chests, Shulker Boxes) in item form.
+ */
+ public static final DataComponentType.Valued<ItemContainerContents> CONTAINER = valued("container");
+ /**
+ * Holds block state properties to apply when placing a block.
+ */
+ public static final DataComponentType.Valued<BlockItemDataProperties> BLOCK_DATA = valued("block_state");
+ // bees
+ /**
+ * Holds the lock state of a container-like block,
+ * copied to container block when placed.
+ * <br>
+ * An item with a custom name of the same value must be used
+ * to open this container.
+ */
+ public static final DataComponentType.Valued<String> LOCK = valued("lock");
+ /**
+ * Holds the unresolved loot table and seed of a container-like block.
+ */
+ public static final DataComponentType.Valued<SeededContainerLoot> CONTAINER_LOOT = valued("container_loot");
+
+ private static DataComponentType.NonValued unvalued(final String name) {
+ return (DataComponentType.NonValued) requireNonNull(Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name)), name + " unvalued data component type couldn't be found, this is a bug.");
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T> DataComponentType.Valued<T> valued(final String name) {
+ return (DataComponentType.Valued<T>) requireNonNull(Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name)), name + " valued data component type couldn't be found, this is a bug.");
+ }
+
+ private DataComponentTypes() {
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/BannerPatternLayers.java b/src/main/java/io/papermc/paper/datacomponent/item/BannerPatternLayers.java
new file mode 100644
index 0000000000000000000000000000000000000000..aed2b74e5c88c5afe9b51ff0952b1adc5c230283
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/BannerPatternLayers.java
@@ -0,0 +1,44 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.Arrays;
+import java.util.List;
+import org.bukkit.block.banner.Pattern;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface BannerPatternLayers {
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull BannerPatternLayers bannerPatternLayers(final @NonNull Pattern @NonNull...patterns) {
+ return bannerPatternLayers(Arrays.asList(patterns));
+ }
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull BannerPatternLayers bannerPatternLayers(final @NonNull List<@NonNull Pattern> patterns) {
+ return bannerPatternLayers().addAll(patterns).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static BannerPatternLayers.@NonNull Builder bannerPatternLayers() {
+ return ComponentTypesBridge.bridge().bannerPatternLayers();
+ }
+
+ @Contract(pure = true)
+ @NonNull @Unmodifiable List<Pattern> patterns();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<BannerPatternLayers> {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder add(@NonNull Pattern pattern);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addAll(@NonNull List<@NonNull Pattern> patterns);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/BlockItemDataProperties.java b/src/main/java/io/papermc/paper/datacomponent/item/BlockItemDataProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..d658f4b06abe507bea705525fa4b17da018c46b8
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/BlockItemDataProperties.java
@@ -0,0 +1,31 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import org.bukkit.Material;
+import org.bukkit.block.BlockType;
+import org.bukkit.block.data.BlockData;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface BlockItemDataProperties {
+
+ @Contract(value = "-> new", pure = true)
+ static BlockItemDataProperties.@NonNull Builder blockItemStateProperties() {
+ return ComponentTypesBridge.bridge().blockItemStateProperties();
+ }
+
+ @Contract(pure = true)
+ @NonNull BlockData createBlockData(@NonNull BlockType blockType);
+
+ @Contract(pure = true)
+ @NonNull BlockData applyToBlockData(@NonNull BlockData blockData);
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<BlockItemDataProperties> {
+ // building this requires BlockProperty API, so an empty builder for now (essentially read-only)
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java b/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java
new file mode 100644
index 0000000000000000000000000000000000000000..7eba2596f12b369e8a8ad96b78198f1f92f0392a
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java
@@ -0,0 +1,64 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.Arrays;
+import java.util.List;
+import org.bukkit.inventory.ItemStack;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Holds all items stored inside of a Bundle.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface BundleContents {
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull BundleContents bundleContents(final @NonNull ItemStack @NonNull... contents) {
+ return bundleContents(Arrays.asList(contents));
+ }
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull BundleContents bundleContents(final @NonNull List<@NonNull ItemStack> contents) {
+ return ComponentTypesBridge.bridge().bundleContents().addAll(contents).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static BundleContents.@NonNull Builder bundleContents() {
+ return ComponentTypesBridge.bridge().bundleContents();
+ }
+
+ /**
+ * Lists the items that are currently stored inside of this component.
+ *
+ * @return items
+ */
+ @Contract(value = "-> new", pure = true)
+ @NonNull @Unmodifiable List<@NonNull ItemStack> contents();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<BundleContents> {
+
+ /**
+ * Adds an item to this builder.
+ *
+ * @param stack item
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder add(@NonNull ItemStack stack);
+
+ /**
+ * Adds items to this builder.
+ *
+ * @param stacks items
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addAll(@NonNull List<@NonNull ItemStack> stacks);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java b/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java
new file mode 100644
index 0000000000000000000000000000000000000000..dd34facf9f9ea1d674f65ff2e5f56386c346fd62
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java
@@ -0,0 +1,64 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.Arrays;
+import java.util.List;
+import org.bukkit.inventory.ItemStack;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Holds all projectiles that have been loaded into a Crossbow.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface ChargedProjectiles {
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull ChargedProjectiles chargedProjectiles(final @NonNull ItemStack @NonNull...projectiles) {
+ return chargedProjectiles(Arrays.asList(projectiles));
+ }
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull ChargedProjectiles chargedProjectiles(final @NonNull List<@NonNull ItemStack> projectiles) {
+ return chargedProjectiles().addAll(projectiles).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static ChargedProjectiles.@NonNull Builder chargedProjectiles() {
+ return ComponentTypesBridge.bridge().chargedProjectiles();
+ }
+
+ /**
+ * Lists the projectiles that are currently loaded into this component.
+ *
+ * @return the loaded projectiles
+ */
+ @Contract(value = "-> new", pure = true)
+ @NonNull @Unmodifiable List<@NonNull ItemStack> projectiles();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<ChargedProjectiles> {
+
+ /**
+ * Adds a projectile to be loaded in this builder.
+ *
+ * @param stack projectile
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder add(@NonNull ItemStack stack);
+
+ /**
+ * Adds projectiles to be loaded in this builder.
+ *
+ * @param stacks projectiles
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addAll(@NonNull List<@NonNull ItemStack> stacks);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ComponentTypesBridge.java b/src/main/java/io/papermc/paper/datacomponent/item/ComponentTypesBridge.java
new file mode 100644
index 0000000000000000000000000000000000000000..d061ed57d046f9e42b116e55e392a1a9ecc9d655
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ComponentTypesBridge.java
@@ -0,0 +1,87 @@
+package io.papermc.paper.datacomponent.item;
+
+import com.destroystokyo.paper.profile.PlayerProfile;
+import io.papermc.paper.registry.set.RegistryKeySet;
+import io.papermc.paper.util.Filtered;
+import java.util.Optional;
+import java.util.ServiceLoader;
+import net.kyori.adventure.key.Key;
+import net.kyori.adventure.util.TriState;
+import org.bukkit.JukeboxSong;
+import org.bukkit.block.BlockType;
+import org.bukkit.inventory.meta.trim.ArmorTrim;
+import org.bukkit.map.MapCursor;
+import org.bukkit.potion.PotionEffect;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.ApiStatus;
+
+@ApiStatus.Internal
+interface ComponentTypesBridge {
+
+ Optional<ComponentTypesBridge> BRIDGE = ServiceLoader.load(ComponentTypesBridge.class).findFirst();
+
+ static ComponentTypesBridge bridge() {
+ return BRIDGE.orElseThrow();
+ }
+
+ ChargedProjectiles.Builder chargedProjectiles();
+
+ PotDecorations.Builder potDecorations();
+
+ Unbreakable.Builder unbreakable();
+
+ ItemLore.Builder lore();
+
+ ItemEnchantments.Builder enchantments();
+
+ ItemAttributeModifiers.Builder modifiers();
+
+ FoodProperties.Builder food();
+
+ FoodProperties.PossibleEffect foodEffect(PotionEffect effect, float probability);
+
+ DyedItemColor.Builder dyedItemColor();
+
+ PotionContents.Builder potionContents();
+
+ BundleContents.Builder bundleContents();
+
+ SuspiciousStewEffects.Builder suspiciousStewEffects();
+
+ MapItemColor.Builder mapItemColor();
+
+
+ MapDecorations.Builder mapDecorations();
+
+ MapDecorations.DecorationEntry decorationEntry(MapCursor.Type type, double x, double z, float rotation);
+
+ SeededContainerLoot.Builder seededContainerLoot(Key lootTableKey);
+
+ WrittenBookContent.Builder writtenBookContent(Filtered<String> title, String author);
+
+ WritableBookContent.Builder writeableBookContent();
+
+ ItemArmorTrim.Builder itemArmorTrim(ArmorTrim armorTrim);
+
+ LodestoneTracker.Builder lodestoneTracker();
+
+ Fireworks.Builder fireworks();
+
+ ResolvableProfile.Builder resolvableProfile();
+
+ ResolvableProfile resolvableProfile(PlayerProfile profile);
+
+ BannerPatternLayers.Builder bannerPatternLayers();
+
+ BlockItemDataProperties.Builder blockItemStateProperties();
+
+ ItemContainerContents.Builder itemContainerContents();
+
+ JukeboxPlayable.Builder jukeboxPlayable(JukeboxSong song);
+
+ Tool.Builder tool();
+
+ Tool.Rule rule(RegistryKeySet<BlockType> blocks, @Nullable Float speed, TriState correctForDrops);
+
+ ItemAdventurePredicate.Builder itemAdventurePredicate();
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java b/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java
new file mode 100644
index 0000000000000000000000000000000000000000..79e22b97608119b51194622589198070ffeb8993
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java
@@ -0,0 +1,47 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import org.bukkit.Color;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+/**
+ * Represents a color applied to a dyeable item.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface DyedItemColor extends ShownInTooltip<DyedItemColor> {
+
+ @Contract(value = "_, _ -> new", pure = true)
+ static @NonNull DyedItemColor dyedItemColor(final @NonNull Color color, final boolean showInTooltip) {
+ return dyedItemColor().color(color).showInTooltip(showInTooltip).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static DyedItemColor.@NonNull Builder dyedItemColor() {
+ return ComponentTypesBridge.bridge().dyedItemColor();
+ }
+
+ /**
+ * Color of the item.
+ *
+ * @return color
+ */
+ @Contract(value = "-> new", pure = true)
+ @NonNull Color color();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<DyedItemColor> {
+
+ /**
+ * Sets the color of this builder.
+ *
+ * @param color color
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder color(@NonNull Color color);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/Fireworks.java b/src/main/java/io/papermc/paper/datacomponent/item/Fireworks.java
new file mode 100644
index 0000000000000000000000000000000000000000..d8974a1f984a300cfb9b2356f7f0dbf5ce6e9125
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/Fireworks.java
@@ -0,0 +1,76 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.List;
+import org.bukkit.FireworkEffect;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.common.value.qual.IntRange;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Stores all explosions crafted into a Firework Rocket, as well as flight duration.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface Fireworks {
+
+ @Contract(value = "_, _ -> new", pure = true)
+ static @NonNull Fireworks fireworks(final @NonNull List<@NonNull FireworkEffect> effects, final int flightDuration) {
+ return fireworks().addEffects(effects).flightDuration(flightDuration).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static Fireworks.@NonNull Builder fireworks() {
+ return ComponentTypesBridge.bridge().fireworks();
+ }
+
+ /**
+ * Lists the effects stored in this component.
+ *
+ * @return the effects
+ */
+ @Contract(pure = true)
+ @NonNull @Unmodifiable List<@NonNull FireworkEffect> effects();
+
+ /**
+ * Number of gunpowder in this component.
+ *
+ * @return the flight duration
+ */
+ @Contract(pure = true)
+ @IntRange(from = 0, to = 255) int flightDuration();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<Fireworks> {
+
+ /**
+ * Sets the number of gunpowder used in this builder.
+ *
+ * @param duration duration
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder flightDuration(@IntRange(from = 0, to = 255) int duration);
+
+ /**
+ * Adds an explosion to this builder.
+ *
+ * @param effect effect
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addEffect(@NonNull FireworkEffect effect);
+
+ /**
+ * Adds explosions to this builder.
+ *
+ * @param effects effects
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addEffects(@NonNull List<@NonNull FireworkEffect> effects);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/FoodProperties.java b/src/main/java/io/papermc/paper/datacomponent/item/FoodProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..356591941d4c945bba0c510682b7805add52ded4
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/FoodProperties.java
@@ -0,0 +1,116 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.Collection;
+import java.util.List;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.potion.PotionEffect;
+import org.checkerframework.checker.index.qual.NonNegative;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface FoodProperties {
+
+ @Contract(value = "-> new", pure = true)
+ static FoodProperties.@NonNull Builder food() {
+ return ComponentTypesBridge.bridge().food();
+ }
+
+ /**
+ * Number of food points to restore when eaten.
+ *
+ * @return the nutrition
+ */
+ @Contract(pure = true)
+ @NonNegative int nutrition();
+
+ /**
+ * Amount of saturation to restore when eaten.
+ *
+ * @return the saturation
+ */
+ @Contract(pure = true)
+ float saturation();
+
+ /**
+ * If {@code true}, this food can be eaten even if not hungry.
+ *
+ * @return can always be eaten
+ */
+ @Contract(pure = true)
+ boolean canAlwaysEat();
+
+ /**
+ * The number of seconds that it takes to eat this food item.
+ *
+ * @return the number seconds to eat that food
+ */
+ @Contract(pure = true)
+ float eatSeconds();
+
+ @Contract(pure = true)
+ @Nullable ItemStack usingConvertsTo();
+
+ /**
+ * List of effects to apply when eaten.
+ *
+ * @return effects
+ */
+ @NonNull @Unmodifiable List<@NonNull PossibleEffect> effects();
+
+ /**
+ * Effect to be applied when eaten.
+ */
+ @ApiStatus.NonExtendable
+ interface PossibleEffect {
+
+ static @NonNull PossibleEffect of(final @NonNull PotionEffect effect, final float probability) {
+ return ComponentTypesBridge.bridge().foodEffect(effect, probability);
+ }
+
+ /**
+ * Effect instance.
+ *
+ * @return effect
+ */
+ @NonNull PotionEffect effect();
+
+ /**
+ * Float between 0 and 1, chance for the effect to be applied.
+ *
+ * @return chance
+ */
+ float probability();
+ }
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<FoodProperties> {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder canAlwaysEat(boolean canAlwaysEat);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder eatSeconds(float eatSeconds);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder saturation(float saturation);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder nutrition(@NonNegative int nutrition);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder usingConvertsTo(@Nullable ItemStack stack);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addEffect(@NonNull PossibleEffect effect);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addEffects(@NonNull Collection<@NonNull PossibleEffect> effects);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemAdventurePredicate.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemAdventurePredicate.java
new file mode 100644
index 0000000000000000000000000000000000000000..3ae320efec03ebb69bffd70a851c5e9f97002d02
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemAdventurePredicate.java
@@ -0,0 +1,44 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.block.BlockPredicate;
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.List;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Controls which blocks a player in Adventure mode can do a certain action with this item.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface ItemAdventurePredicate extends ShownInTooltip<ItemAdventurePredicate> {
+
+ @Contract(value = "-> new", pure = true)
+ static ItemAdventurePredicate.@NonNull Builder itemAdventurePredicate() {
+ return ComponentTypesBridge.bridge().itemAdventurePredicate();
+ }
+
+ /**
+ * List of block predicates that control if the action is allowed.
+ *
+ * @return predicates
+ */
+ @Contract(pure = true)
+ @NonNull @Unmodifiable List<@NonNull BlockPredicate> predicates();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemAdventurePredicate> {
+ /**
+ * Adds a block predicate to this builder.
+ *
+ * @param predicate predicate
+ * @return the builder for chaining
+ * @see #predicates()
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addPredicate(@NonNull BlockPredicate predicate);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemArmorTrim.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemArmorTrim.java
new file mode 100644
index 0000000000000000000000000000000000000000..0ec21a541f9a817ffe23ecab5cf968f245a50ea4
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemArmorTrim.java
@@ -0,0 +1,46 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import org.bukkit.inventory.meta.trim.ArmorTrim;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+/**
+ * Holds the trims applied to an item.
+ */
+@ApiStatus.NonExtendable
+public interface ItemArmorTrim extends ShownInTooltip<ItemArmorTrim> {
+
+ @Contract(value = "_, _ -> new", pure = true)
+ static @NonNull ItemArmorTrim itemArmorTrim(final @NonNull ArmorTrim armorTrim, final boolean showInTooltip) {
+ return itemArmorTrim(armorTrim).showInTooltip(showInTooltip).build();
+ }
+
+ @Contract(value = "_ -> new", pure = true)
+ static ItemArmorTrim.@NonNull Builder itemArmorTrim(final @NonNull ArmorTrim armorTrim) {
+ return ComponentTypesBridge.bridge().itemArmorTrim(armorTrim);
+ }
+
+ /**
+ * Armor trim present on this item.
+ *
+ * @return trim
+ */
+ @Contract(pure = true)
+ @NonNull ArmorTrim armorTrim();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemArmorTrim> {
+
+ /**
+ * Sets the armor trim for this builder.
+ *
+ * @param armorTrim trim
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder armorTrim(@NonNull ArmorTrim armorTrim);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java
new file mode 100644
index 0000000000000000000000000000000000000000..4bad7a6226dc8d3dc9301084f35945b771da2279
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java
@@ -0,0 +1,58 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.List;
+import org.bukkit.attribute.Attribute;
+import org.bukkit.attribute.AttributeModifier;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Holds attribute modifiers applied to any item
+ */
+@ApiStatus.NonExtendable
+public interface ItemAttributeModifiers extends ShownInTooltip<ItemAttributeModifiers> {
+
+ @Contract(value = "-> new", pure = true)
+ static ItemAttributeModifiers.@NonNull Builder itemAttributes() {
+ return ComponentTypesBridge.bridge().modifiers();
+ }
+
+ /**
+ * Lists the attribute modifiers that are present on this item.
+ *
+ * @return modifiers
+ */
+ @Contract(pure = true)
+ @NonNull @Unmodifiable List<@NonNull Entry> modifiers();
+
+ /**
+ * Holds an attribute entry.
+ */
+ @ApiStatus.NonExtendable
+ interface Entry {
+
+ @Contract(pure = true)
+ @NonNull Attribute attribute();
+
+ @Contract(pure = true)
+ @NonNull AttributeModifier modifier();
+ }
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemAttributeModifiers> {
+
+ /**
+ * Adds a modifier to this builder.
+ *
+ * @param attribute attribute
+ * @param modifier modifier
+ * @return the builder for chaining
+ */
+ @Contract(value = "_, _ -> this", mutates = "this")
+ @NonNull Builder addModifier(@NonNull Attribute attribute, @NonNull AttributeModifier modifier);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemContainerContents.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemContainerContents.java
new file mode 100644
index 0000000000000000000000000000000000000000..edbb7c23ca82465069d50f82b45910cea8b9abaf
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemContainerContents.java
@@ -0,0 +1,44 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.Arrays;
+import java.util.List;
+import org.bukkit.inventory.ItemStack;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface ItemContainerContents {
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull ItemContainerContents containerContents(final @NonNull ItemStack @NonNull...contents) {
+ return containerContents(Arrays.asList(contents));
+ }
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull ItemContainerContents containerContents(final @NonNull List<@NonNull ItemStack> contents) {
+ return containerContents().addAll(contents).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static ItemContainerContents.@NonNull Builder containerContents() {
+ return ComponentTypesBridge.bridge().itemContainerContents();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ @NonNull @Unmodifiable List<@NonNull ItemStack> contents();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<ItemContainerContents> {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder add(@NonNull ItemStack stack);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addAll(@NonNull List<@NonNull ItemStack> stacks);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java
new file mode 100644
index 0000000000000000000000000000000000000000..b547927dd2093ade5d598d6aa1856d10c439ec34
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java
@@ -0,0 +1,60 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.Map;
+import org.bukkit.enchantments.Enchantment;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.common.value.qual.IntRange;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Stores a list of enchantments and their levels on an item.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface ItemEnchantments extends ShownInTooltip<ItemEnchantments> {
+
+ @Contract(value = "_, _ -> new", pure = true)
+ static @NonNull ItemEnchantments itemEnchantments(final @NonNull Map<Enchantment, @IntRange(from = 1, to = 255) Integer> enchantments, final boolean showInTooltip) {
+ return itemEnchantments().addAll(enchantments).showInTooltip(showInTooltip).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static ItemEnchantments.@NonNull Builder itemEnchantments() {
+ return ComponentTypesBridge.bridge().enchantments();
+ }
+
+ /**
+ * Enchantments currently present on this item.
+ *
+ * @return enchantments
+ */
+ @Contract(pure = true)
+ @NonNull @Unmodifiable Map<@NonNull Enchantment, @NonNull @IntRange(from = 0, to = 255) Integer> enchantments();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemEnchantments> {
+
+ /**
+ * Adds an enchantment with the given level to this component.
+ *
+ * @param enchantment enchantment
+ * @param level level
+ * @return the builder for chaining
+ */
+ @Contract(value = "_, _ -> this", mutates = "this")
+ @NonNull Builder add(@NonNull Enchantment enchantment, @IntRange(from = 1, to = 255) int level);
+
+ /**
+ * Adds enchantments with the given level to this component.
+ *
+ * @param enchantments enchantments
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addAll(@NonNull Map<@NonNull Enchantment, @NonNull @IntRange(from = 1, to = 255) Integer> enchantments);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemLore.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemLore.java
new file mode 100644
index 0000000000000000000000000000000000000000..2ca8673bb89c58f76d6ed2e38d6bcf7cc65765e8
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemLore.java
@@ -0,0 +1,76 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.List;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.ComponentLike;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Additional lines to include in an item's tooltip.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface ItemLore {
+
+ @Contract(value = "_ -> new", pure = true)
+ static ItemLore lore(final @NonNull List<@NonNull ? extends ComponentLike> lines) {
+ return lore().lines(lines).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static ItemLore.@NonNull Builder lore() {
+ return ComponentTypesBridge.bridge().lore();
+ }
+
+ /**
+ * Lists the components that are added to an item's tooltip.
+ *
+ * @return component list
+ */
+ @Contract(pure = true)
+ @NonNull @Unmodifiable List<@NonNull Component> lines();
+
+ /**
+ * Lists the styled components (example: italicized and purple) that are added to an item's tooltip.
+ *
+ * @return component list
+ */
+ @Contract(pure = true)
+ @NonNull @Unmodifiable List<@NonNull Component> styledLines();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<ItemLore> {
+
+ /**
+ * Sets the components of this lore.
+ *
+ * @param lines components
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ Builder lines(@NonNull List<@NonNull ? extends ComponentLike> lines);
+
+ /**
+ * Adds a component to the lore.
+ *
+ * @param line component
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addLine(@NonNull ComponentLike line);
+
+ /**
+ * Adds components to the lore.
+ *
+ * @param lines components
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addLines(@NonNull List<@NonNull ? extends ComponentLike> lines);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/JukeboxPlayable.java b/src/main/java/io/papermc/paper/datacomponent/item/JukeboxPlayable.java
new file mode 100644
index 0000000000000000000000000000000000000000..5beb84a0c5c2275e721cab21483e29c366e20b32
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/JukeboxPlayable.java
@@ -0,0 +1,28 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import org.bukkit.JukeboxSong;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface JukeboxPlayable extends ShownInTooltip<JukeboxPlayable> {
+
+ @Contract(value = "_ -> new", pure = true)
+ static JukeboxPlayable.@NonNull Builder jukeboxPlayable(@NonNull JukeboxSong song) {
+ return ComponentTypesBridge.bridge().jukeboxPlayable(song);
+ }
+
+ @Contract(pure = true)
+ @NonNull JukeboxSong jukeboxSong();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends ShownInTooltip.Builder<JukeboxPlayable.Builder>, DataComponentBuilder<JukeboxPlayable> {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder jukeboxSong(@NonNull JukeboxSong song);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/LodestoneTracker.java b/src/main/java/io/papermc/paper/datacomponent/item/LodestoneTracker.java
new file mode 100644
index 0000000000000000000000000000000000000000..749249dca2fcdaf506820ea95a05720b980e25cc
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/LodestoneTracker.java
@@ -0,0 +1,65 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import org.bukkit.Location;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+/**
+ * If present, specifies the target Lodestone that a Compass should point towards.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface LodestoneTracker {
+
+ @Contract(value = "_, _ -> new", pure = true)
+ static @NonNull LodestoneTracker lodestoneTracker(final @Nullable Location location, final boolean tracked) {
+ return lodestoneTracker().location(location).tracked(tracked).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static LodestoneTracker.@NonNull Builder lodestoneTracker() {
+ return ComponentTypesBridge.bridge().lodestoneTracker();
+ }
+
+ /**
+ * The location that the compass should point towards.
+ *
+ * @return location
+ */
+ @Contract(value = "-> new", pure = true)
+ @Nullable Location location();
+
+ /**
+ * If {@code true}, when the Lodestone at the target position is removed, the component will be removed.
+ *
+ * @return tracked
+ */
+ @Contract(pure = true)
+ boolean tracked();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<LodestoneTracker> {
+
+ /**
+ * Sets the location to point towards for this builder.
+ *
+ * @param location location to point towards
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder location(@Nullable Location location);
+
+ /**
+ * Sets if this location lodestone is tracked for this builder.
+ *
+ * @param tracked is tracked
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder tracked(boolean tracked);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/MapDecorations.java b/src/main/java/io/papermc/paper/datacomponent/item/MapDecorations.java
new file mode 100644
index 0000000000000000000000000000000000000000..571b97d22f7a6360c8fa0bde22914f7f8ec71014
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/MapDecorations.java
@@ -0,0 +1,113 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.Map;
+import org.bukkit.map.MapCursor;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Holds a list of markers to be placed on a Filled Map (used for Explorer Maps).
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface MapDecorations {
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull MapDecorations mapDecorations(final @NonNull Map<@NonNull String, @NonNull DecorationEntry> entries) {
+ return mapDecorations().putAll(entries).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static MapDecorations.@NonNull Builder mapDecorations() {
+ return ComponentTypesBridge.bridge().mapDecorations();
+ }
+
+ /**
+ * Gets the decoration entry with the given id.
+ *
+ * @param id id
+ * @return decoration entry, or {@code null} if not present
+ */
+ @Contract(pure = true)
+ @Nullable DecorationEntry getDecoration(@NonNull String id);
+
+ /**
+ * Gets the decoration entries.
+ *
+ * @return the decoration entries
+ */
+ @Contract(pure = true)
+ @NonNull @Unmodifiable Map<@NonNull String, @NonNull DecorationEntry> getDecorations();
+
+ /**
+ * Decoration present on the map.
+ */
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface DecorationEntry {
+
+ @Contract(value = "_, _, _, _ -> new", pure = true)
+ static @NonNull DecorationEntry of(final MapCursor.@NonNull Type type, final double x, final double z, final float rotation) {
+ return ComponentTypesBridge.bridge().decorationEntry(type, x, z, rotation);
+ }
+
+ /**
+ * Type of decoration.
+ *
+ * @return type
+ */
+ @Contract(pure = true)
+ MapCursor.@NonNull Type type();
+
+ /**
+ * X world coordinate of the decoration.
+ *
+ * @return x coordinate
+ */
+ @Contract(pure = true)
+ double x();
+
+ /**
+ * Z world coordinate of the decoration.
+ *
+ * @return z coordinate
+ */
+ @Contract(pure = true)
+ double z();
+
+ /**
+ * Clockwise rotation from north in degrees.
+ *
+ * @return rotation
+ */
+ @Contract(pure = true)
+ float rotation();
+ }
+
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<MapDecorations> {
+
+ /**
+ * Puts the decoration with the given id in this builder.
+ *
+ * @param id id
+ * @param entry decoration
+ * @return the builder for chaining
+ */
+ @Contract(value = "_, _ -> this", mutates = "this")
+ MapDecorations.@NonNull Builder put(@NonNull String id, @NonNull DecorationEntry entry);
+
+ /**
+ * Puts all the decoration with the given id in this builder.
+ *
+ * @param entries decorations
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ MapDecorations.@NonNull Builder putAll(@NonNull Map<@NonNull String, @NonNull DecorationEntry> entries);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/MapItemColor.java b/src/main/java/io/papermc/paper/datacomponent/item/MapItemColor.java
new file mode 100644
index 0000000000000000000000000000000000000000..2bcd83438547417cfc6b382887d04e7d47d0d6c2
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/MapItemColor.java
@@ -0,0 +1,39 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import org.bukkit.Color;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+/**
+ * Represents the tint of the decorations on the Filled Map item.
+ */
+@ApiStatus.NonExtendable
+public interface MapItemColor {
+
+ @Contract(value = "-> new", pure = true)
+ static MapItemColor.@NonNull Builder mapItemColor() {
+ return ComponentTypesBridge.bridge().mapItemColor();
+ }
+
+ /**
+ * The tint to apply.
+ *
+ * @return color
+ */
+ @NonNull Color color();
+
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<MapItemColor> {
+
+ /**
+ * Sets the tint color of this map.
+ *
+ * @param color tint color
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder color(@NonNull Color color);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PotDecorations.java b/src/main/java/io/papermc/paper/datacomponent/item/PotDecorations.java
new file mode 100644
index 0000000000000000000000000000000000000000..f5d2bceb3baa51652274dc890eefd3ec15464b37
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PotDecorations.java
@@ -0,0 +1,54 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import org.bukkit.Material;
+import org.bukkit.inventory.ItemType;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+// CONTRIBUTORS: LEAVE THIS AS ITEM TYPE!!!
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface PotDecorations {
+
+ @Contract(value = "_, _, _, _ -> new", pure = true)
+ static @NonNull PotDecorations potDecorations(final @Nullable ItemType back, final @Nullable ItemType left, final @Nullable ItemType right, final @Nullable ItemType front) {
+ return potDecorations().back(back).left(left).right(right).front(front).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static PotDecorations.@NonNull Builder potDecorations() {
+ return ComponentTypesBridge.bridge().potDecorations();
+ }
+
+ @Contract(pure = true)
+ @Nullable ItemType back();
+
+ @Contract(pure = true)
+ @Nullable ItemType left();
+
+ @Contract(pure = true)
+ @Nullable ItemType right();
+
+ @Contract(pure = true)
+ @Nullable ItemType front();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<PotDecorations> {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder back(@Nullable ItemType back);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder left(@Nullable ItemType left);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder right(@Nullable ItemType right);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder front(@Nullable ItemType font);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PotionContents.java b/src/main/java/io/papermc/paper/datacomponent/item/PotionContents.java
new file mode 100644
index 0000000000000000000000000000000000000000..6f924f3fd13da1de3b7da921d0d2a96a56ca69b3
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PotionContents.java
@@ -0,0 +1,98 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.List;
+import org.bukkit.Color;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionType;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Holds the contents of a potion (Potion, Splash Potion, Lingering Potion), or potion applied to a Tipped Arrow.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface PotionContents {
+
+ @Contract(value = "-> new", pure = true)
+ static PotionContents.@NonNull Builder potionContents() { // can't name it just "enchantments"
+ return ComponentTypesBridge.bridge().potionContents();
+ }
+
+ /**
+ * The potion type in this item: the item will inherit all effects from this.
+ *
+ * @return potion type, or {@code null} if not present
+ */
+ @Contract(pure = true)
+ @Nullable PotionType potion();
+
+ /**
+ * Overrides the visual color of the potion.
+ *
+ * @return color override, or {@code null} if not present
+ * @apiNote alpha channel of the color is only relevant
+ * for Tipped Arrow
+ */
+ @Contract(pure = true)
+ @Nullable Color customColor();
+
+ /**
+ * Additional list of effect instances that this item should apply.
+ *
+ * @return effects
+ */
+ @Contract(pure = true)
+ @NonNull @Unmodifiable List<@NonNull PotionEffect> customEffects();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<PotionContents> {
+
+ /**
+ * Sets the potion type for this builder.
+ *
+ * @param type builder
+ * @see #potion()
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder potion(@Nullable PotionType type);
+
+ /**
+ * Sets the color override for this builder.
+ *
+ * @param color color
+ * @see #customColor()
+ * @return the builder for chaining
+ * @apiNote alpha channel of the color is supported only for
+ * Tipped Arrow
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder customColor(@Nullable Color color);
+
+ /**
+ * Adds a custom effect instance to this builder.
+ *
+ * @param effect effect
+ * @see #customEffects()
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addCustomEffect(@NonNull PotionEffect effect);
+
+ /**
+ * Adds custom effect instances to this builder.
+ *
+ * @param effects effects
+ * @see #customEffects()
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addCustomEffects(@NonNull List<@NonNull PotionEffect> effects);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ResolvableProfile.java b/src/main/java/io/papermc/paper/datacomponent/item/ResolvableProfile.java
new file mode 100644
index 0000000000000000000000000000000000000000..d776e0e93671963fdc0d5a7bc082e7be30ec66d7
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ResolvableProfile.java
@@ -0,0 +1,57 @@
+package io.papermc.paper.datacomponent.item;
+
+import com.destroystokyo.paper.profile.PlayerProfile;
+import com.destroystokyo.paper.profile.ProfileProperty;
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.Collection;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface ResolvableProfile {
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull ResolvableProfile resolvableProfile(@NonNull PlayerProfile profile) {
+ return ComponentTypesBridge.bridge().resolvableProfile(profile);
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static ResolvableProfile.@NonNull Builder resolvableProfile() {
+ return ComponentTypesBridge.bridge().resolvableProfile();
+ }
+
+ @Contract(pure = true)
+ @Nullable UUID uuid();
+
+ @Contract(pure = true)
+ @Nullable String name();
+
+ @Contract(pure = true)
+ @NonNull @Unmodifiable Collection<@NonNull ProfileProperty> properties();
+
+ @Contract(pure = true)
+ @NonNull CompletableFuture<@NonNull PlayerProfile> resolve();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<ResolvableProfile> {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder name(@Nullable String name);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder uuid(@Nullable UUID uuid);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addProperty(@NonNull ProfileProperty property);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addProperties(@NonNull Collection<@NonNull ProfileProperty> properties);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/SeededContainerLoot.java b/src/main/java/io/papermc/paper/datacomponent/item/SeededContainerLoot.java
new file mode 100644
index 0000000000000000000000000000000000000000..481c34440c70270d44d1e039c179eca05ce02428
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/SeededContainerLoot.java
@@ -0,0 +1,39 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import net.kyori.adventure.key.Key;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface SeededContainerLoot {
+
+ @Contract(value = "_, _ -> new", pure = true)
+ static @NonNull SeededContainerLoot seededContainerLoot(final @NonNull Key lootTableKey, final long seed) {
+ return SeededContainerLoot.seededContainerLoot(lootTableKey).seed(seed).build();
+ }
+
+ @Contract(value = "_ -> new", pure = true)
+ static SeededContainerLoot.@NonNull Builder seededContainerLoot(final @NonNull Key lootTableKey) {
+ return ComponentTypesBridge.bridge().seededContainerLoot(lootTableKey);
+ }
+
+ @Contract(pure = true)
+ @NonNull Key lootTable();
+
+ @Contract(pure = true)
+ long seed();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<SeededContainerLoot> {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder lootTable(@NonNull Key key);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder seed(long seed);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java b/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java
new file mode 100644
index 0000000000000000000000000000000000000000..ab642ececb579b86e8c6eab6b968e4980f782395
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java
@@ -0,0 +1,23 @@
+package io.papermc.paper.datacomponent.item;
+
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface ShownInTooltip<T> {
+
+ @Contract(pure = true)
+ boolean showInTooltip();
+
+ @Contract(value = "_ -> new", pure = true)
+ @NonNull T showInTooltip(boolean showInTooltip);
+
+ @ApiStatus.Experimental
+ interface Builder<B> {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull B showInTooltip(boolean showInTooltip);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/SuspiciousStewEffects.java b/src/main/java/io/papermc/paper/datacomponent/item/SuspiciousStewEffects.java
new file mode 100644
index 0000000000000000000000000000000000000000..e3cefefcc7105e1c6fbcb2bbb5c2ea75f2ce9a07
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/SuspiciousStewEffects.java
@@ -0,0 +1,65 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import io.papermc.paper.potion.SuspiciousEffectEntry;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Holds the effects that will be applied when consuming Suspicious Stew.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface SuspiciousStewEffects {
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull SuspiciousStewEffects suspiciousStewEffects(final @NonNull SuspiciousEffectEntry @NonNull...effects) {
+ return suspiciousStewEffects(Arrays.asList(effects));
+ }
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull SuspiciousStewEffects suspiciousStewEffects(final @NonNull Collection<@NonNull SuspiciousEffectEntry> effects) {
+ return suspiciousStewEffects().addAll(effects).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static SuspiciousStewEffects.@NonNull Builder suspiciousStewEffects() {
+ return ComponentTypesBridge.bridge().suspiciousStewEffects();
+ }
+
+ /**
+ * Effects that will be applied when consuming Suspicious Stew.
+ *
+ * @return effects
+ */
+ @Contract(pure = true)
+ @NonNull @Unmodifiable List<@NonNull SuspiciousEffectEntry> effects();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<SuspiciousStewEffects> {
+
+ /**
+ * Adds an effect applied to this builder.
+ *
+ * @param entry effect
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder add(@NonNull SuspiciousEffectEntry entry);
+
+ /**
+ * Adds effects applied to this builder.
+ *
+ * @param entries effect
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addAll(@NonNull Collection<@NonNull SuspiciousEffectEntry> entries);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/Tool.java b/src/main/java/io/papermc/paper/datacomponent/item/Tool.java
new file mode 100644
index 0000000000000000000000000000000000000000..ed67a747acc88099a6aac0d88d82a709c5d12f66
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/Tool.java
@@ -0,0 +1,135 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import java.util.Collection;
+import java.util.List;
+import io.papermc.paper.registry.set.RegistryKeySet;
+import net.kyori.adventure.util.TriState;
+import org.bukkit.block.BlockType;
+import org.checkerframework.checker.index.qual.NonNegative;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Controls the behavior of the item as a tool.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface Tool {
+
+ @Contract(value = "-> new", pure = true)
+ static Tool.@NonNull Builder tool() {
+ return ComponentTypesBridge.bridge().tool();
+ }
+
+ /**
+ * Mining speed to use if no rules match and don't override mining speed.
+ *
+ * @return default mining speed
+ */
+ @Contract(pure = true)
+ float defaultMiningSpeed();
+
+ /**
+ * Amount of durability to remove each time a block is mined with this tool.
+ *
+ * @return durability
+ */
+ @Contract(pure = true)
+ @NonNegative int damagePerBlock();
+
+ /**
+ * List of rule entries.
+ *
+ * @return rules
+ */
+ @Contract(pure = true)
+ @NonNull @Unmodifiable List<Tool.@NonNull Rule> rules();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Rule {
+
+ static @NonNull Rule of(final @NonNull RegistryKeySet<BlockType> blocks, final @Nullable Float speed, final @NonNull TriState correctForDrops) {
+ return ComponentTypesBridge.bridge().rule(blocks, speed, correctForDrops);
+ }
+
+ static @NonNull Rule minesAndDrops(final @NonNull RegistryKeySet<BlockType> blocks, final float speed) {
+ return of(blocks, speed, TriState.TRUE);
+ }
+
+ static @NonNull Rule deniesDrops(final @NonNull RegistryKeySet<BlockType> blocks) {
+ return of(blocks, null, TriState.FALSE);
+ }
+
+ static @NonNull Rule overrideSpeed(final @NonNull RegistryKeySet<BlockType> blocks, final float speed) {
+ return of(blocks, speed, TriState.NOT_SET);
+ }
+
+ /**
+ * Blocks to match.
+ *
+ * @return blocks
+ */
+ @NonNull RegistryKeySet<BlockType> blocks();
+
+ /**
+ * Overrides the mining speed if present and matched.
+ * <p>
+ * {@code true} will cause the block to mine at its most efficient speed, and drop items if the targeted block requires that.
+ *
+ * @return speed override
+ */
+ @Nullable Float speed();
+
+ /**
+ * Overrides whether this tool is considered 'correct' if present and matched.
+ *
+ * @return a tri-state
+ */
+ @NonNull TriState correctForDrops();
+ }
+
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<Tool> {
+
+ /**
+ * Controls the amount of durability to remove each time a block is mined with this tool.
+ *
+ * @param damage durability to remove
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder damagePerBlock(@NonNegative int damage);
+
+ /**
+ * Controls mining speed to use if no rules match and don't override mining speed.
+ *
+ * @param miningSpeed mining speed
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder defaultMiningSpeed(float miningSpeed);
+
+ /**
+ * Adds a rule to the tool that controls the breaking speed / damage per block if matched.
+ *
+ * @param rule rule
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addRule(@NonNull Rule rule);
+
+ /**
+ * Adds rules to the tool that control the breaking speed / damage per block if matched.
+ *
+ * @param rules rules
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addRules(@NonNull Collection<@NonNull Rule> rules);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/Unbreakable.java b/src/main/java/io/papermc/paper/datacomponent/item/Unbreakable.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f34723f51968d83735ed8f95b5d2ef12fe480a2
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/Unbreakable.java
@@ -0,0 +1,29 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+/**
+ * If set, the item will not lose any durability when used.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface Unbreakable extends ShownInTooltip<Unbreakable> {
+
+ @Contract(value = "_ -> new", pure = true)
+ static @NonNull Unbreakable unbreakable(final boolean showInTooltip) {
+ return unbreakable().showInTooltip(showInTooltip).build();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ static Unbreakable.@NonNull Builder unbreakable() {
+ return ComponentTypesBridge.bridge().unbreakable();
+ }
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<Unbreakable> {
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java b/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java
new file mode 100644
index 0000000000000000000000000000000000000000..d000ccc120808b74aa1d0fa3f578565da40d2388
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java
@@ -0,0 +1,69 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import io.papermc.paper.util.Filtered;
+import java.util.Collection;
+import java.util.List;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface WritableBookContent {
+
+ @Contract(value = "-> new", pure = true)
+ static WritableBookContent.@NonNull Builder writeableBookContent() {
+ return ComponentTypesBridge.bridge().writeableBookContent();
+ }
+
+ /**
+ * Holds the pages that can be written to for this component.
+ *
+ * @return pages, as filtered objects
+ */
+ @Contract(pure = true)
+ @NonNull @Unmodifiable List<@NonNull Filtered<String>> pages();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<WritableBookContent> {
+
+ /**
+ * Adds a page that can be written to for this builder.
+ *
+ * @param page page
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addPage(@NonNull String page);
+
+ /**
+ * Adds pages that can be written to for this builder.
+ *
+ * @param pages pages
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addPages(@NonNull Collection<@NonNull String> pages);
+
+ /**
+ * Adds a filterable page that can be written to for this builder.
+ *
+ * @param page page
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addFilteredPage(@NonNull Filtered<@NonNull String> page);
+
+ /**
+ * Adds filterable pages that can be written to for this builder.
+ *
+ * @param pages pages
+ * @return the builder for chaining
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addFilteredPages(@NonNull Collection<@NonNull Filtered<@NonNull String>> pages);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/WrittenBookContent.java b/src/main/java/io/papermc/paper/datacomponent/item/WrittenBookContent.java
new file mode 100644
index 0000000000000000000000000000000000000000..6a3f6daae76e109b6c754752408fda73decc0335
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/item/WrittenBookContent.java
@@ -0,0 +1,99 @@
+package io.papermc.paper.datacomponent.item;
+
+import io.papermc.paper.datacomponent.DataComponentBuilder;
+import io.papermc.paper.util.Filtered;
+import java.util.Collection;
+import java.util.List;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.ComponentLike;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.common.value.qual.IntRange;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+
+/**
+ * Holds the contents and metadata of a Written Book.
+ */
+@ApiStatus.Experimental
+@ApiStatus.NonExtendable
+public interface WrittenBookContent {
+
+ @Contract(value = "_, _ -> new", pure = true)
+ static WrittenBookContent.@NonNull Builder writtenBookContent(final @NonNull String title, final @NonNull String author) {
+ return writtenBookContent(Filtered.of(title, null), author);
+ }
+
+ @Contract(value = "_, _ -> new", pure = true)
+ static WrittenBookContent.@NonNull Builder writtenBookContent(final @NonNull Filtered<@NonNull String> title, final @NonNull String author) {
+ return ComponentTypesBridge.bridge().writtenBookContent(title, author);
+ }
+
+ /**
+ * Title of this book.
+ *
+ * @return title
+ */
+ @Contract(pure = true)
+ @NonNull Filtered<@NonNull String> title();
+
+ /**
+ * Player name of the author of this book.
+ *
+ * @return author
+ */
+ @Contract(pure = true)
+ @NonNull String author();
+
+ /**
+ * The number of times this book has been copied (0 = original).
+ *
+ * @return generation
+ */
+ @Contract(pure = true)
+ @IntRange(from = 0, to = 3) int generation();
+
+ @Contract(pure = true)
+ @NonNull @Unmodifiable List<@NonNull Filtered<@NonNull Component>> pages();
+
+ /**
+ * If the chat components in this book have already been resolved (entity selectors, scores substituted).
+ * If {@code false}, will be resolved when opened by a player.
+ *
+ * @return resolved
+ */
+ @Contract(pure = true)
+ boolean resolved();
+
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends DataComponentBuilder<WrittenBookContent> {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder title(@NonNull String title);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder filteredTitle(@NonNull Filtered<@NonNull String> title);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder author(@NonNull String author);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder generation(@IntRange(from = 0, to = 3) int generation);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder resolved(boolean resolved);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addPage(@NonNull ComponentLike page);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addPages(@NonNull Collection<@NonNull ? extends ComponentLike> page);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addFilteredPage(@NonNull Filtered<@NonNull ? extends ComponentLike> page);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder addFilteredPages(@NonNull Collection<@NonNull Filtered<@NonNull ? extends ComponentLike>> pages);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datacomponent/package-info.java b/src/main/java/io/papermc/paper/datacomponent/package-info.java
new file mode 100644
index 0000000000000000000000000000000000000000..3ddd1f787e97c22eee3e32bb2a9660a8e300d7f9
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datacomponent/package-info.java
@@ -0,0 +1,5 @@
+@DefaultQualifier(NonNull.class)
+package io.papermc.paper.datacomponent;
+
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
diff --git a/src/main/java/io/papermc/paper/item/MapPostProcessing.java b/src/main/java/io/papermc/paper/item/MapPostProcessing.java
new file mode 100644
index 0000000000000000000000000000000000000000..5843768d0be2ae4a0219636ed7640727808da567
--- /dev/null
+++ b/src/main/java/io/papermc/paper/item/MapPostProcessing.java
@@ -0,0 +1,6 @@
+package io.papermc.paper.item;
+
+public enum MapPostProcessing {
+ LOCK,
+ SCALE
+}
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java
index 2945dde566682f977e84fde5d473a6c69be24df1..530cbadc8b4871113dc9ebb24bc565a95a61fdae 100644
--- a/src/main/java/io/papermc/paper/registry/RegistryKey.java
+++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java
@@ -1,5 +1,6 @@
package io.papermc.paper.registry;
+import io.papermc.paper.datacomponent.DataComponentType;
import net.kyori.adventure.key.Keyed;
import org.bukkit.Art;
import org.bukkit.Fluid;
@@ -81,6 +82,10 @@ public sealed interface RegistryKey<T> extends Keyed permits RegistryKeyImpl {
*/
@ApiStatus.Experimental // Paper - already required for registry builders
RegistryKey<ItemType> ITEM = create("item");
+ /**
+ * Built-in registry for data component types.
+ */
+ RegistryKey<DataComponentType> DATA_COMPONENT_TYPE = create("data_component_type");
/* ********************** *
diff --git a/src/main/java/io/papermc/paper/util/Filtered.java b/src/main/java/io/papermc/paper/util/Filtered.java
new file mode 100644
index 0000000000000000000000000000000000000000..6919f01a18bc0ab375d2e0541206524304243d19
--- /dev/null
+++ b/src/main/java/io/papermc/paper/util/Filtered.java
@@ -0,0 +1,30 @@
+package io.papermc.paper.util;
+
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+
+/**
+ * Denotes that this type is filterable by the client, and may be shown differently
+ * depending on the player's set configuration.
+ *
+ * @param <T> type of value
+ */
+@ApiStatus.Experimental
+public interface Filtered<T> {
+
+ @Contract(value = "_, _ -> new", pure = true)
+ static <T> @NonNull Filtered<T> of(final @NonNull T raw, final @Nullable T filtered) {
+ @ApiStatus.Internal
+ record Instance<T>(T raw, T filtered) implements Filtered<T> {}
+
+ return new Instance<>(raw, filtered);
+ }
+
+ @Contract(pure = true)
+ @NonNull T raw();
+
+ @Contract(pure = true)
+ @Nullable T filtered();
+}
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index 54704da43cf9c429f3914f0580246dde99aa93c0..87bc4ce78350d95b9337262ba585b44c77213722 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -130,7 +130,7 @@ import org.jetbrains.annotations.Nullable;
@SuppressWarnings({"DeprecatedIsStillUsed", "deprecation"}) // Paper
public enum Material implements Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper
//<editor-fold desc="Materials" defaultstate="collapsed">
- AIR(9648, 0),
+ AIR(9648, 64), // Paper - air technically stacks to 64
STONE(22948),
GRANITE(21091),
POLISHED_GRANITE(5477),
@@ -5599,6 +5599,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
*/
@ApiStatus.Internal
@Nullable
+ @org.jetbrains.annotations.Contract(pure = true) // Paper
public ItemType asItemType() {
Material material = this;
if (isLegacy()) {
@@ -5615,6 +5616,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
*/
@ApiStatus.Internal
@Nullable
+ @org.jetbrains.annotations.Contract(pure = true) // Paper
public BlockType asBlockType() {
Material material = this;
if (isLegacy()) {
@@ -5622,4 +5624,43 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
}
return Registry.BLOCK.get(material.key);
}
+
+ // Paper start - data component API
+ /**
+ * Gets the default value of the data component type for this item type.
+ *
+ * @param type the data component type
+ * @param <T> the value type
+ * @return the default value or {@code null} if there is none
+ * @see #hasDefaultData(io.papermc.paper.datacomponent.DataComponentType) for DataComponentType.NonValued
+ * @throws IllegalArgumentException if {@link #isItem()} is {@code false}
+ */
+ public @Nullable <T> T getDefaultData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued<T> type) {
+ Preconditions.checkArgument(this.asItemType() != null);
+ return this.asItemType().getDefaultData(type);
+ }
+
+ /**
+ * Checks if the data component type has a default value for this item type.
+ *
+ * @param type the data component type
+ * @return {@code true} if there is a default value
+ * @throws IllegalArgumentException if {@link #isItem()} is {@code false}
+ */
+ public boolean hasDefaultData(final io.papermc.paper.datacomponent.@NotNull DataComponentType type) {
+ Preconditions.checkArgument(this.asItemType() != null);
+ return this.asItemType().hasDefaultData(type);
+ }
+
+ /**
+ * Gets the default data component types for this item type.
+ *
+ * @return an immutable set of data component types
+ * @throws IllegalArgumentException if {@link #isItem()} is {@code false}
+ */
+ public java.util.@org.jetbrains.annotations.Unmodifiable @NotNull Set<io.papermc.paper.datacomponent.DataComponentType> getDefaultDataTypes() {
+ Preconditions.checkArgument(this.asItemType() != null);
+ return this.asItemType().getDefaultDataTypes();
+ }
+ // Paper end - data component API
}
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
index 20015393f91af405c99db2635a471fb6ff19e4bf..7ab29c3d0471d5eb2152ff749efc15ac9d24acf8 100644
--- a/src/main/java/org/bukkit/Registry.java
+++ b/src/main/java/org/bukkit/Registry.java
@@ -349,6 +349,8 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
return StreamSupport.stream(this.spliterator(), false);
}
};
+
+ Registry<io.papermc.paper.datacomponent.DataComponentType> DATA_COMPONENT_TYPE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.DATA_COMPONENT_TYPE); // Paper
// Paper end - potion effect type registry
/**
* Get the object by its key.
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
index b3abe3bde05d4a360e31e490bff8a859dc2bd4a6..794b3cf36f6ce4fb2c7957a4b259f8adf63090f3 100644
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
@@ -1,10 +1,10 @@
package org.bukkit.inventory;
import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableMap;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
+import io.papermc.paper.datacomponent.DataComponentBuilder;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
@@ -1033,4 +1033,149 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
return Bukkit.getUnsafe().computeTooltipLines(this, tooltipContext, player);
}
// Paper end - expose itemstack tooltip lines
+
+ // Paper start - data component API
+ /**
+ * Gets the value for the data component type on this stack.
+ *
+ * @param type the data component type
+ * @param <T> the value type
+ * @return the value for the data component type, or {@code null} if not set or marked as removed
+ * @see #hasData(io.papermc.paper.datacomponent.DataComponentType) for DataComponentType.NonValued
+ */
+ @org.jetbrains.annotations.Contract(pure = true)
+ public <T> @Nullable T getData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued<T> type) {
+ return this.craftDelegate.getData(type);
+ }
+
+ /**
+ * Gets the value for the data component type on this stack with
+ * a fallback value.
+ *
+ * @param type the data component type
+ * @param fallback the fallback value if the value isn't present
+ * @param <T> the value type
+ * @return the value for the data component type or the fallback value
+ */
+ @Utility
+ @org.jetbrains.annotations.Contract(value = "_, !null -> !null", pure = true)
+ public <T> @Nullable T getDataOrDefault(final io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued<? extends T> type, final @Nullable T fallback) {
+ final T object = this.getData(type);
+ return object != null ? object : fallback;
+ }
+
+ /**
+ * Checks if the data component type is set on the itemstack.
+ *
+ * @param type the data component type
+ * @return {@code true} if set, {@code false} otherwise
+ */
+ @org.jetbrains.annotations.Contract(pure = true)
+ public boolean hasData(final io.papermc.paper.datacomponent.@NotNull DataComponentType type) {
+ return this.craftDelegate.hasData(type);
+ }
+
+ /**
+ * Gets all the data component types set on this stack.
+ *
+ * @return an immutable set of data component types
+ */
+ @org.jetbrains.annotations.Contract("-> new")
+ public java.util.@org.jetbrains.annotations.Unmodifiable Set<io.papermc.paper.datacomponent.@NotNull DataComponentType> getDataTypes() {
+ return this.craftDelegate.getDataTypes();
+ }
+
+ /**
+ * Sets the value of the data component type for this itemstack. To
+ * reset the value to the default for the {@link #getType() item type}, use
+ * {@link #resetData(io.papermc.paper.datacomponent.DataComponentType)}. To mark the data component type
+ * as removed, use {@link #unsetData(io.papermc.paper.datacomponent.DataComponentType)}.
+ *
+ * @param type the data component type
+ * @param valueBuilder value builder
+ * @param <T> value type
+ */
+ @Utility
+ public <T> void setData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued<T> type, final @NotNull DataComponentBuilder<T> valueBuilder) {
+ this.setData(type, valueBuilder.build());
+ }
+
+ /**
+ * Sets the value of the data component type for this itemstack. To
+ * reset the value to the default for the {@link #getType() item type}, use
+ * {@link #resetData(io.papermc.paper.datacomponent.DataComponentType)}. To mark the data component type
+ * as removed, use {@link #unsetData(io.papermc.paper.datacomponent.DataComponentType)}.
+ *
+ * @param type the data component type
+ * @param value value to set
+ * @param <T> value type
+ */
+ public <T> void setData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued<T> type, final @NotNull T value) {
+ this.craftDelegate.setData(type, value);
+ }
+
+ /**
+ * Marks this non-valued data component type as present in this itemstack.
+ *
+ * @param type the data component type
+ */
+ public void setData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull NonValued type) {
+ this.craftDelegate.setData(type);
+ }
+
+ /**
+ * Marks this data component as removed for this itemstack.
+ *
+ * @param type the data component type
+ */
+ public void unsetData(final io.papermc.paper.datacomponent.@NotNull DataComponentType type) {
+ this.craftDelegate.unsetData(type);
+ }
+
+ /**
+ * Resets the value of this component to be the default
+ * value for the item type from {@link Material#getDefaultData(io.papermc.paper.datacomponent.DataComponentType.Valued)}.
+ *
+ * @param type the data component type
+ */
+ public void resetData(final io.papermc.paper.datacomponent.@NotNull DataComponentType type) {
+ this.craftDelegate.resetData(type);
+ }
+
+ /**
+ * Checks if the data component type is overridden from the default for the
+ * item type.
+ *
+ * @param type the data component type
+ * @return {@code true} if the data type is overridden
+ */
+ public boolean isOverridden(final io.papermc.paper.datacomponent.@NotNull DataComponentType type) {
+ return this.craftDelegate.isOverridden(type);
+ }
+
+ /**
+ * Checks if this itemstack matches another given itemstack excluding the provided components.
+ * This is useful if you are wanting to ignore certain properties of itemstacks, such as durability.
+ *
+ * @param item the item to compare
+ * @param exclude the data component types to ignore
+ * @return {@code true} if the provided item is equal, ignoring the provided components
+ */
+ public boolean matchesWithoutData(final @NotNull ItemStack item, final @NotNull java.util.Collection<io.papermc.paper.datacomponent.@NotNull DataComponentType> exclude) {
+ return this.matchesWithoutData(item, exclude, false);
+ }
+
+ /**
+ * Checks if this itemstack matches another given itemstack excluding the provided components.
+ * This is useful if you are wanting to ignore certain properties of itemstacks, such as durability.
+ *
+ * @param item the item to compare
+ * @param exclude the data component types to ignore
+ * @param ignoreCount ignore the count of the item
+ * @return {@code true} if the provided item is equal, ignoring the provided components
+ */
+ public boolean matchesWithoutData(final @NotNull ItemStack item, final @NotNull java.util.Collection<io.papermc.paper.datacomponent.@NotNull DataComponentType> exclude, final boolean ignoreCount) {
+ return this.craftDelegate.matchesWithoutData(item, exclude, ignoreCount);
+ }
+ // Paper end - data component API
}
diff --git a/src/main/java/org/bukkit/inventory/ItemType.java b/src/main/java/org/bukkit/inventory/ItemType.java
index 0168f0a14a3e899e84c5e36963ff79950ab580fb..6d0466a8a54531eaf51521b10047a27ef83d47b7 100644
--- a/src/main/java/org/bukkit/inventory/ItemType.java
+++ b/src/main/java/org/bukkit/inventory/ItemType.java
@@ -2336,4 +2336,30 @@ public interface ItemType extends Keyed, Translatable, net.kyori.adventure.trans
*/
@Nullable ItemRarity getItemRarity();
// Paper end - expand ItemRarity API
+ // Paper start - data component API
+ /**
+ * Gets the default value of the data component type for this item type.
+ *
+ * @param type the data component type
+ * @param <T> the value type
+ * @return the default value or {@code null} if there is none
+ * @see #hasDefaultData(io.papermc.paper.datacomponent.DataComponentType) for DataComponentType.NonValued
+ */
+ @Nullable <T> T getDefaultData(io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued<T> type);
+
+ /**
+ * Checks if the data component type has a default value for this item type.
+ *
+ * @param type the data component type
+ * @return {@code true} if there is a default value
+ */
+ boolean hasDefaultData(io.papermc.paper.datacomponent.@NotNull DataComponentType type);
+
+ /**
+ * Gets the default data component types for this item type.
+ *
+ * @return an immutable set of data component types
+ */
+ java.util.@org.jetbrains.annotations.Unmodifiable @NotNull Set<io.papermc.paper.datacomponent.DataComponentType> getDefaultDataTypes();
+ // Paper end - data component API
}
|