From aa7b2edac889361a6483e7c9d5ed01087c1ed8cd Mon Sep 17 00:00:00 2001 From: cech12 Date: Mon, 8 Apr 2024 10:07:28 +0200 Subject: [PATCH] - updated to Minecraft 1.20.4 (Forge 49.0.38, Neoforge 20.4.225) - updated JEI support to 1.20.4-17.3.0.49 (Forge & Neoforge) - updated The One Probe support to 1.20.4_neo-11.0.2-3 (Neoforge) - rename config option "recipeBlacklist" to "recipeBlockedList" --- .github/ISSUE_TEMPLATE/bug.yml | 15 +- .github/workflows/cicd-workflow.yml | 54 +++- .gitignore | 1 + CHANGELOG.md | 7 + build.gradle | 237 ++++++------------ common/build.gradle | 37 +++ .../de/cech12/solarcooker/CommonLoader.java | 19 ++ .../java/de/cech12/solarcooker/Constants.java | 52 ++++ .../java/de/cech12/solarcooker}/ModTags.java | 7 +- .../block/AbstractSolarCookerBlock.java | 4 +- .../solarcooker/block/ReflectorBlock.java | 8 +- .../block/ShiningDiamondBlock.java | 2 +- .../solarcooker/block/SolarCookerBlock.java | 29 ++- .../AbstractSolarCookerBlockEntity.java | 70 +++--- .../SolarCookerBlockEntityRenderer.java | 17 +- .../solarcooker/client/SolarCookerScreen.java | 11 +- .../crafting/SolarCookingRecipe.java | 13 +- .../inventory/SolarCookerContainer.java | 23 +- .../inventory/SolarCookerResultSlot.java | 4 +- .../solarcooker/jei/SolarCookerJEIPlugin.java | 22 +- .../solarcooker/jei/SolarCookingCategory.java | 14 +- .../cech12/solarcooker/platform/Services.java | 43 ++++ .../platform/services/IConfigHelper.java | 107 ++++++++ .../platform/services/IPlatformHelper.java | 41 +++ .../platform/services/IRegistryHelper.java | 16 ++ .../solarcooker/blockstates/reflector.json | 0 .../blockstates/shining_diamond_block.json | 0 .../solarcooker/blockstates/solar_cooker.json | 0 .../assets/solarcooker/lang/de_de.json | 0 .../assets/solarcooker/lang/en_us.json | 0 .../assets/solarcooker/lang/pt_br.json | 14 +- .../assets/solarcooker/lang/ru_ru.json | 0 .../assets/solarcooker/lang/uk_ua.json | 0 .../assets/solarcooker/lang/zh_cn.json | 14 +- .../solarcooker/models/block/reflector.json | 0 .../solarcooker/models/block/reflector_2.json | 0 .../solarcooker/models/block/reflector_l.json | 0 .../solarcooker/models/block/reflector_o.json | 0 .../solarcooker/models/block/reflector_u.json | 0 .../models/block/shining_diamond_block.json | 0 .../models/block/solar_cooker.json | 0 .../solarcooker/models/item/reflector.json | 0 .../models/item/shining_diamond_block.json | 0 .../solarcooker/models/item/solar_cooker.json | 0 .../textures/block/reflector_back.png | Bin .../textures/block/reflector_front.png | Bin .../textures/block/reflector_side.png | Bin .../textures/block/shining_diamond_block.png | Bin .../block/shining_diamond_block.png.mcmeta | 0 .../textures/entity/solar_cooker.png | Bin .../textures/gui/container/solar_cooker.png | Bin .../minecraft/tags/blocks/mineable/axe.json | 0 .../tags/blocks/mineable/pickaxe.json | 0 .../building_blocks/diamond_block.json | 0 .../shining_diamond_block.json | 0 .../recipes/decorations/reflector.json | 0 .../recipes/decorations/solar_cooker.json | 0 .../loot_tables/blocks/reflector.json | 0 .../blocks/shining_diamond_block.json | 0 .../loot_tables/blocks/solar_cooker.json | 0 .../solarcooker/recipes/diamond_block.json | 0 .../data/solarcooker/recipes/reflector.json | 0 .../recipes/shining_diamond_block.json | 0 .../solarcooker/recipes/solar_cooker.json | 0 .../tags/blocks/solar_cooker_shining.json | 0 {src => common/src}/main/resources/logo.png | Bin .../src}/main/resources/pack.mcmeta | 0 forge/build.gradle | 103 ++++++++ .../solarcooker/ForgeSolarCookerMod.java | 55 ++++ .../ForgeSolarCookerBlockEntity.java | 41 +++ .../solarcooker/init/ModBlockEntityTypes.java | 17 ++ .../de/cech12/solarcooker/init/ModBlocks.java | 24 ++ .../de}/cech12/solarcooker/init/ModItems.java | 27 +- .../cech12/solarcooker/init/ModMenuTypes.java | 17 ++ .../solarcooker/init/ModRecipeTypes.java | 16 +- .../platform/ForgeConfigHelper.java | 113 +++++++++ .../platform/ForgePlatformHelper.java | 27 ++ .../platform/ForgeRegistryHelper.java | 18 ++ forge/src/main/resources/META-INF/mods.toml | 31 +++ ...olarcooker.platform.services.IConfigHelper | 1 + ...arcooker.platform.services.IPlatformHelper | 1 + ...arcooker.platform.services.IRegistryHelper | 1 + .../cech12/solarcooker/ReflectorTests.java | 7 +- .../compat/reflector_facing_property.nbt | Bin .../solarcooker/structures/hopper/hoppers.nbt | Bin .../structures/reflector/reflectors.nbt | Bin .../structures/reflectortests.north.nbt | Bin .../structures/reflectortests.north_east.nbt | Bin .../structures/solarcooker/solarcooker.nbt | Bin gradle.properties | 53 ++-- neoforge/build.gradle | 93 +++++++ .../solarcooker/NeoForgeSolarCookerMod.java | 56 +++++ .../NeoForgeSolarCookerBlockEntity.java | 12 + .../cech12/solarcooker/compat/TOPCompat.java | 13 +- .../solarcooker/init/ModBlockEntityTypes.java | 17 ++ .../de/cech12/solarcooker/init/ModBlocks.java | 23 ++ .../de/cech12/solarcooker/init/ModItems.java | 64 +++++ .../cech12/solarcooker/init/ModMenuTypes.java | 17 ++ .../solarcooker/init/ModRecipeTypes.java | 22 ++ .../platform/NeoForgeConfigHelper.java | 113 +++++++++ .../platform/NeoForgePlatformHelper.java | 27 ++ .../platform/NeoForgeRegistryHelper.java | 18 ++ .../src/main/resources/META-INF/mods.toml | 38 +++ ...olarcooker.platform.services.IConfigHelper | 1 + ...arcooker.platform.services.IPlatformHelper | 1 + ...arcooker.platform.services.IRegistryHelper | 1 + settings.gradle | 35 ++- .../cech12/solarcooker/SolarCookerMod.java | 71 ------ .../blockentity/SolarCookerBlockEntity.java | 32 --- .../solarcooker/config/ServerConfig.java | 77 ------ .../solarcooker/init/ModBlockEntityTypes.java | 17 -- .../cech12/solarcooker/init/ModBlocks.java | 25 -- .../cech12/solarcooker/init/ModMenuTypes.java | 18 -- .../resources/META-INF/accesstransformer.cfg | 1 - src/main/resources/META-INF/mods.toml | 38 --- 115 files changed, 1634 insertions(+), 629 deletions(-) create mode 100644 common/build.gradle create mode 100644 common/src/main/java/de/cech12/solarcooker/CommonLoader.java create mode 100644 common/src/main/java/de/cech12/solarcooker/Constants.java rename {src/main/java/cech12/solarcooker/init => common/src/main/java/de/cech12/solarcooker}/ModTags.java (61%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/block/AbstractSolarCookerBlock.java (98%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/block/ReflectorBlock.java (97%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/block/ShiningDiamondBlock.java (95%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/block/SolarCookerBlock.java (72%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/blockentity/AbstractSolarCookerBlockEntity.java (92%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/client/SolarCookerBlockEntityRenderer.java (87%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/client/SolarCookerScreen.java (85%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/crafting/SolarCookingRecipe.java (76%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/inventory/SolarCookerContainer.java (88%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/inventory/SolarCookerResultSlot.java (88%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/jei/SolarCookerJEIPlugin.java (70%) rename {src/main/java => common/src/main/java/de}/cech12/solarcooker/jei/SolarCookingCategory.java (57%) create mode 100644 common/src/main/java/de/cech12/solarcooker/platform/Services.java create mode 100644 common/src/main/java/de/cech12/solarcooker/platform/services/IConfigHelper.java create mode 100644 common/src/main/java/de/cech12/solarcooker/platform/services/IPlatformHelper.java create mode 100644 common/src/main/java/de/cech12/solarcooker/platform/services/IRegistryHelper.java rename {src => common/src}/main/resources/assets/solarcooker/blockstates/reflector.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/blockstates/shining_diamond_block.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/blockstates/solar_cooker.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/lang/de_de.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/lang/en_us.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/lang/pt_br.json (98%) rename {src => common/src}/main/resources/assets/solarcooker/lang/ru_ru.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/lang/uk_ua.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/lang/zh_cn.json (98%) rename {src => common/src}/main/resources/assets/solarcooker/models/block/reflector.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/models/block/reflector_2.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/models/block/reflector_l.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/models/block/reflector_o.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/models/block/reflector_u.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/models/block/shining_diamond_block.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/models/block/solar_cooker.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/models/item/reflector.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/models/item/shining_diamond_block.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/models/item/solar_cooker.json (100%) rename {src => common/src}/main/resources/assets/solarcooker/textures/block/reflector_back.png (100%) rename {src => common/src}/main/resources/assets/solarcooker/textures/block/reflector_front.png (100%) rename {src => common/src}/main/resources/assets/solarcooker/textures/block/reflector_side.png (100%) rename {src => common/src}/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png (100%) rename {src => common/src}/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png.mcmeta (100%) rename {src => common/src}/main/resources/assets/solarcooker/textures/entity/solar_cooker.png (100%) rename {src => common/src}/main/resources/assets/solarcooker/textures/gui/container/solar_cooker.png (100%) rename {src => common/src}/main/resources/data/minecraft/tags/blocks/mineable/axe.json (100%) rename {src => common/src}/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json (100%) rename {src => common/src}/main/resources/data/solarcooker/advancements/recipes/building_blocks/diamond_block.json (100%) rename {src => common/src}/main/resources/data/solarcooker/advancements/recipes/building_blocks/shining_diamond_block.json (100%) rename {src => common/src}/main/resources/data/solarcooker/advancements/recipes/decorations/reflector.json (100%) rename {src => common/src}/main/resources/data/solarcooker/advancements/recipes/decorations/solar_cooker.json (100%) rename {src => common/src}/main/resources/data/solarcooker/loot_tables/blocks/reflector.json (100%) rename {src => common/src}/main/resources/data/solarcooker/loot_tables/blocks/shining_diamond_block.json (100%) rename {src => common/src}/main/resources/data/solarcooker/loot_tables/blocks/solar_cooker.json (100%) rename {src => common/src}/main/resources/data/solarcooker/recipes/diamond_block.json (100%) rename {src => common/src}/main/resources/data/solarcooker/recipes/reflector.json (100%) rename {src => common/src}/main/resources/data/solarcooker/recipes/shining_diamond_block.json (100%) rename {src => common/src}/main/resources/data/solarcooker/recipes/solar_cooker.json (100%) rename {src => common/src}/main/resources/data/solarcooker/tags/blocks/solar_cooker_shining.json (100%) rename {src => common/src}/main/resources/logo.png (100%) rename {src => common/src}/main/resources/pack.mcmeta (100%) create mode 100644 forge/build.gradle create mode 100644 forge/src/main/java/de/cech12/solarcooker/ForgeSolarCookerMod.java create mode 100644 forge/src/main/java/de/cech12/solarcooker/blockentity/ForgeSolarCookerBlockEntity.java create mode 100644 forge/src/main/java/de/cech12/solarcooker/init/ModBlockEntityTypes.java create mode 100644 forge/src/main/java/de/cech12/solarcooker/init/ModBlocks.java rename {src/main/java => forge/src/main/java/de}/cech12/solarcooker/init/ModItems.java (65%) create mode 100644 forge/src/main/java/de/cech12/solarcooker/init/ModMenuTypes.java rename {src/main/java => forge/src/main/java/de}/cech12/solarcooker/init/ModRecipeTypes.java (53%) create mode 100644 forge/src/main/java/de/cech12/solarcooker/platform/ForgeConfigHelper.java create mode 100644 forge/src/main/java/de/cech12/solarcooker/platform/ForgePlatformHelper.java create mode 100644 forge/src/main/java/de/cech12/solarcooker/platform/ForgeRegistryHelper.java create mode 100644 forge/src/main/resources/META-INF/mods.toml create mode 100644 forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IConfigHelper create mode 100644 forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IPlatformHelper create mode 100644 forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IRegistryHelper rename {src/test/java => forge/src/test/java/de}/cech12/solarcooker/ReflectorTests.java (96%) rename {src => forge/src}/test/resources/data/solarcooker/structures/compat/reflector_facing_property.nbt (100%) rename {src => forge/src}/test/resources/data/solarcooker/structures/hopper/hoppers.nbt (100%) rename {src => forge/src}/test/resources/data/solarcooker/structures/reflector/reflectors.nbt (100%) rename {src => forge/src}/test/resources/data/solarcooker/structures/reflectortests.north.nbt (100%) rename {src => forge/src}/test/resources/data/solarcooker/structures/reflectortests.north_east.nbt (100%) rename {src => forge/src}/test/resources/data/solarcooker/structures/solarcooker/solarcooker.nbt (100%) create mode 100644 neoforge/build.gradle create mode 100644 neoforge/src/main/java/de/cech12/solarcooker/NeoForgeSolarCookerMod.java create mode 100644 neoforge/src/main/java/de/cech12/solarcooker/blockentity/NeoForgeSolarCookerBlockEntity.java rename {src/main/java => neoforge/src/main/java/de}/cech12/solarcooker/compat/TOPCompat.java (88%) create mode 100644 neoforge/src/main/java/de/cech12/solarcooker/init/ModBlockEntityTypes.java create mode 100644 neoforge/src/main/java/de/cech12/solarcooker/init/ModBlocks.java create mode 100644 neoforge/src/main/java/de/cech12/solarcooker/init/ModItems.java create mode 100644 neoforge/src/main/java/de/cech12/solarcooker/init/ModMenuTypes.java create mode 100644 neoforge/src/main/java/de/cech12/solarcooker/init/ModRecipeTypes.java create mode 100644 neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgeConfigHelper.java create mode 100644 neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgePlatformHelper.java create mode 100644 neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgeRegistryHelper.java create mode 100644 neoforge/src/main/resources/META-INF/mods.toml create mode 100644 neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IConfigHelper create mode 100644 neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IPlatformHelper create mode 100644 neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IRegistryHelper delete mode 100644 src/main/java/cech12/solarcooker/SolarCookerMod.java delete mode 100644 src/main/java/cech12/solarcooker/blockentity/SolarCookerBlockEntity.java delete mode 100644 src/main/java/cech12/solarcooker/config/ServerConfig.java delete mode 100644 src/main/java/cech12/solarcooker/init/ModBlockEntityTypes.java delete mode 100644 src/main/java/cech12/solarcooker/init/ModBlocks.java delete mode 100644 src/main/java/cech12/solarcooker/init/ModMenuTypes.java delete mode 100644 src/main/resources/META-INF/accesstransformer.cfg delete mode 100644 src/main/resources/META-INF/mods.toml diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index eb9d071..e9fb17a 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -14,11 +14,22 @@ body: description: What version of Minecraft were you running? validations: required: true + - type: dropdown + id: modLoader + attributes: + label: Mod Loader + description: What mod loader were you using? + options: + - Fabric + - Forge + - NeoForge + validations: + required: true - type: input id: modLoaderVersion attributes: - label: Forge Version - description: What version of Forge were you using? + label: Mod Loader Version + description: What mod loader version were you using? validations: required: true - type: input diff --git a/.github/workflows/cicd-workflow.yml b/.github/workflows/cicd-workflow.yml index 5992343..7b50259 100644 --- a/.github/workflows/cicd-workflow.yml +++ b/.github/workflows/cicd-workflow.yml @@ -33,42 +33,82 @@ jobs: needs: codeql if: startsWith(github.ref, 'refs/tags/') name: Publish Github - uses: cech12/MinecraftModActions/.github/workflows/publish-github.yml@main + uses: cech12/MinecraftModActions/.github/workflows/multi-publish-github.yml@main with: java-version: 17 mod-name: Solar Cooker mod-id: solarcooker secrets: github-token: ${{ secrets.GITHUB_TOKEN }} - publish-curseforge: + publish-forge-on-curseforge: needs: publish-github if: startsWith(github.ref, 'refs/tags/') - name: Publish Curseforge + name: Publish Forge on Curseforge uses: cech12/MinecraftModActions/.github/workflows/publish-curseforge.yml@main with: java-version: 17 + subproject: forge + title-prefix: forge- curseforge-id: 436874 game-versions: | - 1.20.2 + 1.20.4 release-type: release loaders: | forge secrets: github-token: ${{ secrets.GITHUB_TOKEN }} curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }} - publish-modrinth: + publish-forge-on-modrinth: needs: publish-github if: startsWith(github.ref, 'refs/tags/') - name: Publish Modrinth + name: Publish Forge on Modrinth uses: cech12/MinecraftModActions/.github/workflows/publish-modrinth.yml@main with: java-version: 17 + subproject: forge + title-prefix: forge- modrinth-id: IsSapAeq game-versions: | - 1.20.2 + 1.20.4 release-type: release loaders: | forge secrets: github-token: ${{ secrets.GITHUB_TOKEN }} modrinth-token: ${{ secrets.MODRINTH_API_KEY }} + publish-neoforge-on-curseforge: + needs: publish-github + if: startsWith(github.ref, 'refs/tags/') + name: Publish Neoforge on Curseforge + uses: cech12/MinecraftModActions/.github/workflows/publish-curseforge.yml@main + with: + java-version: 17 + subproject: neoforge + title-prefix: neoforge- + curseforge-id: 436874 + game-versions: | + 1.20.4 + release-type: release + loaders: | + neoforge + secrets: + github-token: ${{ secrets.GITHUB_TOKEN }} + curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }} + publish-neoforge-on-modrinth: + needs: publish-github + if: startsWith(github.ref, 'refs/tags/') + name: Publish Neoforge on Modrinth + uses: cech12/MinecraftModActions/.github/workflows/publish-modrinth.yml@main + with: + java-version: 17 + subproject: neoforge + title-prefix: neoforge- + modrinth-id: IsSapAeq + game-versions: | + 1.20.4 + release-type: release + loaders: | + neoforge + secrets: + github-token: ${{ secrets.GITHUB_TOKEN }} + modrinth-token: ${{ secrets.MODRINTH_API_KEY }} diff --git a/.gitignore b/.gitignore index 5d3192c..33ba68d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ build # other eclipse run +runs run-data # Files from Forge MDK diff --git a/CHANGELOG.md b/CHANGELOG.md index 90f486d..e41d8dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Forge Recommended Versioning](https://mcforge.readthedocs.io/en/latest/conventions/versioning/). +## [1.20.4-3.0.0.0] - 2024-04-08 +### Changed +- updated to Minecraft 1.20.4 (Forge 49.0.38, Neoforge 20.4.225) +- updated JEI support to 1.20.4-17.3.0.49 (Forge & Neoforge) +- updated The One Probe support to 1.20.4_neo-11.0.2-3 (Neoforge) +- rename config option "recipeBlacklist" to "recipeBlockedList" + ## [1.20.2-2.2.0.0] - 2023-10-26 ### Changed - update and move back to Forge 1.20.2-48.0.23 (from NeoForge) until it is stable diff --git a/build.gradle b/build.gradle index bee8f5d..99f0ef6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,174 +1,93 @@ plugins { - id 'eclipse' - id 'idea' - id 'maven-publish' - id 'net.minecraftforge.gradle' version '[6.0,6.2)' + // Required for NeoGradle + id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7" } -version = "${minecraft_version}-${mod_version}" -group = mod_group_id -base { - archivesName = mod_id -} - -// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. -java.toolchain.languageVersion = JavaLanguageVersion.of(17) - -println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" -minecraft { - mappings channel: 'official', version: minecraft_version - - // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game. - // In most cases, it is not necessary to enable. - // enableEclipsePrepareRuns = true - // enableIdeaPrepareRuns = true - - // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game. - // It is REQUIRED to be set to true for this template to function. - // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html - copyIdeResources = true - - // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations. - // The folder name can be set on a run configuration using the "folderName" property. - // By default, the folder name of a run configuration is the name of the Gradle project containing it. - // generateRunFolders = true - - // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information. - accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - - // Default run configurations. - runs { - // applies to all the run configs below - configureEach { - 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' - - mods { - "${mod_id}" { - source sourceSets.main - source sourceSets.test - } - } - } - - client { - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - property 'forge.enabledGameTestNamespaces', mod_id +subprojects { + apply plugin: 'java' + + version "$project.minecraft_version-$project.mod_version" + + java.toolchain.languageVersion = JavaLanguageVersion.of(17) + //java.withSourcesJar() + //java.withJavadocJar() + + jar { + from(rootProject.file("LICENSE")) + manifest { + attributes([ + 'Specification-Title' : mod_id, + 'Specification-Vendor' : mod_author, + 'Specification-Version' : project.jar.archiveVersion, + 'Implementation-Title' : project.name, + 'Implementation-Version' : project.jar.archiveVersion, + 'Implementation-Vendor' : mod_author, + 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + 'Timestamp' : System.currentTimeMillis(), + 'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", + 'Built-On-Minecraft' : minecraft_version + ]) } + } - server { - property 'forge.enabledGameTestNamespaces', mod_id - args '--nogui' - } + //sourcesJar { + // from(rootProject.file("LICENSE")) + //} - gameTestServer { - property 'forge.enabledGameTestNamespaces', mod_id + repositories { + mavenCentral() + maven { + name = 'Sponge / Mixin' + url = 'https://repo.spongepowered.org/repository/maven-public/' } - - data { - // example of overriding the workingDirectory set in configureEach above - workingDirectory project.file('run-data') - - // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. - args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + maven { + name = 'BlameJared Maven (JEI / CraftTweaker / Bookshelf)' + url = 'https://maven.blamejared.com' } } -} -// Include resources generated by data generators. -sourceSets.main.resources { srcDir 'src/generated/resources' } - -repositories { - maven { - // location of the maven that hosts JEI files since January 2023 - name = "Jared's maven" - url = "https://maven.blamejared.com/" - } - maven { - // location of a maven mirror for JEI files, as a fallback - name = "ModMaven" - url = "https://modmaven.k-4u.nl" + tasks.withType(JavaCompile).configureEach { + it.options.encoding = 'UTF-8' + it.options.getRelease().set(17) } - maven { // TOP - url "https://maven.k-4u.nl" - } -} - -dependencies { - minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}" - - // compile against the JEI API but do not include it at runtime - compileOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}-common-api:${project.jei_version}") - compileOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}-forge:${project.jei_version}") - // at runtime, use the full JEI jar - runtimeOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}-forge:${project.jei_version}") - - //implementation fg.deobf("mcjty.theoneprobe:theoneprobe:$top_version") {transitive = false} -} - -tasks.named('processResources', ProcessResources).configure { - var replaceProperties = [ - minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, - forge_version: forge_version, forge_version_range: forge_version_range, - loader_version_range: loader_version_range, - mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, - mod_authors: mod_authors, mod_description: mod_description, mod_issue_tracker: mod_issue_tracker, - mod_url: mod_url, - jei_version_range: jei_version_range, top_version_range: top_version_range - ] - inputs.properties replaceProperties - - filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { - expand replaceProperties + [project: project] - } -} - -tasks.named('jar', Jar).configure { - manifest { - attributes([ - 'Specification-Title' : mod_id, - 'Specification-Vendor' : mod_authors, - 'Specification-Version' : project.jar.archiveVersion, - 'Implementation-Title' : project.name, - 'Implementation-Version' : project.jar.archiveVersion, - 'Implementation-Vendor' : mod_authors, - 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } - - // This is the preferred method to reobfuscate your jar file - finalizedBy 'reobfJar' -} -// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing: -// tasks.named('publish').configure { -// dependsOn 'reobfJar' -// } - -publishing { - publications { - register('mavenJava', MavenPublication) { - artifact jar + processResources { + def expandProps = [ + "version": version, + "group": project.group, //Else we target the task's group. + "minecraft_version": minecraft_version, + "minecraft_version_range": minecraft_version_range, + "forge_version": forge_version, + "forge_version_range": forge_version_range, + "forge_loader_version_range": forge_loader_version_range, + //"fabric_version": fabric_version, + //"fabric_loader_version": fabric_loader_version, + "neoforge_version": neoforge_version, + "neoforge_version_range": neoforge_version_range, + "neoforge_loader_version_range": neoforge_loader_version_range, + "mod_id": mod_id, + "mod_name": mod_name, + "mod_author": mod_author, + "mod_license": mod_license, + "mod_url": mod_url, + "mod_issue_tracker": mod_issue_tracker, + "mod_description": project.description, + "jei_version": jei_version, + "jei_version_range": jei_version_range, + "top_version": top_version, + "top_version_range": top_version_range + ] + + filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', '*.mixins.json']) { + expand expandProps } + inputs.properties(expandProps) } - repositories { - maven { - url "file://${project.projectDir}/mcmodsrepo" - } - } -} -tasks.withType(JavaCompile).configureEach { - options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation -} + // Disables Gradle's custom module metadata from being published to maven. The + // metadata includes mapped dependencies which are not reasonably consumable by + // other mod developers. + tasks.withType(GenerateModuleMetadata).configureEach { + enabled = false + } +} \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 0000000..fd974a9 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,37 @@ +plugins { + id 'idea' + id 'java' + id 'maven-publish' + id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' +} +base { + archivesName = "${mod_id}-common" +} +minecraft { + version(minecraft_version) + if(file("src/main/resources/${mod_id}.accesswidener").exists()){ + accessWideners(file("src/main/resources/${mod_id}.accesswidener")) + } +} + +dependencies { + compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5' + implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1' + + implementation("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}") + implementation("mezz.jei:jei-${minecraft_version}-lib:${jei_version}") +} + +publishing { + publications { + mavenJava(MavenPublication) { + artifactId base.archivesName.get() + from components.java + } + } + repositories { + maven { + url "file://" + System.getenv("local_maven") + } + } +} \ No newline at end of file diff --git a/common/src/main/java/de/cech12/solarcooker/CommonLoader.java b/common/src/main/java/de/cech12/solarcooker/CommonLoader.java new file mode 100644 index 0000000..e47e4a6 --- /dev/null +++ b/common/src/main/java/de/cech12/solarcooker/CommonLoader.java @@ -0,0 +1,19 @@ +package de.cech12.solarcooker; + +import de.cech12.solarcooker.platform.Services; + +/** + * A static class for all loaders which initializes everything which is used by all loaders. + */ +public class CommonLoader { + + /** + * Initialize method that should be called by every loader mod in the constructor. + */ + public static void init() { + Services.CONFIG.init(); + } + + private CommonLoader() {} + +} diff --git a/common/src/main/java/de/cech12/solarcooker/Constants.java b/common/src/main/java/de/cech12/solarcooker/Constants.java new file mode 100644 index 0000000..b68f933 --- /dev/null +++ b/common/src/main/java/de/cech12/solarcooker/Constants.java @@ -0,0 +1,52 @@ +package de.cech12.solarcooker; + +import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; +import de.cech12.solarcooker.crafting.SolarCookingRecipe; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntityType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.function.Supplier; + +/** + * Class that contains all common constants. + */ +public class Constants { + + /** mod id */ + public static final String MOD_ID = "solarcooker"; + /** mod name*/ + public static final String MOD_NAME = "Solar Cooker"; + /** Logger instance */ + public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME); + + public static final String SOLAR_COOKER_NAME = "solar_cooker"; + public static final String REFLECTOR_NAME = "reflector"; + public static final String SHINING_DIAMOND_BLOCK_NAME = "shining_diamond_block"; + + public static final String SOLAR_COOKING_NAME = "solarcooking"; + + public static final String SOLAR_COOKER_MENU_NAME = "solarcooker"; + + public static Supplier SOLAR_COOKER_BLOCK; + public static Supplier REFLECTOR_BLOCK; + public static Supplier SHINING_DIAMOND_BLOCK_BLOCK; + + public static Supplier> SOLAR_COOKER_ENTITY_TYPE; + + public static Supplier SOLAR_COOKER_ITEM; + public static Supplier REFLECTOR_ITEM; + public static Supplier SHINING_DIAMOND_BLOCK_ITEM; + + public static Supplier> SOLAR_COOKING_RECIPE_TYPE; + + public static Supplier> SOLAR_COOKER_MENU_TYPE; + + private Constants() {} + +} \ No newline at end of file diff --git a/src/main/java/cech12/solarcooker/init/ModTags.java b/common/src/main/java/de/cech12/solarcooker/ModTags.java similarity index 61% rename from src/main/java/cech12/solarcooker/init/ModTags.java rename to common/src/main/java/de/cech12/solarcooker/ModTags.java index bb0bb23..11bce32 100644 --- a/src/main/java/cech12/solarcooker/init/ModTags.java +++ b/common/src/main/java/de/cech12/solarcooker/ModTags.java @@ -1,10 +1,9 @@ -package cech12.solarcooker.init; +package de.cech12.solarcooker; -import cech12.solarcooker.SolarCookerMod; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; -import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nonnull; @@ -15,7 +14,7 @@ public static class Blocks { public static final TagKey SOLAR_COOKER_SHINING = tag("solar_cooker_shining"); private static TagKey tag(@Nonnull String name) { - return TagKey.create(ForgeRegistries.BLOCKS.getRegistryKey(), new ResourceLocation(SolarCookerMod.MOD_ID, name)); + return TagKey.create(Registries.BLOCK, new ResourceLocation(Constants.MOD_ID, name)); } } } diff --git a/src/main/java/cech12/solarcooker/block/AbstractSolarCookerBlock.java b/common/src/main/java/de/cech12/solarcooker/block/AbstractSolarCookerBlock.java similarity index 98% rename from src/main/java/cech12/solarcooker/block/AbstractSolarCookerBlock.java rename to common/src/main/java/de/cech12/solarcooker/block/AbstractSolarCookerBlock.java index e06b563..2a10133 100644 --- a/src/main/java/cech12/solarcooker/block/AbstractSolarCookerBlock.java +++ b/common/src/main/java/de/cech12/solarcooker/block/AbstractSolarCookerBlock.java @@ -1,6 +1,6 @@ -package cech12.solarcooker.block; +package de.cech12.solarcooker.block; -import cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; +import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.RenderShape; diff --git a/src/main/java/cech12/solarcooker/block/ReflectorBlock.java b/common/src/main/java/de/cech12/solarcooker/block/ReflectorBlock.java similarity index 97% rename from src/main/java/cech12/solarcooker/block/ReflectorBlock.java rename to common/src/main/java/de/cech12/solarcooker/block/ReflectorBlock.java index 625de4e..b0778a6 100644 --- a/src/main/java/cech12/solarcooker/block/ReflectorBlock.java +++ b/common/src/main/java/de/cech12/solarcooker/block/ReflectorBlock.java @@ -1,6 +1,6 @@ -package cech12.solarcooker.block; +package de.cech12.solarcooker.block; -import cech12.solarcooker.init.ModItems; +import de.cech12.solarcooker.Constants; import net.minecraft.ChatFormatting; import net.minecraft.core.Direction; import net.minecraft.core.BlockPos; @@ -124,7 +124,7 @@ public List getDrops(@Nonnull BlockState state, @Nonnull LootParams.B if (!drops.isEmpty() && count > 1) { //set the count of the dropped reflector blocks ItemStack stack = drops.get(0); - if (stack.getItem().equals(ModItems.REFLECTOR.get())) { + if (stack.getItem().equals(Constants.REFLECTOR_ITEM.get())) { stack.setCount(count); } } @@ -164,7 +164,7 @@ public boolean canBeReplaced(@Nonnull BlockState state, BlockPlaceContext contex return context.getItemInHand().getItem() == this.asItem() && !isFacingTo(state, context.getHorizontalDirection().getOpposite()) || super.canBeReplaced(state, context); } - @Override + //@Override //overrides a Forge & Neoforge method public BlockState rotate(BlockState state, LevelAccessor world, BlockPos pos, Rotation direction) { int bits; if (direction == Rotation.CLOCKWISE_90) { diff --git a/src/main/java/cech12/solarcooker/block/ShiningDiamondBlock.java b/common/src/main/java/de/cech12/solarcooker/block/ShiningDiamondBlock.java similarity index 95% rename from src/main/java/cech12/solarcooker/block/ShiningDiamondBlock.java rename to common/src/main/java/de/cech12/solarcooker/block/ShiningDiamondBlock.java index 65aaf6c..74a1d85 100644 --- a/src/main/java/cech12/solarcooker/block/ShiningDiamondBlock.java +++ b/common/src/main/java/de/cech12/solarcooker/block/ShiningDiamondBlock.java @@ -1,4 +1,4 @@ -package cech12.solarcooker.block; +package de.cech12.solarcooker.block; import net.minecraft.world.level.block.Block; import net.minecraft.world.item.TooltipFlag; diff --git a/src/main/java/cech12/solarcooker/block/SolarCookerBlock.java b/common/src/main/java/de/cech12/solarcooker/block/SolarCookerBlock.java similarity index 72% rename from src/main/java/cech12/solarcooker/block/SolarCookerBlock.java rename to common/src/main/java/de/cech12/solarcooker/block/SolarCookerBlock.java index abd935d..ebaac82 100644 --- a/src/main/java/cech12/solarcooker/block/SolarCookerBlock.java +++ b/common/src/main/java/de/cech12/solarcooker/block/SolarCookerBlock.java @@ -1,9 +1,11 @@ -package cech12.solarcooker.block; +package de.cech12.solarcooker.block; -import cech12.solarcooker.init.ModBlockEntityTypes; -import cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; -import cech12.solarcooker.blockentity.SolarCookerBlockEntity; +import com.mojang.serialization.MapCodec; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; +import de.cech12.solarcooker.platform.Services; import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.BaseEntityBlock; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -15,8 +17,6 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -25,20 +25,28 @@ public class SolarCookerBlock extends AbstractSolarCookerBlock { + public static final MapCodec CODEC = simpleCodec(SolarCookerBlock::new); + public SolarCookerBlock(BlockBehaviour.Properties builder) { super(builder); } + @Override + @Nonnull + protected MapCodec codec() { + return CODEC; + } + @Nullable @Override public BlockEntity newBlockEntity(@Nonnull BlockPos pos, @Nonnull BlockState state) { - return new SolarCookerBlockEntity(pos, state); + return Services.REGISTRY.getNewBlockEntity(pos, state); } @Override @Nullable public BlockEntityTicker getTicker(@Nonnull Level level, @Nonnull BlockState state, @Nonnull BlockEntityType entityType) { - return createTickerHelper(entityType, ModBlockEntityTypes.SOLAR_COOKER.get(), AbstractSolarCookerBlockEntity::tick); + return createTickerHelper(entityType, Constants.SOLAR_COOKER_ENTITY_TYPE.get(), AbstractSolarCookerBlockEntity::tick); } /** @@ -48,8 +56,8 @@ public BlockEntityTicker getTicker(@Nonnull Level lev @Override protected void interactWith(Level worldIn, @Nonnull BlockPos pos, @Nonnull Player player) { BlockEntity blockEntity = worldIn.getBlockEntity(pos); - if (blockEntity instanceof SolarCookerBlockEntity && player instanceof ServerPlayer) { - player.openMenu((SolarCookerBlockEntity) blockEntity); + if (blockEntity instanceof AbstractSolarCookerBlockEntity && player instanceof ServerPlayer) { + player.openMenu((AbstractSolarCookerBlockEntity) blockEntity); } } @@ -57,7 +65,6 @@ protected void interactWith(Level worldIn, @Nonnull BlockPos pos, @Nonnull Playe * Called periodically clientside on blocks near the player to show effects (like furnace fire particles). */ @Override - @OnlyIn(Dist.CLIENT) public void animateTick(BlockState stateIn, @Nonnull Level worldIn, @Nonnull BlockPos pos, @Nonnull RandomSource rand) { if (stateIn.getValue(BURNING)) { double d0 = (double)pos.getX() + 0.5D; diff --git a/src/main/java/cech12/solarcooker/blockentity/AbstractSolarCookerBlockEntity.java b/common/src/main/java/de/cech12/solarcooker/blockentity/AbstractSolarCookerBlockEntity.java similarity index 92% rename from src/main/java/cech12/solarcooker/blockentity/AbstractSolarCookerBlockEntity.java rename to common/src/main/java/de/cech12/solarcooker/blockentity/AbstractSolarCookerBlockEntity.java index 28acb66..45586ef 100644 --- a/src/main/java/cech12/solarcooker/blockentity/AbstractSolarCookerBlockEntity.java +++ b/common/src/main/java/de/cech12/solarcooker/blockentity/AbstractSolarCookerBlockEntity.java @@ -1,13 +1,18 @@ -package cech12.solarcooker.blockentity; +package de.cech12.solarcooker.blockentity; -import cech12.solarcooker.block.AbstractSolarCookerBlock; -import cech12.solarcooker.block.ReflectorBlock; -import cech12.solarcooker.block.SolarCookerBlock; -import cech12.solarcooker.config.ServerConfig; -import cech12.solarcooker.init.ModTags; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.ModTags; +import de.cech12.solarcooker.block.AbstractSolarCookerBlock; +import de.cech12.solarcooker.block.ReflectorBlock; +import de.cech12.solarcooker.block.SolarCookerBlock; import com.google.common.collect.Lists; +import de.cech12.solarcooker.inventory.SolarCookerContainer; +import de.cech12.solarcooker.platform.Services; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.ContainerData; import net.minecraft.world.inventory.RecipeCraftingHolder; import net.minecraft.world.item.crafting.RecipeHolder; @@ -39,11 +44,6 @@ import net.minecraft.util.Mth; import net.minecraft.world.phys.Vec3; import net.minecraft.world.level.Level; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.wrapper.SidedInvWrapper; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -83,6 +83,10 @@ public AbstractSolarCookerBlockEntity(BlockEntityType tileTypeIn, BlockPos po this.specificRecipeType = specificRecipeTypeIn; } + public AbstractSolarCookerBlockEntity(BlockPos pos, BlockState state) { + this(Constants.SOLAR_COOKER_ENTITY_TYPE.get(), pos, state, Constants.SOLAR_COOKING_RECIPE_TYPE.get()); + } + protected RecipeHolder curRecipe; protected ItemStack failedMatch = ItemStack.EMPTY; @@ -112,6 +116,18 @@ public int getCount() { } }; + @Override + @Nonnull + protected Component getDefaultName() { + return Component.translatable("block.solarcooker.solar_cooker"); + } + + @Override + @Nonnull + protected AbstractContainerMenu createMenu(int id, @Nonnull Inventory player) { + return new SolarCookerContainer(specificRecipeType, id, player, this, this.dataAccess); + } + private boolean hasShiningBlockAbove() { if (this.level != null && !this.level.isClientSide) { BlockPos checkPos = this.worldPosition.above(); @@ -184,7 +200,7 @@ public ClientboundBlockEntityDataPacket getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } - @Override + //@Override //overrides a Forge / Neoforge method ?! TODO public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { this.load(pkt.getTag()); } @@ -350,11 +366,11 @@ protected int getRecipeCookTime() { return 200; } this.checkForReflectors(); - double reflectorFactor = (this.reflectorCount > 0) ? 1 - ((1 - ServerConfig.MAX_REFLECTOR_TIME_FACTOR.get()) / 4.0D) * this.reflectorCount : 1; + double reflectorFactor = (this.reflectorCount > 0) ? 1 - ((1 - Services.CONFIG.getMaxReflectorTimeFactor()) / 4.0D) * this.reflectorCount : 1; if (this.specificRecipeType.getClass().isInstance(rec.value().getType())) { return (int) (rec.value().getCookingTime() * reflectorFactor); } - return (int) (rec.value().getCookingTime() * (ServerConfig.COOK_TIME_FACTOR.get() * reflectorFactor)); + return (int) (rec.value().getCookingTime() * (Services.CONFIG.getCookTimeFactor() * reflectorFactor)); } @SuppressWarnings("unchecked") @@ -369,9 +385,9 @@ protected RecipeHolder getRecipe() { RecipeHolder rec = null; if (this.level != null) { rec = this.level.getRecipeManager().getRecipeFor((RecipeType) this.specificRecipeType, this, this.level).orElse(null); - if (rec == null && ServerConfig.VANILLA_RECIPES_ENABLED.get()) { - rec = this.level.getRecipeManager().getRecipesFor((RecipeType) ServerConfig.getRecipeType(), this, this.level) - .stream().filter(abstractCookingRecipe -> ServerConfig.isRecipeNotBlacklisted(abstractCookingRecipe.id())).findFirst().orElse(null); + if (rec == null && Services.CONFIG.areVanillaRecipesEnabled()) { + rec = this.level.getRecipeManager().getRecipesFor((RecipeType) Services.CONFIG.getRecipeType(), this, this.level) + .stream().filter(abstractCookingRecipe -> Services.CONFIG.isRecipeAllowed(abstractCookingRecipe.id())).findFirst().orElse(null); } } if (rec == null) { @@ -577,26 +593,6 @@ public void fillStackedContents(@Nonnull StackedContents helper) { } } - LazyOptional[] handlers = SidedInvWrapper.create(this, Direction.UP, Direction.NORTH); - - @Override - @Nonnull - public LazyOptional getCapability(@Nonnull Capability capability, @Nullable Direction facing) { - if (!this.remove && facing != null && capability == ForgeCapabilities.ITEM_HANDLER) { - if (facing == Direction.UP) - return handlers[0].cast(); - else - return handlers[1].cast(); - } - return super.getCapability(capability, facing); - } - - @Override - public void invalidateCaps() { - super.invalidateCaps(); - for (LazyOptional handler : handlers) handler.invalidate(); - } - @Override public float getOpenNess(float partialTicks) { if (this.level != null) { diff --git a/src/main/java/cech12/solarcooker/client/SolarCookerBlockEntityRenderer.java b/common/src/main/java/de/cech12/solarcooker/client/SolarCookerBlockEntityRenderer.java similarity index 87% rename from src/main/java/cech12/solarcooker/client/SolarCookerBlockEntityRenderer.java rename to common/src/main/java/de/cech12/solarcooker/client/SolarCookerBlockEntityRenderer.java index c8e273e..a37a667 100644 --- a/src/main/java/cech12/solarcooker/client/SolarCookerBlockEntityRenderer.java +++ b/common/src/main/java/de/cech12/solarcooker/client/SolarCookerBlockEntityRenderer.java @@ -1,9 +1,8 @@ -package cech12.solarcooker.client; +package de.cech12.solarcooker.client; -import cech12.solarcooker.SolarCookerMod; -import cech12.solarcooker.block.AbstractSolarCookerBlock; -import cech12.solarcooker.init.ModBlocks; -import cech12.solarcooker.blockentity.SolarCookerBlockEntity; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.block.AbstractSolarCookerBlock; +import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; @@ -30,9 +29,9 @@ import javax.annotation.Nonnull; -public class SolarCookerBlockEntityRenderer implements BlockEntityRenderer { +public class SolarCookerBlockEntityRenderer implements BlockEntityRenderer { - public static final ResourceLocation TEXTURE = new ResourceLocation(SolarCookerMod.MOD_ID, "textures/entity/solar_cooker.png"); + public static final ResourceLocation TEXTURE = new ResourceLocation(Constants.MOD_ID, "textures/entity/solar_cooker.png"); private static final LayerDefinition innerCube = createInnerLayerDefinition(); @@ -57,10 +56,10 @@ public SolarCookerBlockEntityRenderer(BlockEntityRendererProvider.Context render } @Override - public void render(SolarCookerBlockEntity blockEntity, float partialTicks, @Nonnull PoseStack matrixStackIn, @Nonnull MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { + public void render(AbstractSolarCookerBlockEntity blockEntity, float partialTicks, @Nonnull PoseStack matrixStackIn, @Nonnull MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { Level world = blockEntity.getLevel(); boolean isInWorld = world != null; - BlockState blockstate = isInWorld ? blockEntity.getBlockState() : ModBlocks.SOLAR_COOKER.get().defaultBlockState().setValue(ChestBlock.FACING, Direction.SOUTH); + BlockState blockstate = isInWorld ? blockEntity.getBlockState() : Constants.SOLAR_COOKER_BLOCK.get().defaultBlockState().setValue(ChestBlock.FACING, Direction.SOUTH); Block block = blockstate.getBlock(); if (block instanceof AbstractSolarCookerBlock) { //AbstractSolarCookerBlock abstractBlock = (AbstractSolarCookerBlock)block; diff --git a/src/main/java/cech12/solarcooker/client/SolarCookerScreen.java b/common/src/main/java/de/cech12/solarcooker/client/SolarCookerScreen.java similarity index 85% rename from src/main/java/cech12/solarcooker/client/SolarCookerScreen.java rename to common/src/main/java/de/cech12/solarcooker/client/SolarCookerScreen.java index 921605b..98346ca 100644 --- a/src/main/java/cech12/solarcooker/client/SolarCookerScreen.java +++ b/common/src/main/java/de/cech12/solarcooker/client/SolarCookerScreen.java @@ -1,20 +1,17 @@ -package cech12.solarcooker.client; +package de.cech12.solarcooker.client; -import cech12.solarcooker.SolarCookerMod; -import cech12.solarcooker.inventory.SolarCookerContainer; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.inventory.SolarCookerContainer; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.world.entity.player.Inventory; import net.minecraft.resources.ResourceLocation; import net.minecraft.network.chat.Component; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) public class SolarCookerScreen extends AbstractContainerScreen { - private static final ResourceLocation guiTexture = new ResourceLocation(SolarCookerMod.MOD_ID, "textures/gui/container/solar_cooker.png"); + private static final ResourceLocation guiTexture = new ResourceLocation(Constants.MOD_ID, "textures/gui/container/solar_cooker.png"); public SolarCookerScreen(SolarCookerContainer screenContainer, Inventory inv, Component titleIn) { super(screenContainer, inv, titleIn); diff --git a/src/main/java/cech12/solarcooker/crafting/SolarCookingRecipe.java b/common/src/main/java/de/cech12/solarcooker/crafting/SolarCookingRecipe.java similarity index 76% rename from src/main/java/cech12/solarcooker/crafting/SolarCookingRecipe.java rename to common/src/main/java/de/cech12/solarcooker/crafting/SolarCookingRecipe.java index 8ea01ea..40d9e0a 100644 --- a/src/main/java/cech12/solarcooker/crafting/SolarCookingRecipe.java +++ b/common/src/main/java/de/cech12/solarcooker/crafting/SolarCookingRecipe.java @@ -1,8 +1,7 @@ -package cech12.solarcooker.crafting; +package de.cech12.solarcooker.crafting; -import cech12.solarcooker.config.ServerConfig; -import cech12.solarcooker.init.ModBlocks; -import cech12.solarcooker.init.ModRecipeTypes; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.platform.Services; import net.minecraft.core.RegistryAccess; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.AbstractCookingRecipe; @@ -18,17 +17,17 @@ public class SolarCookingRecipe extends AbstractCookingRecipe { public static final SimpleCookingSerializer SERIALIZER = new SimpleCookingSerializer<>(SolarCookingRecipe::new, 200); public SolarCookingRecipe(String p_i50031_2_, CookingBookCategory category, Ingredient p_i50031_3_, ItemStack p_i50031_4_, float p_i50031_5_, int p_i50031_6_) { - super(ModRecipeTypes.SOLAR_COOKING.get(), p_i50031_2_, category, p_i50031_3_, p_i50031_4_, p_i50031_5_, p_i50031_6_); + super(Constants.SOLAR_COOKING_RECIPE_TYPE.get(), p_i50031_2_, category, p_i50031_3_, p_i50031_4_, p_i50031_5_, p_i50031_6_); } public static SolarCookingRecipe convert(@Nonnull AbstractCookingRecipe recipe, RegistryAccess registryAccess) { - return new SolarCookingRecipe(recipe.getGroup(), recipe.category(), recipe.getIngredients().get(0), recipe.getResultItem(registryAccess), recipe.getExperience(), (int) (recipe.getCookingTime() * ServerConfig.COOK_TIME_FACTOR.get())); + return new SolarCookingRecipe(recipe.getGroup(), recipe.category(), recipe.getIngredients().get(0), recipe.getResultItem(registryAccess), recipe.getExperience(), (int) (recipe.getCookingTime() * Services.CONFIG.getCookTimeFactor())); } @Override @Nonnull public ItemStack getToastSymbol() { - return new ItemStack(ModBlocks.SOLAR_COOKER.get()); + return new ItemStack(Constants.SOLAR_COOKER_BLOCK.get()); } @Override diff --git a/src/main/java/cech12/solarcooker/inventory/SolarCookerContainer.java b/common/src/main/java/de/cech12/solarcooker/inventory/SolarCookerContainer.java similarity index 88% rename from src/main/java/cech12/solarcooker/inventory/SolarCookerContainer.java rename to common/src/main/java/de/cech12/solarcooker/inventory/SolarCookerContainer.java index c5531e9..6de80a9 100644 --- a/src/main/java/cech12/solarcooker/inventory/SolarCookerContainer.java +++ b/common/src/main/java/de/cech12/solarcooker/inventory/SolarCookerContainer.java @@ -1,8 +1,8 @@ -package cech12.solarcooker.inventory; +package de.cech12.solarcooker.inventory; -import cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; -import cech12.solarcooker.config.ServerConfig; -import cech12.solarcooker.init.ModMenuTypes; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; +import de.cech12.solarcooker.platform.Services; import net.minecraft.world.Container; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Inventory; @@ -12,8 +12,6 @@ import net.minecraft.world.item.crafting.AbstractCookingRecipe; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nonnull; @@ -25,9 +23,9 @@ public class SolarCookerContainer extends AbstractContainerMenu { public SolarCookerContainer(RecipeType specificRecipeTypeIn, int id, Inventory playerInventoryIn, Container cooker, ContainerData data) { - super(ModMenuTypes.SOLAR_COOKER.get(), id); + super(Constants.SOLAR_COOKER_MENU_TYPE.get(), id); this.specificRecipeType = specificRecipeTypeIn; - checkContainerSize(cooker, 2); + AbstractContainerMenu.checkContainerSize(cooker, 2); this.cooker = cooker; this.data = data; cooker.startOpen(playerInventoryIn.player); @@ -118,9 +116,9 @@ protected boolean hasRecipe(ItemStack stack) { if (this.world.getRecipeManager().getRecipeFor(this.specificRecipeType, new SimpleContainer(stack), this.world).isPresent()) { return true; } - if (ServerConfig.VANILLA_RECIPES_ENABLED.get()) { - return this.world.getRecipeManager().getRecipesFor(ServerConfig.getRecipeType(), new SimpleContainer(stack), this.world) - .stream().anyMatch(abstractCookingRecipe -> ServerConfig.isRecipeNotBlacklisted(abstractCookingRecipe.id())); + if (Services.CONFIG.areVanillaRecipesEnabled()) { + return this.world.getRecipeManager().getRecipesFor(Services.CONFIG.getRecipeType(), new SimpleContainer(stack), this.world) + .stream().anyMatch(abstractCookingRecipe -> Services.CONFIG.isRecipeAllowed(abstractCookingRecipe.id())); } } return false; @@ -135,19 +133,16 @@ public void removed(@Nonnull Player playerIn) { this.cooker.stopOpen(playerIn); } - @OnlyIn(Dist.CLIENT) public int getCookProgressionScaled() { int i = this.data.get(AbstractSolarCookerBlockEntity.CONTAINER_COOK_TIME); int j = this.data.get(AbstractSolarCookerBlockEntity.CONTAINER_COOK_TIME_TOTAL); return j != 0 && i != 0 ? i * 24 / j : 0; } - @OnlyIn(Dist.CLIENT) public boolean isBurning() { return this.data.get(AbstractSolarCookerBlockEntity.CONTAINER_COOK_TIME) > 0; } - @OnlyIn(Dist.CLIENT) public boolean isSunlit() { return this.data.get(AbstractSolarCookerBlockEntity.CONTAINER_IS_SUNLIT) > 0; } diff --git a/src/main/java/cech12/solarcooker/inventory/SolarCookerResultSlot.java b/common/src/main/java/de/cech12/solarcooker/inventory/SolarCookerResultSlot.java similarity index 88% rename from src/main/java/cech12/solarcooker/inventory/SolarCookerResultSlot.java rename to common/src/main/java/de/cech12/solarcooker/inventory/SolarCookerResultSlot.java index ee05f6d..0b6ebae 100644 --- a/src/main/java/cech12/solarcooker/inventory/SolarCookerResultSlot.java +++ b/common/src/main/java/de/cech12/solarcooker/inventory/SolarCookerResultSlot.java @@ -1,6 +1,6 @@ -package cech12.solarcooker.inventory; +package de.cech12.solarcooker.inventory; -import cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; +import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.Container; import net.minecraft.world.inventory.FurnaceResultSlot; diff --git a/src/main/java/cech12/solarcooker/jei/SolarCookerJEIPlugin.java b/common/src/main/java/de/cech12/solarcooker/jei/SolarCookerJEIPlugin.java similarity index 70% rename from src/main/java/cech12/solarcooker/jei/SolarCookerJEIPlugin.java rename to common/src/main/java/de/cech12/solarcooker/jei/SolarCookerJEIPlugin.java index 861278f..6584f6c 100644 --- a/src/main/java/cech12/solarcooker/jei/SolarCookerJEIPlugin.java +++ b/common/src/main/java/de/cech12/solarcooker/jei/SolarCookerJEIPlugin.java @@ -1,10 +1,8 @@ -package cech12.solarcooker.jei; +package de.cech12.solarcooker.jei; -import cech12.solarcooker.SolarCookerMod; -import cech12.solarcooker.config.ServerConfig; -import cech12.solarcooker.crafting.SolarCookingRecipe; -import cech12.solarcooker.init.ModBlocks; -import cech12.solarcooker.init.ModRecipeTypes; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.crafting.SolarCookingRecipe; +import de.cech12.solarcooker.platform.Services; import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; import mezz.jei.api.helpers.IGuiHelper; @@ -29,7 +27,7 @@ public class SolarCookerJEIPlugin implements IModPlugin { @Override @Nonnull public ResourceLocation getPluginUid() { - return new ResourceLocation(SolarCookerMod.MOD_ID, "plugin_" + SolarCookerMod.MOD_ID); + return new ResourceLocation(Constants.MOD_ID, "plugin_" + Constants.MOD_ID); } @Override @@ -44,11 +42,11 @@ public void registerRecipes(@Nonnull IRecipeRegistration registration) { LocalPlayer player = Minecraft.getInstance().player; if (player != null) { RecipeManager manager = player.connection.getRecipeManager(); - registration.addRecipes(solarCookingCategory.getRecipeType(), manager.getAllRecipesFor(ModRecipeTypes.SOLAR_COOKING.get())); + registration.addRecipes(solarCookingCategory.getRecipeType(), manager.getAllRecipesFor(Constants.SOLAR_COOKING_RECIPE_TYPE.get())); - if (ServerConfig.VANILLA_RECIPES_ENABLED.get()) { - registration.addRecipes(solarCookingCategory.getRecipeType(), manager.getAllRecipesFor(ServerConfig.getRecipeType()).stream() - .filter(recipe -> ServerConfig.isRecipeNotBlacklisted(recipe.id())) + if (Services.CONFIG.areVanillaRecipesEnabled()) { + registration.addRecipes(solarCookingCategory.getRecipeType(), manager.getAllRecipesFor(Services.CONFIG.getRecipeType()).stream() + .filter(recipe -> Services.CONFIG.isRecipeAllowed(recipe.id())) .map(recipe -> new RecipeHolder<>(recipe.id(), SolarCookingRecipe.convert(recipe.value(), player.level().registryAccess()))) .collect(Collectors.toList())); } @@ -58,7 +56,7 @@ public void registerRecipes(@Nonnull IRecipeRegistration registration) { @Override public void registerRecipeCatalysts(@Nonnull IRecipeCatalystRegistration registration) { - registration.addRecipeCatalyst(new ItemStack(ModBlocks.SOLAR_COOKER.get()), solarCookingCategory.getRecipeType()); + registration.addRecipeCatalyst(new ItemStack(Constants.SOLAR_COOKER_BLOCK.get()), solarCookingCategory.getRecipeType()); } } diff --git a/src/main/java/cech12/solarcooker/jei/SolarCookingCategory.java b/common/src/main/java/de/cech12/solarcooker/jei/SolarCookingCategory.java similarity index 57% rename from src/main/java/cech12/solarcooker/jei/SolarCookingCategory.java rename to common/src/main/java/de/cech12/solarcooker/jei/SolarCookingCategory.java index 4fb148d..57a2dd9 100644 --- a/src/main/java/cech12/solarcooker/jei/SolarCookingCategory.java +++ b/common/src/main/java/de/cech12/solarcooker/jei/SolarCookingCategory.java @@ -1,12 +1,12 @@ -package cech12.solarcooker.jei; +package de.cech12.solarcooker.jei; -import cech12.solarcooker.config.ServerConfig; -import cech12.solarcooker.crafting.SolarCookingRecipe; -import cech12.solarcooker.init.ModBlocks; -import cech12.solarcooker.init.ModRecipeTypes; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.crafting.SolarCookingRecipe; +import de.cech12.solarcooker.platform.Services; import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.recipe.RecipeType; import mezz.jei.library.plugins.vanilla.cooking.AbstractCookingCategory; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.RecipeHolder; import javax.annotation.Nonnull; @@ -14,14 +14,14 @@ public class SolarCookingCategory extends AbstractCookingCategory { public SolarCookingCategory(IGuiHelper guiHelper) { - super(guiHelper, ModBlocks.SOLAR_COOKER.get(), "gui.jei.category.smelting", (int) (200 * ServerConfig.COOK_TIME_FACTOR.get())); + super(guiHelper, Constants.SOLAR_COOKER_BLOCK.get(), "gui.jei.category.smelting", (int) (200 * Services.CONFIG.getCookTimeFactor())); } @Override @Nonnull public RecipeType> getRecipeType() { Class> holderClass = (Class>) (Object) RecipeHolder.class; - return new RecipeType<>(ModRecipeTypes.SOLAR_COOKING.getId(), holderClass); + return new RecipeType<>(new ResourceLocation(Constants.MOD_ID, Constants.SOLAR_COOKING_NAME), holderClass); } } diff --git a/common/src/main/java/de/cech12/solarcooker/platform/Services.java b/common/src/main/java/de/cech12/solarcooker/platform/Services.java new file mode 100644 index 0000000..db9d55e --- /dev/null +++ b/common/src/main/java/de/cech12/solarcooker/platform/Services.java @@ -0,0 +1,43 @@ +package de.cech12.solarcooker.platform; + +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.platform.services.IConfigHelper; +import de.cech12.solarcooker.platform.services.IPlatformHelper; +import de.cech12.solarcooker.platform.services.IRegistryHelper; + +import java.util.ServiceLoader; + +/** + * Service loaders are a built-in Java feature that allow us to locate implementations of an interface that vary from one + * environment to another. In the context of MultiLoader we use this feature to access a mock API in the common code that + * is swapped out for the platform specific implementation at runtime. + */ +public class Services { + + /** Config instance */ + public static final IConfigHelper CONFIG = load(IConfigHelper.class); + /** Platform instance */ + public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class); + /** Registry instance */ + public static final IRegistryHelper REGISTRY = load(IRegistryHelper.class); + + /** + * This code is used to load a service for the current environment. Your implementation of the service must be defined + * manually by including a text file in META-INF/services named with the fully qualified class name of the service. + * Inside the file you should write the fully qualified class name of the implementation to load for the platform. For + * example our file on Forge points to ForgePlatformHelper while Fabric points to FabricPlatformHelper. + * @param clazz Service class, which should be loaded. + * @return service instance + * @param Type of service class + */ + public static T load(Class clazz) { + final T loadedService = ServiceLoader.load(clazz) + .findFirst() + .orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName())); + Constants.LOG.debug("Loaded {} for service {}", loadedService, clazz); + return loadedService; + } + + private Services() {} + +} \ No newline at end of file diff --git a/common/src/main/java/de/cech12/solarcooker/platform/services/IConfigHelper.java b/common/src/main/java/de/cech12/solarcooker/platform/services/IConfigHelper.java new file mode 100644 index 0000000..21fd733 --- /dev/null +++ b/common/src/main/java/de/cech12/solarcooker/platform/services/IConfigHelper.java @@ -0,0 +1,107 @@ +package de.cech12.solarcooker.platform.services; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.AbstractCookingRecipe; +import net.minecraft.world.item.crafting.RecipeType; + +/** + * Common configuration helper service interface. + */ +public interface IConfigHelper { + + /** Default value of the vanilla recipe enabled option */ + boolean VANILLA_RECIPES_ENABLED_DEFAULT = true; + /** Config description of the vanilla recipe enabled option */ + String VANILLA_RECIPES_ENABLED_DESCRIPTION = "If enabled, the vanilla blasting, smelting, or smoking recipes are used by the solar cooker."; + + /** Default value of the vanilla recipe type option */ + RecipeType VANILLA_RECIPE_TYPE_DEFAULT = RecipeType.SMOKING; + /** Config description of the vanilla recipe type option */ + String VANILLA_RECIPE_TYPE_DESCRIPTION = "Defines which vanilla recipes the solar cooker can use. Possible values: \"smoking\" (default), \"smelting\", \"blasting\", \"campfire_cooking\""; + + /** Default value of the cook time factor option */ + double COOK_TIME_FACTOR_DEFAULT = 4D; + /** Config description of the cook time factor option */ + String COOK_TIME_FACTOR_DESCRIPTION = "Cook time factor of the solar cooker in relation to corresponding vanilla furnace. (i. e. 0.5 - half the time, 1.0 same time, 2.0 twice the time)"; + /** Minimal value of the cook time factor option */ + double COOK_TIME_FACTOR_MIN = 0D; + /** Maximal value of the cook time factor option */ + double COOK_TIME_FACTOR_MAX = 100D; + + /** Default value of the max reflector time factor option */ + double MAX_REFLECTOR_TIME_FACTOR_DEFAULT = 0.25D; + /** Config description of the max reflector time factor option */ + String MAX_REFLECTOR_TIME_FACTOR_DESCRIPTION = "Speed factor when all 4 reflectors are placed next to the solar cooker. (i. e. 0.5 - half the time, 1.0 same time)"; + /** Minimal value of the max reflector time factor option */ + double MAX_REFLECTOR_TIME_FACTOR_MIN = 0D; + /** Maximal value of the max reflector time factor option */ + double MAX_REFLECTOR_TIME_FACTOR_MAX = 1D; + + /** Default value of the recipe blocked list option */ + String RECIPE_BLOCKED_LIST_DEFAULT = ""; + /** Config description of the recipe blocked list option */ + String RECIPE_BLOCKED_LIST_DESCRIPTION = "A comma separated list of all vanilla recipes that should not be used by the brick furnaces. Example: \"baked_potato,baked_potato_from_smoking,othermod:other_baked_food\""; + + /** + * Initialization method for the Service implementations. + */ + void init(); + + /** + * Gets the configured value of the vanilla recipe enabled option. + * + * @return configured value of the vanilla recipe enabled option + */ + boolean areVanillaRecipesEnabled(); + + /** + * Gets the configured value of the vanilla recipe type option. + * + * @return configured value of the vanilla recipe type option + */ + RecipeType getRecipeType(); + + /** + * Gets the configured value of the cook time factor option. + * + * @return configured value of the cook time factor option + */ + double getCookTimeFactor(); + + /** + * Gets the configured value of the max reflector time factor option. + * + * @return configured value of the max reflector time factor option + */ + double getMaxReflectorTimeFactor(); + + /** + * Gets the configured value of the recipe blocked list option. + * + * @return configured value of the recipe blocked list option + */ + String getRecipeBlockedList(); + + /** + * Checks if the given ResourceLocation is allowed taking into account the recipe blocked list. + * @param id ResourceLocation of recipe + * @return true, if recipe is allowed, else false + */ + default boolean isRecipeAllowed(final ResourceLocation id) { + String configValue = getRecipeBlockedList().trim(); + if (!configValue.isEmpty()) { + String[] ids = configValue.split(","); + if (ids.length < 1) { + return !(new ResourceLocation(configValue).equals(id)); + } else { + for (String recipeId : ids) { + if (new ResourceLocation(recipeId.trim()).equals(id)) { + return false; + } + } + } + } + return true; + } + +} \ No newline at end of file diff --git a/common/src/main/java/de/cech12/solarcooker/platform/services/IPlatformHelper.java b/common/src/main/java/de/cech12/solarcooker/platform/services/IPlatformHelper.java new file mode 100644 index 0000000..faf3e2f --- /dev/null +++ b/common/src/main/java/de/cech12/solarcooker/platform/services/IPlatformHelper.java @@ -0,0 +1,41 @@ +package de.cech12.solarcooker.platform.services; + +import net.minecraft.world.item.ItemStack; + +/** + * Common platform helper service interface. + */ +public interface IPlatformHelper { + + /** + * Gets the name of the current platform + * + * @return The name of the current platform. + */ + String getPlatformName(); + + /** + * Checks if a mod with the given id is loaded. + * + * @param modId The mod to check if it is loaded. + * @return True if the mod is loaded, false otherwise. + */ + boolean isModLoaded(String modId); + + /** + * Check if the game is currently in a development environment. + * + * @return True if in a development environment, false otherwise. + */ + boolean isDevelopmentEnvironment(); + + /** + * Gets the name of the environment type as a string. + * + * @return The name of the environment type. + */ + default String getEnvironmentName() { + return isDevelopmentEnvironment() ? "development" : "production"; + } + +} \ No newline at end of file diff --git a/common/src/main/java/de/cech12/solarcooker/platform/services/IRegistryHelper.java b/common/src/main/java/de/cech12/solarcooker/platform/services/IRegistryHelper.java new file mode 100644 index 0000000..9ab34fe --- /dev/null +++ b/common/src/main/java/de/cech12/solarcooker/platform/services/IRegistryHelper.java @@ -0,0 +1,16 @@ +package de.cech12.solarcooker.platform.services; + +import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; + +import javax.annotation.Nonnull; + +/** + * Common registry helper service interface. + */ +public interface IRegistryHelper { + + AbstractSolarCookerBlockEntity getNewBlockEntity(@Nonnull BlockPos pos, @Nonnull BlockState state); + +} diff --git a/src/main/resources/assets/solarcooker/blockstates/reflector.json b/common/src/main/resources/assets/solarcooker/blockstates/reflector.json similarity index 100% rename from src/main/resources/assets/solarcooker/blockstates/reflector.json rename to common/src/main/resources/assets/solarcooker/blockstates/reflector.json diff --git a/src/main/resources/assets/solarcooker/blockstates/shining_diamond_block.json b/common/src/main/resources/assets/solarcooker/blockstates/shining_diamond_block.json similarity index 100% rename from src/main/resources/assets/solarcooker/blockstates/shining_diamond_block.json rename to common/src/main/resources/assets/solarcooker/blockstates/shining_diamond_block.json diff --git a/src/main/resources/assets/solarcooker/blockstates/solar_cooker.json b/common/src/main/resources/assets/solarcooker/blockstates/solar_cooker.json similarity index 100% rename from src/main/resources/assets/solarcooker/blockstates/solar_cooker.json rename to common/src/main/resources/assets/solarcooker/blockstates/solar_cooker.json diff --git a/src/main/resources/assets/solarcooker/lang/de_de.json b/common/src/main/resources/assets/solarcooker/lang/de_de.json similarity index 100% rename from src/main/resources/assets/solarcooker/lang/de_de.json rename to common/src/main/resources/assets/solarcooker/lang/de_de.json diff --git a/src/main/resources/assets/solarcooker/lang/en_us.json b/common/src/main/resources/assets/solarcooker/lang/en_us.json similarity index 100% rename from src/main/resources/assets/solarcooker/lang/en_us.json rename to common/src/main/resources/assets/solarcooker/lang/en_us.json diff --git a/src/main/resources/assets/solarcooker/lang/pt_br.json b/common/src/main/resources/assets/solarcooker/lang/pt_br.json similarity index 98% rename from src/main/resources/assets/solarcooker/lang/pt_br.json rename to common/src/main/resources/assets/solarcooker/lang/pt_br.json index 950ad2d..2fad183 100644 --- a/src/main/resources/assets/solarcooker/lang/pt_br.json +++ b/common/src/main/resources/assets/solarcooker/lang/pt_br.json @@ -1,8 +1,8 @@ -{ - "block.solarcooker.solar_cooker": "Fogão Solar", - "block.solarcooker.reflector": "Refletor", - "block.solarcooker.shining_diamond_block": "Bloco brilhante de diamante", - - "item.solarcooker.reflector.description": "Até quatro Refletores podem ser colocados à esquerda e à direita de um Fogão Solar para melhorar a incidência de luz e reduzir o tempo de cozimento.", - "item.solarcooker.shining_diamond_block.description": "Brilhar! Pode ser colocado por cima de um Fogão Solar para o utilizar independentemente do sol." +{ + "block.solarcooker.solar_cooker": "Fogão Solar", + "block.solarcooker.reflector": "Refletor", + "block.solarcooker.shining_diamond_block": "Bloco brilhante de diamante", + + "item.solarcooker.reflector.description": "Até quatro Refletores podem ser colocados à esquerda e à direita de um Fogão Solar para melhorar a incidência de luz e reduzir o tempo de cozimento.", + "item.solarcooker.shining_diamond_block.description": "Brilhar! Pode ser colocado por cima de um Fogão Solar para o utilizar independentemente do sol." } \ No newline at end of file diff --git a/src/main/resources/assets/solarcooker/lang/ru_ru.json b/common/src/main/resources/assets/solarcooker/lang/ru_ru.json similarity index 100% rename from src/main/resources/assets/solarcooker/lang/ru_ru.json rename to common/src/main/resources/assets/solarcooker/lang/ru_ru.json diff --git a/src/main/resources/assets/solarcooker/lang/uk_ua.json b/common/src/main/resources/assets/solarcooker/lang/uk_ua.json similarity index 100% rename from src/main/resources/assets/solarcooker/lang/uk_ua.json rename to common/src/main/resources/assets/solarcooker/lang/uk_ua.json diff --git a/src/main/resources/assets/solarcooker/lang/zh_cn.json b/common/src/main/resources/assets/solarcooker/lang/zh_cn.json similarity index 98% rename from src/main/resources/assets/solarcooker/lang/zh_cn.json rename to common/src/main/resources/assets/solarcooker/lang/zh_cn.json index 015d7d2..d5b850f 100644 --- a/src/main/resources/assets/solarcooker/lang/zh_cn.json +++ b/common/src/main/resources/assets/solarcooker/lang/zh_cn.json @@ -1,8 +1,8 @@ -{ - "block.solarcooker.solar_cooker": " 太阳灶", - "block.solarcooker.reflector": "反光板", - "block.solarcooker.shining_diamond_block": "闪耀的钻石块", - - "item.solarcooker.reflector.description": "在太阳灶的左右两侧最多可以放置四个反射板来改善光线的入射以及减少烹饪时间。", - "item.solarcooker.shining_diamond_block.description": "闪闪放光芒!可以放置在一个太阳灶上方,独立于太阳使用。" +{ + "block.solarcooker.solar_cooker": " 太阳灶", + "block.solarcooker.reflector": "反光板", + "block.solarcooker.shining_diamond_block": "闪耀的钻石块", + + "item.solarcooker.reflector.description": "在太阳灶的左右两侧最多可以放置四个反射板来改善光线的入射以及减少烹饪时间。", + "item.solarcooker.shining_diamond_block.description": "闪闪放光芒!可以放置在一个太阳灶上方,独立于太阳使用。" } \ No newline at end of file diff --git a/src/main/resources/assets/solarcooker/models/block/reflector.json b/common/src/main/resources/assets/solarcooker/models/block/reflector.json similarity index 100% rename from src/main/resources/assets/solarcooker/models/block/reflector.json rename to common/src/main/resources/assets/solarcooker/models/block/reflector.json diff --git a/src/main/resources/assets/solarcooker/models/block/reflector_2.json b/common/src/main/resources/assets/solarcooker/models/block/reflector_2.json similarity index 100% rename from src/main/resources/assets/solarcooker/models/block/reflector_2.json rename to common/src/main/resources/assets/solarcooker/models/block/reflector_2.json diff --git a/src/main/resources/assets/solarcooker/models/block/reflector_l.json b/common/src/main/resources/assets/solarcooker/models/block/reflector_l.json similarity index 100% rename from src/main/resources/assets/solarcooker/models/block/reflector_l.json rename to common/src/main/resources/assets/solarcooker/models/block/reflector_l.json diff --git a/src/main/resources/assets/solarcooker/models/block/reflector_o.json b/common/src/main/resources/assets/solarcooker/models/block/reflector_o.json similarity index 100% rename from src/main/resources/assets/solarcooker/models/block/reflector_o.json rename to common/src/main/resources/assets/solarcooker/models/block/reflector_o.json diff --git a/src/main/resources/assets/solarcooker/models/block/reflector_u.json b/common/src/main/resources/assets/solarcooker/models/block/reflector_u.json similarity index 100% rename from src/main/resources/assets/solarcooker/models/block/reflector_u.json rename to common/src/main/resources/assets/solarcooker/models/block/reflector_u.json diff --git a/src/main/resources/assets/solarcooker/models/block/shining_diamond_block.json b/common/src/main/resources/assets/solarcooker/models/block/shining_diamond_block.json similarity index 100% rename from src/main/resources/assets/solarcooker/models/block/shining_diamond_block.json rename to common/src/main/resources/assets/solarcooker/models/block/shining_diamond_block.json diff --git a/src/main/resources/assets/solarcooker/models/block/solar_cooker.json b/common/src/main/resources/assets/solarcooker/models/block/solar_cooker.json similarity index 100% rename from src/main/resources/assets/solarcooker/models/block/solar_cooker.json rename to common/src/main/resources/assets/solarcooker/models/block/solar_cooker.json diff --git a/src/main/resources/assets/solarcooker/models/item/reflector.json b/common/src/main/resources/assets/solarcooker/models/item/reflector.json similarity index 100% rename from src/main/resources/assets/solarcooker/models/item/reflector.json rename to common/src/main/resources/assets/solarcooker/models/item/reflector.json diff --git a/src/main/resources/assets/solarcooker/models/item/shining_diamond_block.json b/common/src/main/resources/assets/solarcooker/models/item/shining_diamond_block.json similarity index 100% rename from src/main/resources/assets/solarcooker/models/item/shining_diamond_block.json rename to common/src/main/resources/assets/solarcooker/models/item/shining_diamond_block.json diff --git a/src/main/resources/assets/solarcooker/models/item/solar_cooker.json b/common/src/main/resources/assets/solarcooker/models/item/solar_cooker.json similarity index 100% rename from src/main/resources/assets/solarcooker/models/item/solar_cooker.json rename to common/src/main/resources/assets/solarcooker/models/item/solar_cooker.json diff --git a/src/main/resources/assets/solarcooker/textures/block/reflector_back.png b/common/src/main/resources/assets/solarcooker/textures/block/reflector_back.png similarity index 100% rename from src/main/resources/assets/solarcooker/textures/block/reflector_back.png rename to common/src/main/resources/assets/solarcooker/textures/block/reflector_back.png diff --git a/src/main/resources/assets/solarcooker/textures/block/reflector_front.png b/common/src/main/resources/assets/solarcooker/textures/block/reflector_front.png similarity index 100% rename from src/main/resources/assets/solarcooker/textures/block/reflector_front.png rename to common/src/main/resources/assets/solarcooker/textures/block/reflector_front.png diff --git a/src/main/resources/assets/solarcooker/textures/block/reflector_side.png b/common/src/main/resources/assets/solarcooker/textures/block/reflector_side.png similarity index 100% rename from src/main/resources/assets/solarcooker/textures/block/reflector_side.png rename to common/src/main/resources/assets/solarcooker/textures/block/reflector_side.png diff --git a/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png b/common/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png similarity index 100% rename from src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png rename to common/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png diff --git a/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png.mcmeta b/common/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png.mcmeta similarity index 100% rename from src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png.mcmeta rename to common/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png.mcmeta diff --git a/src/main/resources/assets/solarcooker/textures/entity/solar_cooker.png b/common/src/main/resources/assets/solarcooker/textures/entity/solar_cooker.png similarity index 100% rename from src/main/resources/assets/solarcooker/textures/entity/solar_cooker.png rename to common/src/main/resources/assets/solarcooker/textures/entity/solar_cooker.png diff --git a/src/main/resources/assets/solarcooker/textures/gui/container/solar_cooker.png b/common/src/main/resources/assets/solarcooker/textures/gui/container/solar_cooker.png similarity index 100% rename from src/main/resources/assets/solarcooker/textures/gui/container/solar_cooker.png rename to common/src/main/resources/assets/solarcooker/textures/gui/container/solar_cooker.png diff --git a/src/main/resources/data/minecraft/tags/blocks/mineable/axe.json b/common/src/main/resources/data/minecraft/tags/blocks/mineable/axe.json similarity index 100% rename from src/main/resources/data/minecraft/tags/blocks/mineable/axe.json rename to common/src/main/resources/data/minecraft/tags/blocks/mineable/axe.json diff --git a/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/common/src/main/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 common/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json diff --git a/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/diamond_block.json b/common/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/diamond_block.json similarity index 100% rename from src/main/resources/data/solarcooker/advancements/recipes/building_blocks/diamond_block.json rename to common/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/diamond_block.json diff --git a/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/shining_diamond_block.json b/common/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/shining_diamond_block.json similarity index 100% rename from src/main/resources/data/solarcooker/advancements/recipes/building_blocks/shining_diamond_block.json rename to common/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/shining_diamond_block.json diff --git a/src/main/resources/data/solarcooker/advancements/recipes/decorations/reflector.json b/common/src/main/resources/data/solarcooker/advancements/recipes/decorations/reflector.json similarity index 100% rename from src/main/resources/data/solarcooker/advancements/recipes/decorations/reflector.json rename to common/src/main/resources/data/solarcooker/advancements/recipes/decorations/reflector.json diff --git a/src/main/resources/data/solarcooker/advancements/recipes/decorations/solar_cooker.json b/common/src/main/resources/data/solarcooker/advancements/recipes/decorations/solar_cooker.json similarity index 100% rename from src/main/resources/data/solarcooker/advancements/recipes/decorations/solar_cooker.json rename to common/src/main/resources/data/solarcooker/advancements/recipes/decorations/solar_cooker.json diff --git a/src/main/resources/data/solarcooker/loot_tables/blocks/reflector.json b/common/src/main/resources/data/solarcooker/loot_tables/blocks/reflector.json similarity index 100% rename from src/main/resources/data/solarcooker/loot_tables/blocks/reflector.json rename to common/src/main/resources/data/solarcooker/loot_tables/blocks/reflector.json diff --git a/src/main/resources/data/solarcooker/loot_tables/blocks/shining_diamond_block.json b/common/src/main/resources/data/solarcooker/loot_tables/blocks/shining_diamond_block.json similarity index 100% rename from src/main/resources/data/solarcooker/loot_tables/blocks/shining_diamond_block.json rename to common/src/main/resources/data/solarcooker/loot_tables/blocks/shining_diamond_block.json diff --git a/src/main/resources/data/solarcooker/loot_tables/blocks/solar_cooker.json b/common/src/main/resources/data/solarcooker/loot_tables/blocks/solar_cooker.json similarity index 100% rename from src/main/resources/data/solarcooker/loot_tables/blocks/solar_cooker.json rename to common/src/main/resources/data/solarcooker/loot_tables/blocks/solar_cooker.json diff --git a/src/main/resources/data/solarcooker/recipes/diamond_block.json b/common/src/main/resources/data/solarcooker/recipes/diamond_block.json similarity index 100% rename from src/main/resources/data/solarcooker/recipes/diamond_block.json rename to common/src/main/resources/data/solarcooker/recipes/diamond_block.json diff --git a/src/main/resources/data/solarcooker/recipes/reflector.json b/common/src/main/resources/data/solarcooker/recipes/reflector.json similarity index 100% rename from src/main/resources/data/solarcooker/recipes/reflector.json rename to common/src/main/resources/data/solarcooker/recipes/reflector.json diff --git a/src/main/resources/data/solarcooker/recipes/shining_diamond_block.json b/common/src/main/resources/data/solarcooker/recipes/shining_diamond_block.json similarity index 100% rename from src/main/resources/data/solarcooker/recipes/shining_diamond_block.json rename to common/src/main/resources/data/solarcooker/recipes/shining_diamond_block.json diff --git a/src/main/resources/data/solarcooker/recipes/solar_cooker.json b/common/src/main/resources/data/solarcooker/recipes/solar_cooker.json similarity index 100% rename from src/main/resources/data/solarcooker/recipes/solar_cooker.json rename to common/src/main/resources/data/solarcooker/recipes/solar_cooker.json diff --git a/src/main/resources/data/solarcooker/tags/blocks/solar_cooker_shining.json b/common/src/main/resources/data/solarcooker/tags/blocks/solar_cooker_shining.json similarity index 100% rename from src/main/resources/data/solarcooker/tags/blocks/solar_cooker_shining.json rename to common/src/main/resources/data/solarcooker/tags/blocks/solar_cooker_shining.json diff --git a/src/main/resources/logo.png b/common/src/main/resources/logo.png similarity index 100% rename from src/main/resources/logo.png rename to common/src/main/resources/logo.png diff --git a/src/main/resources/pack.mcmeta b/common/src/main/resources/pack.mcmeta similarity index 100% rename from src/main/resources/pack.mcmeta rename to common/src/main/resources/pack.mcmeta diff --git a/forge/build.gradle b/forge/build.gradle new file mode 100644 index 0000000..cea4952 --- /dev/null +++ b/forge/build.gradle @@ -0,0 +1,103 @@ +plugins { + id 'idea' + id 'maven-publish' + id 'net.minecraftforge.gradle' version '[6.0.16,6.2)' + id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' +} +base { + archivesName = "${mod_id}-forge" +} +//mixin { +// add(sourceSets.main, "${mod_id}.refmap.json") +// config("${mod_id}.mixins.json") +// config("${mod_id}.forge.mixins.json") +//} + +minecraft { + mappings channel: 'official', version: minecraft_version + + copyIdeResources = true //Calls processResources when in dev + + // Automatically enable forge AccessTransformers if the file exists + // This location is hardcoded in Forge and can not be changed. + // https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123 + if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + } + + runs { + configureEach { + workingDirectory project.file('run') + ideaModule "${rootProject.name}.${project.name}.main" + property 'forge.logging.markers', 'REGISTRIES' + property 'forge.logging.console.level', 'debug' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" + } + client { + property 'forge.enabledGameTestNamespaces', mod_id + } + server { + property 'forge.enabledGameTestNamespaces', mod_id + args '--nogui' + } + gameTestServer { + property 'forge.enabledGameTestNamespaces', mod_id + } + data { + workingDirectory project.file('run-data') + args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + } + } +} + +sourceSets.each { + def dir = layout.buildDirectory.dir("sourcesSets/$it.name") + it.output.resourcesDir = dir + it.java.destinationDirectory = dir +} + +sourceSets.main.resources.srcDir 'src/generated/resources' + +dependencies { + minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" + compileOnly project(":common") + annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor") + + compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")) + testCompileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")) + compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-lib:${jei_version}")) + testCompileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-lib:${jei_version}")) + runtimeOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}")) +} + +tasks.withType(JavaCompile).configureEach { + source(project(":common").sourceSets.main.allSource) +} +//tasks.withType(Javadoc).configureEach { +// source(project(":common").sourceSets.main.allJava) +//} +//tasks.named("sourcesJar", Jar) { +// from(project(":common").sourceSets.main.allSource) +//} + +processResources { + from project(":common").sourceSets.main.resources +} + +jar.finalizedBy('reobfJar') + +publishing { + publications { + mavenJava(MavenPublication) { + artifactId base.archivesName.get() + from components.java + fg.component(it) + } + } + repositories { + maven { + url "file://" + System.getenv("local_maven") + } + } +} \ No newline at end of file diff --git a/forge/src/main/java/de/cech12/solarcooker/ForgeSolarCookerMod.java b/forge/src/main/java/de/cech12/solarcooker/ForgeSolarCookerMod.java new file mode 100644 index 0000000..90f3a7f --- /dev/null +++ b/forge/src/main/java/de/cech12/solarcooker/ForgeSolarCookerMod.java @@ -0,0 +1,55 @@ +package de.cech12.solarcooker; + +import de.cech12.solarcooker.client.SolarCookerBlockEntityRenderer; +import de.cech12.solarcooker.client.SolarCookerScreen; +import de.cech12.solarcooker.init.ModBlockEntityTypes; +import de.cech12.solarcooker.init.ModBlocks; +import de.cech12.solarcooker.init.ModItems; +import de.cech12.solarcooker.init.ModMenuTypes; +import de.cech12.solarcooker.init.ModRecipeTypes; +import de.cech12.solarcooker.inventory.SolarCookerContainer; +import net.minecraft.client.gui.screens.MenuScreens; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + +@Mod(Constants.MOD_ID) +@Mod.EventBusSubscriber(modid= Constants.MOD_ID, bus= Mod.EventBusSubscriber.Bus.MOD) +public class ForgeSolarCookerMod { + + public ForgeSolarCookerMod() { + final IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus(); + ModBlocks.BLOCKS.register(eventBus); + ModBlockEntityTypes.BLOCK_ENTITY_TYPES.register(eventBus); + ModItems.ITEMS.register(eventBus); + ModRecipeTypes.RECIPE_TYPES.register(eventBus); + ModRecipeTypes.RECIPE_SERIALIZERS.register(eventBus); + ModMenuTypes.MENU_TYPES.register(eventBus); + //Config + CommonLoader.init(); + } + + @OnlyIn(Dist.CLIENT) + @SubscribeEvent + public static void onClientRegister(FMLClientSetupEvent event) { + MenuScreens.register((MenuType) Constants.SOLAR_COOKER_MENU_TYPE.get(), SolarCookerScreen::new); + BlockEntityRenderers.register(Constants.SOLAR_COOKER_ENTITY_TYPE.get(), SolarCookerBlockEntityRenderer::new); + } + + @SubscribeEvent + public static void addItemsToTabs(BuildCreativeModeTabContentsEvent event) { + if (event.getTabKey() == CreativeModeTabs.FUNCTIONAL_BLOCKS) { + event.accept(Constants.SOLAR_COOKER_ITEM); + event.accept(Constants.REFLECTOR_ITEM); + event.accept(Constants.SHINING_DIAMOND_BLOCK_ITEM); + } + } +} diff --git a/forge/src/main/java/de/cech12/solarcooker/blockentity/ForgeSolarCookerBlockEntity.java b/forge/src/main/java/de/cech12/solarcooker/blockentity/ForgeSolarCookerBlockEntity.java new file mode 100644 index 0000000..a8eb30d --- /dev/null +++ b/forge/src/main/java/de/cech12/solarcooker/blockentity/ForgeSolarCookerBlockEntity.java @@ -0,0 +1,41 @@ +package de.cech12.solarcooker.blockentity; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.wrapper.SidedInvWrapper; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class ForgeSolarCookerBlockEntity extends AbstractSolarCookerBlockEntity { + + public ForgeSolarCookerBlockEntity(BlockPos pos, BlockState state) { + super(pos, state); + } + + LazyOptional[] handlers = SidedInvWrapper.create(this, Direction.UP, Direction.NORTH); + + @Override + @Nonnull + public LazyOptional getCapability(@Nonnull Capability capability, @Nullable Direction facing) { + if (!this.remove && facing != null && capability == ForgeCapabilities.ITEM_HANDLER) { + if (facing == Direction.UP) + return handlers[0].cast(); + else + return handlers[1].cast(); + } + return super.getCapability(capability, facing); + } + + @Override + public void invalidateCaps() { + super.invalidateCaps(); + for (LazyOptional handler : handlers) handler.invalidate(); + } + +} diff --git a/forge/src/main/java/de/cech12/solarcooker/init/ModBlockEntityTypes.java b/forge/src/main/java/de/cech12/solarcooker/init/ModBlockEntityTypes.java new file mode 100644 index 0000000..59479fe --- /dev/null +++ b/forge/src/main/java/de/cech12/solarcooker/init/ModBlockEntityTypes.java @@ -0,0 +1,17 @@ +package de.cech12.solarcooker.init; + +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.blockentity.ForgeSolarCookerBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; + +public final class ModBlockEntityTypes { + + public static DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, Constants.MOD_ID); + + static { + Constants.SOLAR_COOKER_ENTITY_TYPE = BLOCK_ENTITY_TYPES.register(Constants.SOLAR_COOKER_NAME, () -> BlockEntityType.Builder.of(ForgeSolarCookerBlockEntity::new, Constants.SOLAR_COOKER_BLOCK.get()).build(null)); + } + +} diff --git a/forge/src/main/java/de/cech12/solarcooker/init/ModBlocks.java b/forge/src/main/java/de/cech12/solarcooker/init/ModBlocks.java new file mode 100644 index 0000000..3a3d3be --- /dev/null +++ b/forge/src/main/java/de/cech12/solarcooker/init/ModBlocks.java @@ -0,0 +1,24 @@ +package de.cech12.solarcooker.init; + +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.block.ReflectorBlock; +import de.cech12.solarcooker.block.ShiningDiamondBlock; +import de.cech12.solarcooker.block.SolarCookerBlock; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.material.MapColor; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; + +public final class ModBlocks { + + public static DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Constants.MOD_ID); + + static { + Constants.SOLAR_COOKER_BLOCK = BLOCKS.register(Constants.SOLAR_COOKER_NAME, () -> new SolarCookerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).strength(2.5F, 3.5F).sound(SoundType.WOOD))); + Constants.REFLECTOR_BLOCK = BLOCKS.register(Constants.REFLECTOR_NAME, () -> new ReflectorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).strength(2.0F).sound(SoundType.WOOD))); + Constants.SHINING_DIAMOND_BLOCK_BLOCK = BLOCKS.register(Constants.SHINING_DIAMOND_BLOCK_NAME, () -> new ShiningDiamondBlock(BlockBehaviour.Properties.of().mapColor(MapColor.DIAMOND).requiresCorrectToolForDrops().strength(5.0F, 6.0F).sound(SoundType.METAL).lightLevel(state -> 15))); + } + +} \ No newline at end of file diff --git a/src/main/java/cech12/solarcooker/init/ModItems.java b/forge/src/main/java/de/cech12/solarcooker/init/ModItems.java similarity index 65% rename from src/main/java/cech12/solarcooker/init/ModItems.java rename to forge/src/main/java/de/cech12/solarcooker/init/ModItems.java index 85be08c..0071e7a 100644 --- a/src/main/java/cech12/solarcooker/init/ModItems.java +++ b/forge/src/main/java/de/cech12/solarcooker/init/ModItems.java @@ -1,7 +1,7 @@ -package cech12.solarcooker.init; +package de.cech12.solarcooker.init; -import cech12.solarcooker.SolarCookerMod; -import cech12.solarcooker.blockentity.SolarCookerBlockEntity; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.blockentity.ForgeSolarCookerBlockEntity; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; @@ -19,31 +19,34 @@ import javax.annotation.Nonnull; import java.util.function.Consumer; +import java.util.function.Supplier; public class ModItems { - public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, SolarCookerMod.MOD_ID); + public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Constants.MOD_ID); - public static final RegistryObject SOLAR_COOKER = solarCookerItem(); - public static final RegistryObject REFLECTOR = fromBlock(ModBlocks.REFLECTOR); - public static final RegistryObject SHINING_DIAMOND_BLOCK = fromBlock(ModBlocks.SHINING_DIAMOND_BLOCK); + static { + Constants.SOLAR_COOKER_ITEM = solarCookerItem(); + Constants.REFLECTOR_ITEM = fromBlock(Constants.REFLECTOR_NAME, Constants.REFLECTOR_BLOCK); + Constants.SHINING_DIAMOND_BLOCK_ITEM = fromBlock(Constants.SHINING_DIAMOND_BLOCK_NAME, Constants.SHINING_DIAMOND_BLOCK_BLOCK); + } - private static RegistryObject fromBlock(RegistryObject block) { - return ITEMS.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties())); + private static RegistryObject fromBlock(String name, Supplier block) { + return ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties())); } private static RegistryObject solarCookerItem() { - return ITEMS.register(ModBlocks.SOLAR_COOKER.getId().getPath(), () -> new BlockItem(ModBlocks.SOLAR_COOKER.get(), new Item.Properties()) { + return ITEMS.register(Constants.SOLAR_COOKER_NAME, () -> new BlockItem(Constants.SOLAR_COOKER_BLOCK.get(), new Item.Properties()) { @Override public void initializeClient(@Nonnull Consumer consumer) { consumer.accept(new IClientItemExtensions() { final BlockEntityWithoutLevelRenderer myRenderer = new BlockEntityWithoutLevelRenderer(Minecraft.getInstance().getBlockEntityRenderDispatcher(), Minecraft.getInstance().getEntityModels()) { - private SolarCookerBlockEntity blockEntity; + private ForgeSolarCookerBlockEntity blockEntity; @Override public void renderByItem(@Nonnull ItemStack stack, @Nonnull ItemDisplayContext displayContext, @Nonnull PoseStack matrix, @Nonnull MultiBufferSource buffer, int x, int y) { if (blockEntity == null) { - blockEntity = new SolarCookerBlockEntity(BlockPos.ZERO, ModBlocks.SOLAR_COOKER.get().defaultBlockState()); + blockEntity = new ForgeSolarCookerBlockEntity(BlockPos.ZERO, Constants.SOLAR_COOKER_BLOCK.get().defaultBlockState()); } Minecraft.getInstance().getBlockEntityRenderDispatcher().renderItem(blockEntity, matrix, buffer, x, y); } diff --git a/forge/src/main/java/de/cech12/solarcooker/init/ModMenuTypes.java b/forge/src/main/java/de/cech12/solarcooker/init/ModMenuTypes.java new file mode 100644 index 0000000..50c1be6 --- /dev/null +++ b/forge/src/main/java/de/cech12/solarcooker/init/ModMenuTypes.java @@ -0,0 +1,17 @@ +package de.cech12.solarcooker.init; + +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.inventory.SolarCookerContainer; +import net.minecraft.world.inventory.MenuType; +import net.minecraftforge.common.extensions.IForgeMenuType; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; + +public class ModMenuTypes { + + public static final DeferredRegister> MENU_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, Constants.MOD_ID); + + static { + Constants.SOLAR_COOKER_MENU_TYPE = MENU_TYPES.register(Constants.SOLAR_COOKER_MENU_NAME, () -> IForgeMenuType.create((pWindowID, pInventory, pData) -> new SolarCookerContainer(Constants.SOLAR_COOKING_RECIPE_TYPE.get(), pWindowID, pInventory))); + } +} diff --git a/src/main/java/cech12/solarcooker/init/ModRecipeTypes.java b/forge/src/main/java/de/cech12/solarcooker/init/ModRecipeTypes.java similarity index 53% rename from src/main/java/cech12/solarcooker/init/ModRecipeTypes.java rename to forge/src/main/java/de/cech12/solarcooker/init/ModRecipeTypes.java index 66b7f19..1c197a4 100644 --- a/src/main/java/cech12/solarcooker/init/ModRecipeTypes.java +++ b/forge/src/main/java/de/cech12/solarcooker/init/ModRecipeTypes.java @@ -1,7 +1,7 @@ -package cech12.solarcooker.init; +package de.cech12.solarcooker.init; -import cech12.solarcooker.SolarCookerMod; -import cech12.solarcooker.crafting.SolarCookingRecipe; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.crafting.SolarCookingRecipe; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraftforge.registries.DeferredRegister; @@ -10,11 +10,13 @@ public class ModRecipeTypes { - public static DeferredRegister> RECIPE_TYPES = DeferredRegister.create(ForgeRegistries.RECIPE_TYPES, SolarCookerMod.MOD_ID); + public static DeferredRegister> RECIPE_TYPES = DeferredRegister.create(ForgeRegistries.RECIPE_TYPES, Constants.MOD_ID); - public static RegistryObject> SOLAR_COOKING = RECIPE_TYPES.register("solarcooking", () -> new RecipeType<>() {}); + public static DeferredRegister> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, Constants.MOD_ID); - public static DeferredRegister> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, SolarCookerMod.MOD_ID); + public static RegistryObject> SOLAR_COOKING_SERIALIZER = RECIPE_SERIALIZERS.register(Constants.SOLAR_COOKING_NAME, () -> SolarCookingRecipe.SERIALIZER); - public static RegistryObject> SOLAR_COOKING_SERIALIZER = RECIPE_SERIALIZERS.register("solarcooking", () -> SolarCookingRecipe.SERIALIZER); + static { + Constants.SOLAR_COOKING_RECIPE_TYPE = RECIPE_TYPES.register(Constants.SOLAR_COOKING_NAME, () -> new RecipeType<>() {}); + } } diff --git a/forge/src/main/java/de/cech12/solarcooker/platform/ForgeConfigHelper.java b/forge/src/main/java/de/cech12/solarcooker/platform/ForgeConfigHelper.java new file mode 100644 index 0000000..ceee348 --- /dev/null +++ b/forge/src/main/java/de/cech12/solarcooker/platform/ForgeConfigHelper.java @@ -0,0 +1,113 @@ +package de.cech12.solarcooker.platform; + +import com.electronwill.nightconfig.core.file.CommentedFileConfig; +import com.electronwill.nightconfig.core.io.WritingMode; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.platform.services.IConfigHelper; +import net.minecraft.world.item.crafting.AbstractCookingRecipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.config.ModConfig; +import net.minecraftforge.fml.loading.FMLConfig; +import net.minecraftforge.fml.loading.FMLPaths; +import net.minecraftforge.registries.ForgeRegistries; + +import java.nio.file.Path; + +/** + * The config service implementation for Forge. + */ +public class ForgeConfigHelper implements IConfigHelper { + + private static final ForgeConfigSpec SERVER_CONFIG; + + public static final ForgeConfigSpec.BooleanValue VANILLA_RECIPES_ENABLED; + public static final ForgeConfigSpec.ConfigValue VANILLA_RECIPE_TYPE; + public static final ForgeConfigSpec.DoubleValue COOK_TIME_FACTOR; + public static final ForgeConfigSpec.DoubleValue MAX_REFLECTOR_TIME_FACTOR; + public static final ForgeConfigSpec.ConfigValue RECIPE_BLOCKED_LIST; + + static { + final ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder(); + + builder.comment("Options that affect the added Solar Cooker.").push("Solar Cooker Settings"); + + VANILLA_RECIPES_ENABLED = builder + .comment(VANILLA_RECIPES_ENABLED_DESCRIPTION) + .define("vanillaRecipesEnabled", VANILLA_RECIPES_ENABLED_DEFAULT); + VANILLA_RECIPE_TYPE = builder + .comment(VANILLA_RECIPE_TYPE_DESCRIPTION) + .define("vanillaRecipeType", ForgeRegistries.RECIPE_TYPES.getKey(VANILLA_RECIPE_TYPE_DEFAULT).getPath()); + COOK_TIME_FACTOR = builder + .comment(COOK_TIME_FACTOR_DESCRIPTION) + .defineInRange("cookTimeFactor", COOK_TIME_FACTOR_DEFAULT, COOK_TIME_FACTOR_MIN, COOK_TIME_FACTOR_MAX); + MAX_REFLECTOR_TIME_FACTOR = builder + .comment(MAX_REFLECTOR_TIME_FACTOR_DESCRIPTION) + .defineInRange("maxReflectorSpeedFactor", MAX_REFLECTOR_TIME_FACTOR_DEFAULT, MAX_REFLECTOR_TIME_FACTOR_MIN, MAX_REFLECTOR_TIME_FACTOR_MAX); + RECIPE_BLOCKED_LIST = builder + .comment(RECIPE_BLOCKED_LIST_DESCRIPTION) + .define("recipeBlockedList", RECIPE_BLOCKED_LIST_DEFAULT); + + builder.pop(); + + SERVER_CONFIG = builder.build(); + } + + @Override + public void init() { + ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_CONFIG); + Path path = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath()).resolve(Constants.MOD_ID + "-server.toml"); + final CommentedFileConfig configData = CommentedFileConfig.builder(path).sync().autosave().writingMode(WritingMode.REPLACE).build(); + configData.load(); + SERVER_CONFIG.setConfig(configData); + } + + @Override + public boolean areVanillaRecipesEnabled() { + try { + return VANILLA_RECIPES_ENABLED.get(); + } catch (IllegalStateException ex) { + return VANILLA_RECIPES_ENABLED_DEFAULT; + } + } + + @Override + public RecipeType getRecipeType() { + return switch (VANILLA_RECIPE_TYPE.get()) { + case "smoking" -> RecipeType.SMOKING; + case "smelting" -> RecipeType.SMELTING; + case "campfire_cooking" -> RecipeType.CAMPFIRE_COOKING; + case "blasting" -> RecipeType.BLASTING; + default -> VANILLA_RECIPE_TYPE_DEFAULT; + }; + } + + @Override + public double getCookTimeFactor() { + try { + return COOK_TIME_FACTOR.get(); + } catch (IllegalStateException ex) { + return COOK_TIME_FACTOR_DEFAULT; + } + } + + @Override + public double getMaxReflectorTimeFactor() { + try { + return MAX_REFLECTOR_TIME_FACTOR.get(); + } catch (IllegalStateException ex) { + return MAX_REFLECTOR_TIME_FACTOR_DEFAULT; + } + } + + @Override + public String getRecipeBlockedList() { + try { + return RECIPE_BLOCKED_LIST.get(); + } catch (IllegalStateException ex) { + return RECIPE_BLOCKED_LIST_DEFAULT; + } + } + +} diff --git a/forge/src/main/java/de/cech12/solarcooker/platform/ForgePlatformHelper.java b/forge/src/main/java/de/cech12/solarcooker/platform/ForgePlatformHelper.java new file mode 100644 index 0000000..e3eb5fe --- /dev/null +++ b/forge/src/main/java/de/cech12/solarcooker/platform/ForgePlatformHelper.java @@ -0,0 +1,27 @@ +package de.cech12.solarcooker.platform; + +import de.cech12.solarcooker.platform.services.IPlatformHelper; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.loading.FMLLoader; + +/** + * The platform service implementation for Forge. + */ +public class ForgePlatformHelper implements IPlatformHelper { + + @Override + public String getPlatformName() { + return "Forge"; + } + + @Override + public boolean isModLoaded(String modId) { + return ModList.get().isLoaded(modId); + } + + @Override + public boolean isDevelopmentEnvironment() { + return !FMLLoader.isProduction(); + } + +} diff --git a/forge/src/main/java/de/cech12/solarcooker/platform/ForgeRegistryHelper.java b/forge/src/main/java/de/cech12/solarcooker/platform/ForgeRegistryHelper.java new file mode 100644 index 0000000..ed3b106 --- /dev/null +++ b/forge/src/main/java/de/cech12/solarcooker/platform/ForgeRegistryHelper.java @@ -0,0 +1,18 @@ +package de.cech12.solarcooker.platform; + +import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; +import de.cech12.solarcooker.blockentity.ForgeSolarCookerBlockEntity; +import de.cech12.solarcooker.platform.services.IRegistryHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; + +import javax.annotation.Nonnull; + +public class ForgeRegistryHelper implements IRegistryHelper { + + @Override + public AbstractSolarCookerBlockEntity getNewBlockEntity(@Nonnull BlockPos pos, @Nonnull BlockState state) { + return new ForgeSolarCookerBlockEntity(pos, state); + } + +} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..c41d43d --- /dev/null +++ b/forge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,31 @@ +modLoader="javafml" +loaderVersion="${forge_loader_version_range}" +issueTrackerURL="${mod_issue_tracker}" +license="${mod_license}" +[[mods]] +modId="${mod_id}" +version="${version}" +displayName="${mod_name}" +displayURL="${mod_url}" +logoFile="logo.png" +authors="${mod_author}" +description='''${mod_description}''' +[[dependencies.${mod_id}]] +modId="forge" +mandatory=true +versionRange="${forge_version_range}" +ordering="NONE" +side="BOTH" +[[dependencies.${mod_id}]] +modId="minecraft" +mandatory=true +versionRange="${minecraft_version_range}" +ordering="NONE" +side="BOTH" +[[dependencies.${mod_id}]] +modId="jei" +mandatory=false +versionRange="${jei_version_range}" +referralUrl="https://github.com/mezz/JustEnoughItems" +ordering="NONE" +side="BOTH" \ No newline at end of file diff --git a/forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IConfigHelper b/forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IConfigHelper new file mode 100644 index 0000000..0d2ed67 --- /dev/null +++ b/forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IConfigHelper @@ -0,0 +1 @@ +de.cech12.solarcooker.platform.ForgeConfigHelper \ No newline at end of file diff --git a/forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IPlatformHelper b/forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IPlatformHelper new file mode 100644 index 0000000..c4d1c8d --- /dev/null +++ b/forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IPlatformHelper @@ -0,0 +1 @@ +de.cech12.solarcooker.platform.ForgePlatformHelper \ No newline at end of file diff --git a/forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IRegistryHelper b/forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IRegistryHelper new file mode 100644 index 0000000..3ce3aa5 --- /dev/null +++ b/forge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IRegistryHelper @@ -0,0 +1 @@ +de.cech12.solarcooker.platform.ForgeRegistryHelper \ No newline at end of file diff --git a/src/test/java/cech12/solarcooker/ReflectorTests.java b/forge/src/test/java/de/cech12/solarcooker/ReflectorTests.java similarity index 96% rename from src/test/java/cech12/solarcooker/ReflectorTests.java rename to forge/src/test/java/de/cech12/solarcooker/ReflectorTests.java index c13ff32..e51c440 100644 --- a/src/test/java/cech12/solarcooker/ReflectorTests.java +++ b/forge/src/test/java/de/cech12/solarcooker/ReflectorTests.java @@ -1,6 +1,7 @@ -package cech12.solarcooker; +package de.cech12.solarcooker; -import cech12.solarcooker.block.ReflectorBlock; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.block.ReflectorBlock; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.gametest.framework.GameTest; @@ -8,7 +9,7 @@ import net.minecraft.world.level.block.Rotation; import net.minecraftforge.gametest.GameTestHolder; -@GameTestHolder(SolarCookerMod.MOD_ID) +@GameTestHolder(Constants.MOD_ID) public class ReflectorTests { private static final BlockPos REFLECTOR_POSITION = new BlockPos(0, 1, 0); diff --git a/src/test/resources/data/solarcooker/structures/compat/reflector_facing_property.nbt b/forge/src/test/resources/data/solarcooker/structures/compat/reflector_facing_property.nbt similarity index 100% rename from src/test/resources/data/solarcooker/structures/compat/reflector_facing_property.nbt rename to forge/src/test/resources/data/solarcooker/structures/compat/reflector_facing_property.nbt diff --git a/src/test/resources/data/solarcooker/structures/hopper/hoppers.nbt b/forge/src/test/resources/data/solarcooker/structures/hopper/hoppers.nbt similarity index 100% rename from src/test/resources/data/solarcooker/structures/hopper/hoppers.nbt rename to forge/src/test/resources/data/solarcooker/structures/hopper/hoppers.nbt diff --git a/src/test/resources/data/solarcooker/structures/reflector/reflectors.nbt b/forge/src/test/resources/data/solarcooker/structures/reflector/reflectors.nbt similarity index 100% rename from src/test/resources/data/solarcooker/structures/reflector/reflectors.nbt rename to forge/src/test/resources/data/solarcooker/structures/reflector/reflectors.nbt diff --git a/src/test/resources/data/solarcooker/structures/reflectortests.north.nbt b/forge/src/test/resources/data/solarcooker/structures/reflectortests.north.nbt similarity index 100% rename from src/test/resources/data/solarcooker/structures/reflectortests.north.nbt rename to forge/src/test/resources/data/solarcooker/structures/reflectortests.north.nbt diff --git a/src/test/resources/data/solarcooker/structures/reflectortests.north_east.nbt b/forge/src/test/resources/data/solarcooker/structures/reflectortests.north_east.nbt similarity index 100% rename from src/test/resources/data/solarcooker/structures/reflectortests.north_east.nbt rename to forge/src/test/resources/data/solarcooker/structures/reflectortests.north_east.nbt diff --git a/src/test/resources/data/solarcooker/structures/solarcooker/solarcooker.nbt b/forge/src/test/resources/data/solarcooker/structures/solarcooker/solarcooker.nbt similarity index 100% rename from src/test/resources/data/solarcooker/structures/solarcooker/solarcooker.nbt rename to forge/src/test/resources/data/solarcooker/structures/solarcooker/solarcooker.nbt diff --git a/gradle.properties b/gradle.properties index 943b485..ee4eba0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,29 +1,44 @@ -# Sets default memory used for gradle commands. Can be overridden by user or command line properties. -# This is required to provide enough memory for the Minecraft decompilation process. -org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false - -## Environment Properties -minecraft_version=1.20.2 -minecraft_version_range=[1.20.2,1.21) -forge_version=48.0.23 -forge_version_range=[48.0.23,) -loader_version_range=[48,) +# Important Notes: +# fabric.mod.json's modid field cannot be expanded, you must change it manually. +# Every field you add must be added to the root build.gradle expandProps map. +# Project +group=de.cech12.solarcooker +mod_version=3.0.0.0 mod_id=solarcooker -mod_version=2.2.0.0 -mod_group_id=cech12.solarcooker mod_name=Solar Cooker -mod_authors=Cech12 +mod_author=Cech12 mod_license=The MIT License (MIT) mod_url=https://github.com/cech12/SolarCooker mod_issue_tracker=https://github.com/cech12/SolarCooker/issues -mod_description=A mod which adds a Solar Cooker. +description=A mod which adds a Solar Cooker. + +# Common +minecraft_version=1.20.4 +minecraft_version_range=[1.20.4, 1.21) + +# Fabric +#fabric_version=0.91.0+1.20.2 +#fabric_loader_version=0.15.0 + +# Forge +forge_version=49.0.38 +forge_version_range=[49.0.38,) +forge_loader_version_range=[49,) + +# NeoForge +neoforge_version=20.4.225 +neoforge_version_range=[20.4.225,) +neoforge_loader_version_range=[1,) # jei -jei_version=16.0.0.28 -jei_version_range=[16.0.0.28,) +jei_version=17.3.0.49 +jei_version_range=[17.3.0.49,) #the one probe -top_version=1.20.1-10.0.1-3 -top_version_range=[1.20.1-10.0.1,) +top_version=1.20.4_neo-11.0.2-3 +top_version_range=[1.20.4_neo-11.0.1,) + +# Gradle +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false diff --git a/neoforge/build.gradle b/neoforge/build.gradle new file mode 100644 index 0000000..2cc82da --- /dev/null +++ b/neoforge/build.gradle @@ -0,0 +1,93 @@ +plugins { + id 'idea' + id 'maven-publish' + id 'net.neoforged.gradle.userdev' version '7.0.81' + id 'java-library' +} +base { + archivesName = "${mod_id}-neoforge" +} + +// Automatically enable neoforge AccessTransformers if the file exists +// This location is hardcoded in FML and can not be changed. +// https://github.com/neoforged/FancyModLoader/blob/a952595eaaddd571fbc53f43847680b00894e0c1/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModFile.java#L118 +if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { + minecraft.accessTransformers.file file('src/main/resources/META-INF/accesstransformer.cfg') +} +runs { + configureEach { + modSource project.sourceSets.main + } + client { + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + } + server { + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + programArgument '--nogui' + } + gameTestServer { + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + } + data { + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() + } +} + +sourceSets.main.resources { srcDir 'src/generated/resources' } + +repositories { + maven { // TOP + url "https://maven.k-4u.nl" + } + maven { + // Immersive Engineering + name = "Blamejared Maven" + url "https://maven.blamejared.com" + } +} + +dependencies { + implementation "net.neoforged:neoforge:${neoforge_version}" + compileOnly project(":common") + + compileOnly("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}") + testCompileOnly("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}") + compileOnly("mezz.jei:jei-${minecraft_version}-lib:${jei_version}") + testCompileOnly("mezz.jei:jei-${minecraft_version}-lib:${jei_version}") + runtimeOnly("mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}") + + implementation("mcjty.theoneprobe:theoneprobe:$top_version") {transitive = false} +} + +// NeoGradle compiles the game, but we don't want to add our common code to the game's code +Spec notNeoTask = { Task it -> !it.name.startsWith("neo") } as Spec + +tasks.withType(JavaCompile).matching(notNeoTask).configureEach { + source(project(":common").sourceSets.main.allSource) +} + +//tasks.withType(Javadoc).matching(notNeoTask).configureEach { +// source(project(":common").sourceSets.main.allJava) +//} + +//tasks.named("sourcesJar", Jar) { +// from(project(":common").sourceSets.main.allSource) +//} + +tasks.withType(ProcessResources).matching(notNeoTask).configureEach { + from project(":common").sourceSets.main.resources +} + +publishing { + publications { + mavenJava(MavenPublication) { + artifactId base.archivesName.get() + from components.java + } + } + repositories { + maven { + url "file://" + System.getenv("local_maven") + } + } +} \ No newline at end of file diff --git a/neoforge/src/main/java/de/cech12/solarcooker/NeoForgeSolarCookerMod.java b/neoforge/src/main/java/de/cech12/solarcooker/NeoForgeSolarCookerMod.java new file mode 100644 index 0000000..e410016 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/solarcooker/NeoForgeSolarCookerMod.java @@ -0,0 +1,56 @@ +package de.cech12.solarcooker; + +import de.cech12.solarcooker.client.SolarCookerBlockEntityRenderer; +import de.cech12.solarcooker.client.SolarCookerScreen; +import de.cech12.solarcooker.compat.TOPCompat; +import de.cech12.solarcooker.init.ModBlockEntityTypes; +import de.cech12.solarcooker.init.ModBlocks; +import de.cech12.solarcooker.init.ModItems; +import de.cech12.solarcooker.init.ModMenuTypes; +import de.cech12.solarcooker.init.ModRecipeTypes; +import de.cech12.solarcooker.inventory.SolarCookerContainer; +import net.minecraft.client.gui.screens.MenuScreens; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.CreativeModeTabs; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.ModList; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; +import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; + +@Mod(Constants.MOD_ID) +@Mod.EventBusSubscriber(modid= Constants.MOD_ID, bus= Mod.EventBusSubscriber.Bus.MOD) +public class NeoForgeSolarCookerMod { + + public NeoForgeSolarCookerMod(IEventBus eventBus) { + ModBlocks.BLOCKS.register(eventBus); + ModBlockEntityTypes.BLOCK_ENTITY_TYPES.register(eventBus); + ModItems.ITEMS.register(eventBus); + ModRecipeTypes.RECIPE_TYPES.register(eventBus); + ModRecipeTypes.RECIPE_SERIALIZERS.register(eventBus); + ModMenuTypes.MENU_TYPES.register(eventBus); + //Config + CommonLoader.init(); + //The One Probe registration. + if (ModList.get().isLoaded("theoneprobe")) { + TOPCompat.register(); + } + } + + @SubscribeEvent + public static void onClientRegister(FMLClientSetupEvent event) { + MenuScreens.register((MenuType) Constants.SOLAR_COOKER_MENU_TYPE.get(), SolarCookerScreen::new); + BlockEntityRenderers.register(Constants.SOLAR_COOKER_ENTITY_TYPE.get(), SolarCookerBlockEntityRenderer::new); + } + + @SubscribeEvent + public static void addItemsToTabs(BuildCreativeModeTabContentsEvent event) { + if (event.getTabKey() == CreativeModeTabs.FUNCTIONAL_BLOCKS) { + event.accept(Constants.SOLAR_COOKER_ITEM.get()); + event.accept(Constants.REFLECTOR_ITEM.get()); + event.accept(Constants.SHINING_DIAMOND_BLOCK_ITEM.get()); + } + } +} diff --git a/neoforge/src/main/java/de/cech12/solarcooker/blockentity/NeoForgeSolarCookerBlockEntity.java b/neoforge/src/main/java/de/cech12/solarcooker/blockentity/NeoForgeSolarCookerBlockEntity.java new file mode 100644 index 0000000..db0ba8b --- /dev/null +++ b/neoforge/src/main/java/de/cech12/solarcooker/blockentity/NeoForgeSolarCookerBlockEntity.java @@ -0,0 +1,12 @@ +package de.cech12.solarcooker.blockentity; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; + +public class NeoForgeSolarCookerBlockEntity extends AbstractSolarCookerBlockEntity { + + public NeoForgeSolarCookerBlockEntity(BlockPos pos, BlockState state) { + super(pos, state); + } + +} diff --git a/src/main/java/cech12/solarcooker/compat/TOPCompat.java b/neoforge/src/main/java/de/cech12/solarcooker/compat/TOPCompat.java similarity index 88% rename from src/main/java/cech12/solarcooker/compat/TOPCompat.java rename to neoforge/src/main/java/de/cech12/solarcooker/compat/TOPCompat.java index efb45d7..a94423a 100644 --- a/src/main/java/cech12/solarcooker/compat/TOPCompat.java +++ b/neoforge/src/main/java/de/cech12/solarcooker/compat/TOPCompat.java @@ -1,7 +1,7 @@ -package cech12.solarcooker.compat; -/* -import cech12.solarcooker.SolarCookerMod; -import cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; +package de.cech12.solarcooker.compat; + +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; import mcjty.theoneprobe.api.ElementAlignment; import mcjty.theoneprobe.api.IProbeHitData; import mcjty.theoneprobe.api.IProbeInfo; @@ -16,7 +16,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.fml.InterModComms; +import net.neoforged.fml.InterModComms; import java.util.function.Function; @@ -33,7 +33,7 @@ public Void apply(ITheOneProbe probe) { probe.registerProvider(new IProbeInfoProvider() { @Override public ResourceLocation getID() { - return new ResourceLocation(SolarCookerMod.MOD_ID, "solarcookerinfo"); + return new ResourceLocation(Constants.MOD_ID, "solarcookerinfo"); } @Override @@ -60,4 +60,3 @@ public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player play } } } - */ diff --git a/neoforge/src/main/java/de/cech12/solarcooker/init/ModBlockEntityTypes.java b/neoforge/src/main/java/de/cech12/solarcooker/init/ModBlockEntityTypes.java new file mode 100644 index 0000000..9a52684 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/solarcooker/init/ModBlockEntityTypes.java @@ -0,0 +1,17 @@ +package de.cech12.solarcooker.init; + +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.blockentity.NeoForgeSolarCookerBlockEntity; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.neoforged.neoforge.registries.DeferredRegister; + +public final class ModBlockEntityTypes { + + public static DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(BuiltInRegistries.BLOCK_ENTITY_TYPE, Constants.MOD_ID); + + static { + Constants.SOLAR_COOKER_ENTITY_TYPE = BLOCK_ENTITY_TYPES.register(Constants.SOLAR_COOKER_NAME, () -> BlockEntityType.Builder.of(NeoForgeSolarCookerBlockEntity::new, Constants.SOLAR_COOKER_BLOCK.get()).build(null)); + } + +} diff --git a/neoforge/src/main/java/de/cech12/solarcooker/init/ModBlocks.java b/neoforge/src/main/java/de/cech12/solarcooker/init/ModBlocks.java new file mode 100644 index 0000000..875e131 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/solarcooker/init/ModBlocks.java @@ -0,0 +1,23 @@ +package de.cech12.solarcooker.init; + +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.block.ReflectorBlock; +import de.cech12.solarcooker.block.ShiningDiamondBlock; +import de.cech12.solarcooker.block.SolarCookerBlock; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.material.MapColor; +import net.neoforged.neoforge.registries.DeferredRegister; + +public final class ModBlocks { + + public static DeferredRegister BLOCKS = DeferredRegister.createBlocks(Constants.MOD_ID); + + static { + Constants.SOLAR_COOKER_BLOCK = BLOCKS.register(Constants.SOLAR_COOKER_NAME, () -> new SolarCookerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).strength(2.5F, 3.5F).sound(SoundType.WOOD))); + Constants.REFLECTOR_BLOCK = BLOCKS.register(Constants.REFLECTOR_NAME, () -> new ReflectorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).strength(2.0F).sound(SoundType.WOOD))); + Constants.SHINING_DIAMOND_BLOCK_BLOCK = BLOCKS.register(Constants.SHINING_DIAMOND_BLOCK_NAME, () -> new ShiningDiamondBlock(BlockBehaviour.Properties.of().mapColor(MapColor.DIAMOND).requiresCorrectToolForDrops().strength(5.0F, 6.0F).sound(SoundType.METAL).lightLevel(state -> 15))); + } + +} \ No newline at end of file diff --git a/neoforge/src/main/java/de/cech12/solarcooker/init/ModItems.java b/neoforge/src/main/java/de/cech12/solarcooker/init/ModItems.java new file mode 100644 index 0000000..0324726 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/solarcooker/init/ModItems.java @@ -0,0 +1,64 @@ +package de.cech12.solarcooker.init; + +import de.cech12.solarcooker.Constants; +import com.mojang.blaze3d.vertex.PoseStack; +import de.cech12.solarcooker.blockentity.NeoForgeSolarCookerBlockEntity; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemDisplayContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredRegister; + +import javax.annotation.Nonnull; +import java.util.function.Consumer; +import java.util.function.Supplier; + +public class ModItems { + + public static final DeferredRegister ITEMS = DeferredRegister.createItems(Constants.MOD_ID); + + static { + Constants.SOLAR_COOKER_ITEM = solarCookerItem(); + Constants.REFLECTOR_ITEM = fromBlock(Constants.REFLECTOR_NAME, Constants.REFLECTOR_BLOCK); + Constants.SHINING_DIAMOND_BLOCK_ITEM = fromBlock(Constants.SHINING_DIAMOND_BLOCK_NAME, Constants.SHINING_DIAMOND_BLOCK_BLOCK); + } + + private static DeferredHolder fromBlock(String name, Supplier block) { + return ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties())); + } + + private static DeferredHolder solarCookerItem() { + return ITEMS.register(Constants.SOLAR_COOKER_NAME, () -> new BlockItem(Constants.SOLAR_COOKER_BLOCK.get(), new Item.Properties()) { + @Override + public void initializeClient(@Nonnull Consumer consumer) { + consumer.accept(new IClientItemExtensions() { + final BlockEntityWithoutLevelRenderer myRenderer = new BlockEntityWithoutLevelRenderer(Minecraft.getInstance().getBlockEntityRenderDispatcher(), Minecraft.getInstance().getEntityModels()) { + private NeoForgeSolarCookerBlockEntity blockEntity; + + @Override + public void renderByItem(@Nonnull ItemStack stack, @Nonnull ItemDisplayContext displayContext, @Nonnull PoseStack matrix, @Nonnull MultiBufferSource buffer, int x, int y) { + if (blockEntity == null) { + blockEntity = new NeoForgeSolarCookerBlockEntity(BlockPos.ZERO, Constants.SOLAR_COOKER_BLOCK.get().defaultBlockState()); + } + Minecraft.getInstance().getBlockEntityRenderDispatcher().renderItem(blockEntity, matrix, buffer, x, y); + } + }; + + @Override + public BlockEntityWithoutLevelRenderer getCustomRenderer() { + return myRenderer; + } + }); + } + }); + } + +} diff --git a/neoforge/src/main/java/de/cech12/solarcooker/init/ModMenuTypes.java b/neoforge/src/main/java/de/cech12/solarcooker/init/ModMenuTypes.java new file mode 100644 index 0000000..15c7692 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/solarcooker/init/ModMenuTypes.java @@ -0,0 +1,17 @@ +package de.cech12.solarcooker.init; + +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.inventory.SolarCookerContainer; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.inventory.MenuType; +import net.neoforged.neoforge.common.extensions.IMenuTypeExtension; +import net.neoforged.neoforge.registries.DeferredRegister; + +public class ModMenuTypes { + + public static final DeferredRegister> MENU_TYPES = DeferredRegister.create(BuiltInRegistries.MENU, Constants.MOD_ID); + + static { + Constants.SOLAR_COOKER_MENU_TYPE = MENU_TYPES.register(Constants.SOLAR_COOKER_MENU_NAME, () -> IMenuTypeExtension.create((pWindowID, pInventory, pData) -> new SolarCookerContainer(Constants.SOLAR_COOKING_RECIPE_TYPE.get(), pWindowID, pInventory))); + } +} diff --git a/neoforge/src/main/java/de/cech12/solarcooker/init/ModRecipeTypes.java b/neoforge/src/main/java/de/cech12/solarcooker/init/ModRecipeTypes.java new file mode 100644 index 0000000..da9b0ac --- /dev/null +++ b/neoforge/src/main/java/de/cech12/solarcooker/init/ModRecipeTypes.java @@ -0,0 +1,22 @@ +package de.cech12.solarcooker.init; + +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.crafting.SolarCookingRecipe; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredRegister; + +public class ModRecipeTypes { + + public static DeferredRegister> RECIPE_TYPES = DeferredRegister.create(BuiltInRegistries.RECIPE_TYPE, Constants.MOD_ID); + + public static DeferredRegister> RECIPE_SERIALIZERS = DeferredRegister.create(BuiltInRegistries.RECIPE_SERIALIZER, Constants.MOD_ID); + + public static DeferredHolder, RecipeSerializer> SOLAR_COOKING_SERIALIZER = RECIPE_SERIALIZERS.register(Constants.SOLAR_COOKING_NAME, () -> SolarCookingRecipe.SERIALIZER); + + static { + Constants.SOLAR_COOKING_RECIPE_TYPE = RECIPE_TYPES.register(Constants.SOLAR_COOKING_NAME, () -> new RecipeType<>() {}); + } +} diff --git a/neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgeConfigHelper.java b/neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgeConfigHelper.java new file mode 100644 index 0000000..cf9561b --- /dev/null +++ b/neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgeConfigHelper.java @@ -0,0 +1,113 @@ +package de.cech12.solarcooker.platform; + +import com.electronwill.nightconfig.core.file.CommentedFileConfig; +import com.electronwill.nightconfig.core.io.WritingMode; +import de.cech12.solarcooker.Constants; +import de.cech12.solarcooker.platform.services.IConfigHelper; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.item.crafting.AbstractCookingRecipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.config.ModConfig; +import net.neoforged.fml.loading.FMLConfig; +import net.neoforged.fml.loading.FMLPaths; +import net.neoforged.neoforge.common.ModConfigSpec; + +import java.nio.file.Path; + +/** + * The config service implementation for Forge. + */ +public class NeoForgeConfigHelper implements IConfigHelper { + + private static final ModConfigSpec SERVER_CONFIG; + + public static final ModConfigSpec.BooleanValue VANILLA_RECIPES_ENABLED; + public static final ModConfigSpec.ConfigValue VANILLA_RECIPE_TYPE; + public static final ModConfigSpec.DoubleValue COOK_TIME_FACTOR; + public static final ModConfigSpec.DoubleValue MAX_REFLECTOR_TIME_FACTOR; + public static final ModConfigSpec.ConfigValue RECIPE_BLOCKED_LIST; + + static { + final ModConfigSpec.Builder builder = new ModConfigSpec.Builder(); + + builder.comment("Options that affect the added Solar Cooker.").push("Solar Cooker Settings"); + + VANILLA_RECIPES_ENABLED = builder + .comment(VANILLA_RECIPES_ENABLED_DESCRIPTION) + .define("vanillaRecipesEnabled", VANILLA_RECIPES_ENABLED_DEFAULT); + VANILLA_RECIPE_TYPE = builder + .comment(VANILLA_RECIPE_TYPE_DESCRIPTION) + .define("vanillaRecipeType", BuiltInRegistries.RECIPE_TYPE.getKey(VANILLA_RECIPE_TYPE_DEFAULT).getPath()); + COOK_TIME_FACTOR = builder + .comment(COOK_TIME_FACTOR_DESCRIPTION) + .defineInRange("cookTimeFactor", COOK_TIME_FACTOR_DEFAULT, COOK_TIME_FACTOR_MIN, COOK_TIME_FACTOR_MAX); + MAX_REFLECTOR_TIME_FACTOR = builder + .comment(MAX_REFLECTOR_TIME_FACTOR_DESCRIPTION) + .defineInRange("maxReflectorSpeedFactor", MAX_REFLECTOR_TIME_FACTOR_DEFAULT, MAX_REFLECTOR_TIME_FACTOR_MIN, MAX_REFLECTOR_TIME_FACTOR_MAX); + RECIPE_BLOCKED_LIST = builder + .comment(RECIPE_BLOCKED_LIST_DESCRIPTION) + .define("recipeBlockedList", RECIPE_BLOCKED_LIST_DEFAULT); + + builder.pop(); + + SERVER_CONFIG = builder.build(); + } + + @Override + public void init() { + ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_CONFIG); + Path path = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath()).resolve(Constants.MOD_ID + "-server.toml"); + final CommentedFileConfig configData = CommentedFileConfig.builder(path).sync().autosave().writingMode(WritingMode.REPLACE).build(); + configData.load(); + SERVER_CONFIG.setConfig(configData); + } + + @Override + public boolean areVanillaRecipesEnabled() { + try { + return VANILLA_RECIPES_ENABLED.get(); + } catch (IllegalStateException ex) { + return VANILLA_RECIPES_ENABLED_DEFAULT; + } + } + + @Override + public RecipeType getRecipeType() { + return switch (VANILLA_RECIPE_TYPE.get()) { + case "smoking" -> RecipeType.SMOKING; + case "smelting" -> RecipeType.SMELTING; + case "campfire_cooking" -> RecipeType.CAMPFIRE_COOKING; + case "blasting" -> RecipeType.BLASTING; + default -> VANILLA_RECIPE_TYPE_DEFAULT; + }; + } + + @Override + public double getCookTimeFactor() { + try { + return COOK_TIME_FACTOR.get(); + } catch (IllegalStateException ex) { + return COOK_TIME_FACTOR_DEFAULT; + } + } + + @Override + public double getMaxReflectorTimeFactor() { + try { + return MAX_REFLECTOR_TIME_FACTOR.get(); + } catch (IllegalStateException ex) { + return MAX_REFLECTOR_TIME_FACTOR_DEFAULT; + } + } + + @Override + public String getRecipeBlockedList() { + try { + return RECIPE_BLOCKED_LIST.get(); + } catch (IllegalStateException ex) { + return RECIPE_BLOCKED_LIST_DEFAULT; + } + } + +} diff --git a/neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgePlatformHelper.java b/neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgePlatformHelper.java new file mode 100644 index 0000000..82e84f7 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgePlatformHelper.java @@ -0,0 +1,27 @@ +package de.cech12.solarcooker.platform; + +import de.cech12.solarcooker.platform.services.IPlatformHelper; +import net.neoforged.fml.ModList; +import net.neoforged.fml.loading.FMLLoader; + +/** + * The platform service implementation for Forge. + */ +public class NeoForgePlatformHelper implements IPlatformHelper { + + @Override + public String getPlatformName() { + return "Forge"; + } + + @Override + public boolean isModLoaded(String modId) { + return ModList.get().isLoaded(modId); + } + + @Override + public boolean isDevelopmentEnvironment() { + return !FMLLoader.isProduction(); + } + +} diff --git a/neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgeRegistryHelper.java b/neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgeRegistryHelper.java new file mode 100644 index 0000000..6e6e529 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/solarcooker/platform/NeoForgeRegistryHelper.java @@ -0,0 +1,18 @@ +package de.cech12.solarcooker.platform; + +import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity; +import de.cech12.solarcooker.blockentity.NeoForgeSolarCookerBlockEntity; +import de.cech12.solarcooker.platform.services.IRegistryHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; + +import javax.annotation.Nonnull; + +public class NeoForgeRegistryHelper implements IRegistryHelper { + + @Override + public AbstractSolarCookerBlockEntity getNewBlockEntity(@Nonnull BlockPos pos, @Nonnull BlockState state) { + return new NeoForgeSolarCookerBlockEntity(pos, state); + } + +} diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..f10c2e9 --- /dev/null +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,38 @@ +modLoader="javafml" +loaderVersion="${neoforge_loader_version_range}" +issueTrackerURL="${mod_issue_tracker}" +license="${mod_license}" +[[mods]] +modId="${mod_id}" +version="${version}" +displayName="${mod_name}" +displayURL="${mod_url}" +logoFile="logo.png" +authors="${mod_author}" +description='''${mod_description}''' +[[dependencies.${mod_id}]] +modId="neoforge" +type="required" +versionRange="${neoforge_version_range}" +ordering="NONE" +side="BOTH" +[[dependencies.${mod_id}]] +modId="minecraft" +type="required" +versionRange="${minecraft_version_range}" +ordering="NONE" +side="BOTH" +[[dependencies.${mod_id}]] +modId="jei" +type="optional" +versionRange="${jei_version_range}" +referralUrl="https://github.com/mezz/JustEnoughItems" +ordering="NONE" +side="BOTH" +[[dependencies.${mod_id}]] +modId="theoneprobe" +type="optional" +versionRange="${top_version_range}" +referralUrl="https://www.curseforge.com/minecraft/mc-mods/the-one-probe" +ordering="NONE" +side="BOTH" \ No newline at end of file diff --git a/neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IConfigHelper b/neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IConfigHelper new file mode 100644 index 0000000..42a7e1c --- /dev/null +++ b/neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IConfigHelper @@ -0,0 +1 @@ +de.cech12.solarcooker.platform.NeoForgeConfigHelper \ No newline at end of file diff --git a/neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IPlatformHelper b/neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IPlatformHelper new file mode 100644 index 0000000..c2418b2 --- /dev/null +++ b/neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IPlatformHelper @@ -0,0 +1 @@ +de.cech12.solarcooker.platform.NeoForgePlatformHelper \ No newline at end of file diff --git a/neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IRegistryHelper b/neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IRegistryHelper new file mode 100644 index 0000000..dafab22 --- /dev/null +++ b/neoforge/src/main/resources/META-INF/services/de.cech12.solarcooker.platform.services.IRegistryHelper @@ -0,0 +1 @@ +de.cech12.solarcooker.platform.NeoForgeRegistryHelper \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 291d399..05ba501 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,12 +2,41 @@ pluginManagement { repositories { gradlePluginPortal() maven { - name = 'MinecraftForge' + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + maven { + name = 'NeoForge' + url = 'https://maven.neoforged.net/releases/' + } + maven { + name = 'Forge' url = 'https://maven.minecraftforge.net/' } + maven { + name = 'Sponge Snapshots' + url = 'https://repo.spongepowered.org/repository/maven-public/' + } + maven { + // location of the maven that hosts JEI files since January 2023 + name = "Jared's maven" + url = "https://maven.blamejared.com/" + } + maven { + // location of a maven mirror for JEI files, as a fallback + name = "ModMaven" + url = "https://modmaven.dev" + } } } plugins { - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' -} \ No newline at end of file + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' +} + +// This should match the folder name of the project, or else IDEA may complain (see https://youtrack.jetbrains.com/issue/IDEA-317606) +rootProject.name = 'SolarCooker' +include("common") +//include("fabric") +include("forge") +include("neoforge") \ No newline at end of file diff --git a/src/main/java/cech12/solarcooker/SolarCookerMod.java b/src/main/java/cech12/solarcooker/SolarCookerMod.java deleted file mode 100644 index 463a0a0..0000000 --- a/src/main/java/cech12/solarcooker/SolarCookerMod.java +++ /dev/null @@ -1,71 +0,0 @@ -package cech12.solarcooker; - -import cech12.solarcooker.client.SolarCookerBlockEntityRenderer; -import cech12.solarcooker.client.SolarCookerScreen; -//import cech12.solarcooker.compat.TOPCompat; -import cech12.solarcooker.config.ServerConfig; -import cech12.solarcooker.init.ModBlockEntityTypes; -import cech12.solarcooker.init.ModBlocks; -import cech12.solarcooker.init.ModItems; -import cech12.solarcooker.init.ModMenuTypes; -import cech12.solarcooker.init.ModRecipeTypes; -import cech12.solarcooker.inventory.SolarCookerContainer; -import net.minecraft.client.gui.screens.MenuScreens; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; -import net.minecraft.world.inventory.MenuType; -import net.minecraft.world.item.CreativeModeTabs; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fml.loading.FMLConfig; -import net.minecraftforge.fml.loading.FMLPaths; - -import static cech12.solarcooker.SolarCookerMod.MOD_ID; - -@Mod(MOD_ID) -@Mod.EventBusSubscriber(modid= MOD_ID, bus= Mod.EventBusSubscriber.Bus.MOD) -public class SolarCookerMod { - - public static final String MOD_ID = "solarcooker"; - - public SolarCookerMod() { - final IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus(); - ModBlocks.BLOCKS.register(eventBus); - ModBlockEntityTypes.BLOCK_ENTITY_TYPES.register(eventBus); - ModItems.ITEMS.register(eventBus); - ModRecipeTypes.RECIPE_TYPES.register(eventBus); - ModRecipeTypes.RECIPE_SERIALIZERS.register(eventBus); - ModMenuTypes.MENU_TYPES.register(eventBus); - //Config - ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ServerConfig.SERVER_CONFIG); - ServerConfig.loadConfig(ServerConfig.SERVER_CONFIG, FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath()).resolve(MOD_ID + "-server.toml")); - //The One Probe registration. - if (ModList.get().isLoaded("theoneprobe")) { - //TOPCompat.register(); - } - } - - @OnlyIn(Dist.CLIENT) - @SubscribeEvent - public static void onClientRegister(FMLClientSetupEvent event) { - MenuScreens.register((MenuType) ModMenuTypes.SOLAR_COOKER.get(), SolarCookerScreen::new); - BlockEntityRenderers.register(ModBlockEntityTypes.SOLAR_COOKER.get(), SolarCookerBlockEntityRenderer::new); - } - - @SubscribeEvent - public static void addItemsToTabs(BuildCreativeModeTabContentsEvent event) { - if (event.getTabKey() == CreativeModeTabs.FUNCTIONAL_BLOCKS) { - event.accept(ModItems.SOLAR_COOKER); - event.accept(ModItems.REFLECTOR); - event.accept(ModItems.SHINING_DIAMOND_BLOCK); - } - } -} diff --git a/src/main/java/cech12/solarcooker/blockentity/SolarCookerBlockEntity.java b/src/main/java/cech12/solarcooker/blockentity/SolarCookerBlockEntity.java deleted file mode 100644 index c9e075b..0000000 --- a/src/main/java/cech12/solarcooker/blockentity/SolarCookerBlockEntity.java +++ /dev/null @@ -1,32 +0,0 @@ -package cech12.solarcooker.blockentity; - -import cech12.solarcooker.init.ModBlockEntityTypes; -import cech12.solarcooker.init.ModRecipeTypes; -import cech12.solarcooker.inventory.SolarCookerContainer; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.network.chat.Component; -import net.minecraft.world.level.block.state.BlockState; - -import javax.annotation.Nonnull; - -public class SolarCookerBlockEntity extends AbstractSolarCookerBlockEntity { - - public SolarCookerBlockEntity(BlockPos pos, BlockState state) { - super(ModBlockEntityTypes.SOLAR_COOKER.get(), pos, state, ModRecipeTypes.SOLAR_COOKING.get()); - } - - @Override - @Nonnull - protected Component getDefaultName() { - return Component.translatable("block.solarcooker.solar_cooker"); - } - - @Override - @Nonnull - protected AbstractContainerMenu createMenu(int id, @Nonnull Inventory player) { - return new SolarCookerContainer(ModRecipeTypes.SOLAR_COOKING.get(), id, player, this, this.dataAccess); - } - -} diff --git a/src/main/java/cech12/solarcooker/config/ServerConfig.java b/src/main/java/cech12/solarcooker/config/ServerConfig.java deleted file mode 100644 index 9e08802..0000000 --- a/src/main/java/cech12/solarcooker/config/ServerConfig.java +++ /dev/null @@ -1,77 +0,0 @@ -package cech12.solarcooker.config; - -import com.electronwill.nightconfig.core.file.CommentedFileConfig; -import com.electronwill.nightconfig.core.io.WritingMode; -import net.minecraft.world.item.crafting.AbstractCookingRecipe; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.ForgeConfigSpec; - -import java.nio.file.Path; - -public class ServerConfig { - public static ForgeConfigSpec SERVER_CONFIG; - - public static final ForgeConfigSpec.BooleanValue VANILLA_RECIPES_ENABLED; - public static final ForgeConfigSpec.ConfigValue VANILLA_RECIPE_TYPE; - public static final ForgeConfigSpec.DoubleValue COOK_TIME_FACTOR; - public static final ForgeConfigSpec.DoubleValue MAX_REFLECTOR_TIME_FACTOR; - public static final ForgeConfigSpec.ConfigValue RECIPE_BLACKLIST; - - static { - final ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder(); - - builder.comment("Options that affect the added Solar Cooker.").push("Solar Cooker Settings"); - VANILLA_RECIPES_ENABLED = builder - .comment("If enabled, the vanilla blasting, smelting, or smoking recipes are used by the solar cooker.") - .define("vanillaRecipesEnabled", true); - VANILLA_RECIPE_TYPE = builder - .comment("Defines which vanilla recipes the solar cooker can use. Possible values: \"smoking\" (default), \"smelting\", \"blasting\", \"campfire_cooking\"") - .define("vanillaRecipeType", "smoking"); - COOK_TIME_FACTOR = builder - .comment("Cook time factor of the solar cooker in relation to corresponding vanilla furnace. (i. e. 0.5 - half the time, 1.0 same time, 2.0 twice the time)") - .defineInRange("cookTimeFactor", 4.0, 0.0, 100.0); - MAX_REFLECTOR_TIME_FACTOR = builder - .comment("Speed factor when all 4 reflectors are placed next to the solar cooker. (i. e. 0.5 - half the time, 1.0 same time)") - .defineInRange("maxReflectorSpeedFactor", 0.25, 0.0, 1.0); - RECIPE_BLACKLIST = builder - .comment("A comma separated list of all vanilla recipes that should not be used by the solar cooker. Example: \"baked_potato,baked_potato_from_smoking,othermod:other_baked_food\"") - .define("recipeBlacklist", ""); - builder.pop(); - - SERVER_CONFIG = builder.build(); - } - - public static void loadConfig(ForgeConfigSpec spec, Path path) { - final CommentedFileConfig configData = CommentedFileConfig.builder(path).sync().autosave().writingMode(WritingMode.REPLACE).build(); - configData.load(); - spec.setConfig(configData); - } - - public static RecipeType getRecipeType() { - return switch (VANILLA_RECIPE_TYPE.get()) { - case "smelting" -> RecipeType.SMELTING; - case "campfire_cooking" -> RecipeType.CAMPFIRE_COOKING; - case "blasting" -> RecipeType.BLASTING; - default -> RecipeType.SMOKING; // default to smoking - }; - } - - public static boolean isRecipeNotBlacklisted(final ResourceLocation id) { - String configValue = RECIPE_BLACKLIST.get().trim(); - if (!configValue.isEmpty()) { - String[] ids = configValue.split(","); - if (ids.length < 1) { - return !(new ResourceLocation(configValue).equals(id)); - } else { - for (String recipeId : ids) { - if (new ResourceLocation(recipeId.trim()).equals(id)) { - return false; - } - } - } - } - return true; - } - -} diff --git a/src/main/java/cech12/solarcooker/init/ModBlockEntityTypes.java b/src/main/java/cech12/solarcooker/init/ModBlockEntityTypes.java deleted file mode 100644 index b75823f..0000000 --- a/src/main/java/cech12/solarcooker/init/ModBlockEntityTypes.java +++ /dev/null @@ -1,17 +0,0 @@ -package cech12.solarcooker.init; - -import cech12.solarcooker.SolarCookerMod; -import cech12.solarcooker.blockentity.SolarCookerBlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; - -@Mod.EventBusSubscriber(modid= SolarCookerMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) -public final class ModBlockEntityTypes { - - public static DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, SolarCookerMod.MOD_ID); - public static RegistryObject> SOLAR_COOKER = BLOCK_ENTITY_TYPES.register("solar_cooker", () -> BlockEntityType.Builder.of(SolarCookerBlockEntity::new, ModBlocks.SOLAR_COOKER.get()).build(null)); - -} diff --git a/src/main/java/cech12/solarcooker/init/ModBlocks.java b/src/main/java/cech12/solarcooker/init/ModBlocks.java deleted file mode 100644 index 851f904..0000000 --- a/src/main/java/cech12/solarcooker/init/ModBlocks.java +++ /dev/null @@ -1,25 +0,0 @@ -package cech12.solarcooker.init; - -import cech12.solarcooker.SolarCookerMod; -import cech12.solarcooker.block.ReflectorBlock; -import cech12.solarcooker.block.ShiningDiamondBlock; -import cech12.solarcooker.block.SolarCookerBlock; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.MapColor; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; - -@Mod.EventBusSubscriber(modid= SolarCookerMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) -public final class ModBlocks { - - public static DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, SolarCookerMod.MOD_ID); - - public static RegistryObject SOLAR_COOKER = BLOCKS.register("solar_cooker", () -> new SolarCookerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).strength(2.5F, 3.5F).sound(SoundType.WOOD))); - public static RegistryObject REFLECTOR = BLOCKS.register("reflector", () -> new ReflectorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).strength(2.0F).sound(SoundType.WOOD))); - public static RegistryObject SHINING_DIAMOND_BLOCK = BLOCKS.register("shining_diamond_block", () -> new ShiningDiamondBlock(BlockBehaviour.Properties.of().mapColor(MapColor.DIAMOND).requiresCorrectToolForDrops().strength(5.0F, 6.0F).sound(SoundType.METAL).lightLevel(state -> 15))); - -} \ No newline at end of file diff --git a/src/main/java/cech12/solarcooker/init/ModMenuTypes.java b/src/main/java/cech12/solarcooker/init/ModMenuTypes.java deleted file mode 100644 index 981a79f..0000000 --- a/src/main/java/cech12/solarcooker/init/ModMenuTypes.java +++ /dev/null @@ -1,18 +0,0 @@ -package cech12.solarcooker.init; - -import cech12.solarcooker.SolarCookerMod; -import cech12.solarcooker.inventory.SolarCookerContainer; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.MenuType; -import net.minecraftforge.common.extensions.IForgeMenuType; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; - -public class ModMenuTypes { - - public static final DeferredRegister> MENU_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, SolarCookerMod.MOD_ID); - - public static final RegistryObject> SOLAR_COOKER = MENU_TYPES.register("solarcooker", () -> IForgeMenuType.create((pWindowID, pInventory, pData) -> new SolarCookerContainer(ModRecipeTypes.SOLAR_COOKING.get(), pWindowID, pInventory))); - -} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg deleted file mode 100644 index 3b6ad45..0000000 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ /dev/null @@ -1 +0,0 @@ -public net.minecraft.world.item.crafting.SimpleCookingSerializer$CookieBaker \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 5b0c502..0000000 --- a/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,38 +0,0 @@ -modLoader="javafml" -loaderVersion="${loader_version_range}" -issueTrackerURL="${mod_issue_tracker}" -license="${mod_license}" -[[mods]] - modId="${mod_id}" - version="${minecraft_version}-${mod_version}" - displayName="${mod_name}" - displayURL="${mod_url}" - logoFile="logo.png" - authors="${mod_authors}" - description='''${mod_description}''' -[[dependencies.${mod_id}]] - modId="forge" - mandatory=true - versionRange="${forge_version_range}" - ordering="NONE" - side="BOTH" -[[dependencies.${mod_id}]] - modId="minecraft" - mandatory=true - versionRange="${minecraft_version_range}" - ordering="NONE" - side="BOTH" -[[dependencies.${mod_id}]] - modId="jei" - mandatory=false - versionRange="${jei_version_range}" - referralUrl="https://github.com/mezz/JustEnoughItems" - ordering="NONE" - side="BOTH" -[[dependencies.${mod_id}]] - modId="theoneprobe" - mandatory=false - versionRange="${top_version_range}" - referralUrl="https://www.curseforge.com/minecraft/mc-mods/the-one-probe" - ordering="NONE" - side="BOTH" \ No newline at end of file