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 c6d1624..e8bb421 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: Brick Furnace mod-id: brickfurnace 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: 363593 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: yzHyAUSI 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: 363593 + 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: yzHyAUSI + 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 08b09c3..e9da784 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ build # other eclipse run +runs +run-data runTest # Files from Forge MDK diff --git a/CHANGELOG.md b/CHANGELOG.md index d20a818..4650869 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,17 @@ 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-02 +### Changed +- updated to Minecraft 1.20.4 (Forge 49.0.38, Neoforge 20.4.218) +- updated JEI support to 17.3.0.49 (Forge & Neoforge) +- updated The One Probe support to 1.20.4_neo-11.0.2-3 (Neoforge) +- updated Immersive Engineering support to 1.20.4-11.1.0-172 (Neoforge) +- rename config option "recipeBlacklist" to "recipeBlockedList" + +### Known issues +- Villagers cannot use Brick Blast Furnace or Brick Smoker as workplace in Neoforge + ## [1.20.2-2.2.0.3] - 2024-03-31 ### Fixed - fuel consumption of Brick Smoker & Brick Blast Furnace were incorrect (thanks to t3chdelicious for the report) diff --git a/build.gradle b/build.gradle index fb95d46..36e6754 100644 --- a/build.gradle +++ b/build.gradle @@ -1,188 +1,95 @@ plugins { - id 'eclipse' - id 'idea' - id 'maven-publish' - id 'net.minecraftforge.gradle' version '[6.0,6.2)' - id 'org.spongepowered.mixin' version '0.7.+' //only to use immersive engineering + // 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" - } - maven { // TOP - url "https://maven.k-4u.nl" + tasks.withType(JavaCompile).configureEach { + it.options.encoding = 'UTF-8' + it.options.getRelease().set(17) } - maven { - // Immersive Engineering - name = "Blamejared Maven" - url "https://maven.blamejared.com" - } -} - -dependencies { - // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed - // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. - // The userdev artifact is a special name and will get all sorts of transformations applied to it. - 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} - - //Immersive Engineering - //runtimeOnly fg.deobf("blusunrize.immersiveengineering:ImmersiveEngineering:${project.immersive_engineering_version}") - //compileOnly fg.deobf("blusunrize.immersiveengineering:ImmersiveEngineering:${project.immersive_engineering_version}:api") -} - -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, - immersive_engineering_version_range: immersive_engineering_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, + "immersive_engineering_version": immersive_engineering_version, + "immersive_engineering_version_range": immersive_engineering_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/brickfurnace/CommonLoader.java b/common/src/main/java/de/cech12/brickfurnace/CommonLoader.java new file mode 100644 index 0000000..927e712 --- /dev/null +++ b/common/src/main/java/de/cech12/brickfurnace/CommonLoader.java @@ -0,0 +1,19 @@ +package de.cech12.brickfurnace; + +import de.cech12.brickfurnace.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/brickfurnace/Constants.java b/common/src/main/java/de/cech12/brickfurnace/Constants.java new file mode 100644 index 0000000..ad6fa7f --- /dev/null +++ b/common/src/main/java/de/cech12/brickfurnace/Constants.java @@ -0,0 +1,54 @@ +package de.cech12.brickfurnace; + +import de.cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; +import de.cech12.brickfurnace.crafting.BrickBlastingRecipe; +import de.cech12.brickfurnace.crafting.BrickSmeltingRecipe; +import de.cech12.brickfurnace.crafting.BrickSmokingRecipe; +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 = "brickfurnace"; + /** mod name*/ + public static final String MOD_NAME = "Brick Furnace"; + /** Logger instance */ + public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME); + + public static final String BRICK_FURNACE_NAME = "brick_furnace"; + public static final String BRICK_BLAST_FURNACE_NAME = "brick_blast_furnace"; + public static final String BRICK_SMOKER_NAME = "brick_smoker"; + + public static final String BLASTING_NAME = "blasting"; + public static final String SMELTING_NAME = "smelting"; + public static final String SMOKING_NAME = "smoking"; + + public static Supplier BRICK_FURNACE_BLOCK; + public static Supplier BRICK_BLAST_FURNACE_BLOCK; + public static Supplier BRICK_SMOKER_BLOCK; + + public static Supplier> BRICK_FURNACE_BLOCK_ENTITY_TYPE; + public static Supplier> BRICK_BLAST_FURNACE_BLOCK_ENTITY_TYPE; + public static Supplier> BRICK_SMOKER_BLOCK_ENTITY_TYPE; + + public static Supplier BRICK_FURNACE_ITEM; + public static Supplier BRICK_BLAST_FURNACE_ITEM; + public static Supplier BRICK_SMOKER_ITEM; + + public static Supplier> BLASTING_RECIPE_TYPE; + public static Supplier> SMELTING_RECIPE_TYPE; + public static Supplier> SMOKING_RECIPE_TYPE; + + private Constants() {} + +} \ No newline at end of file diff --git a/src/main/java/cech12/brickfurnace/block/BrickBlastFurnaceBlock.java b/common/src/main/java/de/cech12/brickfurnace/block/BrickBlastFurnaceBlock.java similarity index 78% rename from src/main/java/cech12/brickfurnace/block/BrickBlastFurnaceBlock.java rename to common/src/main/java/de/cech12/brickfurnace/block/BrickBlastFurnaceBlock.java index eda325a..5cd8895 100644 --- a/src/main/java/cech12/brickfurnace/block/BrickBlastFurnaceBlock.java +++ b/common/src/main/java/de/cech12/brickfurnace/block/BrickBlastFurnaceBlock.java @@ -1,8 +1,9 @@ -package cech12.brickfurnace.block; +package de.cech12.brickfurnace.block; -import cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; -import cech12.brickfurnace.blockentity.BrickBlastFurnaceBlockEntity; -import cech12.brickfurnace.init.ModBlockEntityTypes; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; +import de.cech12.brickfurnace.blockentity.BrickBlastFurnaceBlockEntity; +import net.minecraft.world.level.block.BaseEntityBlock; import net.minecraft.world.level.block.BlastFurnaceBlock; import net.minecraft.world.entity.player.Player; import net.minecraft.world.MenuProvider; @@ -33,7 +34,7 @@ public BlockEntity newBlockEntity(@Nonnull BlockPos blockPos, @Nonnull BlockStat @Override @Nullable public BlockEntityTicker getTicker(@Nonnull Level level, @Nonnull BlockState state, @Nonnull BlockEntityType entityType) { - return createTickerHelper(entityType, (BlockEntityType) ModBlockEntityTypes.BRICK_BLAST_FURNACE.get(), AbstractBrickFurnaceBlockEntity::tick); + return BaseEntityBlock.createTickerHelper(entityType, (BlockEntityType) Constants.BRICK_BLAST_FURNACE_BLOCK_ENTITY_TYPE.get(), AbstractBrickFurnaceBlockEntity::tick); } /** diff --git a/src/main/java/cech12/brickfurnace/block/BrickFurnaceBlock.java b/common/src/main/java/de/cech12/brickfurnace/block/BrickFurnaceBlock.java similarity index 78% rename from src/main/java/cech12/brickfurnace/block/BrickFurnaceBlock.java rename to common/src/main/java/de/cech12/brickfurnace/block/BrickFurnaceBlock.java index c067bb3..6d24202 100644 --- a/src/main/java/cech12/brickfurnace/block/BrickFurnaceBlock.java +++ b/common/src/main/java/de/cech12/brickfurnace/block/BrickFurnaceBlock.java @@ -1,8 +1,9 @@ -package cech12.brickfurnace.block; +package de.cech12.brickfurnace.block; -import cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; -import cech12.brickfurnace.blockentity.BrickFurnaceBlockEntity; -import cech12.brickfurnace.init.ModBlockEntityTypes; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; +import de.cech12.brickfurnace.blockentity.BrickFurnaceBlockEntity; +import net.minecraft.world.level.block.BaseEntityBlock; import net.minecraft.world.level.block.FurnaceBlock; import net.minecraft.world.entity.player.Player; import net.minecraft.world.MenuProvider; @@ -33,7 +34,7 @@ public BlockEntity newBlockEntity(@Nonnull BlockPos blockPos, @Nonnull BlockStat @Override @Nullable public BlockEntityTicker getTicker(@Nonnull Level level, @Nonnull BlockState state, @Nonnull BlockEntityType entityType) { - return createTickerHelper(entityType, (BlockEntityType) ModBlockEntityTypes.BRICK_FURNACE.get(), AbstractBrickFurnaceBlockEntity::tick); + return BaseEntityBlock.createTickerHelper(entityType, (BlockEntityType) Constants.BRICK_FURNACE_BLOCK_ENTITY_TYPE.get(), AbstractBrickFurnaceBlockEntity::tick); } /** diff --git a/src/main/java/cech12/brickfurnace/block/BrickSmokerBlock.java b/common/src/main/java/de/cech12/brickfurnace/block/BrickSmokerBlock.java similarity index 78% rename from src/main/java/cech12/brickfurnace/block/BrickSmokerBlock.java rename to common/src/main/java/de/cech12/brickfurnace/block/BrickSmokerBlock.java index f0140ee..c1da99f 100644 --- a/src/main/java/cech12/brickfurnace/block/BrickSmokerBlock.java +++ b/common/src/main/java/de/cech12/brickfurnace/block/BrickSmokerBlock.java @@ -1,8 +1,9 @@ -package cech12.brickfurnace.block; +package de.cech12.brickfurnace.block; -import cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; -import cech12.brickfurnace.blockentity.BrickSmokerBlockEntity; -import cech12.brickfurnace.init.ModBlockEntityTypes; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; +import de.cech12.brickfurnace.blockentity.BrickSmokerBlockEntity; +import net.minecraft.world.level.block.BaseEntityBlock; import net.minecraft.world.level.block.SmokerBlock; import net.minecraft.world.entity.player.Player; import net.minecraft.world.MenuProvider; @@ -33,7 +34,7 @@ public BlockEntity newBlockEntity(@Nonnull BlockPos blockPos, @Nonnull BlockStat @Override @Nullable public BlockEntityTicker getTicker(@Nonnull Level level, @Nonnull BlockState state, @Nonnull BlockEntityType entityType) { - return createTickerHelper(entityType, (BlockEntityType) ModBlockEntityTypes.BRICK_SMOKER.get(), AbstractBrickFurnaceBlockEntity::tick); + return BaseEntityBlock.createTickerHelper(entityType, (BlockEntityType) Constants.BRICK_SMOKER_BLOCK_ENTITY_TYPE.get(), AbstractBrickFurnaceBlockEntity::tick); } /** diff --git a/src/main/java/cech12/brickfurnace/blockentity/AbstractBrickFurnaceBlockEntity.java b/common/src/main/java/de/cech12/brickfurnace/blockentity/AbstractBrickFurnaceBlockEntity.java similarity index 92% rename from src/main/java/cech12/brickfurnace/blockentity/AbstractBrickFurnaceBlockEntity.java rename to common/src/main/java/de/cech12/brickfurnace/blockentity/AbstractBrickFurnaceBlockEntity.java index 0a2806b..b977312 100644 --- a/src/main/java/cech12/brickfurnace/blockentity/AbstractBrickFurnaceBlockEntity.java +++ b/common/src/main/java/de/cech12/brickfurnace/blockentity/AbstractBrickFurnaceBlockEntity.java @@ -1,6 +1,6 @@ -package cech12.brickfurnace.blockentity; +package de.cech12.brickfurnace.blockentity; -import cech12.brickfurnace.config.ServerConfig; +import de.cech12.brickfurnace.platform.Services; import net.minecraft.core.BlockPos; import net.minecraft.world.inventory.ContainerData; import net.minecraft.world.item.crafting.*; @@ -71,11 +71,11 @@ public static void tick(Level level, BlockPos pos, BlockState state, AbstractBri entity.dataAccess.set(RECIPES_USED, entity.dataAccess.get(BURN_TIME)); //changed because of private variable if (entity.isBurning()) { dirty = true; - if (fuel.hasCraftingRemainingItem()) entity.items.set(1, fuel.getCraftingRemainingItem()); + if (Services.PLATFORM.hasCraftingRemainingItem(fuel)) entity.items.set(1, Services.PLATFORM.getCraftingRemainingItem(fuel)); else if (!fuel.isEmpty()) { fuel.shrink(1); if (fuel.isEmpty()) { - entity.items.set(1, fuel.getCraftingRemainingItem()); + entity.items.set(1, Services.PLATFORM.getCraftingRemainingItem(fuel)); } } } @@ -148,7 +148,7 @@ private int getTotalCookTime(RecipeHolder rec) } else if (this.specificRecipeType.getClass().isInstance(rec.value().getType())) { return rec.value().getCookingTime(); } - return (int) (rec.value().getCookingTime() * ServerConfig.COOK_TIME_FACTOR.get()); + return (int) (rec.value().getCookingTime() * Services.CONFIG.getCookTimeFactor()); } public RecipeHolder getRecipe() { @@ -163,9 +163,9 @@ public RecipeHolder getRecipe() { RecipeHolder rec = null; if (this.level != null) { rec = this.level.getRecipeManager().getRecipeFor(this.specificRecipeType, this, this.level).orElse(null); - if (rec == null && ServerConfig.VANILLA_RECIPES_ENABLED.get()) { + if (rec == null && Services.CONFIG.areVanillaRecipesEnabled()) { rec = this.level.getRecipeManager().getRecipesFor(this.vanillaRecipeType, this, this.level) - .stream().filter(abstractCookingRecipe -> ServerConfig.isRecipeNotBlacklisted(abstractCookingRecipe.id())).findFirst().orElse(null); + .stream().filter(abstractCookingRecipe -> Services.CONFIG.isRecipeAllowed(abstractCookingRecipe.id())).findFirst().orElse(null); } } if (rec == null) { diff --git a/src/main/java/cech12/brickfurnace/blockentity/BrickBlastFurnaceBlockEntity.java b/common/src/main/java/de/cech12/brickfurnace/blockentity/BrickBlastFurnaceBlockEntity.java similarity index 75% rename from src/main/java/cech12/brickfurnace/blockentity/BrickBlastFurnaceBlockEntity.java rename to common/src/main/java/de/cech12/brickfurnace/blockentity/BrickBlastFurnaceBlockEntity.java index b430ccb..dc6fe9f 100644 --- a/src/main/java/cech12/brickfurnace/blockentity/BrickBlastFurnaceBlockEntity.java +++ b/common/src/main/java/de/cech12/brickfurnace/blockentity/BrickBlastFurnaceBlockEntity.java @@ -1,8 +1,7 @@ -package cech12.brickfurnace.blockentity; +package de.cech12.brickfurnace.blockentity; -import cech12.brickfurnace.config.ServerConfig; -import cech12.brickfurnace.init.ModBlockEntityTypes; -import cech12.brickfurnace.init.ModRecipeTypes; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.platform.Services; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.BlastFurnaceMenu; @@ -17,7 +16,7 @@ public class BrickBlastFurnaceBlockEntity extends AbstractBrickFurnaceBlockEntity { public BrickBlastFurnaceBlockEntity(BlockPos blockPos, BlockState blockState) { - super(ModBlockEntityTypes.BRICK_BLAST_FURNACE.get(), blockPos, blockState, ModRecipeTypes.BLASTING.get(), RecipeType.BLASTING); + super(Constants.BRICK_BLAST_FURNACE_BLOCK_ENTITY_TYPE.get(), blockPos, blockState, Constants.BLASTING_RECIPE_TYPE.get(), RecipeType.BLASTING); } @Override @@ -28,7 +27,7 @@ protected Component getDefaultName() { @Override protected int getBurnDuration(@Nonnull ItemStack stack) { - return (int) (super.getBurnDuration(stack) * (0.5D * ServerConfig.COOK_TIME_FACTOR.get())); + return (int) (super.getBurnDuration(stack) * (0.5D * Services.CONFIG.getCookTimeFactor())); } @Override diff --git a/src/main/java/cech12/brickfurnace/blockentity/BrickFurnaceBlockEntity.java b/common/src/main/java/de/cech12/brickfurnace/blockentity/BrickFurnaceBlockEntity.java similarity index 71% rename from src/main/java/cech12/brickfurnace/blockentity/BrickFurnaceBlockEntity.java rename to common/src/main/java/de/cech12/brickfurnace/blockentity/BrickFurnaceBlockEntity.java index ea33455..2e9c46e 100644 --- a/src/main/java/cech12/brickfurnace/blockentity/BrickFurnaceBlockEntity.java +++ b/common/src/main/java/de/cech12/brickfurnace/blockentity/BrickFurnaceBlockEntity.java @@ -1,8 +1,7 @@ -package cech12.brickfurnace.blockentity; +package de.cech12.brickfurnace.blockentity; -import cech12.brickfurnace.config.ServerConfig; -import cech12.brickfurnace.init.ModBlockEntityTypes; -import cech12.brickfurnace.init.ModRecipeTypes; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.platform.Services; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.AbstractContainerMenu; @@ -17,7 +16,7 @@ public class BrickFurnaceBlockEntity extends AbstractBrickFurnaceBlockEntity { public BrickFurnaceBlockEntity(BlockPos blockPos, BlockState blockState) { - super(ModBlockEntityTypes.BRICK_FURNACE.get(), blockPos, blockState, ModRecipeTypes.SMELTING.get(), RecipeType.SMELTING); + super(Constants.BRICK_FURNACE_BLOCK_ENTITY_TYPE.get(), blockPos, blockState, Constants.SMELTING_RECIPE_TYPE.get(), RecipeType.SMELTING); } @Override @@ -28,7 +27,7 @@ protected Component getDefaultName() { @Override protected int getBurnDuration(@Nonnull ItemStack stack) { - return (int) (super.getBurnDuration(stack) * ServerConfig.COOK_TIME_FACTOR.get()); + return (int) (super.getBurnDuration(stack) * Services.CONFIG.getCookTimeFactor()); } @Override diff --git a/src/main/java/cech12/brickfurnace/blockentity/BrickSmokerBlockEntity.java b/common/src/main/java/de/cech12/brickfurnace/blockentity/BrickSmokerBlockEntity.java similarity index 75% rename from src/main/java/cech12/brickfurnace/blockentity/BrickSmokerBlockEntity.java rename to common/src/main/java/de/cech12/brickfurnace/blockentity/BrickSmokerBlockEntity.java index 8d4e4e3..90ec2a6 100644 --- a/src/main/java/cech12/brickfurnace/blockentity/BrickSmokerBlockEntity.java +++ b/common/src/main/java/de/cech12/brickfurnace/blockentity/BrickSmokerBlockEntity.java @@ -1,8 +1,7 @@ -package cech12.brickfurnace.blockentity; +package de.cech12.brickfurnace.blockentity; -import cech12.brickfurnace.config.ServerConfig; -import cech12.brickfurnace.init.ModBlockEntityTypes; -import cech12.brickfurnace.init.ModRecipeTypes; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.platform.Services; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.AbstractContainerMenu; @@ -17,7 +16,7 @@ public class BrickSmokerBlockEntity extends AbstractBrickFurnaceBlockEntity { public BrickSmokerBlockEntity(BlockPos blockPos, BlockState blockState) { - super(ModBlockEntityTypes.BRICK_SMOKER.get(), blockPos, blockState, ModRecipeTypes.SMOKING.get(), RecipeType.SMOKING); + super(Constants.BRICK_SMOKER_BLOCK_ENTITY_TYPE.get(), blockPos, blockState, Constants.SMOKING_RECIPE_TYPE.get(), RecipeType.SMOKING); } @Override @@ -28,7 +27,7 @@ protected Component getDefaultName() { @Override protected int getBurnDuration(@Nonnull ItemStack stack) { - return (int) (super.getBurnDuration(stack) * (0.5D * ServerConfig.COOK_TIME_FACTOR.get())); + return (int) (super.getBurnDuration(stack) * (0.5D * Services.CONFIG.getCookTimeFactor())); } @Override diff --git a/src/main/java/cech12/brickfurnace/crafting/BrickBlastingRecipe.java b/common/src/main/java/de/cech12/brickfurnace/crafting/BrickBlastingRecipe.java similarity index 76% rename from src/main/java/cech12/brickfurnace/crafting/BrickBlastingRecipe.java rename to common/src/main/java/de/cech12/brickfurnace/crafting/BrickBlastingRecipe.java index 790e71d..714cabc 100644 --- a/src/main/java/cech12/brickfurnace/crafting/BrickBlastingRecipe.java +++ b/common/src/main/java/de/cech12/brickfurnace/crafting/BrickBlastingRecipe.java @@ -1,8 +1,7 @@ -package cech12.brickfurnace.crafting; +package de.cech12.brickfurnace.crafting; -import cech12.brickfurnace.init.ModBlocks; -import cech12.brickfurnace.init.ModRecipeTypes; -import cech12.brickfurnace.config.ServerConfig; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.platform.Services; import net.minecraft.core.RegistryAccess; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.AbstractCookingRecipe; @@ -19,17 +18,17 @@ public class BrickBlastingRecipe extends AbstractCookingRecipe { public static final SimpleCookingSerializer SERIALIZER = new SimpleCookingSerializer<>(BrickBlastingRecipe::new, 100); public BrickBlastingRecipe(String p_i50031_2_, CookingBookCategory category, Ingredient p_i50031_3_, ItemStack p_i50031_4_, float p_i50031_5_, int p_i50031_6_) { - super(ModRecipeTypes.BLASTING.get(), p_i50031_2_, category, p_i50031_3_, p_i50031_4_, p_i50031_5_, p_i50031_6_); + super(Constants.BLASTING_RECIPE_TYPE.get(), p_i50031_2_, category, p_i50031_3_, p_i50031_4_, p_i50031_5_, p_i50031_6_); } public static BrickBlastingRecipe convert(@Nonnull BlastingRecipe recipe, RegistryAccess registryAccess) { - return new BrickBlastingRecipe(recipe.getGroup(), recipe.category(), recipe.getIngredients().get(0), recipe.getResultItem(registryAccess), recipe.getExperience(), (int) (recipe.getCookingTime() * ServerConfig.COOK_TIME_FACTOR.get())); + return new BrickBlastingRecipe(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.BRICK_BLAST_FURNACE.get()); + return new ItemStack(Constants.BRICK_BLAST_FURNACE_BLOCK.get()); } @Override diff --git a/src/main/java/cech12/brickfurnace/crafting/BrickSmeltingRecipe.java b/common/src/main/java/de/cech12/brickfurnace/crafting/BrickSmeltingRecipe.java similarity index 76% rename from src/main/java/cech12/brickfurnace/crafting/BrickSmeltingRecipe.java rename to common/src/main/java/de/cech12/brickfurnace/crafting/BrickSmeltingRecipe.java index 64f9b6c..73ccf34 100644 --- a/src/main/java/cech12/brickfurnace/crafting/BrickSmeltingRecipe.java +++ b/common/src/main/java/de/cech12/brickfurnace/crafting/BrickSmeltingRecipe.java @@ -1,8 +1,7 @@ -package cech12.brickfurnace.crafting; +package de.cech12.brickfurnace.crafting; -import cech12.brickfurnace.init.ModBlocks; -import cech12.brickfurnace.init.ModRecipeTypes; -import cech12.brickfurnace.config.ServerConfig; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.platform.Services; import net.minecraft.core.RegistryAccess; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.AbstractCookingRecipe; @@ -19,17 +18,17 @@ public class BrickSmeltingRecipe extends AbstractCookingRecipe { public static final SimpleCookingSerializer SERIALIZER = new SimpleCookingSerializer<>(BrickSmeltingRecipe::new, 200); public BrickSmeltingRecipe(String p_i50031_2_, CookingBookCategory category, Ingredient p_i50031_3_, ItemStack p_i50031_4_, float p_i50031_5_, int p_i50031_6_) { - super(ModRecipeTypes.SMELTING.get(), p_i50031_2_, category, p_i50031_3_, p_i50031_4_, p_i50031_5_, p_i50031_6_); + super(Constants.SMELTING_RECIPE_TYPE.get(), p_i50031_2_, category, p_i50031_3_, p_i50031_4_, p_i50031_5_, p_i50031_6_); } public static BrickSmeltingRecipe convert(@Nonnull SmeltingRecipe recipe, RegistryAccess registryAccess) { - return new BrickSmeltingRecipe(recipe.getGroup(), recipe.category(), recipe.getIngredients().get(0), recipe.getResultItem(registryAccess), recipe.getExperience(), (int) (recipe.getCookingTime() * ServerConfig.COOK_TIME_FACTOR.get())); + return new BrickSmeltingRecipe(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.BRICK_FURNACE.get()); + return new ItemStack(Constants.BRICK_FURNACE_BLOCK.get()); } @Override diff --git a/src/main/java/cech12/brickfurnace/crafting/BrickSmokingRecipe.java b/common/src/main/java/de/cech12/brickfurnace/crafting/BrickSmokingRecipe.java similarity index 76% rename from src/main/java/cech12/brickfurnace/crafting/BrickSmokingRecipe.java rename to common/src/main/java/de/cech12/brickfurnace/crafting/BrickSmokingRecipe.java index b169ce8..93d835b 100644 --- a/src/main/java/cech12/brickfurnace/crafting/BrickSmokingRecipe.java +++ b/common/src/main/java/de/cech12/brickfurnace/crafting/BrickSmokingRecipe.java @@ -1,8 +1,7 @@ -package cech12.brickfurnace.crafting; +package de.cech12.brickfurnace.crafting; -import cech12.brickfurnace.init.ModBlocks; -import cech12.brickfurnace.init.ModRecipeTypes; -import cech12.brickfurnace.config.ServerConfig; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.platform.Services; import net.minecraft.core.RegistryAccess; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.AbstractCookingRecipe; @@ -19,17 +18,17 @@ public class BrickSmokingRecipe extends AbstractCookingRecipe { public static final SimpleCookingSerializer SERIALIZER = new SimpleCookingSerializer<>(BrickSmokingRecipe::new, 100); public BrickSmokingRecipe(String p_i50031_2_, CookingBookCategory category, Ingredient p_i50031_3_, ItemStack p_i50031_4_, float p_i50031_5_, int p_i50031_6_) { - super(ModRecipeTypes.SMOKING.get(), p_i50031_2_, category, p_i50031_3_, p_i50031_4_, p_i50031_5_, p_i50031_6_); + super(Constants.SMOKING_RECIPE_TYPE.get(), p_i50031_2_, category, p_i50031_3_, p_i50031_4_, p_i50031_5_, p_i50031_6_); } public static BrickSmokingRecipe convert(@Nonnull SmokingRecipe recipe, RegistryAccess registryAccess) { - return new BrickSmokingRecipe(recipe.getGroup(), recipe.category(), recipe.getIngredients().get(0), recipe.getResultItem(registryAccess), recipe.getExperience(), (int) (recipe.getCookingTime() * ServerConfig.COOK_TIME_FACTOR.get())); + return new BrickSmokingRecipe(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.BRICK_SMOKER.get()); + return new ItemStack(Constants.BRICK_SMOKER_BLOCK.get()); } @Override diff --git a/src/main/java/cech12/brickfurnace/jei/BrickBlastingCategory.java b/common/src/main/java/de/cech12/brickfurnace/jei/BrickBlastingCategory.java similarity index 57% rename from src/main/java/cech12/brickfurnace/jei/BrickBlastingCategory.java rename to common/src/main/java/de/cech12/brickfurnace/jei/BrickBlastingCategory.java index f103e23..a27957a 100644 --- a/src/main/java/cech12/brickfurnace/jei/BrickBlastingCategory.java +++ b/common/src/main/java/de/cech12/brickfurnace/jei/BrickBlastingCategory.java @@ -1,12 +1,12 @@ -package cech12.brickfurnace.jei; +package de.cech12.brickfurnace.jei; -import cech12.brickfurnace.init.ModBlocks; -import cech12.brickfurnace.init.ModRecipeTypes; -import cech12.brickfurnace.config.ServerConfig; -import cech12.brickfurnace.crafting.BrickBlastingRecipe; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.crafting.BrickBlastingRecipe; +import de.cech12.brickfurnace.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 BrickBlastingCategory extends AbstractCookingCategory { public BrickBlastingCategory(IGuiHelper guiHelper) { - super(guiHelper, ModBlocks.BRICK_BLAST_FURNACE.get(), "gui.jei.category.blasting", (int) (100 * ServerConfig.COOK_TIME_FACTOR.get())); + super(guiHelper, Constants.BRICK_BLAST_FURNACE_BLOCK.get(), "gui.jei.category.blasting", (int) (100 * Services.CONFIG.getCookTimeFactor())); } @Override @Nonnull public RecipeType> getRecipeType() { Class> holderClass = (Class>) (Object) RecipeHolder.class; - return new RecipeType<>(ModRecipeTypes.BLASTING.getId(), holderClass); + return new RecipeType<>(new ResourceLocation(Constants.MOD_ID, Constants.BLASTING_NAME), holderClass); } } diff --git a/src/main/java/cech12/brickfurnace/jei/BrickFurnaceJEIPlugin.java b/common/src/main/java/de/cech12/brickfurnace/jei/BrickFurnaceJEIPlugin.java similarity index 72% rename from src/main/java/cech12/brickfurnace/jei/BrickFurnaceJEIPlugin.java rename to common/src/main/java/de/cech12/brickfurnace/jei/BrickFurnaceJEIPlugin.java index 3b09f3f..3f1097d 100644 --- a/src/main/java/cech12/brickfurnace/jei/BrickFurnaceJEIPlugin.java +++ b/common/src/main/java/de/cech12/brickfurnace/jei/BrickFurnaceJEIPlugin.java @@ -1,12 +1,10 @@ -package cech12.brickfurnace.jei; +package de.cech12.brickfurnace.jei; -import cech12.brickfurnace.BrickFurnaceMod; -import cech12.brickfurnace.init.ModBlocks; -import cech12.brickfurnace.init.ModRecipeTypes; -import cech12.brickfurnace.config.ServerConfig; -import cech12.brickfurnace.crafting.BrickBlastingRecipe; -import cech12.brickfurnace.crafting.BrickSmeltingRecipe; -import cech12.brickfurnace.crafting.BrickSmokingRecipe; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.crafting.BrickBlastingRecipe; +import de.cech12.brickfurnace.crafting.BrickSmeltingRecipe; +import de.cech12.brickfurnace.crafting.BrickSmokingRecipe; +import de.cech12.brickfurnace.platform.Services; import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; import mezz.jei.api.helpers.IGuiHelper; @@ -34,7 +32,7 @@ public class BrickFurnaceJEIPlugin implements IModPlugin { @Override @Nonnull public ResourceLocation getPluginUid() { - return new ResourceLocation(BrickFurnaceMod.MOD_ID, "plugin_" + BrickFurnaceMod.MOD_ID); + return new ResourceLocation(Constants.MOD_ID, "plugin_" + Constants.MOD_ID); } @Override @@ -54,21 +52,21 @@ public void registerRecipes(@Nonnull IRecipeRegistration registration) { LocalPlayer player = Minecraft.getInstance().player; if (player != null) { RecipeManager manager = player.connection.getRecipeManager(); - registration.addRecipes(smeltingRecipeType.getRecipeType(), manager.getAllRecipesFor(ModRecipeTypes.SMELTING.get())); - registration.addRecipes(smokingRecipeType.getRecipeType(), manager.getAllRecipesFor(ModRecipeTypes.SMOKING.get())); - registration.addRecipes(blastingRecipeType.getRecipeType(), manager.getAllRecipesFor(ModRecipeTypes.BLASTING.get())); + registration.addRecipes(smeltingRecipeType.getRecipeType(), manager.getAllRecipesFor(Constants.SMELTING_RECIPE_TYPE.get())); + registration.addRecipes(smokingRecipeType.getRecipeType(), manager.getAllRecipesFor(Constants.SMOKING_RECIPE_TYPE.get())); + registration.addRecipes(blastingRecipeType.getRecipeType(), manager.getAllRecipesFor(Constants.BLASTING_RECIPE_TYPE.get())); - if (ServerConfig.VANILLA_RECIPES_ENABLED.get()) { + if (Services.CONFIG.areVanillaRecipesEnabled()) { registration.addRecipes(smeltingRecipeType.getRecipeType(), manager.getAllRecipesFor(RecipeType.SMELTING).stream() - .filter(recipe -> ServerConfig.isRecipeNotBlacklisted(recipe.id())) + .filter(recipe -> Services.CONFIG.isRecipeAllowed(recipe.id())) .map(recipe -> new RecipeHolder<>(recipe.id(), BrickSmeltingRecipe.convert(recipe.value(), player.level().registryAccess()))) .collect(Collectors.toList())); registration.addRecipes(smokingRecipeType.getRecipeType(), manager.getAllRecipesFor(RecipeType.SMOKING).stream() - .filter(recipe -> ServerConfig.isRecipeNotBlacklisted(recipe.id())) + .filter(recipe -> Services.CONFIG.isRecipeAllowed(recipe.id())) .map(recipe -> new RecipeHolder<>(recipe.id(), BrickSmokingRecipe.convert(recipe.value(), player.level().registryAccess()))) .collect(Collectors.toList())); registration.addRecipes(blastingRecipeType.getRecipeType(), manager.getAllRecipesFor(RecipeType.BLASTING).stream() - .filter(recipe -> ServerConfig.isRecipeNotBlacklisted(recipe.id())) + .filter(recipe -> Services.CONFIG.isRecipeAllowed(recipe.id())) .map(recipe -> new RecipeHolder<>(recipe.id(), BrickBlastingRecipe.convert(recipe.value(), player.level().registryAccess()))) .collect(Collectors.toList())); } @@ -77,11 +75,11 @@ public void registerRecipes(@Nonnull IRecipeRegistration registration) { @Override public void registerRecipeCatalysts(@Nonnull IRecipeCatalystRegistration registration) { - registration.addRecipeCatalyst(new ItemStack(ModBlocks.BRICK_FURNACE.get()), + registration.addRecipeCatalyst(new ItemStack(Constants.BRICK_FURNACE_BLOCK.get()), smeltingRecipeType.getRecipeType(), mezz.jei.api.constants.RecipeTypes.FUELING); - registration.addRecipeCatalyst(new ItemStack(ModBlocks.BRICK_SMOKER.get()), + registration.addRecipeCatalyst(new ItemStack(Constants.BRICK_SMOKER_BLOCK.get()), smokingRecipeType.getRecipeType(), mezz.jei.api.constants.RecipeTypes.FUELING); - registration.addRecipeCatalyst(new ItemStack(ModBlocks.BRICK_BLAST_FURNACE.get()), + registration.addRecipeCatalyst(new ItemStack(Constants.BRICK_BLAST_FURNACE_BLOCK.get()), blastingRecipeType.getRecipeType(), mezz.jei.api.constants.RecipeTypes.FUELING); } diff --git a/src/main/java/cech12/brickfurnace/jei/BrickSmeltingCategory.java b/common/src/main/java/de/cech12/brickfurnace/jei/BrickSmeltingCategory.java similarity index 57% rename from src/main/java/cech12/brickfurnace/jei/BrickSmeltingCategory.java rename to common/src/main/java/de/cech12/brickfurnace/jei/BrickSmeltingCategory.java index 950ca8f..d98e369 100644 --- a/src/main/java/cech12/brickfurnace/jei/BrickSmeltingCategory.java +++ b/common/src/main/java/de/cech12/brickfurnace/jei/BrickSmeltingCategory.java @@ -1,12 +1,12 @@ -package cech12.brickfurnace.jei; +package de.cech12.brickfurnace.jei; -import cech12.brickfurnace.init.ModBlocks; -import cech12.brickfurnace.init.ModRecipeTypes; -import cech12.brickfurnace.config.ServerConfig; -import cech12.brickfurnace.crafting.BrickSmeltingRecipe; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.crafting.BrickSmeltingRecipe; +import de.cech12.brickfurnace.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 BrickSmeltingCategory extends AbstractCookingCategory { public BrickSmeltingCategory(IGuiHelper guiHelper) { - super(guiHelper, ModBlocks.BRICK_FURNACE.get(), "gui.jei.category.smelting", (int) (200 * ServerConfig.COOK_TIME_FACTOR.get())); + super(guiHelper, Constants.BRICK_FURNACE_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.SMELTING.getId(), holderClass); + return new RecipeType<>(new ResourceLocation(Constants.MOD_ID, Constants.SMELTING_NAME), holderClass); } } diff --git a/src/main/java/cech12/brickfurnace/jei/BrickSmokingCategory.java b/common/src/main/java/de/cech12/brickfurnace/jei/BrickSmokingCategory.java similarity index 57% rename from src/main/java/cech12/brickfurnace/jei/BrickSmokingCategory.java rename to common/src/main/java/de/cech12/brickfurnace/jei/BrickSmokingCategory.java index 5b5295e..e8c5e1c 100644 --- a/src/main/java/cech12/brickfurnace/jei/BrickSmokingCategory.java +++ b/common/src/main/java/de/cech12/brickfurnace/jei/BrickSmokingCategory.java @@ -1,12 +1,12 @@ -package cech12.brickfurnace.jei; +package de.cech12.brickfurnace.jei; -import cech12.brickfurnace.init.ModBlocks; -import cech12.brickfurnace.init.ModRecipeTypes; -import cech12.brickfurnace.config.ServerConfig; -import cech12.brickfurnace.crafting.BrickSmokingRecipe; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.crafting.BrickSmokingRecipe; +import de.cech12.brickfurnace.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 BrickSmokingCategory extends AbstractCookingCategory { public BrickSmokingCategory(IGuiHelper guiHelper) { - super(guiHelper, ModBlocks.BRICK_SMOKER.get(), "gui.jei.category.smoking", (int) (100 * ServerConfig.COOK_TIME_FACTOR.get())); + super(guiHelper, Constants.BRICK_SMOKER_BLOCK.get(), "gui.jei.category.smoking", (int) (100 * Services.CONFIG.getCookTimeFactor())); } @Override @Nonnull public RecipeType> getRecipeType() { Class> holderClass = (Class>) (Object) RecipeHolder.class; - return new RecipeType<>(ModRecipeTypes.SMOKING.getId(), holderClass); + return new RecipeType<>(new ResourceLocation(Constants.MOD_ID, Constants.SMOKING_NAME), holderClass); } } diff --git a/common/src/main/java/de/cech12/brickfurnace/platform/Services.java b/common/src/main/java/de/cech12/brickfurnace/platform/Services.java new file mode 100644 index 0000000..011abf3 --- /dev/null +++ b/common/src/main/java/de/cech12/brickfurnace/platform/Services.java @@ -0,0 +1,40 @@ +package de.cech12.brickfurnace.platform; + +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.platform.services.IConfigHelper; +import de.cech12.brickfurnace.platform.services.IPlatformHelper; + +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); + + /** + * 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/brickfurnace/platform/services/IConfigHelper.java b/common/src/main/java/de/cech12/brickfurnace/platform/services/IConfigHelper.java new file mode 100644 index 0000000..0a24bd3 --- /dev/null +++ b/common/src/main/java/de/cech12/brickfurnace/platform/services/IConfigHelper.java @@ -0,0 +1,77 @@ +package de.cech12.brickfurnace.platform.services; + +import net.minecraft.resources.ResourceLocation; + +/** + * 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, and smoking recipes are used by the brick furnaces."; + + /** Default value of the cook time factor option */ + double COOK_TIME_FACTOR_DEFAULT = 1D; + /** Config description of the cook time factor option */ + String COOK_TIME_FACTOR_DESCRIPTION = "Cook time factor of all added brick furnaces in relation to corresponding vanilla furnaces. (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 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 cook time factor option. + * + * @return configured value of the cook time factor option + */ + double getCookTimeFactor(); + + /** + * 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/brickfurnace/platform/services/IPlatformHelper.java b/common/src/main/java/de/cech12/brickfurnace/platform/services/IPlatformHelper.java new file mode 100644 index 0000000..8389674 --- /dev/null +++ b/common/src/main/java/de/cech12/brickfurnace/platform/services/IPlatformHelper.java @@ -0,0 +1,45 @@ +package de.cech12.brickfurnace.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"; + } + + boolean hasCraftingRemainingItem(ItemStack stack); + + ItemStack getCraftingRemainingItem(ItemStack stack); + +} \ No newline at end of file diff --git a/src/main/resources/assets/brickfurnace/blockstates/brick_blast_furnace.json b/common/src/main/resources/assets/brickfurnace/blockstates/brick_blast_furnace.json similarity index 100% rename from src/main/resources/assets/brickfurnace/blockstates/brick_blast_furnace.json rename to common/src/main/resources/assets/brickfurnace/blockstates/brick_blast_furnace.json diff --git a/src/main/resources/assets/brickfurnace/blockstates/brick_furnace.json b/common/src/main/resources/assets/brickfurnace/blockstates/brick_furnace.json similarity index 100% rename from src/main/resources/assets/brickfurnace/blockstates/brick_furnace.json rename to common/src/main/resources/assets/brickfurnace/blockstates/brick_furnace.json diff --git a/src/main/resources/assets/brickfurnace/blockstates/brick_smoker.json b/common/src/main/resources/assets/brickfurnace/blockstates/brick_smoker.json similarity index 100% rename from src/main/resources/assets/brickfurnace/blockstates/brick_smoker.json rename to common/src/main/resources/assets/brickfurnace/blockstates/brick_smoker.json diff --git a/src/main/resources/assets/brickfurnace/lang/de_de.json b/common/src/main/resources/assets/brickfurnace/lang/de_de.json similarity index 100% rename from src/main/resources/assets/brickfurnace/lang/de_de.json rename to common/src/main/resources/assets/brickfurnace/lang/de_de.json diff --git a/src/main/resources/assets/brickfurnace/lang/en_us.json b/common/src/main/resources/assets/brickfurnace/lang/en_us.json similarity index 100% rename from src/main/resources/assets/brickfurnace/lang/en_us.json rename to common/src/main/resources/assets/brickfurnace/lang/en_us.json diff --git a/src/main/resources/assets/brickfurnace/lang/es_es.json b/common/src/main/resources/assets/brickfurnace/lang/es_es.json similarity index 100% rename from src/main/resources/assets/brickfurnace/lang/es_es.json rename to common/src/main/resources/assets/brickfurnace/lang/es_es.json diff --git a/src/main/resources/assets/brickfurnace/lang/ko_kr.json b/common/src/main/resources/assets/brickfurnace/lang/ko_kr.json similarity index 100% rename from src/main/resources/assets/brickfurnace/lang/ko_kr.json rename to common/src/main/resources/assets/brickfurnace/lang/ko_kr.json diff --git a/src/main/resources/assets/brickfurnace/lang/pt_br.json b/common/src/main/resources/assets/brickfurnace/lang/pt_br.json similarity index 100% rename from src/main/resources/assets/brickfurnace/lang/pt_br.json rename to common/src/main/resources/assets/brickfurnace/lang/pt_br.json diff --git a/src/main/resources/assets/brickfurnace/lang/pt_pt.json b/common/src/main/resources/assets/brickfurnace/lang/pt_pt.json similarity index 100% rename from src/main/resources/assets/brickfurnace/lang/pt_pt.json rename to common/src/main/resources/assets/brickfurnace/lang/pt_pt.json diff --git a/src/main/resources/assets/brickfurnace/lang/ru_ru.json b/common/src/main/resources/assets/brickfurnace/lang/ru_ru.json similarity index 100% rename from src/main/resources/assets/brickfurnace/lang/ru_ru.json rename to common/src/main/resources/assets/brickfurnace/lang/ru_ru.json diff --git a/src/main/resources/assets/brickfurnace/lang/zh_cn.json b/common/src/main/resources/assets/brickfurnace/lang/zh_cn.json similarity index 100% rename from src/main/resources/assets/brickfurnace/lang/zh_cn.json rename to common/src/main/resources/assets/brickfurnace/lang/zh_cn.json diff --git a/src/main/resources/assets/brickfurnace/lang/zh_tw.json b/common/src/main/resources/assets/brickfurnace/lang/zh_tw.json similarity index 100% rename from src/main/resources/assets/brickfurnace/lang/zh_tw.json rename to common/src/main/resources/assets/brickfurnace/lang/zh_tw.json diff --git a/src/main/resources/assets/brickfurnace/models/block/brick_blast_furnace.json b/common/src/main/resources/assets/brickfurnace/models/block/brick_blast_furnace.json similarity index 100% rename from src/main/resources/assets/brickfurnace/models/block/brick_blast_furnace.json rename to common/src/main/resources/assets/brickfurnace/models/block/brick_blast_furnace.json diff --git a/src/main/resources/assets/brickfurnace/models/block/brick_blast_furnace_on.json b/common/src/main/resources/assets/brickfurnace/models/block/brick_blast_furnace_on.json similarity index 100% rename from src/main/resources/assets/brickfurnace/models/block/brick_blast_furnace_on.json rename to common/src/main/resources/assets/brickfurnace/models/block/brick_blast_furnace_on.json diff --git a/src/main/resources/assets/brickfurnace/models/block/brick_furnace.json b/common/src/main/resources/assets/brickfurnace/models/block/brick_furnace.json similarity index 100% rename from src/main/resources/assets/brickfurnace/models/block/brick_furnace.json rename to common/src/main/resources/assets/brickfurnace/models/block/brick_furnace.json diff --git a/src/main/resources/assets/brickfurnace/models/block/brick_furnace_on.json b/common/src/main/resources/assets/brickfurnace/models/block/brick_furnace_on.json similarity index 100% rename from src/main/resources/assets/brickfurnace/models/block/brick_furnace_on.json rename to common/src/main/resources/assets/brickfurnace/models/block/brick_furnace_on.json diff --git a/src/main/resources/assets/brickfurnace/models/block/brick_smoker.json b/common/src/main/resources/assets/brickfurnace/models/block/brick_smoker.json similarity index 100% rename from src/main/resources/assets/brickfurnace/models/block/brick_smoker.json rename to common/src/main/resources/assets/brickfurnace/models/block/brick_smoker.json diff --git a/src/main/resources/assets/brickfurnace/models/block/brick_smoker_on.json b/common/src/main/resources/assets/brickfurnace/models/block/brick_smoker_on.json similarity index 100% rename from src/main/resources/assets/brickfurnace/models/block/brick_smoker_on.json rename to common/src/main/resources/assets/brickfurnace/models/block/brick_smoker_on.json diff --git a/src/main/resources/assets/brickfurnace/models/item/brick_blast_furnace.json b/common/src/main/resources/assets/brickfurnace/models/item/brick_blast_furnace.json similarity index 100% rename from src/main/resources/assets/brickfurnace/models/item/brick_blast_furnace.json rename to common/src/main/resources/assets/brickfurnace/models/item/brick_blast_furnace.json diff --git a/src/main/resources/assets/brickfurnace/models/item/brick_furnace.json b/common/src/main/resources/assets/brickfurnace/models/item/brick_furnace.json similarity index 100% rename from src/main/resources/assets/brickfurnace/models/item/brick_furnace.json rename to common/src/main/resources/assets/brickfurnace/models/item/brick_furnace.json diff --git a/src/main/resources/assets/brickfurnace/models/item/brick_smoker.json b/common/src/main/resources/assets/brickfurnace/models/item/brick_smoker.json similarity index 100% rename from src/main/resources/assets/brickfurnace/models/item/brick_smoker.json rename to common/src/main/resources/assets/brickfurnace/models/item/brick_smoker.json diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front_on.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front_on.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front_on.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front_on.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front_on.png.mcmeta b/common/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front_on.png.mcmeta similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front_on.png.mcmeta rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_front_on.png.mcmeta diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_side.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_side.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_side.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_side.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_top.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_top.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_top.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_blast_furnace_top.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_front.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_front.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_furnace_front.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_front.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_front_on.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_front_on.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_furnace_front_on.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_front_on.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_side.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_side.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_furnace_side.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_side.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_top.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_top.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_furnace_top.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_furnace_top.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_bottom.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_bottom.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_smoker_bottom.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_bottom.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front_on.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front_on.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front_on.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front_on.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front_on.png.mcmeta b/common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front_on.png.mcmeta similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front_on.png.mcmeta rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_front_on.png.mcmeta diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_side.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_side.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_smoker_side.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_side.png diff --git a/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_top.png b/common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_top.png similarity index 100% rename from src/main/resources/assets/brickfurnace/textures/block/brick_smoker_top.png rename to common/src/main/resources/assets/brickfurnace/textures/block/brick_smoker_top.png diff --git a/src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_blast_furnace.json b/common/src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_blast_furnace.json similarity index 100% rename from src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_blast_furnace.json rename to common/src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_blast_furnace.json diff --git a/src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_furnace.json b/common/src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_furnace.json similarity index 100% rename from src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_furnace.json rename to common/src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_furnace.json diff --git a/src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_smoker.json b/common/src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_smoker.json similarity index 100% rename from src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_smoker.json rename to common/src/main/resources/data/brickfurnace/advancements/recipes/decorations/brick_smoker.json diff --git a/src/main/resources/data/brickfurnace/loot_tables/blocks/brick_blast_furnace.json b/common/src/main/resources/data/brickfurnace/loot_tables/blocks/brick_blast_furnace.json similarity index 100% rename from src/main/resources/data/brickfurnace/loot_tables/blocks/brick_blast_furnace.json rename to common/src/main/resources/data/brickfurnace/loot_tables/blocks/brick_blast_furnace.json diff --git a/src/main/resources/data/brickfurnace/loot_tables/blocks/brick_furnace.json b/common/src/main/resources/data/brickfurnace/loot_tables/blocks/brick_furnace.json similarity index 100% rename from src/main/resources/data/brickfurnace/loot_tables/blocks/brick_furnace.json rename to common/src/main/resources/data/brickfurnace/loot_tables/blocks/brick_furnace.json diff --git a/src/main/resources/data/brickfurnace/loot_tables/blocks/brick_smoker.json b/common/src/main/resources/data/brickfurnace/loot_tables/blocks/brick_smoker.json similarity index 100% rename from src/main/resources/data/brickfurnace/loot_tables/blocks/brick_smoker.json rename to common/src/main/resources/data/brickfurnace/loot_tables/blocks/brick_smoker.json diff --git a/src/main/resources/data/brickfurnace/recipes/brick_blast_furnace.json b/common/src/main/resources/data/brickfurnace/recipes/brick_blast_furnace.json similarity index 100% rename from src/main/resources/data/brickfurnace/recipes/brick_blast_furnace.json rename to common/src/main/resources/data/brickfurnace/recipes/brick_blast_furnace.json diff --git a/src/main/resources/data/brickfurnace/recipes/brick_furnace.json b/common/src/main/resources/data/brickfurnace/recipes/brick_furnace.json similarity index 100% rename from src/main/resources/data/brickfurnace/recipes/brick_furnace.json rename to common/src/main/resources/data/brickfurnace/recipes/brick_furnace.json diff --git a/src/main/resources/data/brickfurnace/recipes/brick_smoker.json b/common/src/main/resources/data/brickfurnace/recipes/brick_smoker.json similarity index 100% rename from src/main/resources/data/brickfurnace/recipes/brick_smoker.json rename to common/src/main/resources/data/brickfurnace/recipes/brick_smoker.json diff --git a/src/main/resources/data/environmental/recipes/kiln_from_brick_furnace.json b/common/src/main/resources/data/environmental/recipes/kiln_from_brick_furnace.json similarity index 100% rename from src/main/resources/data/environmental/recipes/kiln_from_brick_furnace.json rename to common/src/main/resources/data/environmental/recipes/kiln_from_brick_furnace.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/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/brickfurnace/BrickFurnaceMod.java b/forge/src/main/java/de/cech12/brickfurnace/BrickFurnaceMod.java new file mode 100644 index 0000000..6434bab --- /dev/null +++ b/forge/src/main/java/de/cech12/brickfurnace/BrickFurnaceMod.java @@ -0,0 +1,44 @@ +package de.cech12.brickfurnace; + +import de.cech12.brickfurnace.init.ModBlockEntityTypes; +import de.cech12.brickfurnace.init.ModBlocks; +import de.cech12.brickfurnace.init.ModItems; +import de.cech12.brickfurnace.init.ModPoiTypes; +import de.cech12.brickfurnace.init.ModRecipeTypes; +import net.minecraft.world.item.CreativeModeTabs; +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.javafmlmod.FMLJavaModLoadingContext; + +import static de.cech12.brickfurnace.BrickFurnaceMod.MOD_ID; + +@Mod(MOD_ID) +@Mod.EventBusSubscriber(modid= MOD_ID, bus= Mod.EventBusSubscriber.Bus.MOD) +public class BrickFurnaceMod { + + public static final String MOD_ID = "brickfurnace"; + + public BrickFurnaceMod() { + 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); + ModPoiTypes.POI_TYPES.register(eventBus); + //Config + CommonLoader.init(); + } + + @SubscribeEvent + public static void addItemsToTabs(BuildCreativeModeTabContentsEvent event) { + if (event.getTabKey() == CreativeModeTabs.FUNCTIONAL_BLOCKS) { + event.accept(Constants.BRICK_FURNACE_ITEM); + event.accept(Constants.BRICK_BLAST_FURNACE_ITEM); + event.accept(Constants.BRICK_SMOKER_ITEM); + } + } + +} diff --git a/forge/src/main/java/de/cech12/brickfurnace/init/ModBlockEntityTypes.java b/forge/src/main/java/de/cech12/brickfurnace/init/ModBlockEntityTypes.java new file mode 100644 index 0000000..15aa5ff --- /dev/null +++ b/forge/src/main/java/de/cech12/brickfurnace/init/ModBlockEntityTypes.java @@ -0,0 +1,22 @@ +package de.cech12.brickfurnace.init; + +import de.cech12.brickfurnace.BrickFurnaceMod; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.blockentity.BrickBlastFurnaceBlockEntity; +import de.cech12.brickfurnace.blockentity.BrickFurnaceBlockEntity; +import de.cech12.brickfurnace.blockentity.BrickSmokerBlockEntity; +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, BrickFurnaceMod.MOD_ID); + + static { + Constants.BRICK_FURNACE_BLOCK_ENTITY_TYPE = BLOCK_ENTITY_TYPES.register(Constants.BRICK_FURNACE_NAME, () -> BlockEntityType.Builder.of(BrickFurnaceBlockEntity::new, Constants.BRICK_FURNACE_BLOCK.get()).build(null)); + Constants.BRICK_BLAST_FURNACE_BLOCK_ENTITY_TYPE = BLOCK_ENTITY_TYPES.register(Constants.BRICK_BLAST_FURNACE_NAME, () -> BlockEntityType.Builder.of(BrickBlastFurnaceBlockEntity::new, Constants.BRICK_BLAST_FURNACE_BLOCK.get()).build(null)); + Constants.BRICK_SMOKER_BLOCK_ENTITY_TYPE = BLOCK_ENTITY_TYPES.register(Constants.BRICK_SMOKER_NAME, () -> BlockEntityType.Builder.of(BrickSmokerBlockEntity::new, Constants.BRICK_SMOKER_BLOCK.get()).build(null)); + } + +} diff --git a/forge/src/main/java/de/cech12/brickfurnace/init/ModBlocks.java b/forge/src/main/java/de/cech12/brickfurnace/init/ModBlocks.java new file mode 100644 index 0000000..842b85d --- /dev/null +++ b/forge/src/main/java/de/cech12/brickfurnace/init/ModBlocks.java @@ -0,0 +1,33 @@ +package de.cech12.brickfurnace.init; + +import de.cech12.brickfurnace.BrickFurnaceMod; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.block.BrickBlastFurnaceBlock; +import de.cech12.brickfurnace.block.BrickFurnaceBlock; +import de.cech12.brickfurnace.block.BrickSmokerBlock; +import net.minecraft.world.level.material.MapColor; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; + +import java.util.function.ToIntFunction; + +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; + +public final class ModBlocks { + + public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, BrickFurnaceMod.MOD_ID); + + static { + Constants.BRICK_FURNACE_BLOCK = BLOCKS.register(Constants.BRICK_FURNACE_NAME, () -> new BrickFurnaceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).requiresCorrectToolForDrops().strength(2.0F, 6.0F).lightLevel(getLightLevelWhenLit(13)))); + Constants.BRICK_BLAST_FURNACE_BLOCK = BLOCKS.register(Constants.BRICK_BLAST_FURNACE_NAME, () -> new BrickBlastFurnaceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).requiresCorrectToolForDrops().strength(2.0F, 6.0F).lightLevel(getLightLevelWhenLit(13)))); + Constants.BRICK_SMOKER_BLOCK = BLOCKS.register(Constants.BRICK_SMOKER_NAME, () -> new BrickSmokerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).requiresCorrectToolForDrops().strength(2.0F, 6.0F).lightLevel(getLightLevelWhenLit(13)))); + } + + private static ToIntFunction getLightLevelWhenLit(final int lightLevel) { + return (blockState) -> blockState.getValue(BlockStateProperties.LIT) ? lightLevel : 0; + } + +} \ No newline at end of file diff --git a/forge/src/main/java/de/cech12/brickfurnace/init/ModItems.java b/forge/src/main/java/de/cech12/brickfurnace/init/ModItems.java new file mode 100644 index 0000000..070959b --- /dev/null +++ b/forge/src/main/java/de/cech12/brickfurnace/init/ModItems.java @@ -0,0 +1,28 @@ +package de.cech12.brickfurnace.init; + +import de.cech12.brickfurnace.BrickFurnaceMod; +import de.cech12.brickfurnace.Constants; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; + +import java.util.function.Supplier; + +public class ModItems { + + public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, BrickFurnaceMod.MOD_ID); + + static { + Constants.BRICK_FURNACE_ITEM = fromBlock(Constants.BRICK_FURNACE_NAME, Constants.BRICK_FURNACE_BLOCK); + Constants.BRICK_BLAST_FURNACE_ITEM = fromBlock(Constants.BRICK_BLAST_FURNACE_NAME, Constants.BRICK_BLAST_FURNACE_BLOCK); + Constants.BRICK_SMOKER_ITEM = fromBlock(Constants.BRICK_SMOKER_NAME, Constants.BRICK_SMOKER_BLOCK); + } + + private static RegistryObject fromBlock(String name, Supplier block) { + return ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties())); + } + +} diff --git a/src/main/java/cech12/brickfurnace/init/ModPoiTypes.java b/forge/src/main/java/de/cech12/brickfurnace/init/ModPoiTypes.java similarity index 79% rename from src/main/java/cech12/brickfurnace/init/ModPoiTypes.java rename to forge/src/main/java/de/cech12/brickfurnace/init/ModPoiTypes.java index 40e7ee7..44b9d19 100644 --- a/src/main/java/cech12/brickfurnace/init/ModPoiTypes.java +++ b/forge/src/main/java/de/cech12/brickfurnace/init/ModPoiTypes.java @@ -1,5 +1,6 @@ -package cech12.brickfurnace.init; +package de.cech12.brickfurnace.init; +import de.cech12.brickfurnace.Constants; import net.minecraft.world.entity.ai.village.poi.PoiType; import net.minecraft.world.entity.ai.village.poi.PoiTypes; import net.minecraft.world.level.block.state.BlockState; @@ -15,12 +16,12 @@ public class ModPoiTypes { public static RegistryObject ARMORER = POI_TYPES.register("armorer", () -> { HashSet states = new HashSet<>(ForgeRegistries.POI_TYPES.getDelegateOrThrow(PoiTypes.ARMORER).get().matchingStates()); - states.addAll(ModBlocks.BRICK_BLAST_FURNACE.get().getStateDefinition().getPossibleStates()); + states.addAll(Constants.BRICK_BLAST_FURNACE_BLOCK.get().getStateDefinition().getPossibleStates()); return new PoiType(states, 1, 1); }); public static RegistryObject BUTCHER = POI_TYPES.register("butcher", () ->{ HashSet states = new HashSet<>(ForgeRegistries.POI_TYPES.getDelegateOrThrow(PoiTypes.BUTCHER).get().matchingStates()); - states.addAll(ModBlocks.BRICK_SMOKER.get().getStateDefinition().getPossibleStates()); + states.addAll(Constants.BRICK_SMOKER_BLOCK.get().getStateDefinition().getPossibleStates()); return new PoiType(states, 1, 1); }); diff --git a/forge/src/main/java/de/cech12/brickfurnace/init/ModRecipeTypes.java b/forge/src/main/java/de/cech12/brickfurnace/init/ModRecipeTypes.java new file mode 100644 index 0000000..694e01a --- /dev/null +++ b/forge/src/main/java/de/cech12/brickfurnace/init/ModRecipeTypes.java @@ -0,0 +1,29 @@ +package de.cech12.brickfurnace.init; + +import de.cech12.brickfurnace.BrickFurnaceMod; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.crafting.BrickBlastingRecipe; +import de.cech12.brickfurnace.crafting.BrickSmeltingRecipe; +import de.cech12.brickfurnace.crafting.BrickSmokingRecipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; + +public class ModRecipeTypes { + + public static DeferredRegister> RECIPE_TYPES = DeferredRegister.create(ForgeRegistries.RECIPE_TYPES, BrickFurnaceMod.MOD_ID); + public static DeferredRegister> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, BrickFurnaceMod.MOD_ID); + + public static RegistryObject> BLASTING_SERIALIZER = RECIPE_SERIALIZERS.register(Constants.BLASTING_NAME, () -> BrickBlastingRecipe.SERIALIZER); + public static RegistryObject> SMELTING_SERIALIZER = RECIPE_SERIALIZERS.register(Constants.SMELTING_NAME, () -> BrickSmeltingRecipe.SERIALIZER); + public static RegistryObject> SMOKING_SERIALIZER = RECIPE_SERIALIZERS.register(Constants.SMOKING_NAME, () -> BrickSmokingRecipe.SERIALIZER); + + static { + Constants.BLASTING_RECIPE_TYPE = RECIPE_TYPES.register(Constants.BLASTING_NAME, () -> new RecipeType<>() {}); + Constants.SMELTING_RECIPE_TYPE = RECIPE_TYPES.register(Constants.SMELTING_NAME, () -> new RecipeType<>() {}); + Constants.SMOKING_RECIPE_TYPE = RECIPE_TYPES.register(Constants.SMOKING_NAME, () -> new RecipeType<>() {}); + } + +} diff --git a/forge/src/main/java/de/cech12/brickfurnace/platform/ForgeConfigHelper.java b/forge/src/main/java/de/cech12/brickfurnace/platform/ForgeConfigHelper.java new file mode 100644 index 0000000..47c8991 --- /dev/null +++ b/forge/src/main/java/de/cech12/brickfurnace/platform/ForgeConfigHelper.java @@ -0,0 +1,82 @@ +package de.cech12.brickfurnace.platform; + +import com.electronwill.nightconfig.core.file.CommentedFileConfig; +import com.electronwill.nightconfig.core.io.WritingMode; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.platform.services.IConfigHelper; +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 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.DoubleValue COOK_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 furnaces.").push("Furnace Settings"); + + VANILLA_RECIPES_ENABLED = builder + .comment(VANILLA_RECIPES_ENABLED_DESCRIPTION) + .define("vanillaRecipesEnabled", VANILLA_RECIPES_ENABLED_DEFAULT); + COOK_TIME_FACTOR = builder + .comment(COOK_TIME_FACTOR_DESCRIPTION) + .defineInRange("cookTimeFactor", COOK_TIME_FACTOR_DEFAULT, COOK_TIME_FACTOR_MIN, COOK_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 double getCookTimeFactor() { + try { + return COOK_TIME_FACTOR.get(); + } catch (IllegalStateException ex) { + return COOK_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/brickfurnace/platform/ForgePlatformHelper.java b/forge/src/main/java/de/cech12/brickfurnace/platform/ForgePlatformHelper.java new file mode 100644 index 0000000..96cfa73 --- /dev/null +++ b/forge/src/main/java/de/cech12/brickfurnace/platform/ForgePlatformHelper.java @@ -0,0 +1,38 @@ +package de.cech12.brickfurnace.platform; + +import de.cech12.brickfurnace.platform.services.IPlatformHelper; +import net.minecraft.world.item.ItemStack; +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(); + } + + @Override + public boolean hasCraftingRemainingItem(ItemStack stack) { + return stack.hasCraftingRemainingItem(); + } + + @Override + public ItemStack getCraftingRemainingItem(ItemStack stack) { + return stack.getCraftingRemainingItem(); + } + +} 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.brickfurnace.platform.services.IConfigHelper b/forge/src/main/resources/META-INF/services/de.cech12.brickfurnace.platform.services.IConfigHelper new file mode 100644 index 0000000..a1e59d0 --- /dev/null +++ b/forge/src/main/resources/META-INF/services/de.cech12.brickfurnace.platform.services.IConfigHelper @@ -0,0 +1 @@ +de.cech12.brickfurnace.platform.ForgeConfigHelper \ No newline at end of file diff --git a/forge/src/main/resources/META-INF/services/de.cech12.brickfurnace.platform.services.IPlatformHelper b/forge/src/main/resources/META-INF/services/de.cech12.brickfurnace.platform.services.IPlatformHelper new file mode 100644 index 0000000..bab920a --- /dev/null +++ b/forge/src/main/resources/META-INF/services/de.cech12.brickfurnace.platform.services.IPlatformHelper @@ -0,0 +1 @@ +de.cech12.brickfurnace.platform.ForgePlatformHelper \ No newline at end of file diff --git a/src/test/java/cech12/brickfurnace/IntegrationTestUtils.java b/forge/src/test/java/de/cech12/brickfurnace/IntegrationTestUtils.java similarity index 99% rename from src/test/java/cech12/brickfurnace/IntegrationTestUtils.java rename to forge/src/test/java/de/cech12/brickfurnace/IntegrationTestUtils.java index 8adf19f..2f515f7 100644 --- a/src/test/java/cech12/brickfurnace/IntegrationTestUtils.java +++ b/forge/src/test/java/de/cech12/brickfurnace/IntegrationTestUtils.java @@ -1,4 +1,4 @@ -package cech12.brickfurnace; +package de.cech12.brickfurnace; /* import com.alcatrazescapee.mcjunitlib.framework.IntegrationTestHelper; import net.minecraft.entity.Entity; diff --git a/src/test/java/cech12/brickfurnace/integration/HopperTests.java b/forge/src/test/java/de/cech12/brickfurnace/integration/HopperTests.java similarity index 99% rename from src/test/java/cech12/brickfurnace/integration/HopperTests.java rename to forge/src/test/java/de/cech12/brickfurnace/integration/HopperTests.java index 01f9fa8..526c84d 100644 --- a/src/test/java/cech12/brickfurnace/integration/HopperTests.java +++ b/forge/src/test/java/de/cech12/brickfurnace/integration/HopperTests.java @@ -1,4 +1,4 @@ -package cech12.brickfurnace.integration; +package de.cech12.brickfurnace.integration; /* import cech12.brickfurnace.api.block.BrickFurnaceBlocks; import cech12.brickfurnace.tileentity.AbstractBrickFurnaceTileEntity; diff --git a/src/test/java/cech12/brickfurnace/integration/SmeltingTests.java b/forge/src/test/java/de/cech12/brickfurnace/integration/SmeltingTests.java similarity index 98% rename from src/test/java/cech12/brickfurnace/integration/SmeltingTests.java rename to forge/src/test/java/de/cech12/brickfurnace/integration/SmeltingTests.java index 63ce9ae..068173a 100644 --- a/src/test/java/cech12/brickfurnace/integration/SmeltingTests.java +++ b/forge/src/test/java/de/cech12/brickfurnace/integration/SmeltingTests.java @@ -1,4 +1,4 @@ -package cech12.brickfurnace.integration; +package de.cech12.brickfurnace.integration; /* import cech12.brickfurnace.api.block.BrickFurnaceBlocks; import cech12.brickfurnace.tileentity.AbstractBrickFurnaceTileEntity; diff --git a/src/test/java/cech12/brickfurnace/integration/VillagerTests.java b/forge/src/test/java/de/cech12/brickfurnace/integration/VillagerTests.java similarity index 94% rename from src/test/java/cech12/brickfurnace/integration/VillagerTests.java rename to forge/src/test/java/de/cech12/brickfurnace/integration/VillagerTests.java index 33a632b..8a5b6de 100644 --- a/src/test/java/cech12/brickfurnace/integration/VillagerTests.java +++ b/forge/src/test/java/de/cech12/brickfurnace/integration/VillagerTests.java @@ -1,7 +1,7 @@ -package cech12.brickfurnace.integration; +package de.cech12.brickfurnace.integration; -import cech12.brickfurnace.BrickFurnaceMod; -import cech12.brickfurnace.init.ModBlocks; +import de.cech12.brickfurnace.BrickFurnaceMod; +import de.cech12.brickfurnace.init.ModBlocks; import net.minecraft.core.BlockPos; import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; diff --git a/src/test/java/cech12/brickfurnace/recipe/RecipeTests.java b/forge/src/test/java/de/cech12/brickfurnace/recipe/RecipeTests.java similarity index 99% rename from src/test/java/cech12/brickfurnace/recipe/RecipeTests.java rename to forge/src/test/java/de/cech12/brickfurnace/recipe/RecipeTests.java index 0905b63..913fb0e 100644 --- a/src/test/java/cech12/brickfurnace/recipe/RecipeTests.java +++ b/forge/src/test/java/de/cech12/brickfurnace/recipe/RecipeTests.java @@ -1,4 +1,4 @@ -package cech12.brickfurnace.recipe; +package de.cech12.brickfurnace.recipe; /* import cech12.brickfurnace.BrickFurnaceMod; import cech12.brickfurnace.api.block.BrickFurnaceBlocks; diff --git a/src/test/resources/data/brickfurnace/recipes/test_smoking.json b/forge/src/test/resources/data/brickfurnace/recipes/test_smoking.json similarity index 100% rename from src/test/resources/data/brickfurnace/recipes/test_smoking.json rename to forge/src/test/resources/data/brickfurnace/recipes/test_smoking.json diff --git a/src/test/resources/data/brickfurnace/structures/furnace/blast_furnace.nbt b/forge/src/test/resources/data/brickfurnace/structures/furnace/blast_furnace.nbt similarity index 100% rename from src/test/resources/data/brickfurnace/structures/furnace/blast_furnace.nbt rename to forge/src/test/resources/data/brickfurnace/structures/furnace/blast_furnace.nbt diff --git a/src/test/resources/data/brickfurnace/structures/furnace/furnace.nbt b/forge/src/test/resources/data/brickfurnace/structures/furnace/furnace.nbt similarity index 100% rename from src/test/resources/data/brickfurnace/structures/furnace/furnace.nbt rename to forge/src/test/resources/data/brickfurnace/structures/furnace/furnace.nbt diff --git a/src/test/resources/data/brickfurnace/structures/furnace/smoker.nbt b/forge/src/test/resources/data/brickfurnace/structures/furnace/smoker.nbt similarity index 100% rename from src/test/resources/data/brickfurnace/structures/furnace/smoker.nbt rename to forge/src/test/resources/data/brickfurnace/structures/furnace/smoker.nbt diff --git a/src/test/resources/data/brickfurnace/structures/hopper/hoppers.nbt b/forge/src/test/resources/data/brickfurnace/structures/hopper/hoppers.nbt similarity index 100% rename from src/test/resources/data/brickfurnace/structures/hopper/hoppers.nbt rename to forge/src/test/resources/data/brickfurnace/structures/hopper/hoppers.nbt diff --git a/src/test/resources/data/brickfurnace/structures/villagertests.villager_pit.nbt b/forge/src/test/resources/data/brickfurnace/structures/villagertests.villager_pit.nbt similarity index 100% rename from src/test/resources/data/brickfurnace/structures/villagertests.villager_pit.nbt rename to forge/src/test/resources/data/brickfurnace/structures/villagertests.villager_pit.nbt diff --git a/gradle.properties b/gradle.properties index 6a9c55e..dc46273 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,34 +1,48 @@ -# 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. -## Mod Properties +# Project +group=de.cech12.brickfurnace +mod_version=3.0.0.0 mod_id=brickfurnace -mod_version=2.2.0.3 -mod_group_id=cech12.brickfurnace mod_name=Brick Furnace -mod_authors=Cech12 +mod_author=Cech12 mod_license=The MIT License (MIT) mod_url=https://github.com/cech12/BrickFurnace mod_issue_tracker=https://github.com/cech12/BrickFurnace/issues -mod_description=A mod which adds Brick Furnaces. +description=A mod which adds Brick Furnaces. + +# 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.218 +neoforge_version_range=[20.4.218,) +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.0-9.0.0-1 -top_version_range=[1.20.0-9.0.0,) +top_version=1.20.4_neo-11.0.2-3 +top_version_range=[1.20.4_neo-11.0.2,) # immersive engineering -immersive_engineering_version=1.20.1-9.4.0-166.37 -immersive_engineering_version_range=[1.20.1-9.4.0,) +immersive_engineering_version=1.20.4-11.1.0-172.110 +immersive_engineering_version_range=[1.20.4-11.1.0,) + +# Gradle +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false \ No newline at end of file diff --git a/neoforge/build.gradle b/neoforge/build.gradle new file mode 100644 index 0000000..90f8a04 --- /dev/null +++ b/neoforge/build.gradle @@ -0,0 +1,96 @@ +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} + + runtimeOnly("blusunrize.immersiveengineering:ImmersiveEngineering:${project.immersive_engineering_version}") + compileOnly("blusunrize.immersiveengineering:ImmersiveEngineering:${project.immersive_engineering_version}:api") +} + +// 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/brickfurnace/BrickFurnaceMod.java b/neoforge/src/main/java/de/cech12/brickfurnace/BrickFurnaceMod.java new file mode 100644 index 0000000..19ad65b --- /dev/null +++ b/neoforge/src/main/java/de/cech12/brickfurnace/BrickFurnaceMod.java @@ -0,0 +1,48 @@ +package de.cech12.brickfurnace; + +import de.cech12.brickfurnace.compat.TOPCompat; +import de.cech12.brickfurnace.init.ModBlockEntityTypes; +import de.cech12.brickfurnace.init.ModBlocks; +import de.cech12.brickfurnace.init.ModItems; +import de.cech12.brickfurnace.init.ModPoiTypes; +import de.cech12.brickfurnace.init.ModRecipeTypes; +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.neoforge.event.BuildCreativeModeTabContentsEvent; + +import static de.cech12.brickfurnace.BrickFurnaceMod.MOD_ID; + +@Mod(MOD_ID) +@Mod.EventBusSubscriber(modid= MOD_ID, bus= Mod.EventBusSubscriber.Bus.MOD) +public class BrickFurnaceMod { + + public static final String MOD_ID = "brickfurnace"; + + public BrickFurnaceMod(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); + //ModPoiTypes.POI_TYPES.register(eventBus); //TODO POI registration does not work in Neoforge - find another way + //Config + CommonLoader.init(); + //The One Probe registration. + if (ModList.get().isLoaded("theoneprobe") && !ModList.get().isLoaded("topaddons")) { + TOPCompat.register(); + } + } + + @SubscribeEvent + public static void addItemsToTabs(BuildCreativeModeTabContentsEvent event) { + if (event.getTabKey() == CreativeModeTabs.FUNCTIONAL_BLOCKS) { + event.accept(Constants.BRICK_FURNACE_ITEM.get()); + event.accept(Constants.BRICK_BLAST_FURNACE_ITEM.get()); + event.accept(Constants.BRICK_SMOKER_ITEM.get()); + } + } + +} diff --git a/neoforge/src/main/java/de/cech12/brickfurnace/compat/EventHandler.java b/neoforge/src/main/java/de/cech12/brickfurnace/compat/EventHandler.java new file mode 100644 index 0000000..8b390ca --- /dev/null +++ b/neoforge/src/main/java/de/cech12/brickfurnace/compat/EventHandler.java @@ -0,0 +1,20 @@ +package de.cech12.brickfurnace.compat; + +import de.cech12.brickfurnace.compat.immersiveengineering.ImmersiveEngineering; +import de.cech12.brickfurnace.BrickFurnaceMod; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.ModList; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; + +@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD, modid=BrickFurnaceMod.MOD_ID) +public class EventHandler { + + @SubscribeEvent + public static void onCapabilitiesAttachBlockEntity(RegisterCapabilitiesEvent event) { + if (ModList.get().isLoaded("immersiveengineering")) { + ImmersiveEngineering.onCapabilitiesAttachBlockEntity(event); + } + } + +} diff --git a/src/main/java/cech12/brickfurnace/compat/TOPCompat.java b/neoforge/src/main/java/de/cech12/brickfurnace/compat/TOPCompat.java similarity index 91% rename from src/main/java/cech12/brickfurnace/compat/TOPCompat.java rename to neoforge/src/main/java/de/cech12/brickfurnace/compat/TOPCompat.java index 6b4feb9..d0bb463 100644 --- a/src/main/java/cech12/brickfurnace/compat/TOPCompat.java +++ b/neoforge/src/main/java/de/cech12/brickfurnace/compat/TOPCompat.java @@ -1,7 +1,7 @@ -package cech12.brickfurnace.compat; -/* -import cech12.brickfurnace.BrickFurnaceMod; -import cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; +package de.cech12.brickfurnace.compat; + +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; import mcjty.theoneprobe.api.CompoundText; import mcjty.theoneprobe.api.ElementAlignment; import mcjty.theoneprobe.api.IIconStyle; @@ -19,7 +19,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; @@ -39,7 +39,7 @@ public Void apply(ITheOneProbe probe) { @Override public ResourceLocation getID() { - return new ResourceLocation(BrickFurnaceMod.MOD_ID, "brickfurnaceinfo"); + return new ResourceLocation(Constants.MOD_ID, "brickfurnaceinfo"); } @Override @@ -72,4 +72,3 @@ public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player play } } } - */ diff --git a/src/main/java/cech12/brickfurnace/compat/immersiveengineering/BrickFurnaceHeater.java b/neoforge/src/main/java/de/cech12/brickfurnace/compat/immersiveengineering/BrickFurnaceHeater.java similarity index 90% rename from src/main/java/cech12/brickfurnace/compat/immersiveengineering/BrickFurnaceHeater.java rename to neoforge/src/main/java/de/cech12/brickfurnace/compat/immersiveengineering/BrickFurnaceHeater.java index 4e85e0c..8de061f 100644 --- a/src/main/java/cech12/brickfurnace/compat/immersiveengineering/BrickFurnaceHeater.java +++ b/neoforge/src/main/java/de/cech12/brickfurnace/compat/immersiveengineering/BrickFurnaceHeater.java @@ -1,12 +1,12 @@ -package cech12.brickfurnace.compat.immersiveengineering; -/* +package de.cech12.brickfurnace.compat.immersiveengineering; + import blusunrize.immersiveengineering.api.tool.ExternalHeaterHandler; -import cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; -import cech12.brickfurnace.blockentity.BrickFurnaceBlockEntity; +import de.cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; +import de.cech12.brickfurnace.blockentity.BrickFurnaceBlockEntity; import net.minecraft.core.RegistryAccess; import net.minecraft.world.inventory.ContainerData; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.AbstractCookingRecipe; +import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.block.AbstractFurnaceBlock; import net.minecraft.world.level.block.state.BlockState; @@ -24,9 +24,9 @@ public BrickFurnaceHeater(BrickFurnaceBlockEntity furnace) { boolean canCook(RegistryAccess registryAccess) { ItemStack input = furnace.getItem(AbstractBrickFurnaceBlockEntity.INPUT); if (input.isEmpty()) return false; - AbstractCookingRecipe recipe = furnace.getRecipe(); + RecipeHolder recipe = furnace.getRecipe(); if (recipe == null) return false; - ItemStack outStack = recipe.getResultItem(registryAccess); + ItemStack outStack = recipe.value().getResultItem(registryAccess); if (outStack.isEmpty()) return false; ItemStack existingOutput = furnace.getItem(2); if (existingOutput.isEmpty()) return true; @@ -82,4 +82,3 @@ public void setFurnaceActive() { } } } - */ diff --git a/neoforge/src/main/java/de/cech12/brickfurnace/compat/immersiveengineering/ImmersiveEngineering.java b/neoforge/src/main/java/de/cech12/brickfurnace/compat/immersiveengineering/ImmersiveEngineering.java new file mode 100644 index 0000000..e1215c1 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/brickfurnace/compat/immersiveengineering/ImmersiveEngineering.java @@ -0,0 +1,18 @@ +package de.cech12.brickfurnace.compat.immersiveengineering; + +import blusunrize.immersiveengineering.api.tool.ExternalHeaterHandler; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.blockentity.BrickFurnaceBlockEntity; +import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; + +public class ImmersiveEngineering { + + public static void onCapabilitiesAttachBlockEntity(RegisterCapabilitiesEvent event) { + event.registerBlock( + ExternalHeaterHandler.CAPABILITY, + (level, blockPos, blockState, blockEntity, direction) -> new BrickFurnaceHeater((BrickFurnaceBlockEntity)blockEntity), + Constants.BRICK_FURNACE_BLOCK.get() + ); + } + +} diff --git a/neoforge/src/main/java/de/cech12/brickfurnace/init/ModBlockEntityTypes.java b/neoforge/src/main/java/de/cech12/brickfurnace/init/ModBlockEntityTypes.java new file mode 100644 index 0000000..06a0c0d --- /dev/null +++ b/neoforge/src/main/java/de/cech12/brickfurnace/init/ModBlockEntityTypes.java @@ -0,0 +1,22 @@ +package de.cech12.brickfurnace.init; + +import de.cech12.brickfurnace.BrickFurnaceMod; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.blockentity.BrickBlastFurnaceBlockEntity; +import de.cech12.brickfurnace.blockentity.BrickFurnaceBlockEntity; +import de.cech12.brickfurnace.blockentity.BrickSmokerBlockEntity; +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, BrickFurnaceMod.MOD_ID); + + static { + Constants.BRICK_FURNACE_BLOCK_ENTITY_TYPE = BLOCK_ENTITY_TYPES.register(Constants.BRICK_FURNACE_NAME, () -> BlockEntityType.Builder.of(BrickFurnaceBlockEntity::new, Constants.BRICK_FURNACE_BLOCK.get()).build(null)); + Constants.BRICK_BLAST_FURNACE_BLOCK_ENTITY_TYPE = BLOCK_ENTITY_TYPES.register(Constants.BRICK_BLAST_FURNACE_NAME, () -> BlockEntityType.Builder.of(BrickBlastFurnaceBlockEntity::new, Constants.BRICK_BLAST_FURNACE_BLOCK.get()).build(null)); + Constants.BRICK_SMOKER_BLOCK_ENTITY_TYPE = BLOCK_ENTITY_TYPES.register(Constants.BRICK_SMOKER_NAME, () -> BlockEntityType.Builder.of(BrickSmokerBlockEntity::new, Constants.BRICK_SMOKER_BLOCK.get()).build(null)); + } + +} diff --git a/neoforge/src/main/java/de/cech12/brickfurnace/init/ModBlocks.java b/neoforge/src/main/java/de/cech12/brickfurnace/init/ModBlocks.java new file mode 100644 index 0000000..8df7981 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/brickfurnace/init/ModBlocks.java @@ -0,0 +1,32 @@ +package de.cech12.brickfurnace.init; + +import de.cech12.brickfurnace.BrickFurnaceMod; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.block.BrickBlastFurnaceBlock; +import de.cech12.brickfurnace.block.BrickFurnaceBlock; +import de.cech12.brickfurnace.block.BrickSmokerBlock; +import net.minecraft.world.level.material.MapColor; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +import java.util.function.ToIntFunction; + +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.neoforged.neoforge.registries.DeferredRegister; + +public final class ModBlocks { + + public static final DeferredRegister BLOCKS = DeferredRegister.createBlocks(BrickFurnaceMod.MOD_ID); + + static { + Constants.BRICK_FURNACE_BLOCK = BLOCKS.register(Constants.BRICK_FURNACE_NAME, () -> new BrickFurnaceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).requiresCorrectToolForDrops().strength(2.0F, 6.0F).lightLevel(getLightLevelWhenLit(13)))); + Constants.BRICK_BLAST_FURNACE_BLOCK = BLOCKS.register(Constants.BRICK_BLAST_FURNACE_NAME, () -> new BrickBlastFurnaceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).requiresCorrectToolForDrops().strength(2.0F, 6.0F).lightLevel(getLightLevelWhenLit(13)))); + Constants.BRICK_SMOKER_BLOCK = BLOCKS.register(Constants.BRICK_SMOKER_NAME, () -> new BrickSmokerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).requiresCorrectToolForDrops().strength(2.0F, 6.0F).lightLevel(getLightLevelWhenLit(13)))); + } + + private static ToIntFunction getLightLevelWhenLit(final int lightLevel) { + return (blockState) -> blockState.getValue(BlockStateProperties.LIT) ? lightLevel : 0; + } + +} \ No newline at end of file diff --git a/neoforge/src/main/java/de/cech12/brickfurnace/init/ModItems.java b/neoforge/src/main/java/de/cech12/brickfurnace/init/ModItems.java new file mode 100644 index 0000000..454c93b --- /dev/null +++ b/neoforge/src/main/java/de/cech12/brickfurnace/init/ModItems.java @@ -0,0 +1,27 @@ +package de.cech12.brickfurnace.init; + +import de.cech12.brickfurnace.BrickFurnaceMod; +import de.cech12.brickfurnace.Constants; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredRegister; + +import java.util.function.Supplier; + +public class ModItems { + + public static final DeferredRegister ITEMS = DeferredRegister.createItems(BrickFurnaceMod.MOD_ID); + + static { + Constants.BRICK_FURNACE_ITEM = fromBlock(Constants.BRICK_FURNACE_NAME, Constants.BRICK_FURNACE_BLOCK); + Constants.BRICK_BLAST_FURNACE_ITEM = fromBlock(Constants.BRICK_BLAST_FURNACE_NAME, Constants.BRICK_BLAST_FURNACE_BLOCK); + Constants.BRICK_SMOKER_ITEM = fromBlock(Constants.BRICK_SMOKER_NAME, Constants.BRICK_SMOKER_BLOCK); + } + + private static DeferredHolder fromBlock(String name, Supplier block) { + return ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties())); + } + +} diff --git a/neoforge/src/main/java/de/cech12/brickfurnace/init/ModPoiTypes.java b/neoforge/src/main/java/de/cech12/brickfurnace/init/ModPoiTypes.java new file mode 100644 index 0000000..0154c63 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/brickfurnace/init/ModPoiTypes.java @@ -0,0 +1,28 @@ +package de.cech12.brickfurnace.init; + +import de.cech12.brickfurnace.Constants; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.entity.ai.village.poi.PoiType; +import net.minecraft.world.entity.ai.village.poi.PoiTypes; +import net.minecraft.world.level.block.state.BlockState; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredRegister; + +import java.util.HashSet; + +public class ModPoiTypes { + + public static DeferredRegister POI_TYPES = DeferredRegister.create(BuiltInRegistries.POINT_OF_INTEREST_TYPE, "minecraft"); + + public static DeferredHolder ARMORER = POI_TYPES.register("armorer", () -> { + HashSet states = new HashSet<>(BuiltInRegistries.POINT_OF_INTEREST_TYPE.get(PoiTypes.ARMORER).matchingStates()); + states.addAll(Constants.BRICK_BLAST_FURNACE_BLOCK.get().getStateDefinition().getPossibleStates()); + return new PoiType(states, 1, 1); + }); + public static DeferredHolder BUTCHER = POI_TYPES.register("butcher", () ->{ + HashSet states = new HashSet<>(BuiltInRegistries.POINT_OF_INTEREST_TYPE.get(PoiTypes.BUTCHER).matchingStates()); + states.addAll(Constants.BRICK_SMOKER_BLOCK.get().getStateDefinition().getPossibleStates()); + return new PoiType(states, 1, 1); + }); + +} diff --git a/neoforge/src/main/java/de/cech12/brickfurnace/init/ModRecipeTypes.java b/neoforge/src/main/java/de/cech12/brickfurnace/init/ModRecipeTypes.java new file mode 100644 index 0000000..768e8c2 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/brickfurnace/init/ModRecipeTypes.java @@ -0,0 +1,29 @@ +package de.cech12.brickfurnace.init; + +import de.cech12.brickfurnace.BrickFurnaceMod; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.crafting.BrickBlastingRecipe; +import de.cech12.brickfurnace.crafting.BrickSmeltingRecipe; +import de.cech12.brickfurnace.crafting.BrickSmokingRecipe; +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, BrickFurnaceMod.MOD_ID); + public static DeferredRegister> RECIPE_SERIALIZERS = DeferredRegister.create(BuiltInRegistries.RECIPE_SERIALIZER, BrickFurnaceMod.MOD_ID); + + public static DeferredHolder, RecipeSerializer> BLASTING_SERIALIZER = RECIPE_SERIALIZERS.register(Constants.BLASTING_NAME, () -> BrickBlastingRecipe.SERIALIZER); + public static DeferredHolder, RecipeSerializer> SMELTING_SERIALIZER = RECIPE_SERIALIZERS.register(Constants.SMELTING_NAME, () -> BrickSmeltingRecipe.SERIALIZER); + public static DeferredHolder, RecipeSerializer> SMOKING_SERIALIZER = RECIPE_SERIALIZERS.register(Constants.SMOKING_NAME, () -> BrickSmokingRecipe.SERIALIZER); + + static { + Constants.BLASTING_RECIPE_TYPE = RECIPE_TYPES.register(Constants.BLASTING_NAME, () -> new RecipeType<>() {}); + Constants.SMELTING_RECIPE_TYPE = RECIPE_TYPES.register(Constants.SMELTING_NAME, () -> new RecipeType<>() {}); + Constants.SMOKING_RECIPE_TYPE = RECIPE_TYPES.register(Constants.SMOKING_NAME, () -> new RecipeType<>() {}); + } + +} diff --git a/neoforge/src/main/java/de/cech12/brickfurnace/platform/NeoForgeConfigHelper.java b/neoforge/src/main/java/de/cech12/brickfurnace/platform/NeoForgeConfigHelper.java new file mode 100644 index 0000000..60e4e02 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/brickfurnace/platform/NeoForgeConfigHelper.java @@ -0,0 +1,82 @@ +package de.cech12.brickfurnace.platform; + +import com.electronwill.nightconfig.core.file.CommentedFileConfig; +import com.electronwill.nightconfig.core.io.WritingMode; +import de.cech12.brickfurnace.Constants; +import de.cech12.brickfurnace.platform.services.IConfigHelper; +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.DoubleValue COOK_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 furnaces.").push("Furnace Settings"); + + VANILLA_RECIPES_ENABLED = builder + .comment(VANILLA_RECIPES_ENABLED_DESCRIPTION) + .define("vanillaRecipesEnabled", VANILLA_RECIPES_ENABLED_DEFAULT); + COOK_TIME_FACTOR = builder + .comment(COOK_TIME_FACTOR_DESCRIPTION) + .defineInRange("cookTimeFactor", COOK_TIME_FACTOR_DEFAULT, COOK_TIME_FACTOR_MIN, COOK_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 double getCookTimeFactor() { + try { + return COOK_TIME_FACTOR.get(); + } catch (IllegalStateException ex) { + return COOK_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/brickfurnace/platform/NeoForgePlatformHelper.java b/neoforge/src/main/java/de/cech12/brickfurnace/platform/NeoForgePlatformHelper.java new file mode 100644 index 0000000..75edc04 --- /dev/null +++ b/neoforge/src/main/java/de/cech12/brickfurnace/platform/NeoForgePlatformHelper.java @@ -0,0 +1,38 @@ +package de.cech12.brickfurnace.platform; + +import de.cech12.brickfurnace.platform.services.IPlatformHelper; +import net.minecraft.world.item.ItemStack; +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 "Neoforge"; + } + + @Override + public boolean isModLoaded(String modId) { + return ModList.get().isLoaded(modId); + } + + @Override + public boolean isDevelopmentEnvironment() { + return !FMLLoader.isProduction(); + } + + @Override + public boolean hasCraftingRemainingItem(ItemStack stack) { + return stack.hasCraftingRemainingItem(); + } + + @Override + public ItemStack getCraftingRemainingItem(ItemStack stack) { + return stack.getCraftingRemainingItem(); + } + +} diff --git a/neoforge/src/main/resources/META-INF/accesstransformer.cfg b/neoforge/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..ea1ee20 --- /dev/null +++ b/neoforge/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1 @@ +public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity dataAccess \ No newline at end of file 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..75ecf78 --- /dev/null +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,45 @@ +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" +[[dependencies.brickfurnace]] +modId="immersiveengineering" +type="optional" +versionRange="${immersive_engineering_version_range}" +referralUrl="https://github.com/BluSunrize/ImmersiveEngineering" +ordering="NONE" +side="BOTH" \ No newline at end of file diff --git a/neoforge/src/main/resources/META-INF/services/de.cech12.brickfurnace.platform.services.IConfigHelper b/neoforge/src/main/resources/META-INF/services/de.cech12.brickfurnace.platform.services.IConfigHelper new file mode 100644 index 0000000..9e5e454 --- /dev/null +++ b/neoforge/src/main/resources/META-INF/services/de.cech12.brickfurnace.platform.services.IConfigHelper @@ -0,0 +1 @@ +de.cech12.brickfurnace.platform.NeoForgeConfigHelper \ No newline at end of file diff --git a/neoforge/src/main/resources/META-INF/services/de.cech12.brickfurnace.platform.services.IPlatformHelper b/neoforge/src/main/resources/META-INF/services/de.cech12.brickfurnace.platform.services.IPlatformHelper new file mode 100644 index 0000000..bb9045f --- /dev/null +++ b/neoforge/src/main/resources/META-INF/services/de.cech12.brickfurnace.platform.services.IPlatformHelper @@ -0,0 +1 @@ +de.cech12.brickfurnace.platform.NeoForgePlatformHelper \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 291d399..b551a28 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 = 'BrickFurnace' +include("common") +//include("fabric") +include("forge") +include("neoforge") \ No newline at end of file diff --git a/src/main/java/cech12/brickfurnace/BrickFurnaceMod.java b/src/main/java/cech12/brickfurnace/BrickFurnaceMod.java deleted file mode 100644 index 5182b0e..0000000 --- a/src/main/java/cech12/brickfurnace/BrickFurnaceMod.java +++ /dev/null @@ -1,56 +0,0 @@ -package cech12.brickfurnace; - -//import cech12.brickfurnace.compat.TOPCompat; -import cech12.brickfurnace.init.ModBlockEntityTypes; -import cech12.brickfurnace.init.ModBlocks; -import cech12.brickfurnace.init.ModItems; -import cech12.brickfurnace.init.ModPoiTypes; -import cech12.brickfurnace.init.ModRecipeTypes; -import cech12.brickfurnace.config.ServerConfig; -import net.minecraft.world.item.CreativeModeTabs; -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.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fml.loading.FMLConfig; -import net.minecraftforge.fml.loading.FMLPaths; - -import static cech12.brickfurnace.BrickFurnaceMod.MOD_ID; - -@Mod(MOD_ID) -@Mod.EventBusSubscriber(modid= MOD_ID, bus= Mod.EventBusSubscriber.Bus.MOD) -public class BrickFurnaceMod { - - public static final String MOD_ID = "brickfurnace"; - - public BrickFurnaceMod() { - 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); - ModPoiTypes.POI_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") && !ModList.get().isLoaded("topaddons")) { - //TOPCompat.register(); - } - } - - @SubscribeEvent - public static void addItemsToTabs(BuildCreativeModeTabContentsEvent event) { - if (event.getTabKey() == CreativeModeTabs.FUNCTIONAL_BLOCKS) { - event.accept(ModItems.BRICK_FURNACE); - event.accept(ModItems.BRICK_BLAST_FURNACE); - event.accept(ModItems.BRICK_SMOKER); - } - } - -} diff --git a/src/main/java/cech12/brickfurnace/compat/EventHandler.java b/src/main/java/cech12/brickfurnace/compat/EventHandler.java deleted file mode 100644 index 4a4abba..0000000 --- a/src/main/java/cech12/brickfurnace/compat/EventHandler.java +++ /dev/null @@ -1,22 +0,0 @@ -package cech12.brickfurnace.compat; - -//import cech12.brickfurnace.compat.immersiveengineering.ImmersiveEngineering; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraftforge.event.AttachCapabilitiesEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.common.Mod; - -import static cech12.brickfurnace.BrickFurnaceMod.MOD_ID; - -@Mod.EventBusSubscriber(modid= MOD_ID) -public class EventHandler { - - @SubscribeEvent - public static void onCapabilitiesAttachBlockEntity(AttachCapabilitiesEvent event) { - if (ModList.get().isLoaded("immersiveengineering")) { - //ImmersiveEngineering.onCapabilitiesAttachBlockEntity(event); - } - } - -} diff --git a/src/main/java/cech12/brickfurnace/compat/immersiveengineering/ImmersiveEngineering.java b/src/main/java/cech12/brickfurnace/compat/immersiveengineering/ImmersiveEngineering.java deleted file mode 100644 index c28638c..0000000 --- a/src/main/java/cech12/brickfurnace/compat/immersiveengineering/ImmersiveEngineering.java +++ /dev/null @@ -1,45 +0,0 @@ -package cech12.brickfurnace.compat.immersiveengineering; -/* -import blusunrize.immersiveengineering.api.tool.ExternalHeaterHandler; -import blusunrize.immersiveengineering.api.utils.CapabilityUtils; -import cech12.brickfurnace.BrickFurnaceMod; -import cech12.brickfurnace.blockentity.BrickFurnaceBlockEntity; -import net.minecraft.core.Direction; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.event.AttachCapabilitiesEvent; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.Objects; -import java.util.function.Supplier; - -public class ImmersiveEngineering { - - public static void onCapabilitiesAttachBlockEntity(AttachCapabilitiesEvent event) { - if (event.getObject() instanceof BrickFurnaceBlockEntity furnace) { - event.addCapability(new ResourceLocation(BrickFurnaceMod.MOD_ID, "brick_furnace_heater"), - new SimpleCapProvider<>(() -> ExternalHeaterHandler.CAPABILITY, new BrickFurnaceHeater(furnace)) - ); - } - } - - public record SimpleCapProvider(Supplier> cap, LazyOptional value) implements ICapabilityProvider { - public SimpleCapProvider(Supplier> cap, T value) - { - this(cap, CapabilityUtils.constantOptional(value)); - } - - @Nonnull - @Override - public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) - { - return Objects.requireNonNull(this.cap.get()).orEmpty(cap, value); - } - } - -} - */ diff --git a/src/main/java/cech12/brickfurnace/config/ServerConfig.java b/src/main/java/cech12/brickfurnace/config/ServerConfig.java deleted file mode 100644 index 991c108..0000000 --- a/src/main/java/cech12/brickfurnace/config/ServerConfig.java +++ /dev/null @@ -1,58 +0,0 @@ -package cech12.brickfurnace.config; - -import com.electronwill.nightconfig.core.file.CommentedFileConfig; -import com.electronwill.nightconfig.core.io.WritingMode; -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.DoubleValue COOK_TIME_FACTOR; - public static final ForgeConfigSpec.ConfigValue RECIPE_BLACKLIST; - - static { - final ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder(); - - builder.comment("Options that affect the added furnaces.").push("Furnace Settings"); - VANILLA_RECIPES_ENABLED = builder - .comment("If enabled, the vanilla blasting, smelting, and smoking recipes are used by the brick furnaces.") - .define("vanillaRecipesEnabled", true); - COOK_TIME_FACTOR = builder - .comment("Cook time factor of all added brick furnaces in relation to corresponding vanilla furnaces. (i. e. 0.5 - half the time, 1.0 same time, 2.0 twice the time)") - .defineInRange("cookTimeFactor", 1.0, 0.0, 100.0); - RECIPE_BLACKLIST = builder - .comment("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\"") - .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 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/brickfurnace/init/ModBlockEntityTypes.java b/src/main/java/cech12/brickfurnace/init/ModBlockEntityTypes.java deleted file mode 100644 index 19a38f8..0000000 --- a/src/main/java/cech12/brickfurnace/init/ModBlockEntityTypes.java +++ /dev/null @@ -1,21 +0,0 @@ -package cech12.brickfurnace.init; - -import cech12.brickfurnace.BrickFurnaceMod; -import cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity; -import cech12.brickfurnace.blockentity.BrickBlastFurnaceBlockEntity; -import cech12.brickfurnace.blockentity.BrickFurnaceBlockEntity; -import cech12.brickfurnace.blockentity.BrickSmokerBlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; - -public final class ModBlockEntityTypes { - - public static DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, BrickFurnaceMod.MOD_ID); - - public static RegistryObject> BRICK_FURNACE = BLOCK_ENTITY_TYPES.register("brick_furnace", () -> BlockEntityType.Builder.of(BrickFurnaceBlockEntity::new, ModBlocks.BRICK_FURNACE.get()).build(null)); - public static RegistryObject> BRICK_BLAST_FURNACE = BLOCK_ENTITY_TYPES.register("brick_blast_furnace", () -> BlockEntityType.Builder.of(BrickBlastFurnaceBlockEntity::new, ModBlocks.BRICK_BLAST_FURNACE.get()).build(null)); - public static RegistryObject> BRICK_SMOKER = BLOCK_ENTITY_TYPES.register("brick_smoker", () -> BlockEntityType.Builder.of(BrickSmokerBlockEntity::new, ModBlocks.BRICK_SMOKER.get()).build(null)); - -} diff --git a/src/main/java/cech12/brickfurnace/init/ModBlocks.java b/src/main/java/cech12/brickfurnace/init/ModBlocks.java deleted file mode 100644 index 6676db0..0000000 --- a/src/main/java/cech12/brickfurnace/init/ModBlocks.java +++ /dev/null @@ -1,31 +0,0 @@ -package cech12.brickfurnace.init; - -import cech12.brickfurnace.BrickFurnaceMod; -import cech12.brickfurnace.block.BrickBlastFurnaceBlock; -import cech12.brickfurnace.block.BrickFurnaceBlock; -import cech12.brickfurnace.block.BrickSmokerBlock; -import net.minecraft.world.level.material.MapColor; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; - -import java.util.function.ToIntFunction; - -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.registries.RegistryObject; - -public final class ModBlocks { - - public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, BrickFurnaceMod.MOD_ID); - - public static final RegistryObject BRICK_FURNACE = BLOCKS.register("brick_furnace", () -> new BrickFurnaceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).requiresCorrectToolForDrops().strength(2.0F, 6.0F).lightLevel(getLightLevelWhenLit(13)))); - public static final RegistryObject BRICK_BLAST_FURNACE = BLOCKS.register("brick_blast_furnace", () -> new BrickBlastFurnaceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).requiresCorrectToolForDrops().strength(2.0F, 6.0F).lightLevel(getLightLevelWhenLit(13)))); - public static final RegistryObject BRICK_SMOKER = BLOCKS.register("brick_smoker", () -> new BrickSmokerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).requiresCorrectToolForDrops().strength(2.0F, 6.0F).lightLevel(getLightLevelWhenLit(13)))); - - private static ToIntFunction getLightLevelWhenLit(final int lightLevel) { - return (blockState) -> blockState.getValue(BlockStateProperties.LIT) ? lightLevel : 0; - } - -} \ No newline at end of file diff --git a/src/main/java/cech12/brickfurnace/init/ModItems.java b/src/main/java/cech12/brickfurnace/init/ModItems.java deleted file mode 100644 index c27b112..0000000 --- a/src/main/java/cech12/brickfurnace/init/ModItems.java +++ /dev/null @@ -1,23 +0,0 @@ -package cech12.brickfurnace.init; - -import cech12.brickfurnace.BrickFurnaceMod; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; - -public class ModItems { - - public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, BrickFurnaceMod.MOD_ID); - - public static final RegistryObject BRICK_FURNACE = fromBlock(ModBlocks.BRICK_FURNACE); - public static final RegistryObject BRICK_BLAST_FURNACE = fromBlock(ModBlocks.BRICK_BLAST_FURNACE); - public static final RegistryObject BRICK_SMOKER = fromBlock(ModBlocks.BRICK_SMOKER); - - private static RegistryObject fromBlock(RegistryObject block) { - return ITEMS.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties())); - } - -} diff --git a/src/main/java/cech12/brickfurnace/init/ModRecipeTypes.java b/src/main/java/cech12/brickfurnace/init/ModRecipeTypes.java deleted file mode 100644 index 52765a4..0000000 --- a/src/main/java/cech12/brickfurnace/init/ModRecipeTypes.java +++ /dev/null @@ -1,27 +0,0 @@ -package cech12.brickfurnace.init; - -import cech12.brickfurnace.BrickFurnaceMod; -import cech12.brickfurnace.crafting.BrickBlastingRecipe; -import cech12.brickfurnace.crafting.BrickSmeltingRecipe; -import cech12.brickfurnace.crafting.BrickSmokingRecipe; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; - -public class ModRecipeTypes { - - public static DeferredRegister> RECIPE_TYPES = DeferredRegister.create(ForgeRegistries.RECIPE_TYPES, BrickFurnaceMod.MOD_ID); - - public static RegistryObject> BLASTING = RECIPE_TYPES.register("blasting", () -> new RecipeType<>() {}); - public static RegistryObject> SMELTING = RECIPE_TYPES.register("smelting", () -> new RecipeType<>() {}); - public static RegistryObject> SMOKING = RECIPE_TYPES.register("smoking", () -> new RecipeType<>() {}); - - public static DeferredRegister> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, BrickFurnaceMod.MOD_ID); - - public static RegistryObject> BLASTING_SERIALIZER = RECIPE_SERIALIZERS.register("blasting", () -> BrickBlastingRecipe.SERIALIZER); - public static RegistryObject> SMELTING_SERIALIZER = RECIPE_SERIALIZERS.register("smelting", () -> BrickSmeltingRecipe.SERIALIZER); - public static RegistryObject> SMOKING_SERIALIZER = RECIPE_SERIALIZERS.register("smoking", () -> BrickSmokingRecipe.SERIALIZER); - -} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg deleted file mode 100644 index a6731c6..0000000 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ /dev/null @@ -1,2 +0,0 @@ -public net.minecraft.world.item.crafting.SimpleCookingSerializer$CookieBaker -public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity f_58311_ #dataAccess \ 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 f62ce8a..0000000 --- a/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,45 +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" -[[dependencies.brickfurnace]] - modId="immersiveengineering" - mandatory=false - versionRange="${immersive_engineering_version_range}" - referralUrl="https://github.com/BluSunrize/ImmersiveEngineering" - ordering="NONE" - side="BOTH" \ No newline at end of file