From 817e610100599a682a341861c31108e780bbab6d Mon Sep 17 00:00:00 2001 From: direwolf20 <39863894+Direwolf20-MC@users.noreply.github.com> Date: Sat, 11 May 2024 13:28:56 -0400 Subject: [PATCH] It Loads! --- .../2e50376a258ceefdeaf48c21f919aaa551c1fbe8 | 2 +- .../560c5d1147eb8b61b5d489f37c738096153f5af2 | 2 +- .../59eb3dbb5f86130e09b3c62d89b9525ee01cf52d | 4 +- .../9132d71273a5f64d33baabb967ce14786e2e3b23 | 2 +- .../94a08339dfe16979d23f9d4e0445c75f17e0bb9b | 2 +- .../9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e | 110 +++++----- .../recipes/misc/modificationtable.json | 4 +- .../recipes/misc/upgrade_battery_1.json | 4 +- .../recipes/misc/upgrade_battery_2.json | 8 +- .../recipes/misc/upgrade_battery_3.json | 8 +- .../recipes/misc/upgrade_efficiency_1.json | 4 +- .../recipes/misc/upgrade_efficiency_2.json | 8 +- .../recipes/misc/upgrade_efficiency_3.json | 8 +- .../recipes/misc/upgrade_efficiency_4.json | 8 +- .../recipes/misc/upgrade_efficiency_5.json | 8 +- .../recipes/misc/upgrade_empty.json | 2 +- .../recipes/misc/upgrade_fortune_1.json | 4 +- .../recipes/misc/upgrade_fortune_2.json | 8 +- .../recipes/misc/upgrade_fortune_3.json | 8 +- .../recipes/misc/upgrade_freezing.json | 4 +- .../recipes/misc/upgrade_light_placer.json | 4 +- .../recipes/misc/upgrade_magnet.json | 4 +- .../recipes/misc/upgrade_range_1.json | 4 +- .../recipes/misc/upgrade_range_2.json | 8 +- .../recipes/misc/upgrade_range_3.json | 8 +- .../recipes/misc/upgrade_silk.json | 4 +- .../recipes/misc/upgrade_size_1.json | 4 +- .../recipes/misc/upgrade_size_2.json | 8 +- .../recipes/misc/upgrade_size_3.json | 12 +- .../recipes/misc/upgrade_void_junk.json | 4 +- .../recipes/tools/mininggadget.json | 4 +- .../recipes/tools/mininggadget_fancy.json | 4 +- .../recipes/tools/mininggadget_simple.json | 4 +- .../loot_tables/blocks/minerslight.json | 4 + .../loot_tables/blocks/renderblock.json | 4 + .../mininggadgets/recipes/mininggadget.json | 11 +- .../recipes/mininggadget_fancy.json | 11 +- .../recipes/mininggadget_simple.json | 11 +- .../recipes/modificationtable.json | 7 +- .../recipes/upgrade_battery_1.json | 3 +- .../recipes/upgrade_battery_2.json | 5 +- .../recipes/upgrade_battery_3.json | 5 +- .../recipes/upgrade_efficiency_1.json | 5 +- .../recipes/upgrade_efficiency_2.json | 5 +- .../recipes/upgrade_efficiency_3.json | 5 +- .../recipes/upgrade_efficiency_4.json | 5 +- .../recipes/upgrade_efficiency_5.json | 3 +- .../mininggadgets/recipes/upgrade_empty.json | 11 +- .../recipes/upgrade_fortune_1.json | 3 +- .../recipes/upgrade_fortune_2.json | 3 +- .../recipes/upgrade_fortune_3.json | 3 +- .../recipes/upgrade_freezing.json | 3 +- .../recipes/upgrade_light_placer.json | 3 +- .../mininggadgets/recipes/upgrade_magnet.json | 9 +- .../recipes/upgrade_range_1.json | 3 +- .../recipes/upgrade_range_2.json | 3 +- .../recipes/upgrade_range_3.json | 3 +- .../mininggadgets/recipes/upgrade_silk.json | 7 +- .../mininggadgets/recipes/upgrade_size_1.json | 5 +- .../mininggadgets/recipes/upgrade_size_2.json | 5 +- .../mininggadgets/recipes/upgrade_size_3.json | 7 +- .../recipes/upgrade_void_junk.json | 7 +- .../client/MiningGadgetsJEI.java | 3 +- .../mininggadgets/client/OurKeys.java | 4 +- .../client/events/EventRenderGadget.java | 4 +- .../client/particles/ModParticles.java | 9 +- .../particles/ParticleRenderDispatcher.java | 4 +- .../laserparticle/LaserParticleData.java | 81 ++++---- .../laserparticle/LaserParticleType.java | 21 +- .../playerparticle/PlayerParticleData.java | 192 ++++++++++++------ .../playerparticle/PlayerParticleType.java | 27 ++- .../client/renderer/RenderMiningLaser.java | 17 +- .../client/screens/FilterScreen.java | 2 +- .../client/screens/MiningSettingScreen.java | 18 +- .../client/screens/MiningVisualsScreen.java | 18 +- .../screens/ModificationTableScreen.java | 10 +- .../mininggadgets/common/MiningGadgets.java | 9 +- .../common/blocks/ModificationTable.java | 7 +- .../common/blocks/RenderBlock.java | 9 +- .../common/capabilities/EnergisedItem.java | 7 +- .../capabilities/EnergyStorageItemstack.java | 90 ++++++++ .../containers/ModificationTableCommands.java | 6 +- .../mininggadgets/common/data/Generator.java | 14 +- .../common/data/GeneratorBlockStates.java | 8 - .../common/data/GeneratorLoot.java | 50 ++--- .../common/data/GeneratorRecipes.java | 7 +- .../common/events/ServerTickHandler.java | 18 +- .../common/items/MiningGadget.java | 78 ++++--- .../common/items/UpgradeCard.java | 11 +- .../common/items/gadget/MiningProperties.java | 175 +++++++--------- .../common/items/upgrade/UpgradeTools.java | 143 +++++++------ .../common/network/PacketHandler.java | 38 ++-- .../network/data/ChangeBreakTypePayload.java | 19 +- .../network/data/ChangeColorPayload.java | 34 +--- .../data/ChangeFreezeDelayPayload.java | 20 +- .../data/ChangeMiningSizeModePayload.java | 19 +- .../network/data/ChangeMiningSizePayload.java | 19 +- .../network/data/ChangeRangePayload.java | 20 +- .../network/data/ChangeVolumePayload.java | 20 +- .../network/data/DurabilitySyncPayload.java | 53 ++--- .../network/data/ExtractUpgradePayload.java | 26 ++- .../common/network/data/GhostSlotPayload.java | 24 +-- .../network/data/InsertUpgradePayload.java | 23 +-- .../data/OpenFilterContainerPayload.java | 19 +- .../network/data/ToggleFiltersPayload.java | 19 +- .../network/data/TogglePrecisionPayload.java | 19 +- .../network/data/UpdateUpgradePayload.java | 20 +- .../handler/PacketChangeBreakType.java | 13 +- .../network/handler/PacketChangeColor.java | 20 +- .../handler/PacketChangeFreezeDelay.java | 13 +- .../handler/PacketChangeMiningSize.java | 13 +- .../handler/PacketChangeMiningSizeMode.java | 13 +- .../network/handler/PacketChangeRange.java | 13 +- .../network/handler/PacketChangeVolume.java | 13 +- .../network/handler/PacketDurabilitySync.java | 14 +- .../network/handler/PacketExtractUpgrade.java | 15 +- .../network/handler/PacketGhostSlot.java | 13 +- .../network/handler/PacketInsertUpgrade.java | 14 +- .../handler/PacketOpenFilterContainer.java | 21 +- .../network/handler/PacketToggleFilters.java | 13 +- .../handler/PacketTogglePrecision.java | 13 +- .../network/handler/PacketUpdateUpgrade.java | 14 +- .../tiles/ModificationTableTileEntity.java | 26 +-- .../common/tiles/RenderBlockTileEntity.java | 34 ++-- .../common/util/CodecHelpers.java | 78 +++++++ .../common/util/MGDataComponents.java | 55 +++++ .../mininggadgets/setup/ClientSetup.java | 17 +- .../mininggadgets/setup/Config.java | 12 +- .../mininggadgets/setup/ModSetup.java | 5 +- .../mininggadgets/setup/Registration.java | 2 + 130 files changed, 1201 insertions(+), 1116 deletions(-) create mode 100644 src/generated/resources/data/mininggadgets/loot_tables/blocks/minerslight.json create mode 100644 src/generated/resources/data/mininggadgets/loot_tables/blocks/renderblock.json create mode 100644 src/main/java/com/direwolf20/mininggadgets/common/capabilities/EnergyStorageItemstack.java create mode 100644 src/main/java/com/direwolf20/mininggadgets/common/util/CodecHelpers.java create mode 100644 src/main/java/com/direwolf20/mininggadgets/common/util/MGDataComponents.java diff --git a/src/generated/resources/.cache/2e50376a258ceefdeaf48c21f919aaa551c1fbe8 b/src/generated/resources/.cache/2e50376a258ceefdeaf48c21f919aaa551c1fbe8 index e690b333..bf42ebd6 100644 --- a/src/generated/resources/.cache/2e50376a258ceefdeaf48c21f919aaa551c1fbe8 +++ b/src/generated/resources/.cache/2e50376a258ceefdeaf48c21f919aaa551c1fbe8 @@ -1,4 +1,4 @@ -// 1.20.4 2024-02-15T21:19:22.3012844 Item Models +// 1.20.6 2024-05-11T13:25:30.0391409 Item Models 8da37fe8fa2b785fbf0633e3d25dfc8502305df3 assets/mininggadgets/models/item/minerslight.json 6e083fdcfbbe3ace1ce88136cfe9d68bf07c5490 assets/mininggadgets/models/item/modificationtable.json 00d58751e2423f4999a59ca9019b15100de3da1b assets/mininggadgets/models/item/upgrade_battery_1.json diff --git a/src/generated/resources/.cache/560c5d1147eb8b61b5d489f37c738096153f5af2 b/src/generated/resources/.cache/560c5d1147eb8b61b5d489f37c738096153f5af2 index ea2007a6..647bb9fa 100644 --- a/src/generated/resources/.cache/560c5d1147eb8b61b5d489f37c738096153f5af2 +++ b/src/generated/resources/.cache/560c5d1147eb8b61b5d489f37c738096153f5af2 @@ -1,2 +1,2 @@ -// 1.20.4 2024-02-15T21:19:22.3027857 Languages: en_us for mod: mininggadgets +// 1.20.6 2024-05-11T13:25:30.0411425 Languages: en_us for mod: mininggadgets e818e2aea1f0fc0b2317b97b5679d8eebc239abb assets/mininggadgets/lang/en_us.json diff --git a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d index 8244e501..e2c72996 100644 --- a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d +++ b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d @@ -1,2 +1,4 @@ -// 1.20.4 2024-02-15T21:19:22.3047873 Loot Tables +// 1.20.6 2024-05-11T13:25:30.043646 Loot Tables +df030720e5de655cb2bcf400a7dd5b4295ca8286 data/mininggadgets/loot_tables/blocks/minerslight.json b0114caa0db068619f8d048678afab221aa33db5 data/mininggadgets/loot_tables/blocks/modificationtable.json +7901c0f2a3f7693ebaea10cda8c580bcd78d027d data/mininggadgets/loot_tables/blocks/renderblock.json diff --git a/src/generated/resources/.cache/9132d71273a5f64d33baabb967ce14786e2e3b23 b/src/generated/resources/.cache/9132d71273a5f64d33baabb967ce14786e2e3b23 index 7ef0357a..fea0877e 100644 --- a/src/generated/resources/.cache/9132d71273a5f64d33baabb967ce14786e2e3b23 +++ b/src/generated/resources/.cache/9132d71273a5f64d33baabb967ce14786e2e3b23 @@ -1,2 +1,2 @@ -// 1.20.4 2024-02-15T21:19:22.304287 Tags for minecraft:block mod id mininggadgets +// 1.20.6 2024-05-11T13:25:30.0431441 Tags for minecraft:block mod id mininggadgets 1e3063ee4193a81550f3187aefa0924b9cfd6ba3 data/minecraft/tags/blocks/mineable/pickaxe.json diff --git a/src/generated/resources/.cache/94a08339dfe16979d23f9d4e0445c75f17e0bb9b b/src/generated/resources/.cache/94a08339dfe16979d23f9d4e0445c75f17e0bb9b index fdb28a96..1e2c9409 100644 --- a/src/generated/resources/.cache/94a08339dfe16979d23f9d4e0445c75f17e0bb9b +++ b/src/generated/resources/.cache/94a08339dfe16979d23f9d4e0445c75f17e0bb9b @@ -1,4 +1,4 @@ -// 1.20.4 2024-02-15T21:19:22.3037865 Block States: mininggadgets +// 1.20.6 2024-05-11T13:25:30.0421443 Block States: mininggadgets d1a6662ff63880ec364d02b06c4c547d529bb8fe assets/mininggadgets/blockstates/minerslight.json 7c14a211cba596fc721c75f74f9d6f38b660a610 assets/mininggadgets/blockstates/modificationtable.json 58d4442f56c89d6f160a1104d74f3084e370d6d0 assets/mininggadgets/blockstates/renderblock.json diff --git a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e index 00d61907..c7e4f022 100644 --- a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -1,55 +1,55 @@ -// 1.20.4 2024-02-15T21:19:22.3052877 Recipes -64586512af251a3c92705e59f7bfa0de0545b6d7 data/mininggadgets/advancements/recipes/misc/modificationtable.json -55266ee00365ec07b6961e14db0491298bb3f1fb data/mininggadgets/advancements/recipes/misc/upgrade_battery_1.json -ed195c156fcb17f1f40c5cece24f517b00a9a0ef data/mininggadgets/advancements/recipes/misc/upgrade_battery_2.json -e7bf93b34851f7bd20c0faa41b6c51526a3fe9cb data/mininggadgets/advancements/recipes/misc/upgrade_battery_3.json -6b37615f759119d0eb24fc83e215fd2271179cb3 data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_1.json -321d1b85085bac40bce99712ad07e98712b27410 data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_2.json -b0bb914b492b32a3bb67cc9a0280bddcec8e476a data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_3.json -a4b63db5d8fcb172abccfb3c3bd8adf89963e5bd data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_4.json -a4804ea47fb1f377b9b131baf312e7e2f1367724 data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_5.json -b73e0f64a43763a6ac0407e78b6899ef892fef64 data/mininggadgets/advancements/recipes/misc/upgrade_empty.json -1c55100e0801639f91f9da3e0f40a25644280f7f data/mininggadgets/advancements/recipes/misc/upgrade_fortune_1.json -a2dc85ab99d194dfc99c0235abda493b076af3ed data/mininggadgets/advancements/recipes/misc/upgrade_fortune_2.json -c1430d33c3de2ce2613930a84d4b8ad24de46f9e data/mininggadgets/advancements/recipes/misc/upgrade_fortune_3.json -6d70da60d6303e4d0f0f99736720fc3b98c7d8d4 data/mininggadgets/advancements/recipes/misc/upgrade_freezing.json -64387725f7f484f6dbe1a436520c498cc2941efb data/mininggadgets/advancements/recipes/misc/upgrade_light_placer.json -b6798e6973c34eba587f1b2285f50c9775d3bb7b data/mininggadgets/advancements/recipes/misc/upgrade_magnet.json -ad9ca11c143e918ed79dceb87128aa38522b6be9 data/mininggadgets/advancements/recipes/misc/upgrade_range_1.json -8b6510adbd5f653ac6833f9c189327f2f82daaa9 data/mininggadgets/advancements/recipes/misc/upgrade_range_2.json -5fee8433421f9c1a9e64bb7e7beef46be8e508fe data/mininggadgets/advancements/recipes/misc/upgrade_range_3.json -7b2292771a9b52ac2e18f218460aeec3dd1ea02d data/mininggadgets/advancements/recipes/misc/upgrade_silk.json -215f2b5949305ff749ed79687c667e4e92f919f0 data/mininggadgets/advancements/recipes/misc/upgrade_size_1.json -2cf1c196da10a6334f9db5b3243ee4c0e5d0c662 data/mininggadgets/advancements/recipes/misc/upgrade_size_2.json -05138a99a7018b6727c325f23602fac0ccb0e5fd data/mininggadgets/advancements/recipes/misc/upgrade_size_3.json -07f1c858827ef038e52ddfb8110648bdbb9b40b2 data/mininggadgets/advancements/recipes/misc/upgrade_void_junk.json -5cfa0f69976269a43e9aa3bdec2482eed40dbed8 data/mininggadgets/advancements/recipes/tools/mininggadget.json -96744355dff165d924657f4b58fcd24582e69b38 data/mininggadgets/advancements/recipes/tools/mininggadget_fancy.json -2ef41116a880ca71dee4b0f57c8afd814b67cbf9 data/mininggadgets/advancements/recipes/tools/mininggadget_simple.json -71a4834828a1e00f997dfd65ce4f6c2fea694efc data/mininggadgets/recipes/mininggadget.json -a3dc345a8244eb25af74276645c162bb28266129 data/mininggadgets/recipes/mininggadget_fancy.json -a5af2fc42d0fd75470ce35d7d97b855a9e3afa91 data/mininggadgets/recipes/mininggadget_simple.json -3a5a14972d26ed816f59bc41fe4e8e4acd47d4e7 data/mininggadgets/recipes/modificationtable.json -b6a1b64d09dd808b815ac1be45abb98894ddc410 data/mininggadgets/recipes/upgrade_battery_1.json -ef9a20896eec861498ffb3ed3bdc0770ed83e943 data/mininggadgets/recipes/upgrade_battery_2.json -e1e1bafd3bff3cac7e15e6affbb0a0e3ff8ecf83 data/mininggadgets/recipes/upgrade_battery_3.json -6743198ca5bd38c5fa77f1b44b008932fc2ac11f data/mininggadgets/recipes/upgrade_efficiency_1.json -2dda23fc9227899be6b4e7d370d596c303e92a85 data/mininggadgets/recipes/upgrade_efficiency_2.json -41f76f1571d4a9b4b96367b638664925ac21bf37 data/mininggadgets/recipes/upgrade_efficiency_3.json -e9dc917528a3f32eb6910f872505f469dd80f211 data/mininggadgets/recipes/upgrade_efficiency_4.json -611880b306770b33b3ad4002e5a15ea05c5e331f data/mininggadgets/recipes/upgrade_efficiency_5.json -ed9188fd12077c4181f9580c8ab6d2a8a353b250 data/mininggadgets/recipes/upgrade_empty.json -1ab9a33a83aeaade81ec2a2138e402ca125bbe04 data/mininggadgets/recipes/upgrade_fortune_1.json -ab171a00aa72e8e28775c031ab660da7063affd8 data/mininggadgets/recipes/upgrade_fortune_2.json -9c57c331ac7b3234b9b69ce7e0a582b1dcddad18 data/mininggadgets/recipes/upgrade_fortune_3.json -30988a33caf63a7afaf55dd7bb78bace84e1c9ab data/mininggadgets/recipes/upgrade_freezing.json -cdcbaa4b0358867ae23e23f39027f2640ad2979c data/mininggadgets/recipes/upgrade_light_placer.json -b30ba5b56d1dc12032beaf99b760a78806c6020d data/mininggadgets/recipes/upgrade_magnet.json -d9ebb234e5df182f7f18e7cf3c3fa25a7db4bb15 data/mininggadgets/recipes/upgrade_range_1.json -59500b82f052327417609cb83e125bbae71ce611 data/mininggadgets/recipes/upgrade_range_2.json -c3d114c54bd51ee2fb17caa2045055900aab59a4 data/mininggadgets/recipes/upgrade_range_3.json -4aea6947fc633af9d60143e91dec0c737c420e63 data/mininggadgets/recipes/upgrade_silk.json -10fe1524ad9e352187edd62f44a96c3a517cc4e2 data/mininggadgets/recipes/upgrade_size_1.json -43a6f221144db07dfb24edb62db18e7738b639c2 data/mininggadgets/recipes/upgrade_size_2.json -bca429ba351a75a1856c5426de2b9b09bd969e5c data/mininggadgets/recipes/upgrade_size_3.json -42d8b4df35d1239062a2371aada2e6a030b21069 data/mininggadgets/recipes/upgrade_void_junk.json +// 1.20.6 2024-05-11T13:25:30.0441458 Recipes +0c4917b1c62f21c0508368eef5c80deb32f5e648 data/mininggadgets/advancements/recipes/misc/modificationtable.json +86319199f6719071651efaf245bf89d0e96502a0 data/mininggadgets/advancements/recipes/misc/upgrade_battery_1.json +4655429a1b29d879cbd745f3060b829a6fe65479 data/mininggadgets/advancements/recipes/misc/upgrade_battery_2.json +98a3ea043b395dd3cd619cb52ed5d87a2a8564b5 data/mininggadgets/advancements/recipes/misc/upgrade_battery_3.json +f947cbd1a252b26382797b676b3aaec35de53ec9 data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_1.json +cf9b2f4ceea317e69cea60f362daca6dddbfca34 data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_2.json +ee7abc4049f1949c7efc4f64dd3a669990a78b80 data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_3.json +6864f4bcaa7a59fbdc71f54784e7eedd314da2c8 data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_4.json +4840c03b9d1509e1209fcf8f9b815cde6e266902 data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_5.json +4a5cd5300bbf3fe495abbb590e56734d5b4dda39 data/mininggadgets/advancements/recipes/misc/upgrade_empty.json +7cb7942c5068e5bb82dc9fe87f031b73f9cad770 data/mininggadgets/advancements/recipes/misc/upgrade_fortune_1.json +90c9f3895ae2ced561221d923dd9babcefa72ce6 data/mininggadgets/advancements/recipes/misc/upgrade_fortune_2.json +d0792a490963fbbe184878ee32af7791335b68d9 data/mininggadgets/advancements/recipes/misc/upgrade_fortune_3.json +9ff29973376e95e3c27debeaf96eb77f752ddadf data/mininggadgets/advancements/recipes/misc/upgrade_freezing.json +bea7db9c08f22d9c31738fe660c702c7f3267e4f data/mininggadgets/advancements/recipes/misc/upgrade_light_placer.json +2dd54aa3a8787cdc33573a36ebff9dae001372bf data/mininggadgets/advancements/recipes/misc/upgrade_magnet.json +c64a3080c8480301778652f9ac5ba65e07a1435d data/mininggadgets/advancements/recipes/misc/upgrade_range_1.json +7ce2db85bbc0452014f423c4786ae791d0a31119 data/mininggadgets/advancements/recipes/misc/upgrade_range_2.json +aec54d95a422ceebe5650352048d51852fe7a209 data/mininggadgets/advancements/recipes/misc/upgrade_range_3.json +b5facc09cbb14ffc28293c5b94e4fa35f6911dcd data/mininggadgets/advancements/recipes/misc/upgrade_silk.json +a392db915268490e8494ad2fa9651396e620b28d data/mininggadgets/advancements/recipes/misc/upgrade_size_1.json +747c92d4333725a259ce3e9e15d8b7586e6a1756 data/mininggadgets/advancements/recipes/misc/upgrade_size_2.json +1273bc114ff9ae47de38078fc8ab2fa932bc4c72 data/mininggadgets/advancements/recipes/misc/upgrade_size_3.json +a2317fc3cffd0fbb3b70e862ad7e62bb4ed21920 data/mininggadgets/advancements/recipes/misc/upgrade_void_junk.json +22b1e1e36175ff92fcb53be4c01a9b6d0a2848b7 data/mininggadgets/advancements/recipes/tools/mininggadget.json +a58bd6594cc813a99dee718b4f475c6f09a31c17 data/mininggadgets/advancements/recipes/tools/mininggadget_fancy.json +8a79ed93503f6600f8910f345cc83662b54c5232 data/mininggadgets/advancements/recipes/tools/mininggadget_simple.json +79fc75c088ff749a730df7cbcc74da7678343ad4 data/mininggadgets/recipes/mininggadget.json +8cd99a08707bd59f8c0fdfa3cdadbe5b939ce150 data/mininggadgets/recipes/mininggadget_fancy.json +dbe225947da913d0efee2bf30b17720ffb0be75b data/mininggadgets/recipes/mininggadget_simple.json +4a11a29e0d41e2266a94d6320226e3ca3b9b7f42 data/mininggadgets/recipes/modificationtable.json +eb98ef04875899c5fb5b99ea598d3a23d2f7603c data/mininggadgets/recipes/upgrade_battery_1.json +38485e90ce0e55d74b1d31214ed383dd8f69f0dc data/mininggadgets/recipes/upgrade_battery_2.json +f11d45725cf6d1223de8167b2e0d1dd9525721b7 data/mininggadgets/recipes/upgrade_battery_3.json +49797b6c8079cb47b6008d685dffe93cb4639a47 data/mininggadgets/recipes/upgrade_efficiency_1.json +284c73627ec90b68fc014c658bc9ab7ff22d08db data/mininggadgets/recipes/upgrade_efficiency_2.json +8946a2103d4b2b91987217988759a4114662149d data/mininggadgets/recipes/upgrade_efficiency_3.json +3c85b95d398b292d350cf8a826945b70ec102fa5 data/mininggadgets/recipes/upgrade_efficiency_4.json +dda3e28346d620fffb03baa028bd76e6da4739d1 data/mininggadgets/recipes/upgrade_efficiency_5.json +2ce6c5e8cb0fe3c70d6654647082a7cac8519a73 data/mininggadgets/recipes/upgrade_empty.json +53cf79b5d55b82e77b790fe7c0d7b31b059c15a0 data/mininggadgets/recipes/upgrade_fortune_1.json +aef3971ca5446fa20be54606c1c1b378a4d8185b data/mininggadgets/recipes/upgrade_fortune_2.json +d3b7ccacbb115ef3840e7b7b1a5a3bf2050d4094 data/mininggadgets/recipes/upgrade_fortune_3.json +4fb0f6f7a6b018965f5f9392f438a8be788d41ea data/mininggadgets/recipes/upgrade_freezing.json +dadc976fc1a4ef668141e9fd4c5225caf8e54dd6 data/mininggadgets/recipes/upgrade_light_placer.json +b8a86cc91f8a6f7f3929f0f2005e65618efd5661 data/mininggadgets/recipes/upgrade_magnet.json +3567d1074f674cfb53803a3946a6a557914247d2 data/mininggadgets/recipes/upgrade_range_1.json +80e23b7bb7fee3ed5537aaf6e59998573adedeb5 data/mininggadgets/recipes/upgrade_range_2.json +c133c3f6970a68da24ce1e65837778992ef90578 data/mininggadgets/recipes/upgrade_range_3.json +5c92e742ccbfd1288437bbc82f9f8004bdf73500 data/mininggadgets/recipes/upgrade_silk.json +cb59ca862f585563e623e2d93aa01f24bf43704f data/mininggadgets/recipes/upgrade_size_1.json +ee4db8659fa07b87b3b062df838f2176db4f5833 data/mininggadgets/recipes/upgrade_size_2.json +1c7308a3d7938b0af0369b984c49de696b530baa data/mininggadgets/recipes/upgrade_size_3.json +aa1eb8206c8a3ce7863c4b058a80f347838f1087 data/mininggadgets/recipes/upgrade_void_junk.json diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/modificationtable.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/modificationtable.json index ce33bd11..17e5ec80 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/modificationtable.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/modificationtable.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_1.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_1.json index 2192d611..95d7d3cd 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_1.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_1.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_2.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_2.json index a49f689f..be1b9f50 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_2.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_2.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_battery_1" - ] + "items": "mininggadgets:upgrade_battery_1" } ] }, @@ -23,9 +21,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_3.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_3.json index bca3e2fb..097e42d4 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_3.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_battery_3.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_battery_2" - ] + "items": "mininggadgets:upgrade_battery_2" } ] }, @@ -23,9 +21,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_1.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_1.json index 7c646249..decadbe9 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_1.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_1.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_2.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_2.json index baf94e0a..192dbd01 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_2.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_2.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_efficiency_1" - ] + "items": "mininggadgets:upgrade_efficiency_1" } ] }, @@ -23,9 +21,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_3.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_3.json index fe12f7c2..3b68af39 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_3.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_3.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_efficiency_2" - ] + "items": "mininggadgets:upgrade_efficiency_2" } ] }, @@ -23,9 +21,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_4.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_4.json index 044df0f3..f0481d63 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_4.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_4.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_efficiency_3" - ] + "items": "mininggadgets:upgrade_efficiency_3" } ] }, @@ -23,9 +21,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_5.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_5.json index bc62351f..67862f21 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_5.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_efficiency_5.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_efficiency_4" - ] + "items": "mininggadgets:upgrade_efficiency_4" } ] }, @@ -23,9 +21,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_empty.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_empty.json index 16315641..f28a0093 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_empty.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_empty.json @@ -5,7 +5,7 @@ "conditions": { "items": [ { - "tag": "forge:gems/diamond" + "items": "#c:gems/diamond" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_1.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_1.json index c6ca63eb..ea3e6f1b 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_1.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_1.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_2.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_2.json index 04c79fd2..df410f70 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_2.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_2.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_fortune_1" - ] + "items": "mininggadgets:upgrade_fortune_1" } ] }, @@ -23,9 +21,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_3.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_3.json index e399e980..4918372a 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_3.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_fortune_3.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_fortune_2" - ] + "items": "mininggadgets:upgrade_fortune_2" } ] }, @@ -23,9 +21,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_freezing.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_freezing.json index 3495f83d..d02afe8a 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_freezing.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_freezing.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_light_placer.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_light_placer.json index 78275dfa..45ff0019 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_light_placer.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_light_placer.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_magnet.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_magnet.json index 71f93fb8..bcb82948 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_magnet.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_magnet.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_1.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_1.json index 67aa7e79..dc493e44 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_1.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_1.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_2.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_2.json index a4194e24..4015c1c2 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_2.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_2.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_range_1" - ] + "items": "mininggadgets:upgrade_range_1" } ] }, @@ -23,9 +21,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_3.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_3.json index 8d3cb690..62a24e76 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_3.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_range_3.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_range_2" - ] + "items": "mininggadgets:upgrade_range_2" } ] }, @@ -23,9 +21,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_silk.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_silk.json index fbbac4a1..4883ff34 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_silk.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_silk.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_1.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_1.json index 0de9d6a7..a486dd9a 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_1.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_1.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_2.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_2.json index 06b83056..8c685aad 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_2.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_2.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_size_1" - ] + "items": "mininggadgets:upgrade_size_1" } ] }, @@ -23,9 +21,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_3.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_3.json index 287cb062..13905e72 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_3.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_size_3.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_size_1" - ] + "items": "mininggadgets:upgrade_size_1" } ] }, @@ -17,9 +15,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_size_2" - ] + "items": "mininggadgets:upgrade_size_2" } ] }, @@ -35,9 +31,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_void_junk.json b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_void_junk.json index 65c983a6..ff878a48 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_void_junk.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/misc/upgrade_void_junk.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget.json b/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget.json index be5e9c80..eef2ed7a 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget_fancy.json b/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget_fancy.json index d407330f..664735fa 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget_fancy.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget_fancy.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget_simple.json b/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget_simple.json index f1dfe4c3..bff90870 100644 --- a/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget_simple.json +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/tools/mininggadget_simple.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "mininggadgets:upgrade_empty" - ] + "items": "mininggadgets:upgrade_empty" } ] }, diff --git a/src/generated/resources/data/mininggadgets/loot_tables/blocks/minerslight.json b/src/generated/resources/data/mininggadgets/loot_tables/blocks/minerslight.json new file mode 100644 index 00000000..fe1c5d6c --- /dev/null +++ b/src/generated/resources/data/mininggadgets/loot_tables/blocks/minerslight.json @@ -0,0 +1,4 @@ +{ + "type": "minecraft:block", + "random_sequence": "mininggadgets:blocks/minerslight" +} \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/loot_tables/blocks/renderblock.json b/src/generated/resources/data/mininggadgets/loot_tables/blocks/renderblock.json new file mode 100644 index 00000000..2e259b09 --- /dev/null +++ b/src/generated/resources/data/mininggadgets/loot_tables/blocks/renderblock.json @@ -0,0 +1,4 @@ +{ + "type": "minecraft:block", + "random_sequence": "mininggadgets:blocks/renderblock" +} \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/mininggadget.json b/src/generated/resources/data/mininggadgets/recipes/mininggadget.json index f1af86a9..4199aff1 100644 --- a/src/generated/resources/data/mininggadgets/recipes/mininggadget.json +++ b/src/generated/resources/data/mininggadgets/recipes/mininggadget.json @@ -3,16 +3,16 @@ "category": "equipment", "key": { "d": { - "tag": "forge:gems/diamond" + "tag": "c:gems/diamond" }, "g": { - "tag": "forge:ingots/gold" + "tag": "c:ingots/gold" }, "i": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" }, "r": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" }, "u": { "item": "mininggadgets:upgrade_empty" @@ -24,6 +24,7 @@ "dig" ], "result": { - "item": "mininggadgets:mininggadget" + "count": 1, + "id": "mininggadgets:mininggadget" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/mininggadget_fancy.json b/src/generated/resources/data/mininggadgets/recipes/mininggadget_fancy.json index 29fd51c5..7873a6ae 100644 --- a/src/generated/resources/data/mininggadgets/recipes/mininggadget_fancy.json +++ b/src/generated/resources/data/mininggadgets/recipes/mininggadget_fancy.json @@ -3,16 +3,16 @@ "category": "equipment", "key": { "d": { - "tag": "forge:gems/diamond" + "tag": "c:gems/diamond" }, "g": { - "tag": "forge:ingots/gold" + "tag": "c:ingots/gold" }, "i": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" }, "r": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" }, "u": { "item": "mininggadgets:upgrade_empty" @@ -24,6 +24,7 @@ "dig" ], "result": { - "item": "mininggadgets:mininggadget_fancy" + "count": 1, + "id": "mininggadgets:mininggadget_fancy" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/mininggadget_simple.json b/src/generated/resources/data/mininggadgets/recipes/mininggadget_simple.json index 55177764..6628a173 100644 --- a/src/generated/resources/data/mininggadgets/recipes/mininggadget_simple.json +++ b/src/generated/resources/data/mininggadgets/recipes/mininggadget_simple.json @@ -3,16 +3,16 @@ "category": "equipment", "key": { "d": { - "tag": "forge:gems/diamond" + "tag": "c:gems/diamond" }, "g": { - "tag": "forge:ingots/gold" + "tag": "c:ingots/gold" }, "i": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" }, "r": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" }, "u": { "item": "mininggadgets:upgrade_empty" @@ -24,6 +24,7 @@ "dii" ], "result": { - "item": "mininggadgets:mininggadget_simple" + "count": 1, + "id": "mininggadgets:mininggadget_simple" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/modificationtable.json b/src/generated/resources/data/mininggadgets/recipes/modificationtable.json index 61c8765a..97a97d4c 100644 --- a/src/generated/resources/data/mininggadgets/recipes/modificationtable.json +++ b/src/generated/resources/data/mininggadgets/recipes/modificationtable.json @@ -3,10 +3,10 @@ "category": "misc", "key": { "i": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" }, "r": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" }, "u": { "item": "mininggadgets:upgrade_empty" @@ -18,6 +18,7 @@ "iii" ], "result": { - "item": "mininggadgets:modificationtable" + "count": 1, + "id": "mininggadgets:modificationtable" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_1.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_1.json index 77872c8e..c3127081 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_1.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_1.json @@ -15,6 +15,7 @@ "qqq" ], "result": { - "item": "mininggadgets:upgrade_battery_1" + "count": 1, + "id": "mininggadgets:upgrade_battery_1" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_2.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_2.json index 6f481e8e..a64b8fa8 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_2.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_2.json @@ -6,7 +6,7 @@ "item": "minecraft:quartz_block" }, "g": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" }, "q": { "item": "minecraft:quartz" @@ -21,6 +21,7 @@ "qbq" ], "result": { - "item": "mininggadgets:upgrade_battery_2" + "count": 1, + "id": "mininggadgets:upgrade_battery_2" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_3.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_3.json index d78bdf00..c3030545 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_3.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_battery_3.json @@ -6,7 +6,7 @@ "item": "minecraft:quartz_block" }, "g": { - "tag": "forge:ingots/gold" + "tag": "c:ingots/gold" }, "q": { "item": "minecraft:quartz" @@ -21,6 +21,7 @@ "bqb" ], "result": { - "item": "mininggadgets:upgrade_battery_3" + "count": 1, + "id": "mininggadgets:upgrade_battery_3" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_1.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_1.json index 70a026ff..3ff07028 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_1.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_1.json @@ -3,7 +3,7 @@ "category": "misc", "key": { "r": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" }, "u": { "item": "mininggadgets:upgrade_empty" @@ -15,6 +15,7 @@ "rrr" ], "result": { - "item": "mininggadgets:upgrade_efficiency_1" + "count": 1, + "id": "mininggadgets:upgrade_efficiency_1" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_2.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_2.json index 885d47fc..ce7ccda4 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_2.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_2.json @@ -6,7 +6,7 @@ "item": "minecraft:redstone_block" }, "r": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" }, "u": { "item": "mininggadgets:upgrade_efficiency_1" @@ -18,6 +18,7 @@ "rbr" ], "result": { - "item": "mininggadgets:upgrade_efficiency_2" + "count": 1, + "id": "mininggadgets:upgrade_efficiency_2" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_3.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_3.json index f7d32f68..b0ca028e 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_3.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_3.json @@ -6,7 +6,7 @@ "item": "minecraft:redstone_block" }, "r": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" }, "u": { "item": "mininggadgets:upgrade_efficiency_2" @@ -18,6 +18,7 @@ "rbr" ], "result": { - "item": "mininggadgets:upgrade_efficiency_3" + "count": 1, + "id": "mininggadgets:upgrade_efficiency_3" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_4.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_4.json index 2dc42ea3..56f2cb3c 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_4.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_4.json @@ -6,7 +6,7 @@ "item": "minecraft:redstone_block" }, "r": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" }, "u": { "item": "mininggadgets:upgrade_efficiency_3" @@ -18,6 +18,7 @@ "brb" ], "result": { - "item": "mininggadgets:upgrade_efficiency_4" + "count": 1, + "id": "mininggadgets:upgrade_efficiency_4" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_5.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_5.json index 3b8f4360..1dafae75 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_5.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_efficiency_5.json @@ -15,6 +15,7 @@ "bbb" ], "result": { - "item": "mininggadgets:upgrade_efficiency_5" + "count": 1, + "id": "mininggadgets:upgrade_efficiency_5" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_empty.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_empty.json index 8c20a2d3..686dc89d 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_empty.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_empty.json @@ -3,16 +3,16 @@ "category": "misc", "key": { "d": { - "tag": "forge:gems/diamond" + "tag": "c:gems/diamond" }, "g": { - "tag": "forge:glass_panes" + "tag": "c:glass_panes" }, "l": { - "tag": "forge:gems/lapis" + "tag": "c:gems/lapis" }, "r": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" } }, "pattern": [ @@ -21,6 +21,7 @@ "rlr" ], "result": { - "item": "mininggadgets:upgrade_empty" + "count": 1, + "id": "mininggadgets:upgrade_empty" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_1.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_1.json index f9e6785f..3e620df5 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_1.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_1.json @@ -18,6 +18,7 @@ "lgl" ], "result": { - "item": "mininggadgets:upgrade_fortune_1" + "count": 1, + "id": "mininggadgets:upgrade_fortune_1" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_2.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_2.json index 3d9b9865..5c698b42 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_2.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_2.json @@ -18,6 +18,7 @@ "lgl" ], "result": { - "item": "mininggadgets:upgrade_fortune_2" + "count": 1, + "id": "mininggadgets:upgrade_fortune_2" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_3.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_3.json index 3ba6d236..fca3a977 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_3.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_fortune_3.json @@ -18,6 +18,7 @@ "ldl" ], "result": { - "item": "mininggadgets:upgrade_fortune_3" + "count": 1, + "id": "mininggadgets:upgrade_fortune_3" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_freezing.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_freezing.json index 0a37c042..937ac447 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_freezing.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_freezing.json @@ -15,6 +15,7 @@ "sss" ], "result": { - "item": "mininggadgets:upgrade_freezing" + "count": 1, + "id": "mininggadgets:upgrade_freezing" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_light_placer.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_light_placer.json index 776365fb..ca6e766c 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_light_placer.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_light_placer.json @@ -24,6 +24,7 @@ "grg" ], "result": { - "item": "mininggadgets:upgrade_light_placer" + "count": 1, + "id": "mininggadgets:upgrade_light_placer" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_magnet.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_magnet.json index 0fd4616b..114780a8 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_magnet.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_magnet.json @@ -3,13 +3,13 @@ "category": "misc", "key": { "g": { - "tag": "forge:ingots/gold" + "tag": "c:ingots/gold" }, "i": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" }, "r": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" }, "u": { "item": "mininggadgets:upgrade_empty" @@ -21,6 +21,7 @@ "rgr" ], "result": { - "item": "mininggadgets:upgrade_magnet" + "count": 1, + "id": "mininggadgets:upgrade_magnet" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_range_1.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_range_1.json index 83d7dbfd..b6420149 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_range_1.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_range_1.json @@ -21,6 +21,7 @@ "lgl" ], "result": { - "item": "mininggadgets:upgrade_range_1" + "count": 1, + "id": "mininggadgets:upgrade_range_1" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_range_2.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_range_2.json index 724bfc64..17ee9059 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_range_2.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_range_2.json @@ -21,6 +21,7 @@ "lgl" ], "result": { - "item": "mininggadgets:upgrade_range_2" + "count": 1, + "id": "mininggadgets:upgrade_range_2" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_range_3.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_range_3.json index fea03626..8294c039 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_range_3.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_range_3.json @@ -24,6 +24,7 @@ "lgl" ], "result": { - "item": "mininggadgets:upgrade_range_3" + "count": 1, + "id": "mininggadgets:upgrade_range_3" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_silk.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_silk.json index 1562edec..ba161d5b 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_silk.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_silk.json @@ -6,10 +6,10 @@ "item": "minecraft:golden_apple" }, "g": { - "tag": "forge:ingots/gold" + "tag": "c:ingots/gold" }, "s": { - "tag": "forge:slimeballs" + "tag": "c:slimeballs" }, "u": { "item": "mininggadgets:upgrade_empty" @@ -21,6 +21,7 @@ "sss" ], "result": { - "item": "mininggadgets:upgrade_silk" + "count": 1, + "id": "mininggadgets:upgrade_silk" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_size_1.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_size_1.json index 6e5cebb3..46508b37 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_size_1.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_size_1.json @@ -6,7 +6,7 @@ "item": "minecraft:diamond_block" }, "e": { - "tag": "forge:ender_pearls" + "tag": "c:ender_pearls" }, "p": { "item": "minecraft:diamond_pickaxe" @@ -24,6 +24,7 @@ "rpr" ], "result": { - "item": "mininggadgets:upgrade_size_1" + "count": 1, + "id": "mininggadgets:upgrade_size_1" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_size_2.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_size_2.json index 9018950b..de9d3e52 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_size_2.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_size_2.json @@ -6,7 +6,7 @@ "item": "minecraft:diamond_block" }, "e": { - "tag": "forge:ender_pearls" + "tag": "c:ender_pearls" }, "n": { "item": "minecraft:netherite_block" @@ -24,6 +24,7 @@ "epe" ], "result": { - "item": "mininggadgets:upgrade_size_2" + "count": 1, + "id": "mininggadgets:upgrade_size_2" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_size_3.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_size_3.json index 6aaf3061..b6716b91 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_size_3.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_size_3.json @@ -3,7 +3,7 @@ "category": "misc", "key": { "e": { - "tag": "forge:ender_pearls" + "tag": "c:ender_pearls" }, "n": { "item": "minecraft:netherite_block" @@ -12,7 +12,7 @@ "item": "minecraft:netherite_pickaxe" }, "s": { - "tag": "forge:nether_stars" + "tag": "c:nether_stars" }, "u": { "item": "mininggadgets:upgrade_size_2" @@ -24,6 +24,7 @@ "sps" ], "result": { - "item": "mininggadgets:upgrade_size_3" + "count": 1, + "id": "mininggadgets:upgrade_size_3" } } \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/upgrade_void_junk.json b/src/generated/resources/data/mininggadgets/recipes/upgrade_void_junk.json index 739dcb09..20597195 100644 --- a/src/generated/resources/data/mininggadgets/recipes/upgrade_void_junk.json +++ b/src/generated/resources/data/mininggadgets/recipes/upgrade_void_junk.json @@ -3,13 +3,13 @@ "category": "misc", "key": { "e": { - "tag": "forge:ender_pearls" + "tag": "c:ender_pearls" }, "o": { "item": "minecraft:obsidian" }, "r": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" }, "u": { "item": "mininggadgets:upgrade_empty" @@ -21,6 +21,7 @@ "ror" ], "result": { - "item": "mininggadgets:upgrade_void_junk" + "count": 1, + "id": "mininggadgets:upgrade_void_junk" } } \ No newline at end of file diff --git a/src/main/java/com/direwolf20/mininggadgets/client/MiningGadgetsJEI.java b/src/main/java/com/direwolf20/mininggadgets/client/MiningGadgetsJEI.java index 825b0b42..4489b0d2 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/MiningGadgetsJEI.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/MiningGadgetsJEI.java @@ -3,6 +3,7 @@ import com.direwolf20.mininggadgets.client.screens.ModificationTableScreen; import com.direwolf20.mininggadgets.common.MiningGadgets; import com.direwolf20.mininggadgets.common.items.MiningGadget; +import com.direwolf20.mininggadgets.common.util.MGDataComponents; import com.direwolf20.mininggadgets.setup.Config; import com.direwolf20.mininggadgets.setup.Registration; import mezz.jei.api.IModPlugin; @@ -36,7 +37,7 @@ public void registerItemSubtypes(ISubtypeRegistration registration) { return IIngredientSubtypeInterpreter.NONE; } - double energy = stack.getOrCreateTag().getDouble("energy"); + int energy = stack.getOrDefault(MGDataComponents.FORGE_ENERGY, 0); if (energy == 0) { return "empty"; } else if (energy == Config.MININGGADGET_MAXPOWER.get()) { diff --git a/src/main/java/com/direwolf20/mininggadgets/client/OurKeys.java b/src/main/java/com/direwolf20/mininggadgets/client/OurKeys.java index 83430a83..f16461a9 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/OurKeys.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/OurKeys.java @@ -4,11 +4,11 @@ import net.minecraft.client.KeyMapping; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; -@Mod.EventBusSubscriber(value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD) public class OurKeys { public static final KeyMapping shiftClickGuiBinding = new KeyMapping("mininggadgets.text.open_gui", InputConstants.UNKNOWN.getValue(), "itemGroup.mininggadgets"); diff --git a/src/main/java/com/direwolf20/mininggadgets/client/events/EventRenderGadget.java b/src/main/java/com/direwolf20/mininggadgets/client/events/EventRenderGadget.java index e4b7217e..b1d03ab9 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/events/EventRenderGadget.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/events/EventRenderGadget.java @@ -17,11 +17,11 @@ import net.minecraft.world.item.ItemDisplayContext; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.client.event.RenderHandEvent; -@Mod.EventBusSubscriber(modid = MiningGadgets.MOD_ID, value = Dist.CLIENT) +@EventBusSubscriber(modid = MiningGadgets.MOD_ID, value = Dist.CLIENT) public class EventRenderGadget { @SubscribeEvent diff --git a/src/main/java/com/direwolf20/mininggadgets/client/particles/ModParticles.java b/src/main/java/com/direwolf20/mininggadgets/client/particles/ModParticles.java index 749d5d9f..4abe89cf 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/particles/ModParticles.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/particles/ModParticles.java @@ -1,14 +1,13 @@ package com.direwolf20.mininggadgets.client.particles; -import com.direwolf20.mininggadgets.client.particles.laserparticle.LaserParticleData; import com.direwolf20.mininggadgets.client.particles.laserparticle.LaserParticleType; import com.direwolf20.mininggadgets.client.particles.lightparticle.LightParticleType; -import com.direwolf20.mininggadgets.client.particles.playerparticle.PlayerParticleData; import com.direwolf20.mininggadgets.client.particles.playerparticle.PlayerParticleType; import com.direwolf20.mininggadgets.common.MiningGadgets; import net.minecraft.core.particles.ParticleType; import net.minecraft.core.particles.SimpleParticleType; import net.minecraft.core.registries.Registries; +import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredRegister; import java.util.function.Supplier; @@ -17,7 +16,9 @@ public class ModParticles { public static final DeferredRegister> PARTICLE_TYPES = DeferredRegister.create(Registries.PARTICLE_TYPE, MiningGadgets.MOD_ID); - public static final Supplier> LASERPARTICLE = PARTICLE_TYPES.register("laserparticle", LaserParticleType::new); - public static final Supplier> PLAYERPARTICLE = PARTICLE_TYPES.register("playerparticle", PlayerParticleType::new); + public static final DeferredHolder, LaserParticleType> LASERPARTICLE = PARTICLE_TYPES.register("laserparticle", () -> new LaserParticleType(false)); + public static final DeferredHolder, PlayerParticleType> PLAYERPARTICLE = PARTICLE_TYPES.register("playerparticle", () -> new PlayerParticleType(false)); + //public static final Supplier> LASERPARTICLE = PARTICLE_TYPES.register("laserparticle", LaserParticleType::new); + //public static final Supplier> PLAYERPARTICLE = PARTICLE_TYPES.register("playerparticle", PlayerParticleType::new); public static final Supplier> LIGHT_PARTICLE = PARTICLE_TYPES.register("light_particle", LightParticleType::new); } diff --git a/src/main/java/com/direwolf20/mininggadgets/client/particles/ParticleRenderDispatcher.java b/src/main/java/com/direwolf20/mininggadgets/client/particles/ParticleRenderDispatcher.java index c17fd717..f32eea28 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/particles/ParticleRenderDispatcher.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/particles/ParticleRenderDispatcher.java @@ -6,11 +6,11 @@ import com.direwolf20.mininggadgets.common.MiningGadgets; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent; -@Mod.EventBusSubscriber(modid = MiningGadgets.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(modid = MiningGadgets.MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD) public class ParticleRenderDispatcher { @SubscribeEvent diff --git a/src/main/java/com/direwolf20/mininggadgets/client/particles/laserparticle/LaserParticleData.java b/src/main/java/com/direwolf20/mininggadgets/client/particles/laserparticle/LaserParticleData.java index 3de1f4a4..c8e73f22 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/particles/laserparticle/LaserParticleData.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/particles/laserparticle/LaserParticleData.java @@ -1,20 +1,39 @@ package com.direwolf20.mininggadgets.client.particles.laserparticle; import com.direwolf20.mininggadgets.client.particles.ModParticles; -import com.mojang.brigadier.StringReader; -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.commands.arguments.blocks.BlockStateParser; +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import javax.annotation.Nonnull; -import java.util.Locale; public class LaserParticleData implements ParticleOptions { + public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + BlockState.CODEC.fieldOf("state").forGetter(p -> p.state), + Codec.FLOAT.fieldOf("size").forGetter(p -> p.size), + Codec.FLOAT.fieldOf("maxAgeMul").forGetter(p -> p.maxAgeMul), + Codec.BOOL.fieldOf("depthTest").forGetter(p -> p.depthTest) + ).apply(instance, LaserParticleData::new)); + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.idMapper(Block.BLOCK_STATE_REGISTRY), + LaserParticleData::getState, + ByteBufCodecs.FLOAT, + LaserParticleData::getSize, + ByteBufCodecs.FLOAT, + LaserParticleData::getMaxAgeMul, + ByteBufCodecs.BOOL, + LaserParticleData::isDepthTest, + LaserParticleData::new + ); + public final float size; public final float maxAgeMul; public final boolean depthTest; @@ -35,49 +54,27 @@ private LaserParticleData(BlockState state, float size, float maxAgeMul, boolean this.state = state; } + public float getSize() { + return size; + } - @Nonnull - @Override - public ParticleType getType() { - return ModParticles.LASERPARTICLE.get(); + public float getMaxAgeMul() { + return maxAgeMul; } - @Override - public void writeToNetwork(FriendlyByteBuf buf) { - buf.writeVarInt(Block.BLOCK_STATE_REGISTRY.getId(state)); - buf.writeFloat(size); - buf.writeFloat(maxAgeMul); - buf.writeBoolean(depthTest); + public boolean isDepthTest() { + return depthTest; } + public BlockState getState() { + return state; + } + + @Nonnull @Override - public String writeToString() { - return String.format(Locale.ROOT, "%s %.2f %.2f %s", - this.getType(), this.size, this.maxAgeMul, this.depthTest); + public ParticleType getType() { + return ModParticles.LASERPARTICLE.get(); } - public static final Deserializer DESERIALIZER = new Deserializer<>() { - @Nonnull - @Override - public LaserParticleData fromCommand(@Nonnull ParticleType type, @Nonnull StringReader reader) throws CommandSyntaxException { - reader.expect(' '); - BlockState state = (BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK.asLookup(), reader, false).blockState()); - reader.expect(' '); - float size = reader.readFloat(); - reader.expect(' '); - float mam = reader.readFloat(); - boolean depth = true; - if (reader.canRead()) { - reader.expect(' '); - depth = reader.readBoolean(); - } - return new LaserParticleData(state, size, mam, depth); - } - - @Override - public LaserParticleData fromNetwork(@Nonnull ParticleType type, FriendlyByteBuf buf) { - return new LaserParticleData(Block.BLOCK_STATE_REGISTRY.byId(buf.readVarInt()), buf.readFloat(), buf.readFloat(), buf.readBoolean()); - } - }; } diff --git a/src/main/java/com/direwolf20/mininggadgets/client/particles/laserparticle/LaserParticleType.java b/src/main/java/com/direwolf20/mininggadgets/client/particles/laserparticle/LaserParticleType.java index 38fe433f..f3032684 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/particles/laserparticle/LaserParticleType.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/particles/laserparticle/LaserParticleType.java @@ -1,15 +1,26 @@ package com.direwolf20.mininggadgets.client.particles.laserparticle; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import net.minecraft.core.particles.ParticleType; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; public class LaserParticleType extends ParticleType { - public LaserParticleType() { - super(false, LaserParticleData.DESERIALIZER); + public LaserParticleType(boolean pOverrideLimiter) { + super(pOverrideLimiter); + } + + public LaserParticleType getType() { + return this; + } + + @Override + public MapCodec codec() { + return LaserParticleData.MAP_CODEC; } @Override - public Codec codec() { - return null; + public StreamCodec streamCodec() { + return LaserParticleData.STREAM_CODEC; } } diff --git a/src/main/java/com/direwolf20/mininggadgets/client/particles/playerparticle/PlayerParticleData.java b/src/main/java/com/direwolf20/mininggadgets/client/particles/playerparticle/PlayerParticleData.java index 0a579971..505e1dbf 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/particles/playerparticle/PlayerParticleData.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/particles/playerparticle/PlayerParticleData.java @@ -1,16 +1,111 @@ package com.direwolf20.mininggadgets.client.particles.playerparticle; import com.direwolf20.mininggadgets.client.particles.ModParticles; -import com.mojang.brigadier.StringReader; -import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.datafixers.util.Function10; +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import javax.annotation.Nonnull; -import java.util.Locale; +import java.util.function.Function; public class PlayerParticleData implements ParticleOptions { + public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + Codec.STRING.fieldOf("partType").forGetter(p -> p.partType), + Codec.DOUBLE.fieldOf("targetX").forGetter(p -> p.targetX), + Codec.DOUBLE.fieldOf("targetY").forGetter(p -> p.targetY), + Codec.DOUBLE.fieldOf("targetZ").forGetter(p -> p.targetZ), + Codec.FLOAT.fieldOf("size").forGetter(p -> p.size), + Codec.FLOAT.fieldOf("r").forGetter(p -> p.r), + Codec.FLOAT.fieldOf("g").forGetter(p -> p.g), + Codec.FLOAT.fieldOf("b").forGetter(p -> p.b), + Codec.FLOAT.fieldOf("maxAgeMul").forGetter(p -> p.maxAgeMul), + Codec.BOOL.fieldOf("depthTest").forGetter(p -> p.depthTest) + ).apply(instance, PlayerParticleData::new)); + public static final StreamCodec STREAM_CODEC = composite( + ByteBufCodecs.STRING_UTF8, + PlayerParticleData::getPartType, + ByteBufCodecs.DOUBLE, + PlayerParticleData::getTargetX, + ByteBufCodecs.DOUBLE, + PlayerParticleData::getTargetY, + ByteBufCodecs.DOUBLE, + PlayerParticleData::getTargetZ, + ByteBufCodecs.FLOAT, + PlayerParticleData::getSize, + ByteBufCodecs.FLOAT, + PlayerParticleData::getR, + ByteBufCodecs.FLOAT, + PlayerParticleData::getG, + ByteBufCodecs.FLOAT, + PlayerParticleData::getB, + ByteBufCodecs.FLOAT, + PlayerParticleData::getMaxAgeMul, + ByteBufCodecs.BOOL, + PlayerParticleData::isDepthTest, + PlayerParticleData::new + ); + + public static StreamCodec composite( + final StreamCodec codec1, + final Function getter1, + final StreamCodec codec2, + final Function getter2, + final StreamCodec codec3, + final Function getter3, + final StreamCodec codec4, + final Function getter4, + final StreamCodec codec5, + final Function getter5, + final StreamCodec codec6, + final Function getter6, + final StreamCodec codec7, + final Function getter7, + final StreamCodec codec8, + final Function getter8, + final StreamCodec codec9, + final Function getter9, + final StreamCodec codec10, + final Function getter10, + final Function10 p_331335_) { + return new StreamCodec() { + @Override + public C decode(B p_330310_) { + T1 t1 = codec1.decode(p_330310_); + T2 t2 = codec2.decode(p_330310_); + T3 t3 = codec3.decode(p_330310_); + T4 t4 = codec4.decode(p_330310_); + T5 t5 = codec5.decode(p_330310_); + T6 t6 = codec6.decode(p_330310_); + T7 t7 = codec7.decode(p_330310_); + T8 t8 = codec8.decode(p_330310_); + T9 t9 = codec9.decode(p_330310_); + T10 t10 = codec10.decode(p_330310_); + return p_331335_.apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); + } + + @Override + public void encode(B p_332052_, C p_331912_) { + codec1.encode(p_332052_, getter1.apply(p_331912_)); + codec2.encode(p_332052_, getter2.apply(p_331912_)); + codec3.encode(p_332052_, getter3.apply(p_331912_)); + codec4.encode(p_332052_, getter4.apply(p_331912_)); + codec5.encode(p_332052_, getter5.apply(p_331912_)); + codec6.encode(p_332052_, getter6.apply(p_331912_)); + codec7.encode(p_332052_, getter7.apply(p_331912_)); + codec8.encode(p_332052_, getter8.apply(p_331912_)); + codec9.encode(p_332052_, getter9.apply(p_331912_)); + codec10.encode(p_332052_, getter10.apply(p_331912_)); + } + }; + } + public final float size; public final float r, g, b; public final float maxAgeMul; @@ -56,60 +151,43 @@ public ParticleType getType() { return ModParticles.PLAYERPARTICLE.get(); } - @Override - public void writeToNetwork(FriendlyByteBuf buf) { - buf.writeUtf(partType); - buf.writeDouble(targetX); - buf.writeDouble(targetY); - buf.writeDouble(targetZ); - buf.writeFloat(size); - buf.writeFloat(r); - buf.writeFloat(g); - buf.writeFloat(b); - buf.writeFloat(maxAgeMul); - buf.writeBoolean(depthTest); + public float getSize() { + return size; } - @Nonnull - @Override - public String writeToString() { - return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f %.2f %s", - this.getType(), this.size, this.r, this.g, this.b, this.maxAgeMul, this.depthTest); - } - - public static final ParticleOptions.Deserializer DESERIALIZER = new ParticleOptions.Deserializer<>() { - @Nonnull - @Override - public PlayerParticleData fromCommand(@Nonnull ParticleType type, @Nonnull StringReader reader) throws CommandSyntaxException { - reader.expect(' '); - String partType = reader.readString(); - reader.expect(' '); - double targetX = reader.readDouble(); - reader.expect(' '); - double targetY = reader.readDouble(); - reader.expect(' '); - double targetZ = reader.readDouble(); - reader.expect(' '); - float size = reader.readFloat(); - reader.expect(' '); - float r = reader.readFloat(); - reader.expect(' '); - float g = reader.readFloat(); - reader.expect(' '); - float b = reader.readFloat(); - reader.expect(' '); - float mam = reader.readFloat(); - boolean depth = true; - if (reader.canRead()) { - reader.expect(' '); - depth = reader.readBoolean(); - } - return new PlayerParticleData(partType, targetX, targetY, targetZ, size, r, g, b, mam, depth); - } - - @Override - public PlayerParticleData fromNetwork(@Nonnull ParticleType type, FriendlyByteBuf buf) { - return new PlayerParticleData(buf.readUtf(), buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readBoolean()); - } - }; + public float getR() { + return r; + } + + public float getG() { + return g; + } + + public float getB() { + return b; + } + + public float getMaxAgeMul() { + return maxAgeMul; + } + + public boolean isDepthTest() { + return depthTest; + } + + public double getTargetX() { + return targetX; + } + + public double getTargetY() { + return targetY; + } + + public double getTargetZ() { + return targetZ; + } + + public String getPartType() { + return partType; + } } diff --git a/src/main/java/com/direwolf20/mininggadgets/client/particles/playerparticle/PlayerParticleType.java b/src/main/java/com/direwolf20/mininggadgets/client/particles/playerparticle/PlayerParticleType.java index d8596560..b2746b5c 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/particles/playerparticle/PlayerParticleType.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/particles/playerparticle/PlayerParticleType.java @@ -1,20 +1,31 @@ package com.direwolf20.mininggadgets.client.particles.playerparticle; -import com.mojang.serialization.Codec; -import net.minecraft.client.particle.SpriteSet; -import net.minecraft.client.particle.ParticleProvider; -import net.minecraft.client.particle.Particle; +import com.mojang.serialization.MapCodec; import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.client.particle.SpriteSet; import net.minecraft.core.particles.ParticleType; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; public class PlayerParticleType extends ParticleType { - public PlayerParticleType() { - super(false, PlayerParticleData.DESERIALIZER); + public PlayerParticleType(boolean pOverrideLimiter) { + super(pOverrideLimiter); + } + + public PlayerParticleType getType() { + return this; + } + + @Override + public MapCodec codec() { + return PlayerParticleData.MAP_CODEC; } @Override - public Codec codec() { - return null; + public StreamCodec streamCodec() { + return PlayerParticleData.STREAM_CODEC; } public static class FACTORY implements ParticleProvider { diff --git a/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaser.java b/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaser.java index 64680e50..66406df0 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaser.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaser.java @@ -5,6 +5,7 @@ import com.direwolf20.mininggadgets.common.items.gadget.MiningProperties; import com.direwolf20.mininggadgets.common.items.upgrade.Upgrade; import com.direwolf20.mininggadgets.common.items.upgrade.UpgradeTools; +import com.direwolf20.mininggadgets.common.util.CodecHelpers; import com.direwolf20.mininggadgets.setup.Registration; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; @@ -47,7 +48,13 @@ public static void renderLaser(RenderLevelStageEvent event, Player player, float // parse data from item float speedModifier = getSpeedModifier(stack); - drawLasers(stack, event, playerPos, trace, 0, 0, 0, MiningProperties.getColor(stack, MiningProperties.COLOR_RED) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE) / 255f, 0.02f, player, ticks, speedModifier); + CodecHelpers.LaserColor laserColor = MiningProperties.getColors(stack); + + float red = laserColor.red() / 255f; + float green = laserColor.green() / 255f; + float blue = laserColor.blue() / 255f; + + drawLasers(stack, event, playerPos, trace, 0, 0, 0, red, green, blue, 0.02f, player, ticks, speedModifier); } private static float getSpeedModifier(ItemStack stack) { @@ -76,9 +83,11 @@ private static void drawLasers(ItemStack stack, RenderLevelStageEvent event, Vec double v = gameTime * speedModifier; float additiveThickness = (thickness * 3.5f) * calculateLaserFlickerModifier(gameTime); - float beam2r = MiningProperties.getColor(stack, MiningProperties.COLOR_RED_INNER) / 255f; - float beam2g = MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN_INNER) / 255f; - float beam2b = MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE_INNER) / 255f; + CodecHelpers.LaserColor laserColor = MiningProperties.getColors(stack); + + float beam2r = laserColor.innerRed() / 255f; + float beam2g = laserColor.innerGreen() / 255f; + float beam2b = laserColor.innerBlue() / 255f; Vec3 view = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource(); diff --git a/src/main/java/com/direwolf20/mininggadgets/client/screens/FilterScreen.java b/src/main/java/com/direwolf20/mininggadgets/client/screens/FilterScreen.java index be6dc4a8..281f8312 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/screens/FilterScreen.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/screens/FilterScreen.java @@ -59,7 +59,7 @@ public boolean mouseClicked(double x, double y, int btn) { stack = stack.copy().split(hoveredSlot.getMaxStackSize()); // Limit to slot limit hoveredSlot.set(stack); // Temporarily update the client for continuity purposes - PacketDistributor.SERVER.noArg().send(new GhostSlotPayload(hoveredSlot.index, stack)); + PacketDistributor.sendToServer(new GhostSlotPayload(hoveredSlot.index, stack)); return true; } diff --git a/src/main/java/com/direwolf20/mininggadgets/client/screens/MiningSettingScreen.java b/src/main/java/com/direwolf20/mininggadgets/client/screens/MiningSettingScreen.java index 09e3290a..c1d3d880 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/screens/MiningSettingScreen.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/screens/MiningSettingScreen.java @@ -90,14 +90,14 @@ protected void init() { if( containsVoid ) { addRenderableWidget( Button.builder(getTrans("tooltip.screen.edit_filters"), (button) -> { - PacketDistributor.SERVER.noArg().send(new OpenFilterContainerPayload()); + PacketDistributor.sendToServer(new OpenFilterContainerPayload()); }).pos(baseX + 10, top + 20).size( 95, 20).build() ); addRenderableWidget(new WhitelistButton(baseX + 10 + (115 - 20), top + 20, 20, 20, isWhitelist, (button) -> { isWhitelist = !isWhitelist; ((WhitelistButton) button).setWhitelist(isWhitelist); - PacketDistributor.SERVER.noArg().send(new ToggleFiltersPayload()); + PacketDistributor.sendToServer(new ToggleFiltersPayload()); })); } @@ -113,7 +113,7 @@ protected void init() { currentSize += 2; button.setMessage(getTrans("tooltip.screen.size", currentSize)); - PacketDistributor.SERVER.noArg().send(new ChangeMiningSizePayload()); + PacketDistributor.sendToServer(new ChangeMiningSizePayload()); }).pos(baseX - 135, 0).size(125, 20).build()); if (maxMiningRange > 3) { @@ -121,7 +121,7 @@ protected void init() { currentMode = MiningProperties.nextSizeMode(gadget); button.setMessage(currentMode.getTooltip()); - PacketDistributor.SERVER.noArg().send(new ChangeMiningSizeModePayload()); + PacketDistributor.sendToServer(new ChangeMiningSizeModePayload()); }).pos(baseX - 135, 0).size(125, 20).build()); } @@ -141,7 +141,7 @@ protected void applyValue() { leftWidgets.add(Button.builder(getTrans("tooltip.screen.precision_mode", isPrecision), (button) -> { isPrecision = !isPrecision; button.setMessage(getTrans("tooltip.screen.precision_mode", isPrecision)); - PacketDistributor.SERVER.noArg().send(new TogglePrecisionPayload()); + PacketDistributor.sendToServer(new TogglePrecisionPayload()); }).pos(baseX - 135, 0).size(125, 20).build()); // volume slider @@ -177,7 +177,7 @@ private boolean toggleUpgrade(Upgrade upgrade, boolean update) { // When the button is clicked we toggle if( update ) { this.updateButtons(upgrade); - PacketDistributor.SERVER.noArg().send(new UpdateUpgradePayload(upgrade.getName())); + PacketDistributor.sendToServer(new UpdateUpgradePayload(upgrade.getName())); } // When we're just init the gui, we check if it's on or off. @@ -239,9 +239,9 @@ public boolean isPauseScreen() { @Override public void removed() { - PacketDistributor.SERVER.noArg().send(new ChangeRangePayload(this.beamRange)); - PacketDistributor.SERVER.noArg().send(new ChangeVolumePayload(this.volume)); - PacketDistributor.SERVER.noArg().send(new ChangeFreezeDelayPayload(this.freezeDelay)); + PacketDistributor.sendToServer(new ChangeRangePayload(this.beamRange)); + PacketDistributor.sendToServer(new ChangeVolumePayload(this.volume)); + PacketDistributor.sendToServer(new ChangeFreezeDelayPayload(this.freezeDelay)); super.removed(); } diff --git a/src/main/java/com/direwolf20/mininggadgets/client/screens/MiningVisualsScreen.java b/src/main/java/com/direwolf20/mininggadgets/client/screens/MiningVisualsScreen.java index 95616004..2fb6361a 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/screens/MiningVisualsScreen.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/screens/MiningVisualsScreen.java @@ -3,6 +3,7 @@ import com.direwolf20.mininggadgets.common.items.gadget.MiningProperties; import com.direwolf20.mininggadgets.common.network.data.ChangeBreakTypePayload; import com.direwolf20.mininggadgets.common.network.data.ChangeColorPayload; +import com.direwolf20.mininggadgets.common.util.CodecHelpers; import com.mojang.blaze3d.platform.InputConstants; import it.unimi.dsi.fastutil.shorts.ShortConsumer; import net.minecraft.client.gui.GuiGraphics; @@ -38,12 +39,13 @@ public class MiningVisualsScreen extends Screen { public MiningVisualsScreen(ItemStack gadget) { super(Component.literal("title")); this.gadget = gadget; - this.red = MiningProperties.getColor(gadget, MiningProperties.COLOR_RED); - this.green = MiningProperties.getColor(gadget, MiningProperties.COLOR_GREEN); - this.blue = MiningProperties.getColor(gadget, MiningProperties.COLOR_BLUE); - this.red_inner = MiningProperties.getColor(gadget, MiningProperties.COLOR_RED_INNER); - this.green_inner = MiningProperties.getColor(gadget, MiningProperties.COLOR_GREEN_INNER); - this.blue_inner = MiningProperties.getColor(gadget, MiningProperties.COLOR_BLUE_INNER); + CodecHelpers.LaserColor laserColor = MiningProperties.getColors(gadget); + this.red = laserColor.red(); + this.green = laserColor.green(); + this.blue = laserColor.blue(); + this.red_inner = laserColor.innerRed(); + this.green_inner = laserColor.innerGreen(); + this.blue_inner = laserColor.innerBlue(); } @Override @@ -64,7 +66,7 @@ protected void init() { else button.setMessage(Component.translatable("mininggadgets.tooltip.screen.shrink")); - PacketDistributor.SERVER.noArg().send(new ChangeBreakTypePayload()); + PacketDistributor.sendToServer(new ChangeBreakTypePayload()); } ) .pos(baseX - (150), baseY - 55) @@ -177,7 +179,7 @@ public void removed() { } private void syncColors() { - PacketDistributor.SERVER.noArg().send(new ChangeColorPayload(this.red, this.green, this.blue, this.red_inner, this.green_inner, this.blue_inner)); + PacketDistributor.sendToServer(new ChangeColorPayload(new CodecHelpers.LaserColor(this.red, this.green, this.blue, this.red_inner, this.green_inner, this.blue_inner))); } @Override diff --git a/src/main/java/com/direwolf20/mininggadgets/client/screens/ModificationTableScreen.java b/src/main/java/com/direwolf20/mininggadgets/client/screens/ModificationTableScreen.java index 924450cf..01e18c92 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/screens/ModificationTableScreen.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/screens/ModificationTableScreen.java @@ -21,10 +21,10 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.neoforged.neoforge.client.gui.widget.ScrollPanel; -import net.neoforged.neoforge.common.I18nExtension; import net.neoforged.neoforge.network.PacketDistributor; @@ -58,7 +58,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia guiGraphics.drawCenteredString(font, Component.translatable(MiningGadgets.MOD_ID + ".text.modification_table"), relX, relY - 100, 0xFFFFFF); if (this.container.getUpgradesCache().size() == 0) { - String string = I18nExtension.parseMessage(String.format("%s.%s", MiningGadgets.MOD_ID, "text.empty_table_helper")); + String string = Component.translatable(MiningGadgets.MOD_ID + ".text.modification_table").getString(); //String string = MiningGadgets.MOD_ID + ".text.empty_table_helper"; String[] parts = string.split("\n"); for (int i = 0; i < parts.length; i++) { @@ -107,7 +107,7 @@ public boolean mouseClicked(double mouseXIn, double mouseYIn, int p_231044_5_) { return false; } - PacketDistributor.SERVER.noArg().send(new InsertUpgradePayload(this.tePos, heldStack)); + PacketDistributor.sendToServer(new InsertUpgradePayload(this.tePos, heldStack)); this.menu.setCarried(ItemStack.EMPTY); } } @@ -169,7 +169,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { if( !isMouseOver(mouseX, mouseY) || this.upgrade == null ) return false; - PacketDistributor.SERVER.noArg().send(new ExtractUpgradePayload(this.parent.tePos, this.upgrade.getName(), this.upgrade.getName().length())); + PacketDistributor.sendToServer(new ExtractUpgradePayload(this.parent.tePos, this.upgrade.getName(), this.upgrade.getName().length())); return super.mouseClicked(mouseX, mouseY, button); } @@ -178,7 +178,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia super.render(guiGraphics, mouseX, mouseY, partialTicks); if( this.upgrade != null ) - guiGraphics.renderTooltip(Minecraft.getInstance().font, Lists.transform(new ItemStack(this.upgrade.getCardItem().get()).getTooltipLines(this.parent.getMinecraft().player, TooltipFlag.Default.NORMAL), Component::getVisualOrderText), mouseX, mouseY); + guiGraphics.renderTooltip(Minecraft.getInstance().font, Lists.transform(new ItemStack(this.upgrade.getCardItem().get()).getTooltipLines(Item.TooltipContext.EMPTY, this.parent.getMinecraft().player, TooltipFlag.Default.NORMAL), Component::getVisualOrderText), mouseX, mouseY); } @Override diff --git a/src/main/java/com/direwolf20/mininggadgets/common/MiningGadgets.java b/src/main/java/com/direwolf20/mininggadgets/common/MiningGadgets.java index 4f2c45a3..e19f57f1 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/MiningGadgets.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/MiningGadgets.java @@ -1,6 +1,6 @@ package com.direwolf20.mininggadgets.common; -import com.direwolf20.mininggadgets.common.capabilities.EnergisedItem; +import com.direwolf20.mininggadgets.common.capabilities.EnergyStorageItemstack; import com.direwolf20.mininggadgets.common.items.MiningGadget; import com.direwolf20.mininggadgets.common.network.PacketHandler; import com.direwolf20.mininggadgets.common.tiles.ModificationTableTileEntity; @@ -13,6 +13,7 @@ import net.minecraft.world.level.block.*; import net.neoforged.bus.api.IEventBus; import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.ModContainer; import net.neoforged.fml.common.Mod; import net.neoforged.fml.loading.FMLLoader; import net.neoforged.neoforge.capabilities.Capabilities; @@ -28,10 +29,10 @@ public class MiningGadgets public static final String MOD_ID = "mininggadgets"; private static final Logger LOGGER = LogManager.getLogger(); - public MiningGadgets(IEventBus event) { + public MiningGadgets(IEventBus event, ModContainer container) { // Register all of our items, blocks, item blocks, etc Registration.init(event); - Config.register(); + Config.register(container); event.addListener(ModSetup::init); ModSetup.TABS.register(event); @@ -45,7 +46,7 @@ public MiningGadgets(IEventBus event) { } private void registerCapabilities(RegisterCapabilitiesEvent event) { - event.registerItem(Capabilities.EnergyStorage.ITEM, (itemStack, context) -> new EnergisedItem(itemStack, ((MiningGadget) itemStack.getItem()).getEnergyMax()), + event.registerItem(Capabilities.EnergyStorage.ITEM, (itemStack, context) -> new EnergyStorageItemstack(((MiningGadget) itemStack.getItem()).getEnergyMax(), itemStack), Registration.MININGGADGET.get(), Registration.MININGGADGET_FANCY.get(), Registration.MININGGADGET_SIMPLE.get() diff --git a/src/main/java/com/direwolf20/mininggadgets/common/blocks/ModificationTable.java b/src/main/java/com/direwolf20/mininggadgets/common/blocks/ModificationTable.java index 3dab3ca9..da1f5593 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/blocks/ModificationTable.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/blocks/ModificationTable.java @@ -4,7 +4,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.Containers; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Player; @@ -57,9 +56,9 @@ public BlockEntity newBlockEntity(BlockPos p_153215_, BlockState p_153216_) { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult result) { - if (!world.isClientSide) { - BlockEntity tileEntity = world.getBlockEntity(pos); + public InteractionResult useWithoutItem(BlockState blockState, Level level, BlockPos blockPos, Player player, BlockHitResult hit) { + if (!level.isClientSide) { + BlockEntity tileEntity = level.getBlockEntity(blockPos); if (tileEntity instanceof MenuProvider) { player.openMenu((MenuProvider) tileEntity, tileEntity.getBlockPos()); } else { diff --git a/src/main/java/com/direwolf20/mininggadgets/common/blocks/RenderBlock.java b/src/main/java/com/direwolf20/mininggadgets/common/blocks/RenderBlock.java index 4cddee5d..60a7f212 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/blocks/RenderBlock.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/blocks/RenderBlock.java @@ -25,6 +25,7 @@ public RenderBlock() { Properties.of() .strength(50.0F, 1200.0F) .noOcclusion() + .pushReaction(PushReaction.BLOCK) .isRedstoneConductor((a, b, c) -> false) // @mcp: setOpaque seems to replace isNormalBlock ); } @@ -53,14 +54,6 @@ public RenderShape getRenderShape(BlockState state) { return RenderShape.INVISIBLE; } - /** - * @deprecated call via {@link BlockState#getPistonPushReaction()} whenever possible. Implementing/overriding is fine. - */ - @Override - public PushReaction getPistonPushReaction(BlockState state) { - return PushReaction.BLOCK; - } - @Override public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) { return 0; diff --git a/src/main/java/com/direwolf20/mininggadgets/common/capabilities/EnergisedItem.java b/src/main/java/com/direwolf20/mininggadgets/common/capabilities/EnergisedItem.java index 8cf938d8..4e05448f 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/capabilities/EnergisedItem.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/capabilities/EnergisedItem.java @@ -1,10 +1,6 @@ package com.direwolf20.mininggadgets.common.capabilities; -import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.energy.EnergyStorage; - - -public class EnergisedItem extends EnergyStorage { +/*public class EnergisedItem extends EnergyStorage { private ItemStack stack; public EnergisedItem(ItemStack stack, int capacity) { @@ -49,3 +45,4 @@ public int receiveEnergy(int maxReceive, boolean simulate) { return amount; } } +*/ \ No newline at end of file diff --git a/src/main/java/com/direwolf20/mininggadgets/common/capabilities/EnergyStorageItemstack.java b/src/main/java/com/direwolf20/mininggadgets/common/capabilities/EnergyStorageItemstack.java new file mode 100644 index 00000000..21aa8852 --- /dev/null +++ b/src/main/java/com/direwolf20/mininggadgets/common/capabilities/EnergyStorageItemstack.java @@ -0,0 +1,90 @@ +package com.direwolf20.mininggadgets.common.capabilities; + +import com.direwolf20.mininggadgets.common.util.MGDataComponents; +import net.minecraft.core.HolderLookup; +import net.minecraft.nbt.IntTag; +import net.minecraft.nbt.Tag; +import net.minecraft.world.item.ItemStack; +import net.neoforged.neoforge.energy.EnergyStorage; + +public class EnergyStorageItemstack extends EnergyStorage { + protected final ItemStack itemStack; + + public EnergyStorageItemstack(int capacity, ItemStack itemStack) { + super(capacity, capacity, capacity, 0); + this.itemStack = itemStack; + this.energy = itemStack.getOrDefault(MGDataComponents.FORGE_ENERGY, 0); + } + + public void setEnergy(int energy) { + this.energy = energy; + itemStack.set(MGDataComponents.FORGE_ENERGY, energy); + } + + public void updatedMaxEnergy(int max) { + itemStack.set(MGDataComponents.FORGE_ENERGY_MAX_ENERGY, max); + this.capacity = max; + this.energy = Math.min(max, this.energy); + + // Ensure the current stored energy is up to date with the new max. + this.receiveEnergy(1, false); + } + + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { + if (!canReceive()) + return 0; + + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + if (!simulate) { + energy += energyReceived; + itemStack.set(MGDataComponents.FORGE_ENERGY, energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + if (!canExtract()) + return 0; + + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (!simulate) { + energy -= energyExtracted; + itemStack.set(MGDataComponents.FORGE_ENERGY, energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored() { + return itemStack.getOrDefault(MGDataComponents.FORGE_ENERGY, 0); + } + + @Override + public int getMaxEnergyStored() { + return capacity; + } + + @Override + public boolean canExtract() { + return this.maxExtract > 0; + } + + @Override + public boolean canReceive() { + return this.maxReceive > 0; + } + + @Override + public Tag serializeNBT(HolderLookup.Provider provider) { + return IntTag.valueOf(this.getEnergyStored()); + } + + @Override + public void deserializeNBT(HolderLookup.Provider provider, Tag nbt) { + if (!(nbt instanceof IntTag intNbt)) + throw new IllegalArgumentException("Can not deserialize to an instance that isn't the default implementation"); + this.energy = intNbt.getAsInt(); + } +} diff --git a/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java b/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java index a6595c83..aadf9ef4 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java @@ -1,7 +1,7 @@ package com.direwolf20.mininggadgets.common.containers; -import com.direwolf20.mininggadgets.common.capabilities.EnergisedItem; +import com.direwolf20.mininggadgets.common.capabilities.EnergyStorageItemstack; import com.direwolf20.mininggadgets.common.items.MiningGadget; import com.direwolf20.mininggadgets.common.items.UpgradeCard; import com.direwolf20.mininggadgets.common.items.gadget.MiningProperties; @@ -58,7 +58,7 @@ public static boolean insertButton(ModificationTableContainer container, ItemSta UpgradeBatteryLevels.getBatteryByLevel(card.getTier()).ifPresent(power -> { var cap = laser.getCapability(Capabilities.EnergyStorage.ITEM); if (cap == null) return; - ((EnergisedItem) cap).updatedMaxEnergy(power.getPower()); + ((EnergyStorageItemstack) cap).updatedMaxEnergy(power.getPower()); if (card.getTier() == Upgrade.BATTERY_CREATIVE.getTier()) { cap.receiveEnergy(cap.getMaxEnergyStored() - cap.getEnergyStored(), false); } @@ -108,7 +108,7 @@ public static void extractButton(ModificationTableContainer container, ServerPla MiningProperties.setBatteryTier(laser, 0); var cap = laser.getCapability(Capabilities.EnergyStorage.ITEM); if (cap == null) return; - ((EnergisedItem) cap).updatedMaxEnergy(UpgradeBatteryLevels.BATTERY.getPower()); + ((EnergyStorageItemstack) cap).updatedMaxEnergy(UpgradeBatteryLevels.BATTERY.getPower()); } }); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/data/Generator.java b/src/main/java/com/direwolf20/mininggadgets/common/data/Generator.java index 6b9dcfbe..2a602589 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/data/Generator.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/data/Generator.java @@ -3,13 +3,18 @@ import com.direwolf20.mininggadgets.common.MiningGadgets; import net.minecraft.data.DataGenerator; import net.minecraft.data.PackOutput; +import net.minecraft.data.loot.LootTableProvider; +import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.common.data.ExistingFileHelper; import net.neoforged.neoforge.data.event.GatherDataEvent; +import java.util.Collections; +import java.util.List; -@Mod.EventBusSubscriber(modid = MiningGadgets.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) + +@EventBusSubscriber(modid = MiningGadgets.MOD_ID, bus = EventBusSubscriber.Bus.MOD) public class Generator { @SubscribeEvent public static void gatherData(GatherDataEvent event) { @@ -24,8 +29,9 @@ public static void gatherData(GatherDataEvent event) { generator.addProvider(includeClient, new GeneratorItemModels(packOutput, helper)); // Server - generator.addProvider(includeServer, new GeneratorLoot(packOutput)); - generator.addProvider(includeServer, new GeneratorRecipes(packOutput)); + generator.addProvider(event.includeServer(), new LootTableProvider(packOutput, Collections.emptySet(), + List.of(new LootTableProvider.SubProviderEntry(GeneratorLoot::new, LootContextParamSets.BLOCK)), event.getLookupProvider())); + generator.addProvider(includeServer, new GeneratorRecipes(packOutput, event.getLookupProvider())); generator.addProvider(includeServer, new GeneratorBlockTags(packOutput, event.getLookupProvider(), generator, helper)); generator.addProvider(includeServer, new GeneratorBlockStates(packOutput, helper)); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorBlockStates.java b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorBlockStates.java index ba319b28..43a79713 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorBlockStates.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorBlockStates.java @@ -17,14 +17,6 @@ public GeneratorBlockStates(PackOutput output, ExistingFileHelper exFileHelper) @Override protected void registerStatesAndModels() { -// horizontalBlock(ModBlocks.MODIFICATION_TABLE.get(), models().orientableWithBottom( -// Objects.requireNonNull(ModBlocks.MODIFICATION_TABLE.get().getRegistryName()).getPath(), -// modLoc("block/modificationtable_side"), -// modLoc("block/modificationtable_front"), -// modLoc("block/modificationtable_bottom"), -// modLoc("block/modificationtable_top") -// ).texture("particle", modLoc("block/modificationtable_side"))); - horizontalBlock(Registration.MODIFICATION_TABLE.get(), new ModelFile.UncheckedModelFile(modLoc("block/modificationtable"))); // Render block diff --git a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLoot.java b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLoot.java index 18d554c6..905bdccf 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLoot.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLoot.java @@ -1,48 +1,26 @@ package com.direwolf20.mininggadgets.common.data; import com.direwolf20.mininggadgets.setup.Registration; -import com.google.common.collect.ImmutableList; -import net.minecraft.data.PackOutput; -import net.minecraft.data.loot.BlockLootSubProvider; -import net.minecraft.data.loot.LootTableProvider; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.flag.FeatureFlags; +import net.minecraft.data.loot.packs.VanillaBlockLoot; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.storage.loot.LootDataId; -import net.minecraft.world.level.storage.loot.LootDataType; -import net.minecraft.world.level.storage.loot.LootTable; -import net.minecraft.world.level.storage.loot.ValidationContext; -import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; +import net.neoforged.neoforge.registries.DeferredHolder; -import java.util.Collections; -import java.util.Map; -import java.util.Set; +import java.util.ArrayList; +import java.util.List; -public class GeneratorLoot extends LootTableProvider { - public GeneratorLoot(PackOutput output) { - super(output, Set.of(), ImmutableList.of( - new SubProviderEntry(Blocks::new, LootContextParamSets.BLOCK) - )); - } +public class GeneratorLoot extends VanillaBlockLoot { @Override - protected void validate(Map map, ValidationContext validationContext) { - map.forEach((name, table) -> table.validate(validationContext.setParams(table.getParamSet()).enterElement("{" + name + "}", new LootDataId<>(LootDataType.TABLE, name)))); + protected void generate() { + dropSelf(Registration.MODIFICATION_TABLE.get()); + add(Registration.RENDER_BLOCK.get(), noDrop()); + add(Registration.MINERS_LIGHT.get(), noDrop()); } - private static class Blocks extends BlockLootSubProvider { - protected Blocks() { - super(Set.of(), FeatureFlags.REGISTRY.allFlags()); - } - - @Override - protected void generate() { - this.dropSelf(Registration.MODIFICATION_TABLE.get()); - } - - @Override - protected Iterable getKnownBlocks() { - return Collections.singletonList(Registration.MODIFICATION_TABLE.get()); - } + @Override + protected Iterable getKnownBlocks() { + List knownBlocks = new ArrayList<>(); + knownBlocks.addAll(Registration.BLOCKS.getEntries().stream().map(DeferredHolder::get).toList()); + return knownBlocks; } } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorRecipes.java b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorRecipes.java index fba0a74d..8804ec16 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorRecipes.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorRecipes.java @@ -1,6 +1,7 @@ package com.direwolf20.mininggadgets.common.data; import com.direwolf20.mininggadgets.setup.Registration; +import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.RecipeOutput; @@ -11,11 +12,13 @@ import net.neoforged.neoforge.common.Tags; import org.jetbrains.annotations.NotNull; +import java.util.concurrent.CompletableFuture; + import static com.direwolf20.mininggadgets.setup.Registration.*; public class GeneratorRecipes extends RecipeProvider { - public GeneratorRecipes(PackOutput output) { - super(output); + public GeneratorRecipes(PackOutput output, CompletableFuture completableFuture) { + super(output, completableFuture); } /** diff --git a/src/main/java/com/direwolf20/mininggadgets/common/events/ServerTickHandler.java b/src/main/java/com/direwolf20/mininggadgets/common/events/ServerTickHandler.java index c21566b2..b659a3b6 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/events/ServerTickHandler.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/events/ServerTickHandler.java @@ -1,11 +1,11 @@ package com.direwolf20.mininggadgets.common.events; import com.direwolf20.mininggadgets.common.network.data.DurabilitySyncPayload; +import com.direwolf20.mininggadgets.common.util.CodecHelpers; import net.minecraft.core.BlockPos; -import net.minecraft.util.Tuple; import net.minecraft.world.level.Level; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.neoforge.event.TickEvent; +import net.neoforged.neoforge.event.tick.ServerTickEvent; import net.neoforged.neoforge.network.PacketDistributor; import java.util.ArrayList; @@ -13,21 +13,19 @@ public class ServerTickHandler { - private static List> updateList = new ArrayList<>(); + private static List updateList = new ArrayList<>(); private static Level serverWorld; @SubscribeEvent - public static void handleTickEndEvent(TickEvent.ServerTickEvent event) { - if (event.phase == TickEvent.Phase.END) { - if (!updateList.isEmpty()) { - PacketDistributor.ALL.noArg().send(new DurabilitySyncPayload(List.copyOf(updateList))); - updateList.clear(); - } + public static void handleTickEndEvent(ServerTickEvent.Post event) { + if (!updateList.isEmpty()) { + PacketDistributor.sendToAllPlayers(new DurabilitySyncPayload(List.copyOf(updateList))); + updateList.clear(); } } public static void addToList(BlockPos pos, int durability, Level world) { - updateList.add(new Tuple<>(pos, durability)); + updateList.add(new CodecHelpers.DurabilitySyncData(pos, durability)); serverWorld = world; } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java b/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java index b872893b..8af7f215 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java @@ -11,6 +11,7 @@ import com.direwolf20.mininggadgets.common.sounds.LaserLoopSound; import com.direwolf20.mininggadgets.common.sounds.OurSounds; import com.direwolf20.mininggadgets.common.tiles.RenderBlockTileEntity; +import com.direwolf20.mininggadgets.common.util.CodecHelpers; import com.direwolf20.mininggadgets.common.util.MagicHelpers; import com.direwolf20.mininggadgets.common.util.VectorHelper; import com.direwolf20.mininggadgets.setup.Config; @@ -23,7 +24,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.server.level.ServerLevel; @@ -53,9 +53,7 @@ import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.event.level.BlockEvent; -import org.jetbrains.annotations.NotNull; -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -77,9 +75,8 @@ public int getEnergyMax() { return Config.MININGGADGET_MAXPOWER.get(); } - //TODO Add an override for onCreated and initialize all NBT Tags in it - - @Override + //TODO Still Needed? + /*@Override public void verifyTagAfterLoad(@NotNull CompoundTag tag) { if (UpgradeTools.containsUpgrades(tag)) { UpgradeTools.walkUpgradesOnTag(tag, (CompoundTag upgradeTag, String upgradeName) -> { @@ -89,7 +86,7 @@ public void verifyTagAfterLoad(@NotNull CompoundTag tag) { return null; }); } - } + }*/ @Override public int getMaxDamage(ItemStack stack) { @@ -135,16 +132,16 @@ public int getBarColor(ItemStack stack) { @OnlyIn(Dist.CLIENT) @Override - public void appendHoverText(ItemStack stack, @Nullable Level world, List tooltip, TooltipFlag flag) { - super.appendHoverText(stack, world, tooltip, flag); - - List upgrades = UpgradeTools.getUpgrades(stack); + public void appendHoverText(ItemStack stack, Item.TooltipContext context, List tooltip, TooltipFlag flagIn) { + super.appendHoverText(stack, context, tooltip, flagIn); Minecraft mc = Minecraft.getInstance(); - - if (world == null || mc.player == null) { + if (mc.level == null || mc.player == null) { return; } + List upgrades = UpgradeTools.getUpgrades(stack); + + boolean sneakPressed = Screen.hasShiftDown(); if (!sneakPressed) { @@ -388,37 +385,56 @@ public void onUseTick(Level world, LivingEntity livingEntity, ItemStack stack, i if (!world.isClientSide && stack.getHoverName().getString().toLowerCase(Locale.ROOT).contains("rgb")) { - float beam2r = MiningProperties.getColor(stack, MiningProperties.COLOR_RED_INNER) / 255f; - float beam2g = MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN_INNER) / 255f; - float beam2b = MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE_INNER) / 255f; - float r = MiningProperties.getColor(stack, MiningProperties.COLOR_RED) / 255f; - float g = MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN) / 255f; - float b = MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE) / 255f; + CodecHelpers.LaserColor laserColor = MiningProperties.getColors(stack); + float beam2r = laserColor.innerRed() / 255f; + float beam2g = laserColor.innerGreen() / 255f; + float beam2b = laserColor.innerBlue() / 255f; + float r = laserColor.red() / 255f; + float g = laserColor.green() / 255f; + float b = laserColor.blue() / 255f; + + + // Calculate new color values based on conditions + short newInnerRed = laserColor.innerRed(); + short newInnerGreen = laserColor.innerGreen(); + short newInnerBlue = laserColor.innerBlue(); + short newRed = laserColor.red(); + short newGreen = laserColor.green(); + short newBlue = laserColor.blue(); + + // Update inner beam colors if (beam2r < 1 && beam2g == 0) - MiningProperties.setColor(stack, (short) (beam2r * 255f + Math.min(255-(beam2r * 255f), 5)), MiningProperties.COLOR_RED_INNER); + newInnerRed = (short) (beam2r * 255f + Math.min(255 - (beam2r * 255f), 5)); else if (beam2b > 0 && beam2r == 1) - MiningProperties.setColor(stack, (short) (beam2b * 255f - Math.min(Math.abs(0-(beam2b * 255f)), 5)), MiningProperties.COLOR_BLUE_INNER); + newInnerBlue = (short) (beam2b * 255f - Math.min(Math.abs(0 - (beam2b * 255f)), 5)); else if (beam2g < 1 && beam2r == 1) - MiningProperties.setColor(stack, (short) (beam2g * 255f + Math.min(255-(beam2g * 255f), 5)), MiningProperties.COLOR_GREEN_INNER); + newInnerGreen = (short) (beam2g * 255f + Math.min(255 - (beam2g * 255f), 5)); else if (beam2r > 0 && beam2g == 1) - MiningProperties.setColor(stack, (short) (beam2r * 255f - Math.min(Math.abs(0-(beam2r * 255f)), 5)), MiningProperties.COLOR_RED_INNER); + newInnerRed = (short) (beam2r * 255f - Math.min(Math.abs(0 - (beam2r * 255f)), 5)); else if (beam2b < 1 && beam2g == 1) - MiningProperties.setColor(stack, (short) (beam2b * 255f + Math.min(255-(beam2b * 255f), 5)), MiningProperties.COLOR_BLUE_INNER); + newInnerBlue = (short) (beam2b * 255f + Math.min(255 - (beam2b * 255f), 5)); else if (beam2g > 0 && beam2b == 1) - MiningProperties.setColor(stack, (short) (beam2g * 255f - Math.min(Math.abs(0-(beam2g * 255f)), 5)), MiningProperties.COLOR_GREEN_INNER); + newInnerGreen = (short) (beam2g * 255f - Math.min(Math.abs(0 - (beam2g * 255f)), 5)); + // Update outer beam colors if (r < 1 && g == 0) - MiningProperties.setColor(stack, (short) (r * 255f + Math.min(255-(r * 255f), 5)), MiningProperties.COLOR_RED); + newRed = (short) (r * 255f + Math.min(255 - (r * 255f), 5)); else if (b > 0 && r == 1) - MiningProperties.setColor(stack, (short) (b * 255f - Math.min(Math.abs(0-(b * 255f)), 5)), MiningProperties.COLOR_BLUE); + newBlue = (short) (b * 255f - Math.min(Math.abs(0 - (b * 255f)), 5)); else if (g < 1 && r == 1) - MiningProperties.setColor(stack, (short) (g * 255f + Math.min(255-(g * 255f), 5)), MiningProperties.COLOR_GREEN); + newGreen = (short) (g * 255f + Math.min(255 - (g * 255f), 5)); else if (r > 0 && g == 1) - MiningProperties.setColor(stack, (short) (r * 255f - Math.min(Math.abs(0-(r * 255f)), 5)), MiningProperties.COLOR_RED); + newRed = (short) (r * 255f - Math.min(Math.abs(0 - (r * 255f)), 5)); else if (b < 1 && g == 1) - MiningProperties.setColor(stack, (short) (b * 255f + Math.min(255-(b * 255f), 5)), MiningProperties.COLOR_BLUE); + newBlue = (short) (b * 255f + Math.min(255 - (b * 255f), 5)); else if (g > 0 && b == 1) - MiningProperties.setColor(stack, (short) (g * 255f - Math.min(Math.abs(0-(g * 255f)), 5)), MiningProperties.COLOR_GREEN); + newGreen = (short) (g * 255f - Math.min(Math.abs(0 - (g * 255f)), 5)); + + // Construct the new LaserColor object + CodecHelpers.LaserColor newLaserColor = new CodecHelpers.LaserColor(newRed, newGreen, newBlue, newInnerRed, newInnerGreen, newInnerBlue); + + // Set the new color on the item stack + MiningProperties.setColor(stack, newLaserColor); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/UpgradeCard.java b/src/main/java/com/direwolf20/mininggadgets/common/items/UpgradeCard.java index 85cd76ab..49e03e4f 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/UpgradeCard.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/UpgradeCard.java @@ -5,21 +5,24 @@ import com.direwolf20.mininggadgets.common.util.MagicHelpers; import com.direwolf20.mininggadgets.setup.Config; import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; import net.minecraft.network.chat.Component; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; -import javax.annotation.Nullable; import java.util.List; public class UpgradeCard extends Item { private Upgrade upgrade; @Override - public void appendHoverText(ItemStack stack, @Nullable Level world, List tooltip, TooltipFlag flag) { - super.appendHoverText(stack, world, tooltip, flag); + public void appendHoverText(ItemStack stack, Item.TooltipContext context, List tooltip, TooltipFlag flagIn) { + super.appendHoverText(stack, context, tooltip, flagIn); + Minecraft mc = Minecraft.getInstance(); + if (mc.level == null || mc.player == null) { + return; + } if (stack.getItem() instanceof UpgradeCard) { Upgrade upgrade = ((UpgradeCard) stack.getItem()).upgrade; int cost = upgrade.getCostPerBlock(); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/gadget/MiningProperties.java b/src/main/java/com/direwolf20/mininggadgets/common/items/gadget/MiningProperties.java index 6a707c66..3a363812 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/gadget/MiningProperties.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/gadget/MiningProperties.java @@ -1,6 +1,9 @@ package com.direwolf20.mininggadgets.common.items.gadget; import com.direwolf20.mininggadgets.common.MiningGadgets; +import com.direwolf20.mininggadgets.common.util.CodecHelpers; +import com.direwolf20.mininggadgets.common.util.MGDataComponents; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; @@ -66,28 +69,20 @@ public Component getTooltip() { } } - public static short getColor(ItemStack gadget, String color) { - CompoundTag compound = gadget.getOrCreateTag(); - if (color.equals(COLOR_RED) || color.contains("Inner")) { - return !compound.contains(color) ? setColor(gadget, (short) 255, color) : compound.getShort(color); - } else { - return !compound.contains(color) ? setColor(gadget, (short) 0, color) : compound.getShort(color); - } + public static CodecHelpers.LaserColor getColors(ItemStack gadget) { + return gadget.getOrDefault(MGDataComponents.LASER_COLOR, new CodecHelpers.LaserColor((short) 255, (short) 0, (short) 0, (short) 255, (short) 255, (short) 255)); } - public static short setColor(ItemStack gadget, short colorValue, String color) { - gadget.getOrCreateTag().putShort(color, colorValue); - return colorValue; + public static void setColor(ItemStack gadget, CodecHelpers.LaserColor laserColor) { + gadget.set(MGDataComponents.LASER_COLOR, laserColor); } - public static BreakTypes setBreakType(ItemStack gadget, BreakTypes breakType) { - gadget.getOrCreateTag().putByte(BREAK_TYPE, (byte) breakType.ordinal()); - return breakType; + public static void setBreakType(ItemStack gadget, BreakTypes breakType) { + gadget.set(MGDataComponents.BREAK_TYPE, (byte) breakType.ordinal()); } public static void nextBreakType(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - if (compound.contains(BREAK_TYPE)) { + if (gadget.has(MGDataComponents.BREAK_TYPE)) { int type = getBreakType(gadget).ordinal() == BreakTypes.values().length - 1 ? 0 : getBreakType(gadget).ordinal() + 1; setBreakType(gadget, BreakTypes.values()[type]); } else { @@ -96,182 +91,148 @@ public static void nextBreakType(ItemStack gadget) { } public static BreakTypes getBreakType(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(BREAK_TYPE) ? setBreakType(gadget, BreakTypes.SHRINK) : BreakTypes.values()[compound.getByte(BREAK_TYPE)]; + return BreakTypes.values()[gadget.getOrDefault(MGDataComponents.BREAK_TYPE, (byte) 0)]; } - public static int setSpeed(ItemStack gadget, int speed) { - gadget.getOrCreateTag().putInt(KEY_SPEED, speed); - return speed; + public static void setSpeed(ItemStack gadget, int speed) { + gadget.set(MGDataComponents.SPEED, speed); } public static int getSpeed(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(KEY_SPEED) ? setSpeed(gadget, 1) : compound.getInt(KEY_SPEED); + return gadget.getOrDefault(MGDataComponents.SPEED, 1); } - public static int setRange(ItemStack gadget, int range) { - gadget.getOrCreateTag().putInt(KEY_RANGE, range); - return range; + public static void setRange(ItemStack gadget, int range) { + gadget.set(MGDataComponents.RANGE, range); } public static int getRange(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(KEY_RANGE) ? setRange(gadget, 1) : compound.getInt(KEY_RANGE); + return gadget.getOrDefault(MGDataComponents.RANGE, 1); } - public static int setBeamRange(ItemStack gadget, int range) { - gadget.getOrCreateTag().putInt(KEY_BEAM_RANGE, range); - return range; + public static void setBeamRange(ItemStack gadget, int range) { + gadget.set(MGDataComponents.BEAM_RANGE, range); } - public static int setBeamMaxRange(ItemStack gadget, int range) { - gadget.getOrCreateTag().putInt(KEY_MAX_BEAM_RANGE, range); - return range; + public static void setBeamMaxRange(ItemStack gadget, int range) { + gadget.set(MGDataComponents.MAX_BEAM_RANGE, range); } public static int getBeamRange(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(KEY_BEAM_RANGE) ? setBeamRange(gadget, MIN_RANGE) : compound.getInt(KEY_BEAM_RANGE); + return gadget.getOrDefault(MGDataComponents.BEAM_RANGE, 1); } public static int getBeamMaxRange(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(KEY_MAX_BEAM_RANGE) ? setBeamMaxRange(gadget, MIN_RANGE) : compound.getInt(KEY_MAX_BEAM_RANGE); + return gadget.getOrDefault(MGDataComponents.MAX_BEAM_RANGE, 1); } - public static int setMaxMiningRange(ItemStack gadget, int range) { - gadget.getOrCreateTag().putInt(KEY_MAX_MINING_RANGE, range); - return range; + public static void setMaxMiningRange(ItemStack gadget, int range) { + gadget.set(MGDataComponents.MAX_MINING_RANGE, range); } public static int getMaxMiningRange(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(KEY_MAX_MINING_RANGE) ? setMaxMiningRange(gadget, 1) : compound.getInt(KEY_MAX_MINING_RANGE); + return gadget.getOrDefault(MGDataComponents.MAX_MINING_RANGE, 1); } - public static boolean setWhitelist(ItemStack gadget, boolean isWhitelist) { - gadget.getOrCreateTag().putBoolean(KEY_WHITELIST, isWhitelist); - return isWhitelist; + public static void setWhitelist(ItemStack gadget, boolean isWhitelist) { + gadget.set(MGDataComponents.WHITELIST, isWhitelist); } public static boolean getWhiteList(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(KEY_WHITELIST) ? setWhitelist(gadget, true) : compound.getBoolean(KEY_WHITELIST); + return gadget.getOrDefault(MGDataComponents.WHITELIST, true); } - public static boolean setCanMine(ItemStack gadget, boolean canMine) { - gadget.getOrCreateTag().putBoolean(CAN_MINE, canMine); - return canMine; + public static void setCanMine(ItemStack gadget, boolean canMine) { + gadget.set(MGDataComponents.CAN_MINE, canMine); } public static boolean getCanMine(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(CAN_MINE) ? setCanMine(gadget, true) : compound.getBoolean(CAN_MINE); + return gadget.getOrDefault(MGDataComponents.CAN_MINE, true); } - public static boolean setPrecisionMode(ItemStack gadget, boolean precisionMode) { - gadget.getOrCreateTag().putBoolean(PRECISION_MODE, precisionMode); - return precisionMode; + public static void setPrecisionMode(ItemStack gadget, boolean precisionMode) { + gadget.set(MGDataComponents.PRECISION_MODE, precisionMode); } public static boolean getPrecisionMode(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(PRECISION_MODE) ? setPrecisionMode(gadget, false) : compound.getBoolean(PRECISION_MODE); + return gadget.getOrDefault(MGDataComponents.PRECISION_MODE, false); } - public static SizeMode setSizeMode(ItemStack gadget, SizeMode sizeMode) { - gadget.getOrCreateTag().putByte(KEY_SIZE_MODE, (byte) sizeMode.ordinal()); - return sizeMode; + public static void setSizeMode(ItemStack gadget, SizeMode sizeMode) { + gadget.set(MGDataComponents.SIZE_MODE, (byte) sizeMode.ordinal()); } public static SizeMode nextSizeMode(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - if (compound.contains(KEY_SIZE_MODE)) { + if (gadget.has(MGDataComponents.SIZE_MODE)) { int type = getSizeMode(gadget).ordinal() == SizeMode.values().length - 1 ? 0 : getSizeMode(gadget).ordinal() + 1; - return setSizeMode(gadget, SizeMode.values()[type]); + setSizeMode(gadget, SizeMode.values()[type]); } else { - return setSizeMode(gadget, SizeMode.NORMAL); + setSizeMode(gadget, SizeMode.NORMAL); } + return getSizeMode(gadget); } public static SizeMode getSizeMode(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(KEY_SIZE_MODE) ? setSizeMode(gadget, SizeMode.NORMAL) : SizeMode.values()[compound.getByte(KEY_SIZE_MODE)]; + return SizeMode.values()[gadget.getOrDefault(MGDataComponents.SIZE_MODE, (byte) SizeMode.NORMAL.ordinal())]; } - public static float setVolume(ItemStack gadget, float volume) { - gadget.getOrCreateTag().putFloat(VOLUME, Math.max(0.0f, Math.min(1.0f, volume))); - return volume; + public static void setVolume(ItemStack gadget, float volume) { + gadget.set(MGDataComponents.VOLUME, volume); } public static float getVolume(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(VOLUME) ? setVolume(gadget, 1.0f) : compound.getFloat(VOLUME); + return gadget.getOrDefault(MGDataComponents.VOLUME, 1.0f); } - public static int setFreezeDelay(ItemStack gadget, int volume) { - gadget.getOrCreateTag().putInt(FREEZE_PARTICLE_DELAY, Math.max(0, Math.min(10, volume))); - return volume; + public static void setFreezeDelay(ItemStack gadget, int freezeDelay) { + gadget.set(MGDataComponents.FREEZE_DELAY, freezeDelay); } public static int getFreezeDelay(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(FREEZE_PARTICLE_DELAY) ? setFreezeDelay(gadget, 0) : compound.getInt(FREEZE_PARTICLE_DELAY); + return gadget.getOrDefault(MGDataComponents.FREEZE_DELAY, 0); } - public static int setBatteryTier(ItemStack gadget, int tier) { - gadget.getOrCreateTag().putInt(KEY_BATTERY_TIER, tier); - return tier; + public static void setBatteryTier(ItemStack gadget, int tier) { + gadget.set(MGDataComponents.BATTERY_TIER, tier); } public static int getBatteryTier(ItemStack gadget) { - CompoundTag compound = gadget.getOrCreateTag(); - return !compound.contains(KEY_BATTERY_TIER) ? setBatteryTier(gadget, 0) : compound.getInt(KEY_BATTERY_TIER); - } - - /** - * So this is a bit fun, because we only need the items in our list we're ditching half the data - * that the `Items` actually contains. - * - * @implNote Please do not use {@link #deserializeItemStackList(CompoundTag)} or {@link #serializeItemStackList(List)} - * if you wish to maintain the original tag data on the gadget. These have specific uses. - * - * See {@link com.direwolf20.mininggadgets.common.network.handler.PacketOpenFilterContainer} for an - * understanding on why you shouldn't change the tad data on the gadget directly. - */ + return gadget.getOrDefault(MGDataComponents.BATTERY_TIER, 0); + } + public static List getFiltersAsList(ItemStack gadget) { - return deserializeItemStackList(gadget.getOrCreateTagElement(MiningProperties.KEY_FILTERS)); + return gadget.getOrDefault(MGDataComponents.FILTER_LIST, new ArrayList<>()); + } + + public static void setFiltersAsList(ItemStack gadget, List stacks) { + gadget.set(MGDataComponents.FILTER_LIST, stacks); } // mostly stolen from ItemStackHandler - public static List deserializeItemStackList(CompoundTag nbt) { + public static List deserializeItemStackList(CompoundTag nbt, HolderLookup.Provider provider) { List stacks = new ArrayList<>(); ListTag tagList = nbt.getList("Items", Tag.TAG_COMPOUND); - for (int i = 0; i < tagList.size(); i++) { CompoundTag itemTags = tagList.getCompound(i); - stacks.add(ItemStack.of(itemTags)); + stacks.add(ItemStack.parse(provider, itemTags).orElse(ItemStack.EMPTY)); } return stacks; } - public static CompoundTag serializeItemStackList(List stacks) { + public static CompoundTag serializeItemStackList(List stacks, HolderLookup.Provider provider) { ListTag nbtTagList = new ListTag(); - for (int i = 0; i < stacks.size(); i++) - { - if (stacks.get(i).isEmpty()) - continue; - - CompoundTag itemTag = new CompoundTag(); - stacks.get(i).save(itemTag); - nbtTagList.add(itemTag); + for (int i = 0; i < stacks.size(); i++) { + if (!stacks.get(i).isEmpty()) { + CompoundTag itemTag = new CompoundTag(); + itemTag.putInt("Slot", i); + nbtTagList.add(stacks.get(i).save(provider, itemTag)); + } } - CompoundTag nbt = new CompoundTag(); nbt.put("Items", nbtTagList); + nbt.putInt("Size", stacks.size()); return nbt; } } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/UpgradeTools.java b/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/UpgradeTools.java index 4b9ffcd4..1c6417ef 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/UpgradeTools.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/UpgradeTools.java @@ -2,19 +2,18 @@ import com.direwolf20.mininggadgets.common.items.MiningGadget; import com.direwolf20.mininggadgets.common.items.UpgradeCard; +import com.direwolf20.mininggadgets.common.util.CodecHelpers; +import com.direwolf20.mininggadgets.common.util.MGDataComponents; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.common.I18nExtension; import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.function.BiFunction; -import java.util.stream.Collectors; public class UpgradeTools { private static final String KEY_UPGRADES = "upgrades"; @@ -27,15 +26,68 @@ public class UpgradeTools { * use {@link MiningGadget#applyUpgrade(ItemStack, UpgradeCard)} unless you actually require this * kind of unchecked functionality */ - private static void setUpgradeNBT(CompoundTag nbt, UpgradeCard upgrade) { - ListTag list = nbt.getList(KEY_UPGRADES, Tag.TAG_COMPOUND); + private static void setUpgradeNBT(ItemStack tool, UpgradeCard upgrade) { + List upgradeData = tool.getOrDefault(MGDataComponents.UPGRADE_DATA, new ArrayList<>()); + CodecHelpers.UpgradeData newUpgrade = new CodecHelpers.UpgradeData(upgrade.getUpgrade().getName(), upgrade.getUpgrade().isEnabled()); + upgradeData.removeIf(k -> k.upgradeName().equals(upgrade.getUpgrade().getName())); + upgradeData.add(newUpgrade); + tool.set(MGDataComponents.UPGRADE_DATA, upgradeData); + } + + public static List setUpgrades(ItemStack tool, List laserUpgrades) { + List upgradeData = new ArrayList<>(); + laserUpgrades.forEach(upgrade -> { + CodecHelpers.UpgradeData newUpgrade = new CodecHelpers.UpgradeData(upgrade.getName(), upgrade.isEnabled()); + upgradeData.add(newUpgrade); + }); + tool.set(MGDataComponents.UPGRADE_DATA, upgradeData); + return upgradeData; + } + + public static void setUpgrade(ItemStack tool, UpgradeCard upgrade) { + setUpgradeNBT(tool, upgrade); + } + + public static void updateUpgrade(ItemStack tool, Upgrade upgrade) { + List upgradeData = tool.getOrDefault(MGDataComponents.UPGRADE_DATA, new ArrayList<>()); + List newUpgradeData = new ArrayList<>(); + + upgradeData.forEach(e -> { + String name = e.upgradeName(); + boolean enabled = e.isActive(); + + if ((name.contains(Upgrade.FORTUNE_1.getBaseName()) && enabled && upgrade.lazyIs(Upgrade.SILK)) + || (name.equals(Upgrade.SILK.getBaseName()) && enabled && upgrade.lazyIs(Upgrade.FORTUNE_1))) + enabled = false; + + if (name.equals(upgrade.getName())) + enabled = !enabled; + + newUpgradeData.add(new CodecHelpers.UpgradeData(name, enabled)); + }); + + tool.set(MGDataComponents.UPGRADE_DATA, newUpgradeData); + } - CompoundTag compound = new CompoundTag(); - compound.putString(KEY_UPGRADE, upgrade.getUpgrade().getName()); - compound.putBoolean(KEY_ENABLED, upgrade.getUpgrade().isEnabled()); + // Return all upgrades in the item. + public static List getUpgrades(ItemStack tool) { + List upgradeData = tool.getOrDefault(MGDataComponents.UPGRADE_DATA, new ArrayList<>()); + + List functionalUpgrades = new ArrayList<>(); + if (upgradeData.isEmpty()) + return functionalUpgrades; + + for (CodecHelpers.UpgradeData data : upgradeData) { + // Skip unknowns + Upgrade type = getUpgradeByName(data.upgradeName()); + if (type == null) + continue; - list.add(compound); - nbt.put(KEY_UPGRADES, list); + type.setEnabled(data.isActive()); + functionalUpgrades.add(type); + } + + return functionalUpgrades; } public static CompoundTag setUpgradesNBT(List laserUpgrades) { @@ -53,30 +105,6 @@ public static CompoundTag setUpgradesNBT(List laserUpgrades) { return listCompound; } - public static void setUpgrade(ItemStack tool, UpgradeCard upgrade) { - CompoundTag tagCompound = tool.getOrCreateTag(); - setUpgradeNBT(tagCompound, upgrade); - } - - public static void updateUpgrade(ItemStack tool, Upgrade upgrade) { - CompoundTag tagCompound = tool.getOrCreateTag(); - ListTag list = tagCompound.getList(KEY_UPGRADES, Tag.TAG_COMPOUND); - - list.forEach( e -> { - CompoundTag compound = (CompoundTag) e; - String name = compound.getString(KEY_UPGRADE); - boolean enabled = compound.getBoolean(KEY_ENABLED); - - if( (name.contains(Upgrade.FORTUNE_1.getBaseName()) && enabled && upgrade.lazyIs(Upgrade.SILK) ) - || (name.equals(Upgrade.SILK.getBaseName()) && enabled && upgrade.lazyIs(Upgrade.FORTUNE_1) )) - compound.putBoolean(KEY_ENABLED, false); - - if( name.equals(upgrade.getName()) ) - compound.putBoolean(KEY_ENABLED, !compound.getBoolean(KEY_ENABLED)); - }); - } - - // Return all upgrades in the item. public static List getUpgradesFromTag(CompoundTag tagCompound) { ListTag upgrades = tagCompound.getList(KEY_UPGRADES, Tag.TAG_COMPOUND); @@ -99,21 +127,20 @@ public static List getUpgradesFromTag(CompoundTag tagCompound) { return functionalUpgrades; } - public static List getActiveUpgradesFromTag(CompoundTag tagCompound) { - ListTag upgrades = tagCompound.getList(KEY_UPGRADES, Tag.TAG_COMPOUND); + public static List getActiveUpgrades(ItemStack tool) { + List upgradeData = tool.getOrDefault(MGDataComponents.UPGRADE_DATA, new ArrayList<>()); List functionalUpgrades = new ArrayList<>(); - if (upgrades.isEmpty()) + if (upgradeData.isEmpty()) return functionalUpgrades; - for (int i = 0; i < upgrades.size(); i++) { - CompoundTag tag = upgrades.getCompound(i); + for (CodecHelpers.UpgradeData data : upgradeData) { - Upgrade type = getUpgradeByName(tag.getString(KEY_UPGRADE)); + Upgrade type = getUpgradeByName(data.upgradeName()); if (type == null) continue; - type.setEnabled(!tag.contains(KEY_ENABLED) || tag.getBoolean(KEY_ENABLED)); + type.setEnabled(data.isActive()); if (type.isEnabled()) functionalUpgrades.add(type); } @@ -121,7 +148,7 @@ public static List getActiveUpgradesFromTag(CompoundTag tagCompound) { return functionalUpgrades; } - public static void walkUpgradesOnTag(CompoundTag tagCompound, BiFunction consumer) { + /*public static void walkUpgradesOnTag(CompoundTag tagCompound, BiFunction consumer) { ListTag upgrades = tagCompound.getList(KEY_UPGRADES, Tag.TAG_COMPOUND); if (upgrades.isEmpty()) @@ -136,7 +163,7 @@ public static void walkUpgradesOnTag(CompoundTag tagCompound, BiFunction getUpgrades(ItemStack tool) { - CompoundTag tagCompound = tool.getOrCreateTag(); - return getUpgradesFromTag(tagCompound); - } - - public static List getActiveUpgrades(ItemStack tool) { - CompoundTag tagCompound = tool.getOrCreateTag(); - return getActiveUpgradesFromTag(tagCompound); - } - public static boolean containsUpgrades(ItemStack tool) { - return tool.getOrCreateTag().contains(KEY_UPGRADES); - } - public static boolean containsUpgrades(CompoundTag tag) { - return tag.contains(KEY_UPGRADES); + return tool.has(MGDataComponents.UPGRADE_DATA); } /** @@ -190,13 +203,9 @@ public static Optional getUpgradeFromGadget(ItemStack tool, Upgrade typ * as the gadget stores the full name and not it's base name */ public static void removeUpgrade(ItemStack tool, Upgrade upgrade) { - CompoundTag tagCompound = tool.getOrCreateTag(); - ListTag upgrades = tagCompound.getList(KEY_UPGRADES, Tag.TAG_COMPOUND); - - // Slightly completed but basically it just makes a new list and collects that back to an ListNBT - tagCompound.put(KEY_UPGRADES, upgrades.stream() - .filter(e -> !((CompoundTag) e).getString(KEY_UPGRADE).equals(upgrade.getName())) - .collect(Collectors.toCollection(ListTag::new))); + List upgradeData = tool.getOrDefault(MGDataComponents.UPGRADE_DATA, new ArrayList<>()); + upgradeData.removeIf(k -> k.upgradeName().equals(upgrade.getName())); + tool.set(MGDataComponents.UPGRADE_DATA, upgradeData); } public static boolean containsUpgrade(ItemStack tool, Upgrade type) { @@ -230,8 +239,8 @@ public static int getMaxBeamRange(int tier) { * @param upgrade the upgrade Enum * @return A formatted string of the Upgrade without it's `Upgrade:` prefix */ - public static Component getName(Upgrade upgrade) { - return Component.literal(I18nExtension.parseMessage(upgrade.getLocal()).replace(I18nExtension.parseMessage(upgrade.getLocalReplacement()), "")); + public static Component getName(Upgrade upgrade) { //TODO Validate what this did + return Component.translatable(upgrade.getLocal());//.replace(Component.translatable(upgrade.getLocalReplacement()), "")); } public static int getMaxMiningRange(int tier) { diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/PacketHandler.java b/src/main/java/com/direwolf20/mininggadgets/common/network/PacketHandler.java index a14ffd33..24839836 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/PacketHandler.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/PacketHandler.java @@ -3,32 +3,32 @@ import com.direwolf20.mininggadgets.common.MiningGadgets; import com.direwolf20.mininggadgets.common.network.data.*; import com.direwolf20.mininggadgets.common.network.handler.*; -import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent; -import net.neoforged.neoforge.network.registration.IPayloadRegistrar; +import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent; +import net.neoforged.neoforge.network.registration.PayloadRegistrar; public class PacketHandler { - public static void registerNetworking(final RegisterPayloadHandlerEvent event) { - final IPayloadRegistrar registrar = event.registrar(MiningGadgets.MOD_ID); + public static void registerNetworking(final RegisterPayloadHandlersEvent event) { + final PayloadRegistrar registrar = event.registrar(MiningGadgets.MOD_ID); // Server side - registrar.play(ExtractUpgradePayload.ID, ExtractUpgradePayload::new, handler -> handler.server(PacketExtractUpgrade.get()::handle)); - registrar.play(UpdateUpgradePayload.ID, UpdateUpgradePayload::new, handler -> handler.server(PacketUpdateUpgrade.get()::handle)); - registrar.play(ChangeMiningSizePayload.ID, ChangeMiningSizePayload::new, handler -> handler.server(PacketChangeMiningSize.get()::handle)); - registrar.play(ChangeMiningSizeModePayload.ID, ChangeMiningSizeModePayload::new, handler -> handler.server(PacketChangeMiningSizeMode.get()::handle)); - registrar.play(ChangeRangePayload.ID, ChangeRangePayload::new, handler -> handler.server(PacketChangeRange.get()::handle)); - registrar.play(ChangeBreakTypePayload.ID, ChangeBreakTypePayload::new, handler -> handler.server(PacketChangeBreakType.get()::handle)); - registrar.play(ChangeColorPayload.ID, ChangeColorPayload::new, handler -> handler.server(PacketChangeColor.get()::handle)); - registrar.play(GhostSlotPayload.ID, GhostSlotPayload::new, handler -> handler.server(PacketGhostSlot.get()::handle)); - registrar.play(OpenFilterContainerPayload.ID, OpenFilterContainerPayload::new, handler -> handler.server(PacketOpenFilterContainer.get()::handle)); - registrar.play(ToggleFiltersPayload.ID, ToggleFiltersPayload::new, handler -> handler.server(PacketToggleFilters.get()::handle)); - registrar.play(TogglePrecisionPayload.ID, TogglePrecisionPayload::new, handler -> handler.server(PacketTogglePrecision.get()::handle)); - registrar.play(ChangeVolumePayload.ID, ChangeVolumePayload::new, handler -> handler.server(PacketChangeVolume.get()::handle)); - registrar.play(ChangeFreezeDelayPayload.ID, ChangeFreezeDelayPayload::new, handler -> handler.server(PacketChangeFreezeDelay.get()::handle)); - registrar.play(InsertUpgradePayload.ID, InsertUpgradePayload::new, handler -> handler.server(PacketInsertUpgrade.get()::handle)); + registrar.playToServer(ExtractUpgradePayload.TYPE, ExtractUpgradePayload.STREAM_CODEC, PacketExtractUpgrade.get()::handle); + registrar.playToServer(UpdateUpgradePayload.TYPE, UpdateUpgradePayload.STREAM_CODEC, PacketUpdateUpgrade.get()::handle); + registrar.playToServer(ChangeMiningSizePayload.TYPE, ChangeMiningSizePayload.STREAM_CODEC, PacketChangeMiningSize.get()::handle); + registrar.playToServer(ChangeMiningSizeModePayload.TYPE, ChangeMiningSizeModePayload.STREAM_CODEC, PacketChangeMiningSizeMode.get()::handle); + registrar.playToServer(ChangeRangePayload.TYPE, ChangeRangePayload.STREAM_CODEC, PacketChangeRange.get()::handle); + registrar.playToServer(ChangeBreakTypePayload.TYPE, ChangeBreakTypePayload.STREAM_CODEC, PacketChangeBreakType.get()::handle); + registrar.playToServer(ChangeColorPayload.TYPE, ChangeColorPayload.STREAM_CODEC, PacketChangeColor.get()::handle); + registrar.playToServer(GhostSlotPayload.TYPE, GhostSlotPayload.STREAM_CODEC, PacketGhostSlot.get()::handle); + registrar.playToServer(OpenFilterContainerPayload.TYPE, OpenFilterContainerPayload.STREAM_CODEC, PacketOpenFilterContainer.get()::handle); + registrar.playToServer(ToggleFiltersPayload.TYPE, ToggleFiltersPayload.STREAM_CODEC, PacketToggleFilters.get()::handle); + registrar.playToServer(TogglePrecisionPayload.TYPE, TogglePrecisionPayload.STREAM_CODEC, PacketTogglePrecision.get()::handle); + registrar.playToServer(ChangeVolumePayload.TYPE, ChangeVolumePayload.STREAM_CODEC, PacketChangeVolume.get()::handle); + registrar.playToServer(ChangeFreezeDelayPayload.TYPE, ChangeFreezeDelayPayload.STREAM_CODEC, PacketChangeFreezeDelay.get()::handle); + registrar.playToServer(InsertUpgradePayload.TYPE, InsertUpgradePayload.STREAM_CODEC, PacketInsertUpgrade.get()::handle); //Client Side - registrar.play(DurabilitySyncPayload.ID, DurabilitySyncPayload::new, handler -> handler.client(PacketDurabilitySync.get()::handle)); + registrar.playToClient(DurabilitySyncPayload.TYPE, DurabilitySyncPayload.STREAM_CODEC, PacketDurabilitySync.get()::handle); } } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeBreakTypePayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeBreakTypePayload.java index f200b74b..46372b80 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeBreakTypePayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeBreakTypePayload.java @@ -1,25 +1,20 @@ package com.direwolf20.mininggadgets.common.network.data; import com.direwolf20.mininggadgets.common.MiningGadgets; -import net.minecraft.network.FriendlyByteBuf; +import io.netty.buffer.ByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; public record ChangeBreakTypePayload() implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "change_break_type"); - - public ChangeBreakTypePayload(final FriendlyByteBuf buffer) { - this(); - } + public static final ChangeBreakTypePayload INSTANCE = new ChangeBreakTypePayload(); + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "change_break_type")); @Override - public void write(FriendlyByteBuf buffer) { - + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.unit(INSTANCE); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeColorPayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeColorPayload.java index 3151a671..b3b94469 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeColorPayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeColorPayload.java @@ -1,37 +1,25 @@ package com.direwolf20.mininggadgets.common.network.data; import com.direwolf20.mininggadgets.common.MiningGadgets; -import net.minecraft.network.FriendlyByteBuf; +import com.direwolf20.mininggadgets.common.util.CodecHelpers; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; public record ChangeColorPayload( - short red, - short green, - short blue, - short red_inner, - short green_inner, - short blue_inner + CodecHelpers.LaserColor laserColor ) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "change_color"); - - public ChangeColorPayload(final FriendlyByteBuf buffer) { - this(buffer.readShort(), buffer.readShort(), buffer.readShort(), buffer.readShort(), buffer.readShort(), buffer.readShort()); - } + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "change_color")); @Override - public void write(FriendlyByteBuf buffer) { - buffer.writeShort(red()); - buffer.writeShort(green()); - buffer.writeShort(blue()); - buffer.writeShort(red_inner()); - buffer.writeShort(green_inner()); - buffer.writeShort(blue_inner()); + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + CodecHelpers.LaserColor.STREAM_CODEC, ChangeColorPayload::laserColor, + ChangeColorPayload::new + ); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeFreezeDelayPayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeFreezeDelayPayload.java index 119dca2b..3a426543 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeFreezeDelayPayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeFreezeDelayPayload.java @@ -2,26 +2,24 @@ import com.direwolf20.mininggadgets.common.MiningGadgets; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; public record ChangeFreezeDelayPayload( int freezeDelay ) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "change_freeze_delay"); - - public ChangeFreezeDelayPayload(final FriendlyByteBuf buffer) { - this(buffer.readInt()); - } + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "change_freeze_delay")); @Override - public void write(FriendlyByteBuf buffer) { - buffer.writeInt(freezeDelay()); + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.INT, ChangeFreezeDelayPayload::freezeDelay, + ChangeFreezeDelayPayload::new + ); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeMiningSizeModePayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeMiningSizeModePayload.java index 3096ecb3..a727ebb6 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeMiningSizeModePayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeMiningSizeModePayload.java @@ -1,25 +1,20 @@ package com.direwolf20.mininggadgets.common.network.data; import com.direwolf20.mininggadgets.common.MiningGadgets; -import net.minecraft.network.FriendlyByteBuf; +import io.netty.buffer.ByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; public record ChangeMiningSizeModePayload() implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "change_mining_size_mode"); - - public ChangeMiningSizeModePayload(final FriendlyByteBuf buffer) { - this(); - } + public static final ChangeMiningSizeModePayload INSTANCE = new ChangeMiningSizeModePayload(); + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "change_mining_size_mode")); @Override - public void write(FriendlyByteBuf buffer) { - + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.unit(INSTANCE); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeMiningSizePayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeMiningSizePayload.java index e9af57b3..23aff303 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeMiningSizePayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeMiningSizePayload.java @@ -1,25 +1,20 @@ package com.direwolf20.mininggadgets.common.network.data; import com.direwolf20.mininggadgets.common.MiningGadgets; -import net.minecraft.network.FriendlyByteBuf; +import io.netty.buffer.ByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; public record ChangeMiningSizePayload() implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "change_mining_size"); - - public ChangeMiningSizePayload(final FriendlyByteBuf buffer) { - this(); - } + public static final ChangeMiningSizePayload INSTANCE = new ChangeMiningSizePayload(); + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "change_mining_size")); @Override - public void write(FriendlyByteBuf buffer) { - + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.unit(INSTANCE); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeRangePayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeRangePayload.java index 1da437cd..30df2b44 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeRangePayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeRangePayload.java @@ -2,26 +2,24 @@ import com.direwolf20.mininggadgets.common.MiningGadgets; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; public record ChangeRangePayload( int range ) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "change_range"); - - public ChangeRangePayload(final FriendlyByteBuf buffer) { - this(buffer.readInt()); - } + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "change_range")); @Override - public void write(FriendlyByteBuf buffer) { - buffer.writeInt(range()); + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.INT, ChangeRangePayload::range, + ChangeRangePayload::new + ); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeVolumePayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeVolumePayload.java index 56eb8b6e..91c89749 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeVolumePayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ChangeVolumePayload.java @@ -2,26 +2,24 @@ import com.direwolf20.mininggadgets.common.MiningGadgets; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; public record ChangeVolumePayload( float volume ) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "change_volume"); - - public ChangeVolumePayload(final FriendlyByteBuf buffer) { - this(buffer.readFloat()); - } + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "change_volume")); @Override - public void write(FriendlyByteBuf buffer) { - buffer.writeFloat(volume()); + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.FLOAT, ChangeVolumePayload::volume, + ChangeVolumePayload::new + ); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/DurabilitySyncPayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/DurabilitySyncPayload.java index 09edd2f2..572f6543 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/DurabilitySyncPayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/DurabilitySyncPayload.java @@ -1,57 +1,28 @@ package com.direwolf20.mininggadgets.common.network.data; import com.direwolf20.mininggadgets.common.MiningGadgets; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.NbtUtils; -import net.minecraft.nbt.Tag; -import net.minecraft.network.FriendlyByteBuf; +import com.direwolf20.mininggadgets.common.util.CodecHelpers; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Tuple; -import java.util.ArrayList; import java.util.List; public record DurabilitySyncPayload( - List> updateList + List updateList ) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "durability_sync"); - - public DurabilitySyncPayload(final FriendlyByteBuf buffer) { - this(decodeList(buffer)); - } - - public static List> decodeList(final FriendlyByteBuf buffer) { - CompoundTag tag = buffer.readNbt(); - ListTag nbtList = tag.getList("list", Tag.TAG_COMPOUND); - List> thisList = new ArrayList<>(); - for (int i = 0; i < nbtList.size(); i++) { - CompoundTag nbt = nbtList.getCompound(i); - thisList.add(new Tuple<>(NbtUtils.readBlockPos(nbt.getCompound("pos")), nbt.getInt("dur"))); - } - return thisList; - } + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "durability_sync")); @Override - public void write(FriendlyByteBuf buffer) { - List> thisList = List.copyOf(updateList()); - CompoundTag tag = new CompoundTag(); - ListTag nbtList = new ListTag(); - for (int i = 0; i < thisList.size(); i++) { - CompoundTag nbt = new CompoundTag(); - nbt.put("pos", NbtUtils.writeBlockPos(thisList.get(i).getA())); - nbt.putInt("dur", thisList.get(i).getB()); - nbtList.add(i, nbt); - } - tag.put("list", nbtList); - buffer.writeNbt(tag); + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + CodecHelpers.DurabilitySyncData.STREAM_CODEC.apply(ByteBufCodecs.list()), DurabilitySyncPayload::updateList, + DurabilitySyncPayload::new + ); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ExtractUpgradePayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ExtractUpgradePayload.java index 318ef740..1a2809ed 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ExtractUpgradePayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ExtractUpgradePayload.java @@ -2,7 +2,9 @@ import com.direwolf20.mininggadgets.common.MiningGadgets; import net.minecraft.core.BlockPos; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; @@ -11,22 +13,18 @@ public record ExtractUpgradePayload( String upgrade, int nameLength ) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "extract_upgrade"); - - public ExtractUpgradePayload(final FriendlyByteBuf buffer) { - this(buffer.readBlockPos(), buffer.readUtf(), buffer.readInt()); - } + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "extract_upgrade")); @Override - public void write(FriendlyByteBuf buffer) { - buffer.writeBlockPos(pos()); - buffer.writeUtf(upgrade()); - buffer.writeInt(nameLength()); + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + BlockPos.STREAM_CODEC, ExtractUpgradePayload::pos, + ByteBufCodecs.STRING_UTF8, ExtractUpgradePayload::upgrade, + ByteBufCodecs.VAR_INT, ExtractUpgradePayload::nameLength, + ExtractUpgradePayload::new + ); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/GhostSlotPayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/GhostSlotPayload.java index 6dd648b5..9482bf56 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/GhostSlotPayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/GhostSlotPayload.java @@ -1,7 +1,9 @@ package com.direwolf20.mininggadgets.common.network.data; import com.direwolf20.mininggadgets.common.MiningGadgets; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -10,21 +12,17 @@ public record GhostSlotPayload( int slotNumber, ItemStack stack ) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "ghost_slot"); - - public GhostSlotPayload(final FriendlyByteBuf buffer) { - this(buffer.readInt(), buffer.readItem()); - } + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "ghost_slot")); @Override - public void write(FriendlyByteBuf buffer) { - buffer.writeInt(slotNumber()); - buffer.writeItem(stack()); + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.INT, GhostSlotPayload::slotNumber, + ItemStack.STREAM_CODEC, GhostSlotPayload::stack, + GhostSlotPayload::new + ); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/InsertUpgradePayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/InsertUpgradePayload.java index f3d51876..f2501c0e 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/InsertUpgradePayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/InsertUpgradePayload.java @@ -2,7 +2,8 @@ import com.direwolf20.mininggadgets.common.MiningGadgets; import net.minecraft.core.BlockPos; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -11,21 +12,17 @@ public record InsertUpgradePayload( BlockPos pos, ItemStack upgrade ) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "insert_upgrade"); - - public InsertUpgradePayload(final FriendlyByteBuf buffer) { - this(buffer.readBlockPos(), buffer.readItem()); - } + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "insert_upgrade")); @Override - public void write(FriendlyByteBuf buffer) { - buffer.writeBlockPos(pos()); - buffer.writeItem(upgrade()); + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + BlockPos.STREAM_CODEC, InsertUpgradePayload::pos, + ItemStack.STREAM_CODEC, InsertUpgradePayload::upgrade, + InsertUpgradePayload::new + ); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/OpenFilterContainerPayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/OpenFilterContainerPayload.java index 919416b2..1c593f13 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/OpenFilterContainerPayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/OpenFilterContainerPayload.java @@ -1,25 +1,20 @@ package com.direwolf20.mininggadgets.common.network.data; import com.direwolf20.mininggadgets.common.MiningGadgets; -import net.minecraft.network.FriendlyByteBuf; +import io.netty.buffer.ByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; public record OpenFilterContainerPayload() implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "open_filter_container"); - - public OpenFilterContainerPayload(final FriendlyByteBuf buffer) { - this(); - } + public static final OpenFilterContainerPayload INSTANCE = new OpenFilterContainerPayload(); + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "open_filter_container")); @Override - public void write(FriendlyByteBuf buffer) { - + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.unit(INSTANCE); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ToggleFiltersPayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ToggleFiltersPayload.java index 2abf1018..6cb8cfd6 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/ToggleFiltersPayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/ToggleFiltersPayload.java @@ -1,25 +1,20 @@ package com.direwolf20.mininggadgets.common.network.data; import com.direwolf20.mininggadgets.common.MiningGadgets; -import net.minecraft.network.FriendlyByteBuf; +import io.netty.buffer.ByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; public record ToggleFiltersPayload() implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "toggle_filters"); - - public ToggleFiltersPayload(final FriendlyByteBuf buffer) { - this(); - } + public static final ToggleFiltersPayload INSTANCE = new ToggleFiltersPayload(); + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "toggle_filters")); @Override - public void write(FriendlyByteBuf buffer) { - + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.unit(INSTANCE); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/TogglePrecisionPayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/TogglePrecisionPayload.java index 2d0ef7a5..a630f741 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/TogglePrecisionPayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/TogglePrecisionPayload.java @@ -1,25 +1,20 @@ package com.direwolf20.mininggadgets.common.network.data; import com.direwolf20.mininggadgets.common.MiningGadgets; -import net.minecraft.network.FriendlyByteBuf; +import io.netty.buffer.ByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; public record TogglePrecisionPayload() implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "toggle_precision"); - - public TogglePrecisionPayload(final FriendlyByteBuf buffer) { - this(); - } + public static final TogglePrecisionPayload INSTANCE = new TogglePrecisionPayload(); + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "toggle_precision")); @Override - public void write(FriendlyByteBuf buffer) { - + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.unit(INSTANCE); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/data/UpdateUpgradePayload.java b/src/main/java/com/direwolf20/mininggadgets/common/network/data/UpdateUpgradePayload.java index 6f5f9f68..a1c7af82 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/data/UpdateUpgradePayload.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/data/UpdateUpgradePayload.java @@ -2,26 +2,24 @@ import com.direwolf20.mininggadgets.common.MiningGadgets; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; public record UpdateUpgradePayload( String upgrade ) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(MiningGadgets.MOD_ID, "update_upgrade"); - - public UpdateUpgradePayload(final FriendlyByteBuf buffer) { - this(buffer.readUtf()); - } + public static final Type TYPE = new Type<>(new ResourceLocation(MiningGadgets.MOD_ID, "update_upgrade")); @Override - public void write(FriendlyByteBuf buffer) { - buffer.writeUtf(upgrade()); + public Type type() { + return TYPE; } - @Override - public ResourceLocation id() { - return ID; - } + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.STRING_UTF8, UpdateUpgradePayload::upgrade, + UpdateUpgradePayload::new + ); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeBreakType.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeBreakType.java index 136dd447..8a80cb5b 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeBreakType.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeBreakType.java @@ -5,9 +5,7 @@ import com.direwolf20.mininggadgets.common.network.data.ChangeBreakTypePayload; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketChangeBreakType { public static final PacketChangeBreakType INSTANCE = new PacketChangeBreakType(); @@ -16,12 +14,9 @@ public static PacketChangeBreakType get() { return INSTANCE; } - public void handle(final ChangeBreakTypePayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - Player player = senderOptional.get(); + public void handle(final ChangeBreakTypePayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); ItemStack stack = MiningGadget.getGadget(player); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeColor.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeColor.java index d6831d1c..467e275a 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeColor.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeColor.java @@ -5,9 +5,7 @@ import com.direwolf20.mininggadgets.common.network.data.ChangeColorPayload; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketChangeColor { public static final PacketChangeColor INSTANCE = new PacketChangeColor(); @@ -16,21 +14,13 @@ public static PacketChangeColor get() { return INSTANCE; } - public void handle(final ChangeColorPayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - Player player = senderOptional.get(); + public void handle(final ChangeColorPayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); ItemStack stack = MiningGadget.getGadget(player); - MiningProperties.setColor(stack, payload.red(), MiningProperties.COLOR_RED); - MiningProperties.setColor(stack, payload.green(), MiningProperties.COLOR_GREEN); - MiningProperties.setColor(stack, payload.blue(), MiningProperties.COLOR_BLUE); - MiningProperties.setColor(stack, payload.red_inner(), MiningProperties.COLOR_RED_INNER); - MiningProperties.setColor(stack, payload.green_inner(), MiningProperties.COLOR_GREEN_INNER); - MiningProperties.setColor(stack, payload.blue_inner(), MiningProperties.COLOR_BLUE_INNER); + MiningProperties.setColor(stack, payload.laserColor()); }); } } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeFreezeDelay.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeFreezeDelay.java index 1ed1f64b..804a3c4b 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeFreezeDelay.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeFreezeDelay.java @@ -5,9 +5,7 @@ import com.direwolf20.mininggadgets.common.network.data.ChangeFreezeDelayPayload; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketChangeFreezeDelay { public static final PacketChangeFreezeDelay INSTANCE = new PacketChangeFreezeDelay(); @@ -16,12 +14,9 @@ public static PacketChangeFreezeDelay get() { return INSTANCE; } - public void handle(final ChangeFreezeDelayPayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - Player player = senderOptional.get(); + public void handle(final ChangeFreezeDelayPayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); ItemStack stack = MiningGadget.getGadget(player); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeMiningSize.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeMiningSize.java index ecb15062..574fa351 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeMiningSize.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeMiningSize.java @@ -4,9 +4,7 @@ import com.direwolf20.mininggadgets.common.network.data.ChangeMiningSizePayload; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketChangeMiningSize { public static final PacketChangeMiningSize INSTANCE = new PacketChangeMiningSize(); @@ -15,12 +13,9 @@ public static PacketChangeMiningSize get() { return INSTANCE; } - public void handle(final ChangeMiningSizePayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - Player player = senderOptional.get(); + public void handle(final ChangeMiningSizePayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); ItemStack stack = MiningGadget.getGadget(player); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeMiningSizeMode.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeMiningSizeMode.java index 0d6224b0..c38404ac 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeMiningSizeMode.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeMiningSizeMode.java @@ -5,9 +5,7 @@ import com.direwolf20.mininggadgets.common.network.data.ChangeMiningSizeModePayload; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketChangeMiningSizeMode { public static final PacketChangeMiningSizeMode INSTANCE = new PacketChangeMiningSizeMode(); @@ -16,12 +14,9 @@ public static PacketChangeMiningSizeMode get() { return INSTANCE; } - public void handle(final ChangeMiningSizeModePayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - Player player = senderOptional.get(); + public void handle(final ChangeMiningSizeModePayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); ItemStack stack = MiningGadget.getGadget(player); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeRange.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeRange.java index 343f5b46..32644bb2 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeRange.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeRange.java @@ -5,9 +5,7 @@ import com.direwolf20.mininggadgets.common.network.data.ChangeRangePayload; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketChangeRange { public static final PacketChangeRange INSTANCE = new PacketChangeRange(); @@ -16,12 +14,9 @@ public static PacketChangeRange get() { return INSTANCE; } - public void handle(final ChangeRangePayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - Player player = senderOptional.get(); + public void handle(final ChangeRangePayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); ItemStack stack = MiningGadget.getGadget(player); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeVolume.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeVolume.java index c0fbd4bc..2b001b51 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeVolume.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketChangeVolume.java @@ -5,9 +5,7 @@ import com.direwolf20.mininggadgets.common.network.data.ChangeVolumePayload; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketChangeVolume { public static final PacketChangeVolume INSTANCE = new PacketChangeVolume(); @@ -16,12 +14,9 @@ public static PacketChangeVolume get() { return INSTANCE; } - public void handle(final ChangeVolumePayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - Player player = senderOptional.get(); + public void handle(final ChangeVolumePayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); ItemStack stack = MiningGadget.getGadget(player); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketDurabilitySync.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketDurabilitySync.java index c73a9a6e..cea65679 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketDurabilitySync.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketDurabilitySync.java @@ -2,11 +2,11 @@ import com.direwolf20.mininggadgets.common.network.data.DurabilitySyncPayload; import com.direwolf20.mininggadgets.common.tiles.RenderBlockTileEntity; +import com.direwolf20.mininggadgets.common.util.CodecHelpers; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; -import net.minecraft.util.Tuple; import net.minecraft.world.level.block.entity.BlockEntity; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; +import net.neoforged.neoforge.network.handling.IPayloadContext; import java.util.List; @@ -17,13 +17,13 @@ public static PacketDurabilitySync get() { return INSTANCE; } - public void handle(final DurabilitySyncPayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - List> thisList = payload.updateList(); + public void handle(final DurabilitySyncPayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + List thisList = payload.updateList(); for (int i = 0; i < thisList.size(); i++) { - BlockPos pos = thisList.get(i).getA(); - int durability = thisList.get(i).getB(); + BlockPos pos = thisList.get(i).blockPos(); + int durability = thisList.get(i).durability(); BlockEntity clientTE = Minecraft.getInstance().level.getBlockEntity(pos); if (!(clientTE instanceof RenderBlockTileEntity)) return; ((RenderBlockTileEntity) clientTE).setClientDurability(durability); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketExtractUpgrade.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketExtractUpgrade.java index 0813d24d..bb25d647 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketExtractUpgrade.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketExtractUpgrade.java @@ -9,9 +9,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketExtractUpgrade { public static final PacketExtractUpgrade INSTANCE = new PacketExtractUpgrade(); @@ -20,12 +18,9 @@ public static PacketExtractUpgrade get() { return INSTANCE; } - public void handle(final ExtractUpgradePayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - ServerPlayer player = (ServerPlayer) senderOptional.get(); + public void handle(final ExtractUpgradePayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); Level world = player.level(); BlockPos pos = payload.pos(); @@ -34,7 +29,7 @@ public void handle(final ExtractUpgradePayload payload, final PlayPayloadContext if (!(te instanceof ModificationTableTileEntity)) return; ModificationTableContainer container = ((ModificationTableTileEntity) te).getContainer(player); - ModificationTableCommands.extractButton(container, player, payload.upgrade()); + ModificationTableCommands.extractButton(container, (ServerPlayer) player, payload.upgrade()); }); } } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketGhostSlot.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketGhostSlot.java index f7304dc5..67468f4e 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketGhostSlot.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketGhostSlot.java @@ -5,9 +5,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.Slot; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketGhostSlot { public static final PacketGhostSlot INSTANCE = new PacketGhostSlot(); @@ -16,12 +14,9 @@ public static PacketGhostSlot get() { return INSTANCE; } - public void handle(final GhostSlotPayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - Player player = senderOptional.get(); + public void handle(final GhostSlotPayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); AbstractContainerMenu container = player.containerMenu; if (container == null) diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketInsertUpgrade.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketInsertUpgrade.java index 0bc39d41..f722e1ba 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketInsertUpgrade.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketInsertUpgrade.java @@ -5,14 +5,11 @@ import com.direwolf20.mininggadgets.common.network.data.InsertUpgradePayload; import com.direwolf20.mininggadgets.common.tiles.ModificationTableTileEntity; import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerPlayer; 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.entity.BlockEntity; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketInsertUpgrade { public static final PacketInsertUpgrade INSTANCE = new PacketInsertUpgrade(); @@ -21,12 +18,9 @@ public static PacketInsertUpgrade get() { return INSTANCE; } - public void handle(final InsertUpgradePayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - ServerPlayer player = (ServerPlayer) senderOptional.get(); + public void handle(final InsertUpgradePayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); Level world = player.level(); BlockPos pos = payload.pos(); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketOpenFilterContainer.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketOpenFilterContainer.java index fe4dbb6e..beda8529 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketOpenFilterContainer.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketOpenFilterContainer.java @@ -4,15 +4,15 @@ import com.direwolf20.mininggadgets.common.items.MiningGadget; import com.direwolf20.mininggadgets.common.items.gadget.MiningProperties; import com.direwolf20.mininggadgets.common.network.data.OpenFilterContainerPayload; +import com.direwolf20.mininggadgets.common.util.MGDataComponents; +import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; import net.minecraft.world.SimpleMenuProvider; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.neoforged.neoforge.items.ItemStackHandler; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketOpenFilterContainer { public static final PacketOpenFilterContainer INSTANCE = new PacketOpenFilterContainer(); @@ -21,13 +21,9 @@ public static PacketOpenFilterContainer get() { return INSTANCE; } - public void handle(final OpenFilterContainerPayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - - Player player = senderOptional.get(); + public void handle(final OpenFilterContainerPayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); AbstractContainerMenu container = player.containerMenu; if (container == null) return; @@ -36,14 +32,13 @@ public void handle(final OpenFilterContainerPayload payload, final PlayPayloadCo if (stack.isEmpty()) return; - ItemStackHandler ghostInventory = new ItemStackHandler(30) { + ItemStackHandler ghostInventory = new ItemStackHandler((NonNullList) MiningProperties.getFiltersAsList(stack)) { @Override protected void onContentsChanged(int slot) { - stack.getOrCreateTag().put(MiningProperties.KEY_FILTERS, serializeNBT()); + stack.set(MGDataComponents.FILTER_LIST, stacks); } }; - ghostInventory.deserializeNBT(stack.getOrCreateTagElement(MiningProperties.KEY_FILTERS)); player.openMenu(new SimpleMenuProvider( (windowId, playerInventory, playerEntity) -> new FilterContainer(windowId, playerInventory, ghostInventory), Component.literal("") )); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketToggleFilters.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketToggleFilters.java index a819abc7..44c5bb0c 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketToggleFilters.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketToggleFilters.java @@ -5,9 +5,7 @@ import com.direwolf20.mininggadgets.common.network.data.ToggleFiltersPayload; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketToggleFilters { public static final PacketToggleFilters INSTANCE = new PacketToggleFilters(); @@ -16,12 +14,9 @@ public static PacketToggleFilters get() { return INSTANCE; } - public void handle(final ToggleFiltersPayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - Player player = senderOptional.get(); + public void handle(final ToggleFiltersPayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); ItemStack stack = MiningGadget.getGadget(player); MiningProperties.setWhitelist(stack, !MiningProperties.getWhiteList(stack)); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketTogglePrecision.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketTogglePrecision.java index d3c33a1b..6a9615ad 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketTogglePrecision.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketTogglePrecision.java @@ -5,9 +5,7 @@ import com.direwolf20.mininggadgets.common.network.data.TogglePrecisionPayload; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketTogglePrecision { public static final PacketTogglePrecision INSTANCE = new PacketTogglePrecision(); @@ -16,12 +14,9 @@ public static PacketTogglePrecision get() { return INSTANCE; } - public void handle(final TogglePrecisionPayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - Player player = senderOptional.get(); + public void handle(final TogglePrecisionPayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); ItemStack stack = MiningGadget.getGadget(player); MiningProperties.setPrecisionMode(stack, !MiningProperties.getPrecisionMode(stack)); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketUpdateUpgrade.java b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketUpdateUpgrade.java index 9d530b07..af7c08ea 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketUpdateUpgrade.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/handler/PacketUpdateUpgrade.java @@ -4,12 +4,9 @@ import com.direwolf20.mininggadgets.common.items.upgrade.Upgrade; import com.direwolf20.mininggadgets.common.items.upgrade.UpgradeTools; import com.direwolf20.mininggadgets.common.network.data.UpdateUpgradePayload; -import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; - -import java.util.Optional; +import net.neoforged.neoforge.network.handling.IPayloadContext; public class PacketUpdateUpgrade { public static final PacketUpdateUpgrade INSTANCE = new PacketUpdateUpgrade(); @@ -18,12 +15,9 @@ public static PacketUpdateUpgrade get() { return INSTANCE; } - public void handle(final UpdateUpgradePayload payload, final PlayPayloadContext context) { - context.workHandler().submitAsync(() -> { - Optional senderOptional = context.player(); - if (senderOptional.isEmpty()) - return; - ServerPlayer player = (ServerPlayer) senderOptional.get(); + public void handle(final UpdateUpgradePayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player player = context.player(); Upgrade upgrade = UpgradeTools.getUpgradeByName(payload.upgrade()); if (upgrade == null) diff --git a/src/main/java/com/direwolf20/mininggadgets/common/tiles/ModificationTableTileEntity.java b/src/main/java/com/direwolf20/mininggadgets/common/tiles/ModificationTableTileEntity.java index 2486df91..6af510f7 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/tiles/ModificationTableTileEntity.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/tiles/ModificationTableTileEntity.java @@ -3,6 +3,7 @@ import com.direwolf20.mininggadgets.common.containers.ModificationTableContainer; import com.direwolf20.mininggadgets.common.containers.ModificationTableHandler; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Connection; import net.minecraft.network.chat.Component; @@ -15,7 +16,6 @@ import net.minecraft.world.level.block.state.BlockState; import javax.annotation.Nullable; -import java.util.Objects; import static com.direwolf20.mininggadgets.setup.Registration.MODIFICATIONTABLE_TILE; @@ -32,33 +32,33 @@ public ClientboundBlockEntityDataPacket getUpdatePacket() { } @Override - public CompoundTag getUpdateTag() { + public CompoundTag getUpdateTag(HolderLookup.Provider provider) { CompoundTag tag = new CompoundTag(); - saveAdditional(tag); + saveAdditional(tag, provider); return tag; } @Override - public void handleUpdateTag(CompoundTag tag) { - this.load(tag); + public void handleUpdateTag(CompoundTag tag, HolderLookup.Provider lookupProvider) { + this.loadAdditional(tag, lookupProvider); } @Override - public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { - this.load(Objects.requireNonNull(pkt.getTag())); + public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt, HolderLookup.Provider lookupProvider) { + super.onDataPacket(net, pkt, lookupProvider); } @Override - public void load(CompoundTag tag) { + public void loadAdditional(CompoundTag tag, HolderLookup.Provider provider) { if (tag.contains("Inventory")) - handler.deserializeNBT(tag.getCompound("Inventory")); - super.load(tag); + handler.deserializeNBT(provider, tag.getCompound("Inventory")); + super.loadAdditional(tag, provider); } @Override - public void saveAdditional(CompoundTag tag) { - super.saveAdditional(tag); - tag.put("Inventory", handler.serializeNBT()); + public void saveAdditional(CompoundTag tag, HolderLookup.Provider provider) { + super.saveAdditional(tag, provider); + tag.put("Inventory", handler.serializeNBT(provider)); } @Override diff --git a/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java b/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java index 6915c839..5fb04c96 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java @@ -10,6 +10,7 @@ import com.direwolf20.mininggadgets.setup.Registration; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; @@ -32,7 +33,6 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; import net.neoforged.neoforge.capabilities.Capabilities; -import net.neoforged.neoforge.common.CommonHooks; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.event.EventHooks; import net.neoforged.neoforge.event.level.BlockEvent; @@ -345,20 +345,20 @@ public ClientboundBlockEntityDataPacket getUpdatePacket() { } @Override - public void handleUpdateTag(CompoundTag tag) { - this.load(tag); + public void handleUpdateTag(CompoundTag tag, HolderLookup.Provider lookupProvider) { + this.loadAdditional(tag, lookupProvider); } @Override - public CompoundTag getUpdateTag() { + public CompoundTag getUpdateTag(HolderLookup.Provider provider) { CompoundTag tag = new CompoundTag(); - saveAdditional(tag); + saveAdditional(tag, provider); return tag; } @Override - public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { - this.load(pkt.getTag()); + public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt, HolderLookup.Provider lookupProvider) { + super.onDataPacket(net, pkt, lookupProvider); } public void markDirtyClient() { @@ -370,8 +370,8 @@ public void markDirtyClient() { } @Override - public void load(CompoundTag tag) { - super.load(tag); + public void loadAdditional(CompoundTag tag, HolderLookup.Provider provider) { + super.loadAdditional(tag, provider); this.renderBlock = NbtUtils.readBlockState(this.level.holderLookup(Registries.BLOCK), tag.getCompound("renderBlock")); this.originalDurability = tag.getInt("originalDurability"); this.priorDurability = tag.getInt("priorDurability"); @@ -382,14 +382,14 @@ public void load(CompoundTag tag) { } this.gadgetUpgrades = UpgradeTools.getUpgradesFromTag(tag); this.breakType = MiningProperties.BreakTypes.values()[tag.getByte("breakType")]; - this.gadgetFilters = MiningProperties.deserializeItemStackList(tag.getCompound("gadgetFilters")); + this.gadgetFilters = MiningProperties.deserializeItemStackList(tag.getCompound("gadgetFilters"), provider); this.gadgetIsWhitelist = tag.getBoolean("gadgetIsWhitelist"); this.blockAllowed = tag.getBoolean("blockAllowed"); } @Override - public void saveAdditional(CompoundTag tag) { - super.saveAdditional(tag); + public void saveAdditional(CompoundTag tag, HolderLookup.Provider provider) { + super.saveAdditional(tag, provider); if (this.renderBlock != null) { tag.put("renderBlock", NbtUtils.writeBlockState(this.renderBlock)); } @@ -402,7 +402,7 @@ public void saveAdditional(CompoundTag tag) { } tag.put("upgrades", UpgradeTools.setUpgradesNBT(this.gadgetUpgrades).getList("upgrades", Tag.TAG_COMPOUND)); tag.putByte("breakType", (byte) this.breakType.ordinal()); - tag.put("gadgetFilters", MiningProperties.serializeItemStackList(this.getGadgetFilters())); + tag.put("gadgetFilters", MiningProperties.serializeItemStackList(this.getGadgetFilters(), provider)); tag.putBoolean("gadgetIsWhitelist", this.isGadgetIsWhitelist()); tag.putBoolean("blockAllowed", this.blockAllowed); } @@ -433,7 +433,7 @@ private void removeBlock() { Optional upgrade = UpgradeTools.getUpgradeFromList(this.gadgetUpgrades, Upgrade.FORTUNE_1); if (upgrade.isPresent()) { fortune = upgrade.get().getTier(); - tempTool.enchant(Enchantments.BLOCK_FORTUNE, fortune); + tempTool.enchant(Enchantments.FORTUNE, fortune); } } @@ -503,8 +503,8 @@ private void removeBlock() { private static BlockEvent.BreakEvent fixForgeEventBreakBlock(BlockState state, Player player, Level world, BlockPos pos, ItemStack tool) { BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, player); // Handle empty block or player unable to break block scenario - if (state != null && CommonHooks.isCorrectToolForDrops(state, player)) { - int bonusLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool); + if (state != null && tool.isCorrectToolForDrops(state)) { + int bonusLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.FORTUNE, tool); int silklevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool); event.setExpToDrop(state.getExpDrop(world, world.random, pos, bonusLevel, silklevel)); } @@ -547,7 +547,7 @@ public void setBlockAllowed() { Optional upgrade = UpgradeTools.getUpgradeFromList(this.gadgetUpgrades, Upgrade.FORTUNE_1); if (upgrade.isPresent()) { fortune = upgrade.get().getTier(); - tempTool.enchant(Enchantments.BLOCK_FORTUNE, fortune); + tempTool.enchant(Enchantments.FORTUNE, fortune); } } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/util/CodecHelpers.java b/src/main/java/com/direwolf20/mininggadgets/common/util/CodecHelpers.java new file mode 100644 index 00000000..c5989a1b --- /dev/null +++ b/src/main/java/com/direwolf20/mininggadgets/common/util/CodecHelpers.java @@ -0,0 +1,78 @@ +package com.direwolf20.mininggadgets.common.util; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.core.BlockPos; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; + +import java.util.List; + +public class CodecHelpers { + public record DurabilitySyncData(BlockPos blockPos, int durability) { + public static final Codec CODEC = RecordCodecBuilder.create( + cooldownInstance -> cooldownInstance.group( + BlockPos.CODEC.fieldOf("blockPos").forGetter(DurabilitySyncData::blockPos), + Codec.INT.fieldOf("durability").forGetter(DurabilitySyncData::durability) + ) + .apply(cooldownInstance, DurabilitySyncData::new) + ); + public static final Codec> LIST_CODEC = CODEC.listOf(); + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + BlockPos.STREAM_CODEC, + DurabilitySyncData::blockPos, + ByteBufCodecs.VAR_INT, + DurabilitySyncData::durability, + DurabilitySyncData::new + ); + } + + public record UpgradeData(String upgradeName, boolean isActive) { + public static final Codec CODEC = RecordCodecBuilder.create( + cooldownInstance -> cooldownInstance.group( + Codec.STRING.fieldOf("upgradeName").forGetter(UpgradeData::upgradeName), + Codec.BOOL.fieldOf("isActive").forGetter(UpgradeData::isActive) + ) + .apply(cooldownInstance, UpgradeData::new) + ); + public static final Codec> LIST_CODEC = CODEC.listOf(); + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.STRING_UTF8, + UpgradeData::upgradeName, + ByteBufCodecs.BOOL, + UpgradeData::isActive, + UpgradeData::new + ); + } + + public record LaserColor(short red, short green, short blue, short innerRed, short innerGreen, short innerBlue) { + public static final Codec CODEC = RecordCodecBuilder.create( + cooldownInstance -> cooldownInstance.group( + Codec.SHORT.fieldOf("red").forGetter(LaserColor::red), + Codec.SHORT.fieldOf("green").forGetter(LaserColor::green), + Codec.SHORT.fieldOf("blue").forGetter(LaserColor::blue), + Codec.SHORT.fieldOf("innerRed").forGetter(LaserColor::innerRed), + Codec.SHORT.fieldOf("innerGreen").forGetter(LaserColor::innerGreen), + Codec.SHORT.fieldOf("innerBlue").forGetter(LaserColor::innerBlue) + ) + .apply(cooldownInstance, LaserColor::new) + ); + public static final Codec> LIST_CODEC = CODEC.listOf(); + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.SHORT, + LaserColor::red, + ByteBufCodecs.SHORT, + LaserColor::green, + ByteBufCodecs.SHORT, + LaserColor::blue, + ByteBufCodecs.SHORT, + LaserColor::innerRed, + ByteBufCodecs.SHORT, + LaserColor::innerGreen, + ByteBufCodecs.SHORT, + LaserColor::innerBlue, + LaserColor::new + ); + } +} diff --git a/src/main/java/com/direwolf20/mininggadgets/common/util/MGDataComponents.java b/src/main/java/com/direwolf20/mininggadgets/common/util/MGDataComponents.java new file mode 100644 index 00000000..f3a1f0e9 --- /dev/null +++ b/src/main/java/com/direwolf20/mininggadgets/common/util/MGDataComponents.java @@ -0,0 +1,55 @@ +package com.direwolf20.mininggadgets.common.util; + +import com.direwolf20.mininggadgets.common.MiningGadgets; +import com.mojang.serialization.Codec; +import net.minecraft.core.component.DataComponentType; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.world.item.ItemStack; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredRegister; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class MGDataComponents { + public static final DeferredRegister> COMPONENTS = DeferredRegister.createDataComponents(MiningGadgets.MOD_ID); + + + public static final DeferredHolder, DataComponentType> FORGE_ENERGY = COMPONENTS.register("forge_energy", () -> DataComponentType.builder().persistent(Codec.INT).networkSynchronized(ByteBufCodecs.VAR_INT).build()); + public static final DeferredHolder, DataComponentType> FORGE_ENERGY_MAX_ENERGY = COMPONENTS.register("forge_energy_max_energy", () -> DataComponentType.builder().persistent(Codec.INT).networkSynchronized(ByteBufCodecs.VAR_INT).build()); + + public static final DeferredHolder, DataComponentType>> UPGRADE_DATA = COMPONENTS.register("upgrade_data", () -> DataComponentType.>builder().persistent(CodecHelpers.UpgradeData.LIST_CODEC).networkSynchronized(CodecHelpers.UpgradeData.STREAM_CODEC.apply(ByteBufCodecs.list())).build()); + + public static final DeferredHolder, DataComponentType> LASER_COLOR = COMPONENTS.register("laser_color", () -> DataComponentType.builder().persistent(CodecHelpers.LaserColor.CODEC).networkSynchronized(CodecHelpers.LaserColor.STREAM_CODEC).build()); + public static final DeferredHolder, DataComponentType> BREAK_TYPE = COMPONENTS.register("break_type", () -> DataComponentType.builder().persistent(Codec.BYTE).networkSynchronized(ByteBufCodecs.BYTE).build()); + public static final DeferredHolder, DataComponentType> SPEED = COMPONENTS.register("speed", () -> DataComponentType.builder().persistent(Codec.INT).networkSynchronized(ByteBufCodecs.VAR_INT).build()); + public static final DeferredHolder, DataComponentType> RANGE = COMPONENTS.register("range", () -> DataComponentType.builder().persistent(Codec.INT).networkSynchronized(ByteBufCodecs.VAR_INT).build()); + public static final DeferredHolder, DataComponentType> BEAM_RANGE = COMPONENTS.register("beam_range", () -> DataComponentType.builder().persistent(Codec.INT).networkSynchronized(ByteBufCodecs.VAR_INT).build()); + public static final DeferredHolder, DataComponentType> MAX_BEAM_RANGE = COMPONENTS.register("max_beam_range", () -> DataComponentType.builder().persistent(Codec.INT).networkSynchronized(ByteBufCodecs.VAR_INT).build()); + public static final DeferredHolder, DataComponentType> MAX_MINING_RANGE = COMPONENTS.register("max_mining_range", () -> DataComponentType.builder().persistent(Codec.INT).networkSynchronized(ByteBufCodecs.VAR_INT).build()); + public static final DeferredHolder, DataComponentType> WHITELIST = COMPONENTS.register("whitelist", () -> DataComponentType.builder().persistent(Codec.BOOL).networkSynchronized(ByteBufCodecs.BOOL).build()); + public static final DeferredHolder, DataComponentType> CAN_MINE = COMPONENTS.register("can_mine", () -> DataComponentType.builder().persistent(Codec.BOOL).networkSynchronized(ByteBufCodecs.BOOL).build()); + public static final DeferredHolder, DataComponentType> PRECISION_MODE = COMPONENTS.register("precision_mode", () -> DataComponentType.builder().persistent(Codec.BOOL).networkSynchronized(ByteBufCodecs.BOOL).build()); + public static final DeferredHolder, DataComponentType> SIZE_MODE = COMPONENTS.register("size_mode", () -> DataComponentType.builder().persistent(Codec.BYTE).networkSynchronized(ByteBufCodecs.BYTE).build()); + public static final DeferredHolder, DataComponentType> VOLUME = COMPONENTS.register("volume", () -> DataComponentType.builder().persistent(Codec.FLOAT).networkSynchronized(ByteBufCodecs.FLOAT).build()); + public static final DeferredHolder, DataComponentType> FREEZE_DELAY = COMPONENTS.register("freeze_delay", () -> DataComponentType.builder().persistent(Codec.INT).networkSynchronized(ByteBufCodecs.VAR_INT).build()); + public static final DeferredHolder, DataComponentType> BATTERY_TIER = COMPONENTS.register("battery_tier", () -> DataComponentType.builder().persistent(Codec.INT).networkSynchronized(ByteBufCodecs.VAR_INT).build()); + + public static final DeferredHolder, DataComponentType>> FILTER_LIST = COMPONENTS.register("filter_list", () -> DataComponentType.>builder().persistent(ItemStack.CODEC.listOf()).networkSynchronized(ItemStack.LIST_STREAM_CODEC).build()); + + private static @NotNull DeferredHolder, DataComponentType> register(String name, final Codec codec) { + return register(name, codec, null); + } + + private static @NotNull DeferredHolder, DataComponentType> register(String name, final Codec codec, @Nullable final StreamCodec streamCodec) { + if (streamCodec == null) { + return COMPONENTS.register(name, () -> DataComponentType.builder().persistent(codec).build()); + } else { + return COMPONENTS.register(name, () -> DataComponentType.builder().persistent(codec).networkSynchronized(streamCodec).build()); + } + } + +} diff --git a/src/main/java/com/direwolf20/mininggadgets/setup/ClientSetup.java b/src/main/java/com/direwolf20/mininggadgets/setup/ClientSetup.java index 521ba1b1..5628cd62 100644 --- a/src/main/java/com/direwolf20/mininggadgets/setup/ClientSetup.java +++ b/src/main/java/com/direwolf20/mininggadgets/setup/ClientSetup.java @@ -6,19 +6,18 @@ import com.direwolf20.mininggadgets.client.screens.FilterScreen; import com.direwolf20.mininggadgets.client.screens.ModificationTableScreen; import com.direwolf20.mininggadgets.common.MiningGadgets; -import net.minecraft.client.gui.screens.MenuScreens; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; import net.neoforged.neoforge.client.event.EntityRenderersEvent; +import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; import net.neoforged.neoforge.common.NeoForge; -@Mod.EventBusSubscriber(modid = MiningGadgets.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(modid = MiningGadgets.MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD) public class ClientSetup { public static void init(final FMLClientSetupEvent event) { //registerRenderers(event); - registerContainerScreens(event); //Register our Render Events Class NeoForge.EVENT_BUS.register(ClientEvents.class); @@ -27,12 +26,10 @@ public static void init(final FMLClientSetupEvent event) { /** * Called from some Client Dist runner in the main class */ - private static void registerContainerScreens(final FMLClientSetupEvent event) { - //Screens - event.enqueueWork(() -> { - MenuScreens.register(Registration.MODIFICATIONTABLE_CONTAINER.get(), ModificationTableScreen::new); - MenuScreens.register(Registration.FILTER_CONTAINER.get(), FilterScreen::new); - }); + @SubscribeEvent + public static void registerScreens(RegisterMenuScreensEvent event) { + event.register(Registration.MODIFICATIONTABLE_CONTAINER.get(), ModificationTableScreen::new); + event.register(Registration.FILTER_CONTAINER.get(), FilterScreen::new); } /** diff --git a/src/main/java/com/direwolf20/mininggadgets/setup/Config.java b/src/main/java/com/direwolf20/mininggadgets/setup/Config.java index 35f5ec3d..b11f2d45 100644 --- a/src/main/java/com/direwolf20/mininggadgets/setup/Config.java +++ b/src/main/java/com/direwolf20/mininggadgets/setup/Config.java @@ -1,6 +1,6 @@ package com.direwolf20.mininggadgets.setup; -import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.ModContainer; import net.neoforged.fml.config.ModConfig; import net.neoforged.neoforge.common.ModConfigSpec; @@ -37,17 +37,17 @@ public class Config { public static ModConfigSpec.IntValue UPGRADECOST_BATTERY3; - public static void register() { + public static void register(ModContainer container) { //registerServerConfigs(); - registerCommonConfigs(); + registerCommonConfigs(container); //registerClientConfigs(); } private static void registerClientConfigs() { - ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CLIENT_BUILDER.build()); + //ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CLIENT_BUILDER.build()); } - private static void registerCommonConfigs() { + private static void registerCommonConfigs(ModContainer container) { COMMON_BUILDER.comment("General settings").push(CATEGORY_GENERAL); COMMON_BUILDER.pop(); @@ -57,7 +57,7 @@ private static void registerCommonConfigs() { COMMON_BUILDER.pop(); - ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, COMMON_BUILDER.build()); + container.registerConfig(ModConfig.Type.COMMON, COMMON_BUILDER.build()); } private static void setupMiningGadgetConfig() { diff --git a/src/main/java/com/direwolf20/mininggadgets/setup/ModSetup.java b/src/main/java/com/direwolf20/mininggadgets/setup/ModSetup.java index 3718e40e..579d2386 100644 --- a/src/main/java/com/direwolf20/mininggadgets/setup/ModSetup.java +++ b/src/main/java/com/direwolf20/mininggadgets/setup/ModSetup.java @@ -4,6 +4,7 @@ import com.direwolf20.mininggadgets.common.events.ServerTickHandler; import com.direwolf20.mininggadgets.common.items.MiningGadget; import com.direwolf20.mininggadgets.common.items.upgrade.UpgradeBatteryLevels; +import com.direwolf20.mininggadgets.common.util.MGDataComponents; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.world.item.CreativeModeTab; @@ -36,7 +37,7 @@ public static void init(final FMLCommonSetupEvent event) { // Charged if (item instanceof MiningGadget) { ItemStack stack = new ItemStack(item); - stack.getOrCreateTag().putInt("energy", UpgradeBatteryLevels.BATTERY.getPower()); + stack.set(MGDataComponents.FORGE_ENERGY, UpgradeBatteryLevels.BATTERY.getPower()); output.accept(stack); } }); @@ -49,7 +50,7 @@ public static void init(final FMLCommonSetupEvent event) { // Charged if (item instanceof MiningGadget) { ItemStack stack = new ItemStack(item); - stack.getOrCreateTag().putInt("energy", UpgradeBatteryLevels.BATTERY.getPower()); + stack.set(MGDataComponents.FORGE_ENERGY, UpgradeBatteryLevels.BATTERY.getPower()); output.accept(stack); } }); diff --git a/src/main/java/com/direwolf20/mininggadgets/setup/Registration.java b/src/main/java/com/direwolf20/mininggadgets/setup/Registration.java index afa688e9..1173e55c 100644 --- a/src/main/java/com/direwolf20/mininggadgets/setup/Registration.java +++ b/src/main/java/com/direwolf20/mininggadgets/setup/Registration.java @@ -13,6 +13,7 @@ import com.direwolf20.mininggadgets.common.sounds.OurSounds; import com.direwolf20.mininggadgets.common.tiles.ModificationTableTileEntity; import com.direwolf20.mininggadgets.common.tiles.RenderBlockTileEntity; +import com.direwolf20.mininggadgets.common.util.MGDataComponents; import net.minecraft.core.registries.Registries; import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.BlockItem; @@ -45,6 +46,7 @@ public static void init(IEventBus eventBus) { CONTAINERS.register(eventBus); ModParticles.PARTICLE_TYPES.register(eventBus); OurSounds.SOUND_REGISTRY.register(eventBus); + MGDataComponents.COMPONENTS.register(eventBus); } /**