From a0378e44ab7b0a42b44644f1b999c926075eb80b Mon Sep 17 00:00:00 2001 From: Mutzi Date: Fri, 12 May 2023 18:58:46 +0200 Subject: [PATCH] Replaced static json data files with datagen --- .idea/.name | 2 +- .idea/misc.xml | 11 +- .idea/modules.xml | 5 +- .idea/modules/mattv.iml | 8 -- .../{mattv.test.iml => mquarry.main.iml} | 9 +- .../{mattv.main.iml => mquarry.test.iml} | 2 - .idea/runConfigurations/runClient.xml | 17 --- .idea/runConfigurations/runData.xml | 17 --- .idea/runConfigurations/runGameTestServer.xml | 18 --- .idea/runConfigurations/runServer.xml | 17 --- build.gradle | 66 +--------- settings.gradle | 2 +- src/generated/resources/.cache/cache | 17 +++ .../assets/mquarry/blockstates/quarry.json | 0 .../resources/assets/mquarry/lang/en_us.json | 6 + .../assets/mquarry/models/block/quarry.json | 7 + .../mquarry/models/item/controller.json | 2 +- .../assets/mquarry/models/item/quarry.json | 0 .../mquarry/models/item/upgrade_fortune.json | 2 +- .../mquarry/models/item/upgrade_speed.json | 2 +- .../tags/blocks/mineable/pickaxe.json | 0 .../tags/blocks/needs_iron_tool.json | 0 .../advancements/recipes/misc/controller.json | 25 ++++ .../advancements/recipes/misc/quarry.json | 25 ++++ .../recipes/misc/upgrade_fortune.json | 25 ++++ .../recipes/misc/upgrade_speed.json | 25 ++++ .../data/mquarry/recipes/controller.json | 22 ++++ .../data/mquarry/recipes/quarry.json | 37 ++++++ .../data/mquarry/recipes/upgrade_fortune.json | 25 ++++ .../data/mquarry/recipes/upgrade_speed.json | 25 ++++ src/main/kotlin/de/mattv/quarry/DataGen.kt | 124 ++++++++++++++++++ src/main/kotlin/de/mattv/quarry/QuarryMod.kt | 7 +- .../resources/assets/mquarry/lang/en_us.json | 7 - .../assets/mquarry/models/block/quarry.json | 11 -- .../data/mquarry/recipes/controller.json | 14 -- .../data/mquarry/recipes/quarry.json | 19 --- .../data/mquarry/recipes/upgrade_fortune.json | 15 --- .../data/mquarry/recipes/upgrade_speed.json | 15 --- 38 files changed, 386 insertions(+), 245 deletions(-) delete mode 100644 .idea/modules/mattv.iml rename .idea/modules/{mattv.test.iml => mquarry.main.iml} (73%) rename .idea/modules/{mattv.main.iml => mquarry.test.iml} (88%) delete mode 100644 .idea/runConfigurations/runClient.xml delete mode 100644 .idea/runConfigurations/runData.xml delete mode 100644 .idea/runConfigurations/runGameTestServer.xml delete mode 100644 .idea/runConfigurations/runServer.xml create mode 100644 src/generated/resources/.cache/cache rename src/{main => generated}/resources/assets/mquarry/blockstates/quarry.json (100%) create mode 100644 src/generated/resources/assets/mquarry/lang/en_us.json create mode 100644 src/generated/resources/assets/mquarry/models/block/quarry.json rename src/{main => generated}/resources/assets/mquarry/models/item/controller.json (61%) rename src/{main => generated}/resources/assets/mquarry/models/item/quarry.json (100%) rename src/{main => generated}/resources/assets/mquarry/models/item/upgrade_fortune.json (63%) rename src/{main => generated}/resources/assets/mquarry/models/item/upgrade_speed.json (62%) rename src/{main => generated}/resources/data/minecraft/tags/blocks/mineable/pickaxe.json (100%) rename src/{main => generated}/resources/data/minecraft/tags/blocks/needs_iron_tool.json (100%) create mode 100644 src/generated/resources/data/mquarry/advancements/recipes/misc/controller.json create mode 100644 src/generated/resources/data/mquarry/advancements/recipes/misc/quarry.json create mode 100644 src/generated/resources/data/mquarry/advancements/recipes/misc/upgrade_fortune.json create mode 100644 src/generated/resources/data/mquarry/advancements/recipes/misc/upgrade_speed.json create mode 100644 src/generated/resources/data/mquarry/recipes/controller.json create mode 100644 src/generated/resources/data/mquarry/recipes/quarry.json create mode 100644 src/generated/resources/data/mquarry/recipes/upgrade_fortune.json create mode 100644 src/generated/resources/data/mquarry/recipes/upgrade_speed.json create mode 100644 src/main/kotlin/de/mattv/quarry/DataGen.kt delete mode 100755 src/main/resources/assets/mquarry/lang/en_us.json delete mode 100644 src/main/resources/assets/mquarry/models/block/quarry.json delete mode 100644 src/main/resources/data/mquarry/recipes/controller.json delete mode 100644 src/main/resources/data/mquarry/recipes/quarry.json delete mode 100644 src/main/resources/data/mquarry/recipes/upgrade_fortune.json delete mode 100644 src/main/resources/data/mquarry/recipes/upgrade_speed.json diff --git a/.idea/.name b/.idea/.name index 0e20e9d..c478269 100644 --- a/.idea/.name +++ b/.idea/.name @@ -1 +1 @@ -mattv \ No newline at end of file +mquarry \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 08fbd7d..a7ed6f2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,11 +1,12 @@ - - - - - + + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml index 3a7d485..2fe35c4 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,9 +2,8 @@ - - - + + \ No newline at end of file diff --git a/.idea/modules/mattv.iml b/.idea/modules/mattv.iml deleted file mode 100644 index 19d4940..0000000 --- a/.idea/modules/mattv.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/mattv.test.iml b/.idea/modules/mquarry.main.iml similarity index 73% rename from .idea/modules/mattv.test.iml rename to .idea/modules/mquarry.main.iml index da4952a..3f7231d 100644 --- a/.idea/modules/mattv.test.iml +++ b/.idea/modules/mquarry.main.iml @@ -3,9 +3,14 @@ + + + + + + + - FORGE - MIXIN MCP diff --git a/.idea/modules/mattv.main.iml b/.idea/modules/mquarry.test.iml similarity index 88% rename from .idea/modules/mattv.main.iml rename to .idea/modules/mquarry.test.iml index da4952a..3a5c2e3 100644 --- a/.idea/modules/mattv.main.iml +++ b/.idea/modules/mquarry.test.iml @@ -4,8 +4,6 @@ - FORGE - MIXIN MCP diff --git a/.idea/runConfigurations/runClient.xml b/.idea/runConfigurations/runClient.xml deleted file mode 100644 index a3a2e2c..0000000 --- a/.idea/runConfigurations/runClient.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/runData.xml b/.idea/runConfigurations/runData.xml deleted file mode 100644 index 563c5a3..0000000 --- a/.idea/runConfigurations/runData.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/runGameTestServer.xml b/.idea/runConfigurations/runGameTestServer.xml deleted file mode 100644 index 05395ac..0000000 --- a/.idea/runConfigurations/runGameTestServer.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - diff --git a/.idea/runConfigurations/runServer.xml b/.idea/runConfigurations/runServer.xml deleted file mode 100644 index b6ec52d..0000000 --- a/.idea/runConfigurations/runServer.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/build.gradle b/build.gradle index 7090f43..0febe35 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,3 @@ - plugins { id 'net.minecraftforge.gradle' version '5.1.+' id 'org.jetbrains.kotlin.jvm' version '1.8.21' @@ -34,67 +33,6 @@ minecraft { // Default run configurations. // These can be tweaked, removed, or duplicated as needed. runs { - client { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - // The markers can be added/remove as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - property 'forge.logging.markers', 'REGISTRIES' - - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - property 'forge.logging.console.level', 'debug' - - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - property 'forge.enabledGameTestNamespaces', 'mattv' - - mods { - quarry { - source sourceSets.main - } - } - } - - server { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - - property 'forge.logging.console.level', 'debug' - - property 'forge.enabledGameTestNamespaces', 'mattv' - - mods { - quarry { - source sourceSets.main - } - } - } - - // This run config launches GameTestServer and runs all registered gametests, then exits. - // By default, the server will crash when no gametests are provided. - // The gametest system is also enabled by default for other run configs under the /test command. - gameTestServer { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - - property 'forge.logging.console.level', 'debug' - - property 'forge.enabledGameTestNamespaces', 'mattv' - - mods { - quarry { - source sourceSets.main - } - } - } - data { workingDirectory project.file('run') @@ -103,10 +41,10 @@ minecraft { property 'forge.logging.console.level', 'debug' // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. - args '--mod', 'quarry', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + args '--mod', 'mquarry', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') mods { - quarry { + mquarry { source sourceSets.main } } diff --git a/settings.gradle b/settings.gradle index 03e1ff8..ae64d70 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,4 +5,4 @@ pluginManagement { } } -rootProject.name = 'mattv' +rootProject.name = 'mquarry' diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache new file mode 100644 index 0000000..c713814 --- /dev/null +++ b/src/generated/resources/.cache/cache @@ -0,0 +1,17 @@ +7b3fd1814758741d669955a94a335814801dc443 assets/mquarry/blockstates/quarry.json +cfc584fffe5ae3e47f2e43576177fe3b8fc01716 assets/mquarry/lang/en_us.json +0b9c1b24e1c1e35ffefac69707a7fb061aabee1d assets/mquarry/models/block/quarry.json +4cf439a6c11ccf4f890097123eee3c333774d1cf assets/mquarry/models/item/controller.json +4bb1d41c62ac0ff4f0fda72807e95eb4f8ab2db8 assets/mquarry/models/item/quarry.json +26792c633f94d1fe4a1ce9f6cd04857c61446b46 assets/mquarry/models/item/upgrade_fortune.json +b4c303efcde3f154effdfd5e82c96b1f9f7d9a28 assets/mquarry/models/item/upgrade_speed.json +d75bd4ba05c1014ba0c4c17a287d3a442b3ebd55 data/minecraft/tags/blocks/mineable/pickaxe.json +d75bd4ba05c1014ba0c4c17a287d3a442b3ebd55 data/minecraft/tags/blocks/needs_iron_tool.json +57c4a44bb5b0f0caef784a7d3e4a287e8e5e7255 data/mquarry/advancements/recipes/misc/controller.json +56cc9c88e7143b5defc447852bb4f9be5d2362c7 data/mquarry/advancements/recipes/misc/quarry.json +ceb30d9aeb5908beae5298093ef46d0f31de2939 data/mquarry/advancements/recipes/misc/upgrade_fortune.json +7cb959a2d3838c18b463ed39e4216e11bd1234ca data/mquarry/advancements/recipes/misc/upgrade_speed.json +20ae285accbee967d9458ff7c727502ecf987a61 data/mquarry/recipes/controller.json +cd032661812d4df345e9b2b1994b9a70831442e8 data/mquarry/recipes/quarry.json +f04d10d847d84057879a6801c222ce9dc83be8de data/mquarry/recipes/upgrade_fortune.json +49f0b2988a9dc3dd28c93ec4d389e81daf80c04d data/mquarry/recipes/upgrade_speed.json diff --git a/src/main/resources/assets/mquarry/blockstates/quarry.json b/src/generated/resources/assets/mquarry/blockstates/quarry.json similarity index 100% rename from src/main/resources/assets/mquarry/blockstates/quarry.json rename to src/generated/resources/assets/mquarry/blockstates/quarry.json diff --git a/src/generated/resources/assets/mquarry/lang/en_us.json b/src/generated/resources/assets/mquarry/lang/en_us.json new file mode 100644 index 0000000..f2212ba --- /dev/null +++ b/src/generated/resources/assets/mquarry/lang/en_us.json @@ -0,0 +1,6 @@ +{ + "block.mquarry.quarry": "MQuarry", + "item.mquarry.controller": "MQuarry controller", + "item.mquarry.upgrade_fortune": "MQuarry fortune upgrade", + "item.mquarry.upgrade_speed": "MQuarry speed upgrade" +} \ No newline at end of file diff --git a/src/generated/resources/assets/mquarry/models/block/quarry.json b/src/generated/resources/assets/mquarry/models/block/quarry.json new file mode 100644 index 0000000..4180364 --- /dev/null +++ b/src/generated/resources/assets/mquarry/models/block/quarry.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/cube_column", + "textures": { + "side": "mquarry:blocks/quarry/side", + "end": "mquarry:blocks/quarry/updown" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/mquarry/models/item/controller.json b/src/generated/resources/assets/mquarry/models/item/controller.json similarity index 61% rename from src/main/resources/assets/mquarry/models/item/controller.json rename to src/generated/resources/assets/mquarry/models/item/controller.json index 5d8f9dd..e7395de 100644 --- a/src/main/resources/assets/mquarry/models/item/controller.json +++ b/src/generated/resources/assets/mquarry/models/item/controller.json @@ -1,5 +1,5 @@ { - "parent": "item/generated", + "parent": "minecraft:item/generated", "textures": { "layer0": "mquarry:items/controller" } diff --git a/src/main/resources/assets/mquarry/models/item/quarry.json b/src/generated/resources/assets/mquarry/models/item/quarry.json similarity index 100% rename from src/main/resources/assets/mquarry/models/item/quarry.json rename to src/generated/resources/assets/mquarry/models/item/quarry.json diff --git a/src/main/resources/assets/mquarry/models/item/upgrade_fortune.json b/src/generated/resources/assets/mquarry/models/item/upgrade_fortune.json similarity index 63% rename from src/main/resources/assets/mquarry/models/item/upgrade_fortune.json rename to src/generated/resources/assets/mquarry/models/item/upgrade_fortune.json index b3e0383..afba18a 100644 --- a/src/main/resources/assets/mquarry/models/item/upgrade_fortune.json +++ b/src/generated/resources/assets/mquarry/models/item/upgrade_fortune.json @@ -1,5 +1,5 @@ { - "parent": "item/generated", + "parent": "minecraft:item/generated", "textures": { "layer0": "mquarry:items/upgrade_fortune" } diff --git a/src/main/resources/assets/mquarry/models/item/upgrade_speed.json b/src/generated/resources/assets/mquarry/models/item/upgrade_speed.json similarity index 62% rename from src/main/resources/assets/mquarry/models/item/upgrade_speed.json rename to src/generated/resources/assets/mquarry/models/item/upgrade_speed.json index 4f875f3..f422b49 100644 --- a/src/main/resources/assets/mquarry/models/item/upgrade_speed.json +++ b/src/generated/resources/assets/mquarry/models/item/upgrade_speed.json @@ -1,5 +1,5 @@ { - "parent": "item/generated", + "parent": "minecraft:item/generated", "textures": { "layer0": "mquarry:items/upgrade_speed" } diff --git a/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json similarity index 100% rename from src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json rename to src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json diff --git a/src/main/resources/data/minecraft/tags/blocks/needs_iron_tool.json b/src/generated/resources/data/minecraft/tags/blocks/needs_iron_tool.json similarity index 100% rename from src/main/resources/data/minecraft/tags/blocks/needs_iron_tool.json rename to src/generated/resources/data/minecraft/tags/blocks/needs_iron_tool.json diff --git a/src/generated/resources/data/mquarry/advancements/recipes/misc/controller.json b/src/generated/resources/data/mquarry/advancements/recipes/misc/controller.json new file mode 100644 index 0000000..5419264 --- /dev/null +++ b/src/generated/resources/data/mquarry/advancements/recipes/misc/controller.json @@ -0,0 +1,25 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "mquarry:controller" + ] + }, + "criteria": { + "never": { + "trigger": "minecraft:impossible" + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "mquarry:controller" + } + } + }, + "requirements": [ + [ + "never", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/mquarry/advancements/recipes/misc/quarry.json b/src/generated/resources/data/mquarry/advancements/recipes/misc/quarry.json new file mode 100644 index 0000000..2cac284 --- /dev/null +++ b/src/generated/resources/data/mquarry/advancements/recipes/misc/quarry.json @@ -0,0 +1,25 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "mquarry:quarry" + ] + }, + "criteria": { + "never": { + "trigger": "minecraft:impossible" + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "mquarry:quarry" + } + } + }, + "requirements": [ + [ + "never", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/mquarry/advancements/recipes/misc/upgrade_fortune.json b/src/generated/resources/data/mquarry/advancements/recipes/misc/upgrade_fortune.json new file mode 100644 index 0000000..589293e --- /dev/null +++ b/src/generated/resources/data/mquarry/advancements/recipes/misc/upgrade_fortune.json @@ -0,0 +1,25 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "mquarry:upgrade_fortune" + ] + }, + "criteria": { + "never": { + "trigger": "minecraft:impossible" + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "mquarry:upgrade_fortune" + } + } + }, + "requirements": [ + [ + "never", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/mquarry/advancements/recipes/misc/upgrade_speed.json b/src/generated/resources/data/mquarry/advancements/recipes/misc/upgrade_speed.json new file mode 100644 index 0000000..9f9cfc6 --- /dev/null +++ b/src/generated/resources/data/mquarry/advancements/recipes/misc/upgrade_speed.json @@ -0,0 +1,25 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "mquarry:upgrade_speed" + ] + }, + "criteria": { + "never": { + "trigger": "minecraft:impossible" + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "mquarry:upgrade_speed" + } + } + }, + "requirements": [ + [ + "never", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/mquarry/recipes/controller.json b/src/generated/resources/data/mquarry/recipes/controller.json new file mode 100644 index 0000000..9cdea28 --- /dev/null +++ b/src/generated/resources/data/mquarry/recipes/controller.json @@ -0,0 +1,22 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "i i", + "rrr", + " d " + ], + "key": { + "i": { + "tag": "forge:ingots/iron" + }, + "r": { + "tag": "forge:dusts/redstone" + }, + "d": { + "tag": "forge:gems/diamond" + } + }, + "result": { + "item": "mquarry:controller" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/mquarry/recipes/quarry.json b/src/generated/resources/data/mquarry/recipes/quarry.json new file mode 100644 index 0000000..618d033 --- /dev/null +++ b/src/generated/resources/data/mquarry/recipes/quarry.json @@ -0,0 +1,37 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "eEe", + "pRs", + "DGI" + ], + "key": { + "e": { + "tag": "forge:ender_pearls" + }, + "p": { + "item": "minecraft:netherite_pickaxe" + }, + "s": { + "item": "minecraft:netherite_shovel" + }, + "E": { + "item": "minecraft:emerald_block" + }, + "R": { + "item": "minecraft:redstone_block" + }, + "D": { + "item": "minecraft:diamond_block" + }, + "G": { + "item": "minecraft:gold_block" + }, + "I": { + "item": "minecraft:iron_block" + } + }, + "result": { + "item": "mquarry:quarry" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/mquarry/recipes/upgrade_fortune.json b/src/generated/resources/data/mquarry/recipes/upgrade_fortune.json new file mode 100644 index 0000000..a4f9c14 --- /dev/null +++ b/src/generated/resources/data/mquarry/recipes/upgrade_fortune.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "LLL", + "eRe", + "RIR" + ], + "key": { + "e": { + "tag": "forge:gems/emerald" + }, + "R": { + "item": "minecraft:redstone_block" + }, + "I": { + "item": "minecraft:iron_block" + }, + "L": { + "item": "minecraft:lapis_block" + } + }, + "result": { + "item": "mquarry:upgrade_fortune" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/mquarry/recipes/upgrade_speed.json b/src/generated/resources/data/mquarry/recipes/upgrade_speed.json new file mode 100644 index 0000000..b27eea5 --- /dev/null +++ b/src/generated/resources/data/mquarry/recipes/upgrade_speed.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "sss", + "dRd", + "RIR" + ], + "key": { + "s": { + "item": "minecraft:sugar" + }, + "d": { + "tag": "forge:gems/diamond" + }, + "R": { + "item": "minecraft:redstone_block" + }, + "I": { + "item": "minecraft:iron_block" + } + }, + "result": { + "item": "mquarry:upgrade_speed" + } +} \ No newline at end of file diff --git a/src/main/kotlin/de/mattv/quarry/DataGen.kt b/src/main/kotlin/de/mattv/quarry/DataGen.kt new file mode 100644 index 0000000..a0fad99 --- /dev/null +++ b/src/main/kotlin/de/mattv/quarry/DataGen.kt @@ -0,0 +1,124 @@ +package de.mattv.quarry + +import net.minecraft.data.DataGenerator +import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeProvider +import net.minecraft.data.recipes.ShapedRecipeBuilder +import net.minecraft.data.tags.BlockTagsProvider +import net.minecraft.tags.BlockTags +import net.minecraft.world.item.Items +import net.minecraftforge.client.model.generators.BlockStateProvider +import net.minecraftforge.client.model.generators.ItemModelProvider +import net.minecraftforge.common.Tags +import net.minecraftforge.common.data.ExistingFileHelper +import net.minecraftforge.common.data.LanguageProvider +import net.minecraftforge.eventbus.api.SubscribeEvent +import net.minecraftforge.fml.common.Mod +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent +import java.util.function.Consumer + +@Mod.EventBusSubscriber(modid=QuarryMod.ID, bus=Mod.EventBusSubscriber.Bus.MOD) +object DataGenSubscriber { + @SubscribeEvent + fun gatherData(event: GatherDataEvent) { + val gen = event.generator + if (event.includeServer()) { + gen.addProvider(DataGenBlockTags(gen, event.existingFileHelper)) + gen.addProvider(DataGenRecipes(gen)) + } + if (event.includeClient()) { + gen.addProvider(DataGenBlockStates(gen, event.existingFileHelper)) + gen.addProvider(DataGenItemModels(gen, event.existingFileHelper)) + gen.addProvider(DataGenTranslation(gen, "en_us")) + } + } +} + +class DataGenBlockStates(gen: DataGenerator?, helper: ExistingFileHelper?) : BlockStateProvider(gen, QuarryMod.ID, helper) { + override fun registerStatesAndModels() { + val quarryBlock = QuarryMod.QUARRY_BLOCK.get() + val quarryUpDown = modLoc("blocks/quarry/updown") + val quarrySide = modLoc("blocks/quarry/side") + simpleBlock(quarryBlock, models().cubeColumn(quarryBlock.registryName!!.path, quarrySide, quarryUpDown)) + } +} + +class DataGenItemModels(gen: DataGenerator?, helper: ExistingFileHelper?) : ItemModelProvider(gen, QuarryMod.ID, helper) { + override fun registerModels() { + withExistingParent(QuarryMod.QUARRY_ITEM.get().registryName!!.path, modLoc("block/quarry")) + singleTexture(QuarryMod.CONTROLLER_ITEM.get().registryName!!.path, mcLoc("item/generated"), "layer0", modLoc("items/controller")) + singleTexture(QuarryMod.QUARRY_SPEED_UPGRADE.get().registryName!!.path, mcLoc("item/generated"), "layer0", modLoc("items/upgrade_speed")) + singleTexture(QuarryMod.QUARRY_FORTUNE_UPGRADE.get().registryName!!.path, mcLoc("item/generated"), "layer0", modLoc("items/upgrade_fortune")) + } +} + +class DataGenBlockTags(gen: DataGenerator, helper: ExistingFileHelper?) : BlockTagsProvider(gen, QuarryMod.ID, helper) { + override fun addTags() { + tag(BlockTags.MINEABLE_WITH_PICKAXE) + .add(QuarryMod.QUARRY_BLOCK.get()) + tag(BlockTags.NEEDS_IRON_TOOL) + .add(QuarryMod.QUARRY_BLOCK.get()) + } + + override fun getName(): String = "MQuarry Tags" +} + +class DataGenTranslation(gen: DataGenerator, locale: String) : LanguageProvider(gen, QuarryMod.ID, locale) { + override fun addTranslations() { + add(QuarryMod.QUARRY_BLOCK.get(), "MQuarry") + add(QuarryMod.QUARRY_SPEED_UPGRADE.get(), "MQuarry speed upgrade") + add(QuarryMod.QUARRY_FORTUNE_UPGRADE.get(), "MQuarry fortune upgrade") + add(QuarryMod.CONTROLLER_ITEM.get(), "MQuarry controller") + } +} + +class DataGenRecipes(gen: DataGenerator) : RecipeProvider(gen) { + override fun buildCraftingRecipes(consumer: Consumer) { + ShapedRecipeBuilder.shaped(QuarryMod.QUARRY_ITEM.get()) + .pattern("eEe") + .pattern("pRs") + .pattern("DGI") + .define('e', Tags.Items.ENDER_PEARLS) + .define('p', Items.NETHERITE_PICKAXE) + .define('s', Items.NETHERITE_SHOVEL) + .define('E', Items.EMERALD_BLOCK) + .define('R', Items.REDSTONE_BLOCK) + .define('D', Items.DIAMOND_BLOCK) + .define('G', Items.GOLD_BLOCK) + .define('I', Items.IRON_BLOCK) + .unlockedBy("never", net.minecraft.advancements.critereon.ImpossibleTrigger.TriggerInstance()) + .save(consumer) + + ShapedRecipeBuilder.shaped(QuarryMod.QUARRY_SPEED_UPGRADE.get()) + .pattern("sss") + .pattern("dRd") + .pattern("RIR") + .define('s', Items.SUGAR) + .define('d', Tags.Items.GEMS_DIAMOND) + .define('R', Items.REDSTONE_BLOCK) + .define('I', Items.IRON_BLOCK) + .unlockedBy("never", net.minecraft.advancements.critereon.ImpossibleTrigger.TriggerInstance()) + .save(consumer) + + ShapedRecipeBuilder.shaped(QuarryMod.QUARRY_FORTUNE_UPGRADE.get()) + .pattern("LLL") + .pattern("eRe") + .pattern("RIR") + .define('e', Tags.Items.GEMS_EMERALD) + .define('R', Items.REDSTONE_BLOCK) + .define('I', Items.IRON_BLOCK) + .define('L', Items.LAPIS_BLOCK) + .unlockedBy("never", net.minecraft.advancements.critereon.ImpossibleTrigger.TriggerInstance()) + .save(consumer) + + ShapedRecipeBuilder.shaped(QuarryMod.CONTROLLER_ITEM.get()) + .pattern("i i") + .pattern("rrr") + .pattern(" d ") + .define('i', Tags.Items.INGOTS_IRON) + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('d', Tags.Items.GEMS_DIAMOND) + .unlockedBy("never", net.minecraft.advancements.critereon.ImpossibleTrigger.TriggerInstance()) + .save(consumer) + } +} diff --git a/src/main/kotlin/de/mattv/quarry/QuarryMod.kt b/src/main/kotlin/de/mattv/quarry/QuarryMod.kt index 03eca0a..e5b29da 100644 --- a/src/main/kotlin/de/mattv/quarry/QuarryMod.kt +++ b/src/main/kotlin/de/mattv/quarry/QuarryMod.kt @@ -3,19 +3,14 @@ package de.mattv.quarry import net.minecraft.world.item.BlockItem import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.Item -import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.entity.BlockEntityType -import net.minecraftforge.event.RegistryEvent -import net.minecraftforge.eventbus.api.SubscribeEvent import net.minecraftforge.fml.common.Mod import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries -import net.minecraftforge.registries.RegistryObject import thedarkcolour.kotlinforforge.forge.MOD_BUS import thedarkcolour.kotlinforforge.forge.registerObject @Mod(QuarryMod.ID) -@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) object QuarryMod { const val ID = "mquarry" @@ -30,9 +25,9 @@ object QuarryMod { val QUARRY_SPEED_UPGRADE = ITEM_REGISTRY.registerObject("upgrade_speed") { QuarryUpgrade(QuarryUpgrade.Type.SPEED) } val QUARRY_FORTUNE_UPGRADE = ITEM_REGISTRY.registerObject("upgrade_fortune") { QuarryUpgrade(QuarryUpgrade.Type.FORTUNE) } val QUARRY_ITEM = ITEM_REGISTRY.registerObject("quarry") { BlockItem(QUARRY_BLOCK.get(), Item.Properties().tab(CreativeModeTab.TAB_MISC)) } + val CONTROLLER_ITEM = ITEM_REGISTRY.registerObject("controller", ::QuarryController) init { - ITEM_REGISTRY.registerObject("controller", ::QuarryController) //LOGGER.log(Level.INFO, "MQuarry initializing") BLOCK_REGISTRY.register(MOD_BUS) TILES_REGISTRY.register(MOD_BUS) diff --git a/src/main/resources/assets/mquarry/lang/en_us.json b/src/main/resources/assets/mquarry/lang/en_us.json deleted file mode 100755 index 155a98a..0000000 --- a/src/main/resources/assets/mquarry/lang/en_us.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "block.mquarry.quarry": "MQuarry", - - "item.mquarry.upgrade_speed": "MQuarry speed upgrade", - "item.mquarry.upgrade_fortune": "MQuarry fortune upgrade", - "item.mquarry.controller": "MQuarry controller" -} \ No newline at end of file diff --git a/src/main/resources/assets/mquarry/models/block/quarry.json b/src/main/resources/assets/mquarry/models/block/quarry.json deleted file mode 100644 index 6bbe9ed..0000000 --- a/src/main/resources/assets/mquarry/models/block/quarry.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "parent": "block/cube_all", - "textures": { - "up": "mquarry:blocks/quarry/updown", - "down": "mquarry:blocks/quarry/updown", - "north": "mquarry:blocks/quarry/side", - "south": "mquarry:blocks/quarry/side", - "west": "mquarry:blocks/quarry/side", - "east": "mquarry:blocks/quarry/side" - } -} \ No newline at end of file diff --git a/src/main/resources/data/mquarry/recipes/controller.json b/src/main/resources/data/mquarry/recipes/controller.json deleted file mode 100644 index 9a2c7a4..0000000 --- a/src/main/resources/data/mquarry/recipes/controller.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - "i i", - "rrr", - " d " - ], - "key": { - "i": { "item": "minecraft:iron_ingot" }, - "r": { "item": "minecraft:redstone" }, - "d": { "item": "minecraft:diamond" } - }, - "result": { "item": "mquarry:controller" } -} \ No newline at end of file diff --git a/src/main/resources/data/mquarry/recipes/quarry.json b/src/main/resources/data/mquarry/recipes/quarry.json deleted file mode 100644 index 4ebd83f..0000000 --- a/src/main/resources/data/mquarry/recipes/quarry.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - "eEe", - "pRs", - "DGI" - ], - "key": { - "e": { "item": "minecraft:ender_pearl" }, - "p": { "item": "minecraft:netherite_pickaxe" }, - "s": { "item": "minecraft:netherite_shovel" }, - "E": { "item": "minecraft:emerald_block" }, - "R": { "item": "minecraft:redstone_block" }, - "D": { "item": "minecraft:diamond_block" }, - "G": { "item": "minecraft:gold_block" }, - "I": { "item": "minecraft:iron_block" } - }, - "result": { "item": "mquarry:quarry" } -} \ No newline at end of file diff --git a/src/main/resources/data/mquarry/recipes/upgrade_fortune.json b/src/main/resources/data/mquarry/recipes/upgrade_fortune.json deleted file mode 100644 index 4364f55..0000000 --- a/src/main/resources/data/mquarry/recipes/upgrade_fortune.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - "LLL", - "eRe", - "RIR" - ], - "key": { - "L": { "item": "minecraft:lapis_block" }, - "e": { "item": "minecraft:emerald" }, - "R": { "item": "minecraft:redstone_block" }, - "I": { "item": "minecraft:iron_block" } - }, - "result": { "item": "mquarry:upgrade_fortune" } -} diff --git a/src/main/resources/data/mquarry/recipes/upgrade_speed.json b/src/main/resources/data/mquarry/recipes/upgrade_speed.json deleted file mode 100644 index 658ce7b..0000000 --- a/src/main/resources/data/mquarry/recipes/upgrade_speed.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - "sss", - "dRd", - "RIR" - ], - "key": { - "s": { "item": "minecraft:sugar" }, - "d": { "item": "minecraft:diamond" }, - "R": { "item": "minecraft:redstone_block" }, - "I": { "item": "minecraft:iron_block" } - }, - "result": { "item": "mquarry:upgrade_speed" } -}