diff --git a/build.gradle b/build.gradle index 7a64cf5..72efdcc 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ buildscript { apply plugin: 'net.minecraftforge.gradle' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. apply plugin: 'eclipse' -apply plugin: 'maven-publish' + apply plugin: 'maven-publish' version = "${mod_version}" diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 336f06b..6ddc032 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -1,216 +1 @@ -f66c3ba45c212b59d393675573509b9bdffd920c assets\forest_tree\blockstates\oak_branch_-1_-1_-1.json -3a192cdf0690fa5fe586d1618e98377a04cdace1 assets\forest_tree\blockstates\oak_branch_-1_-1_0.json -1289f977e7bf3a23477a6907c37be34dac88722d assets\forest_tree\blockstates\oak_branch_-1_-1_1.json -2475623d366adfe3803d58703f906232c20025fa assets\forest_tree\blockstates\oak_branch_-1_0_-1.json -764ae34b0adea01aaaadb1c85dfea152f83a9135 assets\forest_tree\blockstates\oak_branch_-1_0_0.json -629edf9c0c9ab95cc1a3257c3fb9788534b17b8c assets\forest_tree\blockstates\oak_branch_-1_0_1.json -3aa8cc8ecd0ce686cc20918153832276df8730e6 assets\forest_tree\blockstates\oak_branch_-1_1_-1.json -fee6e31ba43cc7020143063c656b3f1c1e760f52 assets\forest_tree\blockstates\oak_branch_-1_1_0.json -0f4978648281a80a1f03dd70eba41e5c8f63190a assets\forest_tree\blockstates\oak_branch_-1_1_1.json -e05b2e57101d5d6ffa8078634e1b36a4c9464919 assets\forest_tree\blockstates\oak_branch_0_-1_-1.json -ac94f60efd920e90e7503f33c63ab6435d8985c6 assets\forest_tree\blockstates\oak_branch_0_-1_0.json -45b17c92ac5af2a6982bc603ca7c6b09fce0ee87 assets\forest_tree\blockstates\oak_branch_0_-1_1.json -e9a49b64cda7372bd4226c52587b71c534e3d489 assets\forest_tree\blockstates\oak_branch_0_0_-1.json -302057f6b2c8ba1ac640f61d63b6b38cca1c9d17 assets\forest_tree\blockstates\oak_branch_0_0_0.json -f9ff14f30e02261b01865cdc8fb02cc352f55afe assets\forest_tree\blockstates\oak_branch_0_0_1.json -8c05989c501372d3927da2a0d58ade1549148666 assets\forest_tree\blockstates\oak_branch_0_1_-1.json -a4aba961ed30cc2da9c12aaa28588a66b3906c06 assets\forest_tree\blockstates\oak_branch_0_1_0.json -229669ef1b6d56a1da49f6207bad1cc7eba26556 assets\forest_tree\blockstates\oak_branch_0_1_1.json -6f69eb3d6cf54d872a8727e363ff3d4ecea79074 assets\forest_tree\blockstates\oak_branch_1_-1_-1.json -7da13ae299b865fd2a4d88a920fc66f1b38be634 assets\forest_tree\blockstates\oak_branch_1_-1_0.json -3ed6f2e1e12f9c8e89c053b2b6d0c86b26a5fa6d assets\forest_tree\blockstates\oak_branch_1_-1_1.json -d5a80bff72bc3614f3d7e30375e08666efd7d780 assets\forest_tree\blockstates\oak_branch_1_0_-1.json -1bed6ebc458ba02bed6d02f4ca9008e2776cbfa9 assets\forest_tree\blockstates\oak_branch_1_0_0.json -82fbd878392e8365e5bffaca0ce4a12ac12b8154 assets\forest_tree\blockstates\oak_branch_1_0_1.json -dc70c8069717afc2c1bec7b543dc75c6b4489922 assets\forest_tree\blockstates\oak_branch_1_1_-1.json -c94d3a19d939b182eb974ec8e014b85e3d4642d0 assets\forest_tree\blockstates\oak_branch_1_1_0.json -0b52f625a55bca6a9f50b4cdbb8c86220fa27ac7 assets\forest_tree\blockstates\oak_branch_1_1_1.json -91136b8dcc3987702db0e508ea8535b317ce0115 assets\forest_tree\blockstates\oak_branch_end_-1_-1_-1.json -e88c26a1dd0d741fa37d2e0f7232f1d38c9500c4 assets\forest_tree\blockstates\oak_branch_end_-1_-1_0.json -049a230a9808af653505ee1fc3e407d22afd0f8c assets\forest_tree\blockstates\oak_branch_end_-1_-1_1.json -bd7fc679ef3d7aeb65dbaa8f166b83ac5b71f76e assets\forest_tree\blockstates\oak_branch_end_-1_0_-1.json -f8488c0e59e3b7cffaa10d99a2dafbad83615588 assets\forest_tree\blockstates\oak_branch_end_-1_0_0.json -e5c00d408894a7c54f8e051cb29869915dfff5b7 assets\forest_tree\blockstates\oak_branch_end_-1_0_1.json -0b8db6e9a3479c66e5ae3b23a6849f5d6220b9f4 assets\forest_tree\blockstates\oak_branch_end_-1_1_-1.json -85f806353fad173f3b9c013e9f0b8a657333710f assets\forest_tree\blockstates\oak_branch_end_-1_1_0.json -472e2ff2200248af46a1aa4c2c2902a7cd59df09 assets\forest_tree\blockstates\oak_branch_end_-1_1_1.json -34f60bada46ac7c6d1eeb6da0f45272ef9f78443 assets\forest_tree\blockstates\oak_branch_end_0_-1_-1.json -d72558a6411895e43ac627886e05d7e880f47e6a assets\forest_tree\blockstates\oak_branch_end_0_-1_0.json -cf96af9b55b27bd373a12f16ea1dea6ba31f0cdf assets\forest_tree\blockstates\oak_branch_end_0_-1_1.json -45e8f54020301783179bb45e2b624d5189e6b905 assets\forest_tree\blockstates\oak_branch_end_0_0_-1.json -c31a0398544594a3c5ca4266caf15959f1888b5e assets\forest_tree\blockstates\oak_branch_end_0_0_0.json -69b45d1046b1043f8f696b5e7df5ed707a08b799 assets\forest_tree\blockstates\oak_branch_end_0_0_1.json -5442df2e94eba548d7f0b4d5b7cc70d573ac5f50 assets\forest_tree\blockstates\oak_branch_end_0_1_-1.json -52767324cd4f5080a2e9e3717c1aa3a5393df473 assets\forest_tree\blockstates\oak_branch_end_0_1_0.json -20d9416cfed2f0d98b9aa164813dbe7613d25a19 assets\forest_tree\blockstates\oak_branch_end_0_1_1.json -b91e7995582e94c20a1cd3b49bd6216f3ab5d5ac assets\forest_tree\blockstates\oak_branch_end_1_-1_-1.json -c17082f0643e4080a267cac26488aa50abd53061 assets\forest_tree\blockstates\oak_branch_end_1_-1_0.json -95a5e0b20c33d36c4bb30932f20d1badfe51bacd assets\forest_tree\blockstates\oak_branch_end_1_-1_1.json -5e1d2d793560f617a31c17d9d2626aa2756b6bfa assets\forest_tree\blockstates\oak_branch_end_1_0_-1.json -018a25c2a49c4a8de735bfa603dd284a3404078e assets\forest_tree\blockstates\oak_branch_end_1_0_0.json -224e40093f20c1d430e59abf92a12c8ce485b765 assets\forest_tree\blockstates\oak_branch_end_1_0_1.json -500bf40f4e808202553a4e5a9ea0bf2ef1bd3274 assets\forest_tree\blockstates\oak_branch_end_1_1_-1.json -dc568ea4c93477f5991cd57122f5cfc5d9debdbd assets\forest_tree\blockstates\oak_branch_end_1_1_0.json -f760ff98dcbeb6576301126c4279ad97091f1ead assets\forest_tree\blockstates\oak_branch_end_1_1_1.json -a5f9dac9d80d9b946b59b56c327f8596df291a15 assets\forest_tree\blockstates\spruce_branch_-1_-1_-1.json -d84e1f8808c8389c719546194cda66d566676157 assets\forest_tree\blockstates\spruce_branch_-1_-1_0.json -57470b8f20c5a2b46637e2ed7ff174ae8e98e235 assets\forest_tree\blockstates\spruce_branch_-1_-1_1.json -67cff39790c8ba9ab807e1a9bbd6aacd32181ab3 assets\forest_tree\blockstates\spruce_branch_-1_0_-1.json -91e4e0c3e1a77b847481340d04e4205da2dc2f98 assets\forest_tree\blockstates\spruce_branch_-1_0_0.json -16ee6f08942f638f04071bfc8f1ccfffc4ccd50f assets\forest_tree\blockstates\spruce_branch_-1_0_1.json -e5fd507dc5bef86b3c7d0ab5560903d362ebbe35 assets\forest_tree\blockstates\spruce_branch_-1_1_-1.json -00227cbeb1a5c0f6c3028dcb7171bf78c37aee26 assets\forest_tree\blockstates\spruce_branch_-1_1_0.json -515851e75c296b0d1c8349a2b55378931a3fcee2 assets\forest_tree\blockstates\spruce_branch_-1_1_1.json -ec051b17618713dfab0a83a2357f919749a9b0b2 assets\forest_tree\blockstates\spruce_branch_0_-1_-1.json -ea081c936b68d75d5e775e5f118591f9e0856627 assets\forest_tree\blockstates\spruce_branch_0_-1_0.json -e3a430ccc426cb2725d599691e01badc567b0641 assets\forest_tree\blockstates\spruce_branch_0_-1_1.json -08216c7d87f81df1fefb0e412cf75d27e11b152f assets\forest_tree\blockstates\spruce_branch_0_0_-1.json -bfc1909d4d5cc796aaeea40c59b0a1c8556c4413 assets\forest_tree\blockstates\spruce_branch_0_0_0.json -0292c317b0e45bdfecae20e951796a4438112184 assets\forest_tree\blockstates\spruce_branch_0_0_1.json -3311a10c8e228a9bf456fc940412070dfab04253 assets\forest_tree\blockstates\spruce_branch_0_1_-1.json -3024d2b198835f8fdc5b58a0e1f49ce35142dff3 assets\forest_tree\blockstates\spruce_branch_0_1_0.json -2a0e2e7b5c6a0bcdde1d00c53e64898af813fda9 assets\forest_tree\blockstates\spruce_branch_0_1_1.json -74b0662974bd331f93db887f3ccc271e1140937a assets\forest_tree\blockstates\spruce_branch_1_-1_-1.json -6455a47dc53f3f9aeb276c641ab726324302894d assets\forest_tree\blockstates\spruce_branch_1_-1_0.json -1ae9c1971f2708c6de53ff1a76e855497463efbb assets\forest_tree\blockstates\spruce_branch_1_-1_1.json -5ad4d25b31e5cb376be96ab996cb8ac762de16c6 assets\forest_tree\blockstates\spruce_branch_1_0_-1.json -3e9542a92ab1744e999057260f4f937b9dcc9ae9 assets\forest_tree\blockstates\spruce_branch_1_0_0.json -b14e2879b0136b29851320c6aadc74b8e7c03154 assets\forest_tree\blockstates\spruce_branch_1_0_1.json -34e7ada01a0a122b978d09a7cef49c17de7b743c assets\forest_tree\blockstates\spruce_branch_1_1_-1.json -46d795c5aca843096ef8fe58bdad27c4c47acbf6 assets\forest_tree\blockstates\spruce_branch_1_1_0.json -9a36d4c82dff33c6f754ecfc620936c7e0ffcb75 assets\forest_tree\blockstates\spruce_branch_1_1_1.json -139577e3d2d5092f6807be1ea134a8a58a05b3d1 assets\forest_tree\blockstates\spruce_branch_end_-1_-1_-1.json -aee945d57917220116b43b67444e8d32dbd15f36 assets\forest_tree\blockstates\spruce_branch_end_-1_-1_0.json -53741d285bf15dca48e1c9bd62efbaf26417dd46 assets\forest_tree\blockstates\spruce_branch_end_-1_-1_1.json -210345ad4575850e6dabeba89c4a9b057b1a1fa7 assets\forest_tree\blockstates\spruce_branch_end_-1_0_-1.json -4b70e803efc0369acae3d10b73e0e8fad15f6c64 assets\forest_tree\blockstates\spruce_branch_end_-1_0_0.json -cc94188340b1a966b819725596c7f2dd97359e57 assets\forest_tree\blockstates\spruce_branch_end_-1_0_1.json -3171c8239d5c5c02171d55901933df25f3ea01e3 assets\forest_tree\blockstates\spruce_branch_end_-1_1_-1.json -dd91c055d71b582b70b34a5829280b71d10c20cd assets\forest_tree\blockstates\spruce_branch_end_-1_1_0.json -0803528f6a309868d5971bd6f2f2fbe82bf4fcfb assets\forest_tree\blockstates\spruce_branch_end_-1_1_1.json -db7932815b1f77a36928c2d102a7d457f1b87ace assets\forest_tree\blockstates\spruce_branch_end_0_-1_-1.json -9aca43ac1657792b2811fbd9dae4afe79f304e1b assets\forest_tree\blockstates\spruce_branch_end_0_-1_0.json -bf0b47913e953af7a9a8c7c79c40f4fce51980ba assets\forest_tree\blockstates\spruce_branch_end_0_-1_1.json -94f86debd1d004674efae8ada56525b39f2e76bb assets\forest_tree\blockstates\spruce_branch_end_0_0_-1.json -6cd24a920b607799e6b27c1e97702a106cc82582 assets\forest_tree\blockstates\spruce_branch_end_0_0_0.json -020dc787ee2060d1fa731d71143c4174f117d2ce assets\forest_tree\blockstates\spruce_branch_end_0_0_1.json -6323bd310d56a391fbd27da6bae9dcdf37d251d0 assets\forest_tree\blockstates\spruce_branch_end_0_1_-1.json -54a4d1004b86281387b409098f96aaa919dcca1e assets\forest_tree\blockstates\spruce_branch_end_0_1_0.json -2cab59d4c455122c49a07d18c90b33d69ffb8ab8 assets\forest_tree\blockstates\spruce_branch_end_0_1_1.json -639cfb9f27944e4f4dfc904ce7e4485026d3d6fe assets\forest_tree\blockstates\spruce_branch_end_1_-1_-1.json -db2e1c8f5059960d485013cb073eafec8c299ebc assets\forest_tree\blockstates\spruce_branch_end_1_-1_0.json -e2772991c8679e8aa58dd89b97e507bf077d8ae9 assets\forest_tree\blockstates\spruce_branch_end_1_-1_1.json -f16abaed9c17851061ad8f51a3f6480340c1b127 assets\forest_tree\blockstates\spruce_branch_end_1_0_-1.json -c12895871a0c2c8f611baa1359c59381e950ef3e assets\forest_tree\blockstates\spruce_branch_end_1_0_0.json -64e550428262676f45d2df9b4aa2d9b1b5b963c6 assets\forest_tree\blockstates\spruce_branch_end_1_0_1.json -0d27a0e1e84ed39b8195c38f35b6117ac4203567 assets\forest_tree\blockstates\spruce_branch_end_1_1_-1.json -1995deab91c944f54e1dfca2a22087e32eb84901 assets\forest_tree\blockstates\spruce_branch_end_1_1_0.json -9744b7f225c63886250cadfa13554f0325c0af43 assets\forest_tree\blockstates\spruce_branch_end_1_1_1.json -ef780f77f760dd49cab2267002de5d02947d5c9e assets\forest_tree\models\block\branch\oak_branch_-1_-1_-1.json -1be6f4f040ce80303e707615b3b1642b3d4f33b3 assets\forest_tree\models\block\branch\oak_branch_-1_-1_0.json -7da6cb058b78abc77bc03604c0478e5b1792bf39 assets\forest_tree\models\block\branch\oak_branch_-1_-1_1.json -9f17abe25d7be56635bbb6ed1acdd6979a7127cc assets\forest_tree\models\block\branch\oak_branch_-1_0_-1.json -9f1a41a7dcd991b8fa6794058ebda13bfdbb7e0e assets\forest_tree\models\block\branch\oak_branch_-1_0_0.json -9f1124f9cf1f6ceaa993bdf84654d9b829d38507 assets\forest_tree\models\block\branch\oak_branch_-1_0_1.json -6a2f829b66a412da28d93050778a0fc8cecf1d53 assets\forest_tree\models\block\branch\oak_branch_-1_1_-1.json -9a42b377d9b6af99e37fe4a085872c9881206a30 assets\forest_tree\models\block\branch\oak_branch_-1_1_0.json -bc3e3b255e160cb69f493ab43396ca634eb845b5 assets\forest_tree\models\block\branch\oak_branch_-1_1_1.json -23077880308a02c1b0baca2dfaffaf2d34efbc42 assets\forest_tree\models\block\branch\oak_branch_0_-1_-1.json -d74a3256035be6024820aeef5a34366739299a97 assets\forest_tree\models\block\branch\oak_branch_0_-1_0.json -40cf950244ff5aa51c7c8075eff98bfa1d06474b assets\forest_tree\models\block\branch\oak_branch_0_-1_1.json -4bc340947b38ef3c59ee05f7b333455d3a091310 assets\forest_tree\models\block\branch\oak_branch_0_0_-1.json -0d6f9ea57764ad8d26927340bc8cad74f89b3de0 assets\forest_tree\models\block\branch\oak_branch_0_0_0.json -e0864b68fe38fb7c1aa72ef85207b8b33afbec03 assets\forest_tree\models\block\branch\oak_branch_0_0_1.json -a32ece353a8845a640df34cf9f79dea1675caf95 assets\forest_tree\models\block\branch\oak_branch_0_1_-1.json -0d41120e5678ef0e42a0e55fa20d4defb705ae8b assets\forest_tree\models\block\branch\oak_branch_0_1_0.json -a55c31a4ca7ed5dd478318efc58cdbfde5199c45 assets\forest_tree\models\block\branch\oak_branch_0_1_1.json -71be3fbddc083913b75ea22fc8870301c2fb2970 assets\forest_tree\models\block\branch\oak_branch_1_-1_-1.json -316823357ef8c68bfaa54e079a087469a7322ab8 assets\forest_tree\models\block\branch\oak_branch_1_-1_0.json -b4f73a11477268ca0e958d9dcee3baeb0e55a866 assets\forest_tree\models\block\branch\oak_branch_1_-1_1.json -628fd17ecc594a1d2b931160e0879ab2c4d38a2e assets\forest_tree\models\block\branch\oak_branch_1_0_-1.json -10f26d864fa9dc316c9a0811f67b472ddd6b9ec3 assets\forest_tree\models\block\branch\oak_branch_1_0_0.json -aada23f76b8a43f881fbb79ec9f8667c131e15ca assets\forest_tree\models\block\branch\oak_branch_1_0_1.json -11d647956da96b24e5af4afb29393269c30a2835 assets\forest_tree\models\block\branch\oak_branch_1_1_-1.json -580705633ab9897c1a18229a10d5f4257be1826a assets\forest_tree\models\block\branch\oak_branch_1_1_0.json -cd4a9c79075eb9fc678151fd586d21c48c8c5c61 assets\forest_tree\models\block\branch\oak_branch_1_1_1.json -ef780f77f760dd49cab2267002de5d02947d5c9e assets\forest_tree\models\block\branch\oak_branch_end_-1_-1_-1.json -1be6f4f040ce80303e707615b3b1642b3d4f33b3 assets\forest_tree\models\block\branch\oak_branch_end_-1_-1_0.json -7da6cb058b78abc77bc03604c0478e5b1792bf39 assets\forest_tree\models\block\branch\oak_branch_end_-1_-1_1.json -9f17abe25d7be56635bbb6ed1acdd6979a7127cc assets\forest_tree\models\block\branch\oak_branch_end_-1_0_-1.json -9f1a41a7dcd991b8fa6794058ebda13bfdbb7e0e assets\forest_tree\models\block\branch\oak_branch_end_-1_0_0.json -9f1124f9cf1f6ceaa993bdf84654d9b829d38507 assets\forest_tree\models\block\branch\oak_branch_end_-1_0_1.json -6a2f829b66a412da28d93050778a0fc8cecf1d53 assets\forest_tree\models\block\branch\oak_branch_end_-1_1_-1.json -9a42b377d9b6af99e37fe4a085872c9881206a30 assets\forest_tree\models\block\branch\oak_branch_end_-1_1_0.json -bc3e3b255e160cb69f493ab43396ca634eb845b5 assets\forest_tree\models\block\branch\oak_branch_end_-1_1_1.json -23077880308a02c1b0baca2dfaffaf2d34efbc42 assets\forest_tree\models\block\branch\oak_branch_end_0_-1_-1.json -d74a3256035be6024820aeef5a34366739299a97 assets\forest_tree\models\block\branch\oak_branch_end_0_-1_0.json -40cf950244ff5aa51c7c8075eff98bfa1d06474b assets\forest_tree\models\block\branch\oak_branch_end_0_-1_1.json -4bc340947b38ef3c59ee05f7b333455d3a091310 assets\forest_tree\models\block\branch\oak_branch_end_0_0_-1.json -0d6f9ea57764ad8d26927340bc8cad74f89b3de0 assets\forest_tree\models\block\branch\oak_branch_end_0_0_0.json -e0864b68fe38fb7c1aa72ef85207b8b33afbec03 assets\forest_tree\models\block\branch\oak_branch_end_0_0_1.json -a32ece353a8845a640df34cf9f79dea1675caf95 assets\forest_tree\models\block\branch\oak_branch_end_0_1_-1.json -0d41120e5678ef0e42a0e55fa20d4defb705ae8b assets\forest_tree\models\block\branch\oak_branch_end_0_1_0.json -a55c31a4ca7ed5dd478318efc58cdbfde5199c45 assets\forest_tree\models\block\branch\oak_branch_end_0_1_1.json -71be3fbddc083913b75ea22fc8870301c2fb2970 assets\forest_tree\models\block\branch\oak_branch_end_1_-1_-1.json -316823357ef8c68bfaa54e079a087469a7322ab8 assets\forest_tree\models\block\branch\oak_branch_end_1_-1_0.json -b4f73a11477268ca0e958d9dcee3baeb0e55a866 assets\forest_tree\models\block\branch\oak_branch_end_1_-1_1.json -628fd17ecc594a1d2b931160e0879ab2c4d38a2e assets\forest_tree\models\block\branch\oak_branch_end_1_0_-1.json -10f26d864fa9dc316c9a0811f67b472ddd6b9ec3 assets\forest_tree\models\block\branch\oak_branch_end_1_0_0.json -aada23f76b8a43f881fbb79ec9f8667c131e15ca assets\forest_tree\models\block\branch\oak_branch_end_1_0_1.json -11d647956da96b24e5af4afb29393269c30a2835 assets\forest_tree\models\block\branch\oak_branch_end_1_1_-1.json -580705633ab9897c1a18229a10d5f4257be1826a assets\forest_tree\models\block\branch\oak_branch_end_1_1_0.json -cd4a9c79075eb9fc678151fd586d21c48c8c5c61 assets\forest_tree\models\block\branch\oak_branch_end_1_1_1.json -1323789d148bc4d3595e01dbb2e0de9cca17f1c3 assets\forest_tree\models\block\branch\spruce_branch_-1_-1_-1.json -a7bbeb173852689bdc96ef583fa61f66ea995f43 assets\forest_tree\models\block\branch\spruce_branch_-1_-1_0.json -8c7f0b3fa4a9c340317bc3b901287eb6d2064883 assets\forest_tree\models\block\branch\spruce_branch_-1_-1_1.json -26218ff7e8cbf749f60f3ff57515328fb92c5be3 assets\forest_tree\models\block\branch\spruce_branch_-1_0_-1.json -17729c8e9b9e0e2135c682c74e0c82570642c4aa assets\forest_tree\models\block\branch\spruce_branch_-1_0_0.json -17dec83ebf183688413cfdff94b4105ec156e873 assets\forest_tree\models\block\branch\spruce_branch_-1_0_1.json -1e16b56ebcd4a43d932401a1b4def2364b34e790 assets\forest_tree\models\block\branch\spruce_branch_-1_1_-1.json -da5347e1fa3c5e9632e4cad49ba5e43dc2510083 assets\forest_tree\models\block\branch\spruce_branch_-1_1_0.json -48016f597cf2c56748ec4d8e0d50e9a25956d0f9 assets\forest_tree\models\block\branch\spruce_branch_-1_1_1.json -e7a5738d3e1df2be4fe5af200bf40f0796355269 assets\forest_tree\models\block\branch\spruce_branch_0_-1_-1.json -126d87048a3ec56cdbca6695d2666e36a6742916 assets\forest_tree\models\block\branch\spruce_branch_0_-1_0.json -6baca789c7a577882889f41d80539212d5c45f02 assets\forest_tree\models\block\branch\spruce_branch_0_-1_1.json -f013cd6d02206c9e0886bc1b22fee2f8a10df440 assets\forest_tree\models\block\branch\spruce_branch_0_0_-1.json -7bd8446f64cf9b32b4298f6f044446e85d4f69cf assets\forest_tree\models\block\branch\spruce_branch_0_0_0.json -5b42ee2665c143bb0438757c148cf1c38eb0d32b assets\forest_tree\models\block\branch\spruce_branch_0_0_1.json -06bd05778e5749baf75cde66c0d39c0f601fa110 assets\forest_tree\models\block\branch\spruce_branch_0_1_-1.json -a13b00b131beabc74f182bea498520a5e4bab3fa assets\forest_tree\models\block\branch\spruce_branch_0_1_0.json -74ebdabafee1bf391cef5de322bf3aad0bdc334c assets\forest_tree\models\block\branch\spruce_branch_0_1_1.json -ea56c3558e64ace1bee6b637d1c1e22488dd0d17 assets\forest_tree\models\block\branch\spruce_branch_1_-1_-1.json -246f77357764e9d66ebc22028a15764979771f40 assets\forest_tree\models\block\branch\spruce_branch_1_-1_0.json -23b5e7f605a4a858cde068cf0700735d64c3f510 assets\forest_tree\models\block\branch\spruce_branch_1_-1_1.json -143f5b78b2884c3fed1db75755aee4119e6dc002 assets\forest_tree\models\block\branch\spruce_branch_1_0_-1.json -ba014b90a720cecbf18a1698289bc51cc6ec20d2 assets\forest_tree\models\block\branch\spruce_branch_1_0_0.json -769e8058216d1f2801ece0ab951b52452ee3290b assets\forest_tree\models\block\branch\spruce_branch_1_0_1.json -9ed22b17fc21cf9796f23f10a1cbd731abdffbcb assets\forest_tree\models\block\branch\spruce_branch_1_1_-1.json -5f03eb4bb65626003b748b0a6eb37304982c72bc assets\forest_tree\models\block\branch\spruce_branch_1_1_0.json -9e267599db1277caca44e3f6f6fec0946261114b assets\forest_tree\models\block\branch\spruce_branch_1_1_1.json -1323789d148bc4d3595e01dbb2e0de9cca17f1c3 assets\forest_tree\models\block\branch\spruce_branch_end_-1_-1_-1.json -a7bbeb173852689bdc96ef583fa61f66ea995f43 assets\forest_tree\models\block\branch\spruce_branch_end_-1_-1_0.json -8c7f0b3fa4a9c340317bc3b901287eb6d2064883 assets\forest_tree\models\block\branch\spruce_branch_end_-1_-1_1.json -26218ff7e8cbf749f60f3ff57515328fb92c5be3 assets\forest_tree\models\block\branch\spruce_branch_end_-1_0_-1.json -17729c8e9b9e0e2135c682c74e0c82570642c4aa assets\forest_tree\models\block\branch\spruce_branch_end_-1_0_0.json -17dec83ebf183688413cfdff94b4105ec156e873 assets\forest_tree\models\block\branch\spruce_branch_end_-1_0_1.json -1e16b56ebcd4a43d932401a1b4def2364b34e790 assets\forest_tree\models\block\branch\spruce_branch_end_-1_1_-1.json -da5347e1fa3c5e9632e4cad49ba5e43dc2510083 assets\forest_tree\models\block\branch\spruce_branch_end_-1_1_0.json -48016f597cf2c56748ec4d8e0d50e9a25956d0f9 assets\forest_tree\models\block\branch\spruce_branch_end_-1_1_1.json -e7a5738d3e1df2be4fe5af200bf40f0796355269 assets\forest_tree\models\block\branch\spruce_branch_end_0_-1_-1.json -126d87048a3ec56cdbca6695d2666e36a6742916 assets\forest_tree\models\block\branch\spruce_branch_end_0_-1_0.json -6baca789c7a577882889f41d80539212d5c45f02 assets\forest_tree\models\block\branch\spruce_branch_end_0_-1_1.json -f013cd6d02206c9e0886bc1b22fee2f8a10df440 assets\forest_tree\models\block\branch\spruce_branch_end_0_0_-1.json -7bd8446f64cf9b32b4298f6f044446e85d4f69cf assets\forest_tree\models\block\branch\spruce_branch_end_0_0_0.json -5b42ee2665c143bb0438757c148cf1c38eb0d32b assets\forest_tree\models\block\branch\spruce_branch_end_0_0_1.json -06bd05778e5749baf75cde66c0d39c0f601fa110 assets\forest_tree\models\block\branch\spruce_branch_end_0_1_-1.json -a13b00b131beabc74f182bea498520a5e4bab3fa assets\forest_tree\models\block\branch\spruce_branch_end_0_1_0.json -74ebdabafee1bf391cef5de322bf3aad0bdc334c assets\forest_tree\models\block\branch\spruce_branch_end_0_1_1.json -ea56c3558e64ace1bee6b637d1c1e22488dd0d17 assets\forest_tree\models\block\branch\spruce_branch_end_1_-1_-1.json -246f77357764e9d66ebc22028a15764979771f40 assets\forest_tree\models\block\branch\spruce_branch_end_1_-1_0.json -23b5e7f605a4a858cde068cf0700735d64c3f510 assets\forest_tree\models\block\branch\spruce_branch_end_1_-1_1.json -143f5b78b2884c3fed1db75755aee4119e6dc002 assets\forest_tree\models\block\branch\spruce_branch_end_1_0_-1.json -ba014b90a720cecbf18a1698289bc51cc6ec20d2 assets\forest_tree\models\block\branch\spruce_branch_end_1_0_0.json -769e8058216d1f2801ece0ab951b52452ee3290b assets\forest_tree\models\block\branch\spruce_branch_end_1_0_1.json -9ed22b17fc21cf9796f23f10a1cbd731abdffbcb assets\forest_tree\models\block\branch\spruce_branch_end_1_1_-1.json -5f03eb4bb65626003b748b0a6eb37304982c72bc assets\forest_tree\models\block\branch\spruce_branch_end_1_1_0.json -9e267599db1277caca44e3f6f6fec0946261114b assets\forest_tree\models\block\branch\spruce_branch_end_1_1_1.json +d6cfc3440ae2f3190da994d2bdfe5c22367426b5 assets/forest_tree/lang/en_us.json diff --git a/src/main/java/lilypuree/forest_tree/Registration.java b/src/main/java/lilypuree/forest_tree/Registration.java index 6df3992..81b4547 100644 --- a/src/main/java/lilypuree/forest_tree/Registration.java +++ b/src/main/java/lilypuree/forest_tree/Registration.java @@ -3,6 +3,7 @@ import com.google.common.collect.ImmutableMap; import lilypuree.forest_tree.trees.block.BranchBlock; import lilypuree.forest_tree.trees.customization.*; +import lilypuree.forest_tree.trees.items.CustomSaplingItem; import lilypuree.forest_tree.trees.items.GraftingToolItem; import lilypuree.forest_tree.trees.species.ModSpecies; import lilypuree.forest_tree.trees.species.Species; @@ -131,13 +132,13 @@ public static void forAllBranchEnds(Consumer action) { // public static final RegistryObject PINE_SAPLING = BLOCKS.register("fir_sapling", ()->new AdvancedSaplingBlock(new PineTree(), Block.Properties.create(Material.PLANTS).doesNotBlockMovement().tickRandomly().hardnessAndResistance(0f).sound(SoundType.PLANT))); // public static final RegistryObject PLACEBO_SAPLING = BLOCKS.register("sapling", () -> new AdvancedSaplingBlock(new CustomTree(), Block.Properties.create(Material.PLANTS).doesNotBlockMovement().tickRandomly().hardnessAndResistance(0f).sound(SoundType.PLANT))); public static final RegistryObject CUSTOM_SAPLING = BLOCKS.register("custom_sapling", () -> new CustomSaplingBlock(Block.Properties.create(Material.PLANTS).doesNotBlockMovement().tickRandomly().hardnessAndResistance(0f).sound(SoundType.PLANT))); - public static final RegistryObject CUSTOM_SAPLING_ITEM = ITEMS.register("custom_sapling", () -> new BlockItem(CUSTOM_SAPLING.get(), new Item.Properties().group(ITEM_GROUP))); + public static final RegistryObject CUSTOM_SAPLING_ITEM = ITEMS.register("custom_sapling", () -> new CustomSaplingItem(CUSTOM_SAPLING.get(), new Item.Properties().group(ITEM_GROUP))); public static final RegistryObject> CUSTOM_SAPLING_TILE = TILE_ENTITIES.register("custom_sapling", () -> TileEntityType.Builder.create(CustomSaplingTile::new, CUSTOM_SAPLING.get()).build(null)); public static final RegistryObject TREE_DESIGNER_BLOCK = BLOCKS.register("tree_designer", () -> new TreeDesignerBlock(Block.Properties.create(Material.EARTH))); public static final RegistryObject TREE_DESIGNER_ITEM = ITEMS.register("tree_designer", () -> new BlockItem(TREE_DESIGNER_BLOCK.get(), new Item.Properties().group(ITEM_GROUP))); public static final RegistryObject> TREE_DESIGNER_TILE = TILE_ENTITIES.register("tree_designer", () -> TileEntityType.Builder.create(TreeDesignerTile::new, TREE_DESIGNER_BLOCK.get()).build(null)); - public static final RegistryObject> TREE_DESIGNER_CONTAINER = CONTAINERS.register("tree_designer", () -> IForgeContainerType.create((TreeDesignerContainer::create))); + public static final RegistryObject> TREE_DESIGNER_CONTAINER = CONTAINERS.register("tree_designer", () -> IForgeContainerType.create((TreeDesignerContainer::getClientContainer))); // public static final ImmutableMap> TREE_BLOCKS; // public static final ImmutableMap> TREE_BLOCK_ITEMS; diff --git a/src/main/java/lilypuree/forest_tree/client/HologramRenderType.java b/src/main/java/lilypuree/forest_tree/client/HologramRenderType.java new file mode 100644 index 0000000..f540c4d --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/client/HologramRenderType.java @@ -0,0 +1,31 @@ +package lilypuree.forest_tree.client; + +import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.renderer.RenderState; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexFormat; +import org.lwjgl.opengl.GL14C; + +import static org.lwjgl.opengl.GL14C.GL_FUNC_ADD; + +public class HologramRenderType extends RenderType { + + public HologramRenderType(String nameIn, VertexFormat vertexFormatIn, int drawModeIn, int bufferSizeIn, boolean useDelegateIn, boolean needsSortingIn, Runnable setupTaskIn, Runnable clearTaskIn) { + super(nameIn, vertexFormatIn, drawModeIn, bufferSizeIn, useDelegateIn, needsSortingIn, setupTaskIn, clearTaskIn); + } + + public static final RenderState.TransparencyState HOLOGRAM_TRANSPARENCY = new RenderState.TransparencyState("hologram_transparency", ()->{ + RenderSystem.enableBlend(); + RenderSystem.blendColor(77/256.0f, 154/256.0f,128/256.0f,1.0f); + RenderSystem.blendEquation(GL_FUNC_ADD); + RenderSystem.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.CONSTANT_COLOR); + }, () -> { + RenderSystem.disableBlend(); + RenderSystem.defaultBlendFunc(); + }); + + public static final RenderType HOLOGRAM = makeType("hologram", DefaultVertexFormats.BLOCK, 7, 256, true, false, + RenderType.State.getBuilder().shadeModel(RenderState.SHADE_DISABLED).lightmap(RenderState.LIGHTMAP_DISABLED).texture(RenderState.BLOCK_SHEET).transparency(HOLOGRAM_TRANSPARENCY).alpha(RenderState.HALF_ALPHA).build(false)); +} diff --git a/src/main/java/lilypuree/forest_tree/client/RenderState.java b/src/main/java/lilypuree/forest_tree/client/RenderState.java new file mode 100644 index 0000000..af1df3a --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/client/RenderState.java @@ -0,0 +1,636 @@ +//package net.minecraft.client.renderer; +// +//import com.mojang.blaze3d.platform.GlStateManager; +//import com.mojang.blaze3d.systems.RenderSystem; +//import java.util.Objects; +//import java.util.Optional; +//import java.util.OptionalDouble; +//import javax.annotation.Nullable; +//import net.minecraft.client.Minecraft; +//import net.minecraft.client.renderer.texture.AtlasTexture; +//import net.minecraft.client.renderer.texture.TextureManager; +//import net.minecraft.util.ResourceLocation; +//import net.minecraft.util.Util; +//import net.minecraftforge.api.distmarker.Dist; +//import net.minecraftforge.api.distmarker.OnlyIn; +// +//@OnlyIn(Dist.CLIENT) +//public abstract class RenderState { +// protected final String name; +// private final Runnable setupTask; +// private final Runnable clearTask; +// protected static final RenderState.TransparencyState NO_TRANSPARENCY = new RenderState.TransparencyState("no_transparency", () -> { +// RenderSystem.disableBlend(); +// }, () -> { +// }); +// protected static final RenderState.TransparencyState ADDITIVE_TRANSPARENCY = new RenderState.TransparencyState("additive_transparency", () -> { +// RenderSystem.enableBlend(); +// RenderSystem.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE); +// }, () -> { +// RenderSystem.disableBlend(); +// RenderSystem.defaultBlendFunc(); +// }); +// protected static final RenderState.TransparencyState LIGHTNING_TRANSPARENCY = new RenderState.TransparencyState("lightning_transparency", () -> { +// RenderSystem.enableBlend(); +// RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE); +// }, () -> { +// RenderSystem.disableBlend(); +// RenderSystem.defaultBlendFunc(); +// }); +// protected static final RenderState.TransparencyState GLINT_TRANSPARENCY = new RenderState.TransparencyState("glint_transparency", () -> { +// RenderSystem.enableBlend(); +// RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE); +// }, () -> { +// RenderSystem.disableBlend(); +// RenderSystem.defaultBlendFunc(); +// }); +// protected static final RenderState.TransparencyState CRUMBLING_TRANSPARENCY = new RenderState.TransparencyState("crumbling_transparency", () -> { +// RenderSystem.enableBlend(); +// RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.DST_COLOR, GlStateManager.DestFactor.SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); +// }, () -> { +// RenderSystem.disableBlend(); +// RenderSystem.defaultBlendFunc(); +// }); +// protected static final RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = new RenderState.TransparencyState("translucent_transparency", () -> { +// RenderSystem.enableBlend(); +// RenderSystem.defaultBlendFunc(); +// }, () -> { +// RenderSystem.disableBlend(); +// }); +// protected static final RenderState.AlphaState ZERO_ALPHA = new RenderState.AlphaState(0.0F); +// protected static final RenderState.AlphaState DEFAULT_ALPHA = new RenderState.AlphaState(0.003921569F); +// protected static final RenderState.AlphaState HALF_ALPHA = new RenderState.AlphaState(0.5F); +// protected static final RenderState.ShadeModelState SHADE_DISABLED = new RenderState.ShadeModelState(false); +// protected static final RenderState.ShadeModelState SHADE_ENABLED = new RenderState.ShadeModelState(true); +// protected static final RenderState.TextureState BLOCK_SHEET_MIPPED = new RenderState.TextureState(AtlasTexture.LOCATION_BLOCKS_TEXTURE, false, true); +// protected static final RenderState.TextureState BLOCK_SHEET = new RenderState.TextureState(AtlasTexture.LOCATION_BLOCKS_TEXTURE, false, false); +// protected static final RenderState.TextureState NO_TEXTURE = new RenderState.TextureState(); +// protected static final RenderState.TexturingState DEFAULT_TEXTURING = new RenderState.TexturingState("default_texturing", () -> { +// }, () -> { +// }); +// protected static final RenderState.TexturingState OUTLINE_TEXTURING = new RenderState.TexturingState("outline_texturing", () -> { +// RenderSystem.setupOutline(); +// }, () -> { +// RenderSystem.teardownOutline(); +// }); +// protected static final RenderState.TexturingState GLINT_TEXTURING = new RenderState.TexturingState("glint_texturing", () -> { +// setupGlintTexturing(8.0F); +// }, () -> { +// RenderSystem.matrixMode(5890); +// RenderSystem.popMatrix(); +// RenderSystem.matrixMode(5888); +// }); +// protected static final RenderState.TexturingState ENTITY_GLINT_TEXTURING = new RenderState.TexturingState("entity_glint_texturing", () -> { +// setupGlintTexturing(0.16F); +// }, () -> { +// RenderSystem.matrixMode(5890); +// RenderSystem.popMatrix(); +// RenderSystem.matrixMode(5888); +// }); +// protected static final RenderState.LightmapState LIGHTMAP_ENABLED = new RenderState.LightmapState(true); +// protected static final RenderState.LightmapState LIGHTMAP_DISABLED = new RenderState.LightmapState(false); +// protected static final RenderState.OverlayState OVERLAY_ENABLED = new RenderState.OverlayState(true); +// protected static final RenderState.OverlayState OVERLAY_DISABLED = new RenderState.OverlayState(false); +// protected static final RenderState.DiffuseLightingState DIFFUSE_LIGHTING_ENABLED = new RenderState.DiffuseLightingState(true); +// protected static final RenderState.DiffuseLightingState DIFFUSE_LIGHTING_DISABLED = new RenderState.DiffuseLightingState(false); +// protected static final RenderState.CullState CULL_ENABLED = new RenderState.CullState(true); +// protected static final RenderState.CullState CULL_DISABLED = new RenderState.CullState(false); +// protected static final RenderState.DepthTestState DEPTH_ALWAYS = new RenderState.DepthTestState(519); +// protected static final RenderState.DepthTestState DEPTH_EQUAL = new RenderState.DepthTestState(514); +// protected static final RenderState.DepthTestState DEPTH_LEQUAL = new RenderState.DepthTestState(515); +// protected static final RenderState.WriteMaskState COLOR_DEPTH_WRITE = new RenderState.WriteMaskState(true, true); +// protected static final RenderState.WriteMaskState COLOR_WRITE = new RenderState.WriteMaskState(true, false); +// protected static final RenderState.WriteMaskState DEPTH_WRITE = new RenderState.WriteMaskState(false, true); +// protected static final RenderState.LayerState NO_LAYERING = new RenderState.LayerState("no_layering", () -> { +// }, () -> { +// }); +// protected static final RenderState.LayerState POLYGON_OFFSET_LAYERING = new RenderState.LayerState("polygon_offset_layering", () -> { +// RenderSystem.polygonOffset(-1.0F, -10.0F); +// RenderSystem.enablePolygonOffset(); +// }, () -> { +// RenderSystem.polygonOffset(0.0F, 0.0F); +// RenderSystem.disablePolygonOffset(); +// }); +// protected static final RenderState.LayerState PROJECTION_LAYERING = new RenderState.LayerState("projection_layering", () -> { +// RenderSystem.matrixMode(5889); +// RenderSystem.pushMatrix(); +// RenderSystem.scalef(1.0F, 1.0F, 0.999F); +// RenderSystem.matrixMode(5888); +// }, () -> { +// RenderSystem.matrixMode(5889); +// RenderSystem.popMatrix(); +// RenderSystem.matrixMode(5888); +// }); +// protected static final RenderState.FogState NO_FOG = new RenderState.FogState("no_fog", () -> { +// }, () -> { +// }); +// protected static final RenderState.FogState FOG = new RenderState.FogState("fog", () -> { +// FogRenderer.applyFog(); +// RenderSystem.enableFog(); +// }, () -> { +// RenderSystem.disableFog(); +// }); +// protected static final RenderState.FogState BLACK_FOG = new RenderState.FogState("black_fog", () -> { +// RenderSystem.fog(2918, 0.0F, 0.0F, 0.0F, 1.0F); +// RenderSystem.enableFog(); +// }, () -> { +// FogRenderer.applyFog(); +// RenderSystem.disableFog(); +// }); +// protected static final RenderState.TargetState MAIN_TARGET = new RenderState.TargetState("main_target", () -> { +// }, () -> { +// }); +// protected static final RenderState.TargetState OUTLINE_TARGET = new RenderState.TargetState("outline_target", () -> { +// Minecraft.getInstance().worldRenderer.getEntityOutlineFramebuffer().bindFramebuffer(false); +// }, () -> { +// Minecraft.getInstance().getFramebuffer().bindFramebuffer(false); +// }); +// protected static final RenderState.LineState DEFAULT_LINE = new RenderState.LineState(OptionalDouble.of(1.0D)); +// +// public RenderState(String nameIn, Runnable setupTaskIn, Runnable clearTaskIn) { +// this.name = nameIn; +// this.setupTask = setupTaskIn; +// this.clearTask = clearTaskIn; +// } +// +// public void setupRenderState() { +// this.setupTask.run(); +// } +// +// public void clearRenderState() { +// this.clearTask.run(); +// } +// +// public boolean equals(@Nullable Object object) { +// if (this == object) { +// return true; +// } else if (object != null && this.getClass() == object.getClass()) { +// RenderState renderstate = (RenderState)object; +// return this.name.equals(renderstate.name); +// } else { +// return false; +// } +// } +// +// public int hashCode() { +// return this.name.hashCode(); +// } +// +// private static void setupGlintTexturing(float scaleIn) { +// RenderSystem.matrixMode(5890); +// RenderSystem.pushMatrix(); +// RenderSystem.loadIdentity(); +// long i = Util.milliTime() * 8L; +// float f = (float)(i % 110000L) / 110000.0F; +// float f1 = (float)(i % 30000L) / 30000.0F; +// RenderSystem.translatef(-f, f1, 0.0F); +// RenderSystem.rotatef(10.0F, 0.0F, 0.0F, 1.0F); +// RenderSystem.scalef(scaleIn, scaleIn, scaleIn); +// RenderSystem.matrixMode(5888); +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class AlphaState extends RenderState { +// private final float ref; +// +// public AlphaState(float refIn) { +// super("alpha", () -> { +// if (refIn > 0.0F) { +// RenderSystem.enableAlphaTest(); +// RenderSystem.alphaFunc(516, refIn); +// } else { +// RenderSystem.disableAlphaTest(); +// } +// +// }, () -> { +// RenderSystem.disableAlphaTest(); +// RenderSystem.defaultAlphaFunc(); +// }); +// this.ref = refIn; +// } +// +// public boolean equals(@Nullable Object p_equals_1_) { +// if (this == p_equals_1_) { +// return true; +// } else if (p_equals_1_ != null && this.getClass() == p_equals_1_.getClass()) { +// if (!super.equals(p_equals_1_)) { +// return false; +// } else { +// return this.ref == ((RenderState.AlphaState)p_equals_1_).ref; +// } +// } else { +// return false; +// } +// } +// +// public int hashCode() { +// return Objects.hash(super.hashCode(), this.ref); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// static class BooleanState extends RenderState { +// private final boolean enabled; +// +// public BooleanState(String nameIn, Runnable setupTaskIn, Runnable clearTaskIn, boolean enabledIn) { +// super(nameIn, setupTaskIn, clearTaskIn); +// this.enabled = enabledIn; +// } +// +// public boolean equals(Object object) { +// if (this == object) { +// return true; +// } else if (object != null && this.getClass() == object.getClass()) { +// RenderState.BooleanState renderstate$booleanstate = (RenderState.BooleanState)object; +// return this.enabled == renderstate$booleanstate.enabled; +// } else { +// return false; +// } +// } +// +// public int hashCode() { +// return Boolean.hashCode(this.enabled); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class CullState extends RenderState.BooleanState { +// public CullState(boolean cull) { +// super("cull", () -> { +// if (cull) { +// RenderSystem.enableCull(); +// } +// +// }, () -> { +// if (cull) { +// RenderSystem.disableCull(); +// } +// +// }, cull); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class DepthTestState extends RenderState { +// private final int func; +// +// public DepthTestState(int depthFunc) { +// super("depth_test", () -> { +// if (depthFunc != 519) { +// RenderSystem.enableDepthTest(); +// RenderSystem.depthFunc(depthFunc); +// } +// +// }, () -> { +// if (depthFunc != 519) { +// RenderSystem.disableDepthTest(); +// RenderSystem.depthFunc(515); +// } +// +// }); +// this.func = depthFunc; +// } +// +// public boolean equals(Object object) { +// if (this == object) { +// return true; +// } else if (object != null && this.getClass() == object.getClass()) { +// RenderState.DepthTestState renderstate$depthteststate = (RenderState.DepthTestState)object; +// return this.func == renderstate$depthteststate.func; +// } else { +// return false; +// } +// } +// +// public int hashCode() { +// return Integer.hashCode(this.func); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class DiffuseLightingState extends RenderState.BooleanState { +// public DiffuseLightingState(boolean diffuseLighting) { +// super("diffuse_lighting", () -> { +// if (diffuseLighting) { +// RenderHelper.enableStandardItemLighting(); +// } +// +// }, () -> { +// if (diffuseLighting) { +// RenderHelper.disableStandardItemLighting(); +// } +// +// }, diffuseLighting); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class FogState extends RenderState { +// public FogState(String name, Runnable setupTaskIn, Runnable clearTaskIn) { +// super(name, setupTaskIn, clearTaskIn); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class LayerState extends RenderState { +// public LayerState(String nameIn, Runnable setupTaskIn, Runnable clearTaskIn) { +// super(nameIn, setupTaskIn, clearTaskIn); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class LightmapState extends RenderState.BooleanState { +// public LightmapState(boolean lightmap) { +// super("lightmap", () -> { +// if (lightmap) { +// Minecraft.getInstance().gameRenderer.getLightTexture().enableLightmap(); +// } +// +// }, () -> { +// if (lightmap) { +// Minecraft.getInstance().gameRenderer.getLightTexture().disableLightmap(); +// } +// +// }, lightmap); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class LineState extends RenderState { +// private final OptionalDouble width; +// +// public LineState(OptionalDouble optionalWidth) { +// super("line_width", () -> { // FORGE: fix MC-167447 +// if (!Objects.equals(optionalWidth, OptionalDouble.of(1.0D))) { +// if (optionalWidth.isPresent()) { +// RenderSystem.lineWidth((float)optionalWidth.getAsDouble()); +// } else { +// RenderSystem.lineWidth(Math.max(2.5F, (float)Minecraft.getInstance().getMainWindow().getFramebufferWidth() / 1920.0F * 2.5F)); +// } +// } +// +// }, () -> { +// if (!Objects.equals(optionalWidth, OptionalDouble.of(1.0D))) { +// RenderSystem.lineWidth(1.0F); +// } +// +// }); +// this.width = optionalWidth; +// } +// +// public boolean equals(@Nullable Object object) { +// if (this == object) { +// return true; +// } else if (object != null && this.getClass() == object.getClass()) { +// return !super.equals(object) ? false : Objects.equals(this.width, ((RenderState.LineState)object).width); +// } else { +// return false; +// } +// } +// +// public int hashCode() { +// return Objects.hash(super.hashCode(), this.width); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static final class OffsetTexturingState extends RenderState.TexturingState { +// private final float offsetU; +// private final float offsetV; +// +// public OffsetTexturingState(float offsetUIn, float offsetVIn) { +// super("offset_texturing", () -> { +// RenderSystem.matrixMode(5890); +// RenderSystem.pushMatrix(); +// RenderSystem.loadIdentity(); +// RenderSystem.translatef(offsetUIn, offsetVIn, 0.0F); +// RenderSystem.matrixMode(5888); +// }, () -> { +// RenderSystem.matrixMode(5890); +// RenderSystem.popMatrix(); +// RenderSystem.matrixMode(5888); +// }); +// this.offsetU = offsetUIn; +// this.offsetV = offsetVIn; +// } +// +// public boolean equals(Object object) { +// if (this == object) { +// return true; +// } else if (object != null && this.getClass() == object.getClass()) { +// RenderState.OffsetTexturingState renderstate$offsettexturingstate = (RenderState.OffsetTexturingState)object; +// return Float.compare(renderstate$offsettexturingstate.offsetU, this.offsetU) == 0 && Float.compare(renderstate$offsettexturingstate.offsetV, this.offsetV) == 0; +// } else { +// return false; +// } +// } +// +// public int hashCode() { +// return Objects.hash(this.offsetU, this.offsetV); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class OverlayState extends RenderState.BooleanState { +// public OverlayState(boolean overlay) { +// super("overlay", () -> { +// if (overlay) { +// Minecraft.getInstance().gameRenderer.getOverlayTexture().setupOverlayColor(); +// } +// +// }, () -> { +// if (overlay) { +// Minecraft.getInstance().gameRenderer.getOverlayTexture().teardownOverlayColor(); +// } +// +// }, overlay); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static final class PortalTexturingState extends RenderState.TexturingState { +// private final int iteration; +// +// public PortalTexturingState(int iterationIn) { +// super("portal_texturing", () -> { +// RenderSystem.matrixMode(5890); +// RenderSystem.pushMatrix(); +// RenderSystem.loadIdentity(); +// RenderSystem.translatef(0.5F, 0.5F, 0.0F); +// RenderSystem.scalef(0.5F, 0.5F, 1.0F); +// RenderSystem.translatef(17.0F / (float)iterationIn, (2.0F + (float)iterationIn / 1.5F) * ((float)(Util.milliTime() % 800000L) / 800000.0F), 0.0F); +// RenderSystem.rotatef(((float)(iterationIn * iterationIn) * 4321.0F + (float)iterationIn * 9.0F) * 2.0F, 0.0F, 0.0F, 1.0F); +// RenderSystem.scalef(4.5F - (float)iterationIn / 4.0F, 4.5F - (float)iterationIn / 4.0F, 1.0F); +// RenderSystem.mulTextureByProjModelView(); +// RenderSystem.matrixMode(5888); +// RenderSystem.setupEndPortalTexGen(); +// }, () -> { +// RenderSystem.matrixMode(5890); +// RenderSystem.popMatrix(); +// RenderSystem.matrixMode(5888); +// RenderSystem.clearTexGen(); +// }); +// this.iteration = iterationIn; +// } +// +// public boolean equals(Object object) { +// if (this == object) { +// return true; +// } else if (object != null && this.getClass() == object.getClass()) { +// RenderState.PortalTexturingState renderstate$portaltexturingstate = (RenderState.PortalTexturingState)object; +// return this.iteration == renderstate$portaltexturingstate.iteration; +// } else { +// return false; +// } +// } +// +// public int hashCode() { +// return Integer.hashCode(this.iteration); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class ShadeModelState extends RenderState { +// private final boolean smooth; +// +// public ShadeModelState(boolean p_i225987_1_) { +// super("shade_model", () -> { +// RenderSystem.shadeModel(p_i225987_1_ ? 7425 : 7424); +// }, () -> { +// RenderSystem.shadeModel(7424); +// }); +// this.smooth = p_i225987_1_; +// } +// +// public boolean equals(Object p_equals_1_) { +// if (this == p_equals_1_) { +// return true; +// } else if (p_equals_1_ != null && this.getClass() == p_equals_1_.getClass()) { +// RenderState.ShadeModelState renderstate$shademodelstate = (RenderState.ShadeModelState)p_equals_1_; +// return this.smooth == renderstate$shademodelstate.smooth; +// } else { +// return false; +// } +// } +// +// public int hashCode() { +// return Boolean.hashCode(this.smooth); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class TargetState extends RenderState { +// public TargetState(String name, Runnable setupTaskIn, Runnable clearTaskIn) { +// super(name, setupTaskIn, clearTaskIn); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class TextureState extends RenderState { +// private final Optional texture; +// private final boolean blur; +// private final boolean mipmap; +// +// public TextureState(ResourceLocation texture, boolean blurIn, boolean mipmapIn) { +// super("texture", () -> { +// RenderSystem.enableTexture(); +// TextureManager texturemanager = Minecraft.getInstance().getTextureManager(); +// texturemanager.bindTexture(texture); +// texturemanager.getTexture(texture).setBlurMipmapDirect(blurIn, mipmapIn); +// }, () -> { +// }); +// this.texture = Optional.of(texture); +// this.blur = blurIn; +// this.mipmap = mipmapIn; +// } +// +// public TextureState() { +// super("texture", () -> { +// RenderSystem.disableTexture(); +// }, () -> { +// RenderSystem.enableTexture(); +// }); +// this.texture = Optional.empty(); +// this.blur = false; +// this.mipmap = false; +// } +// +// public boolean equals(Object object) { +// if (this == object) { +// return true; +// } else if (object != null && this.getClass() == object.getClass()) { +// RenderState.TextureState renderstate$texturestate = (RenderState.TextureState)object; +// return this.texture.equals(renderstate$texturestate.texture) && this.blur == renderstate$texturestate.blur && this.mipmap == renderstate$texturestate.mipmap; +// } else { +// return false; +// } +// } +// +// public int hashCode() { +// return this.texture.hashCode(); +// } +// +// protected Optional texture() { +// return this.texture; +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class TexturingState extends RenderState { +// public TexturingState(String name, Runnable setupTask, Runnable clearTask) { +// super(name, setupTask, clearTask); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class TransparencyState extends RenderState { +// public TransparencyState(String name, Runnable setupTask, Runnable clearTask) { +// super(name, setupTask, clearTask); +// } +// } +// +// @OnlyIn(Dist.CLIENT) +// public static class WriteMaskState extends RenderState { +// private final boolean colorMask; +// private final boolean depthMask; +// +// public WriteMaskState(boolean colorMaskIn, boolean depthMaskIn) { +// super("write_mask_state", () -> { +// if (!depthMaskIn) { +// RenderSystem.depthMask(depthMaskIn); +// } +// +// if (!colorMaskIn) { +// RenderSystem.colorMask(colorMaskIn, colorMaskIn, colorMaskIn, colorMaskIn); +// } +// +// }, () -> { +// if (!depthMaskIn) { +// RenderSystem.depthMask(true); +// } +// +// if (!colorMaskIn) { +// RenderSystem.colorMask(true, true, true, true); +// } +// +// }); +// this.colorMask = colorMaskIn; +// this.depthMask = depthMaskIn; +// } +// +// public boolean equals(Object object) { +// if (this == object) { +// return true; +// } else if (object != null && this.getClass() == object.getClass()) { +// RenderState.WriteMaskState renderstate$writemaskstate = (RenderState.WriteMaskState)object; +// return this.colorMask == renderstate$writemaskstate.colorMask && this.depthMask == renderstate$writemaskstate.depthMask; +// } else { +// return false; +// } +// } +// +// public int hashCode() { +// return Objects.hash(this.colorMask, this.depthMask); +// } +// } +//} \ No newline at end of file diff --git a/src/main/java/lilypuree/forest_tree/client/RenderSystem.java b/src/main/java/lilypuree/forest_tree/client/RenderSystem.java new file mode 100644 index 0000000..5d9c6ef --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/client/RenderSystem.java @@ -0,0 +1,776 @@ +//// +//// Source code recreated from a .class file by IntelliJ IDEA +//// (powered by Fernflower decompiler) +//// +// +//package com.mojang.blaze3d.systems; +// +//import com.google.common.collect.Queues; +//import com.mojang.blaze3d.platform.GLX; +//import com.mojang.blaze3d.platform.GlStateManager; +//import com.mojang.blaze3d.platform.GlStateManager.DestFactor; +//import com.mojang.blaze3d.platform.GlStateManager.FogMode; +//import com.mojang.blaze3d.platform.GlStateManager.LogicOp; +//import com.mojang.blaze3d.platform.GlStateManager.SourceFactor; +//import java.nio.ByteBuffer; +//import java.nio.FloatBuffer; +//import java.nio.IntBuffer; +//import java.util.concurrent.ConcurrentLinkedQueue; +//import java.util.function.Consumer; +//import java.util.function.IntSupplier; +//import java.util.function.LongSupplier; +//import java.util.function.Supplier; +//import net.minecraft.client.renderer.Matrix4f; +//import net.minecraft.client.renderer.Tessellator; +//import net.minecraftforge.api.distmarker.Dist; +//import net.minecraftforge.api.distmarker.OnlyIn; +//import org.apache.logging.log4j.LogManager; +//import org.apache.logging.log4j.Logger; +//import org.lwjgl.glfw.GLFW; +//import org.lwjgl.glfw.GLFWErrorCallbackI; +// +//@OnlyIn(Dist.CLIENT) +//public class RenderSystem { +// private static final Logger LOGGER = LogManager.getLogger(); +// private static final ConcurrentLinkedQueue recordingQueue = Queues.newConcurrentLinkedQueue(); +// private static final Tessellator RENDER_THREAD_TESSELATOR = new Tessellator(); +// public static final float DEFAULTALPHACUTOFF = 0.1F; +// private static final int MINIMUM_ATLAS_TEXTURE_SIZE = 1024; +// private static boolean isReplayingQueue; +// private static Thread gameThread; +// private static Thread renderThread; +// private static int MAX_SUPPORTED_TEXTURE_SIZE = -1; +// private static boolean isInInit; +// private static double lastDrawTime = 4.9E-324D; +// +// public RenderSystem() { +// } +// +// public static void initRenderThread() { +// if (renderThread == null && gameThread != Thread.currentThread()) { +// renderThread = Thread.currentThread(); +// } else { +// throw new IllegalStateException("Could not initialize render thread"); +// } +// } +// +// public static boolean isOnRenderThread() { +// return Thread.currentThread() == renderThread; +// } +// +// public static boolean isOnRenderThreadOrInit() { +// return isInInit || isOnRenderThread(); +// } +// +// public static void initGameThread(boolean p_initGameThread_0_) { +// boolean lvt_1_1_ = renderThread == Thread.currentThread(); +// if (gameThread == null && renderThread != null && lvt_1_1_ != p_initGameThread_0_) { +// gameThread = Thread.currentThread(); +// } else { +// throw new IllegalStateException("Could not initialize tick thread"); +// } +// } +// +// public static boolean isOnGameThread() { +// return true; +// } +// +// public static boolean isOnGameThreadOrInit() { +// return isInInit || isOnGameThread(); +// } +// +// public static void assertThread(Supplier p_assertThread_0_) { +// if (!(Boolean)p_assertThread_0_.get()) { +// throw new IllegalStateException("Rendersystem called from wrong thread"); +// } +// } +// +// public static boolean isInInitPhase() { +// return true; +// } +// +// public static void recordRenderCall(IRenderCall p_recordRenderCall_0_) { +// recordingQueue.add(p_recordRenderCall_0_); +// } +// +// public static void flipFrame(long p_flipFrame_0_) { +// GLFW.glfwPollEvents(); +// replayQueue(); +// Tessellator.getInstance().getBuffer().reset(); +// GLFW.glfwSwapBuffers(p_flipFrame_0_); +// GLFW.glfwPollEvents(); +// } +// +// public static void replayQueue() { +// isReplayingQueue = true; +// +// while(!recordingQueue.isEmpty()) { +// IRenderCall lvt_0_1_ = (IRenderCall)recordingQueue.poll(); +// lvt_0_1_.execute(); +// } +// +// isReplayingQueue = false; +// } +// +// public static void limitDisplayFPS(int p_limitDisplayFPS_0_) { +// double lvt_1_1_ = lastDrawTime + 1.0D / (double)p_limitDisplayFPS_0_; +// +// double lvt_3_1_; +// for(lvt_3_1_ = GLFW.glfwGetTime(); lvt_3_1_ < lvt_1_1_; lvt_3_1_ = GLFW.glfwGetTime()) { +// GLFW.glfwWaitEventsTimeout(lvt_1_1_ - lvt_3_1_); +// } +// +// lastDrawTime = lvt_3_1_; +// } +// +// public static void pushLightingAttributes() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.pushLightingAttributes(); +// } +// +// public static void pushTextureAttributes() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.pushTextureAttributes(); +// } +// +// public static void popAttributes() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.popAttributes(); +// } +// +// public static void disableAlphaTest() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disableAlphaTest(); +// } +// +// public static void enableAlphaTest() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.enableAlphaTest(); +// } +// +// public static void alphaFunc(int p_alphaFunc_0_, float p_alphaFunc_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.alphaFunc(p_alphaFunc_0_, p_alphaFunc_1_); +// } +// +// public static void enableLighting() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.enableLighting(); +// } +// +// public static void disableLighting() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disableLighting(); +// } +// +// public static void enableColorMaterial() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.enableColorMaterial(); +// } +// +// public static void disableColorMaterial() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disableColorMaterial(); +// } +// +// public static void colorMaterial(int p_colorMaterial_0_, int p_colorMaterial_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.colorMaterial(p_colorMaterial_0_, p_colorMaterial_1_); +// } +// +// public static void normal3f(float p_normal3f_0_, float p_normal3f_1_, float p_normal3f_2_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.normal3f(p_normal3f_0_, p_normal3f_1_, p_normal3f_2_); +// } +// +// public static void disableDepthTest() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disableDepthTest(); +// } +// +// public static void enableDepthTest() { +// assertThread(RenderSystem::isOnGameThreadOrInit); +// GlStateManager.enableDepthTest(); +// } +// +// public static void depthFunc(int p_depthFunc_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.depthFunc(p_depthFunc_0_); +// } +// +// public static void depthMask(boolean p_depthMask_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.depthMask(p_depthMask_0_); +// } +// +// public static void enableBlend() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.enableBlend(); +// } +// +// public static void disableBlend() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disableBlend(); +// } +// +// public static void blendFunc(SourceFactor p_blendFunc_0_, DestFactor p_blendFunc_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.blendFunc(p_blendFunc_0_.param, p_blendFunc_1_.param); +// } +// +// public static void blendFunc(int p_blendFunc_0_, int p_blendFunc_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.blendFunc(p_blendFunc_0_, p_blendFunc_1_); +// } +// +// public static void blendFuncSeparate(SourceFactor p_blendFuncSeparate_0_, DestFactor p_blendFuncSeparate_1_, SourceFactor p_blendFuncSeparate_2_, DestFactor p_blendFuncSeparate_3_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.blendFuncSeparate(p_blendFuncSeparate_0_.param, p_blendFuncSeparate_1_.param, p_blendFuncSeparate_2_.param, p_blendFuncSeparate_3_.param); +// } +// +// public static void blendFuncSeparate(int p_blendFuncSeparate_0_, int p_blendFuncSeparate_1_, int p_blendFuncSeparate_2_, int p_blendFuncSeparate_3_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.blendFuncSeparate(p_blendFuncSeparate_0_, p_blendFuncSeparate_1_, p_blendFuncSeparate_2_, p_blendFuncSeparate_3_); +// } +// +// public static void blendEquation(int p_blendEquation_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.blendEquation(p_blendEquation_0_); +// } +// +// public static void blendColor(float p_blendColor_0_, float p_blendColor_1_, float p_blendColor_2_, float p_blendColor_3_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.blendColor(p_blendColor_0_, p_blendColor_1_, p_blendColor_2_, p_blendColor_3_); +// } +// +// public static void enableFog() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.enableFog(); +// } +// +// public static void disableFog() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disableFog(); +// } +// +// public static void fogMode(FogMode p_fogMode_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.fogMode(p_fogMode_0_.param); +// } +// +// public static void fogMode(int p_fogMode_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.fogMode(p_fogMode_0_); +// } +// +// public static void fogDensity(float p_fogDensity_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.fogDensity(p_fogDensity_0_); +// } +// +// public static void fogStart(float p_fogStart_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.fogStart(p_fogStart_0_); +// } +// +// public static void fogEnd(float p_fogEnd_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.fogEnd(p_fogEnd_0_); +// } +// +// public static void fog(int p_fog_0_, float p_fog_1_, float p_fog_2_, float p_fog_3_, float p_fog_4_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.fog(p_fog_0_, new float[]{p_fog_1_, p_fog_2_, p_fog_3_, p_fog_4_}); +// } +// +// public static void fogi(int p_fogi_0_, int p_fogi_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.fogi(p_fogi_0_, p_fogi_1_); +// } +// +// public static void enableCull() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.enableCull(); +// } +// +// public static void disableCull() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disableCull(); +// } +// +// public static void polygonMode(int p_polygonMode_0_, int p_polygonMode_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.polygonMode(p_polygonMode_0_, p_polygonMode_1_); +// } +// +// public static void enablePolygonOffset() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.enablePolygonOffset(); +// } +// +// public static void disablePolygonOffset() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disablePolygonOffset(); +// } +// +// public static void enableLineOffset() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.enableLineOffset(); +// } +// +// public static void disableLineOffset() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disableLineOffset(); +// } +// +// public static void polygonOffset(float p_polygonOffset_0_, float p_polygonOffset_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.polygonOffset(p_polygonOffset_0_, p_polygonOffset_1_); +// } +// +// public static void enableColorLogicOp() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.enableColorLogicOp(); +// } +// +// public static void disableColorLogicOp() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disableColorLogicOp(); +// } +// +// public static void logicOp(LogicOp p_logicOp_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.logicOp(p_logicOp_0_.opcode); +// } +// +// public static void activeTexture(int p_activeTexture_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.activeTexture(p_activeTexture_0_); +// } +// +// public static void enableTexture() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.enableTexture(); +// } +// +// public static void disableTexture() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disableTexture(); +// } +// +// public static void texParameter(int p_texParameter_0_, int p_texParameter_1_, int p_texParameter_2_) { +// GlStateManager.texParameter(p_texParameter_0_, p_texParameter_1_, p_texParameter_2_); +// } +// +// public static void deleteTexture(int p_deleteTexture_0_) { +// assertThread(RenderSystem::isOnGameThreadOrInit); +// GlStateManager.deleteTexture(p_deleteTexture_0_); +// } +// +// public static void bindTexture(int p_bindTexture_0_) { +// GlStateManager.bindTexture(p_bindTexture_0_); +// } +// +// public static void shadeModel(int p_shadeModel_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.shadeModel(p_shadeModel_0_); +// } +// +// public static void enableRescaleNormal() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.enableRescaleNormal(); +// } +// +// public static void disableRescaleNormal() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.disableRescaleNormal(); +// } +// +// public static void viewport(int p_viewport_0_, int p_viewport_1_, int p_viewport_2_, int p_viewport_3_) { +// assertThread(RenderSystem::isOnGameThreadOrInit); +// GlStateManager.viewport(p_viewport_0_, p_viewport_1_, p_viewport_2_, p_viewport_3_); +// } +// +// public static void colorMask(boolean p_colorMask_0_, boolean p_colorMask_1_, boolean p_colorMask_2_, boolean p_colorMask_3_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.colorMask(p_colorMask_0_, p_colorMask_1_, p_colorMask_2_, p_colorMask_3_); +// } +// +// public static void stencilFunc(int p_stencilFunc_0_, int p_stencilFunc_1_, int p_stencilFunc_2_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.stencilFunc(p_stencilFunc_0_, p_stencilFunc_1_, p_stencilFunc_2_); +// } +// +// public static void stencilMask(int p_stencilMask_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.stencilMask(p_stencilMask_0_); +// } +// +// public static void stencilOp(int p_stencilOp_0_, int p_stencilOp_1_, int p_stencilOp_2_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.stencilOp(p_stencilOp_0_, p_stencilOp_1_, p_stencilOp_2_); +// } +// +// public static void clearDepth(double p_clearDepth_0_) { +// assertThread(RenderSystem::isOnGameThreadOrInit); +// GlStateManager.clearDepth(p_clearDepth_0_); +// } +// +// public static void clearColor(float p_clearColor_0_, float p_clearColor_1_, float p_clearColor_2_, float p_clearColor_3_) { +// assertThread(RenderSystem::isOnGameThreadOrInit); +// GlStateManager.clearColor(p_clearColor_0_, p_clearColor_1_, p_clearColor_2_, p_clearColor_3_); +// } +// +// public static void clearStencil(int p_clearStencil_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.clearStencil(p_clearStencil_0_); +// } +// +// public static void clear(int p_clear_0_, boolean p_clear_1_) { +// assertThread(RenderSystem::isOnGameThreadOrInit); +// GlStateManager.clear(p_clear_0_, p_clear_1_); +// } +// +// public static void matrixMode(int p_matrixMode_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.matrixMode(p_matrixMode_0_); +// } +// +// public static void loadIdentity() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.loadIdentity(); +// } +// +// public static void pushMatrix() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.pushMatrix(); +// } +// +// public static void popMatrix() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.popMatrix(); +// } +// +// public static void ortho(double p_ortho_0_, double p_ortho_2_, double p_ortho_4_, double p_ortho_6_, double p_ortho_8_, double p_ortho_10_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.ortho(p_ortho_0_, p_ortho_2_, p_ortho_4_, p_ortho_6_, p_ortho_8_, p_ortho_10_); +// } +// +// public static void rotatef(float angle, float x, float y, float z) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.rotatef(angle, x, y, z); +// } +// +// public static void scalef(float x, float y, float z) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.scalef(x, y, z); +// } +// +// public static void scaled(double p_scaled_0_, double p_scaled_2_, double p_scaled_4_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.scaled(p_scaled_0_, p_scaled_2_, p_scaled_4_); +// } +// +// public static void translatef(float x, float y, float z) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.translatef(x, y, z); +// } +// +// public static void translated(double p_translated_0_, double p_translated_2_, double p_translated_4_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.translated(p_translated_0_, p_translated_2_, p_translated_4_); +// } +// +// public static void multMatrix(Matrix4f p_multMatrix_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.multMatrix(p_multMatrix_0_); +// } +// +// public static void color4f(float p_color4f_0_, float p_color4f_1_, float p_color4f_2_, float p_color4f_3_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.color4f(p_color4f_0_, p_color4f_1_, p_color4f_2_, p_color4f_3_); +// } +// +// public static void color3f(float p_color3f_0_, float p_color3f_1_, float p_color3f_2_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.color4f(p_color3f_0_, p_color3f_1_, p_color3f_2_, 1.0F); +// } +// +// public static void clearCurrentColor() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.clearCurrentColor(); +// } +// +// public static void drawArrays(int p_drawArrays_0_, int p_drawArrays_1_, int p_drawArrays_2_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.drawArrays(p_drawArrays_0_, p_drawArrays_1_, p_drawArrays_2_); +// } +// +// public static void lineWidth(float p_lineWidth_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.lineWidth(p_lineWidth_0_); +// } +// +// public static void pixelStore(int p_pixelStore_0_, int p_pixelStore_1_) { +// assertThread(RenderSystem::isOnGameThreadOrInit); +// GlStateManager.pixelStore(p_pixelStore_0_, p_pixelStore_1_); +// } +// +// public static void pixelTransfer(int p_pixelTransfer_0_, float p_pixelTransfer_1_) { +// GlStateManager.pixelTransfer(p_pixelTransfer_0_, p_pixelTransfer_1_); +// } +// +// public static void readPixels(int p_readPixels_0_, int p_readPixels_1_, int p_readPixels_2_, int p_readPixels_3_, int p_readPixels_4_, int p_readPixels_5_, ByteBuffer p_readPixels_6_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.readPixels(p_readPixels_0_, p_readPixels_1_, p_readPixels_2_, p_readPixels_3_, p_readPixels_4_, p_readPixels_5_, p_readPixels_6_); +// } +// +// public static void getString(int p_getString_0_, Consumer p_getString_1_) { +// assertThread(RenderSystem::isOnGameThread); +// p_getString_1_.accept(GlStateManager.getString(p_getString_0_)); +// } +// +// public static String getBackendDescription() { +// assertThread(RenderSystem::isInInitPhase); +// return String.format("LWJGL version %s", GLX._getLWJGLVersion()); +// } +// +// public static String getApiDescription() { +// assertThread(RenderSystem::isInInitPhase); +// return GLX.getOpenGLVersionString(); +// } +// +// public static LongSupplier initBackendSystem() { +// assertThread(RenderSystem::isInInitPhase); +// return GLX._initGlfw(); +// } +// +// public static void initRenderer(int p_initRenderer_0_, boolean p_initRenderer_1_) { +// assertThread(RenderSystem::isInInitPhase); +// GLX._init(p_initRenderer_0_, p_initRenderer_1_); +// } +// +// public static void setErrorCallback(GLFWErrorCallbackI p_setErrorCallback_0_) { +// assertThread(RenderSystem::isInInitPhase); +// GLX._setGlfwErrorCallback(p_setErrorCallback_0_); +// } +// +// public static void renderCrosshair(int p_renderCrosshair_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GLX._renderCrosshair(p_renderCrosshair_0_, true, true, true); +// } +// +// public static void setupNvFogDistance() { +// assertThread(RenderSystem::isOnGameThread); +// GLX._setupNvFogDistance(); +// } +// +// public static void glMultiTexCoord2f(int p_glMultiTexCoord2f_0_, float p_glMultiTexCoord2f_1_, float p_glMultiTexCoord2f_2_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.multiTexCoord2f(p_glMultiTexCoord2f_0_, p_glMultiTexCoord2f_1_, p_glMultiTexCoord2f_2_); +// } +// +// public static String getCapsString() { +// assertThread(RenderSystem::isOnGameThread); +// return GLX._getCapsString(); +// } +// +// public static void setupDefaultState(int p_setupDefaultState_0_, int p_setupDefaultState_1_, int p_setupDefaultState_2_, int p_setupDefaultState_3_) { +// assertThread(RenderSystem::isInInitPhase); +// GlStateManager.enableTexture(); +// GlStateManager.shadeModel(7425); +// GlStateManager.clearDepth(1.0D); +// GlStateManager.enableDepthTest(); +// GlStateManager.depthFunc(515); +// GlStateManager.enableAlphaTest(); +// GlStateManager.alphaFunc(516, 0.1F); +// GlStateManager.matrixMode(5889); +// GlStateManager.loadIdentity(); +// GlStateManager.matrixMode(5888); +// GlStateManager.viewport(p_setupDefaultState_0_, p_setupDefaultState_1_, p_setupDefaultState_2_, p_setupDefaultState_3_); +// } +// +// public static int maxSupportedTextureSize() { +// assertThread(RenderSystem::isInInitPhase); +// if (MAX_SUPPORTED_TEXTURE_SIZE == -1) { +// int lvt_0_1_ = GlStateManager.getInteger(3379); +// +// for(int lvt_1_1_ = Math.max(32768, lvt_0_1_); lvt_1_1_ >= 1024; lvt_1_1_ >>= 1) { +// GlStateManager.texImage2D(32868, 0, 6408, lvt_1_1_, lvt_1_1_, 0, 6408, 5121, (IntBuffer)null); +// int lvt_2_1_ = GlStateManager.getTexLevelParameter(32868, 0, 4096); +// if (lvt_2_1_ != 0) { +// MAX_SUPPORTED_TEXTURE_SIZE = lvt_1_1_; +// return lvt_1_1_; +// } +// } +// +// MAX_SUPPORTED_TEXTURE_SIZE = Math.max(lvt_0_1_, 1024); +// LOGGER.info("Failed to determine maximum texture size by probing, trying GL_MAX_TEXTURE_SIZE = {}", MAX_SUPPORTED_TEXTURE_SIZE); +// } +// +// return MAX_SUPPORTED_TEXTURE_SIZE; +// } +// +// public static void glBindBuffer(int p_glBindBuffer_0_, Supplier p_glBindBuffer_1_) { +// GlStateManager.bindBuffer(p_glBindBuffer_0_, (Integer)p_glBindBuffer_1_.get()); +// } +// +// public static void glBufferData(int p_glBufferData_0_, ByteBuffer p_glBufferData_1_, int p_glBufferData_2_) { +// assertThread(RenderSystem::isOnRenderThreadOrInit); +// GlStateManager.bufferData(p_glBufferData_0_, p_glBufferData_1_, p_glBufferData_2_); +// } +// +// public static void glDeleteBuffers(int p_glDeleteBuffers_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.deleteBuffers(p_glDeleteBuffers_0_); +// } +// +// public static void glUniform1i(int p_glUniform1i_0_, int p_glUniform1i_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniform1i(p_glUniform1i_0_, p_glUniform1i_1_); +// } +// +// public static void glUniform1(int p_glUniform1_0_, IntBuffer p_glUniform1_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniform1i(p_glUniform1_0_, p_glUniform1_1_); +// } +// +// public static void glUniform2(int p_glUniform2_0_, IntBuffer p_glUniform2_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniform2i(p_glUniform2_0_, p_glUniform2_1_); +// } +// +// public static void glUniform3(int p_glUniform3_0_, IntBuffer p_glUniform3_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniform3i(p_glUniform3_0_, p_glUniform3_1_); +// } +// +// public static void glUniform4(int p_glUniform4_0_, IntBuffer p_glUniform4_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniform4i(p_glUniform4_0_, p_glUniform4_1_); +// } +// +// public static void glUniform1(int p_glUniform1_0_, FloatBuffer p_glUniform1_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniform1f(p_glUniform1_0_, p_glUniform1_1_); +// } +// +// public static void glUniform2(int p_glUniform2_0_, FloatBuffer p_glUniform2_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniform2f(p_glUniform2_0_, p_glUniform2_1_); +// } +// +// public static void glUniform3(int p_glUniform3_0_, FloatBuffer p_glUniform3_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniform3f(p_glUniform3_0_, p_glUniform3_1_); +// } +// +// public static void glUniform4(int p_glUniform4_0_, FloatBuffer p_glUniform4_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniform4f(p_glUniform4_0_, p_glUniform4_1_); +// } +// +// public static void glUniformMatrix2(int p_glUniformMatrix2_0_, boolean p_glUniformMatrix2_1_, FloatBuffer p_glUniformMatrix2_2_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniformMatrix2f(p_glUniformMatrix2_0_, p_glUniformMatrix2_1_, p_glUniformMatrix2_2_); +// } +// +// public static void glUniformMatrix3(int p_glUniformMatrix3_0_, boolean p_glUniformMatrix3_1_, FloatBuffer p_glUniformMatrix3_2_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniformMatrix3f(p_glUniformMatrix3_0_, p_glUniformMatrix3_1_, p_glUniformMatrix3_2_); +// } +// +// public static void glUniformMatrix4(int p_glUniformMatrix4_0_, boolean p_glUniformMatrix4_1_, FloatBuffer p_glUniformMatrix4_2_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.uniformMatrix4f(p_glUniformMatrix4_0_, p_glUniformMatrix4_1_, p_glUniformMatrix4_2_); +// } +// +// public static void setupOutline() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.setupOutline(); +// } +// +// public static void teardownOutline() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.teardownOutline(); +// } +// +// public static void setupOverlayColor(IntSupplier p_setupOverlayColor_0_, int p_setupOverlayColor_1_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.setupOverlayColor(p_setupOverlayColor_0_.getAsInt(), p_setupOverlayColor_1_); +// } +// +// public static void teardownOverlayColor() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.teardownOverlayColor(); +// } +// +// public static void setupLevelDiffuseLighting(Matrix4f p_setupLevelDiffuseLighting_0_) { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.setupWorldDiffuseLighting(p_setupLevelDiffuseLighting_0_); +// } +// +// public static void setupGuiFlatDiffuseLighting() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.setupGuiFlatDiffuseLighting(); +// } +// +// public static void setupGui3DDiffuseLighting() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.setupGui3DDiffuseLighting(); +// } +// +// public static void mulTextureByProjModelView() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.mulTextureByProjModelView(); +// } +// +// public static void setupEndPortalTexGen() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.setupEndPortalTexGen(); +// } +// +// public static void clearTexGen() { +// assertThread(RenderSystem::isOnGameThread); +// GlStateManager.clearTexGen(); +// } +// +// public static void beginInitialization() { +// isInInit = true; +// } +// +// public static void finishInitialization() { +// isInInit = false; +// if (!recordingQueue.isEmpty()) { +// replayQueue(); +// } +// +// if (!recordingQueue.isEmpty()) { +// throw new IllegalStateException("Recorded to render queue during initialization"); +// } +// } +// +// public static void glGenBuffers(Consumer p_glGenBuffers_0_) { +// if (!isOnRenderThread()) { +// recordRenderCall(() -> { +// p_glGenBuffers_0_.accept(GlStateManager.genBuffers()); +// }); +// } else { +// p_glGenBuffers_0_.accept(GlStateManager.genBuffers()); +// } +// +// } +// +// public static Tessellator renderThreadTesselator() { +// assertThread(RenderSystem::isOnRenderThread); +// return RENDER_THREAD_TESSELATOR; +// } +// +// public static void defaultBlendFunc() { +// blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); +// } +// +// public static void defaultAlphaFunc() { +// alphaFunc(516, 0.1F); +// } +//} diff --git a/src/main/java/lilypuree/forest_tree/client/RenderType.java b/src/main/java/lilypuree/forest_tree/client/RenderType.java new file mode 100644 index 0000000..e501f65 --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/client/RenderType.java @@ -0,0 +1,528 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + +package net.minecraft.client.renderer; + +import com.google.common.collect.ImmutableList; +import it.unimi.dsi.fastutil.Hash.Strategy; +import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.OptionalDouble; +import javax.annotation.Nullable; + +import net.minecraft.client.renderer.tileentity.EndPortalTileEntityRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) +public abstract class RenderType extends RenderState { + + + + private static final RenderType SOLID; + private static final RenderType CUTOUT_MIPPED; + private static final RenderType CUTOUT; + private static final RenderType TRANSLUCENT; + private static final RenderType TRANSLUCENT_NO_CRUMBLING; + private static final RenderType LEASH; + private static final RenderType WATER_MASK; + private static final RenderType GLINT; + private static final RenderType ENTITY_GLINT; + private static final RenderType LIGHTNING; + public static final RenderType.Type LINES; + private final VertexFormat vertexFormat; + private final int drawMode; + private final int bufferSize; + private final boolean useDelegate; + private final boolean needsSorting; + private final Optional field_230166_ag_; + + public static RenderType getSolid() { + return SOLID; + } + + public static RenderType getCutoutMipped() { + return CUTOUT_MIPPED; + } + + public static RenderType getCutout() { + return CUTOUT; + } + + private static RenderType.State getTranslucentState() { + return RenderType.State.getBuilder().shadeModel(SHADE_ENABLED).lightmap(LIGHTMAP_ENABLED).texture(BLOCK_SHEET_MIPPED).transparency(TRANSLUCENT_TRANSPARENCY).build(true); + } + + public static RenderType getTranslucent() { + return TRANSLUCENT; + } + + public static RenderType getTranslucentNoCrumbling() { + return TRANSLUCENT_NO_CRUMBLING; + } + + public static RenderType getEntitySolid(ResourceLocation texture) { + RenderType.State renderState = RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).transparency(NO_TRANSPARENCY).diffuseLighting(DIFFUSE_LIGHTING_ENABLED).lightmap(LIGHTMAP_ENABLED).overlay(OVERLAY_ENABLED).build(true); + return makeType("entity_solid", DefaultVertexFormats.ENTITY, 7, 256, true, false, renderState); + } + + public static RenderType getEntityCutout(ResourceLocation p_228638_0_) { + RenderType.State lvt_1_1_ = RenderType.State.getBuilder().texture(new TextureState(p_228638_0_, false, false)).transparency(NO_TRANSPARENCY).diffuseLighting(DIFFUSE_LIGHTING_ENABLED).alpha(DEFAULT_ALPHA).lightmap(LIGHTMAP_ENABLED).overlay(OVERLAY_ENABLED).build(true); + return makeType("entity_cutout", DefaultVertexFormats.ENTITY, 7, 256, true, false, lvt_1_1_); + } + + public static RenderType getEntityCutoutNoCull(ResourceLocation p_230167_0_, boolean p_230167_1_) { + RenderType.State lvt_2_1_ = RenderType.State.getBuilder().texture(new TextureState(p_230167_0_, false, false)).transparency(NO_TRANSPARENCY).diffuseLighting(DIFFUSE_LIGHTING_ENABLED).alpha(DEFAULT_ALPHA).cull(CULL_DISABLED).lightmap(LIGHTMAP_ENABLED).overlay(OVERLAY_ENABLED).build(p_230167_1_); + return makeType("entity_cutout_no_cull", DefaultVertexFormats.ENTITY, 7, 256, true, false, lvt_2_1_); + } + + public static RenderType getEntityCutoutNoCull(ResourceLocation p_228640_0_) { + return getEntityCutoutNoCull(p_228640_0_, true); + } + + public static RenderType getEntityTranslucentCull(ResourceLocation texture) { + RenderType.State renderState = RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).transparency(TRANSLUCENT_TRANSPARENCY).diffuseLighting(DIFFUSE_LIGHTING_ENABLED).alpha(DEFAULT_ALPHA).lightmap(LIGHTMAP_ENABLED).overlay(OVERLAY_ENABLED).build(true); + return makeType("entity_translucent_cull", DefaultVertexFormats.ENTITY, 7, 256, true, true, renderState); + } + + public static RenderType getEntityTranslucent(ResourceLocation texture, boolean outline) { + RenderType.State renderState = RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).transparency(TRANSLUCENT_TRANSPARENCY).diffuseLighting(DIFFUSE_LIGHTING_ENABLED).alpha(DEFAULT_ALPHA).cull(CULL_DISABLED).lightmap(LIGHTMAP_ENABLED).overlay(OVERLAY_ENABLED).build(outline); + return makeType("entity_translucent", DefaultVertexFormats.ENTITY, 7, 256, true, true, renderState); + } + + public static RenderType getEntityTranslucent(ResourceLocation p_228644_0_) { + return getEntityTranslucent(p_228644_0_, true); + } + + public static RenderType getEntitySmoothCutout(ResourceLocation p_228646_0_) { + RenderType.State lvt_1_1_ = RenderType.State.getBuilder().texture(new TextureState(p_228646_0_, false, false)).alpha(HALF_ALPHA).diffuseLighting(DIFFUSE_LIGHTING_ENABLED).shadeModel(SHADE_ENABLED).cull(CULL_DISABLED).lightmap(LIGHTMAP_ENABLED).build(true); + return makeType("entity_smooth_cutout", DefaultVertexFormats.ENTITY, 7, 256, lvt_1_1_); + } + + public static RenderType getBeaconBeam(ResourceLocation texture, boolean isTransparent) { + RenderType.State renderState = RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).transparency(isTransparent ? TRANSLUCENT_TRANSPARENCY : NO_TRANSPARENCY).writeMask(isTransparent ? COLOR_WRITE : COLOR_DEPTH_WRITE).fog(NO_FOG).build(false); + return makeType("beacon_beam", DefaultVertexFormats.BLOCK, 7, 256, false, true, renderState); + } + + public static RenderType getEntityDecal(ResourceLocation p_228648_0_) { + RenderType.State lvt_1_1_ = RenderType.State.getBuilder().texture(new TextureState(p_228648_0_, false, false)).diffuseLighting(DIFFUSE_LIGHTING_ENABLED).alpha(DEFAULT_ALPHA).depthTest(DEPTH_EQUAL).cull(CULL_DISABLED).lightmap(LIGHTMAP_ENABLED).overlay(OVERLAY_ENABLED).build(false); + return makeType("entity_decal", DefaultVertexFormats.ENTITY, 7, 256, lvt_1_1_); + } + + public static RenderType getEntityNoOutline(ResourceLocation p_228650_0_) { + RenderType.State lvt_1_1_ = RenderType.State.getBuilder().texture(new TextureState(p_228650_0_, false, false)).transparency(TRANSLUCENT_TRANSPARENCY).diffuseLighting(DIFFUSE_LIGHTING_ENABLED).alpha(DEFAULT_ALPHA).cull(CULL_DISABLED).lightmap(LIGHTMAP_ENABLED).overlay(OVERLAY_ENABLED).writeMask(COLOR_WRITE).build(false); + return makeType("entity_no_outline", DefaultVertexFormats.ENTITY, 7, 256, false, true, lvt_1_1_); + } + + public static RenderType getEntityAlpha(ResourceLocation p_228635_0_, float p_228635_1_) { + RenderType.State renderState = RenderType.State.getBuilder().texture(new TextureState(p_228635_0_, false, false)).alpha(new AlphaState(p_228635_1_)).cull(CULL_DISABLED).build(true); + return makeType("entity_alpha", DefaultVertexFormats.ENTITY, 7, 256, renderState); + } + + public static RenderType getEyes(ResourceLocation texture) { + TextureState textureState = new TextureState(texture, false, false); + return makeType("eyes", DefaultVertexFormats.ENTITY, 7, 256, false, true, RenderType.State.getBuilder().texture(textureState).transparency(ADDITIVE_TRANSPARENCY).writeMask(COLOR_WRITE).fog(BLACK_FOG).build(false)); + } + + public static RenderType getEnergySwirl(ResourceLocation texture, float offsetU, float offsetV) { + return makeType("energy_swirl", DefaultVertexFormats.ENTITY, 7, 256, false, true, RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).texturing(new OffsetTexturingState(offsetU, offsetV)).fog(BLACK_FOG).transparency(ADDITIVE_TRANSPARENCY).diffuseLighting(DIFFUSE_LIGHTING_ENABLED).alpha(DEFAULT_ALPHA).cull(CULL_DISABLED).lightmap(LIGHTMAP_ENABLED).overlay(OVERLAY_ENABLED).build(false)); + } + + public static RenderType getLeash() { + return LEASH; + } + + public static RenderType getWaterMask() { + return WATER_MASK; + } + + public static RenderType getOutline(ResourceLocation texture) { + return makeType("outline", DefaultVertexFormats.POSITION_COLOR_TEX, 7, 256, RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).cull(CULL_DISABLED).depthTest(DEPTH_ALWAYS).alpha(DEFAULT_ALPHA).texturing(OUTLINE_TEXTURING).fog(NO_FOG).target(OUTLINE_TARGET).build(RenderType.OutlineState.IS_OUTLINE)); + } + + public static RenderType getGlint() { + return GLINT; + } + + public static RenderType getEntityGlint() { + return ENTITY_GLINT; + } + + public static RenderType getCrumbling(ResourceLocation texture) { + TextureState lvt_1_1_ = new TextureState(texture, false, false); + return makeType("crumbling", DefaultVertexFormats.BLOCK, 7, 256, false, true, RenderType.State.getBuilder().texture(lvt_1_1_).alpha(DEFAULT_ALPHA).transparency(CRUMBLING_TRANSPARENCY).writeMask(COLOR_WRITE).layer(POLYGON_OFFSET_LAYERING).build(false)); + } + + public static RenderType getText(ResourceLocation texture) { + return makeType("text", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP, 7, 256, false, true, RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).alpha(DEFAULT_ALPHA).transparency(TRANSLUCENT_TRANSPARENCY).lightmap(LIGHTMAP_ENABLED).build(false)); + } + + public static RenderType getTextSeeThrough(ResourceLocation texture) { + return makeType("text_see_through", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP, 7, 256, false, true, RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).alpha(DEFAULT_ALPHA).transparency(TRANSLUCENT_TRANSPARENCY).lightmap(LIGHTMAP_ENABLED).depthTest(DEPTH_ALWAYS).writeMask(COLOR_WRITE).build(false)); + } + + public static RenderType getLightning() { + return LIGHTNING; + } + + public static RenderType getEndPortal(int p_228630_0_) { + TransparencyState transparencyState; + TextureState textureState; + if (p_228630_0_ <= 1) { + transparencyState = TRANSLUCENT_TRANSPARENCY; + textureState = new TextureState(EndPortalTileEntityRenderer.END_SKY_TEXTURE, false, false); + } else { + transparencyState = ADDITIVE_TRANSPARENCY; + textureState = new TextureState(EndPortalTileEntityRenderer.END_PORTAL_TEXTURE, false, false); + } + + return makeType("end_portal", DefaultVertexFormats.POSITION_COLOR, 7, 256, false, true, RenderType.State.getBuilder().transparency(transparencyState).texture(textureState).texturing(new PortalTexturingState(p_228630_0_)).fog(BLACK_FOG).build(false)); + } + + public static RenderType getLines() { + return LINES; + } + + public RenderType(String nameIn, VertexFormat vertexFormatIn, int drawModeIn, int bufferSizeIn, boolean useDelegateIn, boolean needsSortingIn, Runnable setupTaskIn, Runnable clearTaskIn) { + super(nameIn, setupTaskIn, clearTaskIn); + this.vertexFormat = vertexFormatIn; + this.drawMode = drawModeIn; + this.bufferSize = bufferSizeIn; + this.useDelegate = useDelegateIn; + this.needsSorting = needsSortingIn; + this.field_230166_ag_ = Optional.of(this); + } + + public static RenderType.Type makeType(String name, VertexFormat vertexFormat, int drawMode, int bufferSize, RenderType.State renderState) { + return makeType(name, vertexFormat, drawMode, bufferSize, false, false, renderState); + } + + public static RenderType.Type makeType(String name, VertexFormat vertexFormat, int drawMode, int bufferSize, boolean useDelegate, boolean needsSorting, RenderType.State renderState) { + return RenderType.Type.getOrCreate(name, vertexFormat, drawMode, bufferSize, useDelegate, needsSorting, renderState); + } + + public void finish(BufferBuilder bufferBuilder, int cameraX, int cameraY, int cameraZ) { + if (bufferBuilder.isDrawing()) { + if (this.needsSorting) { + bufferBuilder.sortVertexData((float)cameraX, (float)cameraY, (float)cameraZ); + } + + bufferBuilder.finishDrawing(); + this.setupRenderState(); + WorldVertexBufferUploader.draw(bufferBuilder); + this.clearRenderState(); + } + } + + public String toString() { + return this.name; + } + + public static List getBlockRenderTypes() { + return ImmutableList.of(getSolid(), getCutoutMipped(), getCutout(), getTranslucent()); + } + + public int getBufferSize() { + return this.bufferSize; + } + + public VertexFormat getVertexFormat() { + return this.vertexFormat; + } + + public int getDrawMode() { + return this.drawMode; + } + + public Optional getOutline() { + return Optional.empty(); + } + + public boolean getDrawOutline() { + return false; + } + + public boolean isUseDelegate() { + return this.useDelegate; + } + + public Optional func_230169_u_() { + return this.field_230166_ag_; + } + + static { + SOLID = makeType("solid", DefaultVertexFormats.BLOCK, 7, 2097152, true, false, RenderType.State.getBuilder().shadeModel(SHADE_ENABLED).lightmap(LIGHTMAP_ENABLED).texture(BLOCK_SHEET_MIPPED).build(true)); + CUTOUT_MIPPED = makeType("cutout_mipped", DefaultVertexFormats.BLOCK, 7, 131072, true, false, RenderType.State.getBuilder().shadeModel(SHADE_ENABLED).lightmap(LIGHTMAP_ENABLED).texture(BLOCK_SHEET_MIPPED).alpha(HALF_ALPHA).build(true)); + CUTOUT = makeType("cutout", DefaultVertexFormats.BLOCK, 7, 131072, true, false, RenderType.State.getBuilder().shadeModel(SHADE_ENABLED).lightmap(LIGHTMAP_ENABLED).texture(BLOCK_SHEET).alpha(HALF_ALPHA).build(true)); + TRANSLUCENT = makeType("translucent", DefaultVertexFormats.BLOCK, 7, 262144, true, true, getTranslucentState()); + TRANSLUCENT_NO_CRUMBLING = makeType("translucent_no_crumbling", DefaultVertexFormats.BLOCK, 7, 262144, false, true, getTranslucentState()); + LEASH = makeType("leash", DefaultVertexFormats.POSITION_COLOR_LIGHTMAP, 7, 256, RenderType.State.getBuilder().texture(NO_TEXTURE).cull(CULL_DISABLED).lightmap(LIGHTMAP_ENABLED).build(false)); + WATER_MASK = makeType("water_mask", DefaultVertexFormats.POSITION, 7, 256, RenderType.State.getBuilder().texture(NO_TEXTURE).writeMask(DEPTH_WRITE).build(false)); + GLINT = makeType("glint", DefaultVertexFormats.POSITION_TEX, 7, 256, RenderType.State.getBuilder().texture(new TextureState(ItemRenderer.RES_ITEM_GLINT, true, false)).writeMask(COLOR_WRITE).cull(CULL_DISABLED).depthTest(DEPTH_EQUAL).transparency(GLINT_TRANSPARENCY).texturing(GLINT_TEXTURING).build(false)); + ENTITY_GLINT = makeType("entity_glint", DefaultVertexFormats.POSITION_TEX, 7, 256, RenderType.State.getBuilder().texture(new TextureState(ItemRenderer.RES_ITEM_GLINT, true, false)).writeMask(COLOR_WRITE).cull(CULL_DISABLED).depthTest(DEPTH_EQUAL).transparency(GLINT_TRANSPARENCY).texturing(ENTITY_GLINT_TEXTURING).build(false)); + LIGHTNING = makeType("lightning", DefaultVertexFormats.POSITION_COLOR, 7, 256, false, true, RenderType.State.getBuilder().writeMask(COLOR_WRITE).transparency(LIGHTNING_TRANSPARENCY).shadeModel(SHADE_ENABLED).build(false)); + LINES = makeType("lines", DefaultVertexFormats.POSITION_COLOR, 1, 256, RenderType.State.getBuilder().line(new LineState(OptionalDouble.empty())).layer(PROJECTION_LAYERING).transparency(TRANSLUCENT_TRANSPARENCY).writeMask(COLOR_WRITE).build(false)); + } + + @OnlyIn(Dist.CLIENT) + static final class Type extends RenderType { + private static final ObjectOpenCustomHashSet TYPES; + private final RenderType.State renderState; + private final int hashCode; + private final Optional outlineRenderType; + private final boolean outline; + + private Type(String nameIn, VertexFormat vertexFormatIn, int drawModeIn, int bufferSizeIn, boolean useDelegateIn, boolean needsSortingIn, RenderType.State renderStateIn) { + super(nameIn, vertexFormatIn, drawModeIn, bufferSizeIn, useDelegateIn, needsSortingIn, () -> { + renderStateIn.renderStates.forEach(RenderState::setupRenderState); + }, () -> { + renderStateIn.renderStates.forEach(RenderState::clearRenderState); + }); + this.renderState = renderStateIn; + this.outlineRenderType = renderStateIn.outline == RenderType.OutlineState.AFFECTS_OUTLINE ? renderStateIn.texture.texture().map(RenderType::getOutline) : Optional.empty(); + this.outline = renderStateIn.outline == RenderType.OutlineState.IS_OUTLINE; + this.hashCode = Objects.hash(new Object[]{super.hashCode(), renderStateIn}); + } + + private static RenderType.Type getOrCreate(String nameIn, VertexFormat vertexFormatIn, int drawModeIn, int bufferSizeIn, boolean useDelegateIn, boolean needsSortingIn, RenderType.State renderStateIn) { + return (RenderType.Type)TYPES.addOrGet(new RenderType.Type(nameIn, vertexFormatIn, drawModeIn, bufferSizeIn, useDelegateIn, needsSortingIn, renderStateIn)); + } + + public Optional getOutline() { + return this.outlineRenderType; + } + + public boolean getDrawOutline() { + return this.outline; + } + + public boolean equals(@Nullable Object object) { + return this == object; + } + + public int hashCode() { + return this.hashCode; + } + + static { + TYPES = new ObjectOpenCustomHashSet(RenderType.Type.EqualityStrategy.INSTANCE); + } + + @OnlyIn(Dist.CLIENT) + static enum EqualityStrategy implements Strategy { + INSTANCE; + + private EqualityStrategy() { + } + + public int hashCode(@Nullable RenderType.Type typeIn) { + return typeIn == null ? 0 : typeIn.hashCode; + } + + public boolean equals(@Nullable RenderType.Type type1, @Nullable RenderType.Type type2) { + if (type1 == type2) { + return true; + } else { + return type1 != null && type2 != null ? Objects.equals(type1.renderState, type2.renderState) : false; + } + } + } + } + + @OnlyIn(Dist.CLIENT) + public static final class State { + private final TextureState texture; + private final TransparencyState transparency; + private final DiffuseLightingState diffuseLighting; + private final ShadeModelState shadowModel; + private final AlphaState alpha; + private final DepthTestState depthTest; + private final CullState cull; + private final LightmapState lightmap; + private final OverlayState overlay; + private final FogState fog; + private final LayerState layer; + private final TargetState target; + private final TexturingState texturing; + private final WriteMaskState writeMask; + private final LineState line; + private final RenderType.OutlineState outline; + private final ImmutableList renderStates; + + private State(TextureState textureIn, TransparencyState transparencyIn, DiffuseLightingState diffuseLightingIn, ShadeModelState shadowModelIn, AlphaState alphaIn, DepthTestState depthTestIn, CullState cullIn, LightmapState lightmapIn, OverlayState overlayIn, FogState fogIn, LayerState layerIn, TargetState targetIn, TexturingState textureingIn, WriteMaskState writeMaskIn, LineState lineIn, RenderType.OutlineState outlineIn) { + this.texture = textureIn; + this.transparency = transparencyIn; + this.diffuseLighting = diffuseLightingIn; + this.shadowModel = shadowModelIn; + this.alpha = alphaIn; + this.depthTest = depthTestIn; + this.cull = cullIn; + this.lightmap = lightmapIn; + this.overlay = overlayIn; + this.fog = fogIn; + this.layer = layerIn; + this.target = targetIn; + this.texturing = textureingIn; + this.writeMask = writeMaskIn; + this.line = lineIn; + this.outline = outlineIn; + this.renderStates = ImmutableList.of(this.texture, this.transparency, this.diffuseLighting, this.shadowModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.overlay, this.fog, this.layer, this.target, new RenderState[]{this.texturing, this.writeMask, this.line}); + } + + public boolean equals(Object object) { + if (this == object) { + return true; + } else if (object != null && this.getClass() == object.getClass()) { + RenderType.State renderType$state = (RenderType.State)object; + return this.outline == renderType$state.outline && this.renderStates.equals(renderType$state.renderStates); + } else { + return false; + } + } + + public int hashCode() { + return Objects.hash(this.renderStates, this.outline); + } + + public static RenderType.State.Builder getBuilder() { + return new RenderType.State.Builder(); + } + + @OnlyIn(Dist.CLIENT) + public static class Builder { + private TextureState texture; + private TransparencyState transparency; + private DiffuseLightingState diffuseLighting; + private ShadeModelState shadeModel; + private AlphaState alpha; + private DepthTestState depthTest; + private CullState cull; + private LightmapState lightmap; + private OverlayState overlay; + private FogState fog; + private LayerState layer; + private TargetState target; + private TexturingState texturing; + private WriteMaskState writeMask; + private LineState line; + + private Builder() { + this.texture = RenderState.NO_TEXTURE; + this.transparency = RenderState.NO_TRANSPARENCY; + this.diffuseLighting = RenderState.DIFFUSE_LIGHTING_DISABLED; + this.shadeModel = RenderState.SHADE_DISABLED; + this.alpha = RenderState.ZERO_ALPHA; + this.depthTest = RenderState.DEPTH_LEQUAL; + this.cull = RenderState.CULL_ENABLED; + this.lightmap = RenderState.LIGHTMAP_DISABLED; + this.overlay = RenderState.OVERLAY_DISABLED; + this.fog = RenderState.FOG; + this.layer = RenderState.NO_LAYERING; + this.target = RenderState.MAIN_TARGET; + this.texturing = RenderState.DEFAULT_TEXTURING; + this.writeMask = RenderState.COLOR_DEPTH_WRITE; + this.line = RenderState.DEFAULT_LINE; + } + + public RenderType.State.Builder texture(TextureState textureIn) { + this.texture = textureIn; + return this; + } + + public RenderType.State.Builder transparency(TransparencyState transparencyIn) { + this.transparency = transparencyIn; + return this; + } + + public RenderType.State.Builder diffuseLighting(DiffuseLightingState diffuseLightingIn) { + this.diffuseLighting = diffuseLightingIn; + return this; + } + + public RenderType.State.Builder shadeModel(ShadeModelState shadeModelIn) { + this.shadeModel = shadeModelIn; + return this; + } + + public RenderType.State.Builder alpha(AlphaState alphaIn) { + this.alpha = alphaIn; + return this; + } + + public RenderType.State.Builder depthTest(DepthTestState depthTestIn) { + this.depthTest = depthTestIn; + return this; + } + + public RenderType.State.Builder cull(CullState cullIn) { + this.cull = cullIn; + return this; + } + + public RenderType.State.Builder lightmap(LightmapState lightmapIn) { + this.lightmap = lightmapIn; + return this; + } + + public RenderType.State.Builder overlay(OverlayState overlayIn) { + this.overlay = overlayIn; + return this; + } + + public RenderType.State.Builder fog(FogState fogIn) { + this.fog = fogIn; + return this; + } + + public RenderType.State.Builder layer(LayerState layerIn) { + this.layer = layerIn; + return this; + } + + public RenderType.State.Builder target(TargetState targetIn) { + this.target = targetIn; + return this; + } + + public RenderType.State.Builder texturing(TexturingState texturingIn) { + this.texturing = texturingIn; + return this; + } + + public RenderType.State.Builder writeMask(WriteMaskState writeMaskIn) { + this.writeMask = writeMaskIn; + return this; + } + + public RenderType.State.Builder line(LineState lineIn) { + this.line = lineIn; + return this; + } + + public RenderType.State build(boolean outline) { + return this.build(outline ? RenderType.OutlineState.AFFECTS_OUTLINE : RenderType.OutlineState.NONE); + } + + public RenderType.State build(RenderType.OutlineState outlineIn) { + return new RenderType.State(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.overlay, this.fog, this.layer, this.target, this.texturing, this.writeMask, this.line, outlineIn); + } + } + } + + @OnlyIn(Dist.CLIENT) + static enum OutlineState { + NONE, + IS_OUTLINE, + AFFECTS_OUTLINE; + + private OutlineState() { + } + } +} diff --git a/src/main/java/lilypuree/forest_tree/gui/GuiExtended.java b/src/main/java/lilypuree/forest_tree/client/gui/GuiExtended.java similarity index 98% rename from src/main/java/lilypuree/forest_tree/gui/GuiExtended.java rename to src/main/java/lilypuree/forest_tree/client/gui/GuiExtended.java index f6208c6..8d0c99b 100644 --- a/src/main/java/lilypuree/forest_tree/gui/GuiExtended.java +++ b/src/main/java/lilypuree/forest_tree/client/gui/GuiExtended.java @@ -1,4 +1,4 @@ -package lilypuree.forest_tree.gui; +package lilypuree.forest_tree.client.gui; import se.mickelus.mgui.gui.GuiElement; diff --git a/src/main/java/lilypuree/forest_tree/client/gui/GuiResizableTexture.java b/src/main/java/lilypuree/forest_tree/client/gui/GuiResizableTexture.java new file mode 100644 index 0000000..736b84c --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/client/gui/GuiResizableTexture.java @@ -0,0 +1,62 @@ +package lilypuree.forest_tree.client.gui; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.ResourceLocation; +import se.mickelus.mgui.gui.GuiTexture; + +public class GuiResizableTexture extends GuiTexture { + + private int textureWidth; + private int textureHeight; + + public GuiResizableTexture(int x, int y, int width, int height, ResourceLocation textureLocation) { + this(x, y, width, height, 0, 0, textureLocation); + } + + public GuiResizableTexture(int x, int y, int width, int height, int textureX, int textureY, ResourceLocation textureLocation) { + this(x, y, width, height, textureX, textureY, 256, 256, textureLocation); + } + + public GuiResizableTexture(int x, int y, int width, int height, int textureX, int textureY, int textureWidth, int textureHeight, ResourceLocation textureLocation) { + super(x, y, width, height, textureX, textureY, textureLocation); + this.textureHeight = textureHeight; + this.textureWidth = textureWidth; + } + + public void setTextureSize(int textureWidth, int textureHeight){ + this.textureWidth = textureWidth; + this.textureHeight = textureHeight; + } + + @Override + public void draw(MatrixStack matrixStack, int refX, int refY, int screenWidth, int screenHeight, int mouseX, int mouseY, float opacity) { + this.calculateFocusState(refX, refY, mouseX, mouseY); + this.drawChildren(matrixStack, refX + this.x, refY + this.y, screenWidth, screenHeight, mouseX, mouseY, opacity * this.opacity); + drawResizableTexture(matrixStack, this.textureLocation, refX + this.x, refY + this.y, this.width, this.height, this.textureX, this.textureY, this.textureWidth, this.textureHeight, this.color, this.getOpacity() * opacity); + } + + protected static void drawResizableTexture(MatrixStack matrixStack, ResourceLocation textureLocation, int x, int y, int width, int height, int u, int v, int textureWidth, int textureHeight, int color, float opacity) { + RenderSystem.pushMatrix(); + Minecraft.getInstance().getTextureManager().bindTexture(textureLocation); + RenderSystem.color4f((float)(color >> 16 & 255) / 255.0F, (float)(color >> 8 & 255) / 255.0F, (float)(color & 255) / 255.0F, opacity); + RenderSystem.enableBlend(); + RenderSystem.enableAlphaTest(); + Tessellator tessellator = Tessellator.getInstance(); + BufferBuilder buffer = tessellator.getBuffer(); + buffer.begin(7, DefaultVertexFormats.POSITION_TEX); + buffer.pos(matrixStack.getLast().getMatrix(), (float)x, (float)(y + height), 0.0F).tex((float)u / textureWidth, (float)(v + height) / textureHeight).endVertex(); + buffer.pos(matrixStack.getLast().getMatrix(), (float)(x + width), (float)(y + height), 0.0F).tex((float)(u + width) / textureWidth, (float)(v + height) / textureHeight).endVertex(); + buffer.pos(matrixStack.getLast().getMatrix(), (float)(x + width), (float)y, 0.0F).tex((float)(u + width) /textureWidth, (float)v / textureHeight).endVertex(); + buffer.pos(matrixStack.getLast().getMatrix(), (float)x, (float)y, 0.0F).tex((float)u / textureWidth, (float)v / textureHeight).endVertex(); + tessellator.draw(); + RenderSystem.popMatrix(); + } + + + +} diff --git a/src/main/java/lilypuree/forest_tree/gui/GuiScrollBar.java b/src/main/java/lilypuree/forest_tree/client/gui/GuiScrollBar.java similarity index 95% rename from src/main/java/lilypuree/forest_tree/gui/GuiScrollBar.java rename to src/main/java/lilypuree/forest_tree/client/gui/GuiScrollBar.java index da72fea..52e2334 100644 --- a/src/main/java/lilypuree/forest_tree/gui/GuiScrollBar.java +++ b/src/main/java/lilypuree/forest_tree/client/gui/GuiScrollBar.java @@ -1,6 +1,6 @@ -package lilypuree.forest_tree.gui; +package lilypuree.forest_tree.client.gui; -import com.mojang.blaze3d.matrix.MatrixStack; +import lilypuree.forest_tree.client.gui.GuiExtended; import se.mickelus.mgui.gui.GuiElement; import se.mickelus.mgui.gui.GuiRect; @@ -11,7 +11,7 @@ public class GuiScrollBar extends GuiExtended { private float scrollDistance; private int contentHeight; - private int border = 4; + private int border = 0; private GuiElement guibar; private int scrollAmount = 20; @@ -45,6 +45,7 @@ public int getScrollAmount() public void setScrollAmount(int scrollAmount) { this.scrollAmount = scrollAmount; + applyScrollLimits(); } public float getScrollDistance() { @@ -83,6 +84,8 @@ private void updateScrollBar(){ int barHeight = getBarHeight(); int barTop = (int)this.scrollDistance * (height - barHeight) / extraHeight; guibar.setY(barTop); + }else { + guibar.setY(0); } } diff --git a/src/main/java/lilypuree/forest_tree/gui/GuiTextFieldWidget.java b/src/main/java/lilypuree/forest_tree/client/gui/GuiTextFieldWidget.java similarity index 94% rename from src/main/java/lilypuree/forest_tree/gui/GuiTextFieldWidget.java rename to src/main/java/lilypuree/forest_tree/client/gui/GuiTextFieldWidget.java index ef0bb6e..70c1aa9 100644 --- a/src/main/java/lilypuree/forest_tree/gui/GuiTextFieldWidget.java +++ b/src/main/java/lilypuree/forest_tree/client/gui/GuiTextFieldWidget.java @@ -1,9 +1,10 @@ -package lilypuree.forest_tree.gui; +package lilypuree.forest_tree.client.gui; import com.google.common.base.Predicates; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; +import lilypuree.forest_tree.client.gui.GuiExtended; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.FontRenderer; @@ -14,8 +15,6 @@ import net.minecraft.client.util.InputMappings; import net.minecraft.util.SharedConstants; import net.minecraft.util.math.MathHelper; -import se.mickelus.mgui.gui.GuiRect; -import se.mickelus.mgui.gui.GuiString; import java.util.function.BiFunction; import java.util.function.Consumer; @@ -48,23 +47,23 @@ public class GuiTextFieldWidget extends GuiExtended { private int enabledColor = 14737632; private int disabledColor = 7368816; + private Runnable onClickHandler = () -> {}; private Consumer guiResponder = s -> {}; private Predicate validator = Predicates.alwaysTrue(); private BiFunction textFormatter = (string, integer) -> { return string; }; - private boolean enableBackgroundDrawing; - private boolean canLoseFocus; + private boolean enableBackgroundDrawing; + private boolean selected = false; public GuiTextFieldWidget(FontRenderer fontIn, int x, int y, int width, int height) { super(x, y, width, height); this.fontRenderer = fontIn; -// addChild(new GuiRect(0, 0, width, height, 0x53D1BA)); this.text = ""; } - public void setInnerText(String newString) { + private void setInnerText(String newString) { text = newString; } @@ -133,7 +132,7 @@ public String getSelectedText() { } public boolean canWrite() { - return this.isVisible() && this.hasFocus() && this.isEnabled(); + return this.isVisible() && this.isEnabled() && this.selected; } /** @@ -344,20 +343,6 @@ public void setSelectionPos(int position) { } } - @Override - protected void calculateFocusState(int refX, int refY, int mouseX, int mouseY) { - -// boolean gainFocus = mouseX >= this.getX() + refX && mouseX < this.getX() + refX + this.getWidth() && mouseY >= this.getY() + refY && mouseY < this.getY() + refY + this.getHeight(); -// -// if (canLoseFocus && gainFocus != this.hasFocus) { -// this.hasFocus = gainFocus; -// if (this.hasFocus()) { -// this.onFocus(); -// } else { -// this.onBlur(); -// } -// } - } @Override protected void onBlur() { @@ -367,6 +352,8 @@ protected void onBlur() { @Override public boolean onClick(int x, int y) { if (this.hasFocus()) { + selected = true; + onClickHandler.run(); int i = MathHelper.floor(x) - baseX; // if (this.enableBackgroundDrawing) { // i -= 4; @@ -379,6 +366,18 @@ public boolean onClick(int x, int y) { } } + public void setOnClickHandler(Runnable onClickHandler){ + this.onClickHandler = onClickHandler; + } + + public void setSelected(boolean selected){ + this.selected = selected; + } + + public boolean isSelected(){ + return selected; + } + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { @@ -477,6 +476,10 @@ public boolean charTyped(char typedChar) { } } + @Override + protected void calculateFocusState(int refX, int refY, int mouseX, int mouseY) { + super.calculateFocusState(refX, refY, mouseX, mouseY); + } @Override public void draw(MatrixStack matrixStack, int refX, int refY, int screenWidth, int screenHeight, int mouseX, int mouseY, float opacity) { @@ -498,7 +501,7 @@ public void drawText(int refX, int refY) { int selOffset = this.selectionEnd - this.lineScrollOffset; String renderString = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getAdjustedWidth()); boolean cursorInString = lenBehindCursor >= 0 && lenBehindCursor <= renderString.length(); - boolean drawBar = this.hasFocus() && this.cursorCounter / 6 % 2 == 0 && cursorInString; + boolean drawBar = this.selected && this.cursorCounter / 6 % 2 == 0 && cursorInString; int startX = this.enableBackgroundDrawing ? baseX + 4 : baseX; int startY = this.enableBackgroundDrawing ? renderY + (this.height - 8) / 2 : renderY; int startX2 = startX; @@ -612,17 +615,6 @@ public void setEnableBackgroundDrawing(boolean enableBackgroundDrawingIn) { this.enableBackgroundDrawing = enableBackgroundDrawingIn; } - /** - * Sets whether this text box loses focus when something other than it is clicked. - */ - public void setCanLoseFocus(boolean canLoseFocusIn) { - this.canLoseFocus = canLoseFocusIn; - } - - public void setHasFocus(boolean hasFocus){ - this.hasFocus = hasFocus; - } - /** * returns the current position of the cursor */ diff --git a/src/main/java/lilypuree/forest_tree/core/network/ForestTreePacketHandler.java b/src/main/java/lilypuree/forest_tree/core/network/ForestTreePacketHandler.java new file mode 100644 index 0000000..cd43c03 --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/core/network/ForestTreePacketHandler.java @@ -0,0 +1,40 @@ +package lilypuree.forest_tree.core.network; + +import lilypuree.forest_tree.ForestTree; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.network.NetworkDirection; +import net.minecraftforge.fml.network.NetworkRegistry; +import net.minecraftforge.fml.network.simple.SimpleChannel; + +public class ForestTreePacketHandler { + private static SimpleChannel INSTANCE; + private static int ID = 0; + + private static int nextID() { + return ID++; + } + + public static void registerMessages() { + INSTANCE = NetworkRegistry.newSimpleChannel(new ResourceLocation(ForestTree.MODID, "main"), + () -> "1.0", + s -> true, + s -> true); + + INSTANCE.messageBuilder(PacketSaveParams.class, nextID()) + .encoder(PacketSaveParams::toBytes) + .decoder(PacketSaveParams::new) + .consumer(PacketSaveParams::handle) + .add(); + } + + public static void sendToClient(Object packet, ServerPlayerEntity player) { + INSTANCE.sendTo(packet, player.connection.netManager, NetworkDirection.PLAY_TO_CLIENT); + } + + public static void sendToServer(Object packet) { + INSTANCE.sendToServer(packet); + } + + +} diff --git a/src/main/java/lilypuree/forest_tree/core/network/PacketRequestUpdateTreeDesigner.java b/src/main/java/lilypuree/forest_tree/core/network/PacketRequestUpdateTreeDesigner.java new file mode 100644 index 0000000..7c44114 --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/core/network/PacketRequestUpdateTreeDesigner.java @@ -0,0 +1,37 @@ +package lilypuree.forest_tree.core.network; + +import lilypuree.forest_tree.trees.customization.TreeDesignerTile; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.loading.FMLCommonLaunchHandler; +import net.minecraftforge.fml.network.NetworkEvent; + +import java.util.function.Supplier; + +public class PacketRequestUpdateTreeDesigner { + + private BlockPos pos; + + public PacketRequestUpdateTreeDesigner(BlockPos pos, int dimensionID){ + this.pos = pos; + } + + public PacketRequestUpdateTreeDesigner(PacketBuffer buf){ + pos = buf.readBlockPos(); + } + + public void toBytes(PacketBuffer buf){ + buf.writeBlockPos(pos); + } + + + public boolean handle(Supplier ctx){ + ctx.get().enqueueWork(()->{ + World world = ctx.get().getSender().world; + TreeDesignerTile te = (TreeDesignerTile)world.getTileEntity(pos); + ForestTreePacketHandler.sendToClient(new PacketUpdateTreeDesigner(te), ctx.get().getSender()); + }); + return true; + } +} diff --git a/src/main/java/lilypuree/forest_tree/core/network/PacketSaveParams.java b/src/main/java/lilypuree/forest_tree/core/network/PacketSaveParams.java new file mode 100644 index 0000000..1bb7d64 --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/core/network/PacketSaveParams.java @@ -0,0 +1,49 @@ +package lilypuree.forest_tree.core.network; + +import lilypuree.forest_tree.Registration; +import lilypuree.forest_tree.trees.customization.TreeDesignerTile; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.network.NetworkEvent; + +import java.util.function.Supplier; + +public class PacketSaveParams { + + private final BlockPos pos; + private final CompoundNBT generatorTag; + + public PacketSaveParams(BlockPos pos, CompoundNBT generatorTag){ + this.pos = pos; + this.generatorTag = generatorTag; + } + + public PacketSaveParams(PacketBuffer buf){ + pos = buf.readBlockPos(); + generatorTag = buf.readCompoundTag(); + } + + public void toBytes(PacketBuffer buf){ + buf.writeBlockPos(pos); + buf.writeCompoundTag(generatorTag); + } + + public boolean handle(Supplier ctx) { + ctx.get().enqueueWork(() -> { + World world = ctx.get().getSender().world; + if (world.isBlockLoaded(pos)){ + TileEntity te = world.getTileEntity(pos); + if (te instanceof TreeDesignerTile) { + ItemStack newSapling = new ItemStack(Registration.CUSTOM_SAPLING_ITEM.get()); + newSapling.setTagInfo("BlockEntityTag", generatorTag); + ((TreeDesignerTile) te).saplingHandler.setStackInSlot(0, newSapling); + } + } + }); + return true; + } +} diff --git a/src/main/java/lilypuree/forest_tree/core/network/PacketUpdateTreeDesigner.java b/src/main/java/lilypuree/forest_tree/core/network/PacketUpdateTreeDesigner.java new file mode 100644 index 0000000..0deb166 --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/core/network/PacketUpdateTreeDesigner.java @@ -0,0 +1,52 @@ +package lilypuree.forest_tree.core.network; + +import lilypuree.forest_tree.trees.customization.TreeDesignerTile; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.network.NetworkEvent; + +import java.util.function.Supplier; + +public class PacketUpdateTreeDesigner { + + private BlockPos pos; + private ItemStack stack; + private long lastChangeTime; + + public PacketUpdateTreeDesigner(BlockPos pos, ItemStack stack, long lastChangeTime) { + this.pos = pos; + this.stack = stack; + this.lastChangeTime = lastChangeTime; + } + + public PacketUpdateTreeDesigner(PacketBuffer buf) { + pos = buf.readBlockPos(); + stack = buf.readItemStack(); + lastChangeTime = buf.readLong(); + } + + public PacketUpdateTreeDesigner(TreeDesignerTile te){ + pos = te.getPos(); + stack = te.saplingHandler.getStackInSlot(0); + lastChangeTime = te.lastChangeTime; + } + + public void toBytes(PacketBuffer buf) { + buf.writeBlockPos(pos); + buf.writeItemStack(stack); + buf.writeLong(lastChangeTime); + } + + public boolean handle(Supplier ctx) { + ctx.get().enqueueWork(() -> { + World world = Minecraft.getInstance().world; + TreeDesignerTile te = (TreeDesignerTile) world.getTileEntity(pos); + te.saplingHandler.setStackInSlot(0, stack); + te.lastChangeTime = lastChangeTime; + }); + return true; + } +} diff --git a/src/main/java/lilypuree/forest_tree/core/setup/ClientSetup.java b/src/main/java/lilypuree/forest_tree/core/setup/ClientSetup.java index 0569fe6..1698038 100644 --- a/src/main/java/lilypuree/forest_tree/core/setup/ClientSetup.java +++ b/src/main/java/lilypuree/forest_tree/core/setup/ClientSetup.java @@ -3,28 +3,24 @@ import lilypuree.forest_tree.ForestTree; import lilypuree.forest_tree.Registration; import lilypuree.forest_tree.datagen.types.WoodTypes; -import lilypuree.forest_tree.trees.TreeBlocks; import lilypuree.forest_tree.trees.client.BranchModelLoader; import lilypuree.forest_tree.trees.client.gui.TreeDesignerScreen; -import lilypuree.forest_tree.trees.customization.TreeDesignerTile; -import lilypuree.forest_tree.trees.species.ModSpecies; -import lilypuree.forest_tree.trees.species.Species; +import lilypuree.forest_tree.trees.client.render.BlockHologramRenderer; +import lilypuree.forest_tree.trees.client.render.TreeDesignerRenderer; import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.color.BlockColors; +import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.Vec3i; import net.minecraft.world.FoliageColors; import net.minecraft.world.biome.BiomeColors; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.ColorHandlerEvent; +import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; @Mod.EventBusSubscriber(modid = ForestTree.MODID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) public class ClientSetup { @@ -41,6 +37,8 @@ public static void init(final FMLClientSetupEvent event) { RenderTypeLookup.setRenderLayer(branchBlock, RenderType.getCutoutMipped()); } }); + TreeDesignerRenderer.register(); + RenderTypeLookup.setRenderLayer(Registration.CUSTOM_SAPLING.get(), RenderType.getCutout()); ScreenManager.registerFactory(Registration.TREE_DESIGNER_CONTAINER.get(), TreeDesignerScreen::new); } @@ -67,6 +65,17 @@ public static void onBlockColourHandlerEvent(final ColorHandlerEvent.Block event } }); } + + @SubscribeEvent + public static void onTextureStitchEvent(TextureStitchEvent.Pre event){ + ResourceLocation stitching = event.getMap().getTextureLocation(); + if(!stitching.equals(AtlasTexture.LOCATION_BLOCKS_TEXTURE)) + { + return; + } + event.addSprite(TreeDesignerRenderer.HOLOGRAM_RAY); + } + // // @SubscribeEvent // public static void onItemColourHandlerEvent(final ColorHandlerEvent.Item event) { diff --git a/src/main/java/lilypuree/forest_tree/core/setup/ModSetup.java b/src/main/java/lilypuree/forest_tree/core/setup/ModSetup.java index 2c9e806..b6d3a57 100644 --- a/src/main/java/lilypuree/forest_tree/core/setup/ModSetup.java +++ b/src/main/java/lilypuree/forest_tree/core/setup/ModSetup.java @@ -1,26 +1,7 @@ package lilypuree.forest_tree.core.setup; import lilypuree.forest_tree.ForestTree; -import lilypuree.forest_tree.trees.block.BranchBlock; -import lilypuree.forest_tree.trees.block.BranchVoxelShapes; -import lilypuree.forest_tree.util.Util; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.Vec3i; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraftforge.client.event.InputEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.event.world.BlockEvent; -import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.eventbus.api.EventPriority; +import lilypuree.forest_tree.core.network.ForestTreePacketHandler; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; @@ -32,6 +13,7 @@ public class ModSetup { public void init(FMLCommonSetupEvent e) { + ForestTreePacketHandler.registerMessages(); } @SubscribeEvent diff --git a/src/main/java/lilypuree/forest_tree/datagen/BlockStates.java b/src/main/java/lilypuree/forest_tree/datagen/BlockStates.java index 51cd677..13e5810 100644 --- a/src/main/java/lilypuree/forest_tree/datagen/BlockStates.java +++ b/src/main/java/lilypuree/forest_tree/datagen/BlockStates.java @@ -28,6 +28,7 @@ public String getName() { protected void registerModels() { } }; + } // // public ModelFile treePartModel(WoodTypes wood, ThicknessTypes thickness, PartTypes type) { @@ -269,6 +270,7 @@ protected void registerStatesAndModels() { } } } + } @Override diff --git a/src/main/java/lilypuree/forest_tree/datagen/DataGenerators.java b/src/main/java/lilypuree/forest_tree/datagen/DataGenerators.java index 1595f2b..7ed2885 100644 --- a/src/main/java/lilypuree/forest_tree/datagen/DataGenerators.java +++ b/src/main/java/lilypuree/forest_tree/datagen/DataGenerators.java @@ -16,9 +16,9 @@ public static void gatherData(GatherDataEvent event){ // generator.addProvider(new LootTables(generator)); } if (event.includeClient()) { - generator.addProvider(new BlockStates(generator, event.getExistingFileHelper())); +// generator.addProvider(new BlockStates(generator, event.getExistingFileHelper())); // generator.addProvider(new Items(generator, ForestTree.MODID, event.getExistingFileHelper())); -// generator.addProvider(new Languages(generator, "en_us")); + generator.addProvider(new Languages(generator, "en_us")); } } } diff --git a/src/main/java/lilypuree/forest_tree/datagen/Languages.java b/src/main/java/lilypuree/forest_tree/datagen/Languages.java index aa5561f..6389f33 100644 --- a/src/main/java/lilypuree/forest_tree/datagen/Languages.java +++ b/src/main/java/lilypuree/forest_tree/datagen/Languages.java @@ -1,36 +1,34 @@ -//package lilypuree.forest_tree.datagen; -// -//import lilypuree.forest_tree.ForestTree; -//import lilypuree.forest_tree.datagen.types.ThicknessTypes; -//import lilypuree.forest_tree.datagen.types.TreeBlockTypes; -//import lilypuree.forest_tree.datagen.types.WoodTypes; -//import lilypuree.forest_tree.Registration; -//import net.minecraft.data.DataGenerator; -//import net.minecraftforge.common.data.LanguageProvider; -//import org.apache.commons.lang3.StringUtils; -// -//public class Languages extends LanguageProvider { -// -// public Languages(DataGenerator gen, String locale) { -// super(gen, ForestTree.MODID, locale); -// } -// -// @Override -// protected void addTranslations() { -// for(WoodTypes wood : WoodTypes.values()){ -// for (ThicknessTypes thickness : ThicknessTypes.values()){ -// for (TreeBlockTypes type : TreeBlockTypes.values()){ -// add(Registration.getTreeBlockItem(wood, thickness, type), StringUtils.capitalize(thickness.getName())+" " + StringUtils.capitalize(wood.getName()) +" "+ StringUtils.capitalize(type.getName())); -// } -// add(Registration.getTreeItem(wood,thickness), StringUtils.capitalize(thickness.getName())+" "+StringUtils.capitalize(wood.getName())+" Tree"); -// } -// add(Registration.getLeafBlockItem(wood, "slab"), StringUtils.capitalize(wood.getName())+" Leaves Slab"); -// add(Registration.getLeafBlockItem(wood, "stairs"), StringUtils.capitalize(wood.getName())+" Leaves Stairs"); -// add(Registration.getLeafBlockItem(wood, "trapdoor"), StringUtils.capitalize(wood.getName())+" Leaves Trapdoor"); -// add(Registration.getTimber(wood), StringUtils.capitalize(wood.getName())+" Timber"); -// } -// add(Registration.GRAFTING_TOOL.get(), "Grafting Tool"); -// -// -// } -//} +package lilypuree.forest_tree.datagen; + +import lilypuree.forest_tree.ForestTree; +import lilypuree.forest_tree.datagen.types.ThicknessTypes; +import lilypuree.forest_tree.datagen.types.TreeBlockTypes; +import lilypuree.forest_tree.datagen.types.WoodTypes; +import lilypuree.forest_tree.Registration; +import lilypuree.forest_tree.trees.world.gen.feature.parametric.Module; +import lilypuree.forest_tree.trees.world.gen.feature.parametric.Parameter; +import net.minecraft.data.DataGenerator; +import net.minecraftforge.common.data.LanguageProvider; +import org.apache.commons.lang3.StringUtils; + +public class Languages extends LanguageProvider { + + public Languages(DataGenerator gen, String locale) { + super(gen, ForestTree.MODID, locale); + } + + @Override + protected void addTranslations() { + add(Registration.TREE_DESIGNER_BLOCK.get(), "Tree Designer"); + add(Registration.CUSTOM_SAPLING.get(), "Custom Sapling"); + add(Registration.GRAFTING_TOOL.get(), "Grafting Tool"); + + for (Module module : Module.values()){ + for (Parameter parameter : Parameter.parameters[module.index]){ + add("forest_tree.treedesignergui.parameters."+parameter.name, parameter.name); + add("forest_tree.treedesignergui.descriptions."+parameter.name, "description here"); + } + add("forest_tree.treedesignergui.modules."+module.name(), module.name()); + } + } +} diff --git a/src/main/java/lilypuree/forest_tree/trees/block/BranchBlock.java b/src/main/java/lilypuree/forest_tree/trees/block/BranchBlock.java index a539940..dd4522d 100644 --- a/src/main/java/lilypuree/forest_tree/trees/block/BranchBlock.java +++ b/src/main/java/lilypuree/forest_tree/trees/block/BranchBlock.java @@ -1,5 +1,6 @@ package lilypuree.forest_tree.trees.block; +import lilypuree.forest_tree.Registration; import lilypuree.forest_tree.trees.species.Species; import lilypuree.forest_tree.util.Util; import net.minecraft.block.*; @@ -18,6 +19,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; @@ -71,7 +73,7 @@ private VoxelShape getClosestShape(Vec3d start, Vec3d end, BlockPos pos, IBlockR Block otherBlock = blockReader.getBlockState(otherPos).getBlock(); if (otherBlock instanceof BranchBlock && Util.compareVec3iToInts(((BranchBlock) otherBlock).getSourceOffset(), -i, -j, -k)) { shape = BranchVoxelShapes.getVoxelShapeForDirection(i, j, k); - }else{ + } else { continue; } } @@ -224,11 +226,27 @@ public void harvestBlock(World worldIn, PlayerEntity player, BlockPos pos, Block // super.harvestBlock(); if (worldIn.isRemote) return; boolean hasRightTool = true; + if (hasRightTool) { - //do a bfs search + recursiveDestroyTree(worldIn, pos, !player.isCreative()); } } + public void recursiveDestroyTree(World worldIn, BlockPos pos, boolean generateDrop) { + worldIn.destroyBlock(pos, generateDrop); + BlockPos.getAllInBox(new BlockPos(pos).add(-1, -1, -1), new BlockPos(pos).add(1, 1, 1)) + .forEach(bp -> { + Block block = worldIn.getBlockState(bp).getBlock(); + if (block instanceof BranchBlock) { + Vec3i soffset = ((BranchBlock) block).getSourceOffset(); + if (bp.add(soffset).equals(pos)) { + + ((BranchBlock) block).recursiveDestroyTree(worldIn, bp, generateDrop); + } + } + }); + } + @Override public boolean canBeReplacedByLeaves(BlockState state, IWorldReader world, BlockPos pos) { return false; diff --git a/src/main/java/lilypuree/forest_tree/trees/block/trees/CustomTree.java b/src/main/java/lilypuree/forest_tree/trees/block/trees/CustomTree.java index 945257c..a444096 100644 --- a/src/main/java/lilypuree/forest_tree/trees/block/trees/CustomTree.java +++ b/src/main/java/lilypuree/forest_tree/trees/block/trees/CustomTree.java @@ -1,10 +1,13 @@ package lilypuree.forest_tree.trees.block.trees; import lilypuree.forest_tree.core.registry.ForestTreeFeatures; +import lilypuree.forest_tree.trees.customization.CustomSaplingTile; import lilypuree.forest_tree.trees.world.gen.feature.TreeGenerator; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.tags.BlockTags; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.gen.ChunkGenerator; @@ -32,6 +35,12 @@ public boolean place(IWorld worldIn, ChunkGenerator generatorIn, BlockPos pos if(configuredFeature == null){ return false; }else { + TileEntity tileEntity = worldIn.getTileEntity(posIn); + CompoundNBT treeData = new CompoundNBT(); + if(tileEntity instanceof CustomSaplingTile){ + tileEntity.write(treeData); + } + worldIn.setBlockState(posIn, Blocks.AIR.getDefaultState(), 4); // ((AdvancedTreeFeatureConfig)configuredFeature.config).forcePlacement(); @@ -39,6 +48,10 @@ public boolean place(IWorld worldIn, ChunkGenerator generatorIn, BlockPos pos return true; }else { worldIn.setBlockState(posIn, stateIn, 4); + TileEntity newTileEntity = worldIn.getTileEntity(posIn); + if(newTileEntity instanceof CustomSaplingTile){ + newTileEntity.read(treeData); + } return false; } } diff --git a/src/main/java/lilypuree/forest_tree/trees/client/gui/DesignModuleButton.java b/src/main/java/lilypuree/forest_tree/trees/client/gui/DesignModuleButton.java index 9f16229..64d7120 100644 --- a/src/main/java/lilypuree/forest_tree/trees/client/gui/DesignModuleButton.java +++ b/src/main/java/lilypuree/forest_tree/trees/client/gui/DesignModuleButton.java @@ -1,28 +1,56 @@ package lilypuree.forest_tree.trees.client.gui; +import lilypuree.forest_tree.trees.world.gen.feature.parametric.Module; +import net.minecraft.util.text.TranslationTextComponent; import se.mickelus.mgui.gui.GuiClickable; import se.mickelus.mgui.gui.GuiRect; +import java.util.Collections; +import java.util.List; import java.util.function.Consumer; public class DesignModuleButton extends GuiClickable { Module module; + private boolean enabled; + private GuiRect selSquare; + public DesignModuleButton(int x, int y, Module module, Consumer clickHandler) { super(x, y, 20, 20, () -> clickHandler.accept(module)); + this.module = module; + this.enabled = true; + selSquare = new GuiRect(0, 0, width, height, 16777215); + selSquare.setOpacity(0.2f); + selSquare.setVisible(false); + addChild(selSquare); + } + + private void updateColor() { + if (!this.enabled) { + this.selSquare.setColor(8355711); + } else if (this.hasFocus()) { + this.selSquare.setColor(0xFFFF55); + this.selSquare.setVisible(true); + } else { + this.selSquare.setColor(16777215); + this.selSquare.setVisible(false); + } - addChild(new GuiRect(0, 0, width, height, 0)); } @Override protected void onFocus() { - super.onFocus(); + updateColor(); } @Override protected void onBlur() { - super.onBlur(); + updateColor(); } + @Override + public List getTooltipLines() { + return this.hasFocus() ? Collections.singletonList(new TranslationTextComponent("forest_tree.treedesignergui.modules."+module.name()).getFormattedText()) : null; + } } diff --git a/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiDesignModules.java b/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiDesignModules.java index 90cc4de..011fb24 100644 --- a/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiDesignModules.java +++ b/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiDesignModules.java @@ -1,5 +1,6 @@ package lilypuree.forest_tree.trees.client.gui; +import lilypuree.forest_tree.trees.world.gen.feature.parametric.Module; import se.mickelus.mgui.gui.GuiAttachment; import se.mickelus.mgui.gui.GuiElement; diff --git a/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiParameterElement.java b/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiParameterElement.java index 03d9672..13d7e1a 100644 --- a/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiParameterElement.java +++ b/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiParameterElement.java @@ -1,79 +1,161 @@ package lilypuree.forest_tree.trees.client.gui; import lilypuree.forest_tree.ForestTree; -import lilypuree.forest_tree.gui.GuiExtended; -import lilypuree.forest_tree.gui.GuiTextFieldWidget; +import lilypuree.forest_tree.client.gui.GuiExtended; +import lilypuree.forest_tree.client.gui.GuiTextFieldWidget; +import lilypuree.forest_tree.trees.world.gen.feature.parametric.Parameter; +import lilypuree.forest_tree.trees.world.gen.feature.parametric.TreeGenParamData; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.SharedConstants; -import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.TranslationTextComponent; -import se.mickelus.mgui.gui.*; +import se.mickelus.mgui.gui.GuiString; -import java.util.function.Consumer; +import java.util.Collections; +import java.util.List; public class GuiParameterElement extends GuiExtended { private Runnable onClickHandler; - private GuiTextFieldWidget textFieldWidget; - private Consumer onEnterPressed; + private Parameter parameter; + private TreeGenParamData paramData; + private GuiTextFieldWidget textFieldWidgetFocused; + private boolean showToolTip; + private static final int TEXT_LENGTH =150; + private static final int HELP_WIDTH = 10; - public GuiParameterElement(int x, int y, int width, int height, String name, Consumer responder, Runnable onClickHandler, boolean isInt) { + public GuiParameterElement(int x, int y, int width, int height, Parameter parameter, TreeGenParamData paramData, Runnable onClickHandler) { super(x, y, width, height); - this.onEnterPressed = responder; + + this.parameter = parameter; + this.paramData = paramData; this.onClickHandler = onClickHandler; + String paramName = new TranslationTextComponent(ForestTree.MODID + ".treedesignergui.parameters."+parameter.name).getFormattedText(); + this.addChild(new GuiString(1, 0, paramName).setShadow(true)); + this.addChild(new GuiString(width-HELP_WIDTH, 0, HELP_WIDTH, "?"){ + @Override + public List getTooltipLines() { + return showToolTip ? Collections.singletonList(new TranslationTextComponent(ForestTree.MODID+".treedesignergui.descriptions."+parameter.name).getFormattedText()) : null; + } + }); + this.initTextWidgets(); -// String paramName = new TranslationTextComponent(ForestTree.MODID + ".parameters."+name).getKey(); - String paramName = new TranslationTextComponent(name).getKey(); - this.addChild(new GuiString(0, 0, paramName).setShadow(true)); + } - textFieldWidget = new GuiTextFieldWidget(Minecraft.getInstance().fontRenderer, 100, 0, Math.max(0, width - 100) , 10); - if(isInt){ - textFieldWidget.setValidator(string -> string.matches("\\d?")); - }else { - textFieldWidget.setValidator(string -> string.matches("-?\\d?+(\\.\\d*)?")); + private void initTextWidgets() { + if (parameter.type == 2) { + float widgetWidth = (width-TEXT_LENGTH - HELP_WIDTH)/3.0f; + for (int i = 0; i < 9; i++) { + GuiTextFieldWidget textFieldWidget = new GuiTextFieldWidget(Minecraft.getInstance().fontRenderer, (int)(TEXT_LENGTH + (i % 3) * widgetWidth), (i / 3) * 10, (int)widgetWidth, 10); + initTextFieldWidgetArray(textFieldWidget, i); + if (i == 0) textFieldWidgetFocused = textFieldWidget; + addChild(textFieldWidget); + } + } else { + GuiTextFieldWidget textFieldWidget = new GuiTextFieldWidget(Minecraft.getInstance().fontRenderer, TEXT_LENGTH, 0, Math.max(0, width - TEXT_LENGTH), 10); + initTextFieldWidgetSimple(textFieldWidget); + textFieldWidgetFocused = textFieldWidget; + addChild(textFieldWidget); } - textFieldWidget.setResponder(responder); - this.addChild(textFieldWidget); } - public void setValue(String value) { - textFieldWidget.setText(value); - } + private void initTextFieldWidgetSimple(GuiTextFieldWidget textFieldWidget) { + switch (parameter.type) { + case 2: + return; + case 0: + textFieldWidget.setValidator(string -> string.matches("\\d*")); + textFieldWidget.setResponder(s -> { + try { + paramData.setIntegerValue(parameter, Integer.parseInt(s)); + } catch (NumberFormatException ignored) { - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - boolean flag = textFieldWidget.keyPressed(keyCode, scanCode, modifiers); - if (keyCode == 13) { - onEnterPressed.accept(textFieldWidget.getText()); - return true; + } + } + ); + textFieldWidget.setText(Integer.toString(paramData.getIntParameter(parameter))); + break; + case 1: + textFieldWidget.setValidator(string -> string.matches("-?\\d*+(\\.\\d*)?")); + textFieldWidget.setResponder(s -> { + try { + paramData.setFloatValue(parameter, Float.parseFloat(s)); + } catch (NumberFormatException ignored) { + + } + }); + textFieldWidget.setText(Float.toString(paramData.getFloatParameter(parameter))); } - return flag; +// initTextFieldWidgetClickHandler(textFieldWidget); } - public boolean charTyped(char typedChar) { - return textFieldWidget.charTyped(typedChar); + private void initTextFieldWidgetArray(GuiTextFieldWidget textFieldWidget, int index) { + if (parameter.type != 2) return; + textFieldWidget.setValidator(string -> string.matches("-?\\d?+(\\.\\d*)?")); + textFieldWidget.setResponder(s -> { + try { + paramData.setFloatArrayEntry(parameter, index, Float.parseFloat(s)); + } catch (NumberFormatException ignored) { + + } + }); + textFieldWidget.setText(Float.toString(paramData.getFloatArrayEntry(parameter, index))); + initTextFieldWidgetClickHandler(textFieldWidget); } + private void initTextFieldWidgetClickHandler(GuiTextFieldWidget textFieldWidget) { + textFieldWidget.setOnClickHandler(() -> { + if (textFieldWidget != textFieldWidgetFocused || !textFieldWidgetFocused.isSelected()) { + textFieldWidgetFocused.setSelected(false); + textFieldWidget.setSelected(true); + textFieldWidgetFocused = textFieldWidget; + } + }); + } + + @Override public boolean onClick(int x, int y) { super.onClick(x, y); if (this.hasFocus()) { - this.textFieldWidget.setHasFocus(true); +// this.textFieldWidget.setHasFocus(true); this.onClickHandler.run(); return true; } else { + removeSelection(); return false; } } + @Override + protected void calculateFocusState(int refX, int refY, int mouseX, int mouseY) { + super.calculateFocusState(refX, refY, mouseX, mouseY); + + boolean gainFocus = mouseX >= this.getX()+refX+width-HELP_WIDTH && mouseX < this.getX() + refX + this.getWidth() && mouseY >= this.getY() + refY && mouseY < this.getY() + refY + this.getHeight(); + if (gainFocus != this.showToolTip) { + this.showToolTip = gainFocus; + } + } + + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + boolean flag = textFieldWidgetFocused.keyPressed(keyCode, scanCode, modifiers); + if (keyCode == 13) { + return true; + } + return flag; + } + + public boolean charTyped(char typedChar) { + return textFieldWidgetFocused.charTyped(typedChar); + } + + public void tick() { - this.textFieldWidget.tick(); + if (textFieldWidgetFocused.isSelected()) + textFieldWidgetFocused.tick(); } - public void removeSelection(){ - this.textFieldWidget.setHasFocus(false); + public void removeSelection() { + this.textFieldWidgetFocused.setSelected(false); } } diff --git a/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiParameterPanel.java b/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiParameterPanel.java index a4d47dd..d9f2b1c 100644 --- a/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiParameterPanel.java +++ b/src/main/java/lilypuree/forest_tree/trees/client/gui/GuiParameterPanel.java @@ -1,88 +1,72 @@ package lilypuree.forest_tree.trees.client.gui; import com.mojang.blaze3d.matrix.MatrixStack; -import lilypuree.forest_tree.gui.GuiExtended; -import lilypuree.forest_tree.gui.GuiScrollBar; +import lilypuree.forest_tree.client.gui.GuiExtended; +import lilypuree.forest_tree.client.gui.GuiScrollBar; +import lilypuree.forest_tree.trees.world.gen.feature.parametric.Module; +import lilypuree.forest_tree.trees.world.gen.feature.parametric.Parameter; +import lilypuree.forest_tree.trees.world.gen.feature.parametric.TreeGenParamData; import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; import org.lwjgl.opengl.GL11; -import se.mickelus.mgui.gui.GuiAttachment; import se.mickelus.mgui.gui.GuiElement; -import se.mickelus.mgui.gui.GuiRect; - -import java.util.Map; public class GuiParameterPanel extends GuiExtended { - private Map paramMap; + private TreeGenParamData paramData; + private GuiElement background; private GuiScrollBar scrollBar; private GuiExtended parameterList; private GuiParameterElement selected = null; - private GuiElement selectionBox; private final int barWidth = 6; private int elementHeight = 18; - public GuiParameterPanel(int x, int y, int width, int height, Map paramMap) { + public GuiParameterPanel(int x, int y, int width, int height, TreeGenParamData paramData) { super(x, y, width, height); - this.paramMap = paramMap; + this.paramData = paramData; - this.scrollBar = new GuiScrollBar(width - barWidth, 0, barWidth, height, getContentHeight(0)); + this.scrollBar = new GuiScrollBar(width - barWidth , 0, barWidth, height, getContentHeight(0)); scrollBar.setScrollAmount(elementHeight / 2); addChild(scrollBar); - parameterList = new GuiExtended(0, 0, width - barWidth, height); + parameterList = new GuiExtended(0,0 , width - barWidth, height); addChild(parameterList); - - selectionBox = new GuiElement(0, 0, 10, 10); - addChild(selectionBox); - - } private int getContentHeight(int size) { - int tempHeight = 30; - tempHeight += size * elementHeight; - if (tempHeight < height - 8) { - tempHeight = height - 8; + int tempHeight = 10; + tempHeight += size; + if (tempHeight < height) { + tempHeight = height; } return tempHeight; } public void setModule(Module module) { - selectionBox.clearChildren(); parameterList.clearChildren(); if (module == null) { scrollBar.setContentHeight(getContentHeight(0)); + scrollBar.setScrollAmount(elementHeight/2); return; } - scrollBar.setContentHeight(getContentHeight(module.getParameterCount())); int index = 0; - for (String name : module.getParameterNames()) { + int height = 0; + for (Parameter parameter : Parameter.parameters[module.index]) { int finalIndex = index; - boolean isInt = name.equals("maxHeight") || name.equals("minimumBranchAge"); - GuiParameterElement element = new GuiParameterElement(0, index * elementHeight, parameterList.getWidth(), elementHeight, name, - s -> { - try { - if (isInt) { - int num = Integer.parseInt(s); - paramMap.put(name, (float) num); - } else { - float num = Float.parseFloat(s); - paramMap.put(name, num); - } - } catch (NumberFormatException ignored){ - - } - }, - () -> setSelected(finalIndex), isInt - ); + int elementHeight = parameter.type==2 ? this.elementHeight * 2 : this.elementHeight; + GuiParameterElement element = new GuiParameterElement(0, height, parameterList.getWidth(), elementHeight, parameter, paramData, () -> setSelected(finalIndex)); parameterList.addChild(element); + + height += elementHeight; index++; } + scrollBar.setContentHeight(getContentHeight(height)); + scrollBar.setScrollAmount(elementHeight/2); + parameterList.setY(-scrollBar.getScrollAmount()); } public void setSelected(int index) { @@ -92,12 +76,12 @@ public void setSelected(int index) { this.selected.removeSelection(); } this.selected = newSelected; - selectionBox.clearChildren(); - GuiRect selection = new GuiRect(0, 0, 3, 3, 0xFBAC76); - selection.setAttachmentAnchor(GuiAttachment.middleCenter); - selection.setAttachment(GuiAttachment.middleRight); - selection.setY(selected.getY()); - selectionBox.addChild(selection); +// selectionBox.clearChildren(); +// GuiRect selection = new GuiRect(0, 0, 3, 3, 0xFBAC76); +// selection.setAttachmentAnchor(GuiAttachment.middleCenter); +// selection.setAttachment(GuiAttachment.middleRight); +// selection.setY(selected.getY()); +// selectionBox.addChild(selection); } } @@ -124,12 +108,10 @@ public void mouseScrolled(double mouseX, double mouseY, double scroll) { public void draw(MatrixStack matrixStack, int refX, int refY, int screenWidth, int screenHeight, int mouseX, int mouseY, float opacity) { int baseY = -(int) scrollBar.getScrollDistance(); parameterList.setY(baseY); - selectionBox.setY(baseY); - MainWindow mainWindow = Minecraft.getInstance().getMainWindow(); double scale = mainWindow.getGuiScaleFactor(); GL11.glEnable(GL11.GL_SCISSOR_TEST); - GL11.glScissor((int) ((refX + this.x) * scale), (int) (mainWindow.getFramebufferHeight() - ((refY + height) * scale)), + GL11.glScissor((int) ((refX + this.x) * scale), (int) (mainWindow.getFramebufferHeight() - ((refY + this.y + height) * scale)), (int) ((width) * scale), (int) (height * scale)); super.draw(matrixStack, refX, refY, screenWidth, screenHeight, mouseX, mouseY, opacity); diff --git a/src/main/java/lilypuree/forest_tree/trees/client/gui/Module.java b/src/main/java/lilypuree/forest_tree/trees/client/gui/Module.java deleted file mode 100644 index e2340bb..0000000 --- a/src/main/java/lilypuree/forest_tree/trees/client/gui/Module.java +++ /dev/null @@ -1,25 +0,0 @@ -package lilypuree.forest_tree.trees.client.gui; - -public enum Module { - CREATION(0), GROWTH(1), TERMINATION(2), DIRECTIONS(3); - - private int moduleIndex; - private static final String[][] parameterNames = new String[][]{ - {"maxHeight", "minimumBranchAge", "meristemsPerNode", "meristemsPerNodeVariance", "meristemsPerAxillaryNode", "meristemsPerAxillaryNodeVariance","angleOffsetPerNode", "angleOffsetVariance", "axillaryAgeOffset", "axillaryAgeOffsetVariance", "terminalRegenRate"}, - {"nodeInterval", "nodeIntervalVariance", "axillaryNodeInterval", "axillaryNodeIntervalVariance", "terminalGrowthRate", "terminalGrowthRateVariance","axillaryGrowthRate", "axillaryGrowthRateVariance"}, - {"terminalDeathAgeMin", "terminalDeathAgeMax", "axillaryDeathAgeMin", "axillaryDeathAgeMax", "terminalDeathAgeMin", "branchDeathAgeMin","branchDeathAgeMax"}, - {"secondaryYawParallel", "secondaryYaw45Degree", "secondaryYaw90Degree", "secondaryPitch45Degree", "secondaryPitchHorizontal", "secondaryPitch135Degree","terminalYawVariance", "axillaryYawVariance", "terminalMarkovMatrix", "axillaryMarkovMatrix", "branchingMarkovMatrix"} - }; - - Module(int i){ - this.moduleIndex = i; - } - - public int getParameterCount() { - return parameterNames[moduleIndex].length; - } - - public String[] getParameterNames() { - return parameterNames[moduleIndex]; - } -} diff --git a/src/main/java/lilypuree/forest_tree/trees/client/gui/TreeDesignerScreen.java b/src/main/java/lilypuree/forest_tree/trees/client/gui/TreeDesignerScreen.java index b79512c..c10b863 100644 --- a/src/main/java/lilypuree/forest_tree/trees/client/gui/TreeDesignerScreen.java +++ b/src/main/java/lilypuree/forest_tree/trees/client/gui/TreeDesignerScreen.java @@ -2,20 +2,28 @@ import com.mojang.blaze3d.matrix.MatrixStack; import lilypuree.forest_tree.ForestTree; -import lilypuree.forest_tree.gui.GuiExtended; +import lilypuree.forest_tree.Registration; +import lilypuree.forest_tree.core.network.ForestTreePacketHandler; +import lilypuree.forest_tree.core.network.PacketSaveParams; +import lilypuree.forest_tree.client.gui.GuiExtended; +import lilypuree.forest_tree.client.gui.GuiResizableTexture; import lilypuree.forest_tree.trees.customization.TreeDesignerContainer; +import lilypuree.forest_tree.trees.world.gen.feature.parametric.Module; +import lilypuree.forest_tree.trees.world.gen.feature.parametric.TreeGenParamData; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.client.gui.GuiUtils; -import se.mickelus.mgui.gui.GuiElement; +import se.mickelus.mgui.gui.*; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; @OnlyIn(Dist.CLIENT) @@ -23,35 +31,109 @@ public class TreeDesignerScreen extends ContainerScreen { private static final ResourceLocation backgroundTexture = new ResourceLocation(ForestTree.MODID, "textures/gui/container/tree_designer.png"); private GuiExtended defaultGui; - private final TreeDesignerContainer container; private GuiDesignModules designModules; private Module selectedModule; + private GuiElement background; private GuiParameterPanel parameterPanel; + private int panelBorder = 2; - private Map parameters; + private TreeGenParamData paramData; public TreeDesignerScreen(TreeDesignerContainer container, PlayerInventory playerInventory, ITextComponent titleIn) { super(container, playerInventory, titleIn); + } + @Override + protected void init() { + paramData = getParametersFromStack(container.inventorySlots.get(0).getStack()); + System.out.println(this.width + " " +this.height); this.xSize = 320; - this.ySize = 240; - this.container = container; -// defaultGui = new GuiExtended(40, 70, width, height); - defaultGui = new GuiExtended(40, 60, width, height); -// defaultGui.addChild(new GuiTextureOffset(134, 40, 179, 150, backgroundTexture)); - designModules = new GuiDesignModules(0, 0, this::changeModule); + this.ySize = 180; + defaultGui = new GuiExtended(0, 0, xSize, ySize); + defaultGui.addChild(new GuiResizableTexture(0, 0, xSize, ySize, 0, 0, 400, 256, backgroundTexture)); + + defaultGui.addChild(new GuiString(15, 10, new TranslationTextComponent(ForestTree.MODID+".treedesignergui.title").getFormattedText()).setShadow(true)); + designModules = new GuiDesignModules(15, 25, this::changeModule); defaultGui.addChild(designModules); - parameterPanel = new GuiParameterPanel(30, 0,240, 100); + configurePanelBackground(); + + parameterPanel = new GuiParameterPanel(50 + panelBorder, 20 + panelBorder, xSize - 50 - 15 - panelBorder *2, ySize - 20*2 - panelBorder *2, paramData); defaultGui.addChild(parameterPanel); + + defaultGui.addChild(new GuiButton(15, 160, new TranslationTextComponent("forest_tree.treedesignergui.save").getFormattedText(), this::save)); + super.init(); + } + + private void configurePanelBackground(){ + int backgroundheight = ySize - 20*2; + int backgroundwidth = xSize - 50 - 15; + background = new GuiElement(50, 20, backgroundwidth,backgroundheight); + GuiRect transparentScreen = new GuiRect(0,0, backgroundwidth, backgroundheight, 0x111111); + transparentScreen.setOpacity(0.7f); + GuiRect left = new GuiRect(50, 20, 1, backgroundheight, 0x000000); + GuiRect right = new GuiRect(0, 0, 1, backgroundheight, 0x000000); + GuiRect top = new GuiRect(50, 20, 1, backgroundheight, 0x000000); + GuiRect bottom = new GuiRect(0 , 0, backgroundwidth, 1, 0x000000); + right.setAttachment(GuiAttachment.middleRight); + bottom.setAttachmentAnchor(GuiAttachment.bottomCenter); + bottom.setAttachmentPoint(GuiAttachment.bottomCenter); + background.addChild(transparentScreen); + background.addChild(bottom); + background.addChild(right); + background.setVisible(false); + defaultGui.addChild(background); + } + + private TreeGenParamData getParametersFromStack(ItemStack stack) { + CompoundNBT compound = stack.getOrCreateChildTag("BlockEntityTag"); + return TreeGenParamData.deserializeNbt(compound); + } + + private CompoundNBT writeNewParameters(CompoundNBT compound) { + compound.put("BlockEntityTag", paramData.writeToNbt(new CompoundNBT())); + return compound; } private void changeModule(Module module) { + if(paramData == null){ + paramData = getParametersFromStack(container.inventorySlots.get(0).getStack()); + if(paramData == null){ + background.setVisible(false); + return; + } + parameterPanel.remove(); + parameterPanel = new GuiParameterPanel(50 + panelBorder, 20 + panelBorder, xSize - 50 - 15 - panelBorder *2, ySize - 20*2 - panelBorder *2, paramData); + defaultGui.addChild(parameterPanel); + } selectedModule = module; parameterPanel.setModule(module); parameterPanel.setVisible(module != null); + background.setVisible(module != null); + } + + @Override + public boolean shouldCloseOnEsc() { + return true; + } + + @Override + public void onClose() { + save(); + super.onClose(); + } + + public void save(){ + ItemStack sapling = container.getSlot(0).getStack(); + if(sapling.getItem() == Registration.CUSTOM_SAPLING_ITEM.get() && paramData != null){ + CompoundNBT compound = paramData.writeToNbt(new CompoundNBT()); + ForestTreePacketHandler.sendToServer(new PacketSaveParams(this.container.getPos(),compound )); + ItemStack newStack = new ItemStack(sapling.getItem()); + newStack.setTagInfo("BlockEntityTag", compound); + container.getSlot(0).putStack(newStack); + } } @Override @@ -72,7 +154,6 @@ public void render(final int mouseX, final int mouseY, final float partialTicks) protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { int x = (width - xSize) / 2; int y = (height - ySize) / 2; - defaultGui.draw(new MatrixStack(), x, y, width, height, mouseX, mouseY, 1); } diff --git a/src/main/java/lilypuree/forest_tree/trees/client/render/BlockHologramRenderer.java b/src/main/java/lilypuree/forest_tree/trees/client/render/BlockHologramRenderer.java new file mode 100644 index 0000000..92080ca --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/trees/client/render/BlockHologramRenderer.java @@ -0,0 +1,78 @@ +package lilypuree.forest_tree.trees.client.render; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.IVertexBuilder; +import lilypuree.forest_tree.ForestTree; +import lilypuree.forest_tree.client.HologramRenderType; +import net.minecraft.block.BlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.model.BakedQuad; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.Vec3i; +import net.minecraft.world.ILightReader; +import net.minecraft.world.World; +import net.minecraftforge.client.extensions.IForgeVertexBuilder; +import net.minecraftforge.client.model.data.EmptyModelData; +import net.minecraftforge.client.model.data.IModelData; +import net.minecraftforge.client.model.pipeline.LightUtil; +import org.lwjgl.system.MemoryStack; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.util.Random; + +import static org.lwjgl.opengl.GL14C.GL_FUNC_ADD; + +public class BlockHologramRenderer extends BlockModelRenderer { + + private static BlockHologramRenderer INSTANCE; + + public BlockHologramRenderer(BlockModelRenderer baseRenderer) { + super(baseRenderer.blockColors); + } + + public static BlockHologramRenderer getInstance(BlockModelRenderer baseRenderer) { + if (INSTANCE == null || INSTANCE.blockColors != baseRenderer.blockColors) { + INSTANCE = new BlockHologramRenderer(baseRenderer); + } + + return INSTANCE; + } + + @Override + public boolean renderModel(ILightReader worldIn, IBakedModel modelIn, BlockState stateIn, BlockPos posIn, MatrixStack matrixIn, IVertexBuilder buffer, boolean checkSides, Random randomIn, long rand, int combinedOverlayIn, IModelData modelData) { + return super.renderModel(worldIn, modelIn, stateIn, posIn, matrixIn, buffer, checkSides, randomIn, rand, combinedOverlayIn, modelData); + } + + public static void renderBlockHologram(BlockPos pos, BlockState state, World world, MatrixStack matrix, IRenderTypeBuffer renderTypeBuffer, int combinedLight, int combinedOverlay) { + BlockRendererDispatcher blockDispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); + BlockModelRenderer renderer = getInstance(blockDispatcher.getBlockModelRenderer()); + IVertexBuilder hologramBuffer = renderTypeBuffer.getBuffer(HologramRenderType.HOLOGRAM); + + renderer.renderModelFlat( + world, + blockDispatcher.getModelForState(state), + state, + pos, + matrix, + hologramBuffer, + false, + world.rand, + state.getPositionRandom(pos), + OverlayTexture.NO_OVERLAY, + net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + + } + + +} diff --git a/src/main/java/lilypuree/forest_tree/trees/client/render/TreeDesignerRenderer.java b/src/main/java/lilypuree/forest_tree/trees/client/render/TreeDesignerRenderer.java new file mode 100644 index 0000000..c24a2b7 --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/trees/client/render/TreeDesignerRenderer.java @@ -0,0 +1,187 @@ +package lilypuree.forest_tree.trees.client.render; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.IVertexBuilder; +import lilypuree.forest_tree.ForestTree; +import lilypuree.forest_tree.Registration; +import lilypuree.forest_tree.client.HologramRenderType; +import lilypuree.forest_tree.trees.customization.TreeDesignerTile; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.item.BlockItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.client.registry.ClientRegistry; + +public class TreeDesignerRenderer extends TileEntityRenderer { + + public static final ResourceLocation HOLOGRAM_RAY = new ResourceLocation(ForestTree.MODID, "block/hologram_ray_3"); + public static final ResourceLocation HOLOGRAM = new ResourceLocation(ForestTree.MODID, "block/hologram"); + private static TextureAtlasSprite sprite = null; + + public TreeDesignerRenderer(TileEntityRendererDispatcher rendererDispatcherIn) { + super(rendererDispatcherIn); + } + + private static void add(IVertexBuilder renderer, MatrixStack stack, float x, float y, float z, float u, float v) { + renderer.pos(stack.getLast().getMatrix(), x, y, z) + .color(1.0f, 1.0f, 1.0f, 1.0f) + .tex(u, v) + .lightmap(0, 240) + .normal(0, 1, 0) + .endVertex(); + } + + @Override + public void render(TreeDesignerTile tileEntityIn, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { + ItemStack sapling = tileEntityIn.saplingHandler.getStackInSlot(0); + if (sapling.isEmpty()) { + + } else { + long time = System.currentTimeMillis(); + float angle = (time / 50) % 360; + Quaternion rotation = Vector3f.YP.rotationDegrees(angle); + + matrixStack.push(); + float scale = 0.6f; + matrixStack.translate(0.5f * (1 - scale), 0.7f, 0.5f * (1 - scale)); + matrixStack.scale(scale, scale, scale); + matrixStack.translate(0.5f, 0, 0.5f); + matrixStack.rotate(rotation); + matrixStack.translate(-0.5f, 0.0f, -0.5f); + BlockHologramRenderer.renderBlockHologram(tileEntityIn.getPos(), ((BlockItem) sapling.getItem()).getBlock().getDefaultState(), tileEntityIn.getWorld(), matrixStack, bufferIn, combinedLightIn, combinedOverlayIn); + + + matrixStack.pop(); + + addHologramEye(bufferIn, matrixStack); + + int columns = Math.max((int)((100 - tileEntityIn.getPos().distanceSq(Minecraft.getInstance().player.getPosition())) / 10), 1); + + renderDissectedHologramRays(bufferIn, matrixStack, columns); + } + } + + private static float lowerWidthHalf = 2.5f / 16.0f; + private static float upperWidthHalf = 6 / 16.0f; + private static float height = 7 / 16.0f; + private static float actualheight = (float) Math.sqrt((upperWidthHalf - lowerWidthHalf) * (upperWidthHalf - lowerWidthHalf) + height * height); + + + private void addHologramEye(IRenderTypeBuffer buffer, MatrixStack matrixStack) { + IVertexBuilder builder = buffer.getBuffer(HologramRenderType.HOLOGRAM); + sprite = Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(HOLOGRAM); + float x1 = 0.5f - lowerWidthHalf; + float x2 = 0.5f + lowerWidthHalf; + float uwidth = sprite.getMaxU() - sprite.getMinU(); + float vwidth = sprite.getMaxV() - sprite.getMinV(); + float u1 = sprite.getMinU() + uwidth * 5 / 16.0f; + float u2 = sprite.getMinU() + uwidth * 11 / 16.0f; + float v1 = sprite.getMinV() + vwidth * 5 / 16.0f; + float v2 = sprite.getMinV() + vwidth * 11 / 16.0f; + add(builder, matrixStack, x1, 0.26f, x1, u1, v1); + add(builder, matrixStack, x1, 0.26f, x2, u1, v2); + add(builder, matrixStack, x2, 0.26f, x2, u2, v2); + add(builder, matrixStack, x2, 0.26f, x1, u2, v1); + } + + private void renderDissectedHologramRays(IRenderTypeBuffer buffer, MatrixStack matrixStack, int columns) { + IVertexBuilder builder = buffer.getBuffer(RenderType.getTranslucent()); + sprite = Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(HOLOGRAM_RAY); + + float x1 = 0.5f - lowerWidthHalf; + float x2 = 0.5f + lowerWidthHalf; + float x3 = 0.5f - upperWidthHalf; + float x4 = 0.5f + upperWidthHalf; + float y1 = 0.25f; + float y2 = 0.25f + height; + Vector3f vl1 = new Vector3f(x1, y1, x1); + Vector3f vl2 = new Vector3f(x1, y1, x2); + Vector3f vl3 = new Vector3f(x2, y1, x2); + Vector3f vl4 = new Vector3f(x2, y1, x1); + Vector3f vu1 = new Vector3f(x3, y2, x3); + Vector3f vu2 = new Vector3f(x3, y2, x4); + Vector3f vu3 = new Vector3f(x4, y2, x4); + Vector3f vu4 = new Vector3f(x4, y2, x3); + + float minU = sprite.getMinU(); + float texWidth = sprite.getMaxU() - sprite.getMinU(); + float texHeight = sprite.getMaxV() - sprite.getMinV(); + float u1 = minU + (0.5f - lowerWidthHalf) * texWidth; + float u2 = minU + (0.5f + lowerWidthHalf) * texWidth; + float u3 = minU + (0.5f - upperWidthHalf) * texWidth; + float u4 = minU + (0.5f + upperWidthHalf) * texWidth; + float minV = Math.min(sprite.getMinV() + actualheight * texHeight, sprite.getMaxV()); + float maxV = sprite.getMinV(); + + + addDissectedPlanes(builder, matrixStack, vl1, vl2, vu2, vu1, u1, u2, u4, u3, minV, maxV, columns); + addDissectedPlanes(builder, matrixStack, vl2, vl3, vu3, vu2, u1, u2, u4, u3, minV, maxV, columns); + addDissectedPlanes(builder, matrixStack, vl3, vl4, vu4, vu3, u1, u2, u4, u3, minV, maxV, columns); + addDissectedPlanes(builder, matrixStack, vl4, vl1, vu1, vu4, u1, u2, u4, u3, minV, maxV, columns); + } + + public static void addDissectedPlanes(IVertexBuilder builder, MatrixStack matrixStack, Vector3f v1, Vector3f v2, Vector3f v3, Vector3f v4, float u1, float u2, float u3, float u4, float minV, float maxV, int columns) { + float textureWidthLower = u2 - u1; + float textureWidthUpper = u3 - u4; + + float columnWidthMultiplier = 0.4f; + float textureColumnWidthLower = textureWidthLower * columnWidthMultiplier; + float textureColumnWidthUpper = textureWidthUpper * columnWidthMultiplier; + float x1 = v1.getX(); + float x2 = v2.getX(); + float xWidthLower = x2 - x1; + float x3 = v3.getX(); + float x4 = v4.getX(); + float xWidthUpper = x3 - x4; + float z1 = v1.getZ(); + float z2 = v2.getZ(); + float zWidthLower = z2 - z1; + float z3 = v3.getZ(); + float z4 = v4.getZ(); + float zWidthUpper = z3 - z4; + float y1 = v1.getY(); + float y2 = v3.getY(); + float columnWidthLowerX = xWidthLower / columns * columnWidthMultiplier; + float columnWidthUpperX = xWidthUpper / columns * columnWidthMultiplier; + float columnWidthLowerZ = zWidthLower / columns * columnWidthMultiplier; + float columnWidthUpperZ = zWidthUpper / columns * columnWidthMultiplier; + for (int i = 0; i < columns; i++) { + float k = i / (float) columns; + Vector3f vc1 = new Vector3f(x1 + xWidthLower * k, y1, z1 + zWidthLower * k); + Vector3f vc2 = new Vector3f(x1 + xWidthLower * k + columnWidthLowerX, y1, z1 + zWidthLower * k + columnWidthLowerZ); + Vector3f vc3 = new Vector3f(x4 + xWidthUpper * k + columnWidthUpperX, y2, z4 + zWidthUpper * k + columnWidthUpperZ); + Vector3f vc4 = new Vector3f(x4 + xWidthUpper * k, y2, z4 + zWidthUpper * k); + float uc1 = u1 + k * textureWidthLower; + float uc2 = u1 + k * textureWidthLower + textureColumnWidthLower; + float uc3 = u4 + k * textureWidthUpper + textureColumnWidthUpper; + float uc4 = u4 + k * textureWidthUpper; + addFullPlane(builder, matrixStack, vc1, vc2, vc3, vc4, uc1, uc2, uc3, uc4, minV, maxV); + } + } + + public static void addFullPlane(IVertexBuilder builder, MatrixStack matrixStack, Vector3f v1, Vector3f v2, Vector3f v3, Vector3f v4, float u1, float u2, float u3, float u4, float minV, float maxV) { + add(builder, matrixStack, v1.getX(), v1.getY(), v1.getZ(), u1, minV); + add(builder, matrixStack, v2.getX(), v2.getY(), v2.getZ(), u2, minV); + add(builder, matrixStack, v3.getX(), v3.getY(), v3.getZ(), u3, maxV); + add(builder, matrixStack, v4.getX(), v4.getY(), v4.getZ(), u4, maxV); + + add(builder, matrixStack, v1.getX(), v1.getY(), v1.getZ(), u1, minV); + add(builder, matrixStack, v4.getX(), v4.getY(), v4.getZ(), u4, maxV); + add(builder, matrixStack, v3.getX(), v3.getY(), v3.getZ(), u3, maxV); + add(builder, matrixStack, v2.getX(), v2.getY(), v2.getZ(), u2, minV); + } + + public static void register() { + ClientRegistry.bindTileEntityRenderer(Registration.TREE_DESIGNER_TILE.get(), TreeDesignerRenderer::new); + } + + @Override + public boolean isGlobalRenderer(TreeDesignerTile te) { + return true; + } +} diff --git a/src/main/java/lilypuree/forest_tree/trees/customization/CustomSaplingBlock.java b/src/main/java/lilypuree/forest_tree/trees/customization/CustomSaplingBlock.java index 8a5aaa6..13fbc3e 100644 --- a/src/main/java/lilypuree/forest_tree/trees/customization/CustomSaplingBlock.java +++ b/src/main/java/lilypuree/forest_tree/trees/customization/CustomSaplingBlock.java @@ -10,6 +10,8 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.InventoryHelper; +import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.state.IntegerProperty; @@ -22,6 +24,7 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.items.ItemHandlerHelper; import javax.annotation.Nullable; import java.util.Random; @@ -61,10 +64,7 @@ public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, Play if (customSaplingTile.hasCustomName()) { itemstack.setDisplayName(customSaplingTile.getCustomName()); } - - ItemEntity itementity = new ItemEntity(worldIn, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), itemstack); - itementity.setDefaultPickupDelay(); - worldIn.addEntity(itementity); + InventoryHelper.spawnItemStack(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, itemstack); } } super.onBlockHarvested(worldIn, pos, state, player); @@ -73,9 +73,9 @@ public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, Play @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { - if (stack.hasDisplayName()) { - TileEntity tileentity = worldIn.getTileEntity(pos); - if (tileentity instanceof CustomSaplingTile) { + TileEntity tileentity = worldIn.getTileEntity(pos); + if (tileentity instanceof CustomSaplingTile) { + if (stack.hasDisplayName()) { ((CustomSaplingTile) tileentity).setCustomName(stack.getDisplayName()); } } @@ -105,19 +105,19 @@ public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Rand } public void placeTree(ServerWorld world, BlockPos pos, BlockState state, Random rand) { - if (state.get(STAGE) == 0) { - world.setBlockState(pos, state.cycle(STAGE), 4); - } else { - if (!net.minecraftforge.event.ForgeEventFactory.saplingGrowTree(world, rand, pos)) return; - CustomSaplingTile customSaplingTile = (CustomSaplingTile) world.getTileEntity(pos); - if (customSaplingTile != null) { - CustomTree customTree = new CustomTree(customSaplingTile.getTreeGenerator()); - - //TODO - //set age here? - customTree.place(world, world.getChunkProvider().getChunkGenerator(), pos, state, rand); - } +// if (state.get(STAGE) == 0) { +// world.setBlockState(pos, state.cycle(STAGE), 4); +// } else { + if (!net.minecraftforge.event.ForgeEventFactory.saplingGrowTree(world, rand, pos)) return; + CustomSaplingTile customSaplingTile = (CustomSaplingTile) world.getTileEntity(pos); + if (customSaplingTile != null) { + CustomTree customTree = new CustomTree(customSaplingTile.getTreeGenerator()); + + //TODO + //set age here? + customTree.place(world, world.getChunkProvider().getChunkGenerator(), pos, state, rand); } +// } } diff --git a/src/main/java/lilypuree/forest_tree/trees/customization/CustomSaplingTile.java b/src/main/java/lilypuree/forest_tree/trees/customization/CustomSaplingTile.java index f1aee4a..48e128c 100644 --- a/src/main/java/lilypuree/forest_tree/trees/customization/CustomSaplingTile.java +++ b/src/main/java/lilypuree/forest_tree/trees/customization/CustomSaplingTile.java @@ -51,6 +51,7 @@ public CompoundNBT getUpdateTag() { } public CompoundNBT saveToNbt(CompoundNBT compound) { + if(treeGenerator == null) return compound; return treeGenerator.saveToNbt(compound); } diff --git a/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerBlock.java b/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerBlock.java index 7161cb9..2fac65d 100644 --- a/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerBlock.java +++ b/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerBlock.java @@ -1,46 +1,69 @@ package lilypuree.forest_tree.trees.customization; import lilypuree.forest_tree.ForestTree; +import lilypuree.forest_tree.Registration; import net.minecraft.block.Block; +import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.stats.Stats; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; +import javax.annotation.Nonnull; import javax.annotation.Nullable; public class TreeDesignerBlock extends Block { private static final ITextComponent CONTAINER_NAME = new TranslationTextComponent(ForestTree.MODID + "container.treeDesigning"); + private static final VoxelShape BLOCK_SHAPE = VoxelShapes.create(0.0, 0.0, 0.0, 1.0, 0.25, 1.0); public TreeDesignerBlock(Block.Properties properties) { super(properties); } + @Nonnull @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (worldIn.isRemote) { - return ActionResultType.SUCCESS; - } else { + if (worldIn.isRemote()) return ActionResultType.SUCCESS; + else { final TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof TreeDesignerTile) { - ForestTree.LOGGER.info("opening gui"); - NetworkHooks.openGui((ServerPlayerEntity) player, (TreeDesignerTile) tileEntity, pos); + if (player.isSneaking() && player.getHeldItemMainhand().isEmpty()) { + ((TreeDesignerTile) tileEntity).extractSapling(); + worldIn.notifyBlockUpdate(pos, state, state, 3); + } else if (player.getHeldItemMainhand().getItem() == Registration.CUSTOM_SAPLING_ITEM.get()) { + } else { + NetworkHooks.openGui((ServerPlayerEntity) player, (TreeDesignerTile) tileEntity, pos); + return ActionResultType.SUCCESS; + } } - return ActionResultType.SUCCESS; + return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); } } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return BLOCK_SHAPE; + } + + @Override + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.MODEL; + } + @Override public boolean hasTileEntity(BlockState state) { return true; diff --git a/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerContainer.java b/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerContainer.java index b12b7c7..a2c8892 100644 --- a/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerContainer.java +++ b/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerContainer.java @@ -6,35 +6,43 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.IContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; +import net.minecraft.util.IWorldPosCallable; import net.minecraft.util.math.BlockPos; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.SlotItemHandler; +import net.minecraftforge.items.*; + +import javax.annotation.Nonnull; public class TreeDesignerContainer extends Container { - private TreeDesignerTile treeDesigner; + private final IWorldPosCallable usabilityTest; + private final BlockPos pos; + private final PlayerEntity player; + + public static TreeDesignerContainer getClientContainer(final int windowId, final PlayerInventory playerInventory, final PacketBuffer extraData) { + return new TreeDesignerContainer(windowId, playerInventory, extraData.readBlockPos(), new ItemStackHandler(1)); + } - @OnlyIn(Dist.CLIENT) - public static TreeDesignerContainer create(final int windowId, final PlayerInventory playerInventory, final PacketBuffer extraData) { - TreeDesignerTile treeDesignerTile = (TreeDesignerTile) Minecraft.getInstance().world.getTileEntity(extraData.readBlockPos()); - return new TreeDesignerContainer(windowId, treeDesignerTile, playerInventory, Minecraft.getInstance().player); + public static IContainerProvider getServerContainerProvider(TreeDesignerTile te, BlockPos activationPos){ + return (id, playerInventory, serverPlayer) -> new TreeDesignerContainer(id, playerInventory, activationPos, te.saplingHandler); } - public TreeDesignerContainer(final int windowId, TreeDesignerTile treeDesignerIn, final PlayerInventory playerInventory, PlayerEntity player) { - super(Registration.TREE_DESIGNER_CONTAINER.get(), windowId); - this.treeDesigner = treeDesignerIn; + private TreeDesignerContainer(final int id, final PlayerInventory playerInventory, BlockPos pos, IItemHandler itemHandler) { + super(Registration.TREE_DESIGNER_CONTAINER.get(), id); + this.pos = pos; + this.player = playerInventory.player; + this.usabilityTest = IWorldPosCallable.of(this.player.world, pos); + addSlot(new SlotItemHandler(itemHandler, 0, 15, 135)); - treeDesigner.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(handler -> { - addSlot(new SlotItemHandler(handler, 0, 50, 58)); - }); // ContainerHelper.addPlayerInventoryToContainer(this, playerInventory); } + @Nonnull @Override public ItemStack transferStackInSlot(PlayerEntity player, int index) { return ContainerHelper.transferStackInSlot(this, player, index); @@ -42,13 +50,10 @@ public ItemStack transferStackInSlot(PlayerEntity player, int index) { @Override public boolean canInteractWith(PlayerEntity player) { - BlockPos pos = treeDesigner.getPos(); - - // based on Container.isWithinUsableDistance but with more generic blockcheck - if (treeDesigner.getWorld().getBlockState(treeDesigner.getPos()).getBlock() instanceof TreeDesignerBlock) { - return player.getDistanceSq((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D) <= 64.0D; - } + return isWithinUsableDistance(this.usabilityTest, player, Registration.TREE_DESIGNER_BLOCK.get()); + } - return false; + public BlockPos getPos(){ + return pos; } } diff --git a/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerTile.java b/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerTile.java index b51ca3e..37dc0ad 100644 --- a/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerTile.java +++ b/src/main/java/lilypuree/forest_tree/trees/customization/TreeDesignerTile.java @@ -1,16 +1,25 @@ package lilypuree.forest_tree.trees.customization; import lilypuree.forest_tree.Registration; +import lilypuree.forest_tree.core.network.ForestTreePacketHandler; +import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.InventoryHelper; +import net.minecraft.inventory.ItemStackHelper; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.SUpdateTileEntityPacket; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; @@ -21,28 +30,61 @@ public class TreeDesignerTile extends TileEntity implements INamedContainerProvider { - private LazyOptional handler = LazyOptional.of(this::createHandler); - private ItemStackHandler saplingHandler; + public final ItemStackHandler saplingHandler = new ItemStackHandler(1) { + @Override + protected void onContentsChanged(int slot) { + super.onContentsChanged(slot); + if (!world.isRemote) { + lastChangeTime = world.getGameTime(); + } + markDirty(); + } + + @Override + public int getSlotLimit(int slot) { + return 1; + } + + @Override + public boolean isItemValid(int slot, @Nonnull ItemStack stack) { + return super.isItemValid(slot, stack); + } + }; + + private final LazyOptional handler = LazyOptional.of(() -> saplingHandler); private static final String inventoryKey = "inv"; + public long lastChangeTime; public TreeDesignerTile() { super(Registration.TREE_DESIGNER_TILE.get()); } - private ItemStackHandler createHandler() { - return new ItemStackHandler(1) { - @Override - public int getSlotLimit(int slot) { - return 1; - } + public void extractSapling() { + if (world.isRemote) return; + ItemStack extractStack = saplingHandler.extractItem(0, 1, false); + if (!extractStack.isEmpty()) { + InventoryHelper.spawnItemStack(this.world, pos.getX(), pos.getY() + 0.4, pos.getZ(), extractStack); + } + this.markDirty(); + } - @Override - public boolean isItemValid(int slot, @Nonnull ItemStack stack) { - return super.isItemValid(slot, stack); - } - }; + public boolean insertSapling(ItemStack stack) { + if (world.isRemote || stack.getItem() != Registration.CUSTOM_SAPLING_ITEM.get() || !saplingHandler.getStackInSlot(0).isEmpty()) { + return false; + } else { + ItemStack returnStack = saplingHandler.insertItem(0, stack, false); + world.notifyBlockUpdate(pos, this.getBlockState(), this.getBlockState(), 3); + this.markDirty(); + return true; + } + } + + @Override + public void remove() { + this.extractSapling(); + super.remove(); } @Nonnull @@ -57,17 +99,36 @@ public LazyOptional getCapability(@Nonnull Capability cap, @Nullable D @Override public void read(CompoundNBT compound) { super.read(compound); - handler.ifPresent(handler -> handler.deserializeNBT(compound.getCompound(inventoryKey))); - + lastChangeTime = compound.getLong("lastChangeTime"); + saplingHandler.deserializeNBT(compound.getCompound(inventoryKey)); } + @Nonnull @Override public CompoundNBT write(CompoundNBT compound) { super.write(compound); - handler.ifPresent(handler -> compound.put(inventoryKey, handler.serializeNBT())); + compound.putLong("lastChangeTime", lastChangeTime); + compound.put(inventoryKey, saplingHandler.serializeNBT()); return compound; } + @Nullable + @Override + public SUpdateTileEntityPacket getUpdatePacket() { + return new SUpdateTileEntityPacket(this.pos, 0, getUpdateTag()); + } + + @Override + public CompoundNBT getUpdateTag() { + return this.write(new CompoundNBT()); + } + + @Override + public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) { + this.read(pkt.getNbtCompound()); + } + + @Nonnull @Override public ITextComponent getDisplayName() { return new TranslationTextComponent("block.treeDesigner"); @@ -75,7 +136,14 @@ public ITextComponent getDisplayName() { @Nullable @Override - public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity playerEntity) { - return new TreeDesignerContainer(windowId, this, playerInventory, playerEntity); + public Container createMenu(int windowId, @Nonnull PlayerInventory playerInventory, @Nonnull PlayerEntity playerEntity) { + return TreeDesignerContainer.getServerContainerProvider(this, pos).createMenu(windowId, playerInventory, playerEntity); + } + + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return new AxisAlignedBB(getPos(), getPos().add(1, 1, 1)); } + } diff --git a/src/main/java/lilypuree/forest_tree/trees/items/CustomSaplingItem.java b/src/main/java/lilypuree/forest_tree/trees/items/CustomSaplingItem.java new file mode 100644 index 0000000..bca4c67 --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/trees/items/CustomSaplingItem.java @@ -0,0 +1,65 @@ +package lilypuree.forest_tree.trees.items; + +import lilypuree.forest_tree.Registration; +import lilypuree.forest_tree.trees.customization.TreeDesignerTile; +import lilypuree.forest_tree.trees.world.gen.feature.TreeGenerator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.*; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.items.CapabilityItemHandler; + +import javax.annotation.Nonnull; + +public class CustomSaplingItem extends BlockItem { + + public CustomSaplingItem(Block block, Item.Properties properties) { + super(block, properties); + } + + @Override + public void fillItemGroup(ItemGroup group, NonNullList items) { + if (this.isInGroup(group)) { + CompoundNBT nbt = new CompoundNBT(); + nbt.put("BlockEntityTag", new TreeGenerator().saveToNbt(new CompoundNBT())); + ItemStack newStack = new ItemStack(this.getBlock()); + newStack.setTag(nbt); + items.add(newStack); + } + } + + + @Nonnull + @Override + public ActionResultType onItemUse(ItemUseContext context) { + World world = context.getWorld(); + BlockPos pos = context.getPos(); + PlayerEntity player = context.getPlayer(); + BlockState blockState = world.getBlockState(pos); + if (world.isRemote) { + return ActionResultType.PASS; + } else if (blockState.getBlock() == Registration.TREE_DESIGNER_BLOCK.get()) { + if (player != null && player.isSneaking()) { + final TileEntity tileEntity = world.getTileEntity(pos); + if (tileEntity instanceof TreeDesignerTile) { + boolean success = ((TreeDesignerTile) tileEntity).insertSapling(context.getItem()); + if(success){ + if(!player.isCreative()){ + context.getItem().shrink(1); + } + return ActionResultType.SUCCESS; + } + } + } + } + return super.onItemUse(context); + } + +} diff --git a/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/AdvancedTreeFeature.java b/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/AdvancedTreeFeature.java index b8b80e9..b66cb18 100644 --- a/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/AdvancedTreeFeature.java +++ b/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/AdvancedTreeFeature.java @@ -35,9 +35,10 @@ public AdvancedTreeFeature(Function, ? extends T> configFactoryIn) { this.treeGenerator = new TreeGenerator(); } - public AdvancedTreeFeature withGenerator(TreeGenerator generator){ - this.treeGenerator = generator; - return this; + public AdvancedTreeFeature withGenerator(TreeGenerator generator){ + AdvancedTreeFeature feature = new AdvancedTreeFeature<>(NoFeatureConfig::deserialize); + feature.treeGenerator = generator; + return feature; } protected boolean generate(IWorldGenerationReader reader, Random rand, BlockPos pos, Set branches, Set leaves, MutableBoundingBox mBB, T Config) { diff --git a/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/MeristemTerminator.java b/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/MeristemTerminator.java index 0eb783e..a123f6d 100644 --- a/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/MeristemTerminator.java +++ b/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/MeristemTerminator.java @@ -3,8 +3,8 @@ import net.minecraft.nbt.CompoundNBT; public class MeristemTerminator { - private float terminalDeathAgeMin = 0.0f; - private float terminalDeathAgeMax = 0.0f; + private float terminalDeathAgeMin = 5.0f; + private float terminalDeathAgeMax = 12.0f; private float axillaryDeathAgeMin = 3.8f; private float axillaryDeathAgeMax = 9.2f; private float branchDeathAgeMin = 5.4f; @@ -23,7 +23,7 @@ public MeristemTerminator init(float terminalDeathAgeMaxIn, float terminalDeathA public float getMeristemDeathRate(Meristem meristem) { if (meristem.isTerminal()) { - return uniformRandomAlt(terminalDeathAgeMax, terminalDeathAgeMin, meristem.getAge()); + return 1 - uniformRandomAlt(terminalDeathAgeMax, terminalDeathAgeMin, meristem.getAge()); } else { if (meristem.getLength() == 0) { //a newly generated axillary. return uniformRandomAlt(branchDeathAgeMax, branchDeathAgeMin, meristem.getAge()); @@ -33,6 +33,7 @@ public float getMeristemDeathRate(Meristem meristem) { } + private float uniformRandomAlt(float max, float min, float x) { if (x <= min) return 0; else if (x >= max) return 1; diff --git a/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/Module.java b/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/Module.java new file mode 100644 index 0000000..ccd072e --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/Module.java @@ -0,0 +1,18 @@ +package lilypuree.forest_tree.trees.world.gen.feature.parametric; + +import java.util.Arrays; +import java.util.stream.Stream; + +public enum Module { + CREATION(0), GROWTH(1), TERMINATION(2), DIRECTIONS(3); + + public int index; + + Module(int i) { + this.index = i; + } + + public int getParameterCount() { + return Parameter.parameters[index].length; + } +} diff --git a/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/Parameter.java b/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/Parameter.java new file mode 100644 index 0000000..7c81e06 --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/Parameter.java @@ -0,0 +1,40 @@ +package lilypuree.forest_tree.trees.world.gen.feature.parametric; + +public class Parameter { + + public static final Parameter[][] parameters = new Parameter[][]{ + {p("maxHeight", 0), p("minimumBranchAge", 0), pf("meristemsPerNode"), pf("meristemsPerNodeVariance"), pf("meristemsPerAxillaryNode"), pf("meristemsPerAxillaryNodeVariance"), pf("angleOffsetPerNode"), pf("angleOffsetVariance"), pf("axillaryAgeOffset"), pf("axillaryAgeOffsetVariance"), pf("terminalRegenRate")}, + {pf("nodeInterval"), pf("nodeIntervalVariance"), pf("axillaryNodeInterval"), pf("axillaryNodeIntervalVariance"), pf("terminalGrowthRate"), pf("terminalGrowthRateVariance"), pf("axillaryGrowthRate"), pf("axillaryGrowthRateVariance")}, + {pf("terminalDeathAgeMin"), pf("terminalDeathAgeMax"), pf("axillaryDeathAgeMin"), pf("axillaryDeathAgeMax"), pf("branchDeathAgeMin"), pf("branchDeathAgeMax")}, + {pf("secondaryYawParallel"), pf("secondaryYaw45Degree"), pf("secondaryYaw90Degree"), pf("secondaryPitch45Degree"), pf("secondaryPitchHorizontal"), pf("secondaryPitch135Degree"), pf("terminalYawVariance"), pf("axillaryYawVariance"), p("terminalMarkovMatrix", 2), p("axillaryMarkovMatrix", 2), p("branchingMarkovMatrix", 2)} + }; + + + public String name; + + /** + * 0 : int, 1 : float, 2 : float array + */ + public byte type; + + private Parameter(String name, byte type) { + this.name = name; + this.type = type; + } + + private static Parameter pf(String name) { + return new Parameter(name, (byte) 1); + } + + private static Parameter p(String name, int type) { + return new Parameter(name, (byte) type); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof Parameter) { + return ((Parameter) obj).name.equals(this.name); + } + return false; + } +} diff --git a/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/TreeGenParamData.java b/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/TreeGenParamData.java new file mode 100644 index 0000000..d148a3f --- /dev/null +++ b/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/TreeGenParamData.java @@ -0,0 +1,154 @@ +package lilypuree.forest_tree.trees.world.gen.feature.parametric; + +import net.minecraft.nbt.CompoundNBT; + +import java.util.HashMap; +import java.util.Map; + +public class TreeGenParamData { + + Map integerParams; + Map floatParams; + Map floatArrayParams; + + public TreeGenParamData() { + integerParams = new HashMap<>(); + floatParams = new HashMap<>(); + floatArrayParams = new HashMap<>(); + } + + public void setParameterValue(Parameter param, Object value) { + switch (param.type) { + case 0: + if (value instanceof String) { + integerParams.put(param, Integer.valueOf((String) value)); + } else if (value instanceof Integer) { + integerParams.put(param, (int) value); + } + break; + case 1: + if (value instanceof String) { + floatParams.put(param, Float.valueOf((String) value)); + } else if (value instanceof Float) { + floatParams.put(param, (float) value); + } + break; + case 2: + if (value instanceof float[]) { + floatArrayParams.put(param, (float[]) value); + } + } + } + + + public void setIntegerValue(Parameter param, int value) { + if (param.type == 0) { + integerParams.put(param, value); + } + } + + public void setFloatValue(Parameter parameter, float value) { + if (parameter.type == 1) { + floatParams.put(parameter, value); + } + } + + public void setFloatArray(Parameter parameter, float[] array) { + if (parameter.type == 2) { + floatArrayParams.put(parameter, array); + } + } + + public void setFloatArrayEntry(Parameter parameter, int index, float value) { + if (index >= 9) return; + if (parameter.type == 2) { + float[] array = floatArrayParams.get(parameter); + if (array != null) { + array[index] = value; + } else { + array = new float[9]; + array[index] = value; + floatArrayParams.put(parameter, array); + } + } + } + + public static TreeGenParamData deserializeNbt(CompoundNBT compound) { + TreeGenParamData treeGenParamData = new TreeGenParamData(); + if (compound.contains("TreeGenerator")) { + CompoundNBT generatorTag = compound.getCompound("TreeGenerator"); + for (Module module : Module.values()) { + for (Parameter parameter : Parameter.parameters[module.index]) { + switch (parameter.type) { + case 0: + treeGenParamData.integerParams.put(parameter, generatorTag.getInt(parameter.name)); + break; + case 1: + treeGenParamData.floatParams.put(parameter, generatorTag.getFloat(parameter.name)); + break; + case 2: + int[] array = generatorTag.getIntArray(parameter.name); + treeGenParamData.floatArrayParams.put(parameter, BranchDirectionHelper.intArrayToFloatArray(array)); + break; + } + } + } + return treeGenParamData; + } + return null; + } + + + public CompoundNBT writeToNbt(CompoundNBT compound) { + CompoundNBT tag = new CompoundNBT(); + + for (Module module : Module.values()) { + for (Parameter parameter : Parameter.parameters[module.index]) { + switch (parameter.type) { + case 0: + tag.putInt(parameter.name, integerParams.getOrDefault(parameter, 1)); + break; + case 1: + tag.putFloat(parameter.name, floatParams.getOrDefault(parameter, 1.0f)); + break; + case 2: + float[] array = floatArrayParams.getOrDefault(parameter, new float[]{1, 0, 0, 0, 1, 0, 0, 0, 1}); + tag.putIntArray(parameter.name, BranchDirectionHelper.floatArrayToIntArray(array)); + break; + } + } + } + compound.put("TreeGenerator", tag); + return compound; + } + + public int getIntParameter(Parameter parameter) { + if (parameter.type == 0) { + return integerParams.get(parameter); + } + return -1; + } + + public float getFloatParameter(Parameter parameter) { + if (parameter.type == 1) { + return floatParams.get(parameter); + } + return -1; + } + + public float[] getFloatArrayParameter(Parameter parameter) { + if (parameter.type == 2) { + return floatArrayParams.get(parameter); + } + return null; + } + + public float getFloatArrayEntry(Parameter parameter, int index) { + float[] array = getFloatArrayParameter(parameter); + if (array == null || index >= 9) return -1; + else { + return array[index]; + } + } +} + diff --git a/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/TreeParameterDeserializer.java b/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/TreeParameterDeserializer.java deleted file mode 100644 index 5ddc851..0000000 --- a/src/main/java/lilypuree/forest_tree/trees/world/gen/feature/parametric/TreeParameterDeserializer.java +++ /dev/null @@ -1,4 +0,0 @@ -package lilypuree.forest_tree.trees.world.gen.feature.parametric; - -public class TreeParameterDeserializer { -} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index f769f44..3a6f5be 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,2 +1,5 @@ public net.minecraft.inventory.container.Container func_75146_a(Lnet/minecraft/inventory/container/Slot;)Lnet/minecraft/inventory/container/Slot; #addSlot -public net.minecraft.inventory.container.Container func_75135_a(Lnet/minecraft/item/ItemStack;IIZ)Z #mergeItemStack \ No newline at end of file +public net.minecraft.inventory.container.Container func_75135_a(Lnet/minecraft/item/ItemStack;IIZ)Z #mergeItemStack + +public net.minecraft.client.renderer.BlockModelRenderer field_187499_a # blockColors +public net.minecraft.client.renderer.BlockModelRenderer func_228800_a_(Lnet/minecraft/world/ILightReader;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lcom/mojang/blaze3d/vertex/IVertexBuilder;Lcom/mojang/blaze3d/matrix/MatrixStack$Entry;Lnet/minecraft/client/renderer/model/BakedQuad;FFFFIIIII)V # renderQuadSmooth \ No newline at end of file diff --git a/src/main/resources/assets/forest_tree/blockstates/custom_sapling.json b/src/main/resources/assets/forest_tree/blockstates/custom_sapling.json new file mode 100644 index 0000000..adc3d41 --- /dev/null +++ b/src/main/resources/assets/forest_tree/blockstates/custom_sapling.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "block/oak_sapling" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/forest_tree/blockstates/tree_designer.json b/src/main/resources/assets/forest_tree/blockstates/tree_designer.json new file mode 100644 index 0000000..434e3f8 --- /dev/null +++ b/src/main/resources/assets/forest_tree/blockstates/tree_designer.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": {"model": "forest_tree:block/tree_designer"} + } +} \ No newline at end of file diff --git a/src/main/resources/assets/forest_tree/lang/en_us.json b/src/main/resources/assets/forest_tree/lang/en_us.json index 0e0dcd2..c350134 100644 --- a/src/main/resources/assets/forest_tree/lang/en_us.json +++ b/src/main/resources/assets/forest_tree/lang/en_us.json @@ -1,3 +1,86 @@ { + "itemGroup.forest_tree" : "Forest Tree", + "block.forest_tree.tree_designer" : "Tree Designer", + "block.forest_tree.custom_sapling" : "Custom Sapling", + "item.forest_tree.grafting_tool" : "Grafting Tool", + + "forest_tree.treedesignergui.save" : "Save", + "forest_tree.treedesignergui.title" : "Tree Designer", + "forest_tree.treedesignergui.descriptions.angleOffsetPerNode": "At each branch-generating node, this value will be used to determine the direction of the next branch. If more than one branch generates at a node, it will be used multiple times. Units are in degrees.", + "forest_tree.treedesignergui.descriptions.angleOffsetVariance": "description here", + "forest_tree.treedesignergui.descriptions.axillaryAgeOffset": "description here", + "forest_tree.treedesignergui.descriptions.axillaryAgeOffsetVariance": "description here", + "forest_tree.treedesignergui.descriptions.axillaryDeathAgeMax": "description here", + "forest_tree.treedesignergui.descriptions.axillaryDeathAgeMin": "description here", + "forest_tree.treedesignergui.descriptions.axillaryGrowthRate": "description here", + "forest_tree.treedesignergui.descriptions.axillaryGrowthRateVariance": "description here", + "forest_tree.treedesignergui.descriptions.axillaryMarkovMatrix": "description here", + "forest_tree.treedesignergui.descriptions.axillaryNodeInterval": "description here", + "forest_tree.treedesignergui.descriptions.axillaryNodeIntervalVariance": "description here", + "forest_tree.treedesignergui.descriptions.axillaryYawVariance": "description here", + "forest_tree.treedesignergui.descriptions.branchDeathAgeMax": "description here", + "forest_tree.treedesignergui.descriptions.branchDeathAgeMin": "description here", + "forest_tree.treedesignergui.descriptions.branchingMarkovMatrix": "description here", + "forest_tree.treedesignergui.descriptions.maxHeight": "A very long description about what this parameter will do. does //n work? Idk. A very long description about what this parameter will do. does //n work? Idk. A very long description about what this parameter will do. does //n work? Idk. A very long description about what this parameter will do. does //n work? Idk.", + "forest_tree.treedesignergui.descriptions.meristemsPerAxillaryNode": "description here", + "forest_tree.treedesignergui.descriptions.meristemsPerAxillaryNodeVariance": "description here", + "forest_tree.treedesignergui.descriptions.meristemsPerNode": "description here", + "forest_tree.treedesignergui.descriptions.meristemsPerNodeVariance": "description here", + "forest_tree.treedesignergui.descriptions.minimumBranchAge": "description here", + "forest_tree.treedesignergui.descriptions.nodeInterval": "description here", + "forest_tree.treedesignergui.descriptions.nodeIntervalVariance": "description here", + "forest_tree.treedesignergui.descriptions.secondaryPitch135Degree": "description here", + "forest_tree.treedesignergui.descriptions.secondaryPitch45Degree": "description here", + "forest_tree.treedesignergui.descriptions.secondaryPitchHorizontal": "description here", + "forest_tree.treedesignergui.descriptions.secondaryYaw45Degree": "description here", + "forest_tree.treedesignergui.descriptions.secondaryYaw90Degree": "description here", + "forest_tree.treedesignergui.descriptions.secondaryYawParallel": "description here", + "forest_tree.treedesignergui.descriptions.terminalDeathAgeMax": "description here", + "forest_tree.treedesignergui.descriptions.terminalDeathAgeMin": "description here", + "forest_tree.treedesignergui.descriptions.terminalGrowthRate": "description here", + "forest_tree.treedesignergui.descriptions.terminalGrowthRateVariance": "description here", + "forest_tree.treedesignergui.descriptions.terminalMarkovMatrix": "description here", + "forest_tree.treedesignergui.descriptions.terminalRegenRate": "description here", + "forest_tree.treedesignergui.descriptions.terminalYawVariance": "description here", + "forest_tree.treedesignergui.modules.CREATION": "CREATION", + "forest_tree.treedesignergui.modules.DIRECTIONS": "DIRECTIONS", + "forest_tree.treedesignergui.modules.GROWTH": "GROWTH", + "forest_tree.treedesignergui.modules.TERMINATION": "TERMINATION", + "forest_tree.treedesignergui.parameters.angleOffsetPerNode": "Angle offset / node", + "forest_tree.treedesignergui.parameters.angleOffsetVariance": "Angle offset var", + "forest_tree.treedesignergui.parameters.axillaryAgeOffset": "Axillary age offset", + "forest_tree.treedesignergui.parameters.axillaryAgeOffsetVariance": "Axillary age offset var", + "forest_tree.treedesignergui.parameters.axillaryDeathAgeMax": "Max axillary death age", + "forest_tree.treedesignergui.parameters.axillaryDeathAgeMin": "Min axillary death age", + "forest_tree.treedesignergui.parameters.axillaryGrowthRate": "Axillary growth rate", + "forest_tree.treedesignergui.parameters.axillaryGrowthRateVariance": "Axillary Growth rate var", + "forest_tree.treedesignergui.parameters.axillaryMarkovMatrix": "Axillary makov matrix", + "forest_tree.treedesignergui.parameters.axillaryNodeInterval": "Axillary node interval", + "forest_tree.treedesignergui.parameters.axillaryNodeIntervalVariance": "Axillary node interval var", + "forest_tree.treedesignergui.parameters.axillaryYawVariance": "Axillary yaw variance", + "forest_tree.treedesignergui.parameters.branchDeathAgeMax": "Max branch death age", + "forest_tree.treedesignergui.parameters.branchDeathAgeMin": "Min branch death age", + "forest_tree.treedesignergui.parameters.branchingMarkovMatrix": "branchingMarkovMatrix", + "forest_tree.treedesignergui.parameters.maxHeight": "maxHeight", + "forest_tree.treedesignergui.parameters.meristemsPerAxillaryNode": "Meristems / axillary node", + "forest_tree.treedesignergui.parameters.meristemsPerAxillaryNodeVariance": "Meristem / axillary node var", + "forest_tree.treedesignergui.parameters.meristemsPerNode": "meristemsPerNode", + "forest_tree.treedesignergui.parameters.meristemsPerNodeVariance": "meristemsPerNodeVariance", + "forest_tree.treedesignergui.parameters.minimumBranchAge": "minimumBranchAge", + "forest_tree.treedesignergui.parameters.nodeInterval": "nodeInterval", + "forest_tree.treedesignergui.parameters.nodeIntervalVariance": "nodeIntervalVariance", + "forest_tree.treedesignergui.parameters.secondaryPitch135Degree": "secondaryPitch135Degree", + "forest_tree.treedesignergui.parameters.secondaryPitch45Degree": "secondaryPitch45Degree", + "forest_tree.treedesignergui.parameters.secondaryPitchHorizontal": "secondaryPitchHorizontal", + "forest_tree.treedesignergui.parameters.secondaryYaw45Degree": "secondaryYaw45Degree", + "forest_tree.treedesignergui.parameters.secondaryYaw90Degree": "secondaryYaw90Degree", + "forest_tree.treedesignergui.parameters.secondaryYawParallel": "secondaryYawParallel", + "forest_tree.treedesignergui.parameters.terminalDeathAgeMax": "terminalDeathAgeMax", + "forest_tree.treedesignergui.parameters.terminalDeathAgeMin": "terminalDeathAgeMin", + "forest_tree.treedesignergui.parameters.terminalGrowthRate": "terminalGrowthRate", + "forest_tree.treedesignergui.parameters.terminalGrowthRateVariance": "terminalGrowthRateVariance", + "forest_tree.treedesignergui.parameters.terminalMarkovMatrix": "terminalMarkovMatrix", + "forest_tree.treedesignergui.parameters.terminalRegenRate": "terminalRegenRate", + "forest_tree.treedesignergui.parameters.terminalYawVariance": "terminalYawVariance" } \ No newline at end of file diff --git a/src/main/resources/assets/forest_tree/models/block/tree_designer.json b/src/main/resources/assets/forest_tree/models/block/tree_designer.json new file mode 100644 index 0000000..6c37236 --- /dev/null +++ b/src/main/resources/assets/forest_tree/models/block/tree_designer.json @@ -0,0 +1,31 @@ +{ + "credit": "Made with Blockbench", + "parent" : "block/block", + "textures": { + "0": "forest_tree:block/hologram", + "1": "forest_tree:block/hologram_side", + "ray" : "forest_tree:block/hologram_ray", + "particle": "forest_tree:block/hologram" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 4, 16], + "faces": { + "north": {"uv": [0, 0, 16, 4], "texture": "#1"}, + "east": {"uv": [0, 0, 16, 4], "texture": "#1"}, + "south": {"uv": [0, 0, 16, 4], "texture": "#1"}, + "west": {"uv": [0, 0, 16, 4], "texture": "#1"}, + "up": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "down": {"uv": [0, 0, 16, 16], "texture": "#0"} + } + } + ], + "display": { + "firstperson_righthand": { + "rotation": [ 0, 135, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.4, 0.4, 0.4 ] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/forest_tree/models/item/custom_sapling.json b/src/main/resources/assets/forest_tree/models/item/custom_sapling.json new file mode 100644 index 0000000..b2d96ad --- /dev/null +++ b/src/main/resources/assets/forest_tree/models/item/custom_sapling.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "block/oak_sapling" + } +} diff --git a/src/main/resources/assets/forest_tree/models/item/tree_designer.json b/src/main/resources/assets/forest_tree/models/item/tree_designer.json new file mode 100644 index 0000000..5627dc9 --- /dev/null +++ b/src/main/resources/assets/forest_tree/models/item/tree_designer.json @@ -0,0 +1,3 @@ +{ + "parent": "forest_tree:block/tree_designer" +} diff --git a/src/main/resources/assets/forest_tree/textures/block/hologram.png b/src/main/resources/assets/forest_tree/textures/block/hologram.png new file mode 100644 index 0000000..493a74b Binary files /dev/null and b/src/main/resources/assets/forest_tree/textures/block/hologram.png differ diff --git a/src/main/resources/assets/forest_tree/textures/block/hologram_ray.png b/src/main/resources/assets/forest_tree/textures/block/hologram_ray.png new file mode 100644 index 0000000..00a238b Binary files /dev/null and b/src/main/resources/assets/forest_tree/textures/block/hologram_ray.png differ diff --git a/src/main/resources/assets/forest_tree/textures/block/hologram_side.png b/src/main/resources/assets/forest_tree/textures/block/hologram_side.png new file mode 100644 index 0000000..5046e73 Binary files /dev/null and b/src/main/resources/assets/forest_tree/textures/block/hologram_side.png differ diff --git a/src/main/resources/assets/forest_tree/textures/gui/container/tree_designer.png b/src/main/resources/assets/forest_tree/textures/gui/container/tree_designer.png index 38c05c0..c2e9497 100644 Binary files a/src/main/resources/assets/forest_tree/textures/gui/container/tree_designer.png and b/src/main/resources/assets/forest_tree/textures/gui/container/tree_designer.png differ