From e8733d70f0c377042cf7bfe64349d52c7c7ba3d3 Mon Sep 17 00:00:00 2001 From: ochotonida <37985539+ochotonida@users.noreply.github.com> Date: Fri, 22 Jan 2021 19:05:20 +0100 Subject: [PATCH 1/3] Added ToolType ingredient serializer for cutting recipes --- src/generated/resources/.cache/cache | 84 +++++++++--------- .../recipes/cutting/acacia_door.json | 3 +- .../recipes/cutting/acacia_log.json | 3 +- .../recipes/cutting/acacia_sign.json | 3 +- .../recipes/cutting/acacia_trapdoor.json | 3 +- .../recipes/cutting/acacia_wood.json | 3 +- .../recipes/cutting/birch_door.json | 3 +- .../recipes/cutting/birch_log.json | 3 +- .../recipes/cutting/birch_sign.json | 3 +- .../recipes/cutting/birch_trapdoor.json | 3 +- .../recipes/cutting/birch_wood.json | 3 +- .../recipes/cutting/bricks.json | 3 +- .../recipes/cutting/crimson_door.json | 3 +- .../recipes/cutting/crimson_hyphae.json | 3 +- .../recipes/cutting/crimson_sign.json | 3 +- .../recipes/cutting/crimson_stem.json | 3 +- .../recipes/cutting/crimson_trapdoor.json | 3 +- .../recipes/cutting/dark_oak_door.json | 3 +- .../recipes/cutting/dark_oak_log.json | 3 +- .../recipes/cutting/dark_oak_sign.json | 3 +- .../recipes/cutting/dark_oak_trapdoor.json | 3 +- .../recipes/cutting/dark_oak_wood.json | 3 +- .../recipes/cutting/jungle_door.json | 3 +- .../recipes/cutting/jungle_log.json | 3 +- .../recipes/cutting/jungle_sign.json | 3 +- .../recipes/cutting/jungle_trapdoor.json | 3 +- .../recipes/cutting/jungle_wood.json | 3 +- .../recipes/cutting/nether_bricks.json | 3 +- .../recipes/cutting/oak_door.json | 3 +- .../recipes/cutting/oak_log.json | 3 +- .../recipes/cutting/oak_sign.json | 3 +- .../recipes/cutting/oak_trapdoor.json | 3 +- .../recipes/cutting/oak_wood.json | 3 +- .../recipes/cutting/spruce_door.json | 3 +- .../recipes/cutting/spruce_log.json | 3 +- .../recipes/cutting/spruce_sign.json | 3 +- .../recipes/cutting/spruce_trapdoor.json | 3 +- .../recipes/cutting/spruce_wood.json | 3 +- .../recipes/cutting/warped_door.json | 3 +- .../recipes/cutting/warped_hyphae.json | 3 +- .../recipes/cutting/warped_sign.json | 3 +- .../recipes/cutting/warped_stem.json | 3 +- .../recipes/cutting/warped_trapdoor.json | 3 +- .../farmersdelight/FarmersDelight.java | 5 ++ .../crafting/CuttingBoardRecipe.java | 32 +------ .../crafting/ingredients/ToolIngredient.java | 62 ++++++++++++++ .../builder/CuttingBoardRecipeBuilder.java | 37 ++------ .../data/recipes/CuttingRecipes.java | 85 ++++++++++--------- .../tile/CuttingBoardTileEntity.java | 10 +-- 49 files changed, 247 insertions(+), 194 deletions(-) create mode 100644 src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index a8da94b0f..2fa089639 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -405,19 +405,19 @@ b783de3b29f37b56bcb2e81c7b08001c9cd15433 data/farmersdelight/recipes/cooking/veg c0a293cd63227b36f639eb7a33843030551136d2 data/farmersdelight/recipes/cooking/vegetable_soup.json 6e3b5ba173ce14c3530d003548ef6579c3b40642 data/farmersdelight/recipes/cooking_pot.json 5a929fe5c2412b34aca0ccef97bbead04f347173 data/farmersdelight/recipes/crimson_pantry.json -6afa525456f6e4cd16e699b0ab0e10ec35bbe358 data/farmersdelight/recipes/cutting/acacia_door.json -142eae939745d4010f1121d1d5846ca80678f60e data/farmersdelight/recipes/cutting/acacia_log.json -f72c18bf1e439d0c7b452cf6af802b0dee090009 data/farmersdelight/recipes/cutting/acacia_sign.json -66f90536ddbf75902709a4841279dc72d79ecf7c data/farmersdelight/recipes/cutting/acacia_trapdoor.json -2c1bd4be0309f96c91358a9d9fae1d8f97e40a44 data/farmersdelight/recipes/cutting/acacia_wood.json +fee844628d42e8cc68a9b5656837921b3bfa532e data/farmersdelight/recipes/cutting/acacia_door.json +1b73e7c7242cd60b5a0aaabcb5d3da1859878cbf data/farmersdelight/recipes/cutting/acacia_log.json +0ddefcdab5f515610c9de278c5cedbc4f902f341 data/farmersdelight/recipes/cutting/acacia_sign.json +065523d449850d4fcf4a3790c2f807514e4477e3 data/farmersdelight/recipes/cutting/acacia_trapdoor.json +ec2c28065f6e18cf51798ca041eca272ff90032b data/farmersdelight/recipes/cutting/acacia_wood.json 9f0e9a834ed46c0a95d81b136f0a25397df369cb data/farmersdelight/recipes/cutting/apple_pie.json 9d81b1c24841a71a1505a5ef902b7108436255f3 data/farmersdelight/recipes/cutting/beef.json -cacac134ed666fc3a86ea129f5703e2cae73effb data/farmersdelight/recipes/cutting/birch_door.json -49e741d4921160af289d58502f01117c6e28d834 data/farmersdelight/recipes/cutting/birch_log.json -53442c620b2ce6ec9597e7cfc4fd7330267ba452 data/farmersdelight/recipes/cutting/birch_sign.json -27249d870fd5153642b7285886b4d16098811c5c data/farmersdelight/recipes/cutting/birch_trapdoor.json -dcaa959c5b21a936c82c15142a517bd862260062 data/farmersdelight/recipes/cutting/birch_wood.json -c40e3b259d9001639f4dea516084f154c4782be6 data/farmersdelight/recipes/cutting/bricks.json +f5435163162f8511a0e9d518ee4787bfda6722c8 data/farmersdelight/recipes/cutting/birch_door.json +fe5e0a94bf3b6e693c2a17efe8c890200627c6b3 data/farmersdelight/recipes/cutting/birch_log.json +1b4542df84d6228815e73de4ac681a6686e1ef08 data/farmersdelight/recipes/cutting/birch_sign.json +d80ab5d9f11ed212f7fed4646d457cbe28f9efb1 data/farmersdelight/recipes/cutting/birch_trapdoor.json +8728555e6d2760b3881bf67f0a578718000a597d data/farmersdelight/recipes/cutting/birch_wood.json +afe51c56ab8f05caa590489c7095ea2fadbfbaef data/farmersdelight/recipes/cutting/bricks.json 4b0b80ba4ce52942d9f8e0648174b346573418cd data/farmersdelight/recipes/cutting/brown_mushroom_colony.json f802279130ec734bba166e72d2d7b33d8abf856d data/farmersdelight/recipes/cutting/cabbage.json 3cbc2d6c8e96106ee9b5fa4e85021b4548fdd500 data/farmersdelight/recipes/cutting/cake.json @@ -427,33 +427,33 @@ f901e1d070911fb63745525caa8e129b5b299638 data/farmersdelight/recipes/cutting/cod d383fa94f446506d0e5509a180d6276f89133ee4 data/farmersdelight/recipes/cutting/cooked_chicken.json b7923e1caed77cc9e661ee26994b2278f750d892 data/farmersdelight/recipes/cutting/cooked_cod.json 44f738a020ae3fd7fb0d3418b7da5cf3d88bac5d data/farmersdelight/recipes/cutting/cooked_salmon.json -9637706c0eaef5db564bc08a1e878607249e14f5 data/farmersdelight/recipes/cutting/crimson_door.json -7b7b9454a8886e7390a7c574f2667ca876805410 data/farmersdelight/recipes/cutting/crimson_hyphae.json -5d9fc93c6b48a11596d720b9be024a2480dc080c data/farmersdelight/recipes/cutting/crimson_sign.json -db7657fe29d00331cc358cbc55c4bf516e08d1d4 data/farmersdelight/recipes/cutting/crimson_stem.json -143ff67a873eb94041478237b7acc927207ce883 data/farmersdelight/recipes/cutting/crimson_trapdoor.json -035799d12f3b4fa2b7c392e0fa91759520542ea1 data/farmersdelight/recipes/cutting/dark_oak_door.json -4cfbf4f084f88c31c5bec31e4179af2595540e8d data/farmersdelight/recipes/cutting/dark_oak_log.json -6a7210ee48febf664302d8c84310dcc8eb25bce6 data/farmersdelight/recipes/cutting/dark_oak_sign.json -cfbcaab9287563b95adf392cfde2387cdeba1e87 data/farmersdelight/recipes/cutting/dark_oak_trapdoor.json -f735ae6a790789f4cfca9888bc533a594a2e154d data/farmersdelight/recipes/cutting/dark_oak_wood.json +ae333cae5498aa6ff95d1cd5226291c6469d09e9 data/farmersdelight/recipes/cutting/crimson_door.json +e1a837fd1ee8c83d8ac6b349361267fb722f4713 data/farmersdelight/recipes/cutting/crimson_hyphae.json +7401f0fbf7802af8fff23e40ccd7cae29c7bd016 data/farmersdelight/recipes/cutting/crimson_sign.json +0ddf420f64127362230cf34e37c0778cbd5cba5c data/farmersdelight/recipes/cutting/crimson_stem.json +15f50bfd456abba863c66f2e6627268c9991f387 data/farmersdelight/recipes/cutting/crimson_trapdoor.json +8bb200c2eb4d8f284e26b82054e2a57b6c3a1767 data/farmersdelight/recipes/cutting/dark_oak_door.json +84b1714b0c2c98d1dee5510425a6047155c4c775 data/farmersdelight/recipes/cutting/dark_oak_log.json +1a9e49d794c002612ea3a0020899419c6a1c885a data/farmersdelight/recipes/cutting/dark_oak_sign.json +59d9e838eeb2262f4d98b768b7ff6c39a384941a data/farmersdelight/recipes/cutting/dark_oak_trapdoor.json +e9895a181ef95f39b364f35804b121b974f05809 data/farmersdelight/recipes/cutting/dark_oak_wood.json f0475d42bf07c9ea01becafc8aaf8842233f74c9 data/farmersdelight/recipes/cutting/ham.json -6c4acd43110022b3fbf2c84ab4bfe29cfda91106 data/farmersdelight/recipes/cutting/jungle_door.json -4ab1f4d2d117b2ba5c663feebc0ae80ef4bdda48 data/farmersdelight/recipes/cutting/jungle_log.json -c1fc5ae2182767941abf0b8e0bd5d081d35eefc8 data/farmersdelight/recipes/cutting/jungle_sign.json -046615d5ed65576097593432f7875ca87aaf0957 data/farmersdelight/recipes/cutting/jungle_trapdoor.json -17c9a5327b4667a332e362c2f8b16c7666efad62 data/farmersdelight/recipes/cutting/jungle_wood.json +e6adab1d7a297f51f983e85b9be5e8ed36c98857 data/farmersdelight/recipes/cutting/jungle_door.json +ac49058d68148ba67d1e79d433429264216ec0b2 data/farmersdelight/recipes/cutting/jungle_log.json +495104fcac11c01b864f5f733014b70cfb67537a data/farmersdelight/recipes/cutting/jungle_sign.json +cc3ea23ad47409add24e4d5e208286081f42eac8 data/farmersdelight/recipes/cutting/jungle_trapdoor.json +5e46951680bf3a15db811d5edaff10a700c69105 data/farmersdelight/recipes/cutting/jungle_wood.json ee0bd5574f9ebcd2e2d479744ffbf57dabb9863d data/farmersdelight/recipes/cutting/leather_boots.json d8cbf29dc6f312a727643b7bcd844c801ef1fbec data/farmersdelight/recipes/cutting/leather_chestplate.json 4accbc37f2ee0d6af88026952b64f0ea9c1b8fb4 data/farmersdelight/recipes/cutting/leather_helmet.json af758624c08a745f2075b5499d6c3d36fe115625 data/farmersdelight/recipes/cutting/leather_leggings.json da8965db0130401c8b7f60d2e0004c381408a86b data/farmersdelight/recipes/cutting/melon.json -e0303b43d4c488b06a22982979c07068237bdffd data/farmersdelight/recipes/cutting/nether_bricks.json -25ac0371bca2dcc3bcc997b6587dee3b294e5f0e data/farmersdelight/recipes/cutting/oak_door.json -7d163f15a069e427d74a4b2ba39a8fa02f929f5b data/farmersdelight/recipes/cutting/oak_log.json -ec4594e5f53a21338cc9823d8cea9f7e98d57d3f data/farmersdelight/recipes/cutting/oak_sign.json -6b2fb5a4607c607e5fa1eb0fad87ad59d62f199c data/farmersdelight/recipes/cutting/oak_trapdoor.json -065dd10fe0a5fcc3cf986a09099b857ebfa0612d data/farmersdelight/recipes/cutting/oak_wood.json +d8a9b511dc31e6f506909b93f2c85e54e6405e03 data/farmersdelight/recipes/cutting/nether_bricks.json +e071f419b9a34f4cc078db5871ef23e8198cbab3 data/farmersdelight/recipes/cutting/oak_door.json +6c9babe81caca58357e2b5eadb75c503ffa78739 data/farmersdelight/recipes/cutting/oak_log.json +bbdf37bd140924e7e1a52f0caa2260f448cc5f50 data/farmersdelight/recipes/cutting/oak_sign.json +83e7ab8240c20d5146caec91498d9b7b62c24fe2 data/farmersdelight/recipes/cutting/oak_trapdoor.json +062c98a5966ece7026102cdd8e08e05bed4ab0a8 data/farmersdelight/recipes/cutting/oak_wood.json 12ef71e8948493020c9913fb413daa04aa4aee45 data/farmersdelight/recipes/cutting/porkchop.json d341d4759ada5512474f8348855de202eed96e78 data/farmersdelight/recipes/cutting/pumpkin.json 1c9f86d9435b826a571516476e30769688c14d45 data/farmersdelight/recipes/cutting/red_mushroom_colony.json @@ -461,17 +461,17 @@ d341d4759ada5512474f8348855de202eed96e78 data/farmersdelight/recipes/cutting/pum 3af121b7cf9ecefaaed1bca294ca812214479ed9 data/farmersdelight/recipes/cutting/saddle.json 956e804fd912459fb069fe6b102ffedf1473bec9 data/farmersdelight/recipes/cutting/salmon.json a6ff9b90b2125dcb64d74e7cf49cfaeab9d44782 data/farmersdelight/recipes/cutting/smoked_ham.json -f221af11ba8b19df3bcf809cb3ae5ba8ea76fe9b data/farmersdelight/recipes/cutting/spruce_door.json -86a429ef60d896c15f7eb10f613de4f88f5299dc data/farmersdelight/recipes/cutting/spruce_log.json -9b1407548f4b5b7be63cd15e6bce2393096f07dc data/farmersdelight/recipes/cutting/spruce_sign.json -6d8405aeb1f8d13c6eda33bd9414a167a292969f data/farmersdelight/recipes/cutting/spruce_trapdoor.json -189f36300b7ee4eccdc230344d39154ff5368efd data/farmersdelight/recipes/cutting/spruce_wood.json +df85d809dd978062e4e37e0426d9fae47df46a30 data/farmersdelight/recipes/cutting/spruce_door.json +4e0b6bd7659b20d4381bcd1066f0d9263811cb31 data/farmersdelight/recipes/cutting/spruce_log.json +b8895821a9863bf271d03686e3c16d593a323675 data/farmersdelight/recipes/cutting/spruce_sign.json +f43bc73ae7f10b3bfd9e8a95693ca8b18a4788a0 data/farmersdelight/recipes/cutting/spruce_trapdoor.json +5825b638daeb4f2089f53520d48efd91b3155284 data/farmersdelight/recipes/cutting/spruce_wood.json 51905031fcbad1da32c7865e2b92932fd53ffa49 data/farmersdelight/recipes/cutting/sweet_berry_cheesecake.json -35f8c5d7b40187bb644d177e698d6be8ff9283bf data/farmersdelight/recipes/cutting/warped_door.json -7c451fbf4b11f56a2f4f9a9480598465328efbc8 data/farmersdelight/recipes/cutting/warped_hyphae.json -b74c4ab10cbf74673ddd052a4023c15c02a4a673 data/farmersdelight/recipes/cutting/warped_sign.json -f8944e4988864c3ee98da5e5aa4ff06e7bb0b617 data/farmersdelight/recipes/cutting/warped_stem.json -226a4b3b649b8efb0cd8b5ed4a90cb559d41bb29 data/farmersdelight/recipes/cutting/warped_trapdoor.json +2986bea80f127f04912d2e69dc1159e15d081741 data/farmersdelight/recipes/cutting/warped_door.json +acf85beba2cd3528561d2c0344dabd7566e67690 data/farmersdelight/recipes/cutting/warped_hyphae.json +ff85e4344750200d4a9561017020f6513b677842 data/farmersdelight/recipes/cutting/warped_sign.json +46d07ec65280e5ef1aad903917b34867ec214cfa data/farmersdelight/recipes/cutting/warped_stem.json +716cdf2d287fc1ea005a0f3342ef5c53491ee5fd data/farmersdelight/recipes/cutting/warped_trapdoor.json a1afaa4f8dcc43689fb3ffa65f9c6c9c9eee19de data/farmersdelight/recipes/cutting_board.json fe5879ed2f883ee8471c4e5dbada068c969f9e24 data/farmersdelight/recipes/dark_oak_pantry.json 6cf798a8915d956e5d9e3139e027c31b9903b1e0 data/farmersdelight/recipes/diamond_knife.json diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_door.json b/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_door.json index 931a64b87..be8e61c64 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_door.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_door.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_log.json b/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_log.json index 196829050..b198b8be6 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_log.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_log.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_sign.json b/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_sign.json index 2d7e2269f..0d72e74cb 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_sign.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_sign.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_trapdoor.json b/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_trapdoor.json index 062666ba8..5a7b0145e 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_trapdoor.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_trapdoor.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_wood.json b/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_wood.json index 6306b15ab..5ef4152a5 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_wood.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/acacia_wood.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/birch_door.json b/src/generated/resources/data/farmersdelight/recipes/cutting/birch_door.json index e085d548b..ec04874bf 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/birch_door.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/birch_door.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/birch_log.json b/src/generated/resources/data/farmersdelight/recipes/cutting/birch_log.json index 0a8f6ecc8..4e8fb0a3a 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/birch_log.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/birch_log.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/birch_sign.json b/src/generated/resources/data/farmersdelight/recipes/cutting/birch_sign.json index a0a4572d0..0fc054f71 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/birch_sign.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/birch_sign.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/birch_trapdoor.json b/src/generated/resources/data/farmersdelight/recipes/cutting/birch_trapdoor.json index 8669052a7..4429a41fd 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/birch_trapdoor.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/birch_trapdoor.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/birch_wood.json b/src/generated/resources/data/farmersdelight/recipes/cutting/birch_wood.json index 1d9ec5c50..9a05c4672 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/birch_wood.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/birch_wood.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/bricks.json b/src/generated/resources/data/farmersdelight/recipes/cutting/bricks.json index edcd769be..3f26ba3bf 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/bricks.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/bricks.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "pickaxe" + "type": "farmersdelight:tool", + "tool": "pickaxe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_door.json b/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_door.json index d85b625fd..80e0844c6 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_door.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_door.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_hyphae.json b/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_hyphae.json index efbb1fe87..91dc063e2 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_hyphae.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_hyphae.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_sign.json b/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_sign.json index 9a685140e..944fe6016 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_sign.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_sign.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_stem.json b/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_stem.json index 907171fae..586eda627 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_stem.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_stem.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_trapdoor.json b/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_trapdoor.json index 9bbe986c0..f84341c31 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_trapdoor.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/crimson_trapdoor.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_door.json b/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_door.json index a277dce09..c9660cc85 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_door.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_door.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_log.json b/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_log.json index 3f6d23b52..0a01c5f13 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_log.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_log.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_sign.json b/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_sign.json index db712a63a..084def00e 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_sign.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_sign.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_trapdoor.json b/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_trapdoor.json index f9ad4baa8..e0a4109a4 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_trapdoor.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_trapdoor.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_wood.json b/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_wood.json index 12320aaed..37c50b86f 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_wood.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/dark_oak_wood.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_door.json b/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_door.json index 242428c00..a20621c15 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_door.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_door.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_log.json b/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_log.json index 3c1443a4e..f88d0b008 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_log.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_log.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_sign.json b/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_sign.json index d181064e4..316c1c0aa 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_sign.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_sign.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_trapdoor.json b/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_trapdoor.json index 8c264e1c0..0e774d778 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_trapdoor.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_trapdoor.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_wood.json b/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_wood.json index 6b273b629..6e8ba9254 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_wood.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/jungle_wood.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/nether_bricks.json b/src/generated/resources/data/farmersdelight/recipes/cutting/nether_bricks.json index 13ab4eda6..982cbd8bd 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/nether_bricks.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/nether_bricks.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "pickaxe" + "type": "farmersdelight:tool", + "tool": "pickaxe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/oak_door.json b/src/generated/resources/data/farmersdelight/recipes/cutting/oak_door.json index 9eba7be54..b1cbbd615 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/oak_door.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/oak_door.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/oak_log.json b/src/generated/resources/data/farmersdelight/recipes/cutting/oak_log.json index 564f0f746..67787d004 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/oak_log.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/oak_log.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/oak_sign.json b/src/generated/resources/data/farmersdelight/recipes/cutting/oak_sign.json index 4d8af5bf6..5a25e773a 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/oak_sign.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/oak_sign.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/oak_trapdoor.json b/src/generated/resources/data/farmersdelight/recipes/cutting/oak_trapdoor.json index 6f6d94dbc..a82ff5fd0 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/oak_trapdoor.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/oak_trapdoor.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/oak_wood.json b/src/generated/resources/data/farmersdelight/recipes/cutting/oak_wood.json index 49e7e8879..7bae6b8e6 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/oak_wood.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/oak_wood.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_door.json b/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_door.json index 0aafd3d65..46725d748 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_door.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_door.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_log.json b/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_log.json index 374cb49ba..8c392dc15 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_log.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_log.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_sign.json b/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_sign.json index 2f161b0aa..b485ca52e 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_sign.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_sign.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_trapdoor.json b/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_trapdoor.json index 7fba8c702..7663755d8 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_trapdoor.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_trapdoor.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_wood.json b/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_wood.json index 704e3d2ab..483ba0406 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_wood.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/spruce_wood.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/warped_door.json b/src/generated/resources/data/farmersdelight/recipes/cutting/warped_door.json index e97bfe865..a0aef92b3 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/warped_door.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/warped_door.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/warped_hyphae.json b/src/generated/resources/data/farmersdelight/recipes/cutting/warped_hyphae.json index ac927f2a1..b934bc81e 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/warped_hyphae.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/warped_hyphae.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/warped_sign.json b/src/generated/resources/data/farmersdelight/recipes/cutting/warped_sign.json index 241af4e2e..498bc4f8c 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/warped_sign.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/warped_sign.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/warped_stem.json b/src/generated/resources/data/farmersdelight/recipes/cutting/warped_stem.json index db325913a..8b17a583e 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/warped_stem.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/warped_stem.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/generated/resources/data/farmersdelight/recipes/cutting/warped_trapdoor.json b/src/generated/resources/data/farmersdelight/recipes/cutting/warped_trapdoor.json index 388ce1210..021444236 100644 --- a/src/generated/resources/data/farmersdelight/recipes/cutting/warped_trapdoor.json +++ b/src/generated/resources/data/farmersdelight/recipes/cutting/warped_trapdoor.json @@ -6,7 +6,8 @@ } ], "tool": { - "type": "axe" + "type": "farmersdelight:tool", + "tool": "axe" }, "result": [ { diff --git a/src/main/java/vectorwing/farmersdelight/FarmersDelight.java b/src/main/java/vectorwing/farmersdelight/FarmersDelight.java index de7d6e554..033a96049 100644 --- a/src/main/java/vectorwing/farmersdelight/FarmersDelight.java +++ b/src/main/java/vectorwing/farmersdelight/FarmersDelight.java @@ -1,7 +1,9 @@ package vectorwing.farmersdelight; import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.IEventBus; @@ -13,6 +15,7 @@ import org.apache.logging.log4j.Logger; import vectorwing.farmersdelight.crafting.CookingPotRecipe; import vectorwing.farmersdelight.crafting.CuttingBoardRecipe; +import vectorwing.farmersdelight.crafting.ingredients.ToolIngredient; import vectorwing.farmersdelight.registry.*; import vectorwing.farmersdelight.setup.ClientEventHandler; import vectorwing.farmersdelight.setup.CommonEventHandler; @@ -54,6 +57,8 @@ public FarmersDelight() { } private void registerRecipeSerializers(RegistryEvent.Register> event) { + CraftingHelper.register(new ResourceLocation(MODID, "tool"), ToolIngredient.SERIALIZER); + event.getRegistry().register(CookingPotRecipe.SERIALIZER); event.getRegistry().register(CuttingBoardRecipe.SERIALIZER); } diff --git a/src/main/java/vectorwing/farmersdelight/crafting/CuttingBoardRecipe.java b/src/main/java/vectorwing/farmersdelight/crafting/CuttingBoardRecipe.java index c5fcc79cf..e18bf71f2 100644 --- a/src/main/java/vectorwing/farmersdelight/crafting/CuttingBoardRecipe.java +++ b/src/main/java/vectorwing/farmersdelight/crafting/CuttingBoardRecipe.java @@ -11,9 +11,7 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import net.minecraftforge.common.ToolType; import net.minecraftforge.items.wrapper.RecipeWrapper; -import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistryEntry; import vectorwing.farmersdelight.FarmersDelight; @@ -28,16 +26,14 @@ public class CuttingBoardRecipe implements IRecipe private final String group; private final Ingredient input; private final Ingredient tool; - private final ToolType toolType; private final NonNullList results; private final String soundEvent; - public CuttingBoardRecipe(ResourceLocation id, String group, Ingredient input, Ingredient tool, @Nullable ToolType toolType, NonNullList results, String soundEvent) { + public CuttingBoardRecipe(ResourceLocation id, String group, Ingredient input, Ingredient tool, NonNullList results, String soundEvent) { this.id = id; this.group = group; this.input = input; this.tool = tool; - this.toolType = toolType; this.results = results; this.soundEvent = soundEvent; } @@ -70,11 +66,6 @@ public Ingredient getTool() { return this.tool; } - @Nullable - public ToolType getToolType() { - return this.toolType; - } - @Override public ItemStack getCraftingResult(RecipeWrapper inv) { return this.results.get(0).copy(); @@ -130,18 +121,7 @@ public CuttingBoardRecipe read(ResourceLocation recipeId, JsonObject json) { final String groupIn = JSONUtils.getString(json, "group", ""); final NonNullList inputItemsIn = readIngredients(JSONUtils.getJsonArray(json, "ingredients")); final JsonObject toolObject= JSONUtils.getJsonObject(json, "tool"); - final Ingredient toolIn; - final ToolType toolTypeIn; - if (JSONUtils.hasField(toolObject, "type")) { - // Create an Ingredient from all items that have the specified ToolType - toolTypeIn = ToolType.get(JSONUtils.getString(toolObject, "type")); - toolIn = Ingredient.fromStacks(ForgeRegistries.ITEMS.getValues().stream() - .filter((item) -> item.getToolTypes(new ItemStack(item)).contains(toolTypeIn)) - .map(ItemStack::new)); - } else { - toolTypeIn = null; - toolIn = Ingredient.deserialize(toolObject); - } + final Ingredient toolIn = Ingredient.deserialize(toolObject); if (inputItemsIn.isEmpty()) { throw new JsonParseException("No ingredients for cutting recipe"); } else if (toolIn.hasNoMatchingItems()) { @@ -151,7 +131,7 @@ public CuttingBoardRecipe read(ResourceLocation recipeId, JsonObject json) { } else { final NonNullList results = readResults(JSONUtils.getJsonArray(json, "result")); final String soundID = JSONUtils.getString(json, "sound", ""); - return new CuttingBoardRecipe(recipeId, groupIn, inputItemsIn.get(0), toolIn, toolTypeIn, results, soundID); + return new CuttingBoardRecipe(recipeId, groupIn, inputItemsIn.get(0), toolIn, results, soundID); } } @@ -180,8 +160,6 @@ public CuttingBoardRecipe read(ResourceLocation recipeId, PacketBuffer buffer) { String groupIn = buffer.readString(32767); Ingredient inputItemIn = Ingredient.read(buffer); Ingredient toolIn = Ingredient.read(buffer); - String toolTypeName = buffer.readString(); - ToolType toolTypeIn = toolTypeName.isEmpty() ? null : ToolType.get(toolTypeName); int i = buffer.readVarInt(); NonNullList resultsIn = NonNullList.withSize(i, ItemStack.EMPTY); @@ -190,7 +168,7 @@ public CuttingBoardRecipe read(ResourceLocation recipeId, PacketBuffer buffer) { } String soundEventIn = buffer.readString(); - return new CuttingBoardRecipe(recipeId, groupIn, inputItemIn, toolIn, toolTypeIn, resultsIn, soundEventIn); + return new CuttingBoardRecipe(recipeId, groupIn, inputItemIn, toolIn, resultsIn, soundEventIn); } @Override @@ -198,8 +176,6 @@ public void write(PacketBuffer buffer, CuttingBoardRecipe recipe) { buffer.writeString(recipe.group); recipe.input.write(buffer); recipe.tool.write(buffer); - ToolType toolTypeName = recipe.getToolType(); - buffer.writeString(toolTypeName == null ? "" : toolTypeName.getName()); buffer.writeVarInt(recipe.results.size()); for (ItemStack result : recipe.results) { buffer.writeItemStack(result); diff --git a/src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java b/src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java new file mode 100644 index 000000000..53a7ab786 --- /dev/null +++ b/src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java @@ -0,0 +1,62 @@ +package vectorwing.farmersdelight.crafting.ingredients; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.common.ToolType; +import net.minecraftforge.common.crafting.CraftingHelper; +import net.minecraftforge.common.crafting.IIngredientSerializer; +import net.minecraftforge.registries.ForgeRegistries; + +import javax.annotation.ParametersAreNonnullByDefault; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class ToolIngredient extends Ingredient +{ + public static final Serializer SERIALIZER = new Serializer(); + + private final ToolType toolType; + + public ToolIngredient(ToolType toolType) { + super(ForgeRegistries.ITEMS.getValues().stream() + .map(ItemStack::new) + .filter(stack -> stack.getToolTypes().contains(toolType)) + .map(Ingredient.SingleItemList::new)); + this.toolType = toolType; + } + + @Override + public JsonElement serialize() { + JsonObject json = new JsonObject(); + json.addProperty("type", CraftingHelper.getID(SERIALIZER).toString()); + json.addProperty("tool", toolType.getName()); + return json; + } + + @Override + public IIngredientSerializer getSerializer() { + return super.getSerializer(); + } + + public static class Serializer implements IIngredientSerializer + { + @Override + public ToolIngredient parse(JsonObject json) { + return new ToolIngredient(ToolType.get(json.get("tool").getAsString())); + } + + @Override + public ToolIngredient parse(PacketBuffer buffer) { + return new ToolIngredient(ToolType.get(buffer.readString())); + } + + @Override + public void write(PacketBuffer buffer, ToolIngredient ingredient) { + buffer.writeString(ingredient.toolType.getName()); + } + } +} diff --git a/src/main/java/vectorwing/farmersdelight/data/builder/CuttingBoardRecipeBuilder.java b/src/main/java/vectorwing/farmersdelight/data/builder/CuttingBoardRecipeBuilder.java index 9a042247c..c3bec096d 100644 --- a/src/main/java/vectorwing/farmersdelight/data/builder/CuttingBoardRecipeBuilder.java +++ b/src/main/java/vectorwing/farmersdelight/data/builder/CuttingBoardRecipeBuilder.java @@ -9,7 +9,6 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.ToolType; import net.minecraftforge.registries.ForgeRegistries; import vectorwing.farmersdelight.FarmersDelight; import vectorwing.farmersdelight.crafting.CuttingBoardRecipe; @@ -27,42 +26,26 @@ public class CuttingBoardRecipeBuilder private final Map results = new LinkedHashMap<>(4); private final Ingredient ingredient; private final Ingredient tool; - private final ToolType toolType; private String soundEventID; - private CuttingBoardRecipeBuilder(Ingredient ingredient, @Nullable Ingredient tool, @Nullable ToolType toolType, IItemProvider mainResult, int count) { + private CuttingBoardRecipeBuilder(Ingredient ingredient, Ingredient tool, IItemProvider mainResult, int count) { this.results.put(mainResult.asItem(), count); this.ingredient = ingredient; this.tool = tool; - this.toolType = toolType; } /** * Creates a new builder for a cutting recipe. */ public static CuttingBoardRecipeBuilder cuttingRecipe(Ingredient ingredient, Ingredient tool, IItemProvider mainResult, int count) { - return new CuttingBoardRecipeBuilder(ingredient, tool, null, mainResult, count); + return new CuttingBoardRecipeBuilder(ingredient, tool, mainResult, count); } /** * Creates a new builder for a cutting recipe, returning 1 unit of the result. */ public static CuttingBoardRecipeBuilder cuttingRecipe(Ingredient ingredient, Ingredient tool, IItemProvider mainResult) { - return new CuttingBoardRecipeBuilder(ingredient, tool, null, mainResult, 1); - } - - /** - * Creates a new builder for a cutting recipe. - */ - public static CuttingBoardRecipeBuilder cuttingRecipe(Ingredient ingredient, ToolType toolType, IItemProvider mainResult, int count) { - return new CuttingBoardRecipeBuilder(ingredient, null, toolType, mainResult, count); - } - - /** - * Creates a new builder for a cutting recipe, returning 1 unit of the result. - */ - public static CuttingBoardRecipeBuilder cuttingRecipe(Ingredient ingredient, ToolType toolType, IItemProvider mainResult) { - return new CuttingBoardRecipeBuilder(ingredient, null, toolType, mainResult, 1); + return new CuttingBoardRecipeBuilder(ingredient, tool, mainResult, 1); } public CuttingBoardRecipeBuilder addResult(IItemProvider result) { @@ -94,7 +77,7 @@ public void build(Consumer consumerIn, String save) { } public void build(Consumer consumerIn, ResourceLocation id) { - consumerIn.accept(new CuttingBoardRecipeBuilder.Result(id, this.ingredient, this.tool, this.toolType, this.results, this.soundEventID == null ? "" : this.soundEventID)); + consumerIn.accept(new CuttingBoardRecipeBuilder.Result(id, this.ingredient, this.tool, this.results, this.soundEventID == null ? "" : this.soundEventID)); } public static class Result implements IFinishedRecipe @@ -102,15 +85,13 @@ public static class Result implements IFinishedRecipe private final ResourceLocation id; private final Ingredient ingredient; private final Ingredient tool; - private final ToolType toolType; private final Map results; private final String soundEventID; - public Result(ResourceLocation idIn, Ingredient ingredientIn, @Nullable Ingredient toolIn, @Nullable ToolType toolType, Map resultsIn, String soundEventIDIn) { + public Result(ResourceLocation idIn, Ingredient ingredientIn, Ingredient toolIn, Map resultsIn, String soundEventIDIn) { this.id = idIn; this.ingredient = ingredientIn; this.tool = toolIn; - this.toolType = toolType; this.results = resultsIn; this.soundEventID = soundEventIDIn; } @@ -121,13 +102,7 @@ public void serialize(JsonObject json) { arrayIngredients.add(this.ingredient.serialize()); json.add("ingredients", arrayIngredients); - if (this.toolType != null) { - JsonObject toolTypeObject = new JsonObject(); - toolTypeObject.addProperty("type", this.toolType.getName()); - json.add("tool", toolTypeObject); - } else { - json.add("tool", this.tool.serialize()); - } + json.add("tool", this.tool.serialize()); JsonArray arrayResults = new JsonArray(); for (Map.Entry result : this.results.entrySet()) { diff --git a/src/main/java/vectorwing/farmersdelight/data/recipes/CuttingRecipes.java b/src/main/java/vectorwing/farmersdelight/data/recipes/CuttingRecipes.java index d8613b5cb..18d934f95 100644 --- a/src/main/java/vectorwing/farmersdelight/data/recipes/CuttingRecipes.java +++ b/src/main/java/vectorwing/farmersdelight/data/recipes/CuttingRecipes.java @@ -6,6 +6,7 @@ import net.minecraft.util.SoundEvents; import net.minecraftforge.common.Tags; import net.minecraftforge.common.ToolType; +import vectorwing.farmersdelight.crafting.ingredients.ToolIngredient; import vectorwing.farmersdelight.data.builder.CuttingBoardRecipeBuilder; import vectorwing.farmersdelight.registry.ModItems; import vectorwing.farmersdelight.utils.tags.ForgeTags; @@ -90,103 +91,103 @@ private static void chopPastries(Consumer consumer) { } private static void salvageBricks(Consumer consumer) { - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BRICKS), ToolType.PICKAXE, Items.BRICK, 4) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BRICKS), new ToolIngredient(ToolType.PICKAXE), Items.BRICK, 4) .build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.NETHER_BRICKS), ToolType.PICKAXE, Items.NETHER_BRICK, 4) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.NETHER_BRICKS), new ToolIngredient(ToolType.PICKAXE), Items.NETHER_BRICK, 4) .build(consumer); } private static void stripWood(Consumer consumer) { // Oak - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.OAK_LOG), ToolType.AXE, Items.STRIPPED_OAK_LOG) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.OAK_LOG), new ToolIngredient(ToolType.AXE), Items.STRIPPED_OAK_LOG) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.OAK_WOOD), ToolType.AXE, Items.STRIPPED_OAK_WOOD) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.OAK_WOOD), new ToolIngredient(ToolType.AXE), Items.STRIPPED_OAK_WOOD) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); // Birch - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BIRCH_LOG), ToolType.AXE, Items.STRIPPED_BIRCH_LOG) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BIRCH_LOG), new ToolIngredient(ToolType.AXE), Items.STRIPPED_BIRCH_LOG) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BIRCH_WOOD), ToolType.AXE, Items.STRIPPED_BIRCH_WOOD) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BIRCH_WOOD), new ToolIngredient(ToolType.AXE), Items.STRIPPED_BIRCH_WOOD) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); // Spruce - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.SPRUCE_LOG), ToolType.AXE, Items.STRIPPED_SPRUCE_LOG) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.SPRUCE_LOG), new ToolIngredient(ToolType.AXE), Items.STRIPPED_SPRUCE_LOG) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.SPRUCE_WOOD), ToolType.AXE, Items.STRIPPED_SPRUCE_WOOD) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.SPRUCE_WOOD), new ToolIngredient(ToolType.AXE), Items.STRIPPED_SPRUCE_WOOD) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); // Jungle - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.JUNGLE_LOG), ToolType.AXE, Items.STRIPPED_JUNGLE_LOG) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.JUNGLE_LOG), new ToolIngredient(ToolType.AXE), Items.STRIPPED_JUNGLE_LOG) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.JUNGLE_WOOD), ToolType.AXE, Items.STRIPPED_JUNGLE_WOOD) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.JUNGLE_WOOD), new ToolIngredient(ToolType.AXE), Items.STRIPPED_JUNGLE_WOOD) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); // Acacia - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.ACACIA_LOG), ToolType.AXE, Items.STRIPPED_ACACIA_LOG) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.ACACIA_LOG), new ToolIngredient(ToolType.AXE), Items.STRIPPED_ACACIA_LOG) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.ACACIA_WOOD), ToolType.AXE, Items.STRIPPED_ACACIA_WOOD) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.ACACIA_WOOD), new ToolIngredient(ToolType.AXE), Items.STRIPPED_ACACIA_WOOD) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); // Dark Oak - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.DARK_OAK_LOG), ToolType.AXE, Items.STRIPPED_DARK_OAK_LOG) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.DARK_OAK_LOG), new ToolIngredient(ToolType.AXE), Items.STRIPPED_DARK_OAK_LOG) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.DARK_OAK_WOOD), ToolType.AXE, Items.STRIPPED_DARK_OAK_WOOD) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.DARK_OAK_WOOD), new ToolIngredient(ToolType.AXE), Items.STRIPPED_DARK_OAK_WOOD) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); // Dark Oak - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.CRIMSON_STEM), ToolType.AXE, Items.STRIPPED_CRIMSON_STEM) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.CRIMSON_STEM), new ToolIngredient(ToolType.AXE), Items.STRIPPED_CRIMSON_STEM) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.CRIMSON_HYPHAE), ToolType.AXE, Items.STRIPPED_CRIMSON_HYPHAE) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.CRIMSON_HYPHAE), new ToolIngredient(ToolType.AXE), Items.STRIPPED_CRIMSON_HYPHAE) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); // Dark Oak - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.WARPED_STEM), ToolType.AXE, Items.STRIPPED_WARPED_STEM) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.WARPED_STEM), new ToolIngredient(ToolType.AXE), Items.STRIPPED_WARPED_STEM) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.WARPED_HYPHAE), ToolType.AXE, Items.STRIPPED_WARPED_HYPHAE) + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.WARPED_HYPHAE), new ToolIngredient(ToolType.AXE), Items.STRIPPED_WARPED_HYPHAE) .addResult(ModItems.TREE_BARK.get()) .addSound(SoundEvents.ITEM_AXE_STRIP.getRegistryName().toString()).build(consumer); } private static void salvageWoodenFurniture(Consumer consumer) { - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.OAK_DOOR), ToolType.AXE, Items.OAK_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.OAK_TRAPDOOR), ToolType.AXE, Items.OAK_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.OAK_SIGN), ToolType.AXE, Items.OAK_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BIRCH_DOOR), ToolType.AXE, Items.BIRCH_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BIRCH_TRAPDOOR), ToolType.AXE, Items.BIRCH_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BIRCH_SIGN), ToolType.AXE, Items.BIRCH_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.SPRUCE_DOOR), ToolType.AXE, Items.SPRUCE_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.SPRUCE_TRAPDOOR), ToolType.AXE, Items.SPRUCE_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.SPRUCE_SIGN), ToolType.AXE, Items.SPRUCE_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.JUNGLE_DOOR), ToolType.AXE, Items.JUNGLE_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.JUNGLE_TRAPDOOR), ToolType.AXE, Items.JUNGLE_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.JUNGLE_SIGN), ToolType.AXE, Items.JUNGLE_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.ACACIA_DOOR), ToolType.AXE, Items.ACACIA_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.ACACIA_TRAPDOOR), ToolType.AXE, Items.ACACIA_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.ACACIA_SIGN), ToolType.AXE, Items.ACACIA_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.DARK_OAK_DOOR), ToolType.AXE, Items.DARK_OAK_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.DARK_OAK_TRAPDOOR), ToolType.AXE, Items.DARK_OAK_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.DARK_OAK_SIGN), ToolType.AXE, Items.DARK_OAK_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.CRIMSON_DOOR), ToolType.AXE, Items.CRIMSON_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.CRIMSON_TRAPDOOR), ToolType.AXE, Items.CRIMSON_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.CRIMSON_SIGN), ToolType.AXE, Items.CRIMSON_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.WARPED_DOOR), ToolType.AXE, Items.WARPED_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.WARPED_TRAPDOOR), ToolType.AXE, Items.WARPED_PLANKS).build(consumer); - CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.WARPED_SIGN), ToolType.AXE, Items.WARPED_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.OAK_DOOR), new ToolIngredient(ToolType.AXE), Items.OAK_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.OAK_TRAPDOOR), new ToolIngredient(ToolType.AXE), Items.OAK_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.OAK_SIGN), new ToolIngredient(ToolType.AXE), Items.OAK_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BIRCH_DOOR), new ToolIngredient(ToolType.AXE), Items.BIRCH_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BIRCH_TRAPDOOR), new ToolIngredient(ToolType.AXE), Items.BIRCH_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.BIRCH_SIGN), new ToolIngredient(ToolType.AXE), Items.BIRCH_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.SPRUCE_DOOR), new ToolIngredient(ToolType.AXE), Items.SPRUCE_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.SPRUCE_TRAPDOOR), new ToolIngredient(ToolType.AXE), Items.SPRUCE_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.SPRUCE_SIGN), new ToolIngredient(ToolType.AXE), Items.SPRUCE_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.JUNGLE_DOOR), new ToolIngredient(ToolType.AXE), Items.JUNGLE_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.JUNGLE_TRAPDOOR), new ToolIngredient(ToolType.AXE), Items.JUNGLE_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.JUNGLE_SIGN), new ToolIngredient(ToolType.AXE), Items.JUNGLE_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.ACACIA_DOOR), new ToolIngredient(ToolType.AXE), Items.ACACIA_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.ACACIA_TRAPDOOR), new ToolIngredient(ToolType.AXE), Items.ACACIA_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.ACACIA_SIGN), new ToolIngredient(ToolType.AXE), Items.ACACIA_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.DARK_OAK_DOOR), new ToolIngredient(ToolType.AXE), Items.DARK_OAK_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.DARK_OAK_TRAPDOOR), new ToolIngredient(ToolType.AXE), Items.DARK_OAK_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.DARK_OAK_SIGN), new ToolIngredient(ToolType.AXE), Items.DARK_OAK_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.CRIMSON_DOOR), new ToolIngredient(ToolType.AXE), Items.CRIMSON_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.CRIMSON_TRAPDOOR), new ToolIngredient(ToolType.AXE), Items.CRIMSON_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.CRIMSON_SIGN), new ToolIngredient(ToolType.AXE), Items.CRIMSON_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.WARPED_DOOR), new ToolIngredient(ToolType.AXE), Items.WARPED_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.WARPED_TRAPDOOR), new ToolIngredient(ToolType.AXE), Items.WARPED_PLANKS).build(consumer); + CuttingBoardRecipeBuilder.cuttingRecipe(Ingredient.fromItems(Items.WARPED_SIGN), new ToolIngredient(ToolType.AXE), Items.WARPED_PLANKS).build(consumer); } private static void salvageUsingShears(Consumer consumer) { diff --git a/src/main/java/vectorwing/farmersdelight/tile/CuttingBoardTileEntity.java b/src/main/java/vectorwing/farmersdelight/tile/CuttingBoardTileEntity.java index fbdc0103b..092c5c7b0 100644 --- a/src/main/java/vectorwing/farmersdelight/tile/CuttingBoardTileEntity.java +++ b/src/main/java/vectorwing/farmersdelight/tile/CuttingBoardTileEntity.java @@ -100,7 +100,7 @@ public boolean processItemUsingTool(ItemStack tool, @Nullable PlayerEntity playe CuttingBoardRecipe irecipe = this.world.getRecipeManager() .getRecipe(this.recipeType, new RecipeWrapper(itemHandler), this.world).orElse(null); - if (irecipe != null && this.isToolValid(tool, irecipe)) { + if (irecipe != null && irecipe.getTool().test(tool)) { NonNullList results = this.getResults(); for (ItemStack result : results) { Direction direction = this.getBlockState().get(CuttingBoardBlock.FACING).rotateYCCW(); @@ -127,14 +127,6 @@ public boolean processItemUsingTool(ItemStack tool, @Nullable PlayerEntity playe return false; } - public boolean isToolValid(ItemStack tool, CuttingBoardRecipe recipe) { - if (recipe.getToolType() != null) { - return tool.getToolTypes().contains(recipe.getToolType()); - } else { - return recipe.getTool().test(tool); - } - } - protected NonNullList getResults() { return this.world.getRecipeManager().getRecipe(this.recipeType, new RecipeWrapper(itemHandler), this.world).map(CuttingBoardRecipe::getResults).orElse(NonNullList.withSize(1, ItemStack.EMPTY)); } From 82291cbe3f49ceb3dfcc9cb8bf3b09b555d81308 Mon Sep 17 00:00:00 2001 From: ochotonida <37985539+ochotonida@users.noreply.github.com> Date: Fri, 22 Jan 2021 21:31:10 +0100 Subject: [PATCH 2/3] Forgot to implement getSerializer --- .../farmersdelight/crafting/ingredients/ToolIngredient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java b/src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java index 53a7ab786..453032f32 100644 --- a/src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java +++ b/src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java @@ -39,7 +39,7 @@ public JsonElement serialize() { @Override public IIngredientSerializer getSerializer() { - return super.getSerializer(); + return SERIALIZER; } public static class Serializer implements IIngredientSerializer From 99fbae150dffdfc8ddf357f7c14aecec7d145a5e Mon Sep 17 00:00:00 2001 From: ochotonida <37985539+ochotonida@users.noreply.github.com> Date: Thu, 4 Feb 2021 01:24:37 +0100 Subject: [PATCH 3/3] Fix tool ingredients not working for items with dynamic tool types --- .../farmersdelight/crafting/ingredients/ToolIngredient.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java b/src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java index 453032f32..741186847 100644 --- a/src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java +++ b/src/main/java/vectorwing/farmersdelight/crafting/ingredients/ToolIngredient.java @@ -11,6 +11,7 @@ import net.minecraftforge.common.crafting.IIngredientSerializer; import net.minecraftforge.registries.ForgeRegistries; +import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; @ParametersAreNonnullByDefault @@ -29,6 +30,11 @@ public ToolIngredient(ToolType toolType) { this.toolType = toolType; } + @Override + public boolean test(@Nullable ItemStack stack) { + return stack != null && stack.getToolTypes().contains(toolType) || super.test(stack); + } + @Override public JsonElement serialize() { JsonObject json = new JsonObject();