Spaces:
Build error
Build error
File size: 136,754 Bytes
d46f4a3 |
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 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 |
package net.minecraft.world.entity;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.collect.ImmutableList.Builder;
import com.mojang.logging.LogUtils;
import it.unimi.dsi.fastutil.floats.FloatArraySet;
import it.unimi.dsi.fastutil.floats.FloatArrays;
import it.unimi.dsi.fastutil.floats.FloatSet;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
import it.unimi.dsi.fastutil.objects.Object2DoubleArrayMap;
import it.unimi.dsi.fastutil.objects.Object2DoubleMap;
import it.unimi.dsi.fastutil.objects.ReferenceArraySet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
import java.util.function.Predicate;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import net.minecraft.BlockUtil;
import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory;
import net.minecraft.ReportedException;
import net.minecraft.Util;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.EntityAnchorArgument;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.SectionPos;
import net.minecraft.core.particles.BlockParticleOption;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.DoubleTag;
import net.minecraft.nbt.FloatTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
import net.minecraft.network.protocol.game.VecDeltaCodec;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SyncedDataHolder;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerEntity;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.TicketType;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.DamageTypeTags;
import net.minecraft.tags.EntityTypeTags;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.TagKey;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.util.profiling.Profiler;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.Nameable;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageSources;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.entity.projectile.ProjectileDeflection;
import net.minecraft.world.entity.vehicle.AbstractBoat;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FenceGateBlock;
import net.minecraft.world.level.block.HoneyBlock;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Portal;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.border.WorldBorder;
import net.minecraft.world.level.entity.EntityAccess;
import net.minecraft.world.level.entity.EntityInLevelCallback;
import net.minecraft.world.level.gameevent.DynamicGameEventListener;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.level.portal.PortalShape;
import net.minecraft.world.level.portal.TeleportTransition;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.scores.PlayerTeam;
import net.minecraft.world.scores.ScoreHolder;
import net.minecraft.world.scores.Team;
import org.slf4j.Logger;
public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder {
private static final Logger LOGGER = LogUtils.getLogger();
public static final String ID_TAG = "id";
public static final String PASSENGERS_TAG = "Passengers";
private static final AtomicInteger ENTITY_COUNTER = new AtomicInteger();
public static final int CONTENTS_SLOT_INDEX = 0;
public static final int BOARDING_COOLDOWN = 60;
public static final int TOTAL_AIR_SUPPLY = 300;
public static final int MAX_ENTITY_TAG_COUNT = 1024;
public static final float DELTA_AFFECTED_BY_BLOCKS_BELOW_0_2 = 0.2F;
public static final double DELTA_AFFECTED_BY_BLOCKS_BELOW_0_5 = 0.500001;
public static final double DELTA_AFFECTED_BY_BLOCKS_BELOW_1_0 = 0.999999;
public static final int BASE_TICKS_REQUIRED_TO_FREEZE = 140;
public static final int FREEZE_HURT_FREQUENCY = 40;
public static final int BASE_SAFE_FALL_DISTANCE = 3;
private static final AABB INITIAL_AABB = new AABB(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
private static final double WATER_FLOW_SCALE = 0.014;
private static final double LAVA_FAST_FLOW_SCALE = 0.007;
private static final double LAVA_SLOW_FLOW_SCALE = 0.0023333333333333335;
public static final String UUID_TAG = "UUID";
private static double viewScale = 1.0;
private final EntityType<?> type;
private int id = ENTITY_COUNTER.incrementAndGet();
public boolean blocksBuilding;
private ImmutableList<Entity> passengers = ImmutableList.of();
protected int boardingCooldown;
@Nullable
private Entity vehicle;
private Level level;
public double xo;
public double yo;
public double zo;
private Vec3 position;
private BlockPos blockPosition;
private ChunkPos chunkPosition;
private Vec3 deltaMovement = Vec3.ZERO;
private float yRot;
private float xRot;
public float yRotO;
public float xRotO;
private AABB bb = INITIAL_AABB;
private boolean onGround;
public boolean horizontalCollision;
public boolean verticalCollision;
public boolean verticalCollisionBelow;
public boolean minorHorizontalCollision;
public boolean hurtMarked;
protected Vec3 stuckSpeedMultiplier = Vec3.ZERO;
@Nullable
private Entity.RemovalReason removalReason;
public static final float DEFAULT_BB_WIDTH = 0.6F;
public static final float DEFAULT_BB_HEIGHT = 1.8F;
public float moveDist;
public float flyDist;
public float fallDistance;
private float nextStep = 1.0F;
public double xOld;
public double yOld;
public double zOld;
public boolean noPhysics;
private boolean wasOnFire;
protected final RandomSource random = RandomSource.create();
public int tickCount;
private int remainingFireTicks = -this.getFireImmuneTicks();
protected boolean wasTouchingWater;
protected Object2DoubleMap<TagKey<Fluid>> fluidHeight = new Object2DoubleArrayMap<>(2);
protected boolean wasEyeInWater;
private final Set<TagKey<Fluid>> fluidOnEyes = new HashSet<>();
public int invulnerableTime;
protected boolean firstTick = true;
protected final SynchedEntityData entityData;
protected static final EntityDataAccessor<Byte> DATA_SHARED_FLAGS_ID = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BYTE);
protected static final int FLAG_ONFIRE = 0;
private static final int FLAG_SHIFT_KEY_DOWN = 1;
private static final int FLAG_SPRINTING = 3;
private static final int FLAG_SWIMMING = 4;
private static final int FLAG_INVISIBLE = 5;
protected static final int FLAG_GLOWING = 6;
protected static final int FLAG_FALL_FLYING = 7;
private static final EntityDataAccessor<Integer> DATA_AIR_SUPPLY_ID = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.INT);
private static final EntityDataAccessor<Optional<Component>> DATA_CUSTOM_NAME = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.OPTIONAL_COMPONENT);
private static final EntityDataAccessor<Boolean> DATA_CUSTOM_NAME_VISIBLE = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BOOLEAN);
private static final EntityDataAccessor<Boolean> DATA_SILENT = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BOOLEAN);
private static final EntityDataAccessor<Boolean> DATA_NO_GRAVITY = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BOOLEAN);
protected static final EntityDataAccessor<Pose> DATA_POSE = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.POSE);
private static final EntityDataAccessor<Integer> DATA_TICKS_FROZEN = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.INT);
private EntityInLevelCallback levelCallback = EntityInLevelCallback.NULL;
private final VecDeltaCodec packetPositionCodec = new VecDeltaCodec();
public boolean hasImpulse;
@Nullable
public PortalProcessor portalProcess;
private int portalCooldown;
private boolean invulnerable;
protected UUID uuid = Mth.createInsecureUUID(this.random);
protected String stringUUID = this.uuid.toString();
private boolean hasGlowingTag;
private final Set<String> tags = Sets.newHashSet();
private final double[] pistonDeltas = new double[]{0.0, 0.0, 0.0};
private long pistonDeltasGameTime;
private EntityDimensions dimensions;
private float eyeHeight;
public boolean isInPowderSnow;
public boolean wasInPowderSnow;
public Optional<BlockPos> mainSupportingBlockPos = Optional.empty();
private boolean onGroundNoBlocks = false;
private float crystalSoundIntensity;
private int lastCrystalSoundPlayTick;
private boolean hasVisualFire;
@Nullable
private BlockState inBlockState = null;
private final List<Entity.Movement> movementThisTick = new ArrayList<>();
private final Set<BlockState> blocksInside = new ReferenceArraySet<>();
private final LongSet visitedBlocks = new LongOpenHashSet();
public Entity(EntityType<?> p_19870_, Level p_19871_) {
this.type = p_19870_;
this.level = p_19871_;
this.dimensions = p_19870_.getDimensions();
this.position = Vec3.ZERO;
this.blockPosition = BlockPos.ZERO;
this.chunkPosition = ChunkPos.ZERO;
SynchedEntityData.Builder synchedentitydata$builder = new SynchedEntityData.Builder(this);
synchedentitydata$builder.define(DATA_SHARED_FLAGS_ID, (byte)0);
synchedentitydata$builder.define(DATA_AIR_SUPPLY_ID, this.getMaxAirSupply());
synchedentitydata$builder.define(DATA_CUSTOM_NAME_VISIBLE, false);
synchedentitydata$builder.define(DATA_CUSTOM_NAME, Optional.empty());
synchedentitydata$builder.define(DATA_SILENT, false);
synchedentitydata$builder.define(DATA_NO_GRAVITY, false);
synchedentitydata$builder.define(DATA_POSE, Pose.STANDING);
synchedentitydata$builder.define(DATA_TICKS_FROZEN, 0);
this.defineSynchedData(synchedentitydata$builder);
this.entityData = synchedentitydata$builder.build();
this.setPos(0.0, 0.0, 0.0);
this.eyeHeight = this.dimensions.eyeHeight();
}
public boolean isColliding(BlockPos p_20040_, BlockState p_20041_) {
VoxelShape voxelshape = p_20041_.getCollisionShape(this.level(), p_20040_, CollisionContext.of(this));
VoxelShape voxelshape1 = voxelshape.move((double)p_20040_.getX(), (double)p_20040_.getY(), (double)p_20040_.getZ());
return Shapes.joinIsNotEmpty(voxelshape1, Shapes.create(this.getBoundingBox()), BooleanOp.AND);
}
public int getTeamColor() {
Team team = this.getTeam();
return team != null && team.getColor().getColor() != null ? team.getColor().getColor() : 16777215;
}
public boolean isSpectator() {
return false;
}
public final void unRide() {
if (this.isVehicle()) {
this.ejectPassengers();
}
if (this.isPassenger()) {
this.stopRiding();
}
}
public void syncPacketPositionCodec(double p_217007_, double p_217008_, double p_217009_) {
this.packetPositionCodec.setBase(new Vec3(p_217007_, p_217008_, p_217009_));
}
public VecDeltaCodec getPositionCodec() {
return this.packetPositionCodec;
}
public EntityType<?> getType() {
return this.type;
}
@Override
public int getId() {
return this.id;
}
public void setId(int p_20235_) {
this.id = p_20235_;
}
public Set<String> getTags() {
return this.tags;
}
public boolean addTag(String p_20050_) {
return this.tags.size() >= 1024 ? false : this.tags.add(p_20050_);
}
public boolean removeTag(String p_20138_) {
return this.tags.remove(p_20138_);
}
public void kill(ServerLevel p_362426_) {
this.remove(Entity.RemovalReason.KILLED);
this.gameEvent(GameEvent.ENTITY_DIE);
}
public final void discard() {
this.remove(Entity.RemovalReason.DISCARDED);
}
protected abstract void defineSynchedData(SynchedEntityData.Builder p_333664_);
public SynchedEntityData getEntityData() {
return this.entityData;
}
@Override
public boolean equals(Object p_20245_) {
return p_20245_ instanceof Entity ? ((Entity)p_20245_).id == this.id : false;
}
@Override
public int hashCode() {
return this.id;
}
public void remove(Entity.RemovalReason p_146834_) {
this.setRemoved(p_146834_);
}
public void onClientRemoval() {
}
public void onRemoval(Entity.RemovalReason p_364553_) {
}
public void setPose(Pose p_20125_) {
this.entityData.set(DATA_POSE, p_20125_);
}
public Pose getPose() {
return this.entityData.get(DATA_POSE);
}
public boolean hasPose(Pose p_217004_) {
return this.getPose() == p_217004_;
}
public boolean closerThan(Entity p_19951_, double p_19952_) {
return this.position().closerThan(p_19951_.position(), p_19952_);
}
public boolean closerThan(Entity p_216993_, double p_216994_, double p_216995_) {
double d0 = p_216993_.getX() - this.getX();
double d1 = p_216993_.getY() - this.getY();
double d2 = p_216993_.getZ() - this.getZ();
return Mth.lengthSquared(d0, d2) < Mth.square(p_216994_) && Mth.square(d1) < Mth.square(p_216995_);
}
protected void setRot(float p_19916_, float p_19917_) {
this.setYRot(p_19916_ % 360.0F);
this.setXRot(p_19917_ % 360.0F);
}
public final void setPos(Vec3 p_146885_) {
this.setPos(p_146885_.x(), p_146885_.y(), p_146885_.z());
}
public void setPos(double p_20210_, double p_20211_, double p_20212_) {
this.setPosRaw(p_20210_, p_20211_, p_20212_);
this.setBoundingBox(this.makeBoundingBox());
}
protected final AABB makeBoundingBox() {
return this.makeBoundingBox(this.position);
}
protected AABB makeBoundingBox(Vec3 p_377233_) {
return this.dimensions.makeBoundingBox(p_377233_);
}
protected void reapplyPosition() {
this.setPos(this.position.x, this.position.y, this.position.z);
}
public void turn(double p_19885_, double p_19886_) {
float f = (float)p_19886_ * 0.15F;
float f1 = (float)p_19885_ * 0.15F;
this.setXRot(this.getXRot() + f);
this.setYRot(this.getYRot() + f1);
this.setXRot(Mth.clamp(this.getXRot(), -90.0F, 90.0F));
this.xRotO += f;
this.yRotO += f1;
this.xRotO = Mth.clamp(this.xRotO, -90.0F, 90.0F);
if (this.vehicle != null) {
this.vehicle.onPassengerTurned(this);
}
}
public void tick() {
this.baseTick();
}
public void baseTick() {
ProfilerFiller profilerfiller = Profiler.get();
profilerfiller.push("entityBaseTick");
this.inBlockState = null;
if (this.isPassenger() && this.getVehicle().isRemoved()) {
this.stopRiding();
}
if (this.boardingCooldown > 0) {
this.boardingCooldown--;
}
this.handlePortal();
if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle();
}
this.wasInPowderSnow = this.isInPowderSnow;
this.isInPowderSnow = false;
this.updateInWaterStateAndDoFluidPushing();
this.updateFluidOnEyes();
this.updateSwimming();
if (this.level() instanceof ServerLevel serverlevel) {
if (this.remainingFireTicks > 0) {
if (this.fireImmune()) {
this.setRemainingFireTicks(this.remainingFireTicks - 4);
if (this.remainingFireTicks < 0) {
this.clearFire();
}
} else {
if (this.remainingFireTicks % 20 == 0 && !this.isInLava()) {
this.hurtServer(serverlevel, this.damageSources().onFire(), 1.0F);
}
this.setRemainingFireTicks(this.remainingFireTicks - 1);
}
if (this.getTicksFrozen() > 0) {
this.setTicksFrozen(0);
this.level().levelEvent(null, 1009, this.blockPosition, 1);
}
}
} else {
this.clearFire();
}
if (this.isInLava()) {
this.lavaHurt();
this.fallDistance *= 0.5F;
}
this.checkBelowWorld();
if (!this.level().isClientSide) {
this.setSharedFlagOnFire(this.remainingFireTicks > 0);
}
this.firstTick = false;
if (this.level() instanceof ServerLevel serverlevel1 && this instanceof Leashable) {
Leashable.tickLeash(serverlevel1, (Entity & Leashable)this);
}
profilerfiller.pop();
}
public void setSharedFlagOnFire(boolean p_146869_) {
this.setSharedFlag(0, p_146869_ || this.hasVisualFire);
}
public void checkBelowWorld() {
if (this.getY() < (double)(this.level().getMinY() - 64)) {
this.onBelowWorld();
}
}
public void setPortalCooldown() {
this.portalCooldown = this.getDimensionChangingDelay();
}
public void setPortalCooldown(int p_287760_) {
this.portalCooldown = p_287760_;
}
public int getPortalCooldown() {
return this.portalCooldown;
}
public boolean isOnPortalCooldown() {
return this.portalCooldown > 0;
}
protected void processPortalCooldown() {
if (this.isOnPortalCooldown()) {
this.portalCooldown--;
}
}
public void lavaHurt() {
if (!this.fireImmune()) {
this.igniteForSeconds(15.0F);
if (this.level() instanceof ServerLevel serverlevel
&& this.hurtServer(serverlevel, this.damageSources().lava(), 4.0F)
&& this.shouldPlayLavaHurtSound()
&& !this.isSilent()) {
serverlevel.playSound(
null,
this.getX(),
this.getY(),
this.getZ(),
SoundEvents.GENERIC_BURN,
this.getSoundSource(),
0.4F,
2.0F + this.random.nextFloat() * 0.4F
);
}
}
}
protected boolean shouldPlayLavaHurtSound() {
return true;
}
public final void igniteForSeconds(float p_344126_) {
this.igniteForTicks(Mth.floor(p_344126_ * 20.0F));
}
public void igniteForTicks(int p_328241_) {
if (this.remainingFireTicks < p_328241_) {
this.setRemainingFireTicks(p_328241_);
}
}
public void setRemainingFireTicks(int p_20269_) {
this.remainingFireTicks = p_20269_;
}
public int getRemainingFireTicks() {
return this.remainingFireTicks;
}
public void clearFire() {
this.setRemainingFireTicks(0);
}
protected void onBelowWorld() {
this.discard();
}
public boolean isFree(double p_20230_, double p_20231_, double p_20232_) {
return this.isFree(this.getBoundingBox().move(p_20230_, p_20231_, p_20232_));
}
private boolean isFree(AABB p_20132_) {
return this.level().noCollision(this, p_20132_) && !this.level().containsAnyLiquid(p_20132_);
}
public void setOnGround(boolean p_20181_) {
this.onGround = p_20181_;
this.checkSupportingBlock(p_20181_, null);
}
public void setOnGroundWithMovement(boolean p_376129_, Vec3 p_377695_) {
this.setOnGroundWithMovement(p_376129_, this.horizontalCollision, p_377695_);
}
public void setOnGroundWithMovement(boolean p_289661_, boolean p_369296_, Vec3 p_289653_) {
this.onGround = p_289661_;
this.horizontalCollision = p_369296_;
this.checkSupportingBlock(p_289661_, p_289653_);
}
public boolean isSupportedBy(BlockPos p_287613_) {
return this.mainSupportingBlockPos.isPresent() && this.mainSupportingBlockPos.get().equals(p_287613_);
}
protected void checkSupportingBlock(boolean p_289694_, @Nullable Vec3 p_289680_) {
if (p_289694_) {
AABB aabb = this.getBoundingBox();
AABB aabb1 = new AABB(aabb.minX, aabb.minY - 1.0E-6, aabb.minZ, aabb.maxX, aabb.minY, aabb.maxZ);
Optional<BlockPos> optional = this.level.findSupportingBlock(this, aabb1);
if (optional.isPresent() || this.onGroundNoBlocks) {
this.mainSupportingBlockPos = optional;
} else if (p_289680_ != null) {
AABB aabb2 = aabb1.move(-p_289680_.x, 0.0, -p_289680_.z);
optional = this.level.findSupportingBlock(this, aabb2);
this.mainSupportingBlockPos = optional;
}
this.onGroundNoBlocks = optional.isEmpty();
} else {
this.onGroundNoBlocks = false;
if (this.mainSupportingBlockPos.isPresent()) {
this.mainSupportingBlockPos = Optional.empty();
}
}
}
public boolean onGround() {
return this.onGround;
}
public void move(MoverType p_19973_, Vec3 p_19974_) {
if (this.noPhysics) {
this.setPos(this.getX() + p_19974_.x, this.getY() + p_19974_.y, this.getZ() + p_19974_.z);
} else {
this.wasOnFire = this.isOnFire();
if (p_19973_ == MoverType.PISTON) {
p_19974_ = this.limitPistonMovement(p_19974_);
if (p_19974_.equals(Vec3.ZERO)) {
return;
}
}
ProfilerFiller profilerfiller = Profiler.get();
profilerfiller.push("move");
if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7) {
p_19974_ = p_19974_.multiply(this.stuckSpeedMultiplier);
this.stuckSpeedMultiplier = Vec3.ZERO;
this.setDeltaMovement(Vec3.ZERO);
}
p_19974_ = this.maybeBackOffFromEdge(p_19974_, p_19973_);
Vec3 vec3 = this.collide(p_19974_);
double d0 = vec3.lengthSqr();
if (d0 > 1.0E-7 || p_19974_.lengthSqr() - d0 < 1.0E-7) {
if (this.fallDistance != 0.0F && d0 >= 1.0) {
BlockHitResult blockhitresult = this.level()
.clip(
new ClipContext(
this.position(), this.position().add(vec3), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this
)
);
if (blockhitresult.getType() != HitResult.Type.MISS) {
this.resetFallDistance();
}
}
this.setPos(this.getX() + vec3.x, this.getY() + vec3.y, this.getZ() + vec3.z);
}
profilerfiller.pop();
profilerfiller.push("rest");
boolean flag1 = !Mth.equal(p_19974_.x, vec3.x);
boolean flag = !Mth.equal(p_19974_.z, vec3.z);
this.horizontalCollision = flag1 || flag;
if (Math.abs(p_19974_.y) > 0.0 || this.isControlledByOrIsLocalPlayer()) {
this.verticalCollision = p_19974_.y != vec3.y;
this.verticalCollisionBelow = this.verticalCollision && p_19974_.y < 0.0;
this.setOnGroundWithMovement(this.verticalCollisionBelow, this.horizontalCollision, vec3);
}
if (this.horizontalCollision) {
this.minorHorizontalCollision = this.isHorizontalCollisionMinor(vec3);
} else {
this.minorHorizontalCollision = false;
}
BlockPos blockpos = this.getOnPosLegacy();
BlockState blockstate = this.level().getBlockState(blockpos);
if ((!this.level().isClientSide() || this.isControlledByLocalInstance()) && !this.isControlledByClient()) {
this.checkFallDamage(vec3.y, this.onGround(), blockstate, blockpos);
}
if (this.isRemoved()) {
profilerfiller.pop();
} else {
if (this.horizontalCollision) {
Vec3 vec31 = this.getDeltaMovement();
this.setDeltaMovement(flag1 ? 0.0 : vec31.x, vec31.y, flag ? 0.0 : vec31.z);
}
if (this.isControlledByLocalInstance()) {
Block block = blockstate.getBlock();
if (p_19974_.y != vec3.y) {
block.updateEntityMovementAfterFallOn(this.level(), this);
}
}
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) {
Entity.MovementEmission entity$movementemission = this.getMovementEmission();
if (entity$movementemission.emitsAnything() && !this.isPassenger()) {
this.applyMovementEmissionAndPlaySound(entity$movementemission, vec3, blockpos, blockstate);
}
}
float f = this.getBlockSpeedFactor();
this.setDeltaMovement(this.getDeltaMovement().multiply((double)f, 1.0, (double)f));
profilerfiller.pop();
}
}
}
private void applyMovementEmissionAndPlaySound(Entity.MovementEmission p_363290_, Vec3 p_364005_, BlockPos p_361951_, BlockState p_369205_) {
float f = 0.6F;
float f1 = (float)(p_364005_.length() * 0.6F);
float f2 = (float)(p_364005_.horizontalDistance() * 0.6F);
BlockPos blockpos = this.getOnPos();
BlockState blockstate = this.level().getBlockState(blockpos);
boolean flag = this.isStateClimbable(blockstate);
this.moveDist += flag ? f1 : f2;
this.flyDist += f1;
if (this.moveDist > this.nextStep && !blockstate.isAir()) {
boolean flag1 = blockpos.equals(p_361951_);
boolean flag2 = this.vibrationAndSoundEffectsFromBlock(p_361951_, p_369205_, p_363290_.emitsSounds(), flag1, p_364005_);
if (!flag1) {
flag2 |= this.vibrationAndSoundEffectsFromBlock(blockpos, blockstate, false, p_363290_.emitsEvents(), p_364005_);
}
if (flag2) {
this.nextStep = this.nextStep();
} else if (this.isInWater()) {
this.nextStep = this.nextStep();
if (p_363290_.emitsSounds()) {
this.waterSwimSound();
}
if (p_363290_.emitsEvents()) {
this.gameEvent(GameEvent.SWIM);
}
}
} else if (blockstate.isAir()) {
this.processFlappingMovement();
}
}
public void applyEffectsFromBlocks() {
this.applyEffectsFromBlocks(this.oldPosition(), this.position);
}
public void applyEffectsFromBlocks(Vec3 p_367330_, Vec3 p_363556_) {
if (this.isAffectedByBlocks()) {
if (this.onGround()) {
BlockPos blockpos = this.getOnPosLegacy();
BlockState blockstate = this.level().getBlockState(blockpos);
blockstate.getBlock().stepOn(this.level(), blockpos, blockstate, this);
}
this.movementThisTick.add(new Entity.Movement(p_367330_, p_363556_));
List<Entity.Movement> list = List.copyOf(this.movementThisTick);
this.movementThisTick.clear();
this.checkInsideBlocks(list, this.blocksInside);
boolean flag = Iterables.any(this.blocksInside, p_20127_ -> p_20127_.is(BlockTags.FIRE) || p_20127_.is(Blocks.LAVA));
this.blocksInside.clear();
if (!flag && this.isAlive()) {
if (this.remainingFireTicks <= 0) {
this.setRemainingFireTicks(-this.getFireImmuneTicks());
}
if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble())) {
this.playEntityOnFireExtinguishedSound();
}
}
if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble())) {
this.setRemainingFireTicks(-this.getFireImmuneTicks());
}
}
}
protected boolean isAffectedByBlocks() {
return !this.isRemoved() && !this.noPhysics;
}
private boolean isStateClimbable(BlockState p_286733_) {
return p_286733_.is(BlockTags.CLIMBABLE) || p_286733_.is(Blocks.POWDER_SNOW);
}
private boolean vibrationAndSoundEffectsFromBlock(BlockPos p_286221_, BlockState p_286549_, boolean p_286708_, boolean p_286543_, Vec3 p_286448_) {
if (p_286549_.isAir()) {
return false;
} else {
boolean flag = this.isStateClimbable(p_286549_);
if ((this.onGround() || flag || this.isCrouching() && p_286448_.y == 0.0 || this.isOnRails()) && !this.isSwimming()) {
if (p_286708_) {
this.walkingStepSound(p_286221_, p_286549_);
}
if (p_286543_) {
this.level().gameEvent(GameEvent.STEP, this.position(), GameEvent.Context.of(this, p_286549_));
}
return true;
} else {
return false;
}
}
}
protected boolean isHorizontalCollisionMinor(Vec3 p_196625_) {
return false;
}
protected void playEntityOnFireExtinguishedSound() {
this.playSound(SoundEvents.GENERIC_EXTINGUISH_FIRE, 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
}
public void extinguishFire() {
if (!this.level().isClientSide && this.wasOnFire) {
this.playEntityOnFireExtinguishedSound();
}
this.clearFire();
}
protected void processFlappingMovement() {
if (this.isFlapping()) {
this.onFlap();
if (this.getMovementEmission().emitsEvents()) {
this.gameEvent(GameEvent.FLAP);
}
}
}
@Deprecated
public BlockPos getOnPosLegacy() {
return this.getOnPos(0.2F);
}
public BlockPos getBlockPosBelowThatAffectsMyMovement() {
return this.getOnPos(0.500001F);
}
public BlockPos getOnPos() {
return this.getOnPos(1.0E-5F);
}
protected BlockPos getOnPos(float p_216987_) {
if (this.mainSupportingBlockPos.isPresent()) {
BlockPos blockpos = this.mainSupportingBlockPos.get();
if (!(p_216987_ > 1.0E-5F)) {
return blockpos;
} else {
BlockState blockstate = this.level().getBlockState(blockpos);
return (!((double)p_216987_ <= 0.5) || !blockstate.is(BlockTags.FENCES))
&& !blockstate.is(BlockTags.WALLS)
&& !(blockstate.getBlock() instanceof FenceGateBlock)
? blockpos.atY(Mth.floor(this.position.y - (double)p_216987_))
: blockpos;
}
} else {
int i = Mth.floor(this.position.x);
int j = Mth.floor(this.position.y - (double)p_216987_);
int k = Mth.floor(this.position.z);
return new BlockPos(i, j, k);
}
}
protected float getBlockJumpFactor() {
float f = this.level().getBlockState(this.blockPosition()).getBlock().getJumpFactor();
float f1 = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getJumpFactor();
return (double)f == 1.0 ? f1 : f;
}
protected float getBlockSpeedFactor() {
BlockState blockstate = this.level().getBlockState(this.blockPosition());
float f = blockstate.getBlock().getSpeedFactor();
if (!blockstate.is(Blocks.WATER) && !blockstate.is(Blocks.BUBBLE_COLUMN)) {
return (double)f == 1.0 ? this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getSpeedFactor() : f;
} else {
return f;
}
}
protected Vec3 maybeBackOffFromEdge(Vec3 p_20019_, MoverType p_20020_) {
return p_20019_;
}
protected Vec3 limitPistonMovement(Vec3 p_20134_) {
if (p_20134_.lengthSqr() <= 1.0E-7) {
return p_20134_;
} else {
long i = this.level().getGameTime();
if (i != this.pistonDeltasGameTime) {
Arrays.fill(this.pistonDeltas, 0.0);
this.pistonDeltasGameTime = i;
}
if (p_20134_.x != 0.0) {
double d2 = this.applyPistonMovementRestriction(Direction.Axis.X, p_20134_.x);
return Math.abs(d2) <= 1.0E-5F ? Vec3.ZERO : new Vec3(d2, 0.0, 0.0);
} else if (p_20134_.y != 0.0) {
double d1 = this.applyPistonMovementRestriction(Direction.Axis.Y, p_20134_.y);
return Math.abs(d1) <= 1.0E-5F ? Vec3.ZERO : new Vec3(0.0, d1, 0.0);
} else if (p_20134_.z != 0.0) {
double d0 = this.applyPistonMovementRestriction(Direction.Axis.Z, p_20134_.z);
return Math.abs(d0) <= 1.0E-5F ? Vec3.ZERO : new Vec3(0.0, 0.0, d0);
} else {
return Vec3.ZERO;
}
}
}
private double applyPistonMovementRestriction(Direction.Axis p_20043_, double p_20044_) {
int i = p_20043_.ordinal();
double d0 = Mth.clamp(p_20044_ + this.pistonDeltas[i], -0.51, 0.51);
p_20044_ = d0 - this.pistonDeltas[i];
this.pistonDeltas[i] = d0;
return p_20044_;
}
private Vec3 collide(Vec3 p_20273_) {
AABB aabb = this.getBoundingBox();
List<VoxelShape> list = this.level().getEntityCollisions(this, aabb.expandTowards(p_20273_));
Vec3 vec3 = p_20273_.lengthSqr() == 0.0 ? p_20273_ : collideBoundingBox(this, p_20273_, aabb, this.level(), list);
boolean flag = p_20273_.x != vec3.x;
boolean flag1 = p_20273_.y != vec3.y;
boolean flag2 = p_20273_.z != vec3.z;
boolean flag3 = flag1 && p_20273_.y < 0.0;
if (this.maxUpStep() > 0.0F && (flag3 || this.onGround()) && (flag || flag2)) {
AABB aabb1 = flag3 ? aabb.move(0.0, vec3.y, 0.0) : aabb;
AABB aabb2 = aabb1.expandTowards(p_20273_.x, (double)this.maxUpStep(), p_20273_.z);
if (!flag3) {
aabb2 = aabb2.expandTowards(0.0, -1.0E-5F, 0.0);
}
List<VoxelShape> list1 = collectColliders(this, this.level, list, aabb2);
float f = (float)vec3.y;
float[] afloat = collectCandidateStepUpHeights(aabb1, list1, this.maxUpStep(), f);
for (float f1 : afloat) {
Vec3 vec31 = collideWithShapes(new Vec3(p_20273_.x, (double)f1, p_20273_.z), aabb1, list1);
if (vec31.horizontalDistanceSqr() > vec3.horizontalDistanceSqr()) {
double d0 = aabb.minY - aabb1.minY;
return vec31.add(0.0, -d0, 0.0);
}
}
}
return vec3;
}
private static float[] collectCandidateStepUpHeights(AABB p_343635_, List<VoxelShape> p_345320_, float p_342502_, float p_345523_) {
FloatSet floatset = new FloatArraySet(4);
for (VoxelShape voxelshape : p_345320_) {
for (double d0 : voxelshape.getCoords(Direction.Axis.Y)) {
float f = (float)(d0 - p_343635_.minY);
if (!(f < 0.0F) && f != p_345523_) {
if (f > p_342502_) {
break;
}
floatset.add(f);
}
}
}
float[] afloat = floatset.toFloatArray();
FloatArrays.unstableSort(afloat);
return afloat;
}
public static Vec3 collideBoundingBox(@Nullable Entity p_198895_, Vec3 p_198896_, AABB p_198897_, Level p_198898_, List<VoxelShape> p_198899_) {
List<VoxelShape> list = collectColliders(p_198895_, p_198898_, p_198899_, p_198897_.expandTowards(p_198896_));
return collideWithShapes(p_198896_, p_198897_, list);
}
private static List<VoxelShape> collectColliders(@Nullable Entity p_345018_, Level p_342100_, List<VoxelShape> p_344721_, AABB p_344685_) {
Builder<VoxelShape> builder = ImmutableList.builderWithExpectedSize(p_344721_.size() + 1);
if (!p_344721_.isEmpty()) {
builder.addAll(p_344721_);
}
WorldBorder worldborder = p_342100_.getWorldBorder();
boolean flag = p_345018_ != null && worldborder.isInsideCloseToBorder(p_345018_, p_344685_);
if (flag) {
builder.add(worldborder.getCollisionShape());
}
builder.addAll(p_342100_.getBlockCollisions(p_345018_, p_344685_));
return builder.build();
}
private static Vec3 collideWithShapes(Vec3 p_198901_, AABB p_198902_, List<VoxelShape> p_198903_) {
if (p_198903_.isEmpty()) {
return p_198901_;
} else {
double d0 = p_198901_.x;
double d1 = p_198901_.y;
double d2 = p_198901_.z;
if (d1 != 0.0) {
d1 = Shapes.collide(Direction.Axis.Y, p_198902_, p_198903_, d1);
if (d1 != 0.0) {
p_198902_ = p_198902_.move(0.0, d1, 0.0);
}
}
boolean flag = Math.abs(d0) < Math.abs(d2);
if (flag && d2 != 0.0) {
d2 = Shapes.collide(Direction.Axis.Z, p_198902_, p_198903_, d2);
if (d2 != 0.0) {
p_198902_ = p_198902_.move(0.0, 0.0, d2);
}
}
if (d0 != 0.0) {
d0 = Shapes.collide(Direction.Axis.X, p_198902_, p_198903_, d0);
if (!flag && d0 != 0.0) {
p_198902_ = p_198902_.move(d0, 0.0, 0.0);
}
}
if (!flag && d2 != 0.0) {
d2 = Shapes.collide(Direction.Axis.Z, p_198902_, p_198903_, d2);
}
return new Vec3(d0, d1, d2);
}
}
protected float nextStep() {
return (float)((int)this.moveDist + 1);
}
protected SoundEvent getSwimSound() {
return SoundEvents.GENERIC_SWIM;
}
protected SoundEvent getSwimSplashSound() {
return SoundEvents.GENERIC_SPLASH;
}
protected SoundEvent getSwimHighSpeedSplashSound() {
return SoundEvents.GENERIC_SPLASH;
}
public void recordMovementThroughBlocks(Vec3 p_363596_, Vec3 p_366313_) {
this.movementThisTick.add(new Entity.Movement(p_363596_, p_366313_));
}
private void checkInsideBlocks(List<Entity.Movement> p_362104_, Set<BlockState> p_362208_) {
if (this.isAffectedByBlocks()) {
LongSet longset = this.visitedBlocks;
for (Entity.Movement entity$movement : p_362104_) {
Vec3 vec3 = entity$movement.from();
Vec3 vec31 = entity$movement.to();
AABB aabb = this.makeBoundingBox(vec31).deflate(1.0E-5F);
for (BlockPos blockpos : BlockGetter.boxTraverseBlocks(vec3, vec31, aabb)) {
if (!this.isAlive()) {
return;
}
BlockState blockstate = this.level().getBlockState(blockpos);
if (!blockstate.isAir() && longset.add(blockpos.asLong())) {
try {
VoxelShape voxelshape = blockstate.getEntityInsideCollisionShape(this.level(), blockpos);
if (voxelshape != Shapes.block() && !this.collidedWithShapeMovingFrom(vec3, vec31, blockpos, voxelshape)) {
continue;
}
blockstate.entityInside(this.level(), blockpos, this);
this.onInsideBlock(blockstate);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Colliding entity with block");
CrashReportCategory crashreportcategory = crashreport.addCategory("Block being collided with");
CrashReportCategory.populateBlockDetails(crashreportcategory, this.level(), blockpos, blockstate);
CrashReportCategory crashreportcategory1 = crashreport.addCategory("Entity being checked for collision");
this.fillCrashReportCategory(crashreportcategory1);
throw new ReportedException(crashreport);
}
p_362208_.add(blockstate);
}
}
}
longset.clear();
}
}
private boolean collidedWithShapeMovingFrom(Vec3 p_365404_, Vec3 p_368726_, BlockPos p_363967_, VoxelShape p_369376_) {
AABB aabb = this.makeBoundingBox(p_365404_);
Vec3 vec3 = p_368726_.subtract(p_365404_);
return aabb.collidedAlongVector(vec3, p_369376_.move(new Vec3(p_363967_)).toAabbs());
}
protected void onInsideBlock(BlockState p_20005_) {
}
public BlockPos adjustSpawnLocation(ServerLevel p_343052_, BlockPos p_342908_) {
BlockPos blockpos = p_343052_.getSharedSpawnPos();
Vec3 vec3 = blockpos.getCenter();
int i = p_343052_.getChunkAt(blockpos).getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, blockpos.getX(), blockpos.getZ()) + 1;
return BlockPos.containing(vec3.x, (double)i, vec3.z);
}
public void gameEvent(Holder<GameEvent> p_335862_, @Nullable Entity p_146854_) {
this.level().gameEvent(p_146854_, p_335862_, this.position);
}
public void gameEvent(Holder<GameEvent> p_334998_) {
this.gameEvent(p_334998_, this);
}
private void walkingStepSound(BlockPos p_281828_, BlockState p_282118_) {
this.playStepSound(p_281828_, p_282118_);
if (this.shouldPlayAmethystStepSound(p_282118_)) {
this.playAmethystStepSound();
}
}
protected void waterSwimSound() {
Entity entity = Objects.requireNonNullElse(this.getControllingPassenger(), this);
float f = entity == this ? 0.35F : 0.4F;
Vec3 vec3 = entity.getDeltaMovement();
float f1 = Math.min(
1.0F, (float)Math.sqrt(vec3.x * vec3.x * 0.2F + vec3.y * vec3.y + vec3.z * vec3.z * 0.2F) * f
);
this.playSwimSound(f1);
}
protected BlockPos getPrimaryStepSoundBlockPos(BlockPos p_278049_) {
BlockPos blockpos = p_278049_.above();
BlockState blockstate = this.level().getBlockState(blockpos);
return !blockstate.is(BlockTags.INSIDE_STEP_SOUND_BLOCKS) && !blockstate.is(BlockTags.COMBINATION_STEP_SOUND_BLOCKS) ? p_278049_ : blockpos;
}
protected void playCombinationStepSounds(BlockState p_277472_, BlockState p_277630_) {
SoundType soundtype = p_277472_.getSoundType();
this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
this.playMuffledStepSound(p_277630_);
}
protected void playMuffledStepSound(BlockState p_283110_) {
SoundType soundtype = p_283110_.getSoundType();
this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.05F, soundtype.getPitch() * 0.8F);
}
protected void playStepSound(BlockPos p_20135_, BlockState p_20136_) {
SoundType soundtype = p_20136_.getSoundType();
this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
private boolean shouldPlayAmethystStepSound(BlockState p_278069_) {
return p_278069_.is(BlockTags.CRYSTAL_SOUND_BLOCKS) && this.tickCount >= this.lastCrystalSoundPlayTick + 20;
}
private void playAmethystStepSound() {
this.crystalSoundIntensity = this.crystalSoundIntensity * (float)Math.pow(0.997, (double)(this.tickCount - this.lastCrystalSoundPlayTick));
this.crystalSoundIntensity = Math.min(1.0F, this.crystalSoundIntensity + 0.07F);
float f = 0.5F + this.crystalSoundIntensity * this.random.nextFloat() * 1.2F;
float f1 = 0.1F + this.crystalSoundIntensity * 1.2F;
this.playSound(SoundEvents.AMETHYST_BLOCK_CHIME, f1, f);
this.lastCrystalSoundPlayTick = this.tickCount;
}
protected void playSwimSound(float p_20213_) {
this.playSound(this.getSwimSound(), p_20213_, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
}
protected void onFlap() {
}
protected boolean isFlapping() {
return false;
}
public void playSound(SoundEvent p_19938_, float p_19939_, float p_19940_) {
if (!this.isSilent()) {
this.level().playSound(null, this.getX(), this.getY(), this.getZ(), p_19938_, this.getSoundSource(), p_19939_, p_19940_);
}
}
public void playSound(SoundEvent p_216991_) {
if (!this.isSilent()) {
this.playSound(p_216991_, 1.0F, 1.0F);
}
}
public boolean isSilent() {
return this.entityData.get(DATA_SILENT);
}
public void setSilent(boolean p_20226_) {
this.entityData.set(DATA_SILENT, p_20226_);
}
public boolean isNoGravity() {
return this.entityData.get(DATA_NO_GRAVITY);
}
public void setNoGravity(boolean p_20243_) {
this.entityData.set(DATA_NO_GRAVITY, p_20243_);
}
protected double getDefaultGravity() {
return 0.0;
}
public final double getGravity() {
return this.isNoGravity() ? 0.0 : this.getDefaultGravity();
}
protected void applyGravity() {
double d0 = this.getGravity();
if (d0 != 0.0) {
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -d0, 0.0));
}
}
protected Entity.MovementEmission getMovementEmission() {
return Entity.MovementEmission.ALL;
}
public boolean dampensVibrations() {
return false;
}
public final void doCheckFallDamage(double p_376543_, double p_378417_, double p_377604_, boolean p_377156_) {
if (!this.touchingUnloadedChunk()) {
this.checkSupportingBlock(p_377156_, new Vec3(p_376543_, p_378417_, p_377604_));
BlockPos blockpos = this.getOnPosLegacy();
BlockState blockstate = this.level().getBlockState(blockpos);
this.checkFallDamage(p_378417_, p_377156_, blockstate, blockpos);
}
}
protected void checkFallDamage(double p_19911_, boolean p_19912_, BlockState p_19913_, BlockPos p_19914_) {
if (p_19912_) {
if (this.fallDistance > 0.0F) {
p_19913_.getBlock().fallOn(this.level(), p_19913_, p_19914_, this, this.fallDistance);
this.level()
.gameEvent(
GameEvent.HIT_GROUND,
this.position,
GameEvent.Context.of(this, this.mainSupportingBlockPos.<BlockState>map(p_286200_ -> this.level().getBlockState(p_286200_)).orElse(p_19913_))
);
}
this.resetFallDistance();
} else if (p_19911_ < 0.0) {
this.fallDistance -= (float)p_19911_;
}
}
public boolean fireImmune() {
return this.getType().fireImmune();
}
public boolean causeFallDamage(float p_146828_, float p_146829_, DamageSource p_146830_) {
if (this.type.is(EntityTypeTags.FALL_DAMAGE_IMMUNE)) {
return false;
} else {
if (this.isVehicle()) {
for (Entity entity : this.getPassengers()) {
entity.causeFallDamage(p_146828_, p_146829_, p_146830_);
}
}
return false;
}
}
public boolean isInWater() {
return this.wasTouchingWater;
}
private boolean isInRain() {
BlockPos blockpos = this.blockPosition();
return this.level().isRainingAt(blockpos)
|| this.level().isRainingAt(BlockPos.containing((double)blockpos.getX(), this.getBoundingBox().maxY, (double)blockpos.getZ()));
}
private boolean isInBubbleColumn() {
return this.getInBlockState().is(Blocks.BUBBLE_COLUMN);
}
public boolean isInWaterOrRain() {
return this.isInWater() || this.isInRain();
}
public boolean isInWaterRainOrBubble() {
return this.isInWater() || this.isInRain() || this.isInBubbleColumn();
}
public boolean isInWaterOrBubble() {
return this.isInWater() || this.isInBubbleColumn();
}
public boolean isInLiquid() {
return this.isInWaterOrBubble() || this.isInLava();
}
public boolean isUnderWater() {
return this.wasEyeInWater && this.isInWater();
}
public void updateSwimming() {
if (this.isSwimming()) {
this.setSwimming(this.isSprinting() && this.isInWater() && !this.isPassenger());
} else {
this.setSwimming(this.isSprinting() && this.isUnderWater() && !this.isPassenger() && this.level().getFluidState(this.blockPosition).is(FluidTags.WATER));
}
}
protected boolean updateInWaterStateAndDoFluidPushing() {
this.fluidHeight.clear();
this.updateInWaterStateAndDoWaterCurrentPushing();
double d0 = this.level().dimensionType().ultraWarm() ? 0.007 : 0.0023333333333333335;
boolean flag = this.updateFluidHeightAndDoFluidPushing(FluidTags.LAVA, d0);
return this.isInWater() || flag;
}
void updateInWaterStateAndDoWaterCurrentPushing() {
if (this.getVehicle() instanceof AbstractBoat abstractboat && !abstractboat.isUnderWater()) {
this.wasTouchingWater = false;
return;
}
if (this.updateFluidHeightAndDoFluidPushing(FluidTags.WATER, 0.014)) {
if (!this.wasTouchingWater && !this.firstTick) {
this.doWaterSplashEffect();
}
this.resetFallDistance();
this.wasTouchingWater = true;
this.clearFire();
} else {
this.wasTouchingWater = false;
}
}
private void updateFluidOnEyes() {
this.wasEyeInWater = this.isEyeInFluid(FluidTags.WATER);
this.fluidOnEyes.clear();
double d0 = this.getEyeY();
if (this.getVehicle() instanceof AbstractBoat abstractboat
&& !abstractboat.isUnderWater()
&& abstractboat.getBoundingBox().maxY >= d0
&& abstractboat.getBoundingBox().minY <= d0) {
return;
}
BlockPos blockpos = BlockPos.containing(this.getX(), d0, this.getZ());
FluidState fluidstate = this.level().getFluidState(blockpos);
double d1 = (double)((float)blockpos.getY() + fluidstate.getHeight(this.level(), blockpos));
if (d1 > d0) {
fluidstate.getTags().forEach(this.fluidOnEyes::add);
}
}
protected void doWaterSplashEffect() {
Entity entity = Objects.requireNonNullElse(this.getControllingPassenger(), this);
float f = entity == this ? 0.2F : 0.9F;
Vec3 vec3 = entity.getDeltaMovement();
float f1 = Math.min(
1.0F, (float)Math.sqrt(vec3.x * vec3.x * 0.2F + vec3.y * vec3.y + vec3.z * vec3.z * 0.2F) * f
);
if (f1 < 0.25F) {
this.playSound(this.getSwimSplashSound(), f1, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
} else {
this.playSound(this.getSwimHighSpeedSplashSound(), f1, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
}
float f2 = (float)Mth.floor(this.getY());
for (int i = 0; (float)i < 1.0F + this.dimensions.width() * 20.0F; i++) {
double d0 = (this.random.nextDouble() * 2.0 - 1.0) * (double)this.dimensions.width();
double d1 = (this.random.nextDouble() * 2.0 - 1.0) * (double)this.dimensions.width();
this.level()
.addParticle(
ParticleTypes.BUBBLE,
this.getX() + d0,
(double)(f2 + 1.0F),
this.getZ() + d1,
vec3.x,
vec3.y - this.random.nextDouble() * 0.2F,
vec3.z
);
}
for (int j = 0; (float)j < 1.0F + this.dimensions.width() * 20.0F; j++) {
double d2 = (this.random.nextDouble() * 2.0 - 1.0) * (double)this.dimensions.width();
double d3 = (this.random.nextDouble() * 2.0 - 1.0) * (double)this.dimensions.width();
this.level()
.addParticle(ParticleTypes.SPLASH, this.getX() + d2, (double)(f2 + 1.0F), this.getZ() + d3, vec3.x, vec3.y, vec3.z);
}
this.gameEvent(GameEvent.SPLASH);
}
@Deprecated
protected BlockState getBlockStateOnLegacy() {
return this.level().getBlockState(this.getOnPosLegacy());
}
public BlockState getBlockStateOn() {
return this.level().getBlockState(this.getOnPos());
}
public boolean canSpawnSprintParticle() {
return this.isSprinting() && !this.isInWater() && !this.isSpectator() && !this.isCrouching() && !this.isInLava() && this.isAlive();
}
protected void spawnSprintParticle() {
BlockPos blockpos = this.getOnPosLegacy();
BlockState blockstate = this.level().getBlockState(blockpos);
if (blockstate.getRenderShape() != RenderShape.INVISIBLE) {
Vec3 vec3 = this.getDeltaMovement();
BlockPos blockpos1 = this.blockPosition();
double d0 = this.getX() + (this.random.nextDouble() - 0.5) * (double)this.dimensions.width();
double d1 = this.getZ() + (this.random.nextDouble() - 0.5) * (double)this.dimensions.width();
if (blockpos1.getX() != blockpos.getX()) {
d0 = Mth.clamp(d0, (double)blockpos.getX(), (double)blockpos.getX() + 1.0);
}
if (blockpos1.getZ() != blockpos.getZ()) {
d1 = Mth.clamp(d1, (double)blockpos.getZ(), (double)blockpos.getZ() + 1.0);
}
this.level()
.addParticle(
new BlockParticleOption(ParticleTypes.BLOCK, blockstate),
d0,
this.getY() + 0.1,
d1,
vec3.x * -4.0,
1.5,
vec3.z * -4.0
);
}
}
public boolean isEyeInFluid(TagKey<Fluid> p_204030_) {
return this.fluidOnEyes.contains(p_204030_);
}
public boolean isInLava() {
return !this.firstTick && this.fluidHeight.getDouble(FluidTags.LAVA) > 0.0;
}
public void moveRelative(float p_19921_, Vec3 p_19922_) {
Vec3 vec3 = getInputVector(p_19922_, p_19921_, this.getYRot());
this.setDeltaMovement(this.getDeltaMovement().add(vec3));
}
protected static Vec3 getInputVector(Vec3 p_20016_, float p_20017_, float p_20018_) {
double d0 = p_20016_.lengthSqr();
if (d0 < 1.0E-7) {
return Vec3.ZERO;
} else {
Vec3 vec3 = (d0 > 1.0 ? p_20016_.normalize() : p_20016_).scale((double)p_20017_);
float f = Mth.sin(p_20018_ * (float) (Math.PI / 180.0));
float f1 = Mth.cos(p_20018_ * (float) (Math.PI / 180.0));
return new Vec3(vec3.x * (double)f1 - vec3.z * (double)f, vec3.y, vec3.z * (double)f1 + vec3.x * (double)f);
}
}
@Deprecated
public float getLightLevelDependentMagicValue() {
return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ())
? this.level().getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()))
: 0.0F;
}
public void absMoveTo(double p_19891_, double p_19892_, double p_19893_, float p_19894_, float p_19895_) {
this.absMoveTo(p_19891_, p_19892_, p_19893_);
this.absRotateTo(p_19894_, p_19895_);
}
public void absRotateTo(float p_345247_, float p_344176_) {
this.setYRot(p_345247_ % 360.0F);
this.setXRot(Mth.clamp(p_344176_, -90.0F, 90.0F) % 360.0F);
this.yRotO = this.getYRot();
this.xRotO = this.getXRot();
}
public void absMoveTo(double p_20249_, double p_20250_, double p_20251_) {
double d0 = Mth.clamp(p_20249_, -3.0E7, 3.0E7);
double d1 = Mth.clamp(p_20251_, -3.0E7, 3.0E7);
this.xo = d0;
this.yo = p_20250_;
this.zo = d1;
this.setPos(d0, p_20250_, d1);
}
public void moveTo(Vec3 p_20220_) {
this.moveTo(p_20220_.x, p_20220_.y, p_20220_.z);
}
public void moveTo(double p_20105_, double p_20106_, double p_20107_) {
this.moveTo(p_20105_, p_20106_, p_20107_, this.getYRot(), this.getXRot());
}
public void moveTo(BlockPos p_20036_, float p_20037_, float p_20038_) {
this.moveTo(p_20036_.getBottomCenter(), p_20037_, p_20038_);
}
public void moveTo(Vec3 p_345414_, float p_343369_, float p_344118_) {
this.moveTo(p_345414_.x, p_345414_.y, p_345414_.z, p_343369_, p_344118_);
}
public void moveTo(double p_20108_, double p_20109_, double p_20110_, float p_20111_, float p_20112_) {
this.setPosRaw(p_20108_, p_20109_, p_20110_);
this.setYRot(p_20111_);
this.setXRot(p_20112_);
this.setOldPosAndRot();
this.reapplyPosition();
}
public final void setOldPosAndRot() {
this.setOldPos();
this.setOldRot();
}
public final void setOldPosAndRot(Vec3 p_365967_, float p_368063_, float p_361219_) {
this.setOldPos(p_365967_);
this.setOldRot(p_368063_, p_361219_);
}
protected void setOldPos() {
this.setOldPos(this.position);
}
public void setOldRot() {
this.setOldRot(this.getYRot(), this.getXRot());
}
private void setOldPos(Vec3 p_365942_) {
this.xo = this.xOld = p_365942_.x;
this.yo = this.yOld = p_365942_.y;
this.zo = this.zOld = p_365942_.z;
}
private void setOldRot(float p_365584_, float p_369408_) {
this.yRotO = p_365584_;
this.xRotO = p_369408_;
}
public final Vec3 oldPosition() {
return new Vec3(this.xOld, this.yOld, this.zOld);
}
public float distanceTo(Entity p_20271_) {
float f = (float)(this.getX() - p_20271_.getX());
float f1 = (float)(this.getY() - p_20271_.getY());
float f2 = (float)(this.getZ() - p_20271_.getZ());
return Mth.sqrt(f * f + f1 * f1 + f2 * f2);
}
public double distanceToSqr(double p_20276_, double p_20277_, double p_20278_) {
double d0 = this.getX() - p_20276_;
double d1 = this.getY() - p_20277_;
double d2 = this.getZ() - p_20278_;
return d0 * d0 + d1 * d1 + d2 * d2;
}
public double distanceToSqr(Entity p_20281_) {
return this.distanceToSqr(p_20281_.position());
}
public double distanceToSqr(Vec3 p_20239_) {
double d0 = this.getX() - p_20239_.x;
double d1 = this.getY() - p_20239_.y;
double d2 = this.getZ() - p_20239_.z;
return d0 * d0 + d1 * d1 + d2 * d2;
}
public void playerTouch(Player p_20081_) {
}
public void push(Entity p_20293_) {
if (!this.isPassengerOfSameVehicle(p_20293_)) {
if (!p_20293_.noPhysics && !this.noPhysics) {
double d0 = p_20293_.getX() - this.getX();
double d1 = p_20293_.getZ() - this.getZ();
double d2 = Mth.absMax(d0, d1);
if (d2 >= 0.01F) {
d2 = Math.sqrt(d2);
d0 /= d2;
d1 /= d2;
double d3 = 1.0 / d2;
if (d3 > 1.0) {
d3 = 1.0;
}
d0 *= d3;
d1 *= d3;
d0 *= 0.05F;
d1 *= 0.05F;
if (!this.isVehicle() && this.isPushable()) {
this.push(-d0, 0.0, -d1);
}
if (!p_20293_.isVehicle() && p_20293_.isPushable()) {
p_20293_.push(d0, 0.0, d1);
}
}
}
}
}
public void push(Vec3 p_344607_) {
this.push(p_344607_.x, p_344607_.y, p_344607_.z);
}
public void push(double p_20286_, double p_20287_, double p_20288_) {
this.setDeltaMovement(this.getDeltaMovement().add(p_20286_, p_20287_, p_20288_));
this.hasImpulse = true;
}
protected void markHurt() {
this.hurtMarked = true;
}
@Deprecated
public final void hurt(DamageSource p_19946_, float p_19947_) {
if (this.level instanceof ServerLevel serverlevel) {
this.hurtServer(serverlevel, p_19946_, p_19947_);
}
}
@Deprecated
public final boolean hurtOrSimulate(DamageSource p_360726_, float p_368025_) {
return this.level instanceof ServerLevel serverlevel ? this.hurtServer(serverlevel, p_360726_, p_368025_) : this.hurtClient(p_360726_);
}
public abstract boolean hurtServer(ServerLevel p_365506_, DamageSource p_366233_, float p_368913_);
public boolean hurtClient(DamageSource p_361982_) {
return false;
}
public final Vec3 getViewVector(float p_20253_) {
return this.calculateViewVector(this.getViewXRot(p_20253_), this.getViewYRot(p_20253_));
}
public Direction getNearestViewDirection() {
return Direction.getApproximateNearest(this.getViewVector(1.0F));
}
public float getViewXRot(float p_20268_) {
return this.getXRot(p_20268_);
}
public float getViewYRot(float p_20279_) {
return this.getYRot(p_20279_);
}
public float getXRot(float p_364727_) {
return p_364727_ == 1.0F ? this.getXRot() : Mth.lerp(p_364727_, this.xRotO, this.getXRot());
}
public float getYRot(float p_360855_) {
return p_360855_ == 1.0F ? this.getYRot() : Mth.rotLerp(p_360855_, this.yRotO, this.getYRot());
}
public final Vec3 calculateViewVector(float p_20172_, float p_20173_) {
float f = p_20172_ * (float) (Math.PI / 180.0);
float f1 = -p_20173_ * (float) (Math.PI / 180.0);
float f2 = Mth.cos(f1);
float f3 = Mth.sin(f1);
float f4 = Mth.cos(f);
float f5 = Mth.sin(f);
return new Vec3((double)(f3 * f4), (double)(-f5), (double)(f2 * f4));
}
public final Vec3 getUpVector(float p_20290_) {
return this.calculateUpVector(this.getViewXRot(p_20290_), this.getViewYRot(p_20290_));
}
protected final Vec3 calculateUpVector(float p_20215_, float p_20216_) {
return this.calculateViewVector(p_20215_ - 90.0F, p_20216_);
}
public final Vec3 getEyePosition() {
return new Vec3(this.getX(), this.getEyeY(), this.getZ());
}
public final Vec3 getEyePosition(float p_20300_) {
double d0 = Mth.lerp((double)p_20300_, this.xo, this.getX());
double d1 = Mth.lerp((double)p_20300_, this.yo, this.getY()) + (double)this.getEyeHeight();
double d2 = Mth.lerp((double)p_20300_, this.zo, this.getZ());
return new Vec3(d0, d1, d2);
}
public Vec3 getLightProbePosition(float p_20309_) {
return this.getEyePosition(p_20309_);
}
public final Vec3 getPosition(float p_20319_) {
double d0 = Mth.lerp((double)p_20319_, this.xo, this.getX());
double d1 = Mth.lerp((double)p_20319_, this.yo, this.getY());
double d2 = Mth.lerp((double)p_20319_, this.zo, this.getZ());
return new Vec3(d0, d1, d2);
}
public HitResult pick(double p_19908_, float p_19909_, boolean p_19910_) {
Vec3 vec3 = this.getEyePosition(p_19909_);
Vec3 vec31 = this.getViewVector(p_19909_);
Vec3 vec32 = vec3.add(vec31.x * p_19908_, vec31.y * p_19908_, vec31.z * p_19908_);
return this.level()
.clip(new ClipContext(vec3, vec32, ClipContext.Block.OUTLINE, p_19910_ ? ClipContext.Fluid.ANY : ClipContext.Fluid.NONE, this));
}
public boolean canBeHitByProjectile() {
return this.isAlive() && this.isPickable();
}
public boolean isPickable() {
return false;
}
public boolean isPushable() {
return false;
}
public void awardKillScore(Entity p_19953_, DamageSource p_19955_) {
if (p_19953_ instanceof ServerPlayer) {
CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer)p_19953_, this, p_19955_);
}
}
public boolean shouldRender(double p_20296_, double p_20297_, double p_20298_) {
double d0 = this.getX() - p_20296_;
double d1 = this.getY() - p_20297_;
double d2 = this.getZ() - p_20298_;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
return this.shouldRenderAtSqrDistance(d3);
}
public boolean shouldRenderAtSqrDistance(double p_19883_) {
double d0 = this.getBoundingBox().getSize();
if (Double.isNaN(d0)) {
d0 = 1.0;
}
d0 *= 64.0 * viewScale;
return p_19883_ < d0 * d0;
}
public boolean saveAsPassenger(CompoundTag p_20087_) {
if (this.removalReason != null && !this.removalReason.shouldSave()) {
return false;
} else {
String s = this.getEncodeId();
if (s == null) {
return false;
} else {
p_20087_.putString("id", s);
this.saveWithoutId(p_20087_);
return true;
}
}
}
public boolean save(CompoundTag p_20224_) {
return this.isPassenger() ? false : this.saveAsPassenger(p_20224_);
}
public CompoundTag saveWithoutId(CompoundTag p_20241_) {
try {
if (this.vehicle != null) {
p_20241_.put("Pos", this.newDoubleList(this.vehicle.getX(), this.getY(), this.vehicle.getZ()));
} else {
p_20241_.put("Pos", this.newDoubleList(this.getX(), this.getY(), this.getZ()));
}
Vec3 vec3 = this.getDeltaMovement();
p_20241_.put("Motion", this.newDoubleList(vec3.x, vec3.y, vec3.z));
p_20241_.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
p_20241_.putFloat("FallDistance", this.fallDistance);
p_20241_.putShort("Fire", (short)this.remainingFireTicks);
p_20241_.putShort("Air", (short)this.getAirSupply());
p_20241_.putBoolean("OnGround", this.onGround());
p_20241_.putBoolean("Invulnerable", this.invulnerable);
p_20241_.putInt("PortalCooldown", this.portalCooldown);
p_20241_.putUUID("UUID", this.getUUID());
Component component = this.getCustomName();
if (component != null) {
p_20241_.putString("CustomName", Component.Serializer.toJson(component, this.registryAccess()));
}
if (this.isCustomNameVisible()) {
p_20241_.putBoolean("CustomNameVisible", this.isCustomNameVisible());
}
if (this.isSilent()) {
p_20241_.putBoolean("Silent", this.isSilent());
}
if (this.isNoGravity()) {
p_20241_.putBoolean("NoGravity", this.isNoGravity());
}
if (this.hasGlowingTag) {
p_20241_.putBoolean("Glowing", true);
}
int i = this.getTicksFrozen();
if (i > 0) {
p_20241_.putInt("TicksFrozen", this.getTicksFrozen());
}
if (this.hasVisualFire) {
p_20241_.putBoolean("HasVisualFire", this.hasVisualFire);
}
if (!this.tags.isEmpty()) {
ListTag listtag = new ListTag();
for (String s : this.tags) {
listtag.add(StringTag.valueOf(s));
}
p_20241_.put("Tags", listtag);
}
this.addAdditionalSaveData(p_20241_);
if (this.isVehicle()) {
ListTag listtag1 = new ListTag();
for (Entity entity : this.getPassengers()) {
CompoundTag compoundtag = new CompoundTag();
if (entity.saveAsPassenger(compoundtag)) {
listtag1.add(compoundtag);
}
}
if (!listtag1.isEmpty()) {
p_20241_.put("Passengers", listtag1);
}
}
return p_20241_;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
CrashReportCategory crashreportcategory = crashreport.addCategory("Entity being saved");
this.fillCrashReportCategory(crashreportcategory);
throw new ReportedException(crashreport);
}
}
public void load(CompoundTag p_20259_) {
try {
ListTag listtag = p_20259_.getList("Pos", 6);
ListTag listtag1 = p_20259_.getList("Motion", 6);
ListTag listtag2 = p_20259_.getList("Rotation", 5);
double d0 = listtag1.getDouble(0);
double d1 = listtag1.getDouble(1);
double d2 = listtag1.getDouble(2);
this.setDeltaMovement(Math.abs(d0) > 10.0 ? 0.0 : d0, Math.abs(d1) > 10.0 ? 0.0 : d1, Math.abs(d2) > 10.0 ? 0.0 : d2);
this.hasImpulse = true;
double d3 = 3.0000512E7;
this.setPosRaw(
Mth.clamp(listtag.getDouble(0), -3.0000512E7, 3.0000512E7),
Mth.clamp(listtag.getDouble(1), -2.0E7, 2.0E7),
Mth.clamp(listtag.getDouble(2), -3.0000512E7, 3.0000512E7)
);
this.setYRot(listtag2.getFloat(0));
this.setXRot(listtag2.getFloat(1));
this.setOldPosAndRot();
this.setYHeadRot(this.getYRot());
this.setYBodyRot(this.getYRot());
this.fallDistance = p_20259_.getFloat("FallDistance");
this.remainingFireTicks = p_20259_.getShort("Fire");
if (p_20259_.contains("Air")) {
this.setAirSupply(p_20259_.getShort("Air"));
}
this.onGround = p_20259_.getBoolean("OnGround");
this.invulnerable = p_20259_.getBoolean("Invulnerable");
this.portalCooldown = p_20259_.getInt("PortalCooldown");
if (p_20259_.hasUUID("UUID")) {
this.uuid = p_20259_.getUUID("UUID");
this.stringUUID = this.uuid.toString();
}
if (!Double.isFinite(this.getX()) || !Double.isFinite(this.getY()) || !Double.isFinite(this.getZ())) {
throw new IllegalStateException("Entity has invalid position");
} else if (Double.isFinite((double)this.getYRot()) && Double.isFinite((double)this.getXRot())) {
this.reapplyPosition();
this.setRot(this.getYRot(), this.getXRot());
if (p_20259_.contains("CustomName", 8)) {
String s = p_20259_.getString("CustomName");
try {
this.setCustomName(Component.Serializer.fromJson(s, this.registryAccess()));
} catch (Exception exception) {
LOGGER.warn("Failed to parse entity custom name {}", s, exception);
}
} else {
this.entityData.set(DATA_CUSTOM_NAME, Optional.empty());
}
this.setCustomNameVisible(p_20259_.getBoolean("CustomNameVisible"));
this.setSilent(p_20259_.getBoolean("Silent"));
this.setNoGravity(p_20259_.getBoolean("NoGravity"));
this.setGlowingTag(p_20259_.getBoolean("Glowing"));
this.setTicksFrozen(p_20259_.getInt("TicksFrozen"));
this.hasVisualFire = p_20259_.getBoolean("HasVisualFire");
if (p_20259_.contains("Tags", 9)) {
this.tags.clear();
ListTag listtag3 = p_20259_.getList("Tags", 8);
int i = Math.min(listtag3.size(), 1024);
for (int j = 0; j < i; j++) {
this.tags.add(listtag3.getString(j));
}
}
this.readAdditionalSaveData(p_20259_);
if (this.repositionEntityAfterLoad()) {
this.reapplyPosition();
}
} else {
throw new IllegalStateException("Entity has invalid rotation");
}
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportCategory crashreportcategory = crashreport.addCategory("Entity being loaded");
this.fillCrashReportCategory(crashreportcategory);
throw new ReportedException(crashreport);
}
}
protected boolean repositionEntityAfterLoad() {
return true;
}
@Nullable
protected final String getEncodeId() {
EntityType<?> entitytype = this.getType();
ResourceLocation resourcelocation = EntityType.getKey(entitytype);
return entitytype.canSerialize() && resourcelocation != null ? resourcelocation.toString() : null;
}
protected abstract void readAdditionalSaveData(CompoundTag p_20052_);
protected abstract void addAdditionalSaveData(CompoundTag p_20139_);
protected ListTag newDoubleList(double... p_20064_) {
ListTag listtag = new ListTag();
for (double d0 : p_20064_) {
listtag.add(DoubleTag.valueOf(d0));
}
return listtag;
}
protected ListTag newFloatList(float... p_20066_) {
ListTag listtag = new ListTag();
for (float f : p_20066_) {
listtag.add(FloatTag.valueOf(f));
}
return listtag;
}
@Nullable
public ItemEntity spawnAtLocation(ServerLevel p_363907_, ItemLike p_364088_) {
return this.spawnAtLocation(p_363907_, p_364088_, 0);
}
@Nullable
public ItemEntity spawnAtLocation(ServerLevel p_361470_, ItemLike p_20001_, int p_20002_) {
return this.spawnAtLocation(p_361470_, new ItemStack(p_20001_), (float)p_20002_);
}
@Nullable
public ItemEntity spawnAtLocation(ServerLevel p_369600_, ItemStack p_19985_) {
return this.spawnAtLocation(p_369600_, p_19985_, 0.0F);
}
@Nullable
public ItemEntity spawnAtLocation(ServerLevel p_364149_, ItemStack p_366908_, float p_367722_) {
if (p_366908_.isEmpty()) {
return null;
} else {
ItemEntity itementity = new ItemEntity(p_364149_, this.getX(), this.getY() + (double)p_367722_, this.getZ(), p_366908_);
itementity.setDefaultPickUpDelay();
p_364149_.addFreshEntity(itementity);
return itementity;
}
}
public boolean isAlive() {
return !this.isRemoved();
}
public boolean isInWall() {
if (this.noPhysics) {
return false;
} else {
float f = this.dimensions.width() * 0.8F;
AABB aabb = AABB.ofSize(this.getEyePosition(), (double)f, 1.0E-6, (double)f);
return BlockPos.betweenClosedStream(aabb)
.anyMatch(
p_201942_ -> {
BlockState blockstate = this.level().getBlockState(p_201942_);
return !blockstate.isAir()
&& blockstate.isSuffocating(this.level(), p_201942_)
&& Shapes.joinIsNotEmpty(
blockstate.getCollisionShape(this.level(), p_201942_)
.move((double)p_201942_.getX(), (double)p_201942_.getY(), (double)p_201942_.getZ()),
Shapes.create(aabb),
BooleanOp.AND
);
}
);
}
}
public InteractionResult interact(Player p_19978_, InteractionHand p_19979_) {
if (this.isAlive() && this instanceof Leashable leashable) {
if (leashable.getLeashHolder() == p_19978_) {
if (!this.level().isClientSide()) {
if (p_19978_.hasInfiniteMaterials()) {
leashable.removeLeash();
} else {
leashable.dropLeash();
}
this.gameEvent(GameEvent.ENTITY_INTERACT, p_19978_);
}
return InteractionResult.SUCCESS.withoutItem();
}
ItemStack itemstack = p_19978_.getItemInHand(p_19979_);
if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) {
if (!this.level().isClientSide()) {
leashable.setLeashedTo(p_19978_, true);
}
itemstack.shrink(1);
return InteractionResult.SUCCESS;
}
}
return InteractionResult.PASS;
}
public boolean canCollideWith(Entity p_20303_) {
return p_20303_.canBeCollidedWith() && !this.isPassengerOfSameVehicle(p_20303_);
}
public boolean canBeCollidedWith() {
return false;
}
public void rideTick() {
this.setDeltaMovement(Vec3.ZERO);
this.tick();
if (this.isPassenger()) {
this.getVehicle().positionRider(this);
}
}
public final void positionRider(Entity p_20312_) {
if (this.hasPassenger(p_20312_)) {
this.positionRider(p_20312_, Entity::setPos);
}
}
protected void positionRider(Entity p_19957_, Entity.MoveFunction p_19958_) {
Vec3 vec3 = this.getPassengerRidingPosition(p_19957_);
Vec3 vec31 = p_19957_.getVehicleAttachmentPoint(this);
p_19958_.accept(p_19957_, vec3.x - vec31.x, vec3.y - vec31.y, vec3.z - vec31.z);
}
public void onPassengerTurned(Entity p_20320_) {
}
public Vec3 getVehicleAttachmentPoint(Entity p_333521_) {
return this.getAttachments().get(EntityAttachment.VEHICLE, 0, this.yRot);
}
public Vec3 getPassengerRidingPosition(Entity p_297660_) {
return this.position().add(this.getPassengerAttachmentPoint(p_297660_, this.dimensions, 1.0F));
}
protected Vec3 getPassengerAttachmentPoint(Entity p_297569_, EntityDimensions p_297882_, float p_300288_) {
return getDefaultPassengerAttachmentPoint(this, p_297569_, p_297882_.attachments());
}
protected static Vec3 getDefaultPassengerAttachmentPoint(Entity p_335392_, Entity p_335654_, EntityAttachments p_334107_) {
int i = p_335392_.getPassengers().indexOf(p_335654_);
return p_334107_.getClamped(EntityAttachment.PASSENGER, i, p_335392_.yRot);
}
public boolean startRiding(Entity p_20330_) {
return this.startRiding(p_20330_, false);
}
public boolean showVehicleHealth() {
return this instanceof LivingEntity;
}
public boolean startRiding(Entity p_19966_, boolean p_19967_) {
if (p_19966_ == this.vehicle) {
return false;
} else if (!p_19966_.couldAcceptPassenger()) {
return false;
} else if (!this.level().isClientSide() && !p_19966_.type.canSerialize()) {
return false;
} else {
for (Entity entity = p_19966_; entity.vehicle != null; entity = entity.vehicle) {
if (entity.vehicle == this) {
return false;
}
}
if (p_19967_ || this.canRide(p_19966_) && p_19966_.canAddPassenger(this)) {
if (this.isPassenger()) {
this.stopRiding();
}
this.setPose(Pose.STANDING);
this.vehicle = p_19966_;
this.vehicle.addPassenger(this);
p_19966_.getIndirectPassengersStream()
.filter(p_185984_ -> p_185984_ instanceof ServerPlayer)
.forEach(p_185982_ -> CriteriaTriggers.START_RIDING_TRIGGER.trigger((ServerPlayer)p_185982_));
return true;
} else {
return false;
}
}
}
protected boolean canRide(Entity p_20339_) {
return !this.isShiftKeyDown() && this.boardingCooldown <= 0;
}
public void ejectPassengers() {
for (int i = this.passengers.size() - 1; i >= 0; i--) {
this.passengers.get(i).stopRiding();
}
}
public void removeVehicle() {
if (this.vehicle != null) {
Entity entity = this.vehicle;
this.vehicle = null;
entity.removePassenger(this);
}
}
public void stopRiding() {
this.removeVehicle();
}
protected void addPassenger(Entity p_20349_) {
if (p_20349_.getVehicle() != this) {
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
} else {
if (this.passengers.isEmpty()) {
this.passengers = ImmutableList.of(p_20349_);
} else {
List<Entity> list = Lists.newArrayList(this.passengers);
if (!this.level().isClientSide && p_20349_ instanceof Player && !(this.getFirstPassenger() instanceof Player)) {
list.add(0, p_20349_);
} else {
list.add(p_20349_);
}
this.passengers = ImmutableList.copyOf(list);
}
this.gameEvent(GameEvent.ENTITY_MOUNT, p_20349_);
}
}
protected void removePassenger(Entity p_20352_) {
if (p_20352_.getVehicle() == this) {
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
if (this.passengers.size() == 1 && this.passengers.get(0) == p_20352_) {
this.passengers = ImmutableList.of();
} else {
this.passengers = this.passengers.stream().filter(p_344072_ -> p_344072_ != p_20352_).collect(ImmutableList.toImmutableList());
}
p_20352_.boardingCooldown = 60;
this.gameEvent(GameEvent.ENTITY_DISMOUNT, p_20352_);
}
}
protected boolean canAddPassenger(Entity p_20354_) {
return this.passengers.isEmpty();
}
protected boolean couldAcceptPassenger() {
return true;
}
public void cancelLerp() {
}
public void lerpTo(double p_19896_, double p_19897_, double p_19898_, float p_19899_, float p_19900_, int p_19901_) {
this.setPos(p_19896_, p_19897_, p_19898_);
this.setRot(p_19899_, p_19900_);
}
public double lerpTargetX() {
return this.getX();
}
public double lerpTargetY() {
return this.getY();
}
public double lerpTargetZ() {
return this.getZ();
}
public float lerpTargetXRot() {
return this.getXRot();
}
public float lerpTargetYRot() {
return this.getYRot();
}
public void lerpHeadTo(float p_19918_, int p_19919_) {
this.setYHeadRot(p_19918_);
}
public float getPickRadius() {
return 0.0F;
}
public Vec3 getLookAngle() {
return this.calculateViewVector(this.getXRot(), this.getYRot());
}
public Vec3 getHandHoldingItemAngle(Item p_204035_) {
if (!(this instanceof Player player)) {
return Vec3.ZERO;
} else {
boolean flag = player.getOffhandItem().is(p_204035_) && !player.getMainHandItem().is(p_204035_);
HumanoidArm humanoidarm = flag ? player.getMainArm().getOpposite() : player.getMainArm();
return this.calculateViewVector(0.0F, this.getYRot() + (float)(humanoidarm == HumanoidArm.RIGHT ? 80 : -80)).scale(0.5);
}
}
public Vec2 getRotationVector() {
return new Vec2(this.getXRot(), this.getYRot());
}
public Vec3 getForward() {
return Vec3.directionFromRotation(this.getRotationVector());
}
public void setAsInsidePortal(Portal p_344101_, BlockPos p_342451_) {
if (this.isOnPortalCooldown()) {
this.setPortalCooldown();
} else {
if (this.portalProcess == null || !this.portalProcess.isSamePortal(p_344101_)) {
this.portalProcess = new PortalProcessor(p_344101_, p_342451_.immutable());
} else if (!this.portalProcess.isInsidePortalThisTick()) {
this.portalProcess.updateEntryPosition(p_342451_.immutable());
this.portalProcess.setAsInsidePortalThisTick(true);
}
}
}
protected void handlePortal() {
if (this.level() instanceof ServerLevel serverlevel) {
this.processPortalCooldown();
if (this.portalProcess != null) {
if (this.portalProcess.processPortalTeleportation(serverlevel, this, this.canUsePortal(false))) {
ProfilerFiller profilerfiller = Profiler.get();
profilerfiller.push("portal");
this.setPortalCooldown();
TeleportTransition teleporttransition = this.portalProcess.getPortalDestination(serverlevel, this);
if (teleporttransition != null) {
ServerLevel serverlevel1 = teleporttransition.newLevel();
if (serverlevel.getServer().isLevelEnabled(serverlevel1)
&& (serverlevel1.dimension() == serverlevel.dimension() || this.canTeleport(serverlevel, serverlevel1))) {
this.teleport(teleporttransition);
}
}
profilerfiller.pop();
} else if (this.portalProcess.hasExpired()) {
this.portalProcess = null;
}
}
}
}
public int getDimensionChangingDelay() {
Entity entity = this.getFirstPassenger();
return entity instanceof ServerPlayer ? entity.getDimensionChangingDelay() : 300;
}
public void lerpMotion(double p_20306_, double p_20307_, double p_20308_) {
this.setDeltaMovement(p_20306_, p_20307_, p_20308_);
}
public void handleDamageEvent(DamageSource p_270704_) {
}
public void handleEntityEvent(byte p_19882_) {
switch (p_19882_) {
case 53:
HoneyBlock.showSlideParticles(this);
}
}
public void animateHurt(float p_265161_) {
}
public boolean isOnFire() {
boolean flag = this.level() != null && this.level().isClientSide;
return !this.fireImmune() && (this.remainingFireTicks > 0 || flag && this.getSharedFlag(0));
}
public boolean isPassenger() {
return this.getVehicle() != null;
}
public boolean isVehicle() {
return !this.passengers.isEmpty();
}
public boolean dismountsUnderwater() {
return this.getType().is(EntityTypeTags.DISMOUNTS_UNDERWATER);
}
public boolean canControlVehicle() {
return !this.getType().is(EntityTypeTags.NON_CONTROLLING_RIDER);
}
public void setShiftKeyDown(boolean p_20261_) {
this.setSharedFlag(1, p_20261_);
}
public boolean isShiftKeyDown() {
return this.getSharedFlag(1);
}
public boolean isSteppingCarefully() {
return this.isShiftKeyDown();
}
public boolean isSuppressingBounce() {
return this.isShiftKeyDown();
}
public boolean isDiscrete() {
return this.isShiftKeyDown();
}
public boolean isDescending() {
return this.isShiftKeyDown();
}
public boolean isCrouching() {
return this.hasPose(Pose.CROUCHING);
}
public boolean isSprinting() {
return this.getSharedFlag(3);
}
public void setSprinting(boolean p_20274_) {
this.setSharedFlag(3, p_20274_);
}
public boolean isSwimming() {
return this.getSharedFlag(4);
}
public boolean isVisuallySwimming() {
return this.hasPose(Pose.SWIMMING);
}
public boolean isVisuallyCrawling() {
return this.isVisuallySwimming() && !this.isInWater();
}
public void setSwimming(boolean p_20283_) {
this.setSharedFlag(4, p_20283_);
}
public final boolean hasGlowingTag() {
return this.hasGlowingTag;
}
public final void setGlowingTag(boolean p_146916_) {
this.hasGlowingTag = p_146916_;
this.setSharedFlag(6, this.isCurrentlyGlowing());
}
public boolean isCurrentlyGlowing() {
return this.level().isClientSide() ? this.getSharedFlag(6) : this.hasGlowingTag;
}
public boolean isInvisible() {
return this.getSharedFlag(5);
}
public boolean isInvisibleTo(Player p_20178_) {
if (p_20178_.isSpectator()) {
return false;
} else {
Team team = this.getTeam();
return team != null && p_20178_ != null && p_20178_.getTeam() == team && team.canSeeFriendlyInvisibles() ? false : this.isInvisible();
}
}
public boolean isOnRails() {
return false;
}
public void updateDynamicGameEventListener(BiConsumer<DynamicGameEventListener<?>, ServerLevel> p_216996_) {
}
@Nullable
public PlayerTeam getTeam() {
return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName());
}
public final boolean isAlliedTo(@Nullable Entity p_20355_) {
return p_20355_ == null ? false : this == p_20355_ || this.considersEntityAsAlly(p_20355_) || p_20355_.considersEntityAsAlly(this);
}
protected boolean considersEntityAsAlly(Entity p_365899_) {
return this.isAlliedTo(p_365899_.getTeam());
}
public boolean isAlliedTo(@Nullable Team p_20032_) {
return this.getTeam() != null ? this.getTeam().isAlliedTo(p_20032_) : false;
}
public void setInvisible(boolean p_20304_) {
this.setSharedFlag(5, p_20304_);
}
protected boolean getSharedFlag(int p_20292_) {
return (this.entityData.get(DATA_SHARED_FLAGS_ID) & 1 << p_20292_) != 0;
}
protected void setSharedFlag(int p_20116_, boolean p_20117_) {
byte b0 = this.entityData.get(DATA_SHARED_FLAGS_ID);
if (p_20117_) {
this.entityData.set(DATA_SHARED_FLAGS_ID, (byte)(b0 | 1 << p_20116_));
} else {
this.entityData.set(DATA_SHARED_FLAGS_ID, (byte)(b0 & ~(1 << p_20116_)));
}
}
public int getMaxAirSupply() {
return 300;
}
public int getAirSupply() {
return this.entityData.get(DATA_AIR_SUPPLY_ID);
}
public void setAirSupply(int p_20302_) {
this.entityData.set(DATA_AIR_SUPPLY_ID, p_20302_);
}
public int getTicksFrozen() {
return this.entityData.get(DATA_TICKS_FROZEN);
}
public void setTicksFrozen(int p_146918_) {
this.entityData.set(DATA_TICKS_FROZEN, p_146918_);
}
public float getPercentFrozen() {
int i = this.getTicksRequiredToFreeze();
return (float)Math.min(this.getTicksFrozen(), i) / (float)i;
}
public boolean isFullyFrozen() {
return this.getTicksFrozen() >= this.getTicksRequiredToFreeze();
}
public int getTicksRequiredToFreeze() {
return 140;
}
public void thunderHit(ServerLevel p_19927_, LightningBolt p_19928_) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
if (this.remainingFireTicks == 0) {
this.igniteForSeconds(8.0F);
}
this.hurtServer(p_19927_, this.damageSources().lightningBolt(), 5.0F);
}
public void onAboveBubbleCol(boolean p_20313_) {
Vec3 vec3 = this.getDeltaMovement();
double d0;
if (p_20313_) {
d0 = Math.max(-0.9, vec3.y - 0.03);
} else {
d0 = Math.min(1.8, vec3.y + 0.1);
}
this.setDeltaMovement(vec3.x, d0, vec3.z);
}
public void onInsideBubbleColumn(boolean p_20322_) {
Vec3 vec3 = this.getDeltaMovement();
double d0;
if (p_20322_) {
d0 = Math.max(-0.3, vec3.y - 0.03);
} else {
d0 = Math.min(0.7, vec3.y + 0.06);
}
this.setDeltaMovement(vec3.x, d0, vec3.z);
this.resetFallDistance();
}
public boolean killedEntity(ServerLevel p_216988_, LivingEntity p_216989_) {
return true;
}
public void checkSlowFallDistance() {
if (this.getDeltaMovement().y() > -0.5 && this.fallDistance > 1.0F) {
this.fallDistance = 1.0F;
}
}
public void resetFallDistance() {
this.fallDistance = 0.0F;
}
protected void moveTowardsClosestSpace(double p_20315_, double p_20316_, double p_20317_) {
BlockPos blockpos = BlockPos.containing(p_20315_, p_20316_, p_20317_);
Vec3 vec3 = new Vec3(p_20315_ - (double)blockpos.getX(), p_20316_ - (double)blockpos.getY(), p_20317_ - (double)blockpos.getZ());
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
Direction direction = Direction.UP;
double d0 = Double.MAX_VALUE;
for (Direction direction1 : new Direction[]{Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST, Direction.UP}) {
blockpos$mutableblockpos.setWithOffset(blockpos, direction1);
if (!this.level().getBlockState(blockpos$mutableblockpos).isCollisionShapeFullBlock(this.level(), blockpos$mutableblockpos)) {
double d1 = vec3.get(direction1.getAxis());
double d2 = direction1.getAxisDirection() == Direction.AxisDirection.POSITIVE ? 1.0 - d1 : d1;
if (d2 < d0) {
d0 = d2;
direction = direction1;
}
}
}
float f = this.random.nextFloat() * 0.2F + 0.1F;
float f1 = (float)direction.getAxisDirection().getStep();
Vec3 vec31 = this.getDeltaMovement().scale(0.75);
if (direction.getAxis() == Direction.Axis.X) {
this.setDeltaMovement((double)(f1 * f), vec31.y, vec31.z);
} else if (direction.getAxis() == Direction.Axis.Y) {
this.setDeltaMovement(vec31.x, (double)(f1 * f), vec31.z);
} else if (direction.getAxis() == Direction.Axis.Z) {
this.setDeltaMovement(vec31.x, vec31.y, (double)(f1 * f));
}
}
public void makeStuckInBlock(BlockState p_20006_, Vec3 p_20007_) {
this.resetFallDistance();
this.stuckSpeedMultiplier = p_20007_;
}
private static Component removeAction(Component p_20141_) {
MutableComponent mutablecomponent = p_20141_.plainCopy().setStyle(p_20141_.getStyle().withClickEvent(null));
for (Component component : p_20141_.getSiblings()) {
mutablecomponent.append(removeAction(component));
}
return mutablecomponent;
}
@Override
public Component getName() {
Component component = this.getCustomName();
return component != null ? removeAction(component) : this.getTypeName();
}
protected Component getTypeName() {
return this.type.getDescription();
}
public boolean is(Entity p_20356_) {
return this == p_20356_;
}
public float getYHeadRot() {
return 0.0F;
}
public void setYHeadRot(float p_20328_) {
}
public void setYBodyRot(float p_20338_) {
}
public boolean isAttackable() {
return true;
}
public boolean skipAttackInteraction(Entity p_20357_) {
return false;
}
@Override
public String toString() {
String s = this.level() == null ? "~NULL~" : this.level().toString();
return this.removalReason != null
? String.format(
Locale.ROOT,
"%s['%s'/%d, l='%s', x=%.2f, y=%.2f, z=%.2f, removed=%s]",
this.getClass().getSimpleName(),
this.getName().getString(),
this.id,
s,
this.getX(),
this.getY(),
this.getZ(),
this.removalReason
)
: String.format(
Locale.ROOT,
"%s['%s'/%d, l='%s', x=%.2f, y=%.2f, z=%.2f]",
this.getClass().getSimpleName(),
this.getName().getString(),
this.id,
s,
this.getX(),
this.getY(),
this.getZ()
);
}
protected final boolean isInvulnerableToBase(DamageSource p_20122_) {
return this.isRemoved()
|| this.invulnerable && !p_20122_.is(DamageTypeTags.BYPASSES_INVULNERABILITY) && !p_20122_.isCreativePlayer()
|| p_20122_.is(DamageTypeTags.IS_FIRE) && this.fireImmune()
|| p_20122_.is(DamageTypeTags.IS_FALL) && this.getType().is(EntityTypeTags.FALL_DAMAGE_IMMUNE);
}
public boolean isInvulnerable() {
return this.invulnerable;
}
public void setInvulnerable(boolean p_20332_) {
this.invulnerable = p_20332_;
}
public void copyPosition(Entity p_20360_) {
this.moveTo(p_20360_.getX(), p_20360_.getY(), p_20360_.getZ(), p_20360_.getYRot(), p_20360_.getXRot());
}
public void restoreFrom(Entity p_20362_) {
CompoundTag compoundtag = p_20362_.saveWithoutId(new CompoundTag());
compoundtag.remove("Dimension");
this.load(compoundtag);
this.portalCooldown = p_20362_.portalCooldown;
this.portalProcess = p_20362_.portalProcess;
}
@Nullable
public Entity teleport(TeleportTransition p_361582_) {
if (this.level() instanceof ServerLevel serverlevel && !this.isRemoved()) {
ServerLevel serverlevel1 = p_361582_.newLevel();
boolean flag = serverlevel1.dimension() != serverlevel.dimension();
if (!p_361582_.asPassenger()) {
this.stopRiding();
}
if (flag) {
return this.teleportCrossDimension(serverlevel1, p_361582_);
}
return this.teleportSameDimension(serverlevel, p_361582_);
}
return null;
}
private Entity teleportSameDimension(ServerLevel p_362369_, TeleportTransition p_367652_) {
for (Entity entity : this.getPassengers()) {
entity.teleport(this.calculatePassengerTransition(p_367652_, entity));
}
ProfilerFiller profilerfiller = Profiler.get();
profilerfiller.push("teleportSameDimension");
this.teleportSetPosition(PositionMoveRotation.of(p_367652_), p_367652_.relatives());
if (!p_367652_.asPassenger()) {
this.sendTeleportTransitionToRidingPlayers(p_367652_);
}
p_367652_.postTeleportTransition().onTransition(this);
profilerfiller.pop();
return this;
}
private Entity teleportCrossDimension(ServerLevel p_365101_, TeleportTransition p_360915_) {
List<Entity> list = this.getPassengers();
List<Entity> list1 = new ArrayList<>(list.size());
this.ejectPassengers();
for (Entity entity : list) {
Entity entity1 = entity.teleport(this.calculatePassengerTransition(p_360915_, entity));
if (entity1 != null) {
list1.add(entity1);
}
}
ProfilerFiller profilerfiller = Profiler.get();
profilerfiller.push("teleportCrossDimension");
Entity entity3 = this.getType().create(p_365101_, EntitySpawnReason.DIMENSION_TRAVEL);
if (entity3 == null) {
profilerfiller.pop();
return null;
} else {
entity3.restoreFrom(this);
this.removeAfterChangingDimensions();
entity3.teleportSetPosition(PositionMoveRotation.of(p_360915_), p_360915_.relatives());
p_365101_.addDuringTeleport(entity3);
for (Entity entity2 : list1) {
entity2.startRiding(entity3, true);
}
p_365101_.resetEmptyTime();
p_360915_.postTeleportTransition().onTransition(entity3);
profilerfiller.pop();
return entity3;
}
}
private TeleportTransition calculatePassengerTransition(TeleportTransition p_367725_, Entity p_368688_) {
float f = p_367725_.yRot() + (p_367725_.relatives().contains(Relative.Y_ROT) ? 0.0F : p_368688_.getYRot() - this.getYRot());
float f1 = p_367725_.xRot() + (p_367725_.relatives().contains(Relative.X_ROT) ? 0.0F : p_368688_.getXRot() - this.getXRot());
Vec3 vec3 = p_368688_.position().subtract(this.position());
Vec3 vec31 = p_367725_.position()
.add(
p_367725_.relatives().contains(Relative.X) ? 0.0 : vec3.x(),
p_367725_.relatives().contains(Relative.Y) ? 0.0 : vec3.y(),
p_367725_.relatives().contains(Relative.Z) ? 0.0 : vec3.z()
);
return p_367725_.withPosition(vec31).withRotation(f, f1).transitionAsPassenger();
}
private void sendTeleportTransitionToRidingPlayers(TeleportTransition p_366110_) {
Entity entity = this.getControllingPassenger();
for (Entity entity1 : this.getIndirectPassengers()) {
if (entity1 instanceof ServerPlayer) {
ServerPlayer serverplayer = (ServerPlayer)entity1;
if (entity != null && serverplayer.getId() == entity.getId()) {
serverplayer.connection
.send(
ClientboundTeleportEntityPacket.teleport(
this.getId(), PositionMoveRotation.of(p_366110_), p_366110_.relatives(), this.onGround
)
);
} else {
serverplayer.connection
.send(ClientboundTeleportEntityPacket.teleport(this.getId(), PositionMoveRotation.of(this), Set.of(), this.onGround));
}
}
}
}
public void teleportSetPosition(PositionMoveRotation p_362266_, Set<Relative> p_362099_) {
PositionMoveRotation positionmoverotation = PositionMoveRotation.of(this);
PositionMoveRotation positionmoverotation1 = PositionMoveRotation.calculateAbsolute(positionmoverotation, p_362266_, p_362099_);
this.setPosRaw(positionmoverotation1.position().x, positionmoverotation1.position().y, positionmoverotation1.position().z);
this.setYRot(positionmoverotation1.yRot());
this.setYHeadRot(positionmoverotation1.yRot());
this.setXRot(positionmoverotation1.xRot());
this.reapplyPosition();
this.setOldPosAndRot();
this.setDeltaMovement(positionmoverotation1.deltaMovement());
this.movementThisTick.clear();
}
public void forceSetRotation(float p_368325_, float p_361917_) {
this.setYRot(p_368325_);
this.setYHeadRot(p_368325_);
this.setXRot(p_361917_);
this.setOldRot();
}
public void placePortalTicket(BlockPos p_343531_) {
if (this.level() instanceof ServerLevel serverlevel) {
serverlevel.getChunkSource().addRegionTicket(TicketType.PORTAL, new ChunkPos(p_343531_), 3, p_343531_);
}
}
protected void removeAfterChangingDimensions() {
this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
if (this instanceof Leashable leashable) {
leashable.removeLeash();
}
}
public Vec3 getRelativePortalPosition(Direction.Axis p_20045_, BlockUtil.FoundRectangle p_20046_) {
return PortalShape.getRelativePosition(p_20046_, p_20045_, this.position(), this.getDimensions(this.getPose()));
}
public boolean canUsePortal(boolean p_343600_) {
return (p_343600_ || !this.isPassenger()) && this.isAlive();
}
public boolean canTeleport(Level p_366960_, Level p_366269_) {
if (p_366960_.dimension() == Level.END && p_366269_.dimension() == Level.OVERWORLD) {
for (Entity entity : this.getPassengers()) {
if (entity instanceof ServerPlayer serverplayer && !serverplayer.seenCredits) {
return false;
}
}
}
return true;
}
public float getBlockExplosionResistance(Explosion p_19992_, BlockGetter p_19993_, BlockPos p_19994_, BlockState p_19995_, FluidState p_19996_, float p_19997_) {
return p_19997_;
}
public boolean shouldBlockExplode(Explosion p_19987_, BlockGetter p_19988_, BlockPos p_19989_, BlockState p_19990_, float p_19991_) {
return true;
}
public int getMaxFallDistance() {
return 3;
}
public boolean isIgnoringBlockTriggers() {
return false;
}
public void fillCrashReportCategory(CrashReportCategory p_20051_) {
p_20051_.setDetail("Entity Type", () -> EntityType.getKey(this.getType()) + " (" + this.getClass().getCanonicalName() + ")");
p_20051_.setDetail("Entity ID", this.id);
p_20051_.setDetail("Entity Name", () -> this.getName().getString());
p_20051_.setDetail("Entity's Exact location", String.format(Locale.ROOT, "%.2f, %.2f, %.2f", this.getX(), this.getY(), this.getZ()));
p_20051_.setDetail(
"Entity's Block location",
CrashReportCategory.formatLocation(this.level(), Mth.floor(this.getX()), Mth.floor(this.getY()), Mth.floor(this.getZ()))
);
Vec3 vec3 = this.getDeltaMovement();
p_20051_.setDetail("Entity's Momentum", String.format(Locale.ROOT, "%.2f, %.2f, %.2f", vec3.x, vec3.y, vec3.z));
p_20051_.setDetail("Entity's Passengers", () -> this.getPassengers().toString());
p_20051_.setDetail("Entity's Vehicle", () -> String.valueOf(this.getVehicle()));
}
public boolean displayFireAnimation() {
return this.isOnFire() && !this.isSpectator();
}
public void setUUID(UUID p_20085_) {
this.uuid = p_20085_;
this.stringUUID = this.uuid.toString();
}
@Override
public UUID getUUID() {
return this.uuid;
}
public String getStringUUID() {
return this.stringUUID;
}
@Override
public String getScoreboardName() {
return this.stringUUID;
}
public boolean isPushedByFluid() {
return true;
}
public static double getViewScale() {
return viewScale;
}
public static void setViewScale(double p_20104_) {
viewScale = p_20104_;
}
@Override
public Component getDisplayName() {
return PlayerTeam.formatNameForTeam(this.getTeam(), this.getName()).withStyle(p_185975_ -> p_185975_.withHoverEvent(this.createHoverEvent()).withInsertion(this.getStringUUID()));
}
public void setCustomName(@Nullable Component p_20053_) {
this.entityData.set(DATA_CUSTOM_NAME, Optional.ofNullable(p_20053_));
}
@Nullable
@Override
public Component getCustomName() {
return this.entityData.get(DATA_CUSTOM_NAME).orElse(null);
}
@Override
public boolean hasCustomName() {
return this.entityData.get(DATA_CUSTOM_NAME).isPresent();
}
public void setCustomNameVisible(boolean p_20341_) {
this.entityData.set(DATA_CUSTOM_NAME_VISIBLE, p_20341_);
}
public boolean isCustomNameVisible() {
return this.entityData.get(DATA_CUSTOM_NAME_VISIBLE);
}
public boolean teleportTo(
ServerLevel p_265257_,
double p_265407_,
double p_265727_,
double p_265410_,
Set<Relative> p_265083_,
float p_265573_,
float p_265094_,
boolean p_363886_
) {
float f = Mth.clamp(p_265094_, -90.0F, 90.0F);
Entity entity = this.teleport(
new TeleportTransition(p_265257_, new Vec3(p_265407_, p_265727_, p_265410_), Vec3.ZERO, p_265573_, f, p_265083_, TeleportTransition.DO_NOTHING)
);
return entity != null;
}
public void dismountTo(double p_146825_, double p_146826_, double p_146827_) {
this.teleportTo(p_146825_, p_146826_, p_146827_);
}
public void teleportTo(double p_19887_, double p_19888_, double p_19889_) {
if (this.level() instanceof ServerLevel) {
this.moveTo(p_19887_, p_19888_, p_19889_, this.getYRot(), this.getXRot());
this.teleportPassengers();
}
}
private void teleportPassengers() {
this.getSelfAndPassengers().forEach(p_185977_ -> {
for (Entity entity : p_185977_.passengers) {
p_185977_.positionRider(entity, Entity::moveTo);
}
});
}
public void teleportRelative(double p_249341_, double p_252229_, double p_252038_) {
this.teleportTo(this.getX() + p_249341_, this.getY() + p_252229_, this.getZ() + p_252038_);
}
public boolean shouldShowName() {
return this.isCustomNameVisible();
}
@Override
public void onSyncedDataUpdated(List<SynchedEntityData.DataValue<?>> p_270372_) {
}
@Override
public void onSyncedDataUpdated(EntityDataAccessor<?> p_20059_) {
if (DATA_POSE.equals(p_20059_)) {
this.refreshDimensions();
}
}
@Deprecated
protected void fixupDimensions() {
Pose pose = this.getPose();
EntityDimensions entitydimensions = this.getDimensions(pose);
this.dimensions = entitydimensions;
this.eyeHeight = entitydimensions.eyeHeight();
}
public void refreshDimensions() {
EntityDimensions entitydimensions = this.dimensions;
Pose pose = this.getPose();
EntityDimensions entitydimensions1 = this.getDimensions(pose);
this.dimensions = entitydimensions1;
this.eyeHeight = entitydimensions1.eyeHeight();
this.reapplyPosition();
boolean flag = entitydimensions1.width() <= 4.0F && entitydimensions1.height() <= 4.0F;
if (!this.level.isClientSide
&& !this.firstTick
&& !this.noPhysics
&& flag
&& (entitydimensions1.width() > entitydimensions.width() || entitydimensions1.height() > entitydimensions.height())
&& !(this instanceof Player)) {
this.fudgePositionAfterSizeChange(entitydimensions);
}
}
public boolean fudgePositionAfterSizeChange(EntityDimensions p_343988_) {
EntityDimensions entitydimensions = this.getDimensions(this.getPose());
Vec3 vec3 = this.position().add(0.0, (double)p_343988_.height() / 2.0, 0.0);
double d0 = (double)Math.max(0.0F, entitydimensions.width() - p_343988_.width()) + 1.0E-6;
double d1 = (double)Math.max(0.0F, entitydimensions.height() - p_343988_.height()) + 1.0E-6;
VoxelShape voxelshape = Shapes.create(AABB.ofSize(vec3, d0, d1, d0));
Optional<Vec3> optional = this.level
.findFreePosition(this, voxelshape, vec3, (double)entitydimensions.width(), (double)entitydimensions.height(), (double)entitydimensions.width());
if (optional.isPresent()) {
this.setPos(optional.get().add(0.0, (double)(-entitydimensions.height()) / 2.0, 0.0));
return true;
} else {
if (entitydimensions.width() > p_343988_.width() && entitydimensions.height() > p_343988_.height()) {
VoxelShape voxelshape1 = Shapes.create(AABB.ofSize(vec3, d0, 1.0E-6, d0));
Optional<Vec3> optional1 = this.level
.findFreePosition(this, voxelshape1, vec3, (double)entitydimensions.width(), (double)p_343988_.height(), (double)entitydimensions.width());
if (optional1.isPresent()) {
this.setPos(optional1.get().add(0.0, (double)(-p_343988_.height()) / 2.0 + 1.0E-6, 0.0));
return true;
}
}
return false;
}
}
public Direction getDirection() {
return Direction.fromYRot((double)this.getYRot());
}
public Direction getMotionDirection() {
return this.getDirection();
}
protected HoverEvent createHoverEvent() {
return new HoverEvent(HoverEvent.Action.SHOW_ENTITY, new HoverEvent.EntityTooltipInfo(this.getType(), this.getUUID(), this.getName()));
}
public boolean broadcastToPlayer(ServerPlayer p_19937_) {
return true;
}
@Override
public final AABB getBoundingBox() {
return this.bb;
}
public final void setBoundingBox(AABB p_20012_) {
this.bb = p_20012_;
}
public final float getEyeHeight(Pose p_20237_) {
return this.getDimensions(p_20237_).eyeHeight();
}
public final float getEyeHeight() {
return this.eyeHeight;
}
public Vec3 getLeashOffset(float p_249286_) {
return this.getLeashOffset();
}
protected Vec3 getLeashOffset() {
return new Vec3(0.0, (double)this.getEyeHeight(), (double)(this.getBbWidth() * 0.4F));
}
public SlotAccess getSlot(int p_146919_) {
return SlotAccess.NULL;
}
public Level getCommandSenderWorld() {
return this.level();
}
@Nullable
public MinecraftServer getServer() {
return this.level().getServer();
}
public InteractionResult interactAt(Player p_19980_, Vec3 p_19981_, InteractionHand p_19982_) {
return InteractionResult.PASS;
}
public boolean ignoreExplosion(Explosion p_309517_) {
return false;
}
public void startSeenByPlayer(ServerPlayer p_20119_) {
}
public void stopSeenByPlayer(ServerPlayer p_20174_) {
}
public float rotate(Rotation p_20004_) {
float f = Mth.wrapDegrees(this.getYRot());
switch (p_20004_) {
case CLOCKWISE_180:
return f + 180.0F;
case COUNTERCLOCKWISE_90:
return f + 270.0F;
case CLOCKWISE_90:
return f + 90.0F;
default:
return f;
}
}
public float mirror(Mirror p_20003_) {
float f = Mth.wrapDegrees(this.getYRot());
switch (p_20003_) {
case FRONT_BACK:
return -f;
case LEFT_RIGHT:
return 180.0F - f;
default:
return f;
}
}
public ProjectileDeflection deflection(Projectile p_336398_) {
return this.getType().is(EntityTypeTags.DEFLECTS_PROJECTILES) ? ProjectileDeflection.REVERSE : ProjectileDeflection.NONE;
}
@Nullable
public LivingEntity getControllingPassenger() {
return null;
}
public final boolean hasControllingPassenger() {
return this.getControllingPassenger() != null;
}
public final List<Entity> getPassengers() {
return this.passengers;
}
@Nullable
public Entity getFirstPassenger() {
return this.passengers.isEmpty() ? null : this.passengers.get(0);
}
public boolean hasPassenger(Entity p_20364_) {
return this.passengers.contains(p_20364_);
}
public boolean hasPassenger(Predicate<Entity> p_146863_) {
for (Entity entity : this.passengers) {
if (p_146863_.test(entity)) {
return true;
}
}
return false;
}
private Stream<Entity> getIndirectPassengersStream() {
return this.passengers.stream().flatMap(Entity::getSelfAndPassengers);
}
@Override
public Stream<Entity> getSelfAndPassengers() {
return Stream.concat(Stream.of(this), this.getIndirectPassengersStream());
}
@Override
public Stream<Entity> getPassengersAndSelf() {
return Stream.concat(this.passengers.stream().flatMap(Entity::getPassengersAndSelf), Stream.of(this));
}
public Iterable<Entity> getIndirectPassengers() {
return () -> this.getIndirectPassengersStream().iterator();
}
public int countPlayerPassengers() {
return (int)this.getIndirectPassengersStream().filter(p_185943_ -> p_185943_ instanceof Player).count();
}
public boolean hasExactlyOnePlayerPassenger() {
return this.countPlayerPassengers() == 1;
}
public Entity getRootVehicle() {
Entity entity = this;
while (entity.isPassenger()) {
entity = entity.getVehicle();
}
return entity;
}
public boolean isPassengerOfSameVehicle(Entity p_20366_) {
return this.getRootVehicle() == p_20366_.getRootVehicle();
}
public boolean hasIndirectPassenger(Entity p_20368_) {
if (!p_20368_.isPassenger()) {
return false;
} else {
Entity entity = p_20368_.getVehicle();
return entity == this ? true : this.hasIndirectPassenger(entity);
}
}
public boolean isControlledByOrIsLocalPlayer() {
return this instanceof Player player ? player.isLocalPlayer() : this.isControlledByLocalInstance();
}
public boolean isControlledByLocalInstance() {
return this.getControllingPassenger() instanceof Player player ? player.isLocalPlayer() : this.isEffectiveAi();
}
public boolean isControlledByClient() {
LivingEntity livingentity = this.getControllingPassenger();
return livingentity != null && livingentity.isControlledByClient();
}
public boolean isEffectiveAi() {
return !this.level().isClientSide;
}
protected static Vec3 getCollisionHorizontalEscapeVector(double p_19904_, double p_19905_, float p_19906_) {
double d0 = (p_19904_ + p_19905_ + 1.0E-5F) / 2.0;
float f = -Mth.sin(p_19906_ * (float) (Math.PI / 180.0));
float f1 = Mth.cos(p_19906_ * (float) (Math.PI / 180.0));
float f2 = Math.max(Math.abs(f), Math.abs(f1));
return new Vec3((double)f * d0 / (double)f2, 0.0, (double)f1 * d0 / (double)f2);
}
public Vec3 getDismountLocationForPassenger(LivingEntity p_20123_) {
return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
}
@Nullable
public Entity getVehicle() {
return this.vehicle;
}
@Nullable
public Entity getControlledVehicle() {
return this.vehicle != null && this.vehicle.getControllingPassenger() == this ? this.vehicle : null;
}
public PushReaction getPistonPushReaction() {
return PushReaction.NORMAL;
}
public SoundSource getSoundSource() {
return SoundSource.NEUTRAL;
}
protected int getFireImmuneTicks() {
return 1;
}
public CommandSourceStack createCommandSourceStackForNameResolution(ServerLevel p_365064_) {
return new CommandSourceStack(
CommandSource.NULL, this.position(), this.getRotationVector(), p_365064_, 0, this.getName().getString(), this.getDisplayName(), p_365064_.getServer(), this
);
}
public void lookAt(EntityAnchorArgument.Anchor p_20033_, Vec3 p_20034_) {
Vec3 vec3 = p_20033_.apply(this);
double d0 = p_20034_.x - vec3.x;
double d1 = p_20034_.y - vec3.y;
double d2 = p_20034_.z - vec3.z;
double d3 = Math.sqrt(d0 * d0 + d2 * d2);
this.setXRot(Mth.wrapDegrees((float)(-(Mth.atan2(d1, d3) * 180.0F / (float)Math.PI))));
this.setYRot(Mth.wrapDegrees((float)(Mth.atan2(d2, d0) * 180.0F / (float)Math.PI) - 90.0F));
this.setYHeadRot(this.getYRot());
this.xRotO = this.getXRot();
this.yRotO = this.getYRot();
}
public float getPreciseBodyRotation(float p_344421_) {
return Mth.lerp(p_344421_, this.yRotO, this.yRot);
}
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> p_204032_, double p_204033_) {
if (this.touchingUnloadedChunk()) {
return false;
} else {
AABB aabb = this.getBoundingBox().deflate(0.001);
int i = Mth.floor(aabb.minX);
int j = Mth.ceil(aabb.maxX);
int k = Mth.floor(aabb.minY);
int l = Mth.ceil(aabb.maxY);
int i1 = Mth.floor(aabb.minZ);
int j1 = Mth.ceil(aabb.maxZ);
double d0 = 0.0;
boolean flag = this.isPushedByFluid();
boolean flag1 = false;
Vec3 vec3 = Vec3.ZERO;
int k1 = 0;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int l1 = i; l1 < j; l1++) {
for (int i2 = k; i2 < l; i2++) {
for (int j2 = i1; j2 < j1; j2++) {
blockpos$mutableblockpos.set(l1, i2, j2);
FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos);
if (fluidstate.is(p_204032_)) {
double d1 = (double)((float)i2 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos));
if (d1 >= aabb.minY) {
flag1 = true;
d0 = Math.max(d1 - aabb.minY, d0);
if (flag) {
Vec3 vec31 = fluidstate.getFlow(this.level(), blockpos$mutableblockpos);
if (d0 < 0.4) {
vec31 = vec31.scale(d0);
}
vec3 = vec3.add(vec31);
k1++;
}
}
}
}
}
}
if (vec3.length() > 0.0) {
if (k1 > 0) {
vec3 = vec3.scale(1.0 / (double)k1);
}
if (!(this instanceof Player)) {
vec3 = vec3.normalize();
}
Vec3 vec32 = this.getDeltaMovement();
vec3 = vec3.scale(p_204033_);
double d2 = 0.003;
if (Math.abs(vec32.x) < 0.003 && Math.abs(vec32.z) < 0.003 && vec3.length() < 0.0045000000000000005) {
vec3 = vec3.normalize().scale(0.0045000000000000005);
}
this.setDeltaMovement(this.getDeltaMovement().add(vec3));
}
this.fluidHeight.put(p_204032_, d0);
return flag1;
}
}
public boolean touchingUnloadedChunk() {
AABB aabb = this.getBoundingBox().inflate(1.0);
int i = Mth.floor(aabb.minX);
int j = Mth.ceil(aabb.maxX);
int k = Mth.floor(aabb.minZ);
int l = Mth.ceil(aabb.maxZ);
return !this.level().hasChunksAt(i, k, j, l);
}
public double getFluidHeight(TagKey<Fluid> p_204037_) {
return this.fluidHeight.getDouble(p_204037_);
}
public double getFluidJumpThreshold() {
return (double)this.getEyeHeight() < 0.4 ? 0.0 : 0.4;
}
public final float getBbWidth() {
return this.dimensions.width();
}
public final float getBbHeight() {
return this.dimensions.height();
}
public Packet<ClientGamePacketListener> getAddEntityPacket(ServerEntity p_344981_) {
return new ClientboundAddEntityPacket(this, p_344981_);
}
public EntityDimensions getDimensions(Pose p_19975_) {
return this.type.getDimensions();
}
public final EntityAttachments getAttachments() {
return this.dimensions.attachments();
}
public Vec3 position() {
return this.position;
}
public Vec3 trackingPosition() {
return this.position();
}
@Override
public BlockPos blockPosition() {
return this.blockPosition;
}
public BlockState getInBlockState() {
if (this.inBlockState == null) {
this.inBlockState = this.level().getBlockState(this.blockPosition());
}
return this.inBlockState;
}
public ChunkPos chunkPosition() {
return this.chunkPosition;
}
public Vec3 getDeltaMovement() {
return this.deltaMovement;
}
public void setDeltaMovement(Vec3 p_20257_) {
this.deltaMovement = p_20257_;
}
public void addDeltaMovement(Vec3 p_250128_) {
this.setDeltaMovement(this.getDeltaMovement().add(p_250128_));
}
public void setDeltaMovement(double p_20335_, double p_20336_, double p_20337_) {
this.setDeltaMovement(new Vec3(p_20335_, p_20336_, p_20337_));
}
public final int getBlockX() {
return this.blockPosition.getX();
}
public final double getX() {
return this.position.x;
}
public double getX(double p_20166_) {
return this.position.x + (double)this.getBbWidth() * p_20166_;
}
public double getRandomX(double p_20209_) {
return this.getX((2.0 * this.random.nextDouble() - 1.0) * p_20209_);
}
public final int getBlockY() {
return this.blockPosition.getY();
}
public final double getY() {
return this.position.y;
}
public double getY(double p_20228_) {
return this.position.y + (double)this.getBbHeight() * p_20228_;
}
public double getRandomY() {
return this.getY(this.random.nextDouble());
}
public double getEyeY() {
return this.position.y + (double)this.eyeHeight;
}
public final int getBlockZ() {
return this.blockPosition.getZ();
}
public final double getZ() {
return this.position.z;
}
public double getZ(double p_20247_) {
return this.position.z + (double)this.getBbWidth() * p_20247_;
}
public double getRandomZ(double p_20263_) {
return this.getZ((2.0 * this.random.nextDouble() - 1.0) * p_20263_);
}
public final void setPosRaw(double p_20344_, double p_20345_, double p_20346_) {
if (this.position.x != p_20344_ || this.position.y != p_20345_ || this.position.z != p_20346_) {
this.position = new Vec3(p_20344_, p_20345_, p_20346_);
int i = Mth.floor(p_20344_);
int j = Mth.floor(p_20345_);
int k = Mth.floor(p_20346_);
if (i != this.blockPosition.getX() || j != this.blockPosition.getY() || k != this.blockPosition.getZ()) {
this.blockPosition = new BlockPos(i, j, k);
this.inBlockState = null;
if (SectionPos.blockToSectionCoord(i) != this.chunkPosition.x || SectionPos.blockToSectionCoord(k) != this.chunkPosition.z) {
this.chunkPosition = new ChunkPos(this.blockPosition);
}
}
this.levelCallback.onMove();
}
}
public void checkDespawn() {
}
public Vec3 getRopeHoldPosition(float p_20347_) {
return this.getPosition(p_20347_).add(0.0, (double)this.eyeHeight * 0.7, 0.0);
}
public void recreateFromPacket(ClientboundAddEntityPacket p_146866_) {
int i = p_146866_.getId();
double d0 = p_146866_.getX();
double d1 = p_146866_.getY();
double d2 = p_146866_.getZ();
this.syncPacketPositionCodec(d0, d1, d2);
this.moveTo(d0, d1, d2, p_146866_.getYRot(), p_146866_.getXRot());
this.setId(i);
this.setUUID(p_146866_.getUUID());
}
@Nullable
public ItemStack getPickResult() {
return null;
}
public void setIsInPowderSnow(boolean p_146925_) {
this.isInPowderSnow = p_146925_;
}
public boolean canFreeze() {
return !this.getType().is(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES);
}
public boolean isFreezing() {
return (this.isInPowderSnow || this.wasInPowderSnow) && this.canFreeze();
}
public float getYRot() {
return this.yRot;
}
public float getVisualRotationYInDegrees() {
return this.getYRot();
}
public void setYRot(float p_146923_) {
if (!Float.isFinite(p_146923_)) {
Util.logAndPauseIfInIde("Invalid entity rotation: " + p_146923_ + ", discarding.");
} else {
this.yRot = p_146923_;
}
}
public float getXRot() {
return this.xRot;
}
public void setXRot(float p_146927_) {
if (!Float.isFinite(p_146927_)) {
Util.logAndPauseIfInIde("Invalid entity rotation: " + p_146927_ + ", discarding.");
} else {
this.xRot = Math.clamp(p_146927_ % 360.0F, -90.0F, 90.0F);
}
}
public boolean canSprint() {
return false;
}
public float maxUpStep() {
return 0.0F;
}
public void onExplosionHit(@Nullable Entity p_331940_) {
}
public final boolean isRemoved() {
return this.removalReason != null;
}
@Nullable
public Entity.RemovalReason getRemovalReason() {
return this.removalReason;
}
@Override
public final void setRemoved(Entity.RemovalReason p_146876_) {
if (this.removalReason == null) {
this.removalReason = p_146876_;
}
if (this.removalReason.shouldDestroy()) {
this.stopRiding();
}
this.getPassengers().forEach(Entity::stopRiding);
this.levelCallback.onRemove(p_146876_);
this.onRemoval(p_146876_);
}
protected void unsetRemoved() {
this.removalReason = null;
}
@Override
public void setLevelCallback(EntityInLevelCallback p_146849_) {
this.levelCallback = p_146849_;
}
@Override
public boolean shouldBeSaved() {
if (this.removalReason != null && !this.removalReason.shouldSave()) {
return false;
} else {
return this.isPassenger() ? false : !this.isVehicle() || !this.hasExactlyOnePlayerPassenger();
}
}
@Override
public boolean isAlwaysTicking() {
return false;
}
public boolean mayInteract(ServerLevel p_366970_, BlockPos p_146844_) {
return true;
}
public Level level() {
return this.level;
}
protected void setLevel(Level p_285201_) {
this.level = p_285201_;
}
public DamageSources damageSources() {
return this.level().damageSources();
}
public RegistryAccess registryAccess() {
return this.level().registryAccess();
}
protected void lerpPositionAndRotationStep(int p_298722_, double p_297490_, double p_300716_, double p_298684_, double p_300659_, double p_298926_) {
double d0 = 1.0 / (double)p_298722_;
double d1 = Mth.lerp(d0, this.getX(), p_297490_);
double d2 = Mth.lerp(d0, this.getY(), p_300716_);
double d3 = Mth.lerp(d0, this.getZ(), p_298684_);
float f = (float)Mth.rotLerp(d0, (double)this.getYRot(), p_300659_);
float f1 = (float)Mth.lerp(d0, (double)this.getXRot(), p_298926_);
this.setPos(d1, d2, d3);
this.setRot(f, f1);
}
public RandomSource getRandom() {
return this.random;
}
public Vec3 getKnownMovement() {
if (this.getControllingPassenger() instanceof Player player && this.isAlive()) {
return player.getKnownMovement();
}
return this.getDeltaMovement();
}
@Nullable
public ItemStack getWeaponItem() {
return null;
}
public Optional<ResourceKey<LootTable>> getLootTable() {
return this.type.getDefaultLootTable();
}
@FunctionalInterface
public interface MoveFunction {
void accept(Entity p_20373_, double p_20374_, double p_20375_, double p_20376_);
}
static record Movement(Vec3 from, Vec3 to) {
}
public static enum MovementEmission {
NONE(false, false),
SOUNDS(true, false),
EVENTS(false, true),
ALL(true, true);
final boolean sounds;
final boolean events;
private MovementEmission(final boolean p_146942_, final boolean p_146943_) {
this.sounds = p_146942_;
this.events = p_146943_;
}
public boolean emitsAnything() {
return this.events || this.sounds;
}
public boolean emitsEvents() {
return this.events;
}
public boolean emitsSounds() {
return this.sounds;
}
}
public static enum RemovalReason {
KILLED(true, false),
DISCARDED(true, false),
UNLOADED_TO_CHUNK(false, true),
UNLOADED_WITH_PLAYER(false, false),
CHANGED_DIMENSION(false, false);
private final boolean destroy;
private final boolean save;
private RemovalReason(final boolean p_146963_, final boolean p_146964_) {
this.destroy = p_146963_;
this.save = p_146964_;
}
public boolean shouldDestroy() {
return this.destroy;
}
public boolean shouldSave() {
return this.save;
}
}
}
|