diff --git a/Common/src/generated/resources/.cache/8f7cd5c924d3264b7777ef1696459761f9a70902 b/Common/src/generated/resources/.cache/8f7cd5c924d3264b7777ef1696459761f9a70902 index c6144611..2f4d7199 100644 --- a/Common/src/generated/resources/.cache/8f7cd5c924d3264b7777ef1696459761f9a70902 +++ b/Common/src/generated/resources/.cache/8f7cd5c924d3264b7777ef1696459761f9a70902 @@ -1,21 +1,25 @@ -// 1.19.2 2022-11-09T19:44:43.409223 Item Models: hexcasting +// 1.19.2 2023-02-17T23:19:00.76285061 Item Models: hexcasting +9af2754cb1e53eeaa85618cf92651b4878cf62b1 assets/hexcasting/models/block/quenched_allay_0.json +de4ff723b4332d4e26bd01f74e0485e28c9a2178 assets/hexcasting/models/block/quenched_allay_1.json +4c29163e07f3a903017e38a9cc102f4b37db20b1 assets/hexcasting/models/block/quenched_allay_2.json +487d34cd8e70b3e468337228b74af5c1b4d14c53 assets/hexcasting/models/block/quenched_allay_3.json f2156b3a7041cf99891b528393db64c6b9ca1a4f assets/hexcasting/models/item/abacus.json -783d8454d6b74f926be0d3e02d87c6505e9d76d0 assets/hexcasting/models/item/acacia_staff.json +f183fcd384db929bf56e397965057218abc32ddb assets/hexcasting/models/item/acacia_staff.json 19730853397b109cfedd0c3bbda83d5de6cd15b9 assets/hexcasting/models/item/akashic_record.json 8c735feff09d46d00ed681311f46f61a50cfdc9b assets/hexcasting/models/item/amethyst_dust.json d1b0892de9d751e7bebc763e6407d5285363c851 assets/hexcasting/models/item/artifact.json 7eb3eb776e70eb616c12ada500b9d1d6a3249a6a assets/hexcasting/models/item/artifact_filled.json 82e3be7bbdad92d2b4c728be54d9d2f2809a0ac2 assets/hexcasting/models/item/battery.json -3dcc41ab5cbf7004f9c959d89be961aff0ce6032 assets/hexcasting/models/item/birch_staff.json -f05937151873b1de302a011851edc62d0554e4db assets/hexcasting/models/item/bosnia_staff.json +71acb8ff7f0457c46683c16da339363f39c7ea8b assets/hexcasting/models/item/birch_staff.json ec7c3a51882a432185fdbb6a449e66165b6a4c4c assets/hexcasting/models/item/charged_amethyst.json +d614c0fd8acb1c18b4211b090d438326d74507f8 assets/hexcasting/models/item/cherry_staff.json c64ed609ece68994ce23dd2809145040bce13579 assets/hexcasting/models/item/conjured.json c64ed609ece68994ce23dd2809145040bce13579 assets/hexcasting/models/item/conjured_block.json c8da4227db3c80e3e2e7f2fb2ae2649656429d68 assets/hexcasting/models/item/creative_unlocker.json -21c0b8d424043a1b0d2748f59d292b129193d9a5 assets/hexcasting/models/item/crimson_staff.json +fd00d0c14663804b78911d7aa73606b88e90ef22 assets/hexcasting/models/item/crimson_staff.json e47acd1d6ef29a3e1941afb1b212bd40b963cb72 assets/hexcasting/models/item/cypher.json 2db55347092ad6bc9e58bc968e88a3b6c5fd77c1 assets/hexcasting/models/item/cypher_filled.json -81eed736b6bae7e427d3c6972ef15a8d967489e5 assets/hexcasting/models/item/dark_oak_staff.json +73ded6154a6e2f6929a05c5625372c9e0498db3d assets/hexcasting/models/item/dark_oak_staff.json 113c51af571a92009f5f687a82e10bc5ce97b010 assets/hexcasting/models/item/dye_colorizer_black.json b5a04716775ba2e1b137abc513025b2f1065e5d1 assets/hexcasting/models/item/dye_colorizer_blue.json 0bb3afbd937b2e07523a581f6e3f389e11078595 assets/hexcasting/models/item/dye_colorizer_brown.json @@ -37,7 +41,7 @@ c9faada6299f388afc2d2798843d2b45159950d1 assets/hexcasting/models/item/edified_d 7f22e012a844cc2c5e30b0fcbdc2e7e4afac1c40 assets/hexcasting/models/item/edified_log.json 6b2c9d4aca0c869d7e18707c22b00c14e1d30f0c assets/hexcasting/models/item/edified_pressure_plate.json 31b4d60ff15a6d6de7aecb6feeba25a366bba2fd assets/hexcasting/models/item/edified_slab.json -66d951804b32cb77bbe6e81d5053ea14c9690b1b assets/hexcasting/models/item/edified_staff.json +aec5d99a7501bdbe7fd7d4ab3640e726682ef0f1 assets/hexcasting/models/item/edified_staff.json 2584421c2e9e1cdf22a703018b54cf449613d7d9 assets/hexcasting/models/item/edified_stairs.json ae58c5b7c304d33cbde60caf44a4c4ee4ec1a633 assets/hexcasting/models/item/edified_trapdoor.json 084183e4351973c8165f6f459c0f0dba2463d957 assets/hexcasting/models/item/edified_wood.json @@ -45,10 +49,12 @@ ae58c5b7c304d33cbde60caf44a4c4ee4ec1a633 assets/hexcasting/models/item/edified_t 947d1539d88f9d6fd0afcdf831f4327356d19baf assets/hexcasting/models/item/focus_filled.json cb2d973af25a2ec07e6094ecc106c896a06918dc assets/hexcasting/models/item/focus_sealed.json 6ec61fea7d8c49cc0c45b64857fd926451b4845f assets/hexcasting/models/item/jeweler_hammer.json -e8ce683966f007b56cc551b3137c77f0a1fe2d9a assets/hexcasting/models/item/jungle_staff.json +0777d2158566f7389f4becd2fb2c77664de90c6a assets/hexcasting/models/item/jungle_staff.json abfc028c974a02780aed3d7a5859352503bbd920 assets/hexcasting/models/item/lens.json a34a6d777ae265c7e49c8bb23c15f04359236544 assets/hexcasting/models/item/lore_fragment.json -9c79526e19bfafb8370718ddcc9126204ed85e3a assets/hexcasting/models/item/oak_staff.json +dbd52dd3d429578cc81b8b3142d25f8d84501273 assets/hexcasting/models/item/mangrove_staff.json +b8fe3a6b792c6014831f047d4c40eaae9f939b1b assets/hexcasting/models/item/mindsplice_staff.json +4b65b6848d43cc27adf7e59ebdffd59281fe3937 assets/hexcasting/models/item/oak_staff.json 38d1dc73c49d185b86c098b13611bf3ec07b255c assets/hexcasting/models/item/old_staff.json 82fa0a2bb17e40c0b3f826e97b2e95445ec24ab8 assets/hexcasting/models/item/patchouli_book.json d69d10e6cb967b98b3294cc86174182c671de671 assets/hexcasting/models/item/phial_large_0.json @@ -82,6 +88,13 @@ d60b723c44183b59cbadfd02a911dab5e89e0e61 assets/hexcasting/models/item/pride_col 6253bab7bd9162f75782c5bc899f46cd941d01ad assets/hexcasting/models/item/pride_colorizer_pansexual.json c67e74e2a323872c3b34b113df99da8b77a501c6 assets/hexcasting/models/item/pride_colorizer_plural.json 7c4191ec2479b0a67e578da49d459deea8294ec4 assets/hexcasting/models/item/pride_colorizer_transgender.json +5038e069909e2dcf8664bcde81b229c8e27191ae assets/hexcasting/models/item/quenched_allay.json +a8859c93236b88f9ed46a4957f5723965ce04e03 assets/hexcasting/models/item/quenched_allay_shard.json +8105007d186fe2c6bea6958dd85d1b2ed3cecb58 assets/hexcasting/models/item/quenched_shard_0.json +aef7d4b759bcc8a1d5b886b8a0170657e447a8d8 assets/hexcasting/models/item/quenched_shard_1.json +4a08374ef00de51381df9659488cb305e7c8674f assets/hexcasting/models/item/quenched_shard_2.json +181aac0f66e5c3937f49da3f5d577f1c8045c635 assets/hexcasting/models/item/quenched_shard_3.json +628df1d43bb959bd7424253d2cf367947e147155 assets/hexcasting/models/item/quenched_staff.json 1ac1d158da25a8f8ec4b8771445d1ec9d42e9519 assets/hexcasting/models/item/scroll.json ae2a8b6eb8a4ef17926e20c6982bc01120ff32b7 assets/hexcasting/models/item/scroll_ancient_large.json 7478e4b91169a3ab9def5af8662db9696eb33a34 assets/hexcasting/models/item/scroll_ancient_medium.json @@ -97,11 +110,17 @@ e6452f95b60240e0067769d7f32a0b9fa7718a1b assets/hexcasting/models/item/slate_wri 986674763b45e0f9381f9f34a708082e5230652a assets/hexcasting/models/item/spellbook.json f962c13ab9e299885387cee35b16006651821e81 assets/hexcasting/models/item/spellbook_filled.json c29e6e7b2168eeeb13b1fc3e93ffc3e0c9bd11ce assets/hexcasting/models/item/spellbook_sealed.json -7f03c6ea7a07cfedc7d580bb9ba5fcdc54cccb86 assets/hexcasting/models/item/spruce_staff.json +bc2dbafadff333484c397675325df15f95e8b9f1 assets/hexcasting/models/item/spruce_staff.json +65bbc32202a58cdae91165e059e53bcfb2c54e10 assets/hexcasting/models/item/staves/quenched_0.json +9d8d276d077fc9ee355d4af5b62d5f63087ed6e1 assets/hexcasting/models/item/staves/quenched_1.json +ff1f37ac81e58185d9ea63d1ef75558e30f2e193 assets/hexcasting/models/item/staves/quenched_2.json +5cb3a83a9e601d4955e0c5456c621c4ac3f3d76e assets/hexcasting/models/item/staves/quenched_3.json d6ebc87cb0fa6f86bee3a4eade7329ebb0cf2d38 assets/hexcasting/models/item/stripped_edified_log.json ea3f18f75776022127f3a108119e3f7a5c211c0f assets/hexcasting/models/item/stripped_edified_wood.json 0a100b64e77394606018320bbc5752a546fe0af4 assets/hexcasting/models/item/sub_sandwich.json +6a7f5af82cf8ec72c3457ef4c1ae11a76717bf88 assets/hexcasting/models/item/thought_knot.json +93b2191ffab47003f661b75a85cd833ec64f0c15 assets/hexcasting/models/item/thought_knot_written.json 5f4831d11d8f45b037a6f48e12d2e794ada7b961 assets/hexcasting/models/item/trinket.json 946970e74b8d3c76c15191f494bc1f3d7e36aa43 assets/hexcasting/models/item/trinket_filled.json c6523de66cbfae3a1e6361c635cc693a0a089bb3 assets/hexcasting/models/item/uuid_colorizer.json -f5b45d5997acc8abe8cc70065a5790b642234fcb assets/hexcasting/models/item/warped_staff.json +30e95dd075eab5379410ce5a7e0cd53dfb606005 assets/hexcasting/models/item/warped_staff.json diff --git a/Common/src/generated/resources/.cache/d2fe5b6fab5fdc7ee7ca336c062752306bdf6128 b/Common/src/generated/resources/.cache/d2fe5b6fab5fdc7ee7ca336c062752306bdf6128 index 21019dee..46daff8b 100644 --- a/Common/src/generated/resources/.cache/d2fe5b6fab5fdc7ee7ca336c062752306bdf6128 +++ b/Common/src/generated/resources/.cache/d2fe5b6fab5fdc7ee7ca336c062752306bdf6128 @@ -1,4 +1,4 @@ -// 1.19.2 2022-11-05T14:30:43.69127 Block States: hexcasting +// 1.19.2 2023-02-17T23:01:49.857526865 Block States: hexcasting 901e38574bdaa40ea4a0f6e773a88a95d9c03e55 assets/hexcasting/blockstates/akashic_bookshelf.json 32a77ef668198002563d68be35a24fa93c8d454a assets/hexcasting/blockstates/akashic_connector.json 85080ce0a0387583a839e4788517d675a1a35e24 assets/hexcasting/blockstates/akashic_record.json @@ -29,6 +29,7 @@ e44322f1178e121b70f45e5242d5b0e9a11c211c assets/hexcasting/blockstates/edified_w 4ffe2f23f6774045d40e3763efa161da84d777c8 assets/hexcasting/blockstates/impetus_look.json 1e45bbe847d2edbec8189249f9afb58acda3fe05 assets/hexcasting/blockstates/impetus_rightclick.json 1d568faf935ff3c67d6a7f074a5d0d3ef6406101 assets/hexcasting/blockstates/impetus_storedplayer.json +c41c3f2f39c9fa8a319a705e2183112df18cb4f8 assets/hexcasting/blockstates/quenched_allay.json 0aca7e2e67793a21ffc794c02fb2b22d02d2058a assets/hexcasting/blockstates/scroll_paper.json e5c88e23be0552d4c06062510e8feeab510472ef assets/hexcasting/blockstates/scroll_paper_lantern.json ef6b44bd2360926cb9dcde5bb3f1380385acea90 assets/hexcasting/blockstates/slate.json @@ -134,6 +135,7 @@ de2a5fd9b621e5086852f2191c360d9274b9b10c assets/hexcasting/models/block/impetus_ 7ac5cb74f321b061c1e93b859540b508c7dcdaa4 assets/hexcasting/models/block/impetus_storedplayer_lit_south.json 46c29660e3fa78aeaa264268b43017f4b0c0d655 assets/hexcasting/models/block/impetus_storedplayer_lit_up.json 4d22557274958179da4671c43c2f387336a701a2 assets/hexcasting/models/block/impetus_storedplayer_lit_west.json +9af2754cb1e53eeaa85618cf92651b4878cf62b1 assets/hexcasting/models/block/quenched_allay.json e1e7ce0bcc08a53b3e6634f7e5b7a6cf488cf45b assets/hexcasting/models/block/redstone_directrix_powered_dim_down.json fb22e529f1ca638b7e952176694ab1912eb4274b assets/hexcasting/models/block/redstone_directrix_powered_dim_east.json a5a53ec6a3cd54592dcb224245a4515a2b3b72ed assets/hexcasting/models/block/redstone_directrix_powered_dim_north.json diff --git a/Common/src/generated/resources/.cache/e5c5eb35b4ba40351ecb7d9f04c3527f2f5779b0 b/Common/src/generated/resources/.cache/e5c5eb35b4ba40351ecb7d9f04c3527f2f5779b0 index 010e48c1..b46c34f8 100644 --- a/Common/src/generated/resources/.cache/e5c5eb35b4ba40351ecb7d9f04c3527f2f5779b0 +++ b/Common/src/generated/resources/.cache/e5c5eb35b4ba40351ecb7d9f04c3527f2f5779b0 @@ -1,7 +1,7 @@ -// 1.19.2 2022-11-09T19:44:43.405259 Advancements +// 1.19.2 2022-11-29T13:33:14.877218824 Advancements b21f0b7f0cda29a7e84693df8139f2fecfeea960 data/hexcasting/advancements/aaa_wasteful_cast.json 9d8b41dd8ddfccdf2cd19433d8d7d3cf934e64db data/hexcasting/advancements/aab_big_cast.json -ef61c93d776c6f212820af20909a4c1d92822baf data/hexcasting/advancements/enlightenment.json +425b42f6da5fd6498053f565dce1f171997dbb8b data/hexcasting/advancements/enlightenment.json 8f97205fa79270eab688aa3019d6fe7dd8c8b0d3 data/hexcasting/advancements/lore.json 2f5ad49936d58c7097ac7f8fbbf3f66f9f90fd2c data/hexcasting/advancements/lore/experiment1.json 9a4eba1c9d7868906e8ea1b4ec287f54a2c379b5 data/hexcasting/advancements/lore/experiment2.json @@ -11,6 +11,6 @@ ef06ae5bd79e2c52291fbfb3c69bc2f74a604477 data/hexcasting/advancements/lore/terab 74fbb1ce0e3acf982325b9e9205f774a67956c3c data/hexcasting/advancements/lore/terabithia3.json 861374b7c144ccdbbd031a3f5042af6718ba42bf data/hexcasting/advancements/lore/terabithia4.json e26db8dfa825b7ac572d59a548b610db7c7bf736 data/hexcasting/advancements/lore/terabithia5.json -2acbfb4efe2a72a1986c8dbe62ad8d93e9613e99 data/hexcasting/advancements/opened_eyes.json +bf319d71d9e706f9131c9484be1bc83ca2b8b6a3 data/hexcasting/advancements/opened_eyes.json d19039a73324eb7532d035d08442f3b68bb13bcb data/hexcasting/advancements/root.json b1b82068d65d6872c258d905d4f78499e8227ccf data/hexcasting/advancements/y_u_no_cast_angy.json diff --git a/Common/src/generated/resources/assets/hexcasting/blockstates/quenched_allay.json b/Common/src/generated/resources/assets/hexcasting/blockstates/quenched_allay.json new file mode 100644 index 00000000..c6bce09c --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/blockstates/quenched_allay.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "hexcasting:block/quenched_allay" + } + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay.json b/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay.json new file mode 100644 index 00000000..6c2a8abe --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "hexcasting:block/quenched_allay_0" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_0.json b/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_0.json new file mode 100644 index 00000000..6c2a8abe --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_0.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "hexcasting:block/quenched_allay_0" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_1.json b/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_1.json new file mode 100644 index 00000000..441d9105 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_1.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "hexcasting:block/quenched_allay_1" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_2.json b/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_2.json new file mode 100644 index 00000000..a561a358 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_2.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "hexcasting:block/quenched_allay_2" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_3.json b/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_3.json new file mode 100644 index 00000000..a6fe2373 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/block/quenched_allay_3.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "hexcasting:block/quenched_allay_3" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/acacia_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/acacia_staff.json index b1db1c8f..cb67faa6 100644 --- a/Common/src/generated/resources/assets/hexcasting/models/item/acacia_staff.json +++ b/Common/src/generated/resources/assets/hexcasting/models/item/acacia_staff.json @@ -8,13 +8,7 @@ } }, { - "model": "hexcasting:item/old_staff", - "predicate": { - "hexcasting:funny_level": 1.0 - } - }, - { - "model": "hexcasting:item/bosnia_staff", + "model": "hexcasting:item/cherry_staff", "predicate": { "hexcasting:funny_level": 2.0 } diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/birch_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/birch_staff.json index f3705923..910956dc 100644 --- a/Common/src/generated/resources/assets/hexcasting/models/item/birch_staff.json +++ b/Common/src/generated/resources/assets/hexcasting/models/item/birch_staff.json @@ -8,13 +8,7 @@ } }, { - "model": "hexcasting:item/old_staff", - "predicate": { - "hexcasting:funny_level": 1.0 - } - }, - { - "model": "hexcasting:item/bosnia_staff", + "model": "hexcasting:item/cherry_staff", "predicate": { "hexcasting:funny_level": 2.0 } diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/bosnia_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/cherry_staff.json similarity index 58% rename from Common/src/generated/resources/assets/hexcasting/models/item/bosnia_staff.json rename to Common/src/generated/resources/assets/hexcasting/models/item/cherry_staff.json index ef91e958..f9007c1a 100644 --- a/Common/src/generated/resources/assets/hexcasting/models/item/bosnia_staff.json +++ b/Common/src/generated/resources/assets/hexcasting/models/item/cherry_staff.json @@ -1,6 +1,6 @@ { "parent": "minecraft:item/handheld_rod", "textures": { - "layer0": "hexcasting:item/staves/bosnia" + "layer0": "hexcasting:item/staves/cherry" } } \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/crimson_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/crimson_staff.json index cc4245dc..35567e93 100644 --- a/Common/src/generated/resources/assets/hexcasting/models/item/crimson_staff.json +++ b/Common/src/generated/resources/assets/hexcasting/models/item/crimson_staff.json @@ -8,13 +8,7 @@ } }, { - "model": "hexcasting:item/old_staff", - "predicate": { - "hexcasting:funny_level": 1.0 - } - }, - { - "model": "hexcasting:item/bosnia_staff", + "model": "hexcasting:item/cherry_staff", "predicate": { "hexcasting:funny_level": 2.0 } diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/dark_oak_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/dark_oak_staff.json index 5d11497a..f0581fea 100644 --- a/Common/src/generated/resources/assets/hexcasting/models/item/dark_oak_staff.json +++ b/Common/src/generated/resources/assets/hexcasting/models/item/dark_oak_staff.json @@ -8,13 +8,7 @@ } }, { - "model": "hexcasting:item/old_staff", - "predicate": { - "hexcasting:funny_level": 1.0 - } - }, - { - "model": "hexcasting:item/bosnia_staff", + "model": "hexcasting:item/cherry_staff", "predicate": { "hexcasting:funny_level": 2.0 } diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/edified_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/edified_staff.json index 02877aa7..655c650e 100644 --- a/Common/src/generated/resources/assets/hexcasting/models/item/edified_staff.json +++ b/Common/src/generated/resources/assets/hexcasting/models/item/edified_staff.json @@ -8,13 +8,7 @@ } }, { - "model": "hexcasting:item/old_staff", - "predicate": { - "hexcasting:funny_level": 1.0 - } - }, - { - "model": "hexcasting:item/bosnia_staff", + "model": "hexcasting:item/cherry_staff", "predicate": { "hexcasting:funny_level": 2.0 } diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/jungle_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/jungle_staff.json index 43a0711d..6c2fdb6f 100644 --- a/Common/src/generated/resources/assets/hexcasting/models/item/jungle_staff.json +++ b/Common/src/generated/resources/assets/hexcasting/models/item/jungle_staff.json @@ -8,13 +8,7 @@ } }, { - "model": "hexcasting:item/old_staff", - "predicate": { - "hexcasting:funny_level": 1.0 - } - }, - { - "model": "hexcasting:item/bosnia_staff", + "model": "hexcasting:item/cherry_staff", "predicate": { "hexcasting:funny_level": 2.0 } diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/mangrove_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/mangrove_staff.json new file mode 100644 index 00000000..126471f8 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/mangrove_staff.json @@ -0,0 +1,20 @@ +{ + "parent": "minecraft:item/handheld_rod", + "overrides": [ + { + "model": "hexcasting:item/mangrove_staff", + "predicate": { + "hexcasting:funny_level": 0.0 + } + }, + { + "model": "hexcasting:item/cherry_staff", + "predicate": { + "hexcasting:funny_level": 2.0 + } + } + ], + "textures": { + "layer0": "hexcasting:item/staves/mangrove" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/mindsplice_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/mindsplice_staff.json new file mode 100644 index 00000000..a99778c8 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/mindsplice_staff.json @@ -0,0 +1,20 @@ +{ + "parent": "minecraft:item/handheld_rod", + "overrides": [ + { + "model": "hexcasting:item/mindsplice_staff", + "predicate": { + "hexcasting:funny_level": 0.0 + } + }, + { + "model": "hexcasting:item/cherry_staff", + "predicate": { + "hexcasting:funny_level": 2.0 + } + } + ], + "textures": { + "layer0": "hexcasting:item/staves/mindsplice" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/oak_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/oak_staff.json index 6897ef64..d4acbdc4 100644 --- a/Common/src/generated/resources/assets/hexcasting/models/item/oak_staff.json +++ b/Common/src/generated/resources/assets/hexcasting/models/item/oak_staff.json @@ -8,13 +8,7 @@ } }, { - "model": "hexcasting:item/old_staff", - "predicate": { - "hexcasting:funny_level": 1.0 - } - }, - { - "model": "hexcasting:item/bosnia_staff", + "model": "hexcasting:item/cherry_staff", "predicate": { "hexcasting:funny_level": 2.0 } diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/quenched_allay.json b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_allay.json new file mode 100644 index 00000000..c6ee6b09 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_allay.json @@ -0,0 +1,28 @@ +{ + "overrides": [ + { + "model": "hexcasting:block/quenched_allay_0", + "predicate": { + "hexcasting:variant": 0.0 + } + }, + { + "model": "hexcasting:block/quenched_allay_1", + "predicate": { + "hexcasting:variant": 1.0 + } + }, + { + "model": "hexcasting:block/quenched_allay_2", + "predicate": { + "hexcasting:variant": 2.0 + } + }, + { + "model": "hexcasting:block/quenched_allay_3", + "predicate": { + "hexcasting:variant": 3.0 + } + } + ] +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/quenched_allay_shard.json b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_allay_shard.json new file mode 100644 index 00000000..495e817b --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_allay_shard.json @@ -0,0 +1,28 @@ +{ + "overrides": [ + { + "model": "hexcasting:item/quenched_shard_0", + "predicate": { + "hexcasting:variant": 0.0 + } + }, + { + "model": "hexcasting:item/quenched_shard_1", + "predicate": { + "hexcasting:variant": 1.0 + } + }, + { + "model": "hexcasting:item/quenched_shard_2", + "predicate": { + "hexcasting:variant": 2.0 + } + }, + { + "model": "hexcasting:item/quenched_shard_3", + "predicate": { + "hexcasting:variant": 3.0 + } + } + ] +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_0.json b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_0.json new file mode 100644 index 00000000..bdd43ddc --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_0.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "hexcasting:item/quenched_shard_0" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_1.json b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_1.json new file mode 100644 index 00000000..4cffa2ef --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_1.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "hexcasting:item/quenched_shard_1" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_2.json b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_2.json new file mode 100644 index 00000000..e24c8daf --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_2.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "hexcasting:item/quenched_shard_2" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_3.json b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_3.json new file mode 100644 index 00000000..208890fe --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_shard_3.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "hexcasting:item/quenched_shard_3" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/quenched_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_staff.json new file mode 100644 index 00000000..110d202d --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/quenched_staff.json @@ -0,0 +1,28 @@ +{ + "overrides": [ + { + "model": "hexcasting:item/staves/quenched_0", + "predicate": { + "hexcasting:variant": 0.0 + } + }, + { + "model": "hexcasting:item/staves/quenched_1", + "predicate": { + "hexcasting:variant": 1.0 + } + }, + { + "model": "hexcasting:item/staves/quenched_2", + "predicate": { + "hexcasting:variant": 2.0 + } + }, + { + "model": "hexcasting:item/staves/quenched_3", + "predicate": { + "hexcasting:variant": 3.0 + } + } + ] +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/spruce_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/spruce_staff.json index 043989b5..0a835d00 100644 --- a/Common/src/generated/resources/assets/hexcasting/models/item/spruce_staff.json +++ b/Common/src/generated/resources/assets/hexcasting/models/item/spruce_staff.json @@ -8,13 +8,7 @@ } }, { - "model": "hexcasting:item/old_staff", - "predicate": { - "hexcasting:funny_level": 1.0 - } - }, - { - "model": "hexcasting:item/bosnia_staff", + "model": "hexcasting:item/cherry_staff", "predicate": { "hexcasting:funny_level": 2.0 } diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_0.json b/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_0.json new file mode 100644 index 00000000..b0632368 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_0.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld_rod", + "textures": { + "layer0": "hexcasting:item/staves/quenched_0" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_1.json b/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_1.json new file mode 100644 index 00000000..9b0bec82 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_1.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld_rod", + "textures": { + "layer0": "hexcasting:item/staves/quenched_1" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_2.json b/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_2.json new file mode 100644 index 00000000..c2f3494d --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_2.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld_rod", + "textures": { + "layer0": "hexcasting:item/staves/quenched_2" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_3.json b/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_3.json new file mode 100644 index 00000000..53be4b0b --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/staves/quenched_3.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld_rod", + "textures": { + "layer0": "hexcasting:item/staves/quenched_3" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/thought_knot.json b/Common/src/generated/resources/assets/hexcasting/models/item/thought_knot.json new file mode 100644 index 00000000..4a991722 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/thought_knot.json @@ -0,0 +1,20 @@ +{ + "parent": "minecraft:item/generated", + "overrides": [ + { + "model": "hexcasting:item/thought_knot", + "predicate": { + "hexcasting:written": 0.0 + } + }, + { + "model": "hexcasting:item/thought_knot_written", + "predicate": { + "hexcasting:written": 1.0 + } + } + ], + "textures": { + "layer0": "hexcasting:item/thought_knot" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/thought_knot_written.json b/Common/src/generated/resources/assets/hexcasting/models/item/thought_knot_written.json new file mode 100644 index 00000000..f5b12c99 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/thought_knot_written.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "hexcasting:item/thought_knot", + "layer1": "hexcasting:item/thought_knot_overlay" + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/warped_staff.json b/Common/src/generated/resources/assets/hexcasting/models/item/warped_staff.json index 256f63dd..7ad6358b 100644 --- a/Common/src/generated/resources/assets/hexcasting/models/item/warped_staff.json +++ b/Common/src/generated/resources/assets/hexcasting/models/item/warped_staff.json @@ -8,13 +8,7 @@ } }, { - "model": "hexcasting:item/old_staff", - "predicate": { - "hexcasting:funny_level": 1.0 - } - }, - { - "model": "hexcasting:item/bosnia_staff", + "model": "hexcasting:item/cherry_staff", "predicate": { "hexcasting:funny_level": 2.0 } diff --git a/Common/src/generated/resources/data/hexcasting/advancements/enlightenment.json b/Common/src/generated/resources/data/hexcasting/advancements/enlightenment.json index a4c76966..4488f207 100644 --- a/Common/src/generated/resources/data/hexcasting/advancements/enlightenment.json +++ b/Common/src/generated/resources/data/hexcasting/advancements/enlightenment.json @@ -7,8 +7,8 @@ "min": 0.8 }, "mojang_i_am_begging_and_crying_please_add_an_entity_health_criterion": { - "max": 2.05, - "min": 0.1 + "max": 1.0, + "min": 2.2250738585072014E-308 } }, "trigger": "hexcasting:overcast" diff --git a/Common/src/generated/resources/data/hexcasting/advancements/opened_eyes.json b/Common/src/generated/resources/data/hexcasting/advancements/opened_eyes.json index 908477ac..fde10466 100644 --- a/Common/src/generated/resources/data/hexcasting/advancements/opened_eyes.json +++ b/Common/src/generated/resources/data/hexcasting/advancements/opened_eyes.json @@ -4,7 +4,7 @@ "health_used": { "conditions": { "mojang_i_am_begging_and_crying_please_add_an_entity_health_criterion": { - "min": 0.1 + "min": 0.0 } }, "trigger": "hexcasting:overcast" diff --git a/Common/src/main/java/at/petrak/hexcasting/README.md b/Common/src/main/java/at/petrak/hexcasting/README.md index 5eb52a0c..a96585f0 100644 --- a/Common/src/main/java/at/petrak/hexcasting/README.md +++ b/Common/src/main/java/at/petrak/hexcasting/README.md @@ -2,8 +2,8 @@ Hello, intrepid Github reader! The "flavor text" words for things in this mod and the internal names are different. (Sorry.) -- A "Hex" is a `Cast`, cast through a [`CastingHarness`](api/spell/casting/CastingHarness.kt) -- A "Pattern" is a [`HexPattern`](api/spell/math/HexPattern.kt) -- An "Action" is an [`Operator`](api/spell/Action.kt) -- An action that pushes a spell is a [`Spell`](api/spell/SpellAction.kt) +- A "Hex" is a `Cast`, cast through a [`CastingHarness`](api/casting/eval/CastingHarness.kt) +- A "Pattern" is a [`HexPattern`](api/casting/math/HexPattern.kt) +- An "Action" is an [`Operator`](api/casting/castables/Action.kt) +- An action that pushes a spell is a [`Spell`](api/casting/castables/SpellAction.kt) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/HexAPI.java b/Common/src/main/java/at/petrak/hexcasting/api/HexAPI.java index e22627dc..0d277a3a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/HexAPI.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/HexAPI.java @@ -1,7 +1,15 @@ package at.petrak.hexcasting.api; +import at.petrak.hexcasting.api.casting.ActionRegistryEntry; +import at.petrak.hexcasting.api.casting.castables.SpecialHandler; import com.google.common.base.Suppliers; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.phys.Vec3; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -22,6 +30,63 @@ public interface HexAPI { } }); + /** + * Return the localization key for the given action. + *

+ * Note we're allowed to have action resource keys on the client, just no actual actions. + *

+ * Special handlers should be calling {@link SpecialHandler#getName()} + */ + default String getActionI18nKey(ResourceKey action) { + return "hexcasting.action.%s".formatted(action.location().toString()); + } + + default String getSpecialHandlerI18nKey(ResourceKey> action) { + return "hexcasting.special.%s".formatted(action.location().toString()); + } + + /** + * Currently introspection/retrospection/consideration are hardcoded, but at least their names won't be + */ + default String getRawHookI18nKey(ResourceLocation name) { + return "hexcasting.rawhook.%s".formatted(name); + } + + default Component getActionI18n(ResourceKey key, boolean isGreat) { + return Component.translatable(getActionI18nKey(key)) + .withStyle(isGreat ? ChatFormatting.GOLD : ChatFormatting.LIGHT_PURPLE); + } + + default Component getSpecialHandlerI18n(ResourceKey> key) { + return Component.translatable(getSpecialHandlerI18nKey(key)) + .withStyle(ChatFormatting.LIGHT_PURPLE); + } + + default Component getRawHookI18n(ResourceLocation name) { + return Component.translatable(getRawHookI18nKey(name)).withStyle(ChatFormatting.LIGHT_PURPLE); + } + + /** + * Register an entity with the given ID to have its velocity as perceived by OpEntityVelocity be different + * than it's "normal" velocity + */ + // Should be OK to use the type directly as the key as they're singleton identity objects + default void registerSpecialVelocityGetter(EntityType key, EntityVelocityGetter getter) { + } + + /** + * If the entity has had a special getter registered with {@link HexAPI#registerSpecialVelocityGetter} then + * return that, otherwise return its normal delta movement + */ + default Vec3 getEntityVelocitySpecial(Entity entity) { + return entity.getDeltaMovement(); + } + + @FunctionalInterface + interface EntityVelocityGetter { + Vec3 getVelocity(T entity); + } + static HexAPI instance() { return INSTANCE.get(); } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/PatternRegistry.java b/Common/src/main/java/at/petrak/hexcasting/api/PatternRegistry.java deleted file mode 100644 index 28a6b33e..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/PatternRegistry.java +++ /dev/null @@ -1,332 +0,0 @@ -package at.petrak.hexcasting.api; - -import at.petrak.hexcasting.api.spell.Action; -import at.petrak.hexcasting.api.spell.math.EulerPathFinder; -import at.petrak.hexcasting.api.spell.math.HexDir; -import at.petrak.hexcasting.api.spell.math.HexPattern; -import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidPattern; -import com.mojang.datafixers.util.Pair; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.saveddata.SavedData; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedDeque; -import java.util.concurrent.ConcurrentMap; -import java.util.stream.Collectors; - -public class PatternRegistry { - private static final ConcurrentMap actionLookup = new ConcurrentHashMap<>(); - private static final ConcurrentMap keyLookup = new ConcurrentHashMap<>(); - private static final ConcurrentLinkedDeque specialHandlers = new ConcurrentLinkedDeque<>(); - - // Map signatures to the "preferred" direction they start in and their operator ID. - private static final ConcurrentMap regularPatternLookup = - new ConcurrentHashMap<>(); - - private static final ConcurrentMap perWorldPatternLookup = - new ConcurrentHashMap<>(); - - public static void mapPattern(HexPattern pattern, ResourceLocation id, - Action action) throws RegisterPatternException { - mapPattern(pattern, id, action, false); - } - - /** - * Associate a given angle signature with a SpellOperator. - */ - public static void mapPattern(HexPattern pattern, ResourceLocation id, Action action, - boolean isPerWorld) throws RegisterPatternException { - if (actionLookup.containsKey(id)) { - throw new RegisterPatternException("The operator with id `%s` was already registered to: %s", id, - actionLookup.get(id)); - } - - actionLookup.put(id, action); - keyLookup.put(action, id); - if (isPerWorld) { - perWorldPatternLookup.put(id, new PerWorldEntry(pattern, id)); - } else { - regularPatternLookup.put(pattern.anglesSignature(), new RegularEntry(pattern.getStartDir(), id)); - } - } - - - /** - * Add a special handler, to take an arbitrary pattern and return whatever kind of operator you like. - */ - public static void addSpecialHandler(SpecialHandlerEntry handler) { - specialHandlers.add(handler); - } - - /** - * Add a special handler, to take an arbitrary pattern and return whatever kind of operator you like. - */ - public static void addSpecialHandler(ResourceLocation id, SpecialHandler handler) { - addSpecialHandler(new SpecialHandlerEntry(id, handler)); - } - - /** - * Internal use only. - */ - public static Action matchPattern(HexPattern pat, ServerLevel overworld) throws MishapInvalidPattern { - return matchPatternAndID(pat, overworld).getFirst(); - } - - /** - * Internal use only. - */ - public static Pair matchPatternAndID(HexPattern pat, - ServerLevel overworld) throws MishapInvalidPattern { - // Pipeline: - // patterns are registered here every time the game boots - // when we try to look - for (var handler : specialHandlers) { - var op = handler.handler.handlePattern(pat); - if (op != null) { - return new Pair<>(op, handler.id); - } - } - - // Is it global? - var sig = pat.anglesSignature(); - if (regularPatternLookup.containsKey(sig)) { - var it = regularPatternLookup.get(sig); - if (!actionLookup.containsKey(it.opId)) { - throw new MishapInvalidPattern(); - } - var op = actionLookup.get(it.opId); - return new Pair<>(op, it.opId); - } - - // Look it up in the world? - var ds = overworld.getDataStorage(); - Save perWorldPatterns = - ds.computeIfAbsent(Save::load, () -> Save.create(overworld.getSeed()), TAG_SAVED_DATA); - perWorldPatterns.fillMissingEntries(overworld.getSeed()); - if (perWorldPatterns.lookup.containsKey(sig)) { - var it = perWorldPatterns.lookup.get(sig); - return new Pair<>(actionLookup.get(it.getFirst()), it.getFirst()); - } - - throw new MishapInvalidPattern(); - } - - /** - * Internal use only. - */ - @Nullable - public static Action lookupPatternByShape(HexPattern pat) { - // Pipeline: - // patterns are registered here every time the game boots - // when we try to look - for (var handler : specialHandlers) { - var op = handler.handler.handlePattern(pat); - if (op != null) { - return op; - } - } - - // Is it global? - var sig = pat.anglesSignature(); - if (regularPatternLookup.containsKey(sig)) { - var it = regularPatternLookup.get(sig); - if (!actionLookup.containsKey(it.opId)) { - return null; - } - return actionLookup.get(it.opId); - } - - // Currently, there's no way to look up the name of a Great Spell, as the client is unaware of the correct mapping. - // TODO: add code to match any pattern in the shape of a Great Spell to its operator. - - // var ds = overworld.getDataStorage(); - // Save perWorldPatterns = - // ds.computeIfAbsent(Save::load, () -> Save.create(overworld.getSeed()), TAG_SAVED_DATA); - // perWorldPatterns.fillMissingEntries(overworld.getSeed()); - // if (perWorldPatterns.lookup.containsKey(sig)) { - // var it = perWorldPatterns.lookup.get(sig); - // return new Pair<>(actionLookup.get(it.getFirst()), it.getFirst()); - // } - - return null; - } - - /** - * Internal use only. - */ - public static Map> getPerWorldPatterns(ServerLevel overworld) { - var ds = overworld.getDataStorage(); - Save perWorldPatterns = - ds.computeIfAbsent(Save::load, () -> Save.create(overworld.getSeed()), TAG_SAVED_DATA); - return perWorldPatterns.lookup; - } - - public static ResourceLocation lookupPattern(Action action) { - return keyLookup.get(action); - } - - /** - * Internal use only. - */ - public static PatternEntry lookupPattern(ResourceLocation opId) { - if (perWorldPatternLookup.containsKey(opId)) { - var it = perWorldPatternLookup.get(opId); - return new PatternEntry(it.prototype, actionLookup.get(it.opId), true); - } - for (var kv : regularPatternLookup.entrySet()) { - var sig = kv.getKey(); - var entry = kv.getValue(); - if (entry.opId.equals(opId)) { - var pattern = HexPattern.fromAngles(sig, entry.preferredStart); - return new PatternEntry(pattern, actionLookup.get(entry.opId), false); - } - } - - throw new IllegalArgumentException("could not find a pattern for " + opId); - } - - /** - * Internal use only. - */ - public static Set getAllPerWorldPatternNames() { - return perWorldPatternLookup.keySet(); - } - - /** - * Special handling of a pattern. Before checking any of the normal angle-signature based patterns, - * a given pattern is run by all of these special handlers patterns. If none of them return non-null, - * then its signature is checked. - *

- * In the base mod, this is used for number patterns and Bookkeeper's Gambit. - */ - @FunctionalInterface - public interface SpecialHandler { - @Nullable Action handlePattern(HexPattern pattern); - } - - public record SpecialHandlerEntry(ResourceLocation id, SpecialHandler handler) { - } - - public static class RegisterPatternException extends Exception { - public RegisterPatternException(String msg, Object... formats) { - super(String.format(msg, formats)); - } - } - - private record RegularEntry(HexDir preferredStart, ResourceLocation opId) { - } - - private record PerWorldEntry(HexPattern prototype, ResourceLocation opId) { - } - - // Fake class we pretend to use internally - public record PatternEntry(HexPattern prototype, Action action, boolean isPerWorld) { - } - - /** - * Maps angle sigs to resource locations and their preferred start dir so we can look them up in the main registry - * Save this on the world in case the random algorithm changes. - */ - public static class Save extends SavedData { - private static final String TAG_OP_ID = "op_id"; - private static final String TAG_START_DIR = "start_dir"; - - // Maps hex signatures to (op ids, canonical start dir) - private Map> lookup; - private boolean missingEntries; - - public Save(Map> lookup, boolean missingEntries) { - this.lookup = lookup; - this.missingEntries = missingEntries; - } - - public Save(Map> lookup) { - this(lookup, missingEntries(lookup)); - } - - private static boolean missingEntries(Map> lookup) { - var allIds = lookup.values().stream().map(Pair::getFirst).collect(Collectors.toSet()); - return perWorldPatternLookup.values().stream().anyMatch(it -> allIds.contains(it.opId)); - } - - private void fillMissingEntries(long seed) { - if (missingEntries) { - var doneAny = false; - - var allIds = lookup.values().stream().map(Pair::getFirst).collect(Collectors.toSet()); - for (var entry : perWorldPatternLookup.values()) { - if (!allIds.contains(entry.opId)) { - scrungle(lookup, entry.prototype, entry.opId, seed); - doneAny = true; - } - } - - if (doneAny) { - setDirty(); - missingEntries = false; - } - } - } - - @Override - public CompoundTag save(CompoundTag tag) { - this.lookup.forEach((sig, rhs) -> { - var entry = new CompoundTag(); - entry.putString(TAG_OP_ID, rhs.getFirst().toString()); - entry.putInt(TAG_START_DIR, rhs.getSecond().ordinal()); - tag.put(sig, entry); - }); - return tag; - } - - private static Save load(CompoundTag tag) { - var map = new HashMap>(); - var allIds = new HashSet(); - for (var sig : tag.getAllKeys()) { - var entry = tag.getCompound(sig); - var opId = ResourceLocation.tryParse(entry.getString(TAG_OP_ID)); - allIds.add(opId); - var startDir = HexDir.values()[entry.getInt(TAG_START_DIR)]; - map.put(sig, new Pair<>(opId, startDir)); - } - var missingEntries = perWorldPatternLookup.values().stream().anyMatch(it -> allIds.contains(it.opId)); - - return new Save(map, missingEntries); - } - - private static void scrungle(Map> lookup, HexPattern prototype, ResourceLocation opId, long seed) { - var scrungled = EulerPathFinder.findAltDrawing(prototype, seed, it -> { - var sig = it.anglesSignature(); - return !lookup.containsKey(sig) && - !regularPatternLookup.containsKey(sig) - && specialHandlers.stream().noneMatch(handler -> handler.handler.handlePattern(it) != null); - }); - lookup.put(scrungled.anglesSignature(), new Pair<>(opId, scrungled.getStartDir())); - } - - public static Save create(long seed) { - var map = new HashMap>(); - PatternRegistry.perWorldPatternLookup.values().forEach(it -> scrungle(map, it.prototype, it.opId, seed)); - var save = new Save(map); - save.setDirty(); - return save; - } - } - - public static final String TAG_SAVED_DATA = "hex.per-world-patterns"; - - public static String getPatternCountInfo() { - return String.format( - "Loaded %d regular patterns, " + - "%d per-world patterns, and " + - "%d special handlers.", regularPatternLookup.size(), perWorldPatternLookup.size(), - specialHandlers.size()); - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADHexHolder.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADHexHolder.java index d0da5b78..3d945942 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADHexHolder.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADHexHolder.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.api.addldata; -import at.petrak.hexcasting.api.spell.iota.Iota; +import at.petrak.hexcasting.api.casting.iota.Iota; import net.minecraft.server.level.ServerLevel; import org.jetbrains.annotations.Nullable; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADIotaHolder.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADIotaHolder.java index 812f4574..4fc1e2c5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADIotaHolder.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADIotaHolder.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.api.addldata; -import at.petrak.hexcasting.api.spell.iota.Iota; +import at.petrak.hexcasting.api.casting.iota.Iota; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADMediaHolder.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADMediaHolder.java index 403a0227..9ec11ca8 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADMediaHolder.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADMediaHolder.java @@ -42,7 +42,7 @@ public interface ADMediaHolder { /** * The priority for this media holder to be selected when casting a hex. Higher priorities are taken first. - * + *

* By default, * * Charged Amethyst has priority 1000 * * Amethyst Shards have priority 2000 @@ -58,9 +58,9 @@ public interface ADMediaHolder { /** * Withdraws media from the holder. Returns the amount of media extracted, which may be less or more than the cost. - * + *

* Even if {@link ADMediaHolder#canProvide} is false, you can still withdraw media this way. - * + *

* Withdrawing a negative amount will act as though you attempted to withdraw as much media as the holder contains. */ default int withdrawMedia(int cost, boolean simulate) { @@ -77,10 +77,11 @@ public interface ADMediaHolder { /** * Inserts media into the holder. Returns the amount of media inserted, which may be less than the requested amount. - * + *

* Even if {@link ADMediaHolder#canRecharge} is false, you can still insert media this way. - * - * Inserting a negative amount will act as though you attempted to insert exactly as much media as the holder was missing. + *

+ * Inserting a negative amount will act as though you attempted to insert exactly as much media as the holder was + * missing. */ default int insertMedia(int amount, boolean simulate) { var mediaHere = getMedia(); @@ -101,6 +102,7 @@ public interface ADMediaHolder { return inserting; } + int QUENCHED_ALLAY_PRIORITY = 900; int CHARGED_AMETHYST_PRIORITY = 1000; int AMETHYST_SHARD_PRIORITY = 2000; int AMETHYST_DUST_PRIORITY = 3000; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ItemDelegatingEntityIotaHolder.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ItemDelegatingEntityIotaHolder.java index d123f0de..390ce0dc 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ItemDelegatingEntityIotaHolder.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ItemDelegatingEntityIotaHolder.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.api.addldata; -import at.petrak.hexcasting.api.spell.iota.Iota; +import at.petrak.hexcasting.api.casting.iota.Iota; import at.petrak.hexcasting.common.entities.EntityWallScroll; import at.petrak.hexcasting.xplat.IXplatAbstractions; import net.minecraft.nbt.CompoundTag; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/advancements/OvercastTrigger.java b/Common/src/main/java/at/petrak/hexcasting/api/advancements/OvercastTrigger.java index 7b5b8d74..ae972d1c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/advancements/OvercastTrigger.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/advancements/OvercastTrigger.java @@ -15,7 +15,8 @@ public class OvercastTrigger extends SimpleCriterionTrigger.getPlayer(idx: Int, argc: Int = 0): ServerPlayer { throw MishapInvalidIota.ofType(x, if (argc == 0) idx else argc - (idx + 1), "entity.player") } -fun List.getVillager(idx: Int, argc: Int = 0): Villager { +fun List.getMob(idx: Int, argc: Int = 0): Mob { val x = this.getOrElse(idx) { throw MishapNotEnoughArgs(idx + 1, this.size) } if (x is EntityIota) { val e = x.entity - if (e is Villager) + if (e is Mob) return e } - throw MishapInvalidIota.ofType(x, if (argc == 0) idx else argc - (idx + 1), "entity.villager") + throw MishapInvalidIota.ofType(x, if (argc == 0) idx else argc - (idx + 1), "entity.mob") } fun List.getLivingEntityButNotArmorStand(idx: Int, argc: Int = 0): LivingEntity { @@ -216,7 +217,7 @@ fun List.getPositiveIntUnderInclusive(idx: Int, max: Int, argc: Int = 0): if (x is DoubleIota) { val double = x.double val rounded = double.roundToInt() - if (abs(double - rounded) <= DoubleIota.TOLERANCE && rounded in 0 .. max) { + if (abs(double - rounded) <= DoubleIota.TOLERANCE && rounded in 0..max) { return rounded } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/ParticleSpray.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/ParticleSpray.kt similarity index 81% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/ParticleSpray.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/ParticleSpray.kt index 617ee5c0..9ffcab4a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/ParticleSpray.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/ParticleSpray.kt @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell +package at.petrak.hexcasting.api.casting import at.petrak.hexcasting.api.misc.FrozenColorizer import at.petrak.hexcasting.common.network.MsgCastParticleAck @@ -6,6 +6,10 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions import net.minecraft.server.level.ServerLevel import net.minecraft.world.phys.Vec3 +/** + * @param fuzziness the radius of the sphere the particle might happen in (pos) + * @param spread the max angle in radians the particle can move in, in relation to vel + */ data class ParticleSpray(val pos: Vec3, val vel: Vec3, val fuzziness: Double, val spread: Double, val count: Int = 20) { companion object { @JvmStatic diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/PatternShapeMatch.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/PatternShapeMatch.java new file mode 100644 index 00000000..b72d3498 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/PatternShapeMatch.java @@ -0,0 +1,57 @@ +package at.petrak.hexcasting.api.casting; + +import at.petrak.hexcasting.api.casting.castables.SpecialHandler; +import net.minecraft.resources.ResourceKey; + +/** + * Possible things we find when trying to match a pattern's shape. + */ +public abstract sealed class PatternShapeMatch { + /** + * I've never met that pattern in my life + */ + public static final class Nothing extends PatternShapeMatch { + } + + /** + * The shape exactly matches a pattern that isn't altered per world + */ + public static final class Normal extends PatternShapeMatch { + public final ResourceKey key; + + public Normal(ResourceKey key) { + this.key = key; + } + } + + /** + * The pattern is the right shape to be one of the per-world patterns. + *

+ * On the server, {@link PerWorld#certain} means whether this is an exact match, or if it's just the + * right shape. (In other words it should only actually be casted if it is true.) + *

+ * On the client, it is always false. + */ + public static final class PerWorld extends PatternShapeMatch { + public final ResourceKey key; + public final boolean certain; + + public PerWorld(ResourceKey key, boolean certain) { + this.key = key; + this.certain = certain; + } + } + + /** + * The shape matches a special handler + */ + public static final class Special extends PatternShapeMatch { + public final ResourceKey> key; + public final SpecialHandler handler; + + public Special(ResourceKey> key, SpecialHandler handler) { + this.key = key; + this.handler = handler; + } + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/RenderedSpell.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/RenderedSpell.kt new file mode 100644 index 00000000..1240d3b7 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/RenderedSpell.kt @@ -0,0 +1,7 @@ +package at.petrak.hexcasting.api.casting + +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment + +interface RenderedSpell { + fun cast(ctx: CastingEnvironment) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/SpellList.kt similarity index 96% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/SpellList.kt index c1472008..2e76c18c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/SpellList.kt @@ -1,6 +1,6 @@ -package at.petrak.hexcasting.api.spell +package at.petrak.hexcasting.api.casting -import at.petrak.hexcasting.api.spell.iota.Iota +import at.petrak.hexcasting.api.casting.iota.Iota /** * Restricted interface for functional lists. diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/castables/Action.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/castables/Action.kt new file mode 100644 index 00000000..862288db --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/castables/Action.kt @@ -0,0 +1,59 @@ +package at.petrak.hexcasting.api.casting.castables + +import at.petrak.hexcasting.api.casting.OperationResult +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation +import at.petrak.hexcasting.api.casting.iota.Iota +import net.minecraft.world.phys.Vec3 +import java.text.DecimalFormat + +/** + * Manipulates the stack in some way, usually by popping some number of values off the stack + * and pushing one new value. + * For a more "traditional" pop arguments, push return experience, see [ConstMediaAction]. + * + * Instances of this can exist on the client, but they should NEVER be used there. They only + * exist on the client because Minecraft's registry system demands they do; any information + * the client needs about them is stored elsewhere. (For example, their canonical stroke order + * is stored in [ActionRegistryEntry], and their localization key is gotten from the resource key + * via [at.petrak.hexcasting.api.HexAPI.getActionI18nKey].) + */ +interface Action { + /** + * Operate on the stack. Return the new stack and any side effects of the cast. + * + * Although this is passed a [MutableList], this is only for the convenience of implementors. + * It is a clone of the stack and modifying it does nothing. You must return the new stack + * with the [OperationResult]. + * + * A particle effect at the cast site and various messages and advancements are done automagically. + */ + fun operate( + continuation: SpellContinuation, + stack: MutableList, + ravenmind: Iota?, + ctx: CastingEnvironment + ): OperationResult + + companion object { + // I see why vzakii did this: you can't raycast out to infinity! + const val MAX_DISTANCE: Double = 32.0 + const val MAX_DISTANCE_FROM_SENTINEL: Double = 16.0 + + @JvmStatic + fun raycastEnd(origin: Vec3, look: Vec3): Vec3 = + origin.add(look.normalize().scale(MAX_DISTANCE)) + + @JvmStatic + fun makeConstantOp(x: Iota): Action = object : ConstMediaAction { + override val argc: Int + get() = 0 + + override fun execute(args: List, ctx: CastingEnvironment): List = + listOf(x) + } + + public val DOUBLE_FORMATTER = DecimalFormat("####.####") + } +} + diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/ConstMediaAction.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/castables/ConstMediaAction.kt similarity index 59% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/ConstMediaAction.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/castables/ConstMediaAction.kt index 1f721bc1..587f0b64 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/ConstMediaAction.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/castables/ConstMediaAction.kt @@ -1,10 +1,11 @@ -package at.petrak.hexcasting.api.spell +package at.petrak.hexcasting.api.casting.castables -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation -import at.petrak.hexcasting.api.spell.casting.sideeffects.OperatorSideEffect -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs +import at.petrak.hexcasting.api.casting.OperationResult +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation +import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs /** * A SimpleOperator that always costs the same amount of media. @@ -14,13 +15,13 @@ interface ConstMediaAction : Action { val mediaCost: Int get() = 0 - fun execute(args: List, ctx: CastingContext): List + fun execute(args: List, ctx: CastingEnvironment): List override fun operate( continuation: SpellContinuation, stack: MutableList, ravenmind: Iota?, - ctx: CastingContext + ctx: CastingEnvironment ): OperationResult { if (this.argc > stack.size) throw MishapNotEnoughArgs(this.argc, stack.size) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/castables/SpecialHandler.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/castables/SpecialHandler.java new file mode 100644 index 00000000..512c8254 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/castables/SpecialHandler.java @@ -0,0 +1,40 @@ +package at.petrak.hexcasting.api.casting.castables; + +import at.petrak.hexcasting.api.casting.math.HexPattern; +import net.minecraft.network.chat.Component; +import org.jetbrains.annotations.Nullable; + +/** + * Special handling of a pattern. Before checking any of the normal angle-signature based patterns, + * a given pattern is run by all of these special handlers patterns. If none of them return non-null, + * then its signature is checked. + *

+ * In the base mod, this is used for number patterns and Bookkeeper's Gambit. + *

+ * There's a separation between the special handlers and their factories so we never have to use + * {@link Action} instances on the client. We can have SpecialHandlers on the client though because they're just + * wrappers. + */ +public interface SpecialHandler { + /** + * Convert this to an action, for modification of the stack and state. + *

+ * This is called on the SERVER-SIDE ONLY. + */ + Action act(); + + /** + * Get the name of this handler. + */ + Component getName(); + + /** + * Given a pattern, possibly make up the special handler from it. + *

+ * This is what goes in the registry! Think of it like BlockEntityType vs BlockEntity. + */ + @FunctionalInterface + public interface Factory { + @Nullable T tryMatch(HexPattern pattern); + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellAction.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/castables/SpellAction.kt similarity index 52% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/SpellAction.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/castables/SpellAction.kt index 856c2b09..41621be0 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellAction.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/castables/SpellAction.kt @@ -1,28 +1,31 @@ -package at.petrak.hexcasting.api.spell +package at.petrak.hexcasting.api.casting.castables -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation -import at.petrak.hexcasting.api.spell.casting.sideeffects.OperatorSideEffect -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs +import at.petrak.hexcasting.api.casting.OperationResult +import at.petrak.hexcasting.api.casting.ParticleSpray +import at.petrak.hexcasting.api.casting.RenderedSpell +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect +import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs interface SpellAction : Action { val argc: Int - fun hasCastingSound(ctx: CastingContext): Boolean = true + fun hasCastingSound(ctx: CastingEnvironment): Boolean = true - fun awardsCastingStat(ctx: CastingContext): Boolean = true + fun awardsCastingStat(ctx: CastingEnvironment): Boolean = true fun execute( args: List, - ctx: CastingContext + ctx: CastingEnvironment ): Triple>? override fun operate( continuation: SpellContinuation, stack: MutableList, ravenmind: Iota?, - ctx: CastingContext + ctx: CastingEnvironment ): OperationResult { if (this.argc > stack.size) throw MishapNotEnoughArgs(this.argc, stack.size) @@ -36,15 +39,13 @@ interface SpellAction : Action { if (media > 0) sideEffects.add(OperatorSideEffect.ConsumeMedia(media)) - // Don't have an effect if the caster isn't enlightened, even if processing other side effects - if (!isGreat || ctx.isCasterEnlightened) - sideEffects.add( - OperatorSideEffect.AttemptSpell( - spell, - this.hasCastingSound(ctx), - this.awardsCastingStat(ctx) - ) + sideEffects.add( + OperatorSideEffect.AttemptSpell( + spell, + this.hasCastingSound(ctx), + this.awardsCastingStat(ctx) ) + ) for (spray in particles) sideEffects.add(OperatorSideEffect.Particles(spray)) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastResult.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastResult.kt new file mode 100644 index 00000000..4254f068 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastResult.kt @@ -0,0 +1,20 @@ +package at.petrak.hexcasting.api.casting.eval + +import at.petrak.hexcasting.api.casting.eval.sideeffects.EvalSound +import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect +import at.petrak.hexcasting.api.casting.eval.vm.FunctionalData +import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation + +/** + * The result of doing something to a cast harness. + * + * Contains the next thing to execute after this is finished, the modified state of the stack, + * and side effects, as well as display information for the client. + */ +data class CastResult( + val continuation: SpellContinuation, + val newData: FunctionalData?, + val sideEffects: List, + val resolutionType: ResolvedPatternType, + val sound: EvalSound, +) \ No newline at end of file diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingContext.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingEnvironment.kt similarity index 92% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingContext.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingEnvironment.kt index 0ae90378..4fcc0c72 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingContext.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingEnvironment.kt @@ -1,12 +1,12 @@ -package at.petrak.hexcasting.api.spell.casting +package at.petrak.hexcasting.api.casting.eval import at.petrak.hexcasting.api.HexAPI.modLoc +import at.petrak.hexcasting.api.casting.castables.Action +import at.petrak.hexcasting.api.casting.mishaps.MishapEntityTooFarAway +import at.petrak.hexcasting.api.casting.mishaps.MishapEvalTooDeep +import at.petrak.hexcasting.api.casting.mishaps.MishapLocationTooFarAway import at.petrak.hexcasting.api.misc.DiscoveryHandlers import at.petrak.hexcasting.api.mod.HexConfig -import at.petrak.hexcasting.api.spell.Action -import at.petrak.hexcasting.api.spell.mishaps.MishapEntityTooFarAway -import at.petrak.hexcasting.api.spell.mishaps.MishapEvalTooDeep -import at.petrak.hexcasting.api.spell.mishaps.MishapLocationTooFarAway import at.petrak.hexcasting.api.utils.otherHand import at.petrak.hexcasting.common.items.magic.ItemCreativeUnlocker import at.petrak.hexcasting.xplat.IXplatAbstractions @@ -25,7 +25,7 @@ import kotlin.math.min /** * Transient info about the moment the spell started being cast. */ -data class CastingContext( +data class CastingEnvironment( val caster: ServerPlayer, val castingHand: InteractionHand, val source: CastSource, @@ -39,7 +39,7 @@ data class CastingContext( ) constructor(caster: ServerPlayer, castingHand: InteractionHand, spellCircleContext: SpellCircleContext) : - this(caster, castingHand, CastSource.SPELL_CIRCLE, spellCircleContext) + this(caster, castingHand, CastSource.SPELL_CIRCLE, spellCircleContext) private var depth: Int = 0 @@ -49,6 +49,8 @@ data class CastingContext( private val entitiesGivenMotion = mutableSetOf() + // TODO: what the hell does this function even do. why are we using it. why do we continually put a predicate + // into here and then do the *same* predicate *again* inline fun getHeldItemToOperateOn(acceptItemIf: (ItemStack) -> Boolean): Pair { val handItem = caster.getItemInHand(otherHand) if (!acceptItemIf(handItem)) { @@ -136,8 +138,8 @@ data class CastingContext( fun canEditBlockAt(pos: BlockPos): Boolean { return this.isVecInRange(Vec3.atCenterOf(pos)) - && this.caster.gameMode.gameModeForPlayer != GameType.ADVENTURE - && this.world.mayInteract(this.caster, pos) + && this.caster.gameMode.gameModeForPlayer != GameType.ADVENTURE + && this.world.mayInteract(this.caster, pos) } /** diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingHarness.kt similarity index 79% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingHarness.kt index b05fac10..a238f9ca 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingHarness.kt @@ -1,48 +1,53 @@ -package at.petrak.hexcasting.api.spell.casting +package at.petrak.hexcasting.api.casting.eval -import at.petrak.hexcasting.api.PatternRegistry +import at.petrak.hexcasting.api.HexAPI import at.petrak.hexcasting.api.advancements.HexAdvancementTriggers import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus +import at.petrak.hexcasting.api.casting.ParticleSpray +import at.petrak.hexcasting.api.casting.PatternShapeMatch +import at.petrak.hexcasting.api.casting.PatternShapeMatch.* +import at.petrak.hexcasting.api.casting.SpellList +import at.petrak.hexcasting.api.casting.castables.Action +import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect +import at.petrak.hexcasting.api.casting.eval.vm.FrameEvaluate +import at.petrak.hexcasting.api.casting.eval.vm.FunctionalData +import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.iota.ListIota +import at.petrak.hexcasting.api.casting.iota.PatternIota +import at.petrak.hexcasting.api.casting.iota.ContinuationIota +import at.petrak.hexcasting.api.casting.math.HexDir +import at.petrak.hexcasting.api.casting.math.HexPattern +import at.petrak.hexcasting.api.casting.mishaps.* import at.petrak.hexcasting.api.misc.DiscoveryHandlers import at.petrak.hexcasting.api.misc.FrozenColorizer import at.petrak.hexcasting.api.misc.HexDamageSources import at.petrak.hexcasting.api.mod.HexConfig -import at.petrak.hexcasting.api.mod.HexItemTags import at.petrak.hexcasting.api.mod.HexStatistics -import at.petrak.hexcasting.api.spell.Action -import at.petrak.hexcasting.api.spell.ParticleSpray -import at.petrak.hexcasting.api.spell.SpellList -import at.petrak.hexcasting.api.spell.casting.eval.ContinuationFrame -import at.petrak.hexcasting.api.spell.casting.eval.FrameEvaluate -import at.petrak.hexcasting.api.spell.casting.eval.FunctionalData -import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation -import at.petrak.hexcasting.api.spell.casting.sideeffects.EvalSound -import at.petrak.hexcasting.api.spell.casting.sideeffects.OperatorSideEffect -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.iota.ListIota -import at.petrak.hexcasting.api.spell.iota.PatternIota -import at.petrak.hexcasting.api.spell.iota.ContinuationIota -import at.petrak.hexcasting.api.spell.math.HexDir -import at.petrak.hexcasting.api.spell.math.HexPattern -import at.petrak.hexcasting.api.spell.mishaps.* +import at.petrak.hexcasting.api.mod.HexTags import at.petrak.hexcasting.api.utils.* +import at.petrak.hexcasting.common.casting.PatternRegistryManifest import at.petrak.hexcasting.common.lib.hex.HexEvalSounds import at.petrak.hexcasting.common.lib.hex.HexIotaTypes import at.petrak.hexcasting.xplat.IXplatAbstractions -import net.minecraft.ChatFormatting +import com.mojang.datafixers.util.Either import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.Tag import net.minecraft.network.chat.Component -import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerLevel import net.minecraft.sounds.SoundSource +import net.minecraft.util.Mth import net.minecraft.world.level.gameevent.GameEvent import net.minecraft.world.phys.Vec3 +import kotlin.math.max import kotlin.math.min /** * Keeps track of a player casting a spell on the server. - * It's stored as NBT on the wand. + * It's stored as NBT on the player. + * + * TODO oh god this entire class needs a gigantic refactor. why are there like 6 different entrypoints for casting + * a pattern. oh god. */ class CastingHarness private constructor( var stack: MutableList, @@ -50,13 +55,13 @@ class CastingHarness private constructor( var parenCount: Int, var parenthesized: List, var escapeNext: Boolean, - val ctx: CastingContext, + val ctx: CastingEnvironment, val prepackagedColorizer: FrozenColorizer? // for trinkets with colorizers ) { @JvmOverloads constructor( - ctx: CastingContext, + ctx: CastingEnvironment, prepackagedColorizer: FrozenColorizer? = null ) : this(mutableListOf(), null, 0, mutableListOf(), false, ctx, prepackagedColorizer) @@ -65,7 +70,7 @@ class CastingHarness private constructor( */ fun executeIota(iota: Iota, world: ServerLevel): ControllerInfo = executeIotas(listOf(iota), world) - private fun displayPattern(escapeNext: Boolean, parenCount: Int, iotaRepresentation: Component) { + private fun displayPatternDebug(escapeNext: Boolean, parenCount: Int, iotaRepresentation: Component) { if (this.ctx.debugPatterns) { val display = " ".repeat(parenCount).asTextComponent if (escapeNext) @@ -76,24 +81,6 @@ class CastingHarness private constructor( } } - private fun getOperatorForPattern(iota: Iota, world: ServerLevel): Action? { - if (iota is PatternIota) - return PatternRegistry.matchPattern(iota.pattern, world) - return null - } - - private fun getPatternForFrame(frame: ContinuationFrame): HexPattern? { - if (frame !is FrameEvaluate) return null - - return (frame.list.car as? PatternIota)?.pattern - } - - private fun getOperatorForFrame(frame: ContinuationFrame, world: ServerLevel): Action? { - if (frame !is FrameEvaluate) return null - - return getOperatorForPattern(frame.list.car, world) - } - /** * Given a list of iotas, execute them in sequence. */ @@ -108,24 +95,9 @@ class CastingHarness private constructor( // Take the top of the continuation stack... val next = continuation.frame // ...and execute it. - val result = try { - next.evaluate(continuation.next, world, this) - } catch (mishap: Mishap) { - val pattern = getPatternForFrame(next) - val operator = getOperatorForFrame(next, world) - CastResult( - continuation, - null, - mishap.resolutionType(ctx), - listOf( - OperatorSideEffect.DoMishap( - mishap, - Mishap.Context(pattern ?: HexPattern(HexDir.WEST), operator) - ) - ), - HexEvalSounds.MISHAP, - ) - } + // TODO there used to be error checking code here; I'm pretty sure any and all mishaps should already + // get caught and folded into CastResult by evaluate. + val result = next.evaluate(continuation.next, world, this) // Then write all pertinent data back to the harness for the next iteration. if (result.newData != null) { this.applyFunctionalData(result.newData) @@ -167,11 +139,35 @@ class CastingHarness private constructor( ) } + /** + * this DOES NOT THROW THINGS + */ + @Throws() fun getUpdate(iota: Iota, world: ServerLevel, continuation: SpellContinuation): CastResult { try { // TODO we can have a special intro/retro sound - this.handleParentheses(iota)?.let { (data, resolutionType) -> - return@getUpdate CastResult(continuation, data, resolutionType, listOf(), HexEvalSounds.OPERATOR) + // ALSO TODO need to add reader macro-style things + try { + this.handleParentheses(iota)?.let { (data, resolutionType) -> + return@getUpdate CastResult(continuation, data, listOf(), resolutionType, HexEvalSounds.OPERATOR) + } + } catch (e: MishapTooManyCloseParens) { + // This is ridiculous and needs to be fixed + return CastResult( + continuation, + null, + listOf( + OperatorSideEffect.DoMishap( + e, + Mishap.Context( + (iota as? PatternIota)?.pattern ?: HexPattern(HexDir.WEST), + HexAPI.instance().getRawHookI18n(HexAPI.modLoc("close_paren")) + ) + ) + ), + ResolvedPatternType.ERRORED, + HexEvalSounds.MISHAP + ) } if (iota is PatternIota) { @@ -181,56 +177,40 @@ class CastingHarness private constructor( return CastResult( iota.continuation!!, null, - ResolvedPatternType.EVALUATED, listOf(), + ResolvedPatternType.EVALUATED, HexEvalSounds.HERMES ) } else { return CastResult( continuation, null, - ResolvedPatternType.INVALID, // Should never matter listOf( OperatorSideEffect.DoMishap( MishapUnescapedValue(iota), Mishap.Context(HexPattern(HexDir.WEST), null) ) - ), + ), // Should never matter + ResolvedPatternType.INVALID, HexEvalSounds.MISHAP ) } - } catch (mishap: Mishap) { - return CastResult( - continuation, - null, - mishap.resolutionType(ctx), - listOf( - OperatorSideEffect.DoMishap( - mishap, - Mishap.Context( - (iota as? PatternIota)?.pattern ?: HexPattern(HexDir.WEST), - getOperatorForPattern(iota, world) - ) - ) - ), - HexEvalSounds.MISHAP - ) } catch (exception: Exception) { // This means something very bad has happened exception.printStackTrace() return CastResult( continuation, null, - ResolvedPatternType.ERRORED, listOf( OperatorSideEffect.DoMishap( MishapError(exception), Mishap.Context( (iota as? PatternIota)?.pattern ?: HexPattern(HexDir.WEST), - getOperatorForPattern(iota, world) + null ) ) ), + ResolvedPatternType.ERRORED, HexEvalSounds.MISHAP ) } @@ -240,33 +220,48 @@ class CastingHarness private constructor( * When the server gets a packet from the client with a new pattern, * handle it functionally. */ - fun updateWithPattern(newPat: HexPattern, world: ServerLevel, continuation: SpellContinuation): CastResult { - var actionIdPair: Pair? = null + private fun updateWithPattern(newPat: HexPattern, world: ServerLevel, continuation: SpellContinuation): CastResult { + var castedName: Component? = null try { - // Don't catch this one - val mojangPair = PatternRegistry.matchPatternAndID(newPat, world) - actionIdPair = mojangPair.first to mojangPair.second + val lookup = PatternRegistryManifest.matchPattern(newPat, world, false) + val lookupResult: Either> = if (lookup is Normal || lookup is PerWorld) { + val key = when (lookup) { + is Normal -> lookup.key + is PerWorld -> lookup.key + else -> throw IllegalStateException() + } - if (this.ctx.spellCircle == null && !HexConfig.server().isActionAllowed(actionIdPair.second)) { - throw MishapDisallowedSpell() - } else if (this.ctx.spellCircle != null - && !HexConfig.server().isActionAllowedInCircles(actionIdPair.second) - ) { - throw MishapDisallowedSpell("disallowed_circle") + val reqsEnlightenment = isOfTag(IXplatAbstractions.INSTANCE.actionRegistry, key, HexTags.Actions.REQUIRES_ENLIGHTENMENT) + val canEnlighten = isOfTag(IXplatAbstractions.INSTANCE.actionRegistry, key, HexTags.Actions.CAN_START_ENLIGHTEN) + + castedName = HexAPI.instance().getActionI18n(key, reqsEnlightenment) + + if (!ctx.isCasterEnlightened && reqsEnlightenment) { + Either.right(listOf(OperatorSideEffect.RequiredEnlightenment(canEnlighten))) + } else { + val regiEntry = IXplatAbstractions.INSTANCE.actionRegistry.get(key)!! + Either.left(regiEntry.action) + } + } else if (lookup is Special) { + castedName = lookup.handler.name + Either.left(lookup.handler.act()) + } else if (lookup is PatternShapeMatch.Nothing) { + throw MishapInvalidPattern() + } else { + throw IllegalStateException() } - - val pattern = actionIdPair.first - - val unenlightened = pattern.isGreat && !ctx.isCasterEnlightened + // TODO: the config denylist should be handled per VM type. + // I just removed it for now, should re-add it... val sideEffects = mutableListOf() var stack2: List? = null var cont2 = continuation var ravenmind2: Iota? = null - if (!unenlightened || pattern.alwaysProcessGreatSpell) { - displayPattern(false, 0, pattern.displayName) - val result = pattern.operate( + if (lookupResult.left().isPresent) { + val action = lookupResult.left().get() + displayPatternDebug(false, 0, castedName) + val result = action.operate( continuation, this.stack.toMutableList(), this.ravenmind, @@ -277,13 +272,13 @@ class CastingHarness private constructor( ravenmind2 = result.newRavenmind // TODO parens also break prescience sideEffects.addAll(result.sideEffects) - } - - if (unenlightened) { - sideEffects.add(OperatorSideEffect.RequiredEnlightenment(pattern.causesBlindDiversion)) + } else { + val problems = lookupResult.right().get() + sideEffects.addAll(problems) } // Stick a poofy particle effect at the caster position + // TODO again this should be on the VM lalala if (this.ctx.spellCircle == null) sideEffects.add( OperatorSideEffect.Particles( @@ -305,7 +300,8 @@ class CastingHarness private constructor( hereFd } - var soundType = if (this.ctx.source == CastingContext.CastSource.STAFF) { + // TODO again this should be per VM + var soundType = if (this.ctx.source == CastingEnvironment.CastSource.STAFF) { HexEvalSounds.OPERATOR } else { HexEvalSounds.NOTHING @@ -326,8 +322,8 @@ class CastingHarness private constructor( return CastResult( cont2, fd, - ResolvedPatternType.EVALUATED, sideEffects, + ResolvedPatternType.EVALUATED, soundType, ) @@ -335,8 +331,8 @@ class CastingHarness private constructor( return CastResult( continuation, null, + listOf(OperatorSideEffect.DoMishap(mishap, Mishap.Context(newPat, castedName))), mishap.resolutionType(ctx), - listOf(OperatorSideEffect.DoMishap(mishap, Mishap.Context(newPat, actionIdPair?.first))), HexEvalSounds.MISHAP ) } @@ -388,6 +384,7 @@ class CastingHarness private constructor( * Return a non-null value if we handled this in some sort of parenthesey way, * either escaping it onto the stack or changing the parenthese-handling state. */ + @Throws(MishapTooManyCloseParens::class) private fun handleParentheses(iota: Iota): Pair? { val sig = (iota as? PatternIota)?.pattern?.anglesSignature() @@ -485,14 +482,17 @@ class CastingHarness private constructor( } } + // TODO: replace this once we can read things from the client + /* if (out != null) { val display = if (iota is PatternIota) { PatternNameHelper.representationForPattern(iota.pattern) .copy() .withStyle(if (out.second == ResolvedPatternType.ESCAPED) ChatFormatting.YELLOW else ChatFormatting.AQUA) } else iota.display() - displayPattern(this.escapeNext, displayDepth, display) + displayPatternDebug(this.escapeNext, displayDepth, display) } + */ return out } @@ -539,7 +539,7 @@ class CastingHarness private constructor( false } - if (casterStack.`is`(HexItemTags.STAVES) || hexHolderDrawsFromInventory) { + if (casterStack.`is`(HexTags.Items.STAVES) || hexHolderDrawsFromInventory) { val mediaSources = DiscoveryHandlers.collectMediaHolders(this) .sortedWith(Comparator(::compareMediaItem).reversed()) for (source in mediaSources) { @@ -551,14 +551,14 @@ class CastingHarness private constructor( if (allowOvercast && costLeft > 0) { // Cast from HP! val mediaToHealth = HexConfig.common().mediaToHealthRate() - val healthtoRemove = costLeft.toDouble() / mediaToHealth + val healthToRemove = max(costLeft.toDouble() / mediaToHealth, 0.5) val mediaAbleToCastFromHP = this.ctx.caster.health * mediaToHealth val mediaToActuallyPayFor = min(mediaAbleToCastFromHP.toInt(), costLeft) costLeft -= if (!fake) { - Mishap.trulyHurt(this.ctx.caster, HexDamageSources.OVERCAST, healthtoRemove.toFloat()) + Mishap.trulyHurt(this.ctx.caster, HexDamageSources.OVERCAST, healthToRemove.toFloat()) - val actuallyTaken = (mediaAbleToCastFromHP - (this.ctx.caster.health * mediaToHealth)).toInt() + val actuallyTaken = Mth.ceil(mediaAbleToCastFromHP - (this.ctx.caster.health * mediaToHealth)) HexAdvancementTriggers.OVERCAST_TRIGGER.trigger(this.ctx.caster, actuallyTaken) this.ctx.caster.awardStat(HexStatistics.MEDIA_OVERCAST, mediaCost - costLeft) @@ -633,7 +633,7 @@ class CastingHarness private constructor( } @JvmStatic - fun fromNBT(nbt: CompoundTag, ctx: CastingContext): CastingHarness { + fun fromNBT(nbt: CompoundTag, ctx: CastingEnvironment): CastingHarness { return try { val stack = mutableListOf() val stackTag = nbt.getList(TAG_STACK, Tag.TAG_COMPOUND) @@ -672,12 +672,4 @@ class CastingHarness private constructor( data class TempControllerInfo( var earlyExit: Boolean, ) - - data class CastResult( - val continuation: SpellContinuation, - val newData: FunctionalData?, - val resolutionType: ResolvedPatternType, - val sideEffects: List, - val sound: EvalSound, - ) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ControllerInfo.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/ControllerInfo.kt similarity index 87% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ControllerInfo.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/ControllerInfo.kt index 64d60aba..c17e096c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ControllerInfo.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/ControllerInfo.kt @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.casting +package at.petrak.hexcasting.api.casting.eval import net.minecraft.nbt.CompoundTag diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ResolvedPattern.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/ResolvedPattern.kt similarity index 84% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ResolvedPattern.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/ResolvedPattern.kt index 0413f64c..61088507 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ResolvedPattern.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/ResolvedPattern.kt @@ -1,7 +1,7 @@ -package at.petrak.hexcasting.api.spell.casting +package at.petrak.hexcasting.api.casting.eval -import at.petrak.hexcasting.api.spell.math.HexCoord -import at.petrak.hexcasting.api.spell.math.HexPattern +import at.petrak.hexcasting.api.casting.math.HexCoord +import at.petrak.hexcasting.api.casting.math.HexPattern import at.petrak.hexcasting.api.utils.NBTBuilder import net.minecraft.nbt.CompoundTag import java.util.* diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ResolvedPatternType.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/ResolvedPatternType.kt similarity index 91% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ResolvedPatternType.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/ResolvedPatternType.kt index 518f3cec..244d7a1c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ResolvedPatternType.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/ResolvedPatternType.kt @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.casting +package at.petrak.hexcasting.api.casting.eval import at.petrak.hexcasting.api.utils.getSafe diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/SpecialPatterns.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/SpecialPatterns.java new file mode 100644 index 00000000..4aee723a --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/SpecialPatterns.java @@ -0,0 +1,10 @@ +package at.petrak.hexcasting.api.casting.eval; + +import at.petrak.hexcasting.api.casting.math.HexDir; +import at.petrak.hexcasting.api.casting.math.HexPattern; + +public final class SpecialPatterns { + public static final HexPattern INTROSPECTION = HexPattern.fromAngles("qqq", HexDir.WEST); + public static final HexPattern RETROSPECTION = HexPattern.fromAngles("eee", HexDir.EAST); + public static final HexPattern CONSIDERATION = HexPattern.fromAngles("qqqaw", HexDir.WEST); +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/SpellCircleContext.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/SpellCircleContext.kt similarity index 94% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/SpellCircleContext.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/SpellCircleContext.kt index 404575f2..269d6465 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/SpellCircleContext.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/SpellCircleContext.kt @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.casting +package at.petrak.hexcasting.api.casting.eval import at.petrak.hexcasting.api.utils.NBTBuilder import net.minecraft.core.BlockPos @@ -6,7 +6,7 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.world.phys.AABB /** - * Optional field on a [CastingContext] for the spell circle + * Optional field on a [CastingEnvironment] for the spell circle */ data class SpellCircleContext(val impetusPos: BlockPos, val aabb: AABB, val activatorAlwaysInRange: Boolean) { fun serializeToNBT() = NBTBuilder { diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/sideeffects/EvalSound.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/sideeffects/EvalSound.java similarity index 90% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/sideeffects/EvalSound.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/sideeffects/EvalSound.java index 73e2ad71..a2109858 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/sideeffects/EvalSound.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/sideeffects/EvalSound.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.casting.sideeffects; +package at.petrak.hexcasting.api.casting.eval.sideeffects; import net.minecraft.sounds.SoundEvent; import org.jetbrains.annotations.Nullable; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/sideeffects/OperatorSideEffect.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/sideeffects/OperatorSideEffect.kt similarity index 90% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/sideeffects/OperatorSideEffect.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/sideeffects/OperatorSideEffect.kt index e1aa04f7..bdf831de 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/sideeffects/OperatorSideEffect.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/sideeffects/OperatorSideEffect.kt @@ -1,13 +1,13 @@ -package at.petrak.hexcasting.api.spell.casting.sideeffects +package at.petrak.hexcasting.api.casting.eval.sideeffects import at.petrak.hexcasting.api.advancements.HexAdvancementTriggers import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus +import at.petrak.hexcasting.api.casting.ParticleSpray +import at.petrak.hexcasting.api.casting.RenderedSpell +import at.petrak.hexcasting.api.casting.eval.CastingHarness +import at.petrak.hexcasting.api.casting.mishaps.Mishap import at.petrak.hexcasting.api.misc.FrozenColorizer import at.petrak.hexcasting.api.mod.HexStatistics -import at.petrak.hexcasting.api.spell.ParticleSpray -import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.casting.CastingHarness -import at.petrak.hexcasting.api.spell.mishaps.Mishap import at.petrak.hexcasting.api.utils.asTranslatedComponent import at.petrak.hexcasting.common.lib.HexItems import net.minecraft.Util @@ -69,7 +69,7 @@ sealed class OperatorSideEffect { data class DoMishap(val mishap: Mishap, val errorCtx: Mishap.Context) : OperatorSideEffect() { override fun performEffect(harness: CastingHarness): Boolean { - val msg = mishap.errorMessage(harness.ctx, errorCtx); + val msg = mishap.errorMessageWithName(harness.ctx, errorCtx); if (harness.ctx.spellCircle != null) { val tile = harness.ctx.world.getBlockEntity(harness.ctx.spellCircle.impetusPos) if (tile is BlockEntityAbstractImpetus) { diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/ContinuationFrame.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/ContinuationFrame.kt similarity index 91% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/ContinuationFrame.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/ContinuationFrame.kt index 4d768732..24235613 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/ContinuationFrame.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/ContinuationFrame.kt @@ -1,9 +1,9 @@ -package at.petrak.hexcasting.api.spell.casting.eval +package at.petrak.hexcasting.api.casting.eval.vm -import at.petrak.hexcasting.api.spell.SpellList -import at.petrak.hexcasting.api.spell.casting.CastingHarness -import at.petrak.hexcasting.api.spell.casting.CastingHarness.CastResult -import at.petrak.hexcasting.api.spell.iota.Iota +import at.petrak.hexcasting.api.casting.SpellList +import at.petrak.hexcasting.api.casting.eval.CastingHarness +import at.petrak.hexcasting.api.casting.eval.CastResult +import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.utils.getList import at.petrak.hexcasting.api.utils.hasList import at.petrak.hexcasting.common.lib.hex.HexIotaTypes diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FrameEvaluate.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameEvaluate.kt similarity index 79% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FrameEvaluate.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameEvaluate.kt index f8052f2d..bec172a1 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FrameEvaluate.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameEvaluate.kt @@ -1,9 +1,10 @@ -package at.petrak.hexcasting.api.spell.casting.eval +package at.petrak.hexcasting.api.casting.eval.vm -import at.petrak.hexcasting.api.spell.SpellList -import at.petrak.hexcasting.api.spell.casting.CastingHarness -import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType -import at.petrak.hexcasting.api.spell.iota.Iota +import at.petrak.hexcasting.api.casting.SpellList +import at.petrak.hexcasting.api.casting.eval.CastResult +import at.petrak.hexcasting.api.casting.eval.CastingHarness +import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType +import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.utils.NBTBuilder import at.petrak.hexcasting.api.utils.serializeToNBT import at.petrak.hexcasting.common.lib.hex.HexEvalSounds @@ -23,7 +24,7 @@ data class FrameEvaluate(val list: SpellList, val isMetacasting: Boolean) : Cont continuation: SpellContinuation, level: ServerLevel, harness: CastingHarness - ): CastingHarness.CastResult { + ): CastResult { // If there are patterns left... return if (list.nonEmpty) { val newCont = if (list.cdr.nonEmpty) { // yay TCO @@ -39,7 +40,7 @@ data class FrameEvaluate(val list: SpellList, val isMetacasting: Boolean) : Cont } } else { // If there are no patterns (e.g. empty Hermes), just return OK. - CastingHarness.CastResult(continuation, null, ResolvedPatternType.EVALUATED, listOf(), HexEvalSounds.HERMES) + CastResult(continuation, null, listOf(), ResolvedPatternType.EVALUATED, HexEvalSounds.HERMES) } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FrameFinishEval.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameFinishEval.kt similarity index 75% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FrameFinishEval.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameFinishEval.kt index 05ec820b..75c42654 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FrameFinishEval.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameFinishEval.kt @@ -1,8 +1,9 @@ -package at.petrak.hexcasting.api.spell.casting.eval +package at.petrak.hexcasting.api.casting.eval.vm -import at.petrak.hexcasting.api.spell.casting.CastingHarness -import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType -import at.petrak.hexcasting.api.spell.iota.Iota +import at.petrak.hexcasting.api.casting.eval.CastResult +import at.petrak.hexcasting.api.casting.eval.CastingHarness +import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType +import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.utils.NBTBuilder import at.petrak.hexcasting.common.lib.hex.HexEvalSounds import net.minecraft.server.level.ServerLevel @@ -20,12 +21,12 @@ object FrameFinishEval : ContinuationFrame { continuation: SpellContinuation, level: ServerLevel, harness: CastingHarness - ): CastingHarness.CastResult { - return CastingHarness.CastResult( + ): CastResult { + return CastResult( continuation, FunctionalData(harness.stack.toList(), 0, listOf(), false, harness.ravenmind), - ResolvedPatternType.EVALUATED, listOf(), + ResolvedPatternType.EVALUATED, HexEvalSounds.NOTHING, ) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FrameForEach.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameForEach.kt similarity index 88% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FrameForEach.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameForEach.kt index 40107399..25dc4bb0 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FrameForEach.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameForEach.kt @@ -1,10 +1,11 @@ -package at.petrak.hexcasting.api.spell.casting.eval +package at.petrak.hexcasting.api.casting.eval.vm -import at.petrak.hexcasting.api.spell.SpellList -import at.petrak.hexcasting.api.spell.casting.CastingHarness -import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.iota.ListIota +import at.petrak.hexcasting.api.casting.SpellList +import at.petrak.hexcasting.api.casting.eval.CastResult +import at.petrak.hexcasting.api.casting.eval.CastingHarness +import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.iota.ListIota import at.petrak.hexcasting.api.utils.NBTBuilder import at.petrak.hexcasting.api.utils.serializeToNBT import at.petrak.hexcasting.common.lib.hex.HexEvalSounds @@ -39,7 +40,7 @@ data class FrameForEach( continuation: SpellContinuation, level: ServerLevel, harness: CastingHarness - ): CastingHarness.CastResult { + ): CastResult { // If this isn't the very first Thoth step (i.e. no Thoth computations run yet)... val stack = if (baseStack == null) { // init stack to the harness stack... @@ -67,11 +68,11 @@ data class FrameForEach( val tStack = stack.toMutableList() tStack.add(stackTop) // TODO: this means we could have Thoth casting do a different sound - return CastingHarness.CastResult( + return CastResult( newCont, FunctionalData(tStack, 0, listOf(), false, harness.ravenmind), - ResolvedPatternType.EVALUATED, listOf(), + ResolvedPatternType.EVALUATED, HexEvalSounds.THOTH, ) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FunctionalData.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FunctionalData.kt similarity index 71% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FunctionalData.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FunctionalData.kt index 32ad396e..49f3d149 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/FunctionalData.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FunctionalData.kt @@ -1,6 +1,6 @@ -package at.petrak.hexcasting.api.spell.casting.eval +package at.petrak.hexcasting.api.casting.eval.vm -import at.petrak.hexcasting.api.spell.iota.Iota +import at.petrak.hexcasting.api.casting.iota.Iota /** * A change to the data in a CastHarness after a pattern is drawn. diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/SpellContinuation.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/SpellContinuation.kt similarity index 96% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/SpellContinuation.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/SpellContinuation.kt index 18d9057c..b1849523 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/eval/SpellContinuation.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/SpellContinuation.kt @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.casting.eval +package at.petrak.hexcasting.api.casting.eval.vm import at.petrak.hexcasting.api.utils.NBTBuilder import at.petrak.hexcasting.api.utils.getList diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/BooleanIota.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/BooleanIota.java similarity index 97% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/iota/BooleanIota.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/iota/BooleanIota.java index 54e3f2be..91cf0b33 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/BooleanIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/BooleanIota.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.iota; +package at.petrak.hexcasting.api.casting.iota; import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/ContinuationIota.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/ContinuationIota.java similarity index 94% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/iota/ContinuationIota.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/iota/ContinuationIota.java index 106e7dc3..c1389b28 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/ContinuationIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/ContinuationIota.java @@ -1,6 +1,6 @@ -package at.petrak.hexcasting.api.spell.iota; +package at.petrak.hexcasting.api.casting.iota; -import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation; +import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation; import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; import net.minecraft.ChatFormatting; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/DoubleIota.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/DoubleIota.java similarity index 97% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/iota/DoubleIota.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/iota/DoubleIota.java index 288501f7..e9ff20f5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/DoubleIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/DoubleIota.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.iota; +package at.petrak.hexcasting.api.casting.iota; import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/EntityIota.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/EntityIota.java similarity index 98% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/iota/EntityIota.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/iota/EntityIota.java index 7c5b0be6..fe2ee51f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/EntityIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/EntityIota.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.iota; +package at.petrak.hexcasting.api.casting.iota; import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/GarbageIota.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/GarbageIota.java similarity index 97% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/iota/GarbageIota.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/iota/GarbageIota.java index 4d480f53..08249858 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/GarbageIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/GarbageIota.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.iota; +package at.petrak.hexcasting.api.casting.iota; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; import net.minecraft.ChatFormatting; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/Iota.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/Iota.java similarity index 96% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/iota/Iota.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/iota/Iota.java index 90489361..85491970 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/Iota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/Iota.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.iota; +package at.petrak.hexcasting.api.casting.iota; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; import net.minecraft.nbt.Tag; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/IotaType.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/IotaType.java similarity index 96% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/iota/IotaType.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/iota/IotaType.java index f40f024c..97cfc9c0 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/IotaType.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/IotaType.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.iota; +package at.petrak.hexcasting.api.casting.iota; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; import net.minecraft.nbt.Tag; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/ListIota.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/ListIota.java similarity index 97% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/iota/ListIota.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/iota/ListIota.java index 69f7f3a4..ca4727c7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/ListIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/ListIota.java @@ -1,6 +1,6 @@ -package at.petrak.hexcasting.api.spell.iota; +package at.petrak.hexcasting.api.casting.iota; -import at.petrak.hexcasting.api.spell.SpellList; +import at.petrak.hexcasting.api.casting.SpellList; import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; import net.minecraft.ChatFormatting; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/NullIota.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/NullIota.java similarity index 97% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/iota/NullIota.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/iota/NullIota.java index 30ab1b2b..525e6b22 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/NullIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/NullIota.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.iota; +package at.petrak.hexcasting.api.casting.iota; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; import net.minecraft.ChatFormatting; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/PatternIota.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/PatternIota.java similarity index 95% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/iota/PatternIota.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/iota/PatternIota.java index f7a28597..0f9b10c3 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/PatternIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/PatternIota.java @@ -1,6 +1,6 @@ -package at.petrak.hexcasting.api.spell.iota; +package at.petrak.hexcasting.api.casting.iota; -import at.petrak.hexcasting.api.spell.math.HexPattern; +import at.petrak.hexcasting.api.casting.math.HexPattern; import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; import net.minecraft.ChatFormatting; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/Vec3Iota.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/Vec3Iota.java similarity index 98% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/iota/Vec3Iota.java rename to Common/src/main/java/at/petrak/hexcasting/api/casting/iota/Vec3Iota.java index 1babae96..d620878f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/Vec3Iota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/Vec3Iota.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.iota; +package at.petrak.hexcasting.api.casting.iota; import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/math/EulerPathFinder.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/math/EulerPathFinder.kt similarity index 98% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/math/EulerPathFinder.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/math/EulerPathFinder.kt index efdbe780..d79ff002 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/math/EulerPathFinder.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/math/EulerPathFinder.kt @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.math +package at.petrak.hexcasting.api.casting.math import at.petrak.hexcasting.api.HexAPI import java.util.* diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexAngle.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexAngle.kt similarity index 82% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexAngle.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexAngle.kt index 4565329b..bca8b0b9 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexAngle.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexAngle.kt @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.math +package at.petrak.hexcasting.api.casting.math enum class HexAngle { FORWARD, RIGHT, RIGHT_BACK, BACK, LEFT_BACK, LEFT; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexCoord.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexCoord.kt similarity index 97% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexCoord.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexCoord.kt index 82506f0e..a10d3dfe 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexCoord.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexCoord.kt @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.math +package at.petrak.hexcasting.api.casting.math import kotlin.math.abs import kotlin.math.max diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexDir.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexDir.kt similarity index 95% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexDir.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexDir.kt index afef8666..514cb0e4 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexDir.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexDir.kt @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.math +package at.petrak.hexcasting.api.casting.math import at.petrak.hexcasting.api.utils.getSafe diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexPattern.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexPattern.kt similarity index 97% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexPattern.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexPattern.kt index d05d6874..096d0340 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/math/HexPattern.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/math/HexPattern.kt @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.api.spell.math +package at.petrak.hexcasting.api.casting.math import at.petrak.hexcasting.api.utils.NBTBuilder import at.petrak.hexcasting.api.utils.coordToPx @@ -129,10 +129,8 @@ data class HexPattern(public val startDir: HexDir, public val angles: MutableLis @JvmStatic fun isPattern(tag: CompoundTag): Boolean { - return tag.contains(TAG_START_DIR, Tag.TAG_ANY_NUMERIC.toInt()) && tag.contains( - TAG_ANGLES, - Tag.TAG_BYTE_ARRAY.toInt() - ) + return tag.contains(TAG_START_DIR, Tag.TAG_ANY_NUMERIC.toInt()) + && tag.contains(TAG_ANGLES, Tag.TAG_BYTE_ARRAY.toInt()) } @JvmStatic diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/Mishap.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/Mishap.kt similarity index 69% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/Mishap.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/Mishap.kt index 5ae88624..ff1517ba 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/Mishap.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/Mishap.kt @@ -1,13 +1,12 @@ -package at.petrak.hexcasting.api.spell.mishaps +package at.petrak.hexcasting.api.casting.mishaps +import at.petrak.hexcasting.api.casting.ParticleSpray +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.math.HexPattern import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.mod.HexItemTags -import at.petrak.hexcasting.api.spell.Action -import at.petrak.hexcasting.api.spell.ParticleSpray -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.math.HexPattern +import at.petrak.hexcasting.api.mod.HexTags import at.petrak.hexcasting.api.utils.asTranslatedComponent import at.petrak.hexcasting.api.utils.lightPurple import at.petrak.hexcasting.common.lib.HexItems @@ -26,22 +25,33 @@ import net.minecraft.world.phys.Vec3 abstract class Mishap : Throwable() { /** Mishaps spray half-red, half-this-color. */ - abstract fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer + abstract fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer - open fun particleSpray(ctx: CastingContext): ParticleSpray { + open fun particleSpray(ctx: CastingEnvironment): ParticleSpray { return ParticleSpray(ctx.position.add(0.0, 0.2, 0.0), Vec3(0.0, 2.0, 0.0), 0.2, Math.PI / 4, 40) } - open fun resolutionType(ctx: CastingContext): ResolvedPatternType = ResolvedPatternType.ERRORED + open fun resolutionType(ctx: CastingEnvironment): ResolvedPatternType = ResolvedPatternType.ERRORED /** * Execute the actual effect, not any sfx. * * You can also mess up the stack with this. */ - abstract fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) + abstract fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) - abstract fun errorMessage(ctx: CastingContext, errorCtx: Context): Component + abstract protected fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component + + /** + * Every error message should be prefixed with the name of the action... + */ + public fun errorMessageWithName(ctx: CastingEnvironment, errorCtx: Context): Component { + return if (errorCtx.name != null) { + "hexcasting.mishap".asTranslatedComponent(errorCtx.name, this.errorMessage(ctx, errorCtx)) + } else { + this.errorMessage(ctx, errorCtx) + } + } // Useful helper functions @@ -54,14 +64,14 @@ abstract class Mishap : Throwable() { protected fun error(stub: String, vararg args: Any): Component = "hexcasting.mishap.$stub".asTranslatedComponent(*args) - protected fun actionName(action: Action?): Component = - action?.displayName ?: "hexcasting.spell.null".asTranslatedComponent.lightPurple + protected fun actionName(name: Component?): Component = + name ?: "hexcasting.spell.null".asTranslatedComponent.lightPurple - protected fun yeetHeldItemsTowards(ctx: CastingContext, targetPos: Vec3) { + protected fun yeetHeldItemsTowards(ctx: CastingEnvironment, targetPos: Vec3) { // Knock the player's items out of their hands val items = mutableListOf() for (hand in InteractionHand.values()) { - if (hand != ctx.castingHand || ctx.caster.getItemInHand(hand).`is`(HexItemTags.STAVES)) { + if (hand != ctx.castingHand || ctx.caster.getItemInHand(hand).`is`(HexTags.Items.STAVES)) { items.add(ctx.caster.getItemInHand(hand).copy()) ctx.caster.setItemInHand(hand, ItemStack.EMPTY) } @@ -74,7 +84,7 @@ abstract class Mishap : Throwable() { } } - protected fun yeetHeldItem(ctx: CastingContext, hand: InteractionHand) { + protected fun yeetHeldItem(ctx: CastingEnvironment, hand: InteractionHand) { val item = ctx.caster.getItemInHand(hand).copy() if (hand == ctx.castingHand && IXplatAbstractions.INSTANCE.findHexHolder(item) != null) return @@ -84,7 +94,7 @@ abstract class Mishap : Throwable() { yeetItem(item, ctx, delta) } - protected fun yeetItem(stack: ItemStack, ctx: CastingContext, delta: Vec3) { + protected fun yeetItem(stack: ItemStack, ctx: CastingEnvironment, delta: Vec3) { val entity = ItemEntity( ctx.world, ctx.position.x, ctx.position.y, ctx.position.z, @@ -97,11 +107,11 @@ abstract class Mishap : Throwable() { ctx.world.addWithUUID(entity) } - protected fun blockAtPos(ctx: CastingContext, pos: BlockPos): Component { + protected fun blockAtPos(ctx: CastingEnvironment, pos: BlockPos): Component { return ctx.world.getBlockState(pos).block.name } - data class Context(val pattern: HexPattern, val action: Action?) + data class Context(val pattern: HexPattern, val name: Component?) companion object { fun trulyHurt(entity: LivingEntity, source: DamageSource, amount: Float) { diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapAlreadyBrainswept.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapAlreadyBrainswept.kt new file mode 100644 index 00000000..50d8506d --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapAlreadyBrainswept.kt @@ -0,0 +1,25 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.misc.FrozenColorizer +import at.petrak.hexcasting.api.misc.HexDamageSources +import at.petrak.hexcasting.api.casting.ParticleSpray +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota +import net.minecraft.world.entity.Mob +import net.minecraft.world.item.DyeColor + +class MishapAlreadyBrainswept(val mob: Mob) : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.GREEN) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + mob.hurt(HexDamageSources.overcastDamageFrom(ctx.caster), mob.health) + } + + override fun particleSpray(ctx: CastingEnvironment) = + ParticleSpray.burst(mob.eyePosition, 1.0) + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("already_brainswept") + +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBlock.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadBlock.kt similarity index 62% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBlock.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadBlock.kt index 822515c1..0f469358 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBlock.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadBlock.kt @@ -1,9 +1,9 @@ -package at.petrak.hexcasting.api.spell.mishaps +package at.petrak.hexcasting.api.casting.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.ParticleSpray -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.casting.CastingContext +import at.petrak.hexcasting.api.casting.ParticleSpray +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.utils.asTranslatedComponent import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component @@ -12,17 +12,17 @@ import net.minecraft.world.level.Explosion import net.minecraft.world.phys.Vec3 class MishapBadBlock(val pos: BlockPos, val expected: Component) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.LIME) - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { ctx.world.explode(null, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, 0.25f, Explosion.BlockInteraction.NONE) } - override fun particleSpray(ctx: CastingContext) = + override fun particleSpray(ctx: CastingEnvironment) = ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0) - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = error("bad_block", expected, this.pos.toShortString(), blockAtPos(ctx, this.pos)) companion object { diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadBrainsweep.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadBrainsweep.kt new file mode 100644 index 00000000..cb8e7463 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadBrainsweep.kt @@ -0,0 +1,27 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.misc.FrozenColorizer +import at.petrak.hexcasting.api.misc.HexDamageSources +import at.petrak.hexcasting.api.casting.ParticleSpray +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota +import net.minecraft.core.BlockPos +import net.minecraft.world.entity.Mob +import net.minecraft.world.item.DyeColor +import net.minecraft.world.phys.Vec3 + +class MishapBadBrainsweep(val mob: Mob, val pos: BlockPos) : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.GREEN) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + trulyHurt(mob, HexDamageSources.overcastDamageFrom(ctx.caster), mob.health) + } + + override fun particleSpray(ctx: CastingEnvironment): ParticleSpray { + return ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0) + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("bad_brainsweep", blockAtPos(ctx, this.pos)) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadEntity.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadEntity.kt similarity index 62% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadEntity.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadEntity.kt index ba3cbcec..143be43e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadEntity.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadEntity.kt @@ -1,8 +1,8 @@ -package at.petrak.hexcasting.api.spell.mishaps +package at.petrak.hexcasting.api.casting.mishaps +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.utils.aqua import at.petrak.hexcasting.api.utils.asTranslatedComponent import net.minecraft.network.chat.Component @@ -11,15 +11,15 @@ import net.minecraft.world.entity.item.ItemEntity import net.minecraft.world.item.DyeColor class MishapBadEntity(val entity: Entity, val wanted: Component) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.BROWN) - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { yeetHeldItemsTowards(ctx, entity.position()) } - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("bad_entity", actionName(errorCtx.action), wanted, entity.displayName.plainCopy().aqua) + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("bad_entity", wanted, entity.displayName.plainCopy().aqua) companion object { @JvmStatic diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadItem.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadItem.kt similarity index 54% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadItem.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadItem.kt index e147e634..44a74fa9 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadItem.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadItem.kt @@ -1,25 +1,25 @@ -package at.petrak.hexcasting.api.spell.mishaps +package at.petrak.hexcasting.api.casting.mishaps +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.utils.asTranslatedComponent import net.minecraft.network.chat.Component import net.minecraft.world.entity.item.ItemEntity import net.minecraft.world.item.DyeColor class MishapBadItem(val item: ItemEntity, val wanted: Component) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.BROWN) - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { item.deltaMovement = item.deltaMovement.add((Math.random() - 0.5) * 0.05, 0.75, (Math.random() - 0.5) * 0.05) } - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = if (item.item.isEmpty) - error("no_item", actionName(errorCtx.action), wanted) + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = if (item.item.isEmpty) + error("no_item", wanted) else - error("bad_item", actionName(errorCtx.action), wanted, item.item.count, item.item.displayName) + error("bad_item", wanted, item.item.count, item.item.displayName) companion object { @JvmStatic diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadOffhandItem.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadOffhandItem.kt similarity index 56% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadOffhandItem.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadOffhandItem.kt index 71dda350..afda2de1 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadOffhandItem.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadOffhandItem.kt @@ -1,8 +1,8 @@ -package at.petrak.hexcasting.api.spell.mishaps +package at.petrak.hexcasting.api.casting.mishaps +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.utils.asTranslatedComponent import net.minecraft.network.chat.Component import net.minecraft.world.InteractionHand @@ -10,17 +10,17 @@ import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack class MishapBadOffhandItem(val item: ItemStack, val hand: InteractionHand, val wanted: Component) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.BROWN) - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { yeetHeldItem(ctx, hand) } - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = if (item.isEmpty) - error("no_item.offhand", actionName(errorCtx.action), wanted) + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = if (item.isEmpty) + error("no_item.offhand", wanted) else - error("bad_item.offhand", actionName(errorCtx.action), wanted, item.count, item.displayName) + error("bad_item.offhand", wanted, item.count, item.displayName) companion object { @JvmStatic diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapDisallowedSpell.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapDisallowedSpell.kt new file mode 100644 index 00000000..a4cb2af6 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapDisallowedSpell.kt @@ -0,0 +1,21 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.misc.FrozenColorizer +import net.minecraft.world.item.DyeColor + +class MishapDisallowedSpell(val type: String = "disallowed") : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.BLACK) + + override fun resolutionType(ctx: CastingEnvironment) = ResolvedPatternType.INVALID + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + // NO-OP + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error(type) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDivideByZero.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapDivideByZero.kt similarity index 79% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDivideByZero.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapDivideByZero.kt index 7b9ec707..8d99eb3b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDivideByZero.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapDivideByZero.kt @@ -1,12 +1,12 @@ -package at.petrak.hexcasting.api.spell.mishaps +package at.petrak.hexcasting.api.casting.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer import at.petrak.hexcasting.api.misc.HexDamageSources -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.iota.DoubleIota -import at.petrak.hexcasting.api.spell.iota.GarbageIota -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.iota.Vec3Iota +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.DoubleIota +import at.petrak.hexcasting.api.casting.iota.GarbageIota +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.iota.Vec3Iota import at.petrak.hexcasting.api.utils.asTranslatedComponent import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor @@ -14,15 +14,15 @@ import net.minecraft.world.phys.Vec3 class MishapDivideByZero(val operand1: Component, val operand2: Component, val suffix: String = "divide") : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.RED) - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { stack.add(GarbageIota()) trulyHurt(ctx.caster, HexDamageSources.OVERCAST, ctx.caster.health / 2) } - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = error("divide_by_zero.$suffix", operand1, operand2) companion object { diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapEntityTooFarAway.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapEntityTooFarAway.kt new file mode 100644 index 00000000..37cc1e98 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapEntityTooFarAway.kt @@ -0,0 +1,21 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.misc.FrozenColorizer +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.Entity +import net.minecraft.world.item.DyeColor + +class MishapEntityTooFarAway(val entity: Entity) : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.PINK) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + // Knock the player's items out of their hands + yeetHeldItemsTowards(ctx, entity.position()) + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component = + error("entity_too_far", entity.displayName) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapError.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapError.kt new file mode 100644 index 00000000..8a5cec36 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapError.kt @@ -0,0 +1,18 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.misc.FrozenColorizer +import net.minecraft.world.item.DyeColor + +class MishapError(val exception: Exception) : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.BLACK) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + // NO-OP + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("unknown", exception) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapEvalTooDeep.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapEvalTooDeep.kt new file mode 100644 index 00000000..b773a235 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapEvalTooDeep.kt @@ -0,0 +1,18 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.misc.FrozenColorizer +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import net.minecraft.world.item.DyeColor + +class MishapEvalTooDeep : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.BLUE) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + ctx.caster.airSupply -= 290 + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("eval_too_deep") +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapImmuneEntity.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapImmuneEntity.kt new file mode 100644 index 00000000..4065d505 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapImmuneEntity.kt @@ -0,0 +1,20 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.misc.FrozenColorizer +import at.petrak.hexcasting.api.utils.aqua +import net.minecraft.world.entity.Entity +import net.minecraft.world.item.DyeColor + +class MishapImmuneEntity(val entity: Entity) : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.BLUE) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + yeetHeldItemsTowards(ctx, entity.position()) + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("immune_entity", entity.displayName.plainCopy().aqua) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidIota.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidIota.kt similarity index 67% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidIota.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidIota.kt index 1e1b6b83..adaddfdd 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidIota.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidIota.kt @@ -1,9 +1,9 @@ -package at.petrak.hexcasting.api.spell.mishaps +package at.petrak.hexcasting.api.casting.mishaps +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.GarbageIota +import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.iota.GarbageIota -import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.utils.asTranslatedComponent import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor @@ -18,16 +18,16 @@ class MishapInvalidIota( val reverseIdx: Int, val expected: Component ) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.GRAY) - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { stack[stack.size - 1 - reverseIdx] = GarbageIota(); } - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = error( - "invalid_value", actionName(errorCtx.action), expected, reverseIdx, + "invalid_value", expected, reverseIdx, perpetrator.display() ) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt new file mode 100644 index 00000000..242247e1 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt @@ -0,0 +1,22 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.misc.FrozenColorizer +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType +import at.petrak.hexcasting.api.casting.iota.GarbageIota +import at.petrak.hexcasting.api.casting.iota.Iota +import net.minecraft.world.item.DyeColor + +class MishapInvalidPattern : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.YELLOW) + + override fun resolutionType(ctx: CastingEnvironment) = ResolvedPatternType.INVALID + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + stack.add(GarbageIota()) + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("invalid_pattern") +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidSpellDatumType.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidSpellDatumType.kt new file mode 100644 index 00000000..a4b743df --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidSpellDatumType.kt @@ -0,0 +1,21 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.misc.FrozenColorizer +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import net.minecraft.world.item.DyeColor + +/** + * this is bad + */ +class MishapInvalidSpellDatumType(val perpetrator: Any) : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.BLACK) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + // NO-OP + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("invalid_spell_datum_type", this.perpetrator.toString(), this.perpetrator.javaClass.typeName) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapLocationInWrongDimension.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapLocationInWrongDimension.kt new file mode 100644 index 00000000..aeb7a933 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapLocationInWrongDimension.kt @@ -0,0 +1,24 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.GarbageIota +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.misc.FrozenColorizer +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.DyeColor + +class MishapLocationInWrongDimension(val properDimension: ResourceLocation) : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.MAGENTA) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + stack.add(GarbageIota()) + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component = + error( + "wrong_dimension", properDimension.toString(), + ctx.world.dimension().location().toString() + ) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapLocationTooFarAway.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapLocationTooFarAway.kt new file mode 100644 index 00000000..5869754a --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapLocationTooFarAway.kt @@ -0,0 +1,21 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.iota.Vec3Iota +import at.petrak.hexcasting.api.misc.FrozenColorizer +import net.minecraft.network.chat.Component +import net.minecraft.world.item.DyeColor +import net.minecraft.world.phys.Vec3 + +class MishapLocationTooFarAway(val location: Vec3, val type: String = "too_far") : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.MAGENTA) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + yeetHeldItemsTowards(ctx, location) + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component = + error("location_$type", Vec3Iota.display(location)) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapNoAkashicRecord.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapNoAkashicRecord.kt new file mode 100644 index 00000000..f48ec9f8 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapNoAkashicRecord.kt @@ -0,0 +1,19 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.misc.FrozenColorizer +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import net.minecraft.core.BlockPos +import net.minecraft.world.item.DyeColor + +class MishapNoAkashicRecord(val pos: BlockPos) : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.PURPLE) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + ctx.caster.giveExperiencePoints(-100) + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("no_akashic_record", pos.toShortString()) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoSpellCircle.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapNoSpellCircle.kt similarity index 66% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoSpellCircle.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapNoSpellCircle.kt index 35726671..db6bfe57 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoSpellCircle.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapNoSpellCircle.kt @@ -1,15 +1,15 @@ -package at.petrak.hexcasting.api.spell.mishaps +package at.petrak.hexcasting.api.casting.mishaps +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.iota.Iota import net.minecraft.world.entity.player.Player import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper class MishapNoSpellCircle : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.LIGHT_BLUE) private inline fun dropAll(player: Player, stacks: MutableList, filter: (ItemStack) -> Boolean = { true }) { @@ -22,7 +22,7 @@ class MishapNoSpellCircle : Mishap() { } } - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { dropAll(ctx.caster, ctx.caster.inventory.items) dropAll(ctx.caster, ctx.caster.inventory.offhand) dropAll(ctx.caster, ctx.caster.inventory.armor) { @@ -30,6 +30,6 @@ class MishapNoSpellCircle : Mishap() { } } - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("no_spell_circle", actionName(errorCtx.action)) + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("no_spell_circle") } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapNotEnoughArgs.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapNotEnoughArgs.kt new file mode 100644 index 00000000..aa7b7e06 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapNotEnoughArgs.kt @@ -0,0 +1,22 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.GarbageIota +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.misc.FrozenColorizer +import net.minecraft.world.item.DyeColor + +class MishapNotEnoughArgs(val expected: Int, val got: Int) : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.LIGHT_GRAY) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + repeat(expected - got) { stack.add(GarbageIota()) } + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + if (got == 0) + error("no_args", expected) + else + error("not_enough_args", expected, got) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapOthersName.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapOthersName.kt similarity index 76% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapOthersName.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapOthersName.kt index fa2e16b4..b7c0cdd5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapOthersName.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapOthersName.kt @@ -1,10 +1,10 @@ -package at.petrak.hexcasting.api.spell.mishaps +package at.petrak.hexcasting.api.casting.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.iota.EntityIota -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.iota.ListIota +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.EntityIota +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.iota.ListIota import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects import net.minecraft.world.entity.player.Player @@ -14,15 +14,15 @@ import net.minecraft.world.item.DyeColor * Also throwable for your *own* name, for cases like Chronicler's Gambit */ class MishapOthersName(val confidant: Player) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.BLACK) - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { val seconds = if (this.confidant == ctx.caster) 5 else 60; ctx.caster.addEffect(MobEffectInstance(MobEffects.BLINDNESS, seconds * 20)) } - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = if (this.confidant == ctx.caster) error("others_name.self") else diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapShameOnYou.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapShameOnYou.kt new file mode 100644 index 00000000..1eaf2144 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapShameOnYou.kt @@ -0,0 +1,18 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.misc.FrozenColorizer +import at.petrak.hexcasting.api.misc.HexDamageSources +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota +import net.minecraft.world.item.DyeColor + +class MishapShameOnYou() : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.BLACK) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + Mishap.trulyHurt(ctx.caster, HexDamageSources.SHAME, 69420f) + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = error("shame") +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapTooManyCloseParens.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapTooManyCloseParens.kt new file mode 100644 index 00000000..f3a9ada7 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapTooManyCloseParens.kt @@ -0,0 +1,20 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.misc.FrozenColorizer +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.iota.PatternIota +import net.minecraft.world.item.DyeColor + +class MishapTooManyCloseParens : Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = + dyeColor(DyeColor.ORANGE) + + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { + // TODO this is a kinda shitty mishap + stack.add(PatternIota(errorCtx.pattern)) + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("too_many_close_parens") +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapUnescapedValue.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapUnescapedValue.kt similarity index 65% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapUnescapedValue.kt rename to Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapUnescapedValue.kt index f952f6d0..bc9cec5e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapUnescapedValue.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapUnescapedValue.kt @@ -1,8 +1,8 @@ -package at.petrak.hexcasting.api.spell.mishaps +package at.petrak.hexcasting.api.casting.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.casting.CastingContext +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import net.minecraft.world.item.DyeColor /** @@ -11,10 +11,10 @@ import net.minecraft.world.item.DyeColor class MishapUnescapedValue( val perpetrator: Iota ) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.GRAY) - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { + override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { // TODO /* val idx = stack.indexOfLast { it.getType() == DatumType.LIST } @@ -30,6 +30,6 @@ class MishapUnescapedValue( */ } - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = error("unescaped", perpetrator.display()) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/client/ScryingLensOverlayRegistry.java b/Common/src/main/java/at/petrak/hexcasting/api/client/ScryingLensOverlayRegistry.java index 88cc62df..476e7f54 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/client/ScryingLensOverlayRegistry.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/client/ScryingLensOverlayRegistry.java @@ -1,16 +1,16 @@ package at.petrak.hexcasting.api.client; -import at.petrak.hexcasting.xplat.IXplatAbstractions; import com.google.common.collect.Lists; import com.mojang.datafixers.util.Pair; import net.minecraft.client.Minecraft; -import net.minecraft.world.level.Level; -import net.minecraft.world.entity.player.Player; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.Registry; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BeehiveBlock; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; @@ -120,7 +120,7 @@ public final class ScryingLensOverlayRegistry { * @throws IllegalArgumentException if the block is already registered. */ public static void addDisplayer(Block block, OverlayBuilder displayer) { - addDisplayer(IXplatAbstractions.INSTANCE.getID(block), displayer); + addDisplayer(Registry.BLOCK.getKey(block), displayer); } /** @@ -152,7 +152,7 @@ public final class ScryingLensOverlayRegistry { Player observer, Level world, Direction hitFace) { List> lines = Lists.newArrayList(); - var idLookedup = ID_LOOKUP.get(IXplatAbstractions.INSTANCE.getID(state.getBlock())); + var idLookedup = ID_LOOKUP.get(Registry.BLOCK.getKey(state.getBlock())); if (idLookedup != null) { idLookedup.addLines(lines, state, pos, observer, world, hitFace); } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java b/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java index bf276235..72ea7685 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.api.item; -import at.petrak.hexcasting.api.spell.iota.Iota; +import at.petrak.hexcasting.api.casting.iota.Iota; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.ApiStatus; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/item/IotaHolderItem.java b/Common/src/main/java/at/petrak/hexcasting/api/item/IotaHolderItem.java index 3aeef986..d0ae62a8 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/item/IotaHolderItem.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/item/IotaHolderItem.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.api.item; -import at.petrak.hexcasting.api.spell.iota.Iota; +import at.petrak.hexcasting.api.casting.iota.Iota; import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.client.ClientTickCounter; @@ -27,7 +27,7 @@ import java.util.List; public interface IotaHolderItem { /** * If this key is set on the item, we ignore the rest of the item and render this as if it were of the - * {@link at.petrak.hexcasting.api.spell.iota.IotaType IotaType} given by the resource location. + * {@link at.petrak.hexcasting.api.casting.iota.IotaType IotaType} given by the resource location. *

* This is not useful to the player at all. */ @@ -54,7 +54,7 @@ public interface IotaHolderItem { /** * What is this considered to contain when nothing can be read? *

- * TODO i'm not sure what this exists for + * TODO i'm not sure what this isCastable for */ @Nullable default Iota emptyIota(ItemStack stack) { @@ -97,7 +97,7 @@ public interface IotaHolderItem { void writeDatum(ItemStack stack, @Nullable Iota iota); static void appendHoverText(IotaHolderItem self, ItemStack stack, List components, - TooltipFlag flag) { + TooltipFlag flag) { var datumTag = self.readIotaTag(stack); if (datumTag != null) { var cmp = HexIotaTypes.getDisplay(datumTag); diff --git a/Common/src/main/java/at/petrak/hexcasting/api/misc/DiscoveryHandlers.java b/Common/src/main/java/at/petrak/hexcasting/api/misc/DiscoveryHandlers.java index f231fe6f..a4dc4400 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/misc/DiscoveryHandlers.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/misc/DiscoveryHandlers.java @@ -1,8 +1,8 @@ package at.petrak.hexcasting.api.misc; import at.petrak.hexcasting.api.addldata.ADMediaHolder; -import at.petrak.hexcasting.api.spell.casting.CastingContext; -import at.petrak.hexcasting.api.spell.casting.CastingHarness; +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment; +import at.petrak.hexcasting.api.casting.eval.CastingHarness; import com.google.common.collect.Lists; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -17,8 +17,8 @@ public class DiscoveryHandlers { private static final List> HAS_LENS_PREDICATE = new ArrayList<>(); private static final List>> MEDIA_HOLDER_DISCOVERY = new ArrayList<>(); private static final List> GRID_SCALE_MODIFIERS = new ArrayList<>(); - private static final List>> ITEM_SLOT_DISCOVERER = new ArrayList<>(); - private static final List>> OPERATIVE_SLOT_DISCOVERER = new ArrayList<>(); + private static final List>> ITEM_SLOT_DISCOVERER = new ArrayList<>(); + private static final List>> OPERATIVE_SLOT_DISCOVERER = new ArrayList<>(); private static final List> DEBUG_DISCOVERER = new ArrayList<>(); public static boolean hasLens(Player player) { @@ -46,7 +46,7 @@ public class DiscoveryHandlers { return mod; } - public static List collectItemSlots(CastingContext ctx) { + public static List collectItemSlots(CastingEnvironment ctx) { List stacks = Lists.newArrayList(); for (var discoverer : ITEM_SLOT_DISCOVERER) { stacks.addAll(discoverer.apply(ctx)); @@ -54,7 +54,7 @@ public class DiscoveryHandlers { return stacks; } - public static List collectOperableSlots(CastingContext ctx) { + public static List collectOperableSlots(CastingEnvironment ctx) { List stacks = Lists.newArrayList(); for (var discoverer : OPERATIVE_SLOT_DISCOVERER) { stacks.addAll(discoverer.apply(ctx)); @@ -84,11 +84,11 @@ public class DiscoveryHandlers { GRID_SCALE_MODIFIERS.add(modifier); } - public static void addItemSlotDiscoverer(Function> discoverer) { + public static void addItemSlotDiscoverer(Function> discoverer) { ITEM_SLOT_DISCOVERER.add(discoverer); } - public static void addOperativeSlotDiscoverer(Function> discoverer) { + public static void addOperativeSlotDiscoverer(Function> discoverer) { OPERATIVE_SLOT_DISCOVERER.add(discoverer); } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/misc/MediaConstants.java b/Common/src/main/java/at/petrak/hexcasting/api/misc/MediaConstants.java index 322a9c82..73764c7c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/misc/MediaConstants.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/misc/MediaConstants.java @@ -4,4 +4,7 @@ public final class MediaConstants { public static final int DUST_UNIT = 10000; public static final int SHARD_UNIT = 5 * DUST_UNIT; public static final int CRYSTAL_UNIT = 10 * DUST_UNIT; + + public static final int QUENCHED_SHARD_UNIT = 3 * CRYSTAL_UNIT; + public static final int QUENCHED_BLOCK_UNIT = 4 * QUENCHED_SHARD_UNIT; } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/misc/ScrollQuantity.java b/Common/src/main/java/at/petrak/hexcasting/api/misc/ScrollQuantity.java deleted file mode 100644 index bc262ea3..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/misc/ScrollQuantity.java +++ /dev/null @@ -1,24 +0,0 @@ -package at.petrak.hexcasting.api.misc; - -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import static at.petrak.hexcasting.api.HexAPI.modLoc; - -public enum ScrollQuantity { - NONE(null), - FEW(modLoc("inject/scroll_loot_few")), - SOME(modLoc("inject/scroll_loot_some")), - MANY(modLoc("inject/scroll_loot_many")); - - private final ResourceLocation pool; - - ScrollQuantity(ResourceLocation pool) { - this.pool = pool; - } - - @Nullable - public ResourceLocation getPool() { - return pool; - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/mod/HexBlockTags.java b/Common/src/main/java/at/petrak/hexcasting/api/mod/HexBlockTags.java deleted file mode 100644 index 05a70ad4..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/mod/HexBlockTags.java +++ /dev/null @@ -1,16 +0,0 @@ -package at.petrak.hexcasting.api.mod; - -import net.minecraft.core.Registry; -import net.minecraft.tags.TagKey; -import net.minecraft.world.level.block.Block; - -import static at.petrak.hexcasting.api.HexAPI.modLoc; - -public class HexBlockTags { - public static final TagKey EDIFIED_LOGS = create("edified_logs"); - public static final TagKey EDIFIED_PLANKS = create("edified_planks"); - - public static TagKey create(String name) { - return TagKey.create(Registry.BLOCK_REGISTRY, modLoc(name)); - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/mod/HexConfig.java b/Common/src/main/java/at/petrak/hexcasting/api/mod/HexConfig.java index 2c3739fd..e1b181da 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/mod/HexConfig.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/mod/HexConfig.java @@ -2,10 +2,11 @@ package at.petrak.hexcasting.api.mod; import at.petrak.hexcasting.api.HexAPI; import at.petrak.hexcasting.api.misc.MediaConstants; -import at.petrak.hexcasting.api.misc.ScrollQuantity; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Tier; import net.minecraft.world.item.Tiers; +import net.minecraft.world.level.Level; import java.util.List; @@ -20,11 +21,21 @@ public class HexConfig { double mediaToHealthRate(); + int cypherCooldown(); + + int trinketCooldown(); + + int artifactCooldown(); + int DEFAULT_DUST_MEDIA_AMOUNT = MediaConstants.DUST_UNIT; int DEFAULT_SHARD_MEDIA_AMOUNT = MediaConstants.SHARD_UNIT; int DEFAULT_CHARGED_MEDIA_AMOUNT = MediaConstants.CRYSTAL_UNIT; double DEFAULT_MEDIA_TO_HEALTH_RATE = 2 * MediaConstants.CRYSTAL_UNIT / 20.0; + int DEFAULT_CYPHER_COOLDOWN = 8; + int DEFAULT_TRINKET_COOLDOWN = 5; + int DEFAULT_ARTIFACT_COOLDOWN = 3; + } public interface ClientConfigAccess { @@ -55,19 +66,16 @@ public class HexConfig { boolean doVillagersTakeOffenseAtMindMurder(); - ScrollQuantity scrollsForLootTable(ResourceLocation lootTable); + // fun fact, although dimension keys are a RegistryHolder, they aren't a registry, so i can't do tags + boolean canTeleportInThisDimension(ResourceKey dimension); int DEFAULT_MAX_RECURSE_DEPTH = 512; int DEFAULT_MAX_SPELL_CIRCLE_LENGTH = 1024; int DEFAULT_OP_BREAK_HARVEST_LEVEL = 3; boolean DEFAULT_VILLAGERS_DISLIKE_MIND_MURDER = true; - List DEFAULT_FEW_SCROLL_TABLES = List.of("minecraft:chests/jungle_temple", - "minecraft:chests/simple_dungeon", "minecraft:chests/village/village_cartographer"); - List DEFAULT_SOME_SCROLL_TABLES = List.of("minecraft:chests/bastion_treasure", - "minecraft:chests/shipwreck_map"); - List DEFAULT_MANY_SCROLL_TABLES = List.of("minecraft:chests/stronghold_library"); - // We can't have default values for the break harvest level or if + + List DEFAULT_DIM_TP_DENYLIST = List.of("twilightforest:twilight_forest"); default Tier opBreakHarvestLevel() { return switch (this.opBreakHarvestLevelBecauseForgeThoughtItWasAGoodIdeaToImplementHarvestTiersUsingAnHonestToGodTopoSort()) { @@ -83,11 +91,23 @@ public class HexConfig { // Simple extensions for resource location configs public static boolean anyMatch(List keys, ResourceLocation key) { - return keys.stream().map(ResourceLocation::new).anyMatch(key::equals); + for (String s : keys) { + if (ResourceLocation.isValidResourceLocation(s)) { + var rl = new ResourceLocation(s); + if (rl.equals(key)) { + return true; + } + } + } + return false; } public static boolean noneMatch(List keys, ResourceLocation key) { - return keys.stream().map(ResourceLocation::new).noneMatch(key::equals); + return !anyMatch(keys, key); + } + + public static boolean anyMatchResLoc(List keys, ResourceLocation key) { + return keys.stream().anyMatch(key::equals); } // oh man this is aesthetically pleasing diff --git a/Common/src/main/java/at/petrak/hexcasting/api/mod/HexItemTags.java b/Common/src/main/java/at/petrak/hexcasting/api/mod/HexItemTags.java deleted file mode 100644 index 67de0a9a..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/mod/HexItemTags.java +++ /dev/null @@ -1,24 +0,0 @@ -package at.petrak.hexcasting.api.mod; - -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; - -import static at.petrak.hexcasting.api.HexAPI.modLoc; - -public class HexItemTags { - public static final TagKey EDIFIED_LOGS = create("edified_logs"); - public static final TagKey EDIFIED_PLANKS = create("edified_planks"); - public static final TagKey STAVES = create("staves"); - public static final TagKey PHIAL_BASE = create("phial_base"); - public static final TagKey GRANTS_ROOT_ADVANCEMENT = create("grants_root_advancement"); - - public static TagKey create(String name) { - return create(modLoc(name)); - } - - public static TagKey create(ResourceLocation id) { - return TagKey.create(Registry.ITEM_REGISTRY, id); - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/mod/HexTags.java b/Common/src/main/java/at/petrak/hexcasting/api/mod/HexTags.java new file mode 100644 index 00000000..4cb64f62 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/mod/HexTags.java @@ -0,0 +1,79 @@ +package at.petrak.hexcasting.api.mod; + +import at.petrak.hexcasting.api.casting.ActionRegistryEntry; +import at.petrak.hexcasting.xplat.IXplatAbstractions; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; + +import static at.petrak.hexcasting.api.HexAPI.modLoc; + +public class HexTags { + public static final class Items { + public static final TagKey EDIFIED_LOGS = create("edified_logs"); + public static final TagKey EDIFIED_PLANKS = create("edified_planks"); + public static final TagKey STAVES = create("staves"); + public static final TagKey PHIAL_BASE = create("phial_base"); + public static final TagKey GRANTS_ROOT_ADVANCEMENT = create("grants_root_advancement"); + public static final TagKey SEAL_MATERIALS = create("seal_materials"); + + public static final TagKey IMPETI = create("impeti"); + public static final TagKey DIRECTRICES = create("directrices"); + public static final TagKey MINDFLAYED_CIRCLE_COMPONENTS = create("brainswept_circle_components"); + + public static TagKey create(String name) { + return create(modLoc(name)); + } + + public static TagKey create(ResourceLocation id) { + return TagKey.create(Registry.ITEM_REGISTRY, id); + } + } + + public static final class Blocks { + public static final TagKey EDIFIED_LOGS = create("edified_logs"); + public static final TagKey EDIFIED_PLANKS = create("edified_planks"); + + + public static final TagKey IMPETI = create("impeti"); + public static final TagKey DIRECTRICES = create("directrices"); + public static final TagKey MINDFLAYED_CIRCLE_COMPONENTS = create("brainswept_circle_components"); + + public static TagKey create(String name) { + return TagKey.create(Registry.BLOCK_REGISTRY, modLoc(name)); + } + } + + public static final class Entities { + public static final TagKey> STICKY_TELEPORTERS = create("sticky_teleporters"); + public static final TagKey> CANNOT_TELEPORT = create("cannot_teleport"); + + public static TagKey> create(String name) { + return TagKey.create(Registry.ENTITY_TYPE_REGISTRY, modLoc(name)); + } + } + + public static final class Actions { + /** + * Actions with this tag can't be used until the caster is enlightened and send the + * "am I not skilled enough" message + */ + public static final TagKey REQUIRES_ENLIGHTENMENT = create("requires_enlightenment"); + /** + * Actions where the pattern is calculated per-world + */ + public static final TagKey PER_WORLD_PATTERN = create("per_world_pattern"); + + /** + * Actions that can cause Blind Diversion + */ + public static final TagKey CAN_START_ENLIGHTEN = create("can_start_enlighten"); + + public static TagKey create(String name) { + return TagKey.create(IXplatAbstractions.INSTANCE.getActionRegistry().key(), modLoc(name)); + } + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/player/AltioraAbility.java b/Common/src/main/java/at/petrak/hexcasting/api/player/AltioraAbility.java new file mode 100644 index 00000000..304a0212 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/player/AltioraAbility.java @@ -0,0 +1,10 @@ +package at.petrak.hexcasting.api.player; + +/** + * Note that this just keeps track of state, actually giving the player the elytra ability is handled + * differently per platform + * + * @param gracePeriod so the flight isn't immediately removed because the player started on the ground + */ +public record AltioraAbility(int gracePeriod) { +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/player/FlightAbility.java b/Common/src/main/java/at/petrak/hexcasting/api/player/FlightAbility.java index 55828a7e..7980a561 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/player/FlightAbility.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/player/FlightAbility.java @@ -4,8 +4,9 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; -public record FlightAbility(boolean allowed, int timeLeft, ResourceKey dimension, Vec3 origin, double radius) { - public static FlightAbility deny() { - return new FlightAbility(false, 0, Level.OVERWORLD, Vec3.ZERO, 0); - } +/** + * @param timeLeft sentinel of -1 for infinite + * @param radius sentinel of negative for infinite + */ +public record FlightAbility(int timeLeft, ResourceKey dimension, Vec3 origin, double radius) { } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/Action.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/Action.kt deleted file mode 100644 index 8f1095be..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/Action.kt +++ /dev/null @@ -1,93 +0,0 @@ -package at.petrak.hexcasting.api.spell - -import at.petrak.hexcasting.api.PatternRegistry -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.utils.asTranslatedComponent -import at.petrak.hexcasting.api.utils.lightPurple -import net.minecraft.network.chat.Component -import net.minecraft.resources.ResourceLocation -import net.minecraft.world.phys.Vec3 -import java.text.DecimalFormat - -/** - * Manipulates the stack in some way, usually by popping some number of values off the stack - * and pushing one new value. - * For a more "traditional" pop arguments, push return experience, see [ConstMediaAction]. - * - * Implementors MUST NOT mutate the context. - */ -interface Action { - /** - * Operate on the stack. Return the new stack and any side effects of the cast. - * - * Although this is passed a [MutableList], this is only for the convenience of implementors. - * It is a clone of the stack and modifying it does nothing. You must return the new stack - * with the [OperationResult]. - * - * A particle effect at the cast site and various messages and advancements are done automagically. - */ - fun operate( - continuation: SpellContinuation, - stack: MutableList, - ravenmind: Iota?, - ctx: CastingContext - ): OperationResult - - /** - * Do you need to be enlightened to use this operator? (i.e. is this operator a Great Pattern) - */ - val isGreat: Boolean get() = false - - /** - * Should this Great Pattern process and have side effects, even if its user isn't enlightened? - * - * The pattern itself may modify its effects based on whether the user is enlightened or not, regardless of what this value is. - */ - val alwaysProcessGreatSpell: Boolean get() = this is SpellAction - - /** - * Can this Great Pattern give you Blind Diversion? - */ - val causesBlindDiversion: Boolean get() = this is SpellAction - - /** - * The component for displaying this pattern's name. Override for dynamic patterns. - */ - val displayName: Component get() = "hexcasting.spell.${PatternRegistry.lookupPattern(this)}".asTranslatedComponent.lightPurple - - companion object { - // I see why vzakii did this: you can't raycast out to infinity! - const val MAX_DISTANCE: Double = 32.0 - const val MAX_DISTANCE_FROM_SENTINEL: Double = 16.0 - - @JvmStatic - fun raycastEnd(origin: Vec3, look: Vec3): Vec3 = - origin.add(look.normalize().scale(MAX_DISTANCE)) - - @JvmStatic - fun makeConstantOp(x: Iota): Action = object : ConstMediaAction { - override val argc: Int - get() = 0 - - override fun execute(args: List, ctx: CastingContext): List = - listOf(x) - } - - private val DOUBLE_FORMATTER = DecimalFormat("####.####") - - @JvmStatic - fun makeConstantOp(x: Double, key: ResourceLocation): Action = object : ConstMediaAction { - override val argc: Int - get() = 0 - - override fun execute(args: List, ctx: CastingContext): List = - x.asActionResult - - override val displayName: Component - get() = "hexcasting.spell.$key".asTranslatedComponent(DOUBLE_FORMATTER.format(x)).lightPurple - } - } -} - diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/RenderedSpell.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/RenderedSpell.kt deleted file mode 100644 index 5929aa71..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/RenderedSpell.kt +++ /dev/null @@ -1,7 +0,0 @@ -package at.petrak.hexcasting.api.spell - -import at.petrak.hexcasting.api.spell.casting.CastingContext - -interface RenderedSpell { - fun cast(ctx: CastingContext) -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/SpecialPatterns.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/SpecialPatterns.java deleted file mode 100644 index e784b87a..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/SpecialPatterns.java +++ /dev/null @@ -1,10 +0,0 @@ -package at.petrak.hexcasting.api.spell.casting; - -import at.petrak.hexcasting.api.spell.math.HexDir; -import at.petrak.hexcasting.api.spell.math.HexPattern; - -public final class SpecialPatterns { - public static final HexPattern INTROSPECTION = HexPattern.fromAngles("qqq", HexDir.WEST); - public static final HexPattern RETROSPECTION = HexPattern.fromAngles("eee", HexDir.EAST); - public static final HexPattern CONSIDERATION = HexPattern.fromAngles("qqqaw", HexDir.EAST); -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapAlreadyBrainswept.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapAlreadyBrainswept.kt deleted file mode 100644 index d23b1092..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapAlreadyBrainswept.kt +++ /dev/null @@ -1,25 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.misc.HexDamageSources -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.ParticleSpray -import at.petrak.hexcasting.api.spell.casting.CastingContext -import net.minecraft.world.entity.npc.Villager -import net.minecraft.world.item.DyeColor - -class MishapAlreadyBrainswept(val villager: Villager) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.GREEN) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - villager.hurt(HexDamageSources.overcastDamageFrom(ctx.caster), villager.health) - } - - override fun particleSpray(ctx: CastingContext) = - ParticleSpray.burst(villager.eyePosition, 1.0) - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("already_brainswept") - -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBrainsweep.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBrainsweep.kt deleted file mode 100644 index 7f121c18..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBrainsweep.kt +++ /dev/null @@ -1,27 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.misc.HexDamageSources -import at.petrak.hexcasting.api.spell.ParticleSpray -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.casting.CastingContext -import net.minecraft.core.BlockPos -import net.minecraft.world.entity.npc.Villager -import net.minecraft.world.item.DyeColor -import net.minecraft.world.phys.Vec3 - -class MishapBadBrainsweep(val villager: Villager, val pos: BlockPos) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.GREEN) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - trulyHurt(villager, HexDamageSources.overcastDamageFrom(ctx.caster), villager.health) - } - - override fun particleSpray(ctx: CastingContext): ParticleSpray { - return ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0) - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("bad_brainsweep", blockAtPos(ctx, this.pos)) -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDisallowedSpell.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDisallowedSpell.kt deleted file mode 100644 index 65da779f..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDisallowedSpell.kt +++ /dev/null @@ -1,21 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType -import net.minecraft.world.item.DyeColor - -class MishapDisallowedSpell(val type: String = "disallowed") : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.BLACK) - - override fun resolutionType(ctx: CastingContext) = ResolvedPatternType.INVALID - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - // NO-OP - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error(type, actionName(errorCtx.action)) -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEntityTooFarAway.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEntityTooFarAway.kt deleted file mode 100644 index 5eb5fab7..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEntityTooFarAway.kt +++ /dev/null @@ -1,21 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.iota.Iota -import net.minecraft.network.chat.Component -import net.minecraft.world.entity.Entity -import net.minecraft.world.item.DyeColor - -class MishapEntityTooFarAway(val entity: Entity) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.PINK) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - // Knock the player's items out of their hands - yeetHeldItemsTowards(ctx, entity.position()) - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component = - error("entity_too_far", entity.displayName, actionName(errorCtx.action)) -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapError.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapError.kt deleted file mode 100644 index 0f6d4666..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapError.kt +++ /dev/null @@ -1,18 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.casting.CastingContext -import net.minecraft.world.item.DyeColor - -class MishapError(val exception: Exception) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.BLACK) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - // NO-OP - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("unknown", actionName(errorCtx.action), exception) -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEvalTooDeep.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEvalTooDeep.kt deleted file mode 100644 index c118486f..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEvalTooDeep.kt +++ /dev/null @@ -1,18 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.casting.CastingContext -import net.minecraft.world.item.DyeColor - -class MishapEvalTooDeep : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.BLUE) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - ctx.caster.airSupply -= 290 - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("eval_too_deep") -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapImmuneEntity.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapImmuneEntity.kt deleted file mode 100644 index 793641f4..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapImmuneEntity.kt +++ /dev/null @@ -1,20 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.utils.aqua -import net.minecraft.world.entity.Entity -import net.minecraft.world.item.DyeColor - -class MishapImmuneEntity(val entity: Entity) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.BLUE) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - yeetHeldItemsTowards(ctx, entity.position()) - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("immune_entity", actionName(errorCtx.action), entity.displayName.plainCopy().aqua) -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidPattern.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidPattern.kt deleted file mode 100644 index f1bee32a..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidPattern.kt +++ /dev/null @@ -1,22 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType -import at.petrak.hexcasting.api.spell.iota.GarbageIota -import at.petrak.hexcasting.api.spell.iota.Iota -import net.minecraft.world.item.DyeColor - -class MishapInvalidPattern : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.YELLOW) - - override fun resolutionType(ctx: CastingContext) = ResolvedPatternType.INVALID - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - stack.add(GarbageIota()) - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("invalid_pattern") -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidSpellDatumType.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidSpellDatumType.kt deleted file mode 100644 index 49ea0825..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidSpellDatumType.kt +++ /dev/null @@ -1,21 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.casting.CastingContext -import net.minecraft.world.item.DyeColor - -/** - * this is bad - */ -class MishapInvalidSpellDatumType(val perpetrator: Any) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.BLACK) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - // NO-OP - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("invalid_spell_datum_type", this.perpetrator.toString(), this.perpetrator.javaClass.typeName) -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationInWrongDimension.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationInWrongDimension.kt deleted file mode 100644 index 865036da..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationInWrongDimension.kt +++ /dev/null @@ -1,24 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.iota.GarbageIota -import at.petrak.hexcasting.api.spell.iota.Iota -import net.minecraft.network.chat.Component -import net.minecraft.resources.ResourceLocation -import net.minecraft.world.item.DyeColor - -class MishapLocationInWrongDimension(val properDimension: ResourceLocation) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.MAGENTA) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - stack.add(GarbageIota()) - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component = - error( - "wrong_dimension", actionName(errorCtx.action!!), properDimension.toString(), - ctx.world.dimension().location().toString() - ) -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationTooFarAway.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationTooFarAway.kt deleted file mode 100644 index f22a4dcf..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationTooFarAway.kt +++ /dev/null @@ -1,21 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.iota.Vec3Iota -import net.minecraft.network.chat.Component -import net.minecraft.world.item.DyeColor -import net.minecraft.world.phys.Vec3 - -class MishapLocationTooFarAway(val location: Vec3, val type: String = "too_far") : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.MAGENTA) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - yeetHeldItemsTowards(ctx, location) - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component = - error("location_$type", Vec3Iota.display(location), actionName(errorCtx.action)) -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoAkashicRecord.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoAkashicRecord.kt deleted file mode 100644 index 66a323f2..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoAkashicRecord.kt +++ /dev/null @@ -1,19 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.casting.CastingContext -import net.minecraft.core.BlockPos -import net.minecraft.world.item.DyeColor - -class MishapNoAkashicRecord(val pos: BlockPos) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.PURPLE) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - ctx.caster.giveExperiencePoints(-100) - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("no_akashic_record", pos.toShortString()) -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNotEnoughArgs.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNotEnoughArgs.kt deleted file mode 100644 index e94b1542..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNotEnoughArgs.kt +++ /dev/null @@ -1,22 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.iota.GarbageIota -import at.petrak.hexcasting.api.spell.iota.Iota -import net.minecraft.world.item.DyeColor - -class MishapNotEnoughArgs(val expected: Int, val got: Int) : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.LIGHT_GRAY) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - repeat(expected - got) { stack.add(GarbageIota()) } - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - if (got == 0) - error("no_args", actionName(errorCtx.action), expected) - else - error("not_enough_args", actionName(errorCtx.action), expected, got) -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapShameOnYou.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapShameOnYou.kt deleted file mode 100644 index 8700cedf..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapShameOnYou.kt +++ /dev/null @@ -1,18 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.misc.HexDamageSources -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.iota.Iota -import net.minecraft.world.item.DyeColor - -class MishapShameOnYou() : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.BLACK) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - Mishap.trulyHurt(ctx.caster, HexDamageSources.SHAME, 69420f) - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = error("shame") -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapTooManyCloseParens.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapTooManyCloseParens.kt deleted file mode 100644 index 5420d090..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapTooManyCloseParens.kt +++ /dev/null @@ -1,20 +0,0 @@ -package at.petrak.hexcasting.api.spell.mishaps - -import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.iota.PatternIota -import net.minecraft.world.item.DyeColor - -class MishapTooManyCloseParens : Mishap() { - override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = - dyeColor(DyeColor.ORANGE) - - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - // TODO this is a kinda shitty mishap - stack.add(PatternIota(errorCtx.pattern)) - } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("too_many_close_parens") -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/utils/HexUtils.kt b/Common/src/main/java/at/petrak/hexcasting/api/utils/HexUtils.kt index 7f65b885..c0c9e041 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/utils/HexUtils.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/utils/HexUtils.kt @@ -2,15 +2,19 @@ package at.petrak.hexcasting.api.utils -import at.petrak.hexcasting.api.spell.iota.Iota -import at.petrak.hexcasting.api.spell.iota.ListIota -import at.petrak.hexcasting.api.spell.math.HexCoord +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.iota.ListIota +import at.petrak.hexcasting.api.casting.math.HexCoord import at.petrak.hexcasting.common.lib.hex.HexIotaTypes import net.minecraft.ChatFormatting +import net.minecraft.core.Registry import net.minecraft.nbt.* import net.minecraft.network.chat.Component import net.minecraft.network.chat.MutableComponent import net.minecraft.network.chat.Style +import net.minecraft.resources.ResourceKey +import net.minecraft.resources.ResourceLocation +import net.minecraft.tags.TagKey import net.minecraft.world.InteractionHand import net.minecraft.world.item.ItemStack import net.minecraft.world.phys.Vec2 @@ -272,3 +276,13 @@ fun Tag.downcast(type: TagType): T { } const val ERROR_COLOR = 0xff_f800f8.toInt() +fun isOfTag(registry: Registry, key: ResourceKey, tag: TagKey): Boolean { + val maybeHolder = registry.getHolder(key) + val holder = if (maybeHolder.isPresent) maybeHolder.get() else return false + return holder.`is`(tag) +} + +fun isOfTag(registry: Registry, loc: ResourceLocation, tag: TagKey): Boolean { + val key = ResourceKey.create(registry.key(), loc); + return isOfTag(registry, key, tag) +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/utils/PatternNameHelper.java b/Common/src/main/java/at/petrak/hexcasting/api/utils/PatternNameHelper.java deleted file mode 100644 index 1f05fc06..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/utils/PatternNameHelper.java +++ /dev/null @@ -1,28 +0,0 @@ -package at.petrak.hexcasting.api.utils; - -import at.petrak.hexcasting.api.PatternRegistry; -import at.petrak.hexcasting.api.spell.casting.SpecialPatterns; -import at.petrak.hexcasting.api.spell.iota.PatternIota; -import at.petrak.hexcasting.api.spell.math.HexPattern; -import net.minecraft.ChatFormatting; -import net.minecraft.network.chat.Component; - -public class PatternNameHelper { - - public static Component representationForPattern(HexPattern pattern) { - if (pattern.sigsEqual(SpecialPatterns.CONSIDERATION)) { - return Component.translatable("hexcasting.spell.hexcasting:escape").withStyle(ChatFormatting.LIGHT_PURPLE); - } else if (pattern.sigsEqual(SpecialPatterns.INTROSPECTION)) { - return Component.translatable("hexcasting.spell.hexcasting:open_paren").withStyle(ChatFormatting.LIGHT_PURPLE); - } else if (pattern.sigsEqual(SpecialPatterns.RETROSPECTION)) { - return Component.translatable("hexcasting.spell.hexcasting:close_paren").withStyle(ChatFormatting.LIGHT_PURPLE); - } - - var action = PatternRegistry.lookupPatternByShape(pattern); - if (action != null) { - return action.getDisplayName(); - } - - return new PatternIota(pattern).display(); // TODO: this should be merged into iota.display once Great Spells can be identified by name - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/client/ClientTickCounter.java b/Common/src/main/java/at/petrak/hexcasting/client/ClientTickCounter.java index 213b3433..e45ba756 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/ClientTickCounter.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/ClientTickCounter.java @@ -1,5 +1,6 @@ package at.petrak.hexcasting.client; +import at.petrak.hexcasting.client.render.GaslightingTracker; import net.minecraft.client.Minecraft; public class ClientTickCounter { @@ -7,7 +8,7 @@ public class ClientTickCounter { public static float partialTicks = 0.0F; public static float getTotal() { - return (float)ticksInGame + partialTicks; + return (float) ticksInGame + partialTicks; } public static void renderTickStart(float renderTickTime) { @@ -18,6 +19,7 @@ public class ClientTickCounter { if (!Minecraft.getInstance().isPaused()) { ++ticksInGame; partialTicks = 0.0F; + GaslightingTracker.postFrameCheckRendered(); } } } diff --git a/Common/src/main/java/at/petrak/hexcasting/client/PatternShapeMatcher.java b/Common/src/main/java/at/petrak/hexcasting/client/PatternShapeMatcher.java new file mode 100644 index 00000000..dbe366ce --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/client/PatternShapeMatcher.java @@ -0,0 +1,4 @@ +package at.petrak.hexcasting.client; + +public class PatternShapeMatcher { +} diff --git a/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java b/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java index 09e66e6a..8e953ec7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java @@ -1,66 +1,72 @@ package at.petrak.hexcasting.client; -import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus; -import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus; -import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry; import at.petrak.hexcasting.api.item.IotaHolderItem; import at.petrak.hexcasting.api.item.MediaHolderItem; import at.petrak.hexcasting.api.misc.MediaConstants; import at.petrak.hexcasting.api.utils.NBTHelper; -import at.petrak.hexcasting.client.be.BlockEntityAkashicBookshelfRenderer; -import at.petrak.hexcasting.client.be.BlockEntitySlateRenderer; import at.petrak.hexcasting.client.entity.WallScrollRenderer; +import at.petrak.hexcasting.client.render.GaslightingTracker; +import at.petrak.hexcasting.client.render.ScryingLensOverlays; +import at.petrak.hexcasting.client.render.be.BlockEntityAkashicBookshelfRenderer; +import at.petrak.hexcasting.client.render.be.BlockEntityQuenchedAllayRenderer; +import at.petrak.hexcasting.client.render.be.BlockEntitySlateRenderer; +import at.petrak.hexcasting.common.blocks.BlockQuenchedAllay; import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicBookshelf; import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicBookshelf; import at.petrak.hexcasting.common.entities.HexEntities; -import at.petrak.hexcasting.common.items.*; +import at.petrak.hexcasting.common.items.ItemStaff; import at.petrak.hexcasting.common.items.magic.ItemMediaBattery; import at.petrak.hexcasting.common.items.magic.ItemPackagedHex; +import at.petrak.hexcasting.common.items.storage.*; import at.petrak.hexcasting.common.lib.HexBlockEntities; import at.petrak.hexcasting.common.lib.HexBlocks; -import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; import at.petrak.hexcasting.common.lib.HexItems; +import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; import at.petrak.hexcasting.xplat.IClientXplatAbstractions; -import com.mojang.datafixers.util.Pair; -import net.minecraft.ChatFormatting; import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TextColor; -import net.minecraft.util.Mth; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.ComparatorMode; -import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; -import net.minecraft.world.level.block.state.properties.RailShape; -import net.minecraft.world.level.material.MaterialColor; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.function.BiConsumer; +import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.ToIntFunction; -import java.util.function.UnaryOperator; + +import static at.petrak.hexcasting.api.HexAPI.modLoc; public class RegisterClientStuff { + public static List QUENCHED_ALLAY_VARIANTS = new ArrayList<>(); + public static void init() { - registerDataHolderOverrides(HexItems.FOCUS, + registerSealableDataHolderOverrides(HexItems.FOCUS, stack -> HexItems.FOCUS.readIotaTag(stack) != null, ItemFocus::isSealed); - registerDataHolderOverrides(HexItems.SPELLBOOK, + registerSealableDataHolderOverrides(HexItems.SPELLBOOK, stack -> HexItems.SPELLBOOK.readIotaTag(stack) != null, ItemSpellbook::isSealed); + IClientXplatAbstractions.INSTANCE.registerItemProperty(HexItems.THOUGHT_KNOT, ItemThoughtKnot.WRITTEN_PRED, + (stack, level, holder, holderID) -> { + if (NBTHelper.contains(stack, ItemThoughtKnot.TAG_DATA)) { + return 1; + } else { + return 0; + } + }); registerPackagedSpellOverrides(HexItems.CYPHER); registerPackagedSpellOverrides(HexItems.TRINKET); @@ -93,6 +99,12 @@ public class RegisterClientStuff { registerWandOverrides(HexItems.STAFF_DARK_OAK); registerWandOverrides(HexItems.STAFF_ACACIA); registerWandOverrides(HexItems.STAFF_EDIFIED); + // purposely skip quenched + registerWandOverrides(HexItems.STAFF_MINDSPLICE); + + registerGaslight4(HexItems.STAFF_QUENCHED); + registerGaslight4(HexBlocks.QUENCHED_ALLAY.asItem()); + registerGaslight4(HexItems.QUENCHED_SHARD); x.setRenderLayer(HexBlocks.CONJURED_LIGHT, RenderType.cutout()); x.setRenderLayer(HexBlocks.CONJURED_BLOCK, RenderType.cutout()); @@ -106,6 +118,7 @@ public class RegisterClientStuff { x.setRenderLayer(HexBlocks.CITRINE_EDIFIED_LEAVES, RenderType.cutoutMipped()); x.setRenderLayer(HexBlocks.AKASHIC_RECORD, RenderType.translucent()); + x.setRenderLayer(HexBlocks.QUENCHED_ALLAY, RenderType.translucent()); x.registerEntityRenderer(HexEntities.WALL_SCROLL, WallScrollRenderer::new); @@ -117,13 +130,20 @@ public class RegisterClientStuff { // Minecraft.getInstance().getTextureManager().bindForSetup(tex); // } - addScryingLensStuff(); + ScryingLensOverlays.addScryingLensStuff(); + } + + private static void registerGaslight4(Item item) { + IClientXplatAbstractions.INSTANCE.registerItemProperty(item, + GaslightingTracker.GASLIGHTING_PRED, (stack, level, holder, holderID) -> + Math.abs(GaslightingTracker.getGaslightingAmount() % 4)); } public static void registerColorProviders(BiConsumer itemColorRegistry, - BiConsumer blockColorRegistry) { + BiConsumer blockColorRegistry) { itemColorRegistry.accept(makeIotaStorageColorizer(HexItems.FOCUS::getColor), HexItems.FOCUS); itemColorRegistry.accept(makeIotaStorageColorizer(HexItems.SPELLBOOK::getColor), HexItems.SPELLBOOK); + itemColorRegistry.accept(makeIotaStorageColorizer(HexItems.THOUGHT_KNOT::getColor), HexItems.THOUGHT_KNOT); blockColorRegistry.accept((bs, level, pos, idx) -> { if (!bs.getValue(BlockAkashicBookshelf.HAS_BOOKS) || level == null || pos == null) { @@ -156,154 +176,8 @@ public class RegisterClientStuff { }; } - private static void addScryingLensStuff() { - ScryingLensOverlayRegistry.addPredicateDisplayer( - (state, pos, observer, world, direction) -> state.getBlock() instanceof BlockAbstractImpetus, - (lines, state, pos, observer, world, direction) -> { - if (world.getBlockEntity(pos) instanceof BlockEntityAbstractImpetus beai) { - beai.applyScryingLensOverlay(lines, state, pos, observer, world, direction); - } - }); - - ScryingLensOverlayRegistry.addDisplayer(Blocks.NOTE_BLOCK, - (lines, state, pos, observer, world, direction) -> { - int note = state.getValue(NoteBlock.NOTE); - - float rCol = Math.max(0.0F, Mth.sin((note / 24F + 0.0F) * Mth.TWO_PI) * 0.65F + 0.35F); - float gCol = Math.max(0.0F, Mth.sin((note / 24F + 0.33333334F) * Mth.TWO_PI) * 0.65F + 0.35F); - float bCol = Math.max(0.0F, Mth.sin((note / 24F + 0.6666667F) * Mth.TWO_PI) * 0.65F + 0.35F); - - int noteColor = 0xFF_000000 | Mth.color(rCol, gCol, bCol); - - var instrument = state.getValue(NoteBlock.INSTRUMENT); - - lines.add(new Pair<>( - new ItemStack(Items.MUSIC_DISC_CHIRP), - Component.literal(String.valueOf(instrument.ordinal())) - .withStyle(color(instrumentColor(instrument))))); - lines.add(new Pair<>( - new ItemStack(Items.NOTE_BLOCK), - Component.literal(String.valueOf(note)) - .withStyle(color(noteColor)))); - }); - - ScryingLensOverlayRegistry.addDisplayer(HexBlocks.AKASHIC_BOOKSHELF, - (lines, state, pos, observer, world, direction) -> { - if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) { - var iotaTag = tile.getIotaTag(); - if (iotaTag != null) { - var display = HexIotaTypes.getDisplay(iotaTag); - lines.add(new Pair<>(new ItemStack(Items.BOOK), display)); - } - } - }); - - ScryingLensOverlayRegistry.addDisplayer(Blocks.COMPARATOR, - (lines, state, pos, observer, world, direction) -> { - int comparatorValue = ScryingLensOverlayRegistry.getComparatorValue(true); - lines.add(new Pair<>( - new ItemStack(Items.REDSTONE), - Component.literal(comparatorValue == -1 ? "" : String.valueOf(comparatorValue)) - .withStyle(redstoneColor(comparatorValue)))); - - boolean compare = state.getValue(ComparatorBlock.MODE) == ComparatorMode.COMPARE; - - lines.add(new Pair<>( - new ItemStack(Items.REDSTONE_TORCH), - Component.literal(compare ? ">=" : "-") - .withStyle(redstoneColor(compare ? 0 : 15)))); - }); - - ScryingLensOverlayRegistry.addDisplayer(Blocks.POWERED_RAIL, - (lines, state, pos, observer, world, direction) -> { - int power = getPoweredRailStrength(world, pos, state); - lines.add(new Pair<>( - new ItemStack(Items.POWERED_RAIL), - Component.literal(String.valueOf(power)) - .withStyle(redstoneColor(power, 9)))); - }); - - ScryingLensOverlayRegistry.addDisplayer(Blocks.REPEATER, - (lines, state, pos, observer, world, direction) -> lines.add(new Pair<>( - new ItemStack(Items.CLOCK), - Component.literal(String.valueOf(state.getValue(RepeaterBlock.DELAY))) - .withStyle(ChatFormatting.YELLOW)))); - - ScryingLensOverlayRegistry.addPredicateDisplayer( - (state, pos, observer, world, direction) -> state.getBlock() instanceof BeehiveBlock, - (lines, state, pos, observer, world, direction) -> { - int count = ScryingLensOverlayRegistry.getBeeValue(); - lines.add(new Pair<>(new ItemStack(Items.BEE_NEST), count == -1 ? Component.empty() : - Component.translatable( - "hexcasting.tooltip.lens.bee" + (count == 1 ? ".single" : ""), - count - ))); - }); - - ScryingLensOverlayRegistry.addPredicateDisplayer( - (state, pos, observer, world, direction) -> state.isSignalSource() && !state.is( - Blocks.COMPARATOR), - (lines, state, pos, observer, world, direction) -> { - int signalStrength = 0; - if (state.getBlock() instanceof RedStoneWireBlock) { - signalStrength = state.getValue(RedStoneWireBlock.POWER); - } else { - for (Direction dir : Direction.values()) { - signalStrength = Math.max(signalStrength, state.getSignal(world, pos, dir)); - } - } - - lines.add(0, new Pair<>( - new ItemStack(Items.REDSTONE), - Component.literal(String.valueOf(signalStrength)) - .withStyle(redstoneColor(signalStrength)))); - }); - - ScryingLensOverlayRegistry.addPredicateDisplayer( - (state, pos, observer, world, direction) -> state.hasAnalogOutputSignal(), - (lines, state, pos, observer, world, direction) -> { - int comparatorValue = ScryingLensOverlayRegistry.getComparatorValue(false); - lines.add( - new Pair<>( - new ItemStack(Items.COMPARATOR), - Component.literal(comparatorValue == -1 ? "" : String.valueOf(comparatorValue)) - .withStyle(redstoneColor(comparatorValue)))); - }); - } - - private static UnaryOperator