diff --git a/build.gradle b/build.gradle index 511d95c..06fbf2c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.0-SNAPSHOT' + id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' } @@ -48,8 +48,7 @@ processResources { } tasks.withType(JavaCompile).configureEach { - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. - it.options.release = 17 + it.options.release = 21 } java { @@ -91,7 +90,7 @@ loom { name "Data Generation" vmArg "-Dfabric-api.datagen" vmArg "-Dfabric-api.datagen.output-dir=${file("src/main/generated")}" - vmArg "-Dfabric-api.datagen.modid=${mod_id}" + vmArg "-Dfabric-api.datagen.modid=${archives_base_name}" runDir "build/datagen" } diff --git a/gradle.properties b/gradle.properties index 8242f20..1cc16ed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,16 +4,15 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.10 -loader_version=0.15.3 +minecraft_version=1.20.6 +yarn_mappings=1.20.6+build.1 +loader_version=0.15.11 # Mod Properties -mod_version=1.0.5 -mod_id="caffeinated" -maven_group=com.chikoritalover +mod_version=1.0.6 +maven_group=net.chikorita_lover.caffeinated archives_base_name=caffeinated # Dependencies -fabric_version=0.91.0+1.20.1 +fabric_version=0.98.0+1.20.6 farmersdelight_version=4640640 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f398c33..509c4a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/generated/.cache/23ea077d1d6c303dee4db4b707eb3883dc4bc6bb b/src/main/generated/.cache/23ea077d1d6c303dee4db4b707eb3883dc4bc6bb new file mode 100644 index 0000000..d460a7c --- /dev/null +++ b/src/main/generated/.cache/23ea077d1d6c303dee4db4b707eb3883dc4bc6bb @@ -0,0 +1,8 @@ +// 1.20.6 2024-05-09T17:09:50.125139 Caffeinated/Block Loot Tables +d481f7802dfc0e83cd271518b47e73b256a24d2f data\caffeinated\loot_tables\blocks\flowering_coffee_shrub.json +548d115eeb79b74d3fbe03951bdc179110ed6f8a data\caffeinated\loot_tables\blocks\coffee_cauldron.json +548d115eeb79b74d3fbe03951bdc179110ed6f8a data\caffeinated\loot_tables\blocks\ground_coffee_cauldron.json +3bec24cd54986eea9c228540df648ca7b01c86fc data\caffeinated\loot_tables\blocks\coffee_bean_block.json +2181144c1ab146492f9cae41e26a4ad585b0c46b data\caffeinated\loot_tables\blocks\ground_coffee_block.json +8b8e67a4f2fbd3f51a69d1359cceb2704429f4c3 data\caffeinated\loot_tables\blocks\coffee_berry_crate.json +c3b830bd1a84007839d42eaa7ecafef75a366d62 data\caffeinated\loot_tables\blocks\potted_coffee_shrub.json diff --git a/src/main/generated/.cache/c189bb4c92920ea572e0709157481155fe15e5dc b/src/main/generated/.cache/c189bb4c92920ea572e0709157481155fe15e5dc index 0820a58..2163081 100644 --- a/src/main/generated/.cache/c189bb4c92920ea572e0709157481155fe15e5dc +++ b/src/main/generated/.cache/c189bb4c92920ea572e0709157481155fe15e5dc @@ -1,19 +1,21 @@ -// 1.20.1 2024-01-06T12:11:53.8042848 Caffeinated/Recipes -e154bc568fca23d856835d0e300a33c5e3c1fcd5 data\caffeinated\advancements\recipes\misc\coffee_beans_from_block.json -2b1061f72b3e9a1295c9aa4334d37c9dcb3dfc53 data\caffeinated\advancements\recipes\misc\java_banner_pattern.json -76a46edddf4e31119b24a67f63988b18a8aee17f data\caffeinated\recipes\ground_coffee_block.json -187961e40d0322c1b7b655376bfe28d0b99ec8bd data\caffeinated\advancements\recipes\misc\ground_coffee_from_block.json -06c7edbdec5cf1deb92d8e421279587f14aaab54 data\caffeinated\advancements\recipes\food\tiramisu.json -aff0b344beb7238820d9ef40b8eeae0b6ee96bb9 data\caffeinated\recipes\coffee_beans_from_block.json -4c85433379ef206f984248f2181f8f0d58e04302 data\caffeinated\recipes\coffee_beans_from_coffee_berries.json -6b9902befd959eb3bc01bca55faa32da5902eaeb data\caffeinated\recipes\tiramisu.json -195cc52740e219af6b8b65dde7d9ef8d0768d307 data\caffeinated\advancements\recipes\misc\coffee_beans_from_coffee_berries.json -d34b1b5cba65cbe93df946e3a6badee9edc69dc0 data\caffeinated\recipes\coffee_berries.json -7872d0d8329ad57778754a3bb074ae65f2fe2990 data\caffeinated\recipes\coffee_bean_block.json -743816fab7585e00cd7f2678713589c48bdc2aed data\caffeinated\recipes\ground_coffee_from_block.json -55a0f263de5782dd9ec9aecd1d1ae815e3760bdb data\caffeinated\advancements\recipes\building_blocks\ground_coffee_block.json -d466ced2e8e679a807bdbcee307e0eb5e6547942 data\caffeinated\recipes\java_banner_pattern.json -bb529f25b75b190a9da8518d7a0931d22cbaf194 data\caffeinated\advancements\recipes\building_blocks\coffee_bean_block.json -9d1c02e4b749346060e0aca83030e22690aed245 data\caffeinated\recipes\ground_coffee_from_coffee_beans.json -c25fb492ba07b4ed02e133e2329fe9f0b00a2b5e data\caffeinated\advancements\recipes\misc\ground_coffee_from_coffee_beans.json -7ac9428c1c4810e6e439997467b8c5afad1711b9 data\caffeinated\advancements\recipes\food\coffee_berries.json +// 1.20.6 2024-05-09T17:09:50.125139 Caffeinated/Recipes +de06447040bc87e767e2afd307bdf559a780865a data\caffeinated\advancements\recipes\misc\coffee_beans_from_block.json +ea5881f924bd7cef6e6da660f1fd92cdf3e2584a data\caffeinated\advancements\recipes\misc\java_banner_pattern.json +502b882af91d38778cbf774342f9a865f9420474 data\caffeinated\recipes\ground_coffee_block.json +c7380b07538b219d6c28d1ab96ed76850e2bf79c data\caffeinated\advancements\recipes\misc\ground_coffee_from_block.json +28fbe891feaa35e46b5015bbcd4693e28b79ab4c data\caffeinated\advancements\recipes\food\tiramisu.json +5fd485c95e8541afbd5c36cbb898fc212dab1049 data\caffeinated\recipes\coffee_beans_from_block.json +32683e175792178cf8a7630890b33f7327dc0f3e data\caffeinated\recipes\coffee_beans_from_coffee_berries.json +c53cb3ecd5aefc2402fa20a47249530bfe406917 data\caffeinated\advancements\recipes\misc\coffee_beans_from_coffee_berries.json +f241d014283983a15799cf435d7be5c883b1f112 data\caffeinated\recipes\tiramisu.json +31f69cf23ef6a168c6d98a8fef731d470bcbb187 data\caffeinated\recipes\coffee_berries.json +bc56b1de573d33d57411984e3b1a021270bb9719 data\caffeinated\recipes\coffee_berry_crate.json +716ff4f0b5a0c7cba8f79624ca38943fa61f0dbe data\caffeinated\recipes\coffee_bean_block.json +f1258bcc7fbf71701ecbdce075c9ac0d21afab91 data\caffeinated\advancements\recipes\decorations\coffee_berry_crate.json +97e68d175c7717e19fbfce0ae98005eecb936cdf data\caffeinated\recipes\ground_coffee_from_block.json +51cbbbc43481615db699ce0878398bb475466f96 data\caffeinated\advancements\recipes\building_blocks\ground_coffee_block.json +e6061a3a68f93067a4057874be4ca45d0c759b01 data\caffeinated\recipes\java_banner_pattern.json +b8e94b6ab3e5b643e335a6036992426d7e3ed11c data\caffeinated\advancements\recipes\building_blocks\coffee_bean_block.json +081e951942029c81b7edec2c02074e4b47d00d3d data\caffeinated\recipes\ground_coffee_from_coffee_beans.json +9e061efc3626a119413e61ca86a53990ab4f8a8a data\caffeinated\advancements\recipes\misc\ground_coffee_from_coffee_beans.json +d9e05f57073c3e404c58a204f07503f392f4d2fe data\caffeinated\advancements\recipes\food\coffee_berries.json diff --git a/src/main/generated/.cache/f97ece2f3a543d4dbc8c984a7bcdf2d64b8f7bed b/src/main/generated/.cache/f97ece2f3a543d4dbc8c984a7bcdf2d64b8f7bed index 20d06db..c11137e 100644 --- a/src/main/generated/.cache/f97ece2f3a543d4dbc8c984a7bcdf2d64b8f7bed +++ b/src/main/generated/.cache/f97ece2f3a543d4dbc8c984a7bcdf2d64b8f7bed @@ -1,4 +1,4 @@ -// 1.20.1 2024-01-06T12:11:53.8005201 Caffeinated/Model Definitions +// 1.20.6 2024-05-09T17:09:50.1219453 Caffeinated/Model Definitions da4528a3cfafc1ab21e5814b64029c10ec357178 assets\caffeinated\blockstates\ground_coffee_block.json 26f35f3a03b0d53578efd2c555721b08353d75f0 assets\caffeinated\blockstates\coffee_cauldron.json b1a481861132973fe035c9b9ce7613e15938034c assets\caffeinated\models\block\coffee_berry_crate.json diff --git a/src/main/generated/data/caffeinated/advancements/recipes/building_blocks/coffee_bean_block.json b/src/main/generated/data/caffeinated/advancements/recipes/building_blocks/coffee_bean_block.json index e8ffe36..856f0cf 100644 --- a/src/main/generated/data/caffeinated/advancements/recipes/building_blocks/coffee_bean_block.json +++ b/src/main/generated/data/caffeinated/advancements/recipes/building_blocks/coffee_bean_block.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "caffeinated:coffee_beans" - ] + "items": "caffeinated:coffee_beans" } ] }, @@ -22,14 +20,13 @@ }, "requirements": [ [ - "has_coffee_beans", - "has_the_recipe" + "has_the_recipe", + "has_coffee_beans" ] ], "rewards": { "recipes": [ "caffeinated:coffee_bean_block" ] - }, - "sends_telemetry_event": false + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/advancements/recipes/building_blocks/ground_coffee_block.json b/src/main/generated/data/caffeinated/advancements/recipes/building_blocks/ground_coffee_block.json index 7b40a74..cea3c84 100644 --- a/src/main/generated/data/caffeinated/advancements/recipes/building_blocks/ground_coffee_block.json +++ b/src/main/generated/data/caffeinated/advancements/recipes/building_blocks/ground_coffee_block.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "caffeinated:ground_coffee" - ] + "items": "caffeinated:ground_coffee" } ] }, @@ -22,14 +20,13 @@ }, "requirements": [ [ - "has_ground_coffee", - "has_the_recipe" + "has_the_recipe", + "has_ground_coffee" ] ], "rewards": { "recipes": [ "caffeinated:ground_coffee_block" ] - }, - "sends_telemetry_event": false + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/advancements/recipes/decorations/coffee_berry_crate.json b/src/main/generated/data/caffeinated/advancements/recipes/decorations/coffee_berry_crate.json new file mode 100644 index 0000000..f270a75 --- /dev/null +++ b/src/main/generated/data/caffeinated/advancements/recipes/decorations/coffee_berry_crate.json @@ -0,0 +1,40 @@ +{ + "fabric:load_conditions": [ + { + "condition": "fabric:all_mods_loaded", + "values": [ + "farmersdelight" + ] + } + ], + "parent": "minecraft:recipes/root", + "criteria": { + "has_coffee_berries": { + "conditions": { + "items": [ + { + "items": "caffeinated:coffee_berries" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "minecraft:coffee_berry_crate" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_coffee_berries" + ] + ], + "rewards": { + "recipes": [ + "minecraft:coffee_berry_crate" + ] + } +} \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/advancements/recipes/food/coffee_berries.json b/src/main/generated/data/caffeinated/advancements/recipes/food/coffee_berries.json index 8ae15c9..5648f3b 100644 --- a/src/main/generated/data/caffeinated/advancements/recipes/food/coffee_berries.json +++ b/src/main/generated/data/caffeinated/advancements/recipes/food/coffee_berries.json @@ -1,13 +1,19 @@ { + "fabric:load_conditions": [ + { + "condition": "fabric:all_mods_loaded", + "values": [ + "farmersdelight" + ] + } + ], "parent": "minecraft:recipes/root", "criteria": { "has_coffee_berry_crate": { "conditions": { "items": [ { - "items": [ - "caffeinated:coffee_berry_crate" - ] + "items": "caffeinated:coffee_berry_crate" } ] }, @@ -15,21 +21,20 @@ }, "has_the_recipe": { "conditions": { - "recipe": "caffeinated:coffee_berries" + "recipe": "minecraft:coffee_berries" }, "trigger": "minecraft:recipe_unlocked" } }, "requirements": [ [ - "has_coffee_berry_crate", - "has_the_recipe" + "has_the_recipe", + "has_coffee_berry_crate" ] ], "rewards": { "recipes": [ - "caffeinated:coffee_berries" + "minecraft:coffee_berries" ] - }, - "sends_telemetry_event": false + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/advancements/recipes/food/tiramisu.json b/src/main/generated/data/caffeinated/advancements/recipes/food/tiramisu.json index c8d69dc..65f29e5 100644 --- a/src/main/generated/data/caffeinated/advancements/recipes/food/tiramisu.json +++ b/src/main/generated/data/caffeinated/advancements/recipes/food/tiramisu.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "caffeinated:coffee_bottle" - ] + "items": "caffeinated:coffee_bottle" } ] }, @@ -22,14 +20,13 @@ }, "requirements": [ [ - "has_coffee_bottle", - "has_the_recipe" + "has_the_recipe", + "has_coffee_bottle" ] ], "rewards": { "recipes": [ "caffeinated:tiramisu" ] - }, - "sends_telemetry_event": false + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/advancements/recipes/misc/coffee_beans_from_block.json b/src/main/generated/data/caffeinated/advancements/recipes/misc/coffee_beans_from_block.json index ab351ad..c0d94f5 100644 --- a/src/main/generated/data/caffeinated/advancements/recipes/misc/coffee_beans_from_block.json +++ b/src/main/generated/data/caffeinated/advancements/recipes/misc/coffee_beans_from_block.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "caffeinated:coffee_bean_block" - ] + "items": "caffeinated:coffee_bean_block" } ] }, @@ -22,14 +20,13 @@ }, "requirements": [ [ - "has_coffee_bean_block", - "has_the_recipe" + "has_the_recipe", + "has_coffee_bean_block" ] ], "rewards": { "recipes": [ "caffeinated:coffee_beans_from_block" ] - }, - "sends_telemetry_event": false + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/advancements/recipes/misc/coffee_beans_from_coffee_berries.json b/src/main/generated/data/caffeinated/advancements/recipes/misc/coffee_beans_from_coffee_berries.json index 8fb4579..68ea25e 100644 --- a/src/main/generated/data/caffeinated/advancements/recipes/misc/coffee_beans_from_coffee_berries.json +++ b/src/main/generated/data/caffeinated/advancements/recipes/misc/coffee_beans_from_coffee_berries.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "caffeinated:coffee_berries" - ] + "items": "caffeinated:coffee_berries" } ] }, @@ -22,14 +20,13 @@ }, "requirements": [ [ - "has_coffee_berries", - "has_the_recipe" + "has_the_recipe", + "has_coffee_berries" ] ], "rewards": { "recipes": [ "caffeinated:coffee_beans_from_coffee_berries" ] - }, - "sends_telemetry_event": false + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/advancements/recipes/misc/ground_coffee_from_block.json b/src/main/generated/data/caffeinated/advancements/recipes/misc/ground_coffee_from_block.json index 68621e9..b5914cd 100644 --- a/src/main/generated/data/caffeinated/advancements/recipes/misc/ground_coffee_from_block.json +++ b/src/main/generated/data/caffeinated/advancements/recipes/misc/ground_coffee_from_block.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "caffeinated:ground_coffee_block" - ] + "items": "caffeinated:ground_coffee_block" } ] }, @@ -22,14 +20,13 @@ }, "requirements": [ [ - "has_ground_coffee_block", - "has_the_recipe" + "has_the_recipe", + "has_ground_coffee_block" ] ], "rewards": { "recipes": [ "caffeinated:ground_coffee_from_block" ] - }, - "sends_telemetry_event": false + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/advancements/recipes/misc/ground_coffee_from_coffee_beans.json b/src/main/generated/data/caffeinated/advancements/recipes/misc/ground_coffee_from_coffee_beans.json index 64ac49e..13d1d70 100644 --- a/src/main/generated/data/caffeinated/advancements/recipes/misc/ground_coffee_from_coffee_beans.json +++ b/src/main/generated/data/caffeinated/advancements/recipes/misc/ground_coffee_from_coffee_beans.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "caffeinated:coffee_beans" - ] + "items": "caffeinated:coffee_beans" } ] }, @@ -22,14 +20,13 @@ }, "requirements": [ [ - "has_coffee_beans", - "has_the_recipe" + "has_the_recipe", + "has_coffee_beans" ] ], "rewards": { "recipes": [ "caffeinated:ground_coffee_from_coffee_beans" ] - }, - "sends_telemetry_event": false + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/advancements/recipes/misc/java_banner_pattern.json b/src/main/generated/data/caffeinated/advancements/recipes/misc/java_banner_pattern.json index 890ed4c..d7051b0 100644 --- a/src/main/generated/data/caffeinated/advancements/recipes/misc/java_banner_pattern.json +++ b/src/main/generated/data/caffeinated/advancements/recipes/misc/java_banner_pattern.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "caffeinated:coffee_bottle" - ] + "items": "caffeinated:coffee_bottle" } ] }, @@ -22,14 +20,13 @@ }, "requirements": [ [ - "has_coffee_bottle", - "has_the_recipe" + "has_the_recipe", + "has_coffee_bottle" ] ], "rewards": { "recipes": [ "caffeinated:java_banner_pattern" ] - }, - "sends_telemetry_event": false + } } \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/loot_tables/blocks/coffee_bean_block.json b/src/main/generated/data/caffeinated/loot_tables/blocks/coffee_bean_block.json similarity index 84% rename from src/main/resources/data/caffeinated/loot_tables/blocks/coffee_bean_block.json rename to src/main/generated/data/caffeinated/loot_tables/blocks/coffee_bean_block.json index e0919bc..30bf11a 100644 --- a/src/main/resources/data/caffeinated/loot_tables/blocks/coffee_bean_block.json +++ b/src/main/generated/data/caffeinated/loot_tables/blocks/coffee_bean_block.json @@ -2,19 +2,19 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, - "bonus_rolls": 0, + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], "entries": [ { "type": "minecraft:item", "name": "caffeinated:coffee_bean_block" } ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] + "rolls": 1.0 } ] } \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/loot_tables/blocks/coffee_berry_crate.json b/src/main/generated/data/caffeinated/loot_tables/blocks/coffee_berry_crate.json similarity index 84% rename from src/main/resources/data/caffeinated/loot_tables/blocks/coffee_berry_crate.json rename to src/main/generated/data/caffeinated/loot_tables/blocks/coffee_berry_crate.json index ae13cac..a76344e 100644 --- a/src/main/resources/data/caffeinated/loot_tables/blocks/coffee_berry_crate.json +++ b/src/main/generated/data/caffeinated/loot_tables/blocks/coffee_berry_crate.json @@ -2,19 +2,19 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, - "bonus_rolls": 0, + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], "entries": [ { "type": "minecraft:item", "name": "caffeinated:coffee_berry_crate" } ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] + "rolls": 1.0 } ] } \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/loot_tables/blocks/coffee_cauldron.json b/src/main/generated/data/caffeinated/loot_tables/blocks/coffee_cauldron.json similarity index 83% rename from src/main/resources/data/caffeinated/loot_tables/blocks/coffee_cauldron.json rename to src/main/generated/data/caffeinated/loot_tables/blocks/coffee_cauldron.json index 01f46cb..68a7312 100644 --- a/src/main/resources/data/caffeinated/loot_tables/blocks/coffee_cauldron.json +++ b/src/main/generated/data/caffeinated/loot_tables/blocks/coffee_cauldron.json @@ -2,19 +2,19 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, - "bonus_rolls": 0, + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], "entries": [ { "type": "minecraft:item", "name": "minecraft:cauldron" } ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] + "rolls": 1.0 } ] } \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/loot_tables/blocks/flowering_coffee_shrub.json b/src/main/generated/data/caffeinated/loot_tables/blocks/flowering_coffee_shrub.json similarity index 83% rename from src/main/resources/data/caffeinated/loot_tables/blocks/flowering_coffee_shrub.json rename to src/main/generated/data/caffeinated/loot_tables/blocks/flowering_coffee_shrub.json index de1da2a..6269abc 100644 --- a/src/main/resources/data/caffeinated/loot_tables/blocks/flowering_coffee_shrub.json +++ b/src/main/generated/data/caffeinated/loot_tables/blocks/flowering_coffee_shrub.json @@ -1,9 +1,23 @@ { "type": "minecraft:block", + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], "pools": [ { - "rolls": 1, - "bonus_rolls": 0, + "bonus_rolls": 0.0, + "conditions": [ + { + "block": "caffeinated:flowering_coffee_shrub", + "condition": "minecraft:block_state_property", + "properties": { + "age": "3", + "half": "lower" + } + } + ], "entries": [ { "type": "minecraft:item", @@ -12,38 +26,24 @@ ], "functions": [ { - "function": "minecraft:set_count", + "add": false, "count": { "type": "minecraft:uniform", - "min": 1, - "max": 3 + "max": 3.0, + "min": 1.0 }, - "add": false + "function": "minecraft:set_count" }, { - "function": "minecraft:apply_bonus", "enchantment": "minecraft:fortune", "formula": "minecraft:uniform_bonus_count", + "function": "minecraft:apply_bonus", "parameters": { "bonusMultiplier": 1 } } ], - "conditions": [ - { - "condition": "minecraft:block_state_property", - "block": "caffeinated:flowering_coffee_shrub", - "properties": { - "age": "3", - "half": "lower" - } - } - ] - } - ], - "functions": [ - { - "function": "minecraft:explosion_decay" + "rolls": 1.0 } ] } \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/loot_tables/blocks/ground_coffee_block.json b/src/main/generated/data/caffeinated/loot_tables/blocks/ground_coffee_block.json similarity index 84% rename from src/main/resources/data/caffeinated/loot_tables/blocks/ground_coffee_block.json rename to src/main/generated/data/caffeinated/loot_tables/blocks/ground_coffee_block.json index e4d14d5..9f0f174 100644 --- a/src/main/resources/data/caffeinated/loot_tables/blocks/ground_coffee_block.json +++ b/src/main/generated/data/caffeinated/loot_tables/blocks/ground_coffee_block.json @@ -2,19 +2,19 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, - "bonus_rolls": 0, + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], "entries": [ { "type": "minecraft:item", "name": "caffeinated:ground_coffee_block" } ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] + "rolls": 1.0 } ] } \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/loot_tables/blocks/ground_coffee_cauldron.json b/src/main/generated/data/caffeinated/loot_tables/blocks/ground_coffee_cauldron.json similarity index 83% rename from src/main/resources/data/caffeinated/loot_tables/blocks/ground_coffee_cauldron.json rename to src/main/generated/data/caffeinated/loot_tables/blocks/ground_coffee_cauldron.json index 01f46cb..68a7312 100644 --- a/src/main/resources/data/caffeinated/loot_tables/blocks/ground_coffee_cauldron.json +++ b/src/main/generated/data/caffeinated/loot_tables/blocks/ground_coffee_cauldron.json @@ -2,19 +2,19 @@ "type": "minecraft:block", "pools": [ { - "rolls": 1, - "bonus_rolls": 0, + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], "entries": [ { "type": "minecraft:item", "name": "minecraft:cauldron" } ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] + "rolls": 1.0 } ] } \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/loot_tables/blocks/potted_coffee_shrub.json b/src/main/generated/data/caffeinated/loot_tables/blocks/potted_coffee_shrub.json similarity index 100% rename from src/main/resources/data/caffeinated/loot_tables/blocks/potted_coffee_shrub.json rename to src/main/generated/data/caffeinated/loot_tables/blocks/potted_coffee_shrub.json diff --git a/src/main/generated/data/caffeinated/recipes/coffee_bean_block.json b/src/main/generated/data/caffeinated/recipes/coffee_bean_block.json index 9e92bb0..e304566 100644 --- a/src/main/generated/data/caffeinated/recipes/coffee_bean_block.json +++ b/src/main/generated/data/caffeinated/recipes/coffee_bean_block.json @@ -12,7 +12,7 @@ "###" ], "result": { - "item": "caffeinated:coffee_bean_block" - }, - "show_notification": true + "count": 1, + "id": "caffeinated:coffee_bean_block" + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/recipes/coffee_beans_from_block.json b/src/main/generated/data/caffeinated/recipes/coffee_beans_from_block.json index 4213d2e..0a5fd0b 100644 --- a/src/main/generated/data/caffeinated/recipes/coffee_beans_from_block.json +++ b/src/main/generated/data/caffeinated/recipes/coffee_beans_from_block.json @@ -9,6 +9,6 @@ ], "result": { "count": 9, - "item": "caffeinated:coffee_beans" + "id": "caffeinated:coffee_beans" } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/recipes/coffee_beans_from_coffee_berries.json b/src/main/generated/data/caffeinated/recipes/coffee_beans_from_coffee_berries.json index 3862d9e..839b43a 100644 --- a/src/main/generated/data/caffeinated/recipes/coffee_beans_from_coffee_berries.json +++ b/src/main/generated/data/caffeinated/recipes/coffee_beans_from_coffee_berries.json @@ -8,6 +8,7 @@ } ], "result": { - "item": "caffeinated:coffee_beans" + "count": 1, + "id": "caffeinated:coffee_beans" } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/recipes/coffee_berries.json b/src/main/generated/data/caffeinated/recipes/coffee_berries.json index 6338c40..1dd2f32 100644 --- a/src/main/generated/data/caffeinated/recipes/coffee_berries.json +++ b/src/main/generated/data/caffeinated/recipes/coffee_berries.json @@ -1,4 +1,12 @@ { + "fabric:load_conditions": [ + { + "condition": "fabric:all_mods_loaded", + "values": [ + "farmersdelight" + ] + } + ], "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ @@ -8,6 +16,6 @@ ], "result": { "count": 9, - "item": "caffeinated:coffee_berries" + "id": "caffeinated:coffee_berries" } } \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/recipes/coffee_berry_crate.json b/src/main/generated/data/caffeinated/recipes/coffee_berry_crate.json similarity index 67% rename from src/main/resources/data/caffeinated/recipes/coffee_berry_crate.json rename to src/main/generated/data/caffeinated/recipes/coffee_berry_crate.json index 5681a79..28adc52 100644 --- a/src/main/resources/data/caffeinated/recipes/coffee_berry_crate.json +++ b/src/main/generated/data/caffeinated/recipes/coffee_berry_crate.json @@ -1,24 +1,26 @@ { - "type": "minecraft:crafting_shaped", - "pattern": [ - "###", - "###", - "###" + "fabric:load_conditions": [ + { + "condition": "fabric:all_mods_loaded", + "values": [ + "farmersdelight" + ] + } ], + "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "item": "caffeinated:coffee_berries" } }, + "pattern": [ + "###", + "###", + "###" + ], "result": { - "item": "caffeinated:coffee_berry_crate" - }, - "fabric:load_conditions": [ - { - "condition": "fabric:any_mod_loaded", - "values": [ - "farmersdelight" - ] - } - ] + "count": 1, + "id": "caffeinated:coffee_berry_crate" + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/recipes/ground_coffee_block.json b/src/main/generated/data/caffeinated/recipes/ground_coffee_block.json index daba738..af9d633 100644 --- a/src/main/generated/data/caffeinated/recipes/ground_coffee_block.json +++ b/src/main/generated/data/caffeinated/recipes/ground_coffee_block.json @@ -12,7 +12,7 @@ "###" ], "result": { - "item": "caffeinated:ground_coffee_block" - }, - "show_notification": true + "count": 1, + "id": "caffeinated:ground_coffee_block" + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/recipes/ground_coffee_from_block.json b/src/main/generated/data/caffeinated/recipes/ground_coffee_from_block.json index cebedfc..0877611 100644 --- a/src/main/generated/data/caffeinated/recipes/ground_coffee_from_block.json +++ b/src/main/generated/data/caffeinated/recipes/ground_coffee_from_block.json @@ -9,6 +9,6 @@ ], "result": { "count": 9, - "item": "caffeinated:ground_coffee" + "id": "caffeinated:ground_coffee" } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/recipes/ground_coffee_from_coffee_beans.json b/src/main/generated/data/caffeinated/recipes/ground_coffee_from_coffee_beans.json index f1ea7ae..02d497e 100644 --- a/src/main/generated/data/caffeinated/recipes/ground_coffee_from_coffee_beans.json +++ b/src/main/generated/data/caffeinated/recipes/ground_coffee_from_coffee_beans.json @@ -11,7 +11,7 @@ "###" ], "result": { - "item": "caffeinated:ground_coffee" - }, - "show_notification": true + "count": 1, + "id": "caffeinated:ground_coffee" + } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/recipes/java_banner_pattern.json b/src/main/generated/data/caffeinated/recipes/java_banner_pattern.json index 1bf683b..45de76d 100644 --- a/src/main/generated/data/caffeinated/recipes/java_banner_pattern.json +++ b/src/main/generated/data/caffeinated/recipes/java_banner_pattern.json @@ -10,6 +10,7 @@ } ], "result": { - "item": "caffeinated:java_banner_pattern" + "count": 1, + "id": "caffeinated:java_banner_pattern" } } \ No newline at end of file diff --git a/src/main/generated/data/caffeinated/recipes/tiramisu.json b/src/main/generated/data/caffeinated/recipes/tiramisu.json index 0b83e52..12f8df7 100644 --- a/src/main/generated/data/caffeinated/recipes/tiramisu.json +++ b/src/main/generated/data/caffeinated/recipes/tiramisu.json @@ -26,7 +26,6 @@ ], "result": { "count": 2, - "item": "caffeinated:tiramisu" - }, - "show_notification": true + "id": "caffeinated:tiramisu" + } } \ No newline at end of file diff --git a/src/main/java/com/chikoritalover/caffeinated/Caffeinated.java b/src/main/java/com/chikoritalover/caffeinated/Caffeinated.java deleted file mode 100644 index fd1a9d1..0000000 --- a/src/main/java/com/chikoritalover/caffeinated/Caffeinated.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.chikoritalover.caffeinated; - -import com.chikoritalover.caffeinated.registry.*; -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.loot.v2.LootTableEvents; -import net.minecraft.item.ItemConvertible; -import net.minecraft.loot.LootPool; -import net.minecraft.loot.LootTables; -import net.minecraft.loot.condition.LootCondition; -import net.minecraft.loot.condition.RandomChanceLootCondition; -import net.minecraft.loot.entry.ItemEntry; -import net.minecraft.loot.provider.number.UniformLootNumberProvider; -import net.minecraft.registry.Registries; -import net.minecraft.util.Identifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Caffeinated implements ModInitializer { - // This logger is used to write text to the console and the log file. - // It is considered best practice to use your mod id as the logger's name. - // That way, it's clear which mod wrote info, warnings, and errors. - public static final String MODID = "caffeinated"; - public static final Logger LOGGER = LoggerFactory.getLogger("modid"); - - @Override - public void onInitialize() { - CaffeinatedBannerPatterns.initAndGetDefault(Registries.BANNER_PATTERN); - CaffeinatedBlocks.register(); - CaffeinatedCauldronBehavior.register(); - CaffeinatedItems.register(); - CaffeinatedParticleTypes.register(); - CaffeinatedPlacedFeatures.register(); - CaffeinatedSoundEvents.register(); - CaffeinatedStats.register(); - CaffeinatedStatusEffects.register(); - CaffeinatedTradeOffers.register(); - CaffeinatedBlockSoundGroup.register(); - CaffeinatedEntityTypeTags.register(); - CaffeinatedBlockTags.register(); - CaffeinatedItemTags.register(); - CaffeinatedBannerPatternTags.register(); - CaffeinatedBannerPatterns.register(); - - registerLootTableEvents(); - } - - public void registerLootTableEvents() { - addLootTablePool(1, 1, 0.5F, LootTables.JUNGLE_TEMPLE_CHEST, CaffeinatedItems.COFFEE_BEANS, 1, 3); - } - - private void addLootTablePool(int minRolls, int maxRolls, float chance, Identifier lootTable, ItemConvertible item) { - addLootTablePool(minRolls, maxRolls, chance, lootTable, item, 1, 1); - } - - private void addLootTablePool(int minRolls, int maxRolls, float chance, Identifier lootTable, ItemConvertible item, int minCount, int maxCount) { - UniformLootNumberProvider lootTableRange = UniformLootNumberProvider.create(minRolls, maxRolls); - LootCondition condition = RandomChanceLootCondition.builder(chance).build(); - LootTableEvents.MODIFY.register((resourceManager, lootManager, id, supplier, setter) -> { - if (lootTable.equals(id)) { - LootPool lootPool = LootPool.builder() - .rolls(lootTableRange) - .conditionally(condition) - .with(ItemEntry.builder(item).build()).build(); - - supplier.pool(lootPool); - } - }); - } -} diff --git a/src/main/java/com/chikoritalover/caffeinated/block/FloweringCoffeeShrubBlock.java b/src/main/java/com/chikoritalover/caffeinated/block/FloweringCoffeeShrubBlock.java deleted file mode 100644 index 7ec0a90..0000000 --- a/src/main/java/com/chikoritalover/caffeinated/block/FloweringCoffeeShrubBlock.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.chikoritalover.caffeinated.block; - -import com.chikoritalover.caffeinated.registry.CaffeinatedItems; -import com.chikoritalover.caffeinated.registry.CaffeinatedSoundEvents; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Fertilizable; -import net.minecraft.block.TallPlantBlock; -import net.minecraft.block.enums.DoubleBlockHalf; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundCategory; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldView; -import net.minecraft.world.event.GameEvent; - -public class FloweringCoffeeShrubBlock extends TallPlantBlock implements Fertilizable { - public static final int MAX_AGE = 3; - public static final IntProperty AGE = Properties.AGE_3; - - public FloweringCoffeeShrubBlock(Settings settings) { - super(settings); - } - - public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { - return new ItemStack(CaffeinatedItems.COFFEE_BEANS); - } - - public boolean hasRandomTicks(BlockState state) { - return state.get(HALF) == DoubleBlockHalf.LOWER && state.get(AGE) < MAX_AGE; - } - - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - int i = state.get(AGE); - if (i < MAX_AGE && random.nextInt(5) == 0 && world.getBaseLightLevel(pos.up(), 0) >= 9) { - this.grow(world, random, pos, state); - } - } - - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - int i = state.get(AGE); - if (i < MAX_AGE && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) { - return ActionResult.PASS; - } - if (i == MAX_AGE) { - int j = world.getRandom().nextInt(2) + 2; - dropStack(world, pos, new ItemStack(CaffeinatedItems.COFFEE_BERRIES, j)); - world.playSound(null, pos, CaffeinatedSoundEvents.BLOCK_COFFEE_SHRUB_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, 0.8F + world.getRandom().nextFloat() * 0.4F); - BlockState blockState = state.with(AGE, 0); - world.setBlockState(pos, blockState, Block.NOTIFY_LISTENERS); - world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(player, blockState)); - if (state.get(HALF) == DoubleBlockHalf.LOWER) { - world.setBlockState(pos.up(), blockState.cycle(HALF), Block.NOTIFY_LISTENERS); - world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos.up(), GameEvent.Emitter.of(player, blockState.cycle(HALF))); - } else { - world.setBlockState(pos.down(), blockState.cycle(HALF), Block.NOTIFY_LISTENERS); - world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos.down(), GameEvent.Emitter.of(player, blockState.cycle(HALF))); - } - return ActionResult.success(world.isClient); - } - return super.onUse(state, world, pos, player, hand, hit); - } - - @Override - protected void appendProperties(StateManager.Builder builder) { - builder.add(AGE); - super.appendProperties(builder); - } - - @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) { - return state.get(AGE) < MAX_AGE; - } - - @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { - if (state.get(HALF) == DoubleBlockHalf.UPPER) { - return this.canGrow(world, random, pos.down(), world.getBlockState(pos.down())); - } - return state.get(AGE) < MAX_AGE && this.canPlaceAt(state, world, pos); - } - - @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - if (!this.canGrow(world, random, pos, state)) { - return; - } - int i = Math.min(MAX_AGE, state.get(AGE) + 1); - world.setBlockState(pos, state.with(AGE, i), Block.NOTIFY_LISTENERS); - if (state.get(HALF) == DoubleBlockHalf.LOWER) { - world.setBlockState(pos.up(), state.with(AGE, i).cycle(HALF), Block.NOTIFY_ALL); - } else { - world.setBlockState(pos.down(), state.with(AGE, i).cycle(HALF), Block.NOTIFY_ALL); - } - } -} diff --git a/src/main/java/com/chikoritalover/caffeinated/mixin/PlayerEntityMixin.java b/src/main/java/com/chikoritalover/caffeinated/mixin/PlayerEntityMixin.java deleted file mode 100644 index 9d3438d..0000000 --- a/src/main/java/com/chikoritalover/caffeinated/mixin/PlayerEntityMixin.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.chikoritalover.caffeinated.mixin; - -import com.chikoritalover.caffeinated.registry.CaffeinatedStatusEffects; -import net.minecraft.entity.player.PlayerEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(PlayerEntity.class) -public class PlayerEntityMixin { - @Inject(method = "addExhaustion", at = @At(value = "HEAD"), cancellable = true) - private void addExhaustion(float exhaustion, CallbackInfo ci) { - PlayerEntity player = PlayerEntity.class.cast(this); - if (player.hasStatusEffect(CaffeinatedStatusEffects.CAFFEINE)) { - int amplifier = player.getStatusEffect(CaffeinatedStatusEffects.CAFFEINE).getAmplifier(); - if (player.getRandom().nextBetween(0, amplifier + 2) > 1) { - ci.cancel(); - } - } - } -} diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBannerPatterns.java b/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBannerPatterns.java deleted file mode 100644 index b37016a..0000000 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBannerPatterns.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.chikoritalover.caffeinated.registry; - -import com.chikoritalover.caffeinated.Caffeinated; -import net.minecraft.block.entity.BannerPattern; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.util.Identifier; - -public class CaffeinatedBannerPatterns { - public static final RegistryKey JAVA = of("java"); - - private static RegistryKey of(String id) { - return RegistryKey.of(RegistryKeys.BANNER_PATTERN, new Identifier(Caffeinated.MODID, id)); - } - - public static BannerPattern initAndGetDefault(Registry registry) { - return Registry.register(registry, JAVA, new BannerPattern("jav")); - } - - public static void register() { - } -} diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedCauldronBehavior.java b/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedCauldronBehavior.java deleted file mode 100644 index 0e7d438..0000000 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedCauldronBehavior.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.chikoritalover.caffeinated.registry; - -import com.chikoritalover.caffeinated.block.CoffeeCauldronBlock; -import net.minecraft.block.Blocks; -import net.minecraft.block.LeveledCauldronBlock; -import net.minecraft.block.cauldron.CauldronBehavior; -import net.minecraft.entity.ExperienceOrbEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUsage; -import net.minecraft.item.Items; -import net.minecraft.potion.PotionUtil; -import net.minecraft.potion.Potions; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.stat.Stats; -import net.minecraft.state.property.IntProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.ActionResult; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.event.GameEvent; - -import java.util.Map; - -public class CaffeinatedCauldronBehavior { - public static final Map COFFEE_CAULDRON_BEHAVIOR = CauldronBehavior.createMap(); - public static final Map GROUND_COFFEE_CAULDRON_BEHAVIOR = CauldronBehavior.createMap(); - - public static void register() { - CauldronBehavior.EMPTY_CAULDRON_BEHAVIOR.put(CaffeinatedItems.COFFEE_BOTTLE, (state, world, pos, player, hand, stack) -> { - if (stack.getItem() != CaffeinatedItems.COFFEE_BOTTLE) { - return ActionResult.PASS; - } else { - if (!world.isClient) { - Item item = stack.getItem(); - player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(Items.GLASS_BOTTLE))); - player.incrementStat(Stats.USE_CAULDRON); - player.incrementStat(Stats.USED.getOrCreateStat(item)); - world.setBlockState(pos, CaffeinatedBlocks.COFFEE_CAULDRON.getDefaultState()); - world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); - world.emitGameEvent(null, GameEvent.FLUID_PLACE, pos); - } - - return ActionResult.success(world.isClient); - } - }); - - CauldronBehavior.WATER_CAULDRON_BEHAVIOR.put(CaffeinatedItems.GROUND_COFFEE, (state, world, pos, player, hand, stack) -> { - if (stack.getItem() != CaffeinatedItems.GROUND_COFFEE) { - return ActionResult.PASS; - } else { - IntProperty level3 = Properties.LEVEL_3; - - if (!world.isClient) { - Item item = stack.getItem(); - player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(Blocks.AIR))); - player.incrementStat(Stats.USE_CAULDRON); - player.incrementStat(Stats.USED.getOrCreateStat(item)); - world.setBlockState(pos, CaffeinatedBlocks.GROUND_COFFEE_CAULDRON.getDefaultState().with(level3, state.get(level3))); - world.playSound(null, pos, CaffeinatedSoundEvents.ITEM_GROUND_COFFEE_SPLASH, SoundCategory.BLOCKS, 1.0F, 1.0F); - world.emitGameEvent(null, GameEvent.FLUID_PLACE, pos); - } - - return ActionResult.success(world.isClient); - } - }); - - COFFEE_CAULDRON_BEHAVIOR.put(Items.GLASS_BOTTLE, (state, world, pos, player, hand, stack) -> { - if (!world.isClient) { - Item item = stack.getItem(); - player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(CaffeinatedItems.COFFEE_BOTTLE))); - player.incrementStat(CaffeinatedStats.COFFEE_TAKEN); - player.incrementStat(Stats.USED.getOrCreateStat(item)); - LeveledCauldronBlock.decrementFluidLevel(state, world, pos); - world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - world.emitGameEvent(null, GameEvent.FLUID_PICKUP, pos); - if (state.get(CoffeeCauldronBlock.REWARD_EXPERIENCE)) { - state = world.getBlockState(pos); - ExperienceOrbEntity.spawn((ServerWorld) world, Vec3d.ofCenter(pos), world.getRandom().nextBetween(1, 3)); - world.setBlockState(pos, state.cycle(CoffeeCauldronBlock.REWARD_EXPERIENCE)); - } - } - - return ActionResult.success(world.isClient); - }); - COFFEE_CAULDRON_BEHAVIOR.put(CaffeinatedItems.COFFEE_BOTTLE, (state, world, pos, player, hand, stack) -> { - if (state.get(LeveledCauldronBlock.LEVEL) != 3 && stack.getItem() == CaffeinatedItems.COFFEE_BOTTLE) { - if (!world.isClient) { - player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(Items.GLASS_BOTTLE))); - player.incrementStat(Stats.USED.getOrCreateStat(stack.getItem())); - world.setBlockState(pos, state.cycle(LeveledCauldronBlock.LEVEL)); - world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); - world.emitGameEvent(null, GameEvent.FLUID_PLACE, pos); - } - - return ActionResult.success(world.isClient); - } else { - return ActionResult.PASS; - } - }); - - GROUND_COFFEE_CAULDRON_BEHAVIOR.put(Items.GLASS_BOTTLE, (state, world, pos, player, hand, stack) -> { - if (!world.isClient) { - Item item = stack.getItem(); - player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, PotionUtil.setPotion(new ItemStack(Items.POTION), Potions.WATER))); - player.incrementStat(Stats.USE_CAULDRON); - player.incrementStat(Stats.USED.getOrCreateStat(item)); - LeveledCauldronBlock.decrementFluidLevel(state, world, pos); - world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - world.emitGameEvent(null, GameEvent.FLUID_PICKUP, pos); - } - - return ActionResult.success(world.isClient); - }); - GROUND_COFFEE_CAULDRON_BEHAVIOR.put(Items.BUCKET, (state, world, pos, player, hand, stack) -> { - if (!world.isClient) { - Item item = stack.getItem(); - player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(Items.WATER_BUCKET))); - player.incrementStat(Stats.USE_CAULDRON); - player.incrementStat(Stats.USED.getOrCreateStat(item)); - world.setBlockState(pos, Blocks.CAULDRON.getDefaultState()); - world.playSound(null, pos, SoundEvents.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - world.emitGameEvent(null, GameEvent.FLUID_PICKUP, pos); - } - - return ActionResult.success(world.isClient); - }); - GROUND_COFFEE_CAULDRON_BEHAVIOR.put(Items.POTION, (state, world, pos, player, hand, stack) -> { - if (state.get(LeveledCauldronBlock.LEVEL) != 3 && PotionUtil.getPotion(stack) == Potions.WATER) { - if (!world.isClient) { - player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(Items.GLASS_BOTTLE))); - player.incrementStat(Stats.USE_CAULDRON); - player.incrementStat(Stats.USED.getOrCreateStat(stack.getItem())); - world.setBlockState(pos, state.cycle(LeveledCauldronBlock.LEVEL)); - world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); - world.emitGameEvent(null, GameEvent.FLUID_PLACE, pos); - } - - return ActionResult.success(world.isClient); - } else { - return ActionResult.PASS; - } - }); - } -} diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedFoodComponents.java b/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedFoodComponents.java deleted file mode 100644 index 80ade9d..0000000 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedFoodComponents.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.chikoritalover.caffeinated.registry; - -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.item.FoodComponent; - -public class CaffeinatedFoodComponents { - public static final FoodComponent COFFEE_BERRIES = (new FoodComponent.Builder()).hunger(2).saturationModifier(0.1F).build(); - public static final FoodComponent COFFEE_BOTTLE = (new FoodComponent.Builder()).hunger(2).saturationModifier(0.3F).statusEffect(new StatusEffectInstance(CaffeinatedStatusEffects.CAFFEINE, 3600, 0), 1.0F).build(); - public static final FoodComponent TIRAMISU = (new FoodComponent.Builder()).hunger(5).saturationModifier(0.6F).statusEffect(new StatusEffectInstance(CaffeinatedStatusEffects.CAFFEINE, 600, 1), 1.0F).build(); -} diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedStatusEffects.java b/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedStatusEffects.java deleted file mode 100644 index c019415..0000000 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedStatusEffects.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.chikoritalover.caffeinated.registry; - -import com.chikoritalover.caffeinated.Caffeinated; -import com.chikoritalover.caffeinated.entity.effect.CaffeineStatusEffect; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectCategory; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.util.Identifier; - -public class CaffeinatedStatusEffects { - public static final StatusEffect CAFFEINE = register("caffeine", StatusEffectCategory.BENEFICIAL, 4927777); - - private static StatusEffect register(String id, StatusEffectCategory category, int i){ - return Registry.register(Registries.STATUS_EFFECT, new Identifier(Caffeinated.MODID, id), new CaffeineStatusEffect(category, i)); - } - - public static void register() { - } -} diff --git a/src/main/java/net/chikorita_lover/caffeinated/Caffeinated.java b/src/main/java/net/chikorita_lover/caffeinated/Caffeinated.java new file mode 100644 index 0000000..2de3fbc --- /dev/null +++ b/src/main/java/net/chikorita_lover/caffeinated/Caffeinated.java @@ -0,0 +1,60 @@ +package net.chikorita_lover.caffeinated; + +import net.chikorita_lover.caffeinated.registry.*; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.loot.v2.LootTableEvents; +import net.minecraft.item.ItemConvertible; +import net.minecraft.loot.LootPool; +import net.minecraft.loot.LootTable; +import net.minecraft.loot.LootTables; +import net.minecraft.loot.condition.LootCondition; +import net.minecraft.loot.condition.RandomChanceLootCondition; +import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.loot.provider.number.UniformLootNumberProvider; +import net.minecraft.registry.RegistryKey; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Caffeinated implements ModInitializer { + public static final Logger LOGGER = LoggerFactory.getLogger("Caffeinated"); + public static final String MODID = "caffeinated"; + + @Override + public void onInitialize() { + CaffeinatedBlocks.register(); + CaffeinatedCauldronBehavior.register(); + CaffeinatedItems.register(); + CaffeinatedParticleTypes.register(); + CaffeinatedPlacedFeatures.register(); + CaffeinatedSoundEvents.register(); + CaffeinatedStats.register(); + CaffeinatedStatusEffects.register(); + CaffeinatedTradeOffers.register(); + CaffeinatedBlockSoundGroup.register(); + CaffeinatedEntityTypeTags.register(); + CaffeinatedBlockTags.register(); + CaffeinatedItemTags.register(); + CaffeinatedBannerPatternTags.register(); + + registerLootTableEvents(); + } + + public void registerLootTableEvents() { + addLootTablePool(1, 1, 0.5F, LootTables.JUNGLE_TEMPLE_CHEST, CaffeinatedItems.COFFEE_BEANS, 1, 3); + } + + private void addLootTablePool(int minRolls, int maxRolls, float chance, RegistryKey lootTable, ItemConvertible item, int minCount, int maxCount) { + UniformLootNumberProvider lootTableRange = UniformLootNumberProvider.create(minRolls, maxRolls); + LootCondition condition = RandomChanceLootCondition.builder(chance).build(); + LootTableEvents.MODIFY.register((key, builder, source) -> { + if (lootTable.equals(key)) { + LootPool lootPool = LootPool.builder() + .rolls(lootTableRange) + .conditionally(condition) + .with(ItemEntry.builder(item).build()).build(); + + builder.pool(lootPool); + } + }); + } +} diff --git a/src/main/java/com/chikoritalover/caffeinated/CaffeinatedClient.java b/src/main/java/net/chikorita_lover/caffeinated/CaffeinatedClient.java similarity index 82% rename from src/main/java/com/chikoritalover/caffeinated/CaffeinatedClient.java rename to src/main/java/net/chikorita_lover/caffeinated/CaffeinatedClient.java index a20c0fd..796369a 100644 --- a/src/main/java/com/chikoritalover/caffeinated/CaffeinatedClient.java +++ b/src/main/java/net/chikorita_lover/caffeinated/CaffeinatedClient.java @@ -1,7 +1,7 @@ -package com.chikoritalover.caffeinated; +package net.chikorita_lover.caffeinated; -import com.chikoritalover.caffeinated.registry.CaffeinatedBlocks; -import com.chikoritalover.caffeinated.registry.CaffeinatedParticleTypes; +import net.chikorita_lover.caffeinated.registry.CaffeinatedBlocks; +import net.chikorita_lover.caffeinated.registry.CaffeinatedParticleTypes; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; diff --git a/src/main/java/com/chikoritalover/caffeinated/CaffeinatedDataGenerator.java b/src/main/java/net/chikorita_lover/caffeinated/CaffeinatedDataGenerator.java similarity index 73% rename from src/main/java/com/chikoritalover/caffeinated/CaffeinatedDataGenerator.java rename to src/main/java/net/chikorita_lover/caffeinated/CaffeinatedDataGenerator.java index 1ffe6cb..1e7c86b 100644 --- a/src/main/java/com/chikoritalover/caffeinated/CaffeinatedDataGenerator.java +++ b/src/main/java/net/chikorita_lover/caffeinated/CaffeinatedDataGenerator.java @@ -1,38 +1,74 @@ -package com.chikoritalover.caffeinated; +package net.chikorita_lover.caffeinated; -import com.chikoritalover.caffeinated.registry.CaffeinatedBlocks; -import com.chikoritalover.caffeinated.registry.CaffeinatedItems; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import net.chikorita_lover.caffeinated.block.FloweringCoffeeShrubBlock; +import net.chikorita_lover.caffeinated.registry.CaffeinatedBlocks; +import net.chikorita_lover.caffeinated.registry.CaffeinatedItems; import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider; import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider; import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider; +import net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditions; import net.minecraft.block.Block; +import net.minecraft.block.Blocks; import net.minecraft.block.LeveledCauldronBlock; +import net.minecraft.block.enums.DoubleBlockHalf; import net.minecraft.data.client.*; -import net.minecraft.data.server.recipe.RecipeJsonProvider; +import net.minecraft.data.server.recipe.RecipeExporter; import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder; import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder; +import net.minecraft.enchantment.Enchantments; import net.minecraft.item.ItemConvertible; import net.minecraft.item.Items; +import net.minecraft.loot.LootPool; +import net.minecraft.loot.LootTable; +import net.minecraft.loot.condition.BlockStatePropertyLootCondition; +import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.loot.function.ApplyBonusLootFunction; +import net.minecraft.loot.function.SetCountLootFunction; +import net.minecraft.loot.provider.number.UniformLootNumberProvider; +import net.minecraft.predicate.StatePredicate; import net.minecraft.recipe.book.RecipeCategory; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.state.property.Properties; import net.minecraft.state.property.Property; import net.minecraft.util.Identifier; import org.jetbrains.annotations.Nullable; -import java.util.function.Consumer; +import java.util.concurrent.CompletableFuture; public class CaffeinatedDataGenerator implements DataGeneratorEntrypoint { @Override public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { FabricDataGenerator.Pack pack = fabricDataGenerator.createPack(); + pack.addProvider(CaffeinatedLootGenerator::new); pack.addProvider(CaffeinatedModelGenerator::new); pack.addProvider(CaffeinatedRecipeGenerator::new); } + private static class CaffeinatedLootGenerator extends FabricBlockLootTableProvider { + protected CaffeinatedLootGenerator(FabricDataOutput dataOutput, CompletableFuture registryLookup) { + super(dataOutput, registryLookup); + } + + @Override + public void generate() { + this.addDrop(CaffeinatedBlocks.FLOWERING_COFFEE_SHRUB, (Block block) -> this.applyExplosionDecay(block, LootTable.builder().pool(LootPool.builder().conditionally(BlockStatePropertyLootCondition.builder(CaffeinatedBlocks.FLOWERING_COFFEE_SHRUB).properties(StatePredicate.Builder.create().exactMatch(FloweringCoffeeShrubBlock.AGE, 3).exactMatch(FloweringCoffeeShrubBlock.HALF, DoubleBlockHalf.LOWER))).with(ItemEntry.builder(CaffeinatedItems.COFFEE_BERRIES)).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1.0F, 3.0F))).apply(ApplyBonusLootFunction.uniformBonusCount(Enchantments.FORTUNE))))); + + this.addPottedPlantDrops(CaffeinatedBlocks.POTTED_COFFEE_SHRUB); + this.addDrop(CaffeinatedBlocks.COFFEE_BEAN_BLOCK); + this.addDrop(CaffeinatedBlocks.GROUND_COFFEE_BLOCK); + + this.addDrop(CaffeinatedBlocks.GROUND_COFFEE_CAULDRON, Blocks.CAULDRON); + this.addDrop(CaffeinatedBlocks.COFFEE_CAULDRON, Blocks.CAULDRON); + + this.addDrop(CaffeinatedBlocks.COFFEE_BERRY_CRATE); + } + } + private static class CaffeinatedModelGenerator extends FabricModelProvider { private CaffeinatedModelGenerator(FabricDataOutput output) { super(output); @@ -82,22 +118,22 @@ public void generateItemModels(ItemModelGenerator itemModelGenerator) { } private static class CaffeinatedRecipeGenerator extends FabricRecipeProvider { - private CaffeinatedRecipeGenerator(FabricDataOutput output) { - super(output); + private CaffeinatedRecipeGenerator(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); } - public static void offerReversibleCompactingRecipes(Consumer exporter, ItemConvertible input, ItemConvertible compacted, String compactingRecipeName, @Nullable String compactingRecipeGroup, String reverseRecipeName, @Nullable String reverseRecipeGroup) { + public static void offerReversibleCompactingRecipes(RecipeExporter exporter, ItemConvertible input, ItemConvertible compacted, String compactingRecipeName, @Nullable String compactingRecipeGroup, String reverseRecipeName, @Nullable String reverseRecipeGroup) { ShapelessRecipeJsonBuilder.create(RecipeCategory.MISC, input, 9).input(compacted).group(reverseRecipeGroup).criterion(hasItem(compacted), conditionsFromItem(compacted)).offerTo(exporter, new Identifier(Caffeinated.MODID, reverseRecipeName)); ShapedRecipeJsonBuilder.create(RecipeCategory.BUILDING_BLOCKS, compacted).input('#', input).pattern("###").pattern("###").pattern("###").group(compactingRecipeGroup).criterion(hasItem(input), conditionsFromItem(input)).offerTo(exporter, new Identifier(Caffeinated.MODID, compactingRecipeName)); } @Override - public void generate(Consumer exporter) { - offerReversibleCompactingRecipes(exporter, CaffeinatedItems.COFFEE_BEANS, CaffeinatedBlocks.COFFEE_BEAN_BLOCK, "coffee_bean_block", null, "coffee_beans_from_block", "coffee_beans"); + public void generate(RecipeExporter exporter) { + final RecipeExporter farmersDelightExporter = this.withConditions(exporter, ResourceConditions.allModsLoaded("farmersdelight")); + offerReversibleCompactingRecipes(exporter, CaffeinatedItems.COFFEE_BEANS, CaffeinatedBlocks.COFFEE_BEAN_BLOCK, "coffee_bean_block", null, "coffee_beans_from_block", "coffee_beans"); offerReversibleCompactingRecipes(exporter, CaffeinatedItems.GROUND_COFFEE, CaffeinatedBlocks.GROUND_COFFEE_BLOCK, "ground_coffee_block", null, "ground_coffee_from_block", "ground_coffee"); - - ShapelessRecipeJsonBuilder.create(RecipeCategory.FOOD, CaffeinatedItems.COFFEE_BERRIES, 9).input(CaffeinatedBlocks.COFFEE_BERRY_CRATE).criterion(hasItem(CaffeinatedBlocks.COFFEE_BERRY_CRATE), conditionsFromItem(CaffeinatedBlocks.COFFEE_BERRY_CRATE)).offerTo(exporter); + offerReversibleCompactingRecipes(farmersDelightExporter, RecipeCategory.FOOD, CaffeinatedItems.COFFEE_BERRIES, RecipeCategory.DECORATIONS, CaffeinatedBlocks.COFFEE_BERRY_CRATE); ShapelessRecipeJsonBuilder.create(RecipeCategory.MISC, CaffeinatedItems.COFFEE_BEANS).input(CaffeinatedItems.COFFEE_BERRIES).group("coffee_beans").criterion(hasItem(CaffeinatedItems.COFFEE_BERRIES), conditionsFromItem(CaffeinatedItems.COFFEE_BERRIES)).offerTo(exporter, new Identifier(Caffeinated.MODID, "coffee_beans_from_coffee_berries")); diff --git a/src/main/java/com/chikoritalover/caffeinated/block/CoffeeCauldronBlock.java b/src/main/java/net/chikorita_lover/caffeinated/block/CoffeeCauldronBlock.java similarity index 69% rename from src/main/java/com/chikoritalover/caffeinated/block/CoffeeCauldronBlock.java rename to src/main/java/net/chikorita_lover/caffeinated/block/CoffeeCauldronBlock.java index f593976..2c43575 100644 --- a/src/main/java/com/chikoritalover/caffeinated/block/CoffeeCauldronBlock.java +++ b/src/main/java/net/chikorita_lover/caffeinated/block/CoffeeCauldronBlock.java @@ -1,14 +1,13 @@ -package com.chikoritalover.caffeinated.block; +package net.chikorita_lover.caffeinated.block; -import com.chikoritalover.caffeinated.registry.CaffeinatedBlockTags; -import com.chikoritalover.caffeinated.registry.CaffeinatedParticleTypes; -import com.chikoritalover.caffeinated.registry.CaffeinatedSoundEvents; +import net.chikorita_lover.caffeinated.registry.CaffeinatedBlockTags; +import net.chikorita_lover.caffeinated.registry.CaffeinatedParticleTypes; +import net.chikorita_lover.caffeinated.registry.CaffeinatedSoundEvents; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.LeveledCauldronBlock; import net.minecraft.block.cauldron.CauldronBehavior; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.particle.ParticleEffect; import net.minecraft.sound.SoundCategory; @@ -17,40 +16,28 @@ import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; -import net.minecraft.world.BlockView; import net.minecraft.world.World; - -import java.util.Map; +import net.minecraft.world.WorldView; public class CoffeeCauldronBlock extends LeveledCauldronBlock { public static final BooleanProperty REWARD_EXPERIENCE = BooleanProperty.of("reward_experience"); - public CoffeeCauldronBlock(Settings settings, Map behaviorMap) { - super(settings, null, behaviorMap); + public CoffeeCauldronBlock(CauldronBehavior.CauldronBehaviorMap behaviorMap, Settings settings) { + super(null, behaviorMap, settings); this.setDefaultState(this.stateManager.getDefaultState().with(REWARD_EXPERIENCE, false)); } public static boolean isLitFireInRange(World world, BlockPos pos) { - BlockPos blockPos = pos.down(); - BlockState blockState = world.getBlockState(blockPos); - - boolean bl = blockState.isIn(CaffeinatedBlockTags.LIT_FIRES); - - if (blockState.contains(Properties.LIT)) { - return bl && blockState.get(Properties.LIT); - } else { - return bl; - } - } - - public ParticleEffect getPopParticleEffect() { - return CaffeinatedParticleTypes.COFFEE_POP; + BlockState state = world.getBlockState(pos.down()); + return state.isIn(CaffeinatedBlockTags.LIT_FIRES) && (!state.contains(Properties.LIT) || state.get(Properties.LIT)); } - public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + @Override + public ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state) { return new ItemStack(Blocks.CAULDRON); } + @Override public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { if (isLitFireInRange(world, pos)) { int level = state.get(LEVEL); @@ -71,4 +58,8 @@ protected void appendProperties(StateManager.Builder builder) super.appendProperties(builder); builder.add(REWARD_EXPERIENCE); } + + public ParticleEffect getPopParticleEffect() { + return CaffeinatedParticleTypes.COFFEE_POP; + } } diff --git a/src/main/java/com/chikoritalover/caffeinated/block/CoffeeShrubBlock.java b/src/main/java/net/chikorita_lover/caffeinated/block/CoffeeShrubBlock.java similarity index 61% rename from src/main/java/com/chikoritalover/caffeinated/block/CoffeeShrubBlock.java rename to src/main/java/net/chikorita_lover/caffeinated/block/CoffeeShrubBlock.java index 1b99472..0d3aa31 100644 --- a/src/main/java/com/chikoritalover/caffeinated/block/CoffeeShrubBlock.java +++ b/src/main/java/net/chikorita_lover/caffeinated/block/CoffeeShrubBlock.java @@ -1,18 +1,14 @@ -package com.chikoritalover.caffeinated.block; +package net.chikorita_lover.caffeinated.block; -import com.chikoritalover.caffeinated.registry.CaffeinatedBlocks; -import com.chikoritalover.caffeinated.registry.CaffeinatedItems; +import com.mojang.serialization.MapCodec; +import net.chikorita_lover.caffeinated.registry.CaffeinatedBlocks; +import net.chikorita_lover.caffeinated.registry.CaffeinatedItems; import net.minecraft.block.*; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.StateManager; import net.minecraft.state.property.IntProperty; import net.minecraft.state.property.Properties; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; import net.minecraft.util.shape.VoxelShape; @@ -32,7 +28,12 @@ public CoffeeShrubBlock(AbstractBlock.Settings settings) { } @Override - public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + protected MapCodec getCodec() { + return createCodec(CoffeeShrubBlock::new); + } + + @Override + public ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state) { return new ItemStack(CaffeinatedItems.COFFEE_BEANS); } @@ -51,47 +52,37 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random if (!this.canGrow(world, random, pos, state)) { return; } - if (random.nextInt(5) == 0 && world.getBaseLightLevel(pos.up(), 0) >= 9) { + if (world.getBaseLightLevel(pos.up(), 0) >= 9 && random.nextInt(5) == 0) { this.grow(world, random, pos, state); - BlockState blockState = world.getBlockState(pos); - world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(blockState)); - } - } - - @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - boolean bl = this.isFertilizable(world, pos, state, world.isClient()); - if (bl && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) { - return ActionResult.PASS; - } else { - return super.onUse(state, world, pos, player, hand, hit); + world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(world.getBlockState(pos))); } } @Override - protected void appendProperties(StateManager.Builder builder) { - builder.add(AGE); - } - - @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) { + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { return state.get(AGE) < 3 || world.isAir(pos.up()); } @Override public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { - return state.get(AGE) < 3 || world.isAir(pos.up()); + return true; } @Override public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { if (state.get(AGE) < 3) { - world.setBlockState(pos, state.with(AGE, state.get(AGE) + 1), Block.NOTIFY_LISTENERS); + world.setBlockState(pos, state.cycle(AGE), Block.NOTIFY_LISTENERS); return; } - BlockState blockState = CaffeinatedBlocks.FLOWERING_COFFEE_SHRUB.getDefaultState(); - if (blockState.canPlaceAt(world, pos) && world.isAir(pos.up())) { - FloweringCoffeeShrubBlock.placeAt(world, blockState, pos, Block.NOTIFY_LISTENERS); + BlockState newState = CaffeinatedBlocks.FLOWERING_COFFEE_SHRUB.getDefaultState(); + if (newState.canPlaceAt(world, pos) && world.isAir(pos.up())) { + FloweringCoffeeShrubBlock.placeAt(world, newState, pos, Block.NOTIFY_LISTENERS); } } + + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(AGE); + } } diff --git a/src/main/java/net/chikorita_lover/caffeinated/block/FloweringCoffeeShrubBlock.java b/src/main/java/net/chikorita_lover/caffeinated/block/FloweringCoffeeShrubBlock.java new file mode 100644 index 0000000..468b326 --- /dev/null +++ b/src/main/java/net/chikorita_lover/caffeinated/block/FloweringCoffeeShrubBlock.java @@ -0,0 +1,118 @@ +package net.chikorita_lover.caffeinated.block; + +import com.mojang.serialization.MapCodec; +import net.chikorita_lover.caffeinated.registry.CaffeinatedItems; +import net.chikorita_lover.caffeinated.registry.CaffeinatedSoundEvents; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Fertilizable; +import net.minecraft.block.TallPlantBlock; +import net.minecraft.block.enums.DoubleBlockHalf; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BoneMealItem; +import net.minecraft.item.ItemStack; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.sound.SoundCategory; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.IntProperty; +import net.minecraft.state.property.Properties; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.ItemActionResult; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.random.Random; +import net.minecraft.world.World; +import net.minecraft.world.WorldView; +import net.minecraft.world.event.GameEvent; + +public class FloweringCoffeeShrubBlock extends TallPlantBlock implements Fertilizable { + public static final int MAX_AGE = 3; + public static final IntProperty AGE = Properties.AGE_3; + + public FloweringCoffeeShrubBlock(Settings settings) { + super(settings); + } + + @Override + public MapCodec getCodec() { + return createCodec(FloweringCoffeeShrubBlock::new); + } + + @Override + public ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state) { + return new ItemStack(CaffeinatedItems.COFFEE_BEANS); + } + + @Override + public boolean hasRandomTicks(BlockState state) { + return state.get(HALF) == DoubleBlockHalf.LOWER && state.get(AGE) < MAX_AGE; + } + + @Override + public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + int age = state.get(AGE); + if (age < MAX_AGE && random.nextInt(5) == 0 && world.getBaseLightLevel(pos.up(), 0) >= 9) { + this.grow(world, random, pos, state); + } + } + + @Override + protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + if (state.get(AGE) < MAX_AGE && stack.getItem() instanceof BoneMealItem) { + return ItemActionResult.SKIP_DEFAULT_BLOCK_INTERACTION; + } + return super.onUseWithItem(stack, state, world, pos, player, hand, hit); + } + + @Override + protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) { + if (state.get(AGE) < MAX_AGE) { + return super.onUse(state, world, pos, player, hit); + } + int count = world.getRandom().nextBetween(1, 3); + dropStack(world, pos, new ItemStack(CaffeinatedItems.COFFEE_BERRIES, count)); + world.playSound(null, pos, CaffeinatedSoundEvents.BLOCK_COFFEE_SHRUB_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, MathHelper.nextBetween(world.getRandom(), 0.8F, 1.2F)); + + BlockState newState = state.with(AGE, 0); + world.setBlockState(pos, newState, Block.NOTIFY_LISTENERS); + world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(player, newState)); + + BlockState otherState = newState.cycle(HALF); + BlockPos otherPos = pos.offset(newState.get(HALF).getOppositeDirection()); + world.setBlockState(otherPos, otherState, Block.NOTIFY_LISTENERS); + world.emitGameEvent(GameEvent.BLOCK_CHANGE, otherPos, GameEvent.Emitter.of(player, otherState)); + + return ActionResult.success(world.isClient()); + } + + @Override + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { + return state.get(AGE) < MAX_AGE; + } + + @Override + public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + if (state.get(HALF) == DoubleBlockHalf.UPPER) { + return this.canGrow(world, random, pos.down(), world.getBlockState(pos.down())); + } + return state.get(AGE) < MAX_AGE && this.canPlaceAt(state, world, pos); + } + + @Override + public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { + if (!this.canGrow(world, random, pos, state)) { + return; + } + int newAge = Math.min(MAX_AGE, state.get(AGE) + 1); + world.setBlockState(pos, state.with(AGE, newAge), Block.NOTIFY_LISTENERS); + world.setBlockState(pos.offset(state.get(HALF).getOppositeDirection()), state.with(AGE, newAge).cycle(HALF), Block.NOTIFY_ALL); + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(AGE); + } +} diff --git a/src/main/java/com/chikoritalover/caffeinated/block/GroundCoffeeCauldronBlock.java b/src/main/java/net/chikorita_lover/caffeinated/block/GroundCoffeeCauldronBlock.java similarity index 76% rename from src/main/java/com/chikoritalover/caffeinated/block/GroundCoffeeCauldronBlock.java rename to src/main/java/net/chikorita_lover/caffeinated/block/GroundCoffeeCauldronBlock.java index e24c1b6..d33ff0c 100644 --- a/src/main/java/com/chikoritalover/caffeinated/block/GroundCoffeeCauldronBlock.java +++ b/src/main/java/net/chikorita_lover/caffeinated/block/GroundCoffeeCauldronBlock.java @@ -1,8 +1,8 @@ -package com.chikoritalover.caffeinated.block; +package net.chikorita_lover.caffeinated.block; -import com.chikoritalover.caffeinated.registry.CaffeinatedBlocks; -import com.chikoritalover.caffeinated.registry.CaffeinatedCauldronBehavior; -import com.chikoritalover.caffeinated.registry.CaffeinatedSoundEvents; +import net.chikorita_lover.caffeinated.registry.CaffeinatedBlocks; +import net.chikorita_lover.caffeinated.registry.CaffeinatedCauldronBehavior; +import net.chikorita_lover.caffeinated.registry.CaffeinatedSoundEvents; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.particle.ParticleEffect; @@ -16,7 +16,7 @@ public class GroundCoffeeCauldronBlock extends CoffeeCauldronBlock { public GroundCoffeeCauldronBlock(Settings settings) { - super(settings, CaffeinatedCauldronBehavior.GROUND_COFFEE_CAULDRON_BEHAVIOR); + super(CaffeinatedCauldronBehavior.GROUND_COFFEE_CAULDRON_BEHAVIOR, settings); } @Override @@ -31,6 +31,7 @@ public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState } } + @Override public void neighborUpdate(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { if (isLitFireInRange(world, pos)) { world.scheduleBlockTick(pos, CaffeinatedBlocks.GROUND_COFFEE_CAULDRON, 200); @@ -40,12 +41,10 @@ public void neighborUpdate(BlockState state, World world, BlockPos pos, Block so @Override public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (isLitFireInRange(world, pos)) { - BlockState blockState = CaffeinatedBlocks.COFFEE_CAULDRON.getDefaultState().with(LEVEL, state.get(LEVEL)).with(CoffeeCauldronBlock.REWARD_EXPERIENCE, true); - + BlockState blockState = CaffeinatedBlocks.COFFEE_CAULDRON.getStateWithProperties(state).with(CoffeeCauldronBlock.REWARD_EXPERIENCE, true); world.setBlockState(pos, blockState); + world.playSound(null, pos, CaffeinatedSoundEvents.BLOCK_CAULDRON_BREW, SoundCategory.BLOCKS); world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(blockState)); - - world.playSound(null, pos, CaffeinatedSoundEvents.BLOCK_CAULDRON_BREW, SoundCategory.BLOCKS, 1.0F, 1.0F); } } } diff --git a/src/main/java/com/chikoritalover/caffeinated/entity/effect/CaffeineStatusEffect.java b/src/main/java/net/chikorita_lover/caffeinated/entity/effect/CaffeineStatusEffect.java similarity index 84% rename from src/main/java/com/chikoritalover/caffeinated/entity/effect/CaffeineStatusEffect.java rename to src/main/java/net/chikorita_lover/caffeinated/entity/effect/CaffeineStatusEffect.java index 6879e4d..0ff27ae 100644 --- a/src/main/java/com/chikoritalover/caffeinated/entity/effect/CaffeineStatusEffect.java +++ b/src/main/java/net/chikorita_lover/caffeinated/entity/effect/CaffeineStatusEffect.java @@ -1,4 +1,4 @@ -package com.chikoritalover.caffeinated.entity.effect; +package net.chikorita_lover.caffeinated.entity.effect; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffectCategory; diff --git a/src/main/java/com/chikoritalover/caffeinated/item/CoffeeBottleItem.java b/src/main/java/net/chikorita_lover/caffeinated/item/CoffeeBottleItem.java similarity index 67% rename from src/main/java/com/chikoritalover/caffeinated/item/CoffeeBottleItem.java rename to src/main/java/net/chikorita_lover/caffeinated/item/CoffeeBottleItem.java index f0ed15a..b73f24d 100644 --- a/src/main/java/com/chikoritalover/caffeinated/item/CoffeeBottleItem.java +++ b/src/main/java/net/chikorita_lover/caffeinated/item/CoffeeBottleItem.java @@ -1,6 +1,6 @@ -package com.chikoritalover.caffeinated.item; +package net.chikorita_lover.caffeinated.item; -import com.chikoritalover.caffeinated.registry.CaffeinatedSoundEvents; +import net.chikorita_lover.caffeinated.registry.CaffeinatedSoundEvents; import net.minecraft.advancement.criterion.Criteria; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffects; @@ -24,46 +24,47 @@ public CoffeeBottleItem(Item.Settings settings) { super(settings); } + @Override public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) { super.finishUsing(stack, world, user); - if (user instanceof ServerPlayerEntity serverPlayerEntity) { - Criteria.CONSUME_ITEM.trigger(serverPlayerEntity, stack); - serverPlayerEntity.incrementStat(Stats.USED.getOrCreateStat(this)); + if (user instanceof ServerPlayerEntity serverPlayer) { + Criteria.CONSUME_ITEM.trigger(serverPlayer, stack); + serverPlayer.incrementStat(Stats.USED.getOrCreateStat(this)); } - - if (!world.isClient) { + if (!world.isClient()) { user.removeStatusEffect(StatusEffects.MINING_FATIGUE); user.removeStatusEffect(StatusEffects.SLOWNESS); } - if (stack.isEmpty()) { return new ItemStack(Items.GLASS_BOTTLE); - } else { - if (user instanceof PlayerEntity playerEntity && !((PlayerEntity)user).getAbilities().creativeMode) { - ItemStack itemStack = new ItemStack(Items.GLASS_BOTTLE); - if (!playerEntity.getInventory().insertStack(itemStack)) { - playerEntity.dropItem(itemStack, false); - } + } + if (user instanceof PlayerEntity player && !player.getAbilities().creativeMode) { + ItemStack bottleStack = new ItemStack(Items.GLASS_BOTTLE); + if (!player.getInventory().insertStack(bottleStack)) { + player.dropItem(bottleStack, false); } - - return stack; } + return stack; } + @Override public int getMaxUseTime(ItemStack stack) { return MAX_USE_TIME; } + @Override public UseAction getUseAction(ItemStack stack) { return UseAction.DRINK; } + @Override public SoundEvent getDrinkSound() { return CaffeinatedSoundEvents.ITEM_COFFEE_BOTTLE_DRINK; } + @Override public SoundEvent getEatSound() { - return CaffeinatedSoundEvents.ITEM_COFFEE_BOTTLE_DRINK; + return this.getDrinkSound(); } public TypedActionResult use(World world, PlayerEntity user, Hand hand) { diff --git a/src/main/java/com/chikoritalover/caffeinated/mixin/GrowCropsGoalMixin.java b/src/main/java/net/chikorita_lover/caffeinated/mixin/GrowCropsGoalMixin.java similarity index 78% rename from src/main/java/com/chikoritalover/caffeinated/mixin/GrowCropsGoalMixin.java rename to src/main/java/net/chikorita_lover/caffeinated/mixin/GrowCropsGoalMixin.java index ec0bf8d..a0faf98 100644 --- a/src/main/java/com/chikoritalover/caffeinated/mixin/GrowCropsGoalMixin.java +++ b/src/main/java/net/chikorita_lover/caffeinated/mixin/GrowCropsGoalMixin.java @@ -1,13 +1,12 @@ -package com.chikoritalover.caffeinated.mixin; +package net.chikorita_lover.caffeinated.mixin; -import com.chikoritalover.caffeinated.block.CoffeeShrubBlock; -import com.chikoritalover.caffeinated.block.FloweringCoffeeShrubBlock; -import com.chikoritalover.caffeinated.registry.CaffeinatedBlocks; +import net.chikorita_lover.caffeinated.block.CoffeeShrubBlock; +import net.chikorita_lover.caffeinated.block.FloweringCoffeeShrubBlock; +import net.chikorita_lover.caffeinated.registry.CaffeinatedBlocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.enums.DoubleBlockHalf; import net.minecraft.entity.passive.BeeEntity; -import net.minecraft.state.property.IntProperty; import net.minecraft.util.math.BlockPos; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -22,12 +21,10 @@ public class GrowCropsGoalMixin { BeeEntity field_20373; @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isIn(Lnet/minecraft/registry/tag/TagKey;)Z", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) - public void tick(CallbackInfo info, int i, BlockPos blockPos, BlockState blockState, Block block) { + public void tryGrowCoffeeShrub(CallbackInfo info, int i, BlockPos blockPos, BlockState blockState, Block block) { boolean bl = false; - if (block instanceof CoffeeShrubBlock) { bl = true; - if (blockState.get(CoffeeShrubBlock.AGE) == 3) { field_20373.getWorld().setBlockState(blockPos, CaffeinatedBlocks.FLOWERING_COFFEE_SHRUB.getDefaultState()); field_20373.getWorld().setBlockState(blockPos.up(), CaffeinatedBlocks.FLOWERING_COFFEE_SHRUB.getDefaultState().cycle(FloweringCoffeeShrubBlock.HALF)); @@ -37,15 +34,11 @@ public void tick(CallbackInfo info, int i, BlockPos blockPos, BlockState blockSt } else if (block instanceof FloweringCoffeeShrubBlock) { if (blockState.get(FloweringCoffeeShrubBlock.AGE) < 3) { bl = true; - IntProperty intProperty = FloweringCoffeeShrubBlock.AGE; - - BlockState blockState2 = blockState.with(intProperty, blockState.get(intProperty) + 1); - + BlockState blockState2 = blockState.cycle(FloweringCoffeeShrubBlock.AGE); field_20373.getWorld().setBlockState(blockPos, blockState2); field_20373.getWorld().setBlockState(blockState2.get(FloweringCoffeeShrubBlock.HALF) == DoubleBlockHalf.LOWER ? blockPos.up() : blockPos.down(), blockState2.cycle(FloweringCoffeeShrubBlock.HALF)); } } - if (bl) { field_20373.getWorld().syncWorldEvent(2005, blockPos, 0); field_20373.addCropCounter(); diff --git a/src/main/java/com/chikoritalover/caffeinated/mixin/ItemMixin.java b/src/main/java/net/chikorita_lover/caffeinated/mixin/ItemMixin.java similarity index 71% rename from src/main/java/com/chikoritalover/caffeinated/mixin/ItemMixin.java rename to src/main/java/net/chikorita_lover/caffeinated/mixin/ItemMixin.java index d0217f6..7b17113 100644 --- a/src/main/java/com/chikoritalover/caffeinated/mixin/ItemMixin.java +++ b/src/main/java/net/chikorita_lover/caffeinated/mixin/ItemMixin.java @@ -1,7 +1,7 @@ -package com.chikoritalover.caffeinated.mixin; +package net.chikorita_lover.caffeinated.mixin; -import com.chikoritalover.caffeinated.registry.CaffeinatedEntityTypeTags; -import com.chikoritalover.caffeinated.registry.CaffeinatedItemTags; +import net.chikorita_lover.caffeinated.registry.CaffeinatedEntityTypeTags; +import net.chikorita_lover.caffeinated.registry.CaffeinatedItemTags; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; @@ -16,7 +16,7 @@ @Mixin(Item.class) public class ItemMixin { @Inject(method = "finishUsing", at = @At(value = "HEAD")) - public void finishUsing(ItemStack stack, World world, LivingEntity user, CallbackInfoReturnable info) { + public void tryInflictCoffeePoison(ItemStack stack, World world, LivingEntity user, CallbackInfoReturnable info) { if (stack.isIn(CaffeinatedItemTags.COFFEE_FOOD) && user.getType().isIn(CaffeinatedEntityTypeTags.COFFEE_INFLICTS_POISON)) { user.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 900)); } diff --git a/src/main/java/net/chikorita_lover/caffeinated/mixin/PlayerEntityMixin.java b/src/main/java/net/chikorita_lover/caffeinated/mixin/PlayerEntityMixin.java new file mode 100644 index 0000000..0b6afcb --- /dev/null +++ b/src/main/java/net/chikorita_lover/caffeinated/mixin/PlayerEntityMixin.java @@ -0,0 +1,28 @@ +package net.chikorita_lover.caffeinated.mixin; + +import net.chikorita_lover.caffeinated.registry.CaffeinatedStatusEffects; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(PlayerEntity.class) +public abstract class PlayerEntityMixin extends LivingEntity { + protected PlayerEntityMixin(EntityType entityType, World world) { + super(entityType, world); + } + + @Inject(method = "addExhaustion", at = @At(value = "HEAD"), cancellable = true) + private void tryCancelExhaustion(float exhaustion, CallbackInfo ci) { + if (this.hasStatusEffect(CaffeinatedStatusEffects.CAFFEINE)) { + int amplifier = this.getStatusEffect(CaffeinatedStatusEffects.CAFFEINE).getAmplifier(); + if (this.getRandom().nextBetween(0, amplifier + 2) > 1) { + ci.cancel(); + } + } + } +} diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBannerPatternTags.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBannerPatternTags.java similarity index 83% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBannerPatternTags.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBannerPatternTags.java index f29b8e7..18cd942 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBannerPatternTags.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBannerPatternTags.java @@ -1,6 +1,6 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; -import com.chikoritalover.caffeinated.Caffeinated; +import net.chikorita_lover.caffeinated.Caffeinated; import net.minecraft.block.entity.BannerPattern; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBlockSoundGroup.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBlockSoundGroup.java similarity index 95% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBlockSoundGroup.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBlockSoundGroup.java index 46e51c0..eafc898 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBlockSoundGroup.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBlockSoundGroup.java @@ -1,4 +1,4 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundEvents; diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBlockTags.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBlockTags.java similarity index 81% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBlockTags.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBlockTags.java index 6696c36..1b717ce 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBlockTags.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBlockTags.java @@ -1,6 +1,6 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; -import com.chikoritalover.caffeinated.Caffeinated; +import net.chikorita_lover.caffeinated.Caffeinated; import net.minecraft.block.Block; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBlocks.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBlocks.java similarity index 75% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBlocks.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBlocks.java index beb5e91..7e6b407 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedBlocks.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedBlocks.java @@ -1,15 +1,16 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; -import com.chikoritalover.caffeinated.Caffeinated; -import com.chikoritalover.caffeinated.block.CoffeeCauldronBlock; -import com.chikoritalover.caffeinated.block.CoffeeShrubBlock; -import com.chikoritalover.caffeinated.block.FloweringCoffeeShrubBlock; -import com.chikoritalover.caffeinated.block.GroundCoffeeCauldronBlock; +import net.chikorita_lover.caffeinated.Caffeinated; +import net.chikorita_lover.caffeinated.block.CoffeeCauldronBlock; +import net.chikorita_lover.caffeinated.block.CoffeeShrubBlock; +import net.chikorita_lover.caffeinated.block.FloweringCoffeeShrubBlock; +import net.chikorita_lover.caffeinated.block.GroundCoffeeCauldronBlock; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.minecraft.block.*; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.util.ColorCode; import net.minecraft.util.Identifier; public class CaffeinatedBlocks { @@ -17,9 +18,9 @@ public class CaffeinatedBlocks { public static final Block FLOWERING_COFFEE_SHRUB = register("flowering_coffee_shrub", new FloweringCoffeeShrubBlock(AbstractBlock.Settings.create().ticksRandomly().noCollision().sounds(BlockSoundGroup.FLOWERING_AZALEA))); public static final Block POTTED_COFFEE_SHRUB = register("potted_coffee_shrub", new FlowerPotBlock(COFFEE_SHRUB, AbstractBlock.Settings.create().breakInstantly().nonOpaque())); public static final Block COFFEE_BEAN_BLOCK = registerBlockWithItem("coffee_bean_block", new Block(AbstractBlock.Settings.create().mapColor(MapColor.SPRUCE_BROWN).sounds(CaffeinatedBlockSoundGroup.COFFEE_BEAN_BLOCK).strength(1.8F, 3.0F))); - public static final Block GROUND_COFFEE_BLOCK = registerBlockWithItem("ground_coffee_block", new SandBlock(8473899, AbstractBlock.Settings.create().mapColor(MapColor.SPRUCE_BROWN).strength(0.5F).sounds(CaffeinatedBlockSoundGroup.GROUND_COFFEE_BLOCK))); + public static final Block GROUND_COFFEE_BLOCK = registerBlockWithItem("ground_coffee_block", new ColoredFallingBlock(new ColorCode(0x814D2B), AbstractBlock.Settings.create().mapColor(MapColor.SPRUCE_BROWN).strength(0.5F).sounds(CaffeinatedBlockSoundGroup.GROUND_COFFEE_BLOCK))); public static final Block COFFEE_BERRY_CRATE = registerBlockWithItem("coffee_berry_crate", new Block(AbstractBlock.Settings.create().mapColor(MapColor.DARK_CRIMSON).sounds(BlockSoundGroup.WOOD).strength(2.0F, 3.0F))); - public static final Block COFFEE_CAULDRON = register("coffee_cauldron", new CoffeeCauldronBlock(AbstractBlock.Settings.copy(Blocks.CAULDRON), CaffeinatedCauldronBehavior.COFFEE_CAULDRON_BEHAVIOR)); + public static final Block COFFEE_CAULDRON = register("coffee_cauldron", new CoffeeCauldronBlock(CaffeinatedCauldronBehavior.COFFEE_CAULDRON_BEHAVIOR, AbstractBlock.Settings.copy(Blocks.CAULDRON))); public static final Block GROUND_COFFEE_CAULDRON = register("ground_coffee_cauldron", new GroundCoffeeCauldronBlock(AbstractBlock.Settings.copy(Blocks.CAULDRON).ticksRandomly())); public static Block registerBlockWithItem(String id, Block block) { diff --git a/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedCauldronBehavior.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedCauldronBehavior.java new file mode 100644 index 0000000..2f9dfb5 --- /dev/null +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedCauldronBehavior.java @@ -0,0 +1,122 @@ +package net.chikorita_lover.caffeinated.registry; + +import net.chikorita_lover.caffeinated.block.CoffeeCauldronBlock; +import net.minecraft.block.Blocks; +import net.minecraft.block.LeveledCauldronBlock; +import net.minecraft.block.cauldron.CauldronBehavior; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.PotionContentsComponent; +import net.minecraft.entity.ExperienceOrbEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUsage; +import net.minecraft.item.Items; +import net.minecraft.potion.Potions; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvents; +import net.minecraft.stat.Stats; +import net.minecraft.util.ItemActionResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.event.GameEvent; + +public class CaffeinatedCauldronBehavior { + public static final CauldronBehavior.CauldronBehaviorMap COFFEE_CAULDRON_BEHAVIOR = CauldronBehavior.createMap("caffeinated_coffee_cauldron"); + public static final CauldronBehavior.CauldronBehaviorMap GROUND_COFFEE_CAULDRON_BEHAVIOR = CauldronBehavior.createMap("caffeinated_ground_coffee_cauldron"); + + public static void register() { + CauldronBehavior.EMPTY_CAULDRON_BEHAVIOR.map().put(CaffeinatedItems.COFFEE_BOTTLE, (state, world, pos, player, hand, stack) -> { + if (!world.isClient()) { + player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(Items.GLASS_BOTTLE))); + player.incrementStat(Stats.USE_CAULDRON); + player.incrementStat(Stats.USED.getOrCreateStat(stack.getItem())); + world.setBlockState(pos, CaffeinatedBlocks.COFFEE_CAULDRON.getDefaultState()); + world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS); + world.emitGameEvent(null, GameEvent.FLUID_PLACE, pos); + } + return ItemActionResult.success(world.isClient()); + }); + CauldronBehavior.WATER_CAULDRON_BEHAVIOR.map().put(CaffeinatedItems.GROUND_COFFEE, (state, world, pos, player, hand, stack) -> { + if (!world.isClient()) { + Item item = stack.getItem(); + if (!player.isCreative()) { + stack.decrement(1); + } + player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(Blocks.AIR))); + player.incrementStat(Stats.USE_CAULDRON); + player.incrementStat(Stats.USED.getOrCreateStat(item)); + world.setBlockState(pos, CaffeinatedBlocks.GROUND_COFFEE_CAULDRON.getDefaultState().with(LeveledCauldronBlock.LEVEL, state.get(LeveledCauldronBlock.LEVEL))); + world.playSound(null, pos, CaffeinatedSoundEvents.ITEM_GROUND_COFFEE_SPLASH, SoundCategory.BLOCKS); + world.emitGameEvent(null, GameEvent.FLUID_PLACE, pos); + } + + return ItemActionResult.success(world.isClient()); + }); + COFFEE_CAULDRON_BEHAVIOR.map().put(Items.GLASS_BOTTLE, (state, world, pos, player, hand, stack) -> { + if (!world.isClient()) { + player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(CaffeinatedItems.COFFEE_BOTTLE))); + player.incrementStat(CaffeinatedStats.COFFEE_TAKEN); + player.incrementStat(Stats.USED.getOrCreateStat(stack.getItem())); + LeveledCauldronBlock.decrementFluidLevel(state, world, pos); + world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS); + world.emitGameEvent(null, GameEvent.FLUID_PICKUP, pos); + if (state.get(CoffeeCauldronBlock.REWARD_EXPERIENCE)) { + ExperienceOrbEntity.spawn((ServerWorld) world, Vec3d.ofCenter(pos), world.getRandom().nextBetween(1, 3)); + world.setBlockState(pos, world.getBlockState(pos).cycle(CoffeeCauldronBlock.REWARD_EXPERIENCE)); + } + } + return ItemActionResult.success(world.isClient()); + }); + COFFEE_CAULDRON_BEHAVIOR.map().put(CaffeinatedItems.COFFEE_BOTTLE, (state, world, pos, player, hand, stack) -> { + if (state.get(LeveledCauldronBlock.LEVEL) == 3) { + return ItemActionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; + } + if (!world.isClient()) { + player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(Items.GLASS_BOTTLE))); + player.incrementStat(Stats.USED.getOrCreateStat(stack.getItem())); + world.setBlockState(pos, state.cycle(LeveledCauldronBlock.LEVEL)); + world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS); + world.emitGameEvent(null, GameEvent.FLUID_PLACE, pos); + } + return ItemActionResult.success(world.isClient()); + }); + GROUND_COFFEE_CAULDRON_BEHAVIOR.map().put(Items.GLASS_BOTTLE, (state, world, pos, player, hand, stack) -> { + if (!world.isClient()) { + Item item = stack.getItem(); + player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, PotionContentsComponent.createStack(Items.POTION, Potions.WATER))); + player.incrementStat(Stats.USE_CAULDRON); + player.incrementStat(Stats.USED.getOrCreateStat(item)); + LeveledCauldronBlock.decrementFluidLevel(state, world, pos); + world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS); + world.emitGameEvent(null, GameEvent.FLUID_PICKUP, pos); + } + return ItemActionResult.success(world.isClient()); + }); + GROUND_COFFEE_CAULDRON_BEHAVIOR.map().put(Items.BUCKET, (state, world, pos, player, hand, stack) -> { + if (!world.isClient()) { + Item item = stack.getItem(); + player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(Items.WATER_BUCKET))); + player.incrementStat(Stats.USE_CAULDRON); + player.incrementStat(Stats.USED.getOrCreateStat(item)); + world.setBlockState(pos, Blocks.CAULDRON.getDefaultState()); + world.playSound(null, pos, SoundEvents.ITEM_BUCKET_FILL, SoundCategory.BLOCKS); + world.emitGameEvent(null, GameEvent.FLUID_PICKUP, pos); + } + return ItemActionResult.success(world.isClient()); + }); + GROUND_COFFEE_CAULDRON_BEHAVIOR.map().put(Items.POTION, (state, world, pos, player, hand, stack) -> { + if (state.get(LeveledCauldronBlock.LEVEL) == 3 || !stack.contains(DataComponentTypes.POTION_CONTENTS) || !stack.get(DataComponentTypes.POTION_CONTENTS).matches(Potions.WATER)) { + return ItemActionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; + } + if (!world.isClient()) { + player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(Items.GLASS_BOTTLE))); + player.incrementStat(Stats.USE_CAULDRON); + player.incrementStat(Stats.USED.getOrCreateStat(stack.getItem())); + world.setBlockState(pos, state.cycle(LeveledCauldronBlock.LEVEL)); + world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS); + world.emitGameEvent(null, GameEvent.FLUID_PLACE, pos); + } + return ItemActionResult.success(world.isClient()); + }); + } +} diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedEntityTypeTags.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedEntityTypeTags.java similarity index 83% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedEntityTypeTags.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedEntityTypeTags.java index 53e02ff..66943f9 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedEntityTypeTags.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedEntityTypeTags.java @@ -1,6 +1,6 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; -import com.chikoritalover.caffeinated.Caffeinated; +import net.chikorita_lover.caffeinated.Caffeinated; import net.minecraft.entity.EntityType; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; diff --git a/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedFoodComponents.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedFoodComponents.java new file mode 100644 index 0000000..87eb742 --- /dev/null +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedFoodComponents.java @@ -0,0 +1,10 @@ +package net.chikorita_lover.caffeinated.registry; + +import net.minecraft.component.type.FoodComponent; +import net.minecraft.entity.effect.StatusEffectInstance; + +public class CaffeinatedFoodComponents { + public static final FoodComponent COFFEE_BERRIES = new FoodComponent.Builder().nutrition(2).saturationModifier(0.1F).build(); + public static final FoodComponent COFFEE_BOTTLE = new FoodComponent.Builder().nutrition(2).saturationModifier(0.3F).statusEffect(new StatusEffectInstance(CaffeinatedStatusEffects.CAFFEINE, 3600, 0), 1.0F).build(); + public static final FoodComponent TIRAMISU = new FoodComponent.Builder().nutrition(5).saturationModifier(0.6F).statusEffect(new StatusEffectInstance(CaffeinatedStatusEffects.CAFFEINE, 600, 1), 1.0F).build(); +} diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedItemTags.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedItemTags.java similarity index 81% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedItemTags.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedItemTags.java index 1993713..4cb109b 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedItemTags.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedItemTags.java @@ -1,6 +1,6 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; -import com.chikoritalover.caffeinated.Caffeinated; +import net.chikorita_lover.caffeinated.Caffeinated; import net.minecraft.item.Item; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedItems.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedItems.java similarity index 83% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedItems.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedItems.java index d90b917..7498a83 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedItems.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedItems.java @@ -1,7 +1,7 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; -import com.chikoritalover.caffeinated.Caffeinated; -import com.chikoritalover.caffeinated.item.CoffeeBottleItem; +import net.chikorita_lover.caffeinated.Caffeinated; +import net.chikorita_lover.caffeinated.item.CoffeeBottleItem; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; import net.minecraft.block.Block; @@ -15,10 +15,12 @@ public class CaffeinatedItems { public static final Item COFFEE_BERRIES = register("coffee_berries", new Item(new Item.Settings().food(CaffeinatedFoodComponents.COFFEE_BERRIES))); public static final Item COFFEE_BEANS = register("coffee_beans", new AliasedBlockItem(CaffeinatedBlocks.COFFEE_SHRUB, new Item.Settings())); public static final Item GROUND_COFFEE = register("ground_coffee", new Item(new Item.Settings())); + public static final Item COFFEE_BOTTLE = register("coffee_bottle", new CoffeeBottleItem(new Item.Settings().food(CaffeinatedFoodComponents.COFFEE_BOTTLE).maxCount(16).recipeRemainder(Items.GLASS_BOTTLE))); - public static final Item JAVA_BANNER_PATTERN = register("java_banner_pattern", new BannerPatternItem(CaffeinatedBannerPatternTags.JAVA_PATTERN_ITEM, (new Item.Settings()).maxCount(1))); public static final Item TIRAMISU = register("tiramisu", new Item(new Item.Settings().food(CaffeinatedFoodComponents.TIRAMISU))); + public static final Item JAVA_BANNER_PATTERN = register("java_banner_pattern", new BannerPatternItem(CaffeinatedBannerPatternTags.JAVA_PATTERN_ITEM, (new Item.Settings()).maxCount(1))); + public static Item register(Block block) { return register(new BlockItem(block, new Item.Settings())); } @@ -37,7 +39,7 @@ private static Item register(String id, Item item) { private static Item register(Identifier id, Item item) { if (item instanceof BlockItem) { - ((BlockItem)item).appendBlocks(Item.BLOCK_ITEMS, item); + ((BlockItem) item).appendBlocks(Item.BLOCK_ITEMS, item); } return Registry.register(Registries.ITEM, id, item); @@ -59,13 +61,12 @@ public static void registerCompostingChances() { public static void registerItemGroups() { ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(entries -> { - entries.addAfter(Blocks.HONEYCOMB_BLOCK, CaffeinatedBlocks.COFFEE_BEAN_BLOCK, CaffeinatedBlocks.GROUND_COFFEE_BLOCK); - entries.addAfter(Items.SWEET_BERRIES, COFFEE_BEANS); + entries.addBefore(Items.NETHER_WART, COFFEE_BEANS); + entries.addBefore(Blocks.BEE_NEST, CaffeinatedBlocks.COFFEE_BEAN_BLOCK, CaffeinatedBlocks.GROUND_COFFEE_BLOCK); }); ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(entries -> { - entries.addAfter(Items.GLOW_BERRIES, COFFEE_BERRIES); - entries.addAfter(Items.PUMPKIN_PIE, TIRAMISU); - entries.addAfter(Items.HONEY_BOTTLE, COFFEE_BOTTLE); + entries.addBefore(Items.CHORUS_FRUIT, COFFEE_BERRIES); + entries.addBefore(Items.ROTTEN_FLESH, COFFEE_BOTTLE, TIRAMISU); }); ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(entries -> { entries.addAfter(Items.WHEAT, COFFEE_BEANS, GROUND_COFFEE); diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedParticleTypes.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedParticleTypes.java similarity index 61% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedParticleTypes.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedParticleTypes.java index dec836a..2d021b3 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedParticleTypes.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedParticleTypes.java @@ -1,14 +1,14 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; -import com.chikoritalover.caffeinated.Caffeinated; +import net.chikorita_lover.caffeinated.Caffeinated; import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; -import net.minecraft.particle.DefaultParticleType; +import net.minecraft.particle.SimpleParticleType; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; public class CaffeinatedParticleTypes { - public static final DefaultParticleType COFFEE_POP = FabricParticleTypes.simple(); + public static final SimpleParticleType COFFEE_POP = FabricParticleTypes.simple(); public static void register() { Registry.register(Registries.PARTICLE_TYPE, new Identifier(Caffeinated.MODID, "coffee_pop"), COFFEE_POP); diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedPlacedFeatures.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedPlacedFeatures.java similarity index 88% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedPlacedFeatures.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedPlacedFeatures.java index fb39842..c1d8fd0 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedPlacedFeatures.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedPlacedFeatures.java @@ -1,6 +1,6 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; -import com.chikoritalover.caffeinated.Caffeinated; +import net.chikorita_lover.caffeinated.Caffeinated; import net.fabricmc.fabric.api.biome.v1.BiomeModifications; import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; import net.minecraft.registry.RegistryKey; diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedSoundEvents.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedSoundEvents.java similarity index 94% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedSoundEvents.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedSoundEvents.java index d294b07..e625d9a 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedSoundEvents.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedSoundEvents.java @@ -1,6 +1,6 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; -import com.chikoritalover.caffeinated.Caffeinated; +import net.chikorita_lover.caffeinated.Caffeinated; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.sound.SoundEvent; diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedStats.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedStats.java similarity index 86% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedStats.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedStats.java index f791f77..4b9eed7 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedStats.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedStats.java @@ -1,6 +1,6 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; -import com.chikoritalover.caffeinated.Caffeinated; +import net.chikorita_lover.caffeinated.Caffeinated; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.stat.StatFormatter; diff --git a/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedStatusEffects.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedStatusEffects.java new file mode 100644 index 0000000..72beb28 --- /dev/null +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedStatusEffects.java @@ -0,0 +1,21 @@ +package net.chikorita_lover.caffeinated.registry; + +import net.chikorita_lover.caffeinated.Caffeinated; +import net.chikorita_lover.caffeinated.entity.effect.CaffeineStatusEffect; +import net.minecraft.entity.effect.StatusEffect; +import net.minecraft.entity.effect.StatusEffectCategory; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.util.Identifier; + +public class CaffeinatedStatusEffects { + public static final RegistryEntry CAFFEINE = register("caffeine", StatusEffectCategory.BENEFICIAL, 0x4B3121); + + private static RegistryEntry register(String id, StatusEffectCategory category, int i) { + return Registry.registerReference(Registries.STATUS_EFFECT, new Identifier(Caffeinated.MODID, id), new CaffeineStatusEffect(category, i)); + } + + public static void register() { + } +} diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedTradeOffers.java b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedTradeOffers.java similarity index 82% rename from src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedTradeOffers.java rename to src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedTradeOffers.java index e0a4790..1e2bea6 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedTradeOffers.java +++ b/src/main/java/net/chikorita_lover/caffeinated/registry/CaffeinatedTradeOffers.java @@ -1,4 +1,4 @@ -package com.chikoritalover.caffeinated.registry; +package net.chikorita_lover.caffeinated.registry; import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper; import net.minecraft.village.TradeOffers; @@ -7,7 +7,7 @@ public class CaffeinatedTradeOffers { public static void register() { TradeOfferHelper.registerVillagerOffers(VillagerProfession.FARMER, 3, factories -> { - factories.add(new TradeOffers.BuyForOneEmeraldFactory(CaffeinatedItems.COFFEE_BERRIES, 8, 12, 20)); + factories.add(new TradeOffers.BuyItemFactory(CaffeinatedItems.COFFEE_BERRIES, 8, 12, 20)); }); TradeOfferHelper.registerVillagerOffers(VillagerProfession.FARMER, 5, factories -> { factories.add(new TradeOffers.SellItemFactory(CaffeinatedItems.TIRAMISU, 3, 1, 12, 30)); diff --git a/src/main/resources/caffeinated.mixins.json b/src/main/resources/caffeinated.mixins.json index 005d353..b147716 100644 --- a/src/main/resources/caffeinated.mixins.json +++ b/src/main/resources/caffeinated.mixins.json @@ -1,16 +1,14 @@ { - "required": true, - "minVersion": "0.8", - "package": "com.chikoritalover.caffeinated.mixin", - "compatibilityLevel": "JAVA_17", - "mixins": [ - "GrowCropsGoalMixin", - "ItemMixin", - "PlayerEntityMixin" - ], - "client": [], - "server": [], - "injectors": { - "defaultRequire": 1 - } + "required": true, + "minVersion": "0.8", + "package": "net.chikorita_lover.caffeinated.mixin", + "compatibilityLevel": "JAVA_21", + "mixins": [ + "GrowCropsGoalMixin", + "ItemMixin", + "PlayerEntityMixin" + ], + "injectors": { + "defaultRequire": 1 + } } diff --git a/src/main/resources/data/c/tags/blocks/storage_blocks.json b/src/main/resources/data/c/tags/blocks/storage_blocks.json new file mode 100644 index 0000000..2a13d4b --- /dev/null +++ b/src/main/resources/data/c/tags/blocks/storage_blocks.json @@ -0,0 +1,7 @@ +{ + "values": [ + "caffeinated:coffee_bean_block", + "caffeinated:coffee_berry_crate", + "caffeinated:ground_coffee_block" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/c/tags/items/foods.json b/src/main/resources/data/c/tags/items/foods.json index 73e53aa..fe73034 100644 --- a/src/main/resources/data/c/tags/items/foods.json +++ b/src/main/resources/data/c/tags/items/foods.json @@ -1,5 +1,6 @@ { "values": [ - "#caffeinated:coffee_food" + "caffeinated:coffee_bottle", + "caffeinated:tiramisu" ] } \ No newline at end of file diff --git a/src/main/resources/data/c/tags/items/foods/fruits.json b/src/main/resources/data/c/tags/items/foods/fruits.json new file mode 100644 index 0000000..1cc5e8c --- /dev/null +++ b/src/main/resources/data/c/tags/items/foods/fruits.json @@ -0,0 +1,5 @@ +{ + "values": [ + "caffeinated:coffee_berries" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/c/tags/items/storage_blocks.json b/src/main/resources/data/c/tags/items/storage_blocks.json new file mode 100644 index 0000000..2a13d4b --- /dev/null +++ b/src/main/resources/data/c/tags/items/storage_blocks.json @@ -0,0 +1,7 @@ +{ + "values": [ + "caffeinated:coffee_bean_block", + "caffeinated:coffee_berry_crate", + "caffeinated:ground_coffee_block" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/advancements/husbandry/brew_coffee.json b/src/main/resources/data/caffeinated/advancements/husbandry/brew_coffee.json index b6cc79d..efb6dcd 100644 --- a/src/main/resources/data/caffeinated/advancements/husbandry/brew_coffee.json +++ b/src/main/resources/data/caffeinated/advancements/husbandry/brew_coffee.json @@ -1,56 +1,44 @@ { - "display": { - "icon": { - "item": "caffeinated:coffee_bottle" - }, - "title": { - "translate": "advancements.husbandry.brew_coffee.title" - }, - "description": { - "translate": "advancements.husbandry.brew_coffee.description" - }, - "frame": "task", - "show_toast": true, - "announce_to_chat": true, - "hidden": false - }, - "parent": "minecraft:husbandry/root", - "criteria": { - "brew_coffee": { - "trigger": "minecraft:item_used_on_block", - "conditions": { - "item": { - "items": [ - "minecraft:glass_bottle" - ] - }, - "location": [ - { - "condition": "minecraft:location_check", - "predicate": { - "block": { - "blocks": [ - "caffeinated:coffee_cauldron" - ] - } - } - }, - { - "condition": "minecraft:match_tool", - "predicate": { - "items": [ - "minecraft:glass_bottle" - ] - } - } - ] - } - } - }, - "requirements": [ - [ - "brew_coffee" - ] - ], - "sends_telemetry_event": true + "parent": "minecraft:husbandry/root", + "criteria": { + "brew_coffee": { + "conditions": { + "location": [ + { + "condition": "minecraft:location_check", + "predicate": { + "block": { + "blocks": "caffeinated:coffee_cauldron" + } + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "items": "minecraft:glass_bottle" + } + } + ] + }, + "trigger": "minecraft:item_used_on_block" + } + }, + "display": { + "description": { + "translate": "advancements.husbandry.brew_coffee.description" + }, + "icon": { + "count": 1, + "id": "caffeinated:coffee_bottle" + }, + "title": { + "translate": "advancements.husbandry.brew_coffee.title" + } + }, + "requirements": [ + [ + "brew_coffee" + ] + ], + "sends_telemetry_event": true } \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/advancements/recipes/coffee_berry_crate.json b/src/main/resources/data/caffeinated/advancements/recipes/coffee_berry_crate.json deleted file mode 100644 index e8411b2..0000000 --- a/src/main/resources/data/caffeinated/advancements/recipes/coffee_berry_crate.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "criteria": { - "has_coffee_berries": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "items": [ - "caffeinated:coffee_berries" - ] - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "caffeinated:coffee_berry_crate" - } - } - }, - "requirements": [ - [ - "has_coffee_berries", - "has_the_recipe" - ] - ], - "rewards": { - "recipes": [ - "caffeinated:coffee_berry_crate" - ] - } -} \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/banner_pattern/java.json b/src/main/resources/data/caffeinated/banner_pattern/java.json new file mode 100644 index 0000000..afbb7fb --- /dev/null +++ b/src/main/resources/data/caffeinated/banner_pattern/java.json @@ -0,0 +1,4 @@ +{ + "asset_id": "caffeinated:java", + "translation_key": "block.minecraft.banner.caffeinated.java" +} \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/recipes/cooking/coffee_bottle.json b/src/main/resources/data/caffeinated/recipes/cooking/coffee_bottle.json index fbc2562..004dedc 100644 --- a/src/main/resources/data/caffeinated/recipes/cooking/coffee_bottle.json +++ b/src/main/resources/data/caffeinated/recipes/cooking/coffee_bottle.json @@ -1,17 +1,20 @@ { "type": "farmersdelight:cooking", "container": { - "item": "minecraft:glass_bottle" + "count": 1, + "id": "minecraft:glass_bottle" }, "cookingtime": 200, "experience": 1.0, "ingredients": [ { - "item": "caffeinated:ground_coffee" + "count": 1, + "id": "caffeinated:ground_coffee" } ], "recipe_book_tab": "drinks", "result": { - "item": "caffeinated:coffee_bottle" + "count": 1, + "id": "caffeinated:coffee_bottle" } } \ No newline at end of file diff --git a/src/main/resources/data/caffeinated/recipes/cutting/coffee_berries.json b/src/main/resources/data/caffeinated/recipes/cutting/coffee_berries.json index 45369dd..e0da5cd 100644 --- a/src/main/resources/data/caffeinated/recipes/cutting/coffee_berries.json +++ b/src/main/resources/data/caffeinated/recipes/cutting/coffee_berries.json @@ -2,13 +2,14 @@ "type": "farmersdelight:cutting", "ingredients": [ { - "item": "caffeinated:coffee_berries" + "count": 1, + "id": "caffeinated:coffee_berries" } ], "result": [ { - "item": "caffeinated:coffee_beans", - "count": 2 + "count": 2, + "id": "caffeinated:coffee_beans" } ], "tool": { diff --git a/src/main/resources/data/minecraft/tags/blocks/flowers.json b/src/main/resources/data/minecraft/tags/blocks/tall_flowers.json similarity index 100% rename from src/main/resources/data/minecraft/tags/blocks/flowers.json rename to src/main/resources/data/minecraft/tags/blocks/tall_flowers.json diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index d0abc6e..45cf982 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -22,26 +22,23 @@ "environment": "*", "entrypoints": { "client": [ - "com.chikoritalover.caffeinated.CaffeinatedClient" + "net.chikorita_lover.caffeinated.CaffeinatedClient" ], "fabric-datagen": [ - "com.chikoritalover.caffeinated.CaffeinatedDataGenerator" + "net.chikorita_lover.caffeinated.CaffeinatedDataGenerator" ], "main": [ - "com.chikoritalover.caffeinated.Caffeinated" + "net.chikorita_lover.caffeinated.Caffeinated" ] }, "mixins": [ "caffeinated.mixins.json" ], "depends": { - "fabricloader": ">=0.15.3", + "fabricloader": ">=0.15.11", "fabric-api": "*", - "minecraft": "~1.20.0", - "java": ">=17" - }, - "suggests": { - "another-mod": "*" + "minecraft": "~1.20.5", + "java": ">=21" }, "accessWidener" : "caffeinated.accesswidener" }