From 50ac2121236735936d9136de7fcb71a8951bee61 Mon Sep 17 00:00:00 2001 From: Yusuf Arfan Ismail Date: Tue, 7 Nov 2023 22:49:29 +0000 Subject: [PATCH] Added support for 1.20.2 for neo forge. --- build.gradle.kts | 64 +++++ .../CustomArmourCraftingTableRecipeBuilder.kt | 6 +- .../CustomToolCraftingTableRecipeBuilder.kt | 13 +- .../recipe/builder/EnchantmentsAndLevels.kt | 2 +- neoforge/CHANGELOG.md | 5 + neoforge/build.gradle.kts | 143 ++++------- neoforge/gradle.properties | 12 +- .../blocks/IngotFusionTollEnhancer.java | 2 +- .../CustomArmourCraftingTableScreen.java | 11 +- .../IngotFusionTollEnhancerBlockEntity.java | 38 ++- .../infusion/IngotFusionTollEnhancerMenu.java | 11 +- .../IngotFusionTollEnhancerScreen.java | 12 +- .../blocks/lit/LITBlock.java | 2 +- .../tool/CustomToolCraftingTableScreen.java | 24 +- ...AndToolsModShieldItemRendererProvider.java | 4 +- ...ndToolsModTridentItemRendererProvider.java | 4 +- .../core/init/BlockEntityTypeInit.java | 6 +- .../core/init/EntityTypeInit.java | 6 +- ...tomArmourCraftingTableRawShapedRecipe.java | 113 +++++++++ ...ustomToolCraftingTableRawShapedRecipe.java | 113 +++++++++ .../IngotFusionTollEnhancerRecipe.java | 87 +++---- .../armourandtoolsmod/ArmourAndToolsMod.kt | 6 +- .../armour/CustomArmourCraftingTableMenu.kt | 10 +- .../CustomArmourCraftingTableResultSlot.kt | 18 +- .../book/CustomArmourCraftingBookCategory.kt | 1 + ...otFusionTollEnhancerRecipeBookComponent.kt | 26 +- .../blocks/infusion/slots/InfusionFuelSlot.kt | 4 +- .../infusion/slots/OutputSlotItemHandler.kt | 8 +- .../tool/CustomToolCraftingTableMenu.kt | 10 +- .../tool/CustomToolCraftingTableResultSlot.kt | 16 +- .../book/CustomToolsCraftingBookCategory.kt | 1 + .../armourandtoolsmod/client/ClientEvents.kt | 10 +- .../entity/ArmourToolsModTridentEntity.kt | 2 +- .../armourandtoolsmod/core/init/BlockInit.kt | 8 +- .../core/init/CreativeModeTabInit.kt | 4 +- .../armourandtoolsmod/core/init/ItemInit.kt | 10 +- .../core/init/MenuTypeInit.kt | 12 +- .../core/init/MobEffectsInit.kt | 6 +- .../core/init/PotionsInit.kt | 8 +- .../core/init/RecipeCategoriesInit.kt | 14 +- .../core/init/RecipeSerializerInit.kt | 8 +- .../core/init/RecipeTypeInit.kt | 8 +- .../core/material/CustomToolMaterial.kt | 1 + .../armourandtoolsmod/core/util/NameUtils.kt | 2 +- .../datagen/DataGenerators.kt | 9 +- .../datagen/advancment/Advancements.kt | 81 ++---- .../advancment/ModAdvancementProvider.kt | 6 +- .../datagen/lang/ModEnLangProvider.kt | 2 +- .../datagen/loot/ModBlockLootTables.kt | 2 +- .../datagen/recipe/MainModRecipeProvider.kt | 29 ++- .../CustomArmourCraftingTableRecipeBuilder.kt | 74 +++--- .../CustomToolCraftingTableRecipeBuilder.kt | 81 +++--- .../recipe/builder/EnchantmentsAndLevels.kt | 32 --- .../IngotFusionTollEnhancerRecipeBuilder.kt | 85 +++---- .../ArmourCraftingTableRecipeProvider.kt | 5 +- .../recipe/provider/FurnaceRecipeProvider.kt | 5 +- .../IngotFusionTollEnhancerRecipeProvider.kt | 5 +- .../NewSmithingTableRecipeProvider.kt | 5 +- .../NormalCraftingTableRecipeProvider.kt | 5 +- .../ToolCraftingTableRecipeProvider.kt | 5 +- .../ArmourAndTollsModSpriteSourceProvider.kt | 16 +- .../datagen/tags/ModBlockTagsProvider.kt | 4 +- .../datagen/tags/ModItemTagsProvider.kt | 4 +- .../datagen/texture/ModBlockStateProvider.kt | 6 +- .../datagen/texture/ModItemStateProvider.kt | 12 +- .../datagen/world/ModWorldGenProvider.kt | 2 +- .../items/hammer/HammerItem.kt | 14 +- .../armourandtoolsmod/items/hammer/Mjolnir.kt | 2 +- .../items/shield/ArmourToolsModShieldItem.kt | 2 +- .../items/trident/AqumarineTridentItem.kt | 2 +- .../trident/ArmourToolsModTridentItem.kt | 2 +- .../CustomArmourCraftingTableShapedRecipe.kt | 240 +++++++----------- .../CustomToolCraftingTableShapedRecipe.kt | 225 ++++++---------- .../armourandtoolsmod/util/KeyBinding.kt | 2 +- .../resources/META-INF/accesstransformer.cfg | 4 +- .../src/main/resources/META-INF/mods.toml | 6 +- ...t_fusion_toll_enhancer_filter_disabled.png | Bin 0 -> 237 bytes ...l_enhancer_filter_disabled_highlighted.png | Bin 0 -> 242 bytes ...ot_fusion_toll_enhancer_filter_enabled.png | Bin 0 -> 243 bytes ...ll_enhancer_filter_enabled_highlighted.png | Bin 0 -> 244 bytes neoforge/src/main/temp_remove/Info.md | 1 + .../init => temp_remove}/JEIRecipeTypes.kt | 0 .../integration/ArmourAndToolsModJEIPlugin.kt | 0 ...tomArmourCraftingTableJEIRecipeCategory.kt | 0 ...ngotFusionTollEnhancerJEIRecipeCategory.kt | 0 .../GenericCraftingTableJEIRecipeCategory.kt | 0 ...ustomToolCraftingTableJEIRecipeCategory.kt | 0 87 files changed, 935 insertions(+), 911 deletions(-) create mode 100644 neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/codec/CustomArmourCraftingTableRawShapedRecipe.java create mode 100644 neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/codec/CustomToolCraftingTableRawShapedRecipe.java delete mode 100644 neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/EnchantmentsAndLevels.kt create mode 100644 neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_disabled.png create mode 100644 neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_disabled_highlighted.png create mode 100644 neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_enabled.png create mode 100644 neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_enabled_highlighted.png create mode 100644 neoforge/src/main/temp_remove/Info.md rename neoforge/src/main/{kotlin/io/github/realyusufismail/armourandtoolsmod/core/init => temp_remove}/JEIRecipeTypes.kt (100%) rename neoforge/src/main/{kotlin/io/github/realyusufismail/armourandtoolsmod => temp_remove}/integration/ArmourAndToolsModJEIPlugin.kt (100%) rename neoforge/src/main/{kotlin/io/github/realyusufismail/armourandtoolsmod => temp_remove}/integration/armour/CustomArmourCraftingTableJEIRecipeCategory.kt (100%) rename neoforge/src/main/{kotlin/io/github/realyusufismail/armourandtoolsmod => temp_remove}/integration/fusion/IngotFusionTollEnhancerJEIRecipeCategory.kt (100%) rename neoforge/src/main/{kotlin/io/github/realyusufismail/armourandtoolsmod => temp_remove}/integration/generic/GenericCraftingTableJEIRecipeCategory.kt (100%) rename neoforge/src/main/{kotlin/io/github/realyusufismail/armourandtoolsmod => temp_remove}/integration/tool/CustomToolCraftingTableJEIRecipeCategory.kt (100%) diff --git a/build.gradle.kts b/build.gradle.kts index bed9cb44..7850d556 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,6 +40,7 @@ allprojects { subprojects { apply(plugin = "org.jetbrains.kotlin.jvm") apply(plugin = "jacoco") + apply(plugin = "com.diffplug.spotless") dependencies { // Json @@ -64,6 +65,69 @@ subprojects { } finalizedBy("jacocoTestCoverageVerification") } + + spotless { + kotlin { + // Excludes build folder since it contains generated java classes. + targetExclude("build/**") + ktfmt("0.42").dropboxStyle() + + licenseHeader( + """/* + * Copyright 2023 RealYusufIsmail. + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ """) + } + + kotlinGradle { + target("**/*.gradle.kts") + ktfmt("0.42").dropboxStyle() + trimTrailingWhitespace() + indentWithSpaces() + endWithNewline() + } + + java { + target("**/*.java") + googleJavaFormat() + trimTrailingWhitespace() + indentWithSpaces() + endWithNewline() + licenseHeader( + """/* + * Copyright 2023 RealYusufIsmail. + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ """) + } + } } spotless { diff --git a/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomArmourCraftingTableRecipeBuilder.kt b/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomArmourCraftingTableRecipeBuilder.kt index 7637afb0..8b307fa6 100644 --- a/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomArmourCraftingTableRecipeBuilder.kt +++ b/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomArmourCraftingTableRecipeBuilder.kt @@ -232,9 +232,9 @@ object CustomArmourCraftingTableRecipeBuilder { key: Map, advancement: Advancement.Builder, advancementId: ResourceLocation, - showNotification: Boolean, - val enchantmentsAndLevels: EnchantmentsAndLevels, - val hideFlags: Boolean, + private val showNotification: Boolean, + private val enchantmentsAndLevels: EnchantmentsAndLevels, + private val hideFlags: Boolean, ) : FinishedRecipe { override fun serializeRecipeData(jsonObject: JsonObject) { if (group.isNotEmpty()) { diff --git a/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomToolCraftingTableRecipeBuilder.kt b/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomToolCraftingTableRecipeBuilder.kt index fc98b8d0..6eda9833 100644 --- a/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomToolCraftingTableRecipeBuilder.kt +++ b/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomToolCraftingTableRecipeBuilder.kt @@ -133,13 +133,6 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { return this } - fun addEnchantments( - enchantmentsAndLevels: EnchantmentsAndLevels - ): CustomToolCraftingTableRecipeBuilder { - this.enchantmentsAndLevels.addAll(enchantmentsAndLevels) - return this - } - fun hideFlags(hideFlags: Int): CustomToolCraftingTableRecipeBuilder { this.hideFlags = hideFlags return this @@ -238,9 +231,9 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { key: Map, advancement: Advancement.Builder, advancementId: ResourceLocation, - showNotification: Boolean, - enchantmentsAndLevels: EnchantmentsAndLevels, - hideFlags: Int = 0, + private val showNotification: Boolean, + private val enchantmentsAndLevels: EnchantmentsAndLevels, + private val hideFlags: Int = 0, ) : FinishedRecipe { override fun serializeRecipeData(jsonObject: JsonObject) { if (group.isNotEmpty()) { diff --git a/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/EnchantmentsAndLevels.kt b/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/EnchantmentsAndLevels.kt index 518be3bb..3ff78e40 100644 --- a/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/EnchantmentsAndLevels.kt +++ b/forge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/EnchantmentsAndLevels.kt @@ -22,7 +22,7 @@ import net.minecraft.world.item.enchantment.Enchantment class EnchantmentsAndLevels : MutableMap by mutableMapOf() { - fun add(enchantment: net.minecraft.world.item.enchantment.Enchantment, level: Int) { + fun add(enchantment: Enchantment, level: Int) { put(enchantment, level) } diff --git a/neoforge/CHANGELOG.md b/neoforge/CHANGELOG.md index 6152b90b..1c7a257f 100644 --- a/neoforge/CHANGELOG.md +++ b/neoforge/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. +# [1.20.2-2.0.0.beta1] - 2023-11-13 + +### Added support for 1.20.2 for neo forge. No longer works with forge mods. +### Fixed some minor issues. + ## [1.20.1-1.0.7.beta2] - 2023-10-24 ### Added support for new forge. Changelog for both versions will now be split. diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index fccb4c97..66e87487 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -1,9 +1,6 @@ -import net.minecraftforge.gradle.userdev.UserDevExtension - plugins { kotlin("jvm") version "1.9.10" - id("net.neoforged.gradle") version "[6.0.18,6.2)" - id("org.parchmentmc.librarian.forgegradle") version "1.+" + id("net.neoforged.gradle.userdev") version "7.0.26" } project.version = properties["modVersion"] as String @@ -14,6 +11,8 @@ val mcVersion = properties["mcVersion"] as String var projectId = properties["projectId"] as String val modId = properties["modId"] as String +java.toolchain.languageVersion.set(JavaLanguageVersion.of(17)) + println( """ Java: ${System.getProperty("java.version")} @@ -22,92 +21,35 @@ println( """ .trimIndent()) -configure { - mappings("parchment", "2023.09.03-$mcVersion") - - accessTransformer("src/main/resources/META-INF/accesstransformer.cfg") - - runs { - create("client") { - workingDirectory(file("run")) - - // add mixin - property("mixin.env.remapRefMap", "true") - property( - "mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg") - - // Recommended logging data for a userdev environment - property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP") - - // Recommended logging level for the console - property("forge.logging.console.level", "debug") - - mods { create(modId) { source(sourceSets["main"]) } } - } - - create("server") { - workingDirectory(file("run")) - - // add mixin - property("mixin.env.remapRefMap", "true") - property( - "mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg") - - // Recommended logging data for a userdev environment - property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP") +accessTransformers.file("src/main/resources/META-INF/accesstransformer.cfg") - // Recommended logging level for the console - property("forge.logging.console.level", "debug") - - mods { create(modId) { source(sourceSets["main"]) } } - } - - create("gameTestServer") { - workingDirectory(file("run")) - - // add mixin - property("mixin.env.remapRefMap", "true") - property( - "mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg") - - // Recommended logging data for a userdev environment - property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP") - - // Recommended logging level for the console - property("forge.logging.console.level", "debug") - - mods { create(modId) { source(sourceSets["main"]) } } - } - - create("data") { - workingDirectory(file("run-data")) - // add mixin - property("mixin.env.remapRefMap", "true") - property( - "mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg") +runs { + configureEach { + systemProperty("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP") + systemProperty("forge.logging.console.level", "debug") + modSource(project.sourceSets.main.get()) + } - // Recommended logging data for a userdev environment - property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP") + create("client") { systemProperty("forge.enabledGameTestNamespaces", modId) } - // Recommended logging level for the console - property("forge.logging.console.level", "debug") + create("server") { + systemProperty("forge.enabledGameTestNamespaces", modId) + programArguments.set(listOf("--nogui")) + } - // Specify the mod id for data generation, where to output the resulting resource, and - // where to look for existing resources. - args( - "--mod", - modId, - "--all", - "--output", - file("src/generated/resources/"), - "--existing", - file("src/main/resources/")) + create("gameTestServer") { systemProperty("forge.enabledGameTestNamespaces", modId) } - mods { create(modId) { source(sourceSets["main"]) } } + create("data") { + workingDirectory(file("run-data")) - // 'runData' is renamed to 'runDataGenerator' to make it more clear what it does. - taskName = "runDataGenerator" - } + programArguments.addAll( + "--mod", + modId, + "--all", + "--output", + file("src/generated/resources/").absolutePath, + "--existing", + file("src/main/resources/").absolutePath) } } @@ -116,10 +58,10 @@ sourceSets.main { resources.srcDir("src/generated/resources") } configurations { compileOnly { extendsFrom(configurations.annotationProcessor.get()) } } dependencies { - minecraft("net.neoforged:forge:${mcVersion}-" + properties["neoForgeVersion"]) + implementation("net.neoforged:neoforge:" + properties["neoForgeVersion"]) // kotlin forge - implementation("thedarkcolour:kotlinforforge:" + properties["kotlinForForgeVersion"]) + implementation("thedarkcolour:kotlinforforge-neoforge:" + properties["kotlinForForgeVersion"]) // Logger implementation("ch.qos.logback:logback-classic:" + properties["logbackVersion"]) @@ -129,9 +71,10 @@ dependencies { implementation("io.github.realyusufismail:realyusufismailcore-neo:" + properties["coreVersion"]) // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime - compileOnly(fg.deobf("mezz.jei:jei-${mcVersion}-common-api:" + properties["jeiVersion"])) - compileOnly(fg.deobf("mezz.jei:jei-${mcVersion}-forge-api:" + properties["jeiVersion"])) - runtimeOnly(fg.deobf("mezz.jei:jei-${mcVersion}-forge:" + properties["jeiVersion"])) + // TODO: Reinstate support once JEI releases support for NEoForge. + // compileOnly("mezz.jei:jei-${mcVersion}-common-api:" + properties["jeiVersion"]) + // compileOnly("mezz.jei:jei-${mcVersion}-forge-api:" + properties["jeiVersion"]) + // runtimeOnly("mezz.jei:jei-${mcVersion}-forge:" + properties["jeiVersion"]) // lombok compileOnly("org.projectlombok:lombok:" + properties["lombokVersion"]) @@ -157,8 +100,28 @@ tasks.create("cfPublish", net.darkhax.curseforgegradle.TaskPublishCurseForge::cl mainFile.changelogType = "markdown" mainFile.releaseType = "release" mainFile.addEmbedded("kotlin-for-forge") - mainFile.addEmbedded("realyusufismail-core") + // mainFile.addEmbedded("realyusufismail-core") mainFile.addJavaVersion("Java 17") mainFile.addModLoader("NeoForge") mainFile.addGameVersion(mcVersion) } + +tasks.withType(ProcessResources::class.java) { + val replaceProperties = + mapOf( + "minecraft_version" to mcVersion, + "minecraft_version_range" to "[1.20.2,1.21)", + "neo_version" to properties["neoForgeVersion"], + "neo_version_range" to "[20.2)", + "loader_version_range" to "[1,)", + "mod_id" to modId, + "mod_license" to "Apache-2.0", + "mod_version" to project.version, + "mod_authors" to "RealYusufIsmail", + "mod_description" to "A Minecraft mod that adds more armour and tools", + "pack_format_number" to "18") + + inputs.properties(replaceProperties) + + filesMatching(listOf("META-INF/mods.toml", "pack.mcmeta")) { expand(replaceProperties) } +} diff --git a/neoforge/gradle.properties b/neoforge/gradle.properties index 764f48bc..985a2324 100644 --- a/neoforge/gradle.properties +++ b/neoforge/gradle.properties @@ -2,15 +2,15 @@ kotlin.code.style=official org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -modVersion = 1.20.1-1.0.7.beta2 -mcVersion = 1.20.1 +modVersion = 1.20.2-2.0.0.beta1 +mcVersion = 1.20.2 projectId = 480779 modId = armourandtoolsmod -neoForgeVersion = 47.1.76 -kotlinForForgeVersion = 4.4.0 +neoForgeVersion = 20.2.35-beta +kotlinForForgeVersion = 4.6.1 logbackVersion = 1.4.11 junitVersion = 5.10.0 -coreVersion = 1.20.1-1.0.2 -jeiVersion = 15.2.0.27 +coreVersion = 1.20.2-1.0.3 +jeiVersion = 16.0.0.28 lombokVersion = 1.18.30 \ No newline at end of file diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/IngotFusionTollEnhancer.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/IngotFusionTollEnhancer.java index 2e4aad01..458cbdd3 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/IngotFusionTollEnhancer.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/IngotFusionTollEnhancer.java @@ -48,7 +48,7 @@ import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.level.material.MapColor; import net.minecraft.world.phys.BlockHitResult; -import net.minecraftforge.network.NetworkHooks; +import net.neoforged.neoforge.network.NetworkHooks; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableScreen.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableScreen.java index 5df64be0..0f0145a8 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableScreen.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableScreen.java @@ -55,21 +55,19 @@ protected void init() { this.widthTooNarrow, this.menu); this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth); + this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth); this.addRenderableWidget( new ImageButton( this.leftPos + 5, this.height / 2 - 49, 20, 18, - 0, - 0, - 19, - RECIPE_BUTTON_LOCATION, - (p_98484_) -> { + RecipeBookComponent.RECIPE_BUTTON_SPRITES, + (p_289630_) -> { this.recipeBookComponent.toggleVisibility(); this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth); - p_98484_.setPosition(this.leftPos + 5, this.height / 2 - 49); + p_289630_.setPosition(this.leftPos + 5, this.height / 2 - 49); })); this.addWidget(this.recipeBookComponent); this.setInitialFocus(this.recipeBookComponent); @@ -90,7 +88,6 @@ public void containerTick() { * @param pPartialTick the partial tick time. */ public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) { - this.renderBackground(pGuiGraphics); if (this.recipeBookComponent.isVisible() && this.widthTooNarrow) { this.renderBg(pGuiGraphics, pPartialTick, pMouseX, pMouseY); this.recipeBookComponent.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick); diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerBlockEntity.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerBlockEntity.java index a35bd0cf..00e4a5c7 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerBlockEntity.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerBlockEntity.java @@ -51,15 +51,12 @@ import net.minecraft.world.entity.player.StackedContents; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.ContainerData; -import net.minecraft.world.inventory.RecipeHolder; +import net.minecraft.world.inventory.RecipeCraftingHolder; import net.minecraft.world.inventory.StackedContentsCompatible; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.AbstractCookingRecipe; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeManager; -import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.world.level.block.entity.BaseContainerBlockEntity; @@ -72,7 +69,7 @@ * @see AbstractFurnaceBlockEntity */ public class IngotFusionTollEnhancerBlockEntity extends BaseContainerBlockEntity - implements WorldlyContainer, RecipeHolder, StackedContentsCompatible { + implements WorldlyContainer, RecipeCraftingHolder, StackedContentsCompatible { @Getter private final RecipeManager.CachedCheck quickCheck; @@ -335,11 +332,7 @@ private void createItem(Level level) { ingredient2 = ingredient2Remaining; } else if (!this.level.isClientSide) { Containers.dropItemStack( - this.level, - (double) blockPos.getX(), - (double) blockPos.getY(), - (double) blockPos.getZ(), - ingredient2Remaining); + this.level, blockPos.getX(), blockPos.getY(), blockPos.getZ(), ingredient2Remaining); } } else { ingredient2.shrink(1); @@ -373,13 +366,13 @@ private void createItem(Level level) { private boolean hasRecipe(ItemStack ingredient) { return level.getRecipeManager().getAllRecipesFor(type).stream() - .anyMatch(recipe -> recipe.isIngredient(ingredient)); + .anyMatch(recipe -> recipe.value().isIngredient(ingredient)); } private ItemStack getOutput( Level level, ItemStack ingredient1, ItemStack ingredient2, ItemStack ingredient3) { return level.getRecipeManager().getAllRecipesFor(type).stream() - .map(recipe -> recipe.getResult(ingredient1, ingredient2, ingredient3)) + .map(recipe -> recipe.value().getResult(ingredient1, ingredient2, ingredient3)) .filter(itemStack -> !itemStack.isEmpty()) .findFirst() .orElse(ItemStack.EMPTY); @@ -437,16 +430,15 @@ public boolean canTakeItemThroughFace(int pIndex, ItemStack pStack, Direction pD } @Override - public void setRecipeUsed(@Nullable Recipe pRecipe) { - if (pRecipe != null) { - ResourceLocation resourcelocation = pRecipe.getId(); + public void setRecipeUsed(@Nullable RecipeHolder recipe) { + if (recipe != null) { + ResourceLocation resourcelocation = recipe.id(); this.recipesUsed.addTo(resourcelocation, 1); } } - @Nullable @Override - public Recipe getRecipeUsed() { + public RecipeHolder getRecipeUsed() { return null; } @@ -460,11 +452,11 @@ public void fillStackedContents(StackedContents pContents) { public void awardUsedRecipes(Player pPlayer, List pItems) {} public void awardUsedRecipesAndPopExperience(ServerPlayer pPlayer) { - List> list = + List> list = this.getRecipesToAwardAndPopExperience(pPlayer.serverLevel(), pPlayer.position()); pPlayer.awardRecipes(list); - for (Recipe recipe : list) { + for (RecipeHolder recipe : list) { if (recipe != null) { pPlayer.triggerRecipeCrafted(recipe, this.items); } @@ -473,8 +465,8 @@ public void awardUsedRecipesAndPopExperience(ServerPlayer pPlayer) { this.recipesUsed.clear(); } - public List> getRecipesToAwardAndPopExperience(ServerLevel pLevel, Vec3 pPopVec) { - List> list = Lists.newArrayList(); + public List> getRecipesToAwardAndPopExperience(ServerLevel pLevel, Vec3 pPopVec) { + List> list = Lists.newArrayList(); for (Object2IntMap.Entry entry : this.recipesUsed.object2IntEntrySet()) { pLevel @@ -487,7 +479,7 @@ public List> getRecipesToAwardAndPopExperience(ServerLevel pLevel, Vec pLevel, pPopVec, entry.getIntValue(), - ((AbstractCookingRecipe) p_155023_).getExperience()); + ((AbstractCookingRecipe) p_155023_.value()).getExperience()); }); } diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerMenu.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerMenu.java index 86f54bb2..8557fd07 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerMenu.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerMenu.java @@ -33,11 +33,12 @@ import net.minecraft.world.inventory.*; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BaseContainerBlockEntity; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.items.SlotItemHandler; +import net.neoforged.neoforge.common.capabilities.Capabilities; +import net.neoforged.neoforge.items.SlotItemHandler; import org.jetbrains.annotations.NotNull; /** @@ -71,7 +72,7 @@ public IngotFusionTollEnhancerMenu( addPlayerHotbar(pInventory); blockEntity - .getCapability(ForgeCapabilities.ITEM_HANDLER) + .getCapability(Capabilities.ITEM_HANDLER) .ifPresent( it -> { // slots to place ingredients @@ -185,8 +186,8 @@ public void clearCraftingContent() { } @Override - public boolean recipeMatches(Recipe pRecipe) { - return pRecipe.matches(this.blockEntity, this.level); + public boolean recipeMatches(RecipeHolder> recipeHolder) { + return recipeHolder.value().matches(this.blockEntity, this.level); } @Override diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerScreen.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerScreen.java index 6b174b70..66c56ba3 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerScreen.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/IngotFusionTollEnhancerScreen.java @@ -70,16 +70,14 @@ protected void init() { this.height / 2 - 22, 20, 18, - 0, - 0, - 19, - RECIPE_BUTTON_LOCATION, - (p_98484_) -> { + IngotFusionTollEnhancerRecipeBookComponent.RECIPE_BUTTON_SPRITES, + (p_289630_) -> { this.recipeBookComponent.toggleVisibility(); this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth); - p_98484_.setPosition(this.leftPos + 5, this.height / 2 - 22); + p_289630_.setPosition(this.leftPos + 5, this.height / 2 - 22); })); + this.addWidget(this.recipeBookComponent); this.setInitialFocus(this.recipeBookComponent); this.titleLabelX = 29; @@ -112,8 +110,6 @@ protected void renderBg( public void render( @NotNull GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) { try { - this.renderBackground(pGuiGraphics); - if (this.recipeBookComponent.isVisible() && this.widthTooNarrow) { this.renderBg(pGuiGraphics, pPartialTick, pMouseX, pMouseY); this.recipeBookComponent.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick); diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/lit/LITBlock.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/lit/LITBlock.java index a4b6f1a4..9e9cad99 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/lit/LITBlock.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/lit/LITBlock.java @@ -71,7 +71,7 @@ protected LITBlock( private static void interact(BlockState pState, Level pLevel, BlockPos pPos) { spawnParticles(pLevel, pPos); if (!pState.getValue(LIT)) { - pLevel.setBlock(pPos, pState.setValue(LIT, Boolean.valueOf(true)), 3); + pLevel.setBlock(pPos, pState.setValue(LIT, Boolean.TRUE), 3); } } diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableScreen.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableScreen.java index 42f85a06..816be63c 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableScreen.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableScreen.java @@ -20,7 +20,6 @@ import java.util.Objects; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.components.ImageButton; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener; @@ -58,22 +57,12 @@ protected void init() { this.widthTooNarrow, this.menu); this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth); - this.addRenderableWidget( - new ImageButton( - this.leftPos + 5, - this.height / 2 - 49, - 20, - 18, - 0, - 0, - 19, - RECIPE_BUTTON_LOCATION, - (p_98484_) -> { - this.recipeBookComponent.toggleVisibility(); - this.leftPos = - this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth); - p_98484_.setPosition(this.leftPos + 5, this.height / 2 - 49); - })); + this.recipeBookComponent.init( + this.width, + this.height, + Objects.requireNonNull(this.minecraft, "Minecraft is null in table screen"), + this.widthTooNarrow, + this.menu); this.addWidget(this.recipeBookComponent); this.setInitialFocus(this.recipeBookComponent); this.titleLabelX = 29; @@ -93,7 +82,6 @@ public void containerTick() { * @param pPartialTick the partial tick time. */ public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) { - this.renderBackground(pGuiGraphics); if (this.recipeBookComponent.isVisible() && this.widthTooNarrow) { this.renderBg(pGuiGraphics, pPartialTick, pMouseX, pMouseY); this.recipeBookComponent.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick); diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/client/ArmourAndToolsModShieldItemRendererProvider.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/client/ArmourAndToolsModShieldItemRendererProvider.java index 87f0d2a1..b372b6b2 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/client/ArmourAndToolsModShieldItemRendererProvider.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/client/ArmourAndToolsModShieldItemRendererProvider.java @@ -19,8 +19,8 @@ package io.github.realyusufismail.armourandtoolsmod.client; import io.github.realyusufismail.armourandtoolsmod.client.renderer.shield.ArmourAndToolsModShieldItemRenderer; -import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; -import net.minecraftforge.client.extensions.common.IClientItemExtensions; +import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; +import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions; public class ArmourAndToolsModShieldItemRendererProvider { private static ArmourAndToolsModShieldItemRenderer shieldItemRenderer; diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/client/ArmourAndToolsModTridentItemRendererProvider.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/client/ArmourAndToolsModTridentItemRendererProvider.java index ab856736..91511ab2 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/client/ArmourAndToolsModTridentItemRendererProvider.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/client/ArmourAndToolsModTridentItemRendererProvider.java @@ -20,8 +20,8 @@ import io.github.realyusufismail.armourandtoolsmod.client.renderer.mjolnir.MjolnirItemRendererISTER; import io.github.realyusufismail.armourandtoolsmod.client.renderer.trident.aq.AqumarineTridentItemRendererISTER; -import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; -import net.minecraftforge.client.extensions.common.IClientItemExtensions; +import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; +import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions; public class ArmourAndToolsModTridentItemRendererProvider { private static AqumarineTridentItemRendererISTER aqumarineTridentItemRendererISTER; diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/core/init/BlockEntityTypeInit.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/core/init/BlockEntityTypeInit.java index ed0873c2..ffb7fabe 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/core/init/BlockEntityTypeInit.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/core/init/BlockEntityTypeInit.java @@ -21,9 +21,9 @@ import io.github.realyusufismail.armourandtoolsmod.ArmourAndToolsMod; import io.github.realyusufismail.armourandtoolsmod.blocks.infusion.IngotFusionTollEnhancerBlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; +import net.neoforged.neoforge.registries.DeferredRegister; +import net.neoforged.neoforge.registries.ForgeRegistries; +import net.neoforged.neoforge.registries.RegistryObject; public class BlockEntityTypeInit { diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/core/init/EntityTypeInit.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/core/init/EntityTypeInit.java index 14826521..a6b58682 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/core/init/EntityTypeInit.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/core/init/EntityTypeInit.java @@ -24,9 +24,9 @@ import io.github.realyusufismail.armourandtoolsmod.common.entity.MjolnirEntity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; +import net.neoforged.neoforge.registries.DeferredRegister; +import net.neoforged.neoforge.registries.ForgeRegistries; +import net.neoforged.neoforge.registries.RegistryObject; public class EntityTypeInit { public static DeferredRegister> ENTITY_TYPES = diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/codec/CustomArmourCraftingTableRawShapedRecipe.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/codec/CustomArmourCraftingTableRawShapedRecipe.java new file mode 100644 index 00000000..6b2cac29 --- /dev/null +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/codec/CustomArmourCraftingTableRawShapedRecipe.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 RealYusufIsmail. + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.github.realyusufismail.armourandtoolsmod.recipe.codec; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.DataResult; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import io.github.realyusufismail.armourandtoolsmod.blocks.armour.book.CustomArmourCraftingBookCategory; +import io.github.realyusufismail.armourandtoolsmod.recipe.armour.CustomArmourCraftingTableShapedRecipe; +import java.util.List; +import java.util.Map; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingRecipeCodecs; +import net.minecraft.world.item.crafting.Ingredient; + +public record CustomArmourCraftingTableRawShapedRecipe( + String group, + CustomArmourCraftingBookCategory category, + Map key, + List pattern, + ItemStack result, + boolean showNotification) { + static final Codec SINGLE_CHARACTER_STRING_CODEC = + Codec.STRING.flatXmap( + p_300861_ -> { + if (p_300861_.length() != 1) { + return DataResult.error( + () -> + "Invalid key entry: '" + + p_300861_ + + "' is an invalid symbol (must be 1 character only)."); + } else { + return " ".equals(p_300861_) + ? DataResult.error(() -> "Invalid key entry: ' ' is a reserved symbol.") + : DataResult.success(p_300861_); + } + }, + DataResult::success); + + static final Codec> PATTERN_CODEC = + Codec.STRING + .listOf() + .flatXmap( + p_300940_ -> { + if (p_300940_.size() > CustomArmourCraftingTableShapedRecipe.MAX_HEIGHT) { + return DataResult.error( + () -> + "Invalid pattern: too many rows, %s is maximum" + .formatted(CustomArmourCraftingTableShapedRecipe.MAX_HEIGHT)); + } else if (p_300940_.isEmpty()) { + return DataResult.error(() -> "Invalid pattern: empty pattern not allowed"); + } else { + int i = p_300940_.get(0).length(); + + for (String s : p_300940_) { + if (s.length() > CustomArmourCraftingTableShapedRecipe.MAX_WIDTH) { + return DataResult.error( + () -> + "Invalid pattern: too many columns, %s is maximum" + .formatted(CustomArmourCraftingTableShapedRecipe.MAX_WIDTH)); + } + + if (i != s.length()) { + return DataResult.error( + () -> "Invalid pattern: each row must be the same width"); + } + } + + return DataResult.success(p_300940_); + } + }, + DataResult::success); + + public static final Codec CODEC = + RecordCodecBuilder.create( + (p_44108_) -> + p_44108_ + .group( + ExtraCodecs.strictOptionalField(Codec.STRING, "group", "") + .forGetter(p_301109_ -> p_301109_.group), + CustomArmourCraftingBookCategory.CODEC + .fieldOf("category") + .orElse(CustomArmourCraftingBookCategory.MISC) + .forGetter(p_301108_ -> p_301108_.category), + ExtraCodecs.strictUnboundedMap( + SINGLE_CHARACTER_STRING_CODEC, Ingredient.CODEC_NONEMPTY) + .fieldOf("key") + .forGetter(p_301234_ -> p_301234_.key), + PATTERN_CODEC.fieldOf("pattern").forGetter(p_301164_ -> p_301164_.pattern), + CraftingRecipeCodecs.ITEMSTACK_OBJECT_CODEC + .fieldOf("result") + .forGetter(p_301076_ -> p_301076_.result), + ExtraCodecs.strictOptionalField(Codec.BOOL, "show_notification", true) + .forGetter(p_301293_ -> p_301293_.showNotification)) + .apply(p_44108_, CustomArmourCraftingTableRawShapedRecipe::new)); +} diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/codec/CustomToolCraftingTableRawShapedRecipe.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/codec/CustomToolCraftingTableRawShapedRecipe.java new file mode 100644 index 00000000..ab34904c --- /dev/null +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/codec/CustomToolCraftingTableRawShapedRecipe.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 RealYusufIsmail. + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.github.realyusufismail.armourandtoolsmod.recipe.codec; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.DataResult; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import io.github.realyusufismail.armourandtoolsmod.blocks.tool.book.CustomToolsCraftingBookCategory; +import io.github.realyusufismail.armourandtoolsmod.recipe.tool.CustomToolCraftingTableShapedRecipe; +import java.util.List; +import java.util.Map; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingRecipeCodecs; +import net.minecraft.world.item.crafting.Ingredient; + +public record CustomToolCraftingTableRawShapedRecipe( + String group, + CustomToolsCraftingBookCategory category, + Map key, + List pattern, + ItemStack result, + boolean showNotification) { + static final Codec SINGLE_CHARACTER_STRING_CODEC = + Codec.STRING.flatXmap( + p_300861_ -> { + if (p_300861_.length() != 1) { + return DataResult.error( + () -> + "Invalid key entry: '" + + p_300861_ + + "' is an invalid symbol (must be 1 character only)."); + } else { + return " ".equals(p_300861_) + ? DataResult.error(() -> "Invalid key entry: ' ' is a reserved symbol.") + : DataResult.success(p_300861_); + } + }, + DataResult::success); + + static final Codec> PATTERN_CODEC = + Codec.STRING + .listOf() + .flatXmap( + p_300940_ -> { + if (p_300940_.size() > CustomToolCraftingTableShapedRecipe.MAX_HEIGHT) { + return DataResult.error( + () -> + "Invalid pattern: too many rows, %s is maximum" + .formatted(CustomToolCraftingTableShapedRecipe.MAX_HEIGHT)); + } else if (p_300940_.isEmpty()) { + return DataResult.error(() -> "Invalid pattern: empty pattern not allowed"); + } else { + int i = p_300940_.get(0).length(); + + for (String s : p_300940_) { + if (s.length() > CustomToolCraftingTableShapedRecipe.MAX_WIDTH) { + return DataResult.error( + () -> + "Invalid pattern: too many columns, %s is maximum" + .formatted(CustomToolCraftingTableShapedRecipe.MAX_WIDTH)); + } + + if (i != s.length()) { + return DataResult.error( + () -> "Invalid pattern: each row must be the same width"); + } + } + + return DataResult.success(p_300940_); + } + }, + DataResult::success); + + public static final Codec CODEC = + RecordCodecBuilder.create( + (p_44108_) -> + p_44108_ + .group( + ExtraCodecs.strictOptionalField(Codec.STRING, "group", "") + .forGetter(p_301109_ -> p_301109_.group), + CustomToolsCraftingBookCategory.CODEC + .fieldOf("category") + .orElse(CustomToolsCraftingBookCategory.MISC) + .forGetter(p_301108_ -> p_301108_.category), + ExtraCodecs.strictUnboundedMap( + SINGLE_CHARACTER_STRING_CODEC, Ingredient.CODEC_NONEMPTY) + .fieldOf("key") + .forGetter(p_301234_ -> p_301234_.key), + PATTERN_CODEC.fieldOf("pattern").forGetter(p_301164_ -> p_301164_.pattern), + CraftingRecipeCodecs.ITEMSTACK_OBJECT_CODEC + .fieldOf("result") + .forGetter(p_301076_ -> p_301076_.result), + ExtraCodecs.strictOptionalField(Codec.BOOL, "show_notification", true) + .forGetter(p_301293_ -> p_301293_.showNotification)) + .apply(p_44108_, CustomToolCraftingTableRawShapedRecipe::new)); +} diff --git a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/infusion/IngotFusionTollEnhancerRecipe.java b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/infusion/IngotFusionTollEnhancerRecipe.java index 668c59e2..5b2a9e0b 100644 --- a/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/infusion/IngotFusionTollEnhancerRecipe.java +++ b/neoforge/src/main/java/io/github/realyusufismail/armourandtoolsmod/recipe/infusion/IngotFusionTollEnhancerRecipe.java @@ -18,7 +18,8 @@ */ package io.github.realyusufismail.armourandtoolsmod.recipe.infusion; -import com.google.gson.JsonObject; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import io.github.realyusufismail.armourandtoolsmod.blocks.infusion.book.IngotFusionTollEnhancerRecipeBookCategory; import io.github.realyusufismail.armourandtoolsmod.core.init.RecipeSerializerInit; import io.github.realyusufismail.armourandtoolsmod.core.init.RecipeTypeInit; @@ -27,8 +28,6 @@ import lombok.val; import net.minecraft.core.RegistryAccess; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.GsonHelper; import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.*; @@ -38,8 +37,6 @@ public class IngotFusionTollEnhancerRecipe implements Recipe { - protected final RecipeType type; - protected final ResourceLocation id; @Getter public final Ingredient ingredient1; @Getter public final Ingredient ingredient2; @Getter public final Ingredient ingredient3; @@ -47,15 +44,11 @@ public class IngotFusionTollEnhancerRecipe implements Recipe { @Getter @NotNull public final IngotFusionTollEnhancerRecipeBookCategory category; public IngotFusionTollEnhancerRecipe( - RecipeType type, - ResourceLocation id, + IngotFusionTollEnhancerRecipeBookCategory category, Ingredient ingredient1, Ingredient ingredient2, Ingredient ingredient3, - ItemStack result, - IngotFusionTollEnhancerRecipeBookCategory category) { - this.type = type; - this.id = id; + ItemStack result) { this.ingredient1 = ingredient1; this.ingredient2 = ingredient2; this.ingredient3 = ingredient3; @@ -85,19 +78,14 @@ public ItemStack getResultItem(RegistryAccess pRegistryAccess) { return this.result; } - @Override - public ResourceLocation getId() { - return this.id; - } - @Override public RecipeSerializer getSerializer() { return RecipeSerializerInit.INGOT_FUSION_TOLL_ENHANCER_RECIPE.get(); } @Override - public RecipeType getType() { - return this.type; + public @NotNull RecipeType getType() { + return RecipeTypeInit.INGOT_FUSION_TOLL_ENHANCER.get(); } public boolean isIngredient(ItemStack ingredient) { @@ -126,42 +114,43 @@ public ItemStack getResult(ItemStack ingredient1, ItemStack ingredient2, ItemSta public static class Serializer implements RecipeSerializer { + private static final Codec CODEC = + RecordCodecBuilder.create( + (p_44108_) -> + p_44108_ + .group( + IngotFusionTollEnhancerRecipeBookCategory.CODEC + .fieldOf("category") + .orElse(IngotFusionTollEnhancerRecipeBookCategory.MISC) + .forGetter(p_301108_ -> p_301108_.category), + Ingredient.CODEC + .fieldOf("ingredient1") + .forGetter((p_44105_) -> p_44105_.ingredient1), + Ingredient.CODEC + .fieldOf("ingredient2") + .forGetter((p_44104_) -> p_44104_.ingredient2), + Ingredient.CODEC + .fieldOf("ingredient3") + .forGetter((p_44106_) -> p_44106_.ingredient3), + CraftingRecipeCodecs.ITEMSTACK_OBJECT_CODEC + .fieldOf("result") + .forGetter((p_44103_) -> p_44103_.result)) + .apply(p_44108_, IngotFusionTollEnhancerRecipe::new)); + @Override - public IngotFusionTollEnhancerRecipe fromJson(ResourceLocation pRecipeId, JsonObject json) { - val category = - IngotFusionTollEnhancerRecipeBookCategory.CODEC.byName( - GsonHelper.getAsString(json, "category", null), - IngotFusionTollEnhancerRecipeBookCategory.MISC); - val ingredient1 = Ingredient.fromJson(GsonHelper.getAsJsonObject(json, "ingredient1")); - val ingredient2 = Ingredient.fromJson(GsonHelper.getAsJsonObject(json, "ingredient2")); - val ingredient3 = Ingredient.fromJson(GsonHelper.getAsJsonObject(json, "ingredient3")); - val result = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result")); - return new IngotFusionTollEnhancerRecipe( - RecipeTypeInit.INGOT_FUSION_TOLL_ENHANCER.get(), - pRecipeId, - ingredient1, - ingredient2, - ingredient3, - result, - category); + public @NotNull Codec codec() { + return CODEC; } @Override - public @Nullable IngotFusionTollEnhancerRecipe fromNetwork( - ResourceLocation pRecipeId, FriendlyByteBuf pBuffer) { - val category = pBuffer.readEnum(IngotFusionTollEnhancerRecipeBookCategory.class); - val ingredient1 = Ingredient.fromNetwork(pBuffer); - val ingredient2 = Ingredient.fromNetwork(pBuffer); - val ingredient3 = Ingredient.fromNetwork(pBuffer); - val result = pBuffer.readItem(); + public @Nullable IngotFusionTollEnhancerRecipe fromNetwork(FriendlyByteBuf friendlyByteBuf) { + val category = friendlyByteBuf.readEnum(IngotFusionTollEnhancerRecipeBookCategory.class); + val ingredient1 = Ingredient.fromNetwork(friendlyByteBuf); + val ingredient2 = Ingredient.fromNetwork(friendlyByteBuf); + val ingredient3 = Ingredient.fromNetwork(friendlyByteBuf); + val result = friendlyByteBuf.readItem(); return new IngotFusionTollEnhancerRecipe( - RecipeTypeInit.INGOT_FUSION_TOLL_ENHANCER.get(), - pRecipeId, - ingredient1, - ingredient2, - ingredient3, - result, - category); + category, ingredient1, ingredient2, ingredient3, result); } @Override diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/ArmourAndToolsMod.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/ArmourAndToolsMod.kt index 4c5b79fb..25e9f209 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/ArmourAndToolsMod.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/ArmourAndToolsMod.kt @@ -26,11 +26,11 @@ import io.github.realyusufismail.armourandtoolsmod.core.init.* import io.github.realyusufismail.armourandtoolsmod.datagen.DataGenerators import java.util.* import net.minecraft.resources.ResourceLocation -import net.minecraftforge.fml.common.Mod +import net.neoforged.fml.common.Mod import org.slf4j.Logger import org.slf4j.LoggerFactory -import thedarkcolour.kotlinforforge.KotlinModLoadingContext -import thedarkcolour.kotlinforforge.forge.FORGE_BUS +import thedarkcolour.kotlinforforge.neoforge.KotlinModLoadingContext +import thedarkcolour.kotlinforforge.neoforge.forge.FORGE_BUS @Mod(MOD_ID) class ArmourAndToolsMod { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableMenu.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableMenu.kt index a07d0cc2..6521fbbc 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableMenu.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableMenu.kt @@ -32,6 +32,7 @@ import net.minecraft.world.entity.player.StackedContents import net.minecraft.world.inventory.* import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Recipe +import net.minecraft.world.item.crafting.RecipeHolder import net.minecraft.world.level.Level /** @see CraftingMenu */ @@ -88,7 +89,8 @@ class CustomArmourCraftingTableMenu( if (optional.isPresent) { val craftingrecipe = optional.get() if (pResult.setRecipeUsed(pLevel, serverplayer, craftingrecipe)) { - val itemstack1 = craftingrecipe.assemble(pContainer, pLevel.registryAccess()) + val itemstack1 = + craftingrecipe.value.assemble(pContainer, pLevel.registryAccess()) if (itemstack1.isItemEnabled(pLevel.enabledFeatures())) { itemstack = itemstack1 } @@ -119,8 +121,10 @@ class CustomArmourCraftingTableMenu( resultSlots.clearContent() } - override fun recipeMatches(pRecipe: Recipe): Boolean { - return pRecipe.matches(craftSlots, player.level()) + override fun recipeMatches( + recipeHolder: RecipeHolder> + ): Boolean { + return recipeHolder.value.matches(craftSlots, player.level()) } /** Called when the container is closed. */ diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableResultSlot.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableResultSlot.kt index cc5ca48c..e97bdeb3 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableResultSlot.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/CustomArmourCraftingTableResultSlot.kt @@ -21,11 +21,11 @@ package io.github.realyusufismail.armourandtoolsmod.blocks.armour import io.github.realyusufismail.armourandtoolsmod.core.init.RecipeTypeInit import net.minecraft.world.Container import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.RecipeHolder +import net.minecraft.world.inventory.RecipeCraftingHolder import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack -import net.minecraftforge.common.ForgeHooks -import net.minecraftforge.event.ForgeEventFactory +import net.neoforged.neoforge.common.CommonHooks +import net.neoforged.neoforge.event.EventHooks /** @see net.minecraft.world.inventory.ResultSlot */ class CustomArmourCraftingTableResultSlot( @@ -74,24 +74,26 @@ class CustomArmourCraftingTableResultSlot( override fun checkTakeAchievements(pStack: ItemStack) { if (this.removeCount > 0) { pStack.onCraftedBy(this.player.level(), this.player, this.removeCount) - ForgeEventFactory.firePlayerCraftingEvent(this.player, pStack, this.craftSlots) + EventHooks.firePlayerCraftingEvent(this.player, pStack, this.craftSlots) } - if (container is RecipeHolder) { - (container as RecipeHolder).awardUsedRecipes(this.player, listOf(pStack)) + + if (container is RecipeCraftingHolder) { + (container as RecipeCraftingHolder).awardUsedRecipes(this.player, listOf(pStack)) } + this.removeCount = 0 } override fun onTake(pPlayer: Player, pStack: ItemStack) { checkTakeAchievements(pStack) - ForgeHooks.setCraftingPlayer(pPlayer) + CommonHooks.setCraftingPlayer(pPlayer) val nonnulllist = pPlayer .level() .recipeManager .getRemainingItemsFor( RecipeTypeInit.ARMOUR_CRAFTING.get(), this.craftSlots, pPlayer.level()) - ForgeHooks.setCraftingPlayer(null) + CommonHooks.setCraftingPlayer(null) for (i in nonnulllist.indices) { var itemstack: ItemStack = this.craftSlots.getItem(i) val itemstack1 = nonnulllist[i] diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/book/CustomArmourCraftingBookCategory.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/book/CustomArmourCraftingBookCategory.kt index 37c70e74..96a486ca 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/book/CustomArmourCraftingBookCategory.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/armour/book/CustomArmourCraftingBookCategory.kt @@ -28,6 +28,7 @@ enum class CustomArmourCraftingBookCategory(private var bookName: String) : Stri MISC("misc"); companion object { + @JvmField val CODEC: StringRepresentable.EnumCodec = StringRepresentable.fromEnum { entries.toTypedArray() } } diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/book/IngotFusionTollEnhancerRecipeBookComponent.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/book/IngotFusionTollEnhancerRecipeBookComponent.kt index e2955a99..4b8e69cb 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/book/IngotFusionTollEnhancerRecipeBookComponent.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/book/IngotFusionTollEnhancerRecipeBookComponent.kt @@ -18,20 +18,34 @@ */ package io.github.realyusufismail.armourandtoolsmod.blocks.infusion.book +import io.github.realyusufismail.armourandtoolsmod.ArmourAndToolsMod import io.github.realyusufismail.armourandtoolsmod.blocks.infusion.IngotFusionTollEnhancerBlockEntity +import net.minecraft.client.gui.components.WidgetSprites import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent import net.minecraft.world.inventory.Slot import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient -import net.minecraft.world.item.crafting.Recipe +import net.minecraft.world.item.crafting.RecipeHolder class IngotFusionTollEnhancerRecipeBookComponent : RecipeBookComponent() { private var fuels: Ingredient? = null private val fuelItems = IngotFusionTollEnhancerBlockEntity.getFuels().keys + // TODO : Check how this works + private val FILTER_SPRITES = + WidgetSprites( + ArmourAndToolsMod.getModIdAndName( + "sprites/recipe_book/ingot_fusion_toll_enhancer_filter_enabled"), + ArmourAndToolsMod.getModIdAndName( + "sprites/recipe_book/ingot_fusion_toll_enhancer_filter_disabled"), + ArmourAndToolsMod.getModIdAndName( + "sprites/recipe_book/ingot_fusion_toll_enhancer_filter_enabled_highlighted"), + ArmourAndToolsMod.getModIdAndName( + "sprites/recipe_book/ingot_fusion_toll_enhancer_filter_disabled_highlighted")) + override fun initFilterButtonTextures() { - filterButton.initTextureValues(152, 182, 28, 18, RECIPE_BOOK_LOCATION) + filterButton.initTextureValues(FILTER_SPRITES) } override fun slotClicked(pSlot: Slot?) { @@ -41,11 +55,11 @@ class IngotFusionTollEnhancerRecipeBookComponent : RecipeBookComponent() { } } - override fun setupGhostRecipe(pRecipe: Recipe<*>, pSlots: List) { - val itemstack = pRecipe.getResultItem(minecraft.level!!.registryAccess()) - ghostRecipe.recipe = pRecipe + override fun setupGhostRecipe(recipeHolder: RecipeHolder<*>, pSlots: List) { + val itemstack = recipeHolder.value.getResultItem(minecraft.level!!.registryAccess()) + ghostRecipe.recipe = recipeHolder ghostRecipe.addIngredient(Ingredient.of(itemstack), pSlots[2].x, pSlots[2].y) - val nonnulllist = pRecipe.ingredients + val nonnulllist = recipeHolder.value.ingredients val slot = pSlots[1] if (slot.item.isEmpty) { if (fuels == null) { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/slots/InfusionFuelSlot.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/slots/InfusionFuelSlot.kt index f9bfe56d..8b0b42a2 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/slots/InfusionFuelSlot.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/slots/InfusionFuelSlot.kt @@ -22,8 +22,8 @@ import io.github.realyusufismail.armourandtoolsmod.blocks.infusion.IngotFusionTo import io.github.realyusufismail.armourandtoolsmod.blocks.infusion.IngotFusionTollEnhancerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items -import net.minecraftforge.items.IItemHandler -import net.minecraftforge.items.SlotItemHandler +import net.neoforged.neoforge.items.IItemHandler +import net.neoforged.neoforge.items.SlotItemHandler class InfusionFuelSlot(itemHandler: IItemHandler, private val menu: IngotFusionTollEnhancerMenu) : SlotItemHandler(itemHandler, IngotFusionTollEnhancerBlockEntity.FUEL_SLOT, 102, 65) { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/slots/OutputSlotItemHandler.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/slots/OutputSlotItemHandler.kt index 29489963..1040fe6a 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/slots/OutputSlotItemHandler.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/infusion/slots/OutputSlotItemHandler.kt @@ -23,9 +23,9 @@ import kotlin.math.min import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack -import net.minecraftforge.event.ForgeEventFactory -import net.minecraftforge.items.IItemHandler -import net.minecraftforge.items.SlotItemHandler +import net.neoforged.neoforge.event.EventHooks +import net.neoforged.neoforge.items.IItemHandler +import net.neoforged.neoforge.items.SlotItemHandler class OutputSlotItemHandler(itemHandler: IItemHandler, val player: Player) : SlotItemHandler(itemHandler, IngotFusionTollEnhancerBlockEntity.RESULT_SLOT, 138, 40) { @@ -57,6 +57,6 @@ class OutputSlotItemHandler(itemHandler: IItemHandler, val player: Player) : player) } removeCount = 0 - ForgeEventFactory.firePlayerSmeltedEvent(this.player, pStack) + EventHooks.firePlayerSmeltedEvent(this.player, pStack) } } diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableMenu.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableMenu.kt index 91e3b786..ebb2a006 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableMenu.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableMenu.kt @@ -32,6 +32,7 @@ import net.minecraft.world.entity.player.StackedContents import net.minecraft.world.inventory.* import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Recipe +import net.minecraft.world.item.crafting.RecipeHolder import net.minecraft.world.level.Level /** @see CraftingMenu */ @@ -88,7 +89,8 @@ class CustomToolCraftingTableMenu( if (optional.isPresent) { val craftingrecipe = optional.get() if (pResult.setRecipeUsed(pLevel, serverplayer, craftingrecipe)) { - val itemstack1 = craftingrecipe.assemble(pContainer, pLevel.registryAccess()) + val itemstack1 = + craftingrecipe.value.assemble(pContainer, pLevel.registryAccess()) if (itemstack1.isItemEnabled(pLevel.enabledFeatures())) { itemstack = itemstack1 } @@ -119,8 +121,10 @@ class CustomToolCraftingTableMenu( resultSlots.clearContent() } - override fun recipeMatches(pRecipe: Recipe): Boolean { - return pRecipe.matches(craftSlots, player.level()) + override fun recipeMatches( + p_301144_: RecipeHolder> + ): Boolean { + return p_301144_.value().matches(craftSlots, player.level()) } /** Called when the container is closed. */ diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableResultSlot.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableResultSlot.kt index 492ba162..cbfe8958 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableResultSlot.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/CustomToolCraftingTableResultSlot.kt @@ -21,11 +21,11 @@ package io.github.realyusufismail.armourandtoolsmod.blocks.tool import io.github.realyusufismail.armourandtoolsmod.core.init.RecipeTypeInit import net.minecraft.world.Container import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.RecipeHolder +import net.minecraft.world.inventory.RecipeCraftingHolder import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack -import net.minecraftforge.common.ForgeHooks -import net.minecraftforge.event.ForgeEventFactory +import net.neoforged.neoforge.common.CommonHooks +import net.neoforged.neoforge.event.EventHooks /** @see net.minecraft.world.inventory.ResultSlot */ class CustomToolCraftingTableResultSlot( @@ -74,24 +74,24 @@ class CustomToolCraftingTableResultSlot( override fun checkTakeAchievements(pStack: ItemStack) { if (this.removeCount > 0) { pStack.onCraftedBy(this.player.level(), this.player, this.removeCount) - ForgeEventFactory.firePlayerCraftingEvent(this.player, pStack, this.craftSlots) + EventHooks.firePlayerCraftingEvent(this.player, pStack, this.craftSlots) } - if (container is RecipeHolder) { - (container as RecipeHolder).awardUsedRecipes(this.player, listOf(pStack)) + if (container is RecipeCraftingHolder) { + (container as RecipeCraftingHolder).awardUsedRecipes(this.player, listOf(pStack)) } this.removeCount = 0 } override fun onTake(pPlayer: Player, pStack: ItemStack) { checkTakeAchievements(pStack) - ForgeHooks.setCraftingPlayer(pPlayer) + CommonHooks.setCraftingPlayer(pPlayer) val nonnulllist = pPlayer .level() .recipeManager .getRemainingItemsFor( RecipeTypeInit.TOOL_CRAFTING.get(), this.craftSlots, pPlayer.level()) - ForgeHooks.setCraftingPlayer(null) + CommonHooks.setCraftingPlayer(null) for (i in nonnulllist.indices) { var itemstack: ItemStack = this.craftSlots.getItem(i) val itemstack1 = nonnulllist[i] diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/book/CustomToolsCraftingBookCategory.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/book/CustomToolsCraftingBookCategory.kt index 7c2ba078..8da6c7e0 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/book/CustomToolsCraftingBookCategory.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/blocks/tool/book/CustomToolsCraftingBookCategory.kt @@ -31,6 +31,7 @@ enum class CustomToolsCraftingBookCategory(private var bookName: String) : Strin MISC("misc"); companion object { + @JvmField val CODEC: StringRepresentable.EnumCodec = StringRepresentable.fromEnum { entries.toTypedArray() } } diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/client/ClientEvents.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/client/ClientEvents.kt index b1df94b2..3d9fc143 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/client/ClientEvents.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/client/ClientEvents.kt @@ -41,11 +41,11 @@ import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.LivingEntity import net.minecraft.world.item.ItemStack import net.minecraft.world.phys.Vec3 -import net.minecraftforge.client.event.EntityRenderersEvent -import net.minecraftforge.client.event.InputEvent -import net.minecraftforge.client.event.RegisterKeyMappingsEvent -import net.minecraftforge.event.entity.living.LivingDeathEvent -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent +import net.neoforged.neoforge.client.event.EntityRenderersEvent +import net.neoforged.neoforge.client.event.InputEvent +import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent +import net.neoforged.neoforge.event.entity.living.LivingDeathEvent object ClientEvents { val MjolnirLayer = ModelLayerLocation(ArmourAndToolsMod.getModIdAndName("mjolnir"), "mjolnir") diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/common/entity/ArmourToolsModTridentEntity.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/common/entity/ArmourToolsModTridentEntity.kt index cfc09099..871f473c 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/common/entity/ArmourToolsModTridentEntity.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/common/entity/ArmourToolsModTridentEntity.kt @@ -40,7 +40,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper import net.minecraft.world.level.Level import net.minecraft.world.phys.EntityHitResult import net.minecraft.world.phys.Vec3 -import net.minecraftforge.network.NetworkHooks +import net.neoforged.neoforge.network.NetworkHooks /** @see ThrownTrident */ abstract class ArmourToolsModTridentEntity : AbstractArrow { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/BlockInit.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/BlockInit.kt index e9a29ae6..8a09873f 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/BlockInit.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/BlockInit.kt @@ -29,10 +29,10 @@ import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.state.BlockBehaviour -import net.minecraftforge.registries.DeferredRegister -import net.minecraftforge.registries.ForgeRegistries -import thedarkcolour.kotlinforforge.forge.ObjectHolderDelegate -import thedarkcolour.kotlinforforge.forge.registerObject +import net.neoforged.neoforge.registries.DeferredRegister +import net.neoforged.neoforge.registries.ForgeRegistries +import thedarkcolour.kotlinforforge.neoforge.forge.ObjectHolderDelegate +import thedarkcolour.kotlinforforge.neoforge.forge.registerObject object BlockInit { val BLOCKS: DeferredRegister = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID) diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/CreativeModeTabInit.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/CreativeModeTabInit.kt index 62e3b3ff..eaf826cb 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/CreativeModeTabInit.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/CreativeModeTabInit.kt @@ -25,8 +25,8 @@ import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.Block -import net.minecraftforge.registries.DeferredRegister -import net.minecraftforge.registries.RegistryObject +import net.neoforged.neoforge.registries.DeferredRegister +import net.neoforged.neoforge.registries.RegistryObject object CreativeModeTabInit { val CREATIVE_MODE_TAB: DeferredRegister = diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/ItemInit.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/ItemInit.kt index e0e875a2..879451d8 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/ItemInit.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/ItemInit.kt @@ -31,11 +31,11 @@ import io.github.realyusufismail.armourandtoolsmod.items.hammer.util.HammerLevel import io.github.realyusufismail.armourandtoolsmod.items.shield.ArmourToolsModShieldItem import io.github.realyusufismail.armourandtoolsmod.items.trident.AqumarineTridentItem import net.minecraft.world.item.* -import net.minecraftforge.registries.DeferredRegister -import net.minecraftforge.registries.ForgeRegistries -import net.minecraftforge.registries.RegistryObject -import thedarkcolour.kotlinforforge.forge.ObjectHolderDelegate -import thedarkcolour.kotlinforforge.forge.registerObject +import net.neoforged.neoforge.registries.DeferredRegister +import net.neoforged.neoforge.registries.ForgeRegistries +import net.neoforged.neoforge.registries.RegistryObject +import thedarkcolour.kotlinforforge.neoforge.forge.ObjectHolderDelegate +import thedarkcolour.kotlinforforge.neoforge.forge.registerObject object ItemInit { val ITEMS: DeferredRegister = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID) diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/MenuTypeInit.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/MenuTypeInit.kt index 6a920dbb..9108da63 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/MenuTypeInit.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/MenuTypeInit.kt @@ -27,11 +27,11 @@ import net.minecraft.world.flag.FeatureFlags import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.MenuType import net.minecraft.world.inventory.MenuType.MenuSupplier -import net.minecraftforge.common.extensions.IForgeMenuType -import net.minecraftforge.registries.DeferredRegister -import net.minecraftforge.registries.ForgeRegistries -import thedarkcolour.kotlinforforge.forge.ObjectHolderDelegate -import thedarkcolour.kotlinforforge.forge.registerObject +import net.neoforged.neoforge.common.extensions.IMenuTypeExtension +import net.neoforged.neoforge.registries.DeferredRegister +import net.neoforged.neoforge.registries.ForgeRegistries +import thedarkcolour.kotlinforforge.neoforge.forge.ObjectHolderDelegate +import thedarkcolour.kotlinforforge.neoforge.forge.registerObject object MenuTypeInit { val MENU: DeferredRegister> = @@ -50,7 +50,7 @@ object MenuTypeInit { ObjectHolderDelegate> = MENU.registerObject("ingot_fusion_toll_enhancer") { // TODO : Get null here. - IForgeMenuType.create { pContainerId, pInventory, pData -> + IMenuTypeExtension.create { pContainerId, pInventory, pData -> IngotFusionTollEnhancerMenu(pContainerId, pInventory, pData) } } diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/MobEffectsInit.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/MobEffectsInit.kt index 973a3a41..88ef975e 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/MobEffectsInit.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/MobEffectsInit.kt @@ -21,9 +21,9 @@ package io.github.realyusufismail.armourandtoolsmod.core.init import io.github.realyusufismail.armourandtoolsmod.ArmourAndToolsMod.ArmorAndToolsMod.MOD_ID import io.github.realyusufismail.armourandtoolsmod.effect.WorthyEffect import net.minecraft.world.effect.MobEffect -import net.minecraftforge.registries.DeferredRegister -import net.minecraftforge.registries.ForgeRegistries -import net.minecraftforge.registries.RegistryObject +import net.neoforged.neoforge.registries.DeferredRegister +import net.neoforged.neoforge.registries.ForgeRegistries +import net.neoforged.neoforge.registries.RegistryObject object MobEffectsInit { val MOB_EFFECTS: DeferredRegister = diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/PotionsInit.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/PotionsInit.kt index 5dccedc1..f6d33b0c 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/PotionsInit.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/PotionsInit.kt @@ -22,10 +22,10 @@ import io.github.realyusufismail.armourandtoolsmod.ArmourAndToolsMod import net.minecraft.world.effect.MobEffect import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.item.alchemy.Potion -import net.minecraftforge.registries.DeferredRegister -import net.minecraftforge.registries.ForgeRegistries -import thedarkcolour.kotlinforforge.forge.ObjectHolderDelegate -import thedarkcolour.kotlinforforge.forge.registerObject +import net.neoforged.neoforge.registries.DeferredRegister +import net.neoforged.neoforge.registries.ForgeRegistries +import thedarkcolour.kotlinforforge.neoforge.forge.ObjectHolderDelegate +import thedarkcolour.kotlinforforge.neoforge.forge.registerObject /** @see MobEffect */ object PotionsInit { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeCategoriesInit.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeCategoriesInit.kt index 5bbcad80..eac4dc04 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeCategoriesInit.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeCategoriesInit.kt @@ -30,7 +30,7 @@ import io.github.realyusufismail.armourandtoolsmod.recipe.tool.CustomToolCraftin import net.minecraft.client.RecipeBookCategories import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items -import net.minecraftforge.client.event.RegisterRecipeBookCategoriesEvent +import net.neoforged.neoforge.client.event.RegisterRecipeBookCategoriesEvent object RecipeCategoriesInit { @@ -172,8 +172,8 @@ object RecipeCategoriesInit { ARMOUR_CRAFTING_BOOTS.get(), listOf(ARMOUR_CRAFTING_BOOTS.get())) event.registerRecipeCategoryFinder(RecipeTypeInit.ARMOUR_CRAFTING.get()) { - if (it is CustomArmourCraftingTableRecipe) { - when (it.category()) { + if (it.value() is CustomArmourCraftingTableRecipe) { + when ((it.value() as CustomArmourCraftingTableRecipe).category()) { CustomArmourCraftingBookCategory.ARMOUR_HEAD -> ARMOUR_CRAFTING_HELMET.get() CustomArmourCraftingBookCategory.ARMOUR_CHEST -> ARMOUR_CRAFTING_CHESTPLATE.get() @@ -235,8 +235,8 @@ object RecipeCategoriesInit { event.registerAggregateCategory(TOOL_CRAFTING_MISC.get(), listOf(TOOL_CRAFTING_MISC.get())) event.registerRecipeCategoryFinder(RecipeTypeInit.TOOL_CRAFTING.get()) { - if (it is CustomToolCraftingTableRecipe) { - when (it.category()) { + if (it.value() is CustomToolCraftingTableRecipe) { + when ((it.value() as CustomToolCraftingTableRecipe).category()) { CustomToolsCraftingBookCategory.SWORD -> TOOL_CRAFTING_SWORD.get() CustomToolsCraftingBookCategory.PICKAXE -> TOOL_CRAFTING_PICKAXE.get() CustomToolsCraftingBookCategory.AXE -> TOOL_CRAFTING_AXE.get() @@ -277,8 +277,8 @@ object RecipeCategoriesInit { INGOT_FUSION_TOLL_ENHANCER_MISC.get(), listOf(INGOT_FUSION_TOLL_ENHANCER_MISC.get())) event.registerRecipeCategoryFinder(RecipeTypeInit.INGOT_FUSION_TOLL_ENHANCER.get()) { - if (it is IngotFusionTollEnhancerRecipe) { - when (it.category) { + if (it.value() is IngotFusionTollEnhancerRecipe) { + when ((it.value() as IngotFusionTollEnhancerRecipe).category) { IngotFusionTollEnhancerRecipeBookCategory.TOOL -> INGOT_FUSION_TOLL_ENHANCER_TOOL.get() IngotFusionTollEnhancerRecipeBookCategory.ARMOUR -> diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeSerializerInit.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeSerializerInit.kt index d4a5279b..c4ab7c83 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeSerializerInit.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeSerializerInit.kt @@ -24,10 +24,10 @@ import io.github.realyusufismail.armourandtoolsmod.recipe.infusion.IngotFusionTo import io.github.realyusufismail.armourandtoolsmod.recipe.tool.CustomToolCraftingTableShapedRecipe import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer -import net.minecraftforge.registries.DeferredRegister -import net.minecraftforge.registries.ForgeRegistries -import thedarkcolour.kotlinforforge.forge.ObjectHolderDelegate -import thedarkcolour.kotlinforforge.forge.registerObject +import net.neoforged.neoforge.registries.DeferredRegister +import net.neoforged.neoforge.registries.ForgeRegistries +import thedarkcolour.kotlinforforge.neoforge.forge.ObjectHolderDelegate +import thedarkcolour.kotlinforforge.neoforge.forge.registerObject object RecipeSerializerInit { val SERIALIZERS: DeferredRegister> = diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeTypeInit.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeTypeInit.kt index 99e270e7..dcf1e3af 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeTypeInit.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/RecipeTypeInit.kt @@ -24,10 +24,10 @@ import io.github.realyusufismail.armourandtoolsmod.recipe.infusion.IngotFusionTo import io.github.realyusufismail.armourandtoolsmod.recipe.tool.CustomToolCraftingTableRecipe import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.crafting.RecipeType -import net.minecraftforge.registries.DeferredRegister -import net.minecraftforge.registries.ForgeRegistries -import thedarkcolour.kotlinforforge.forge.ObjectHolderDelegate -import thedarkcolour.kotlinforforge.forge.registerObject +import net.neoforged.neoforge.registries.DeferredRegister +import net.neoforged.neoforge.registries.ForgeRegistries +import thedarkcolour.kotlinforforge.neoforge.forge.ObjectHolderDelegate +import thedarkcolour.kotlinforforge.neoforge.forge.registerObject /** @see net.minecraft.stats.RecipeBookSettings */ object RecipeTypeInit { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/material/CustomToolMaterial.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/material/CustomToolMaterial.kt index bf3ed88c..e58cc645 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/material/CustomToolMaterial.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/material/CustomToolMaterial.kt @@ -61,6 +61,7 @@ enum class CustomToolMaterial( private val maxUses = 0 private val enchantability = 0 private val repairMaterial: Ingredient? = null + override fun getUses(): Int { return maxUses } diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/util/NameUtils.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/util/NameUtils.kt index 72c6d105..719fd0b9 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/util/NameUtils.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/util/NameUtils.kt @@ -20,7 +20,7 @@ package io.github.realyusufismail.armourandtoolsmod.core.util import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block -import net.minecraftforge.registries.ForgeRegistries +import net.neoforged.neoforge.registries.ForgeRegistries val Item.name: String get() = this.toString() diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/DataGenerators.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/DataGenerators.kt index 06a729ad..fc38e36e 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/DataGenerators.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/DataGenerators.kt @@ -37,7 +37,7 @@ import net.minecraft.data.metadata.PackMetadataGenerator import net.minecraft.network.chat.Component import net.minecraft.server.packs.PackType import net.minecraft.server.packs.metadata.pack.PackMetadataSection -import net.minecraftforge.data.event.GatherDataEvent +import net.neoforged.neoforge.data.event.GatherDataEvent object DataGenerators { @@ -61,16 +61,17 @@ object DataGenerators { val blockTag = ModBlockTagsProvider(gen, existingFileHelper, lookup) gen.addProvider(true, blockTag) gen.addProvider(true, ModItemTagsProvider(gen, existingFileHelper, blockTag, lookup)) - gen.addProvider(true, MainModRecipeProvider(gen)) + gen.addProvider(true, MainModRecipeProvider(gen, lookup)) gen.addProvider(true, ModWorldGenProvider(gen.packOutput, lookup)) gen.addProvider( - true, ArmourAndTollsModSpriteSourceProvider(gen.packOutput, existingFileHelper)) + true, + ArmourAndTollsModSpriteSourceProvider(gen.packOutput, existingFileHelper, lookup)) gen.addProvider( true, ModAdvancementProvider(gen.packOutput, lookup, existingFileHelper)) gen.addProvider(true, PackMetadataGenerator(gen.packOutput)) .add( PackMetadataSection.TYPE, - PackMetadataSection( + PackMetadataSection( Component.literal("Armour and Tools Mod Resources"), DetectedVersion.BUILT_IN.getPackVersion(PackType.CLIENT_RESOURCES), Arrays.stream(PackType.entries.toTypedArray()) diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/advancment/Advancements.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/advancment/Advancements.kt index 604e0128..ccbfb179 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/advancment/Advancements.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/advancment/Advancements.kt @@ -22,11 +22,9 @@ import io.github.realyusufismail.armourandtoolsmod.ArmourAndToolsMod import io.github.realyusufismail.armourandtoolsmod.core.init.BlockInit import io.github.realyusufismail.armourandtoolsmod.core.init.ItemInit import io.github.realyusufismail.armourandtoolsmod.core.init.TagsInit +import java.util.* import java.util.function.Consumer -import net.minecraft.advancements.Advancement -import net.minecraft.advancements.CriterionTriggerInstance -import net.minecraft.advancements.FrameType -import net.minecraft.advancements.RequirementsStrategy +import net.minecraft.advancements.* import net.minecraft.advancements.critereon.* import net.minecraft.core.HolderLookup import net.minecraft.network.chat.Component @@ -36,60 +34,29 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.level.ItemLike -import net.minecraftforge.common.data.ExistingFileHelper -import net.minecraftforge.common.data.ForgeAdvancementProvider - -class Advancements : ForgeAdvancementProvider.AdvancementGenerator { - private fun simpleGetItem( - consumer: Consumer, - item: ItemLike, - parent: Advancement - ): Advancement { - return simpleGetItem(consumer, item, parent, item.asItem().toString()) - } - - private fun simpleGetItem( - consumer: Consumer, - item: ItemLike, - parent: Advancement, - key: String - ): Advancement { - return simpleGetItem(consumer, item, ItemStack(item), parent, key) - } - - private fun simpleGetItem( - consumer: Consumer, - item: ItemLike, - icon: ItemStack, - parent: Advancement, - key: String - ): Advancement { - return Advancement.Builder.advancement() - .parent(parent) - .display(icon, title(key), description(key), null, FrameType.TASK, true, true, false) - .addCriterion("get_item", getItem(item)) - .save(consumer, id(key)) - } +import net.neoforged.neoforge.common.data.AdvancementProvider +import net.neoforged.neoforge.common.data.ExistingFileHelper +class Advancements : AdvancementProvider.AdvancementGenerator { private fun id(path: String): String { return ArmourAndToolsMod.getModIdAndName(path).toString() } - private fun getItem(vararg items: ItemLike): CriterionTriggerInstance { + private fun getItem(vararg items: ItemLike): Criterion { return InventoryChangeTrigger.TriggerInstance.hasItems(*items) } - private fun getItem(tag: TagKey): CriterionTriggerInstance { + private fun getItem(tag: TagKey): Criterion { return InventoryChangeTrigger.TriggerInstance.hasItems( ItemPredicate( - tag, - null, + Optional.of(tag), + Optional.ofNullable(null), MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, - EnchantmentPredicate.NONE, - EnchantmentPredicate.NONE, - null, - NbtPredicate.ANY)) + listOf(), + listOf(), + Optional.ofNullable(null), + Optional.ofNullable(null))) } private fun title(key: String): Component { @@ -103,7 +70,7 @@ class Advancements : ForgeAdvancementProvider.AdvancementGenerator { override fun generate( registries: HolderLookup.Provider, - consumer: Consumer, + consumer: Consumer, existingFileHelper: ExistingFileHelper ) { val rootIcon = ItemStack(ItemInit.AMETHYST_SWORD.get()) @@ -182,7 +149,7 @@ class Advancements : ForgeAdvancementProvider.AdvancementGenerator { .addCriterion("ruby_chestplate", getItem(ItemInit.RUBY_CHESTPLATE.get())) .addCriterion("ruby_leggings", getItem(ItemInit.RUBY_LEGGINGS.get())) .addCriterion("ruby_boots", getItem(ItemInit.RUBY_BOOTS.get())) - .requirements(RequirementsStrategy.OR) + .requirements(AdvancementRequirements.Strategy.OR) .save(consumer, id("ruby_armour")) Advancement.Builder.advancement() @@ -201,7 +168,7 @@ class Advancements : ForgeAdvancementProvider.AdvancementGenerator { .addCriterion("ruby_axe", getItem(ItemInit.RUBY_AXE.get())) .addCriterion("ruby_shovel", getItem(ItemInit.RUBY_SHOVEL.get())) .addCriterion("ruby_hoe", getItem(ItemInit.RUBY_HOE.get())) - .requirements(RequirementsStrategy.OR) + .requirements(AdvancementRequirements.Strategy.OR) .save(consumer, id("ruby_tools")) // Sapphire @@ -265,7 +232,7 @@ class Advancements : ForgeAdvancementProvider.AdvancementGenerator { .addCriterion("sapphire_chestplate", getItem(ItemInit.SAPPHIRE_CHESTPLATE.get())) .addCriterion("sapphire_leggings", getItem(ItemInit.SAPPHIRE_LEGGINGS.get())) .addCriterion("sapphire_boots", getItem(ItemInit.SAPPHIRE_BOOTS.get())) - .requirements(RequirementsStrategy.OR) + .requirements(AdvancementRequirements.Strategy.OR) .save(consumer, id("sapphire_armour")) Advancement.Builder.advancement() @@ -284,7 +251,7 @@ class Advancements : ForgeAdvancementProvider.AdvancementGenerator { .addCriterion("sapphire_axe", getItem(ItemInit.SAPPHIRE_AXE.get())) .addCriterion("sapphire_shovel", getItem(ItemInit.SAPPHIRE_SHOVEL.get())) .addCriterion("sapphire_hoe", getItem(ItemInit.SAPPHIRE_HOE.get())) - .requirements(RequirementsStrategy.OR) + .requirements(AdvancementRequirements.Strategy.OR) .save(consumer, id("sapphire_tools")) // Graphite @@ -348,7 +315,7 @@ class Advancements : ForgeAdvancementProvider.AdvancementGenerator { .addCriterion("graphite_chestplate", getItem(ItemInit.GRAPHITE_CHESTPLATE.get())) .addCriterion("graphite_leggings", getItem(ItemInit.GRAPHITE_LEGGINGS.get())) .addCriterion("graphite_boots", getItem(ItemInit.GRAPHITE_BOOTS.get())) - .requirements(RequirementsStrategy.OR) + .requirements(AdvancementRequirements.Strategy.OR) .save(consumer, id("graphite_armour")) // Aqumarine @@ -412,7 +379,7 @@ class Advancements : ForgeAdvancementProvider.AdvancementGenerator { .addCriterion("aqumarine_chestplate", getItem(ItemInit.AQUMARINE_CHESTPLATE.get())) .addCriterion("aqumarine_leggings", getItem(ItemInit.AQUMARINE_LEGGINGS.get())) .addCriterion("aqumarine_boots", getItem(ItemInit.AQUMARINE_BOOTS.get())) - .requirements(RequirementsStrategy.OR) + .requirements(AdvancementRequirements.Strategy.OR) .save(consumer, id("aqumarine_armour")) // Rainbow @@ -476,7 +443,7 @@ class Advancements : ForgeAdvancementProvider.AdvancementGenerator { .addCriterion("rainbow_chestplate", getItem(ItemInit.RAINBOW_CHESTPLATE.get())) .addCriterion("rainbow_leggings", getItem(ItemInit.RAINBOW_LEGGINGS.get())) .addCriterion("rainbow_boots", getItem(ItemInit.RAINBOW_BOOTS.get())) - .requirements(RequirementsStrategy.OR) + .requirements(AdvancementRequirements.Strategy.OR) .save(consumer, id("rainbow_armour")) // Enderite @@ -540,7 +507,7 @@ class Advancements : ForgeAdvancementProvider.AdvancementGenerator { .addCriterion("enderite_chestplate", getItem(ItemInit.ENDERITE_CHESTPLATE.get())) .addCriterion("enderite_leggings", getItem(ItemInit.ENDERITE_LEGGINGS.get())) .addCriterion("enderite_boots", getItem(ItemInit.ENDERITE_BOOTS.get())) - .requirements(RequirementsStrategy.OR) + .requirements(AdvancementRequirements.Strategy.OR) .save(consumer, id("enderite_armour")) Advancement.Builder.advancement() @@ -559,7 +526,7 @@ class Advancements : ForgeAdvancementProvider.AdvancementGenerator { .addCriterion("enderite_axe", getItem(ItemInit.ENDERITE_AXE.get())) .addCriterion("enderite_shovel", getItem(ItemInit.ENDERITE_SHOVEL.get())) .addCriterion("enderite_hoe", getItem(ItemInit.ENDERITE_HOE.get())) - .requirements(RequirementsStrategy.OR) + .requirements(AdvancementRequirements.Strategy.OR) .save(consumer, id("enderite_tools")) // Imperium @@ -608,7 +575,7 @@ class Advancements : ForgeAdvancementProvider.AdvancementGenerator { .addCriterion("imperium_sword", getItem(ItemInit.IMPERIUM_SWORD.get())) .addCriterion("imperium_pickaxe", getItem(ItemInit.IMPERIUM_PICKAXE.get())) // .addCriterion("imperium_axe", getItem(ItemInit.IMPERIUM_AXE.get())) - .requirements(RequirementsStrategy.OR) + .requirements(AdvancementRequirements.Strategy.OR) .save(consumer, id("imperium_tools")) } } diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/advancment/ModAdvancementProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/advancment/ModAdvancementProvider.kt index 55b47bdf..eea5b32b 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/advancment/ModAdvancementProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/advancment/ModAdvancementProvider.kt @@ -21,11 +21,11 @@ package io.github.realyusufismail.armourandtoolsmod.datagen.advancment import java.util.concurrent.CompletableFuture import net.minecraft.core.HolderLookup import net.minecraft.data.PackOutput -import net.minecraftforge.common.data.ExistingFileHelper -import net.minecraftforge.common.data.ForgeAdvancementProvider +import net.neoforged.neoforge.common.data.AdvancementProvider +import net.neoforged.neoforge.common.data.ExistingFileHelper class ModAdvancementProvider( output: PackOutput, registries: CompletableFuture, existingFileHelper: ExistingFileHelper -) : ForgeAdvancementProvider(output, registries, existingFileHelper, listOf(Advancements())) +) : AdvancementProvider(output, registries, existingFileHelper, listOf(Advancements())) diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/lang/ModEnLangProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/lang/ModEnLangProvider.kt index c6b844fd..575231c0 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/lang/ModEnLangProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/lang/ModEnLangProvider.kt @@ -29,7 +29,7 @@ import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block -import net.minecraftforge.registries.RegistryObject +import net.neoforged.neoforge.registries.RegistryObject class ModEnLangProvider(gen: DataGenerator) : ModEnLangProviderSupport(gen, MOD_ID, "en_us") { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/loot/ModBlockLootTables.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/loot/ModBlockLootTables.kt index 332449bd..f0d75337 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/loot/ModBlockLootTables.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/loot/ModBlockLootTables.kt @@ -27,7 +27,7 @@ import net.minecraft.data.loot.BlockLootSubProvider import net.minecraft.resources.ResourceLocation import net.minecraft.world.flag.FeatureFlags import net.minecraft.world.level.block.Block -import net.minecraftforge.registries.ForgeRegistries +import net.neoforged.neoforge.registries.ForgeRegistries class ModBlockLootTables : BlockLootSubProvider(setOf(), FeatureFlags.REGISTRY.allFlags()) { override fun generate() { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/MainModRecipeProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/MainModRecipeProvider.kt index fb01fe4e..9a875dfc 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/MainModRecipeProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/MainModRecipeProvider.kt @@ -20,25 +20,28 @@ package io.github.realyusufismail.armourandtoolsmod.datagen.recipe import io.github.realyusufismail.armourandtoolsmod.ArmourAndToolsMod.ArmorAndToolsMod.MOD_ID import io.github.realyusufismail.armourandtoolsmod.datagen.recipe.provider.* -import java.util.function.Consumer +import java.util.concurrent.CompletableFuture +import net.minecraft.core.HolderLookup import net.minecraft.data.DataGenerator -import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.RecipeProvider import net.minecraft.resources.ResourceLocation -import net.minecraftforge.common.crafting.conditions.IConditionBuilder +import net.neoforged.neoforge.common.conditions.IConditionBuilder -open class MainModRecipeProvider(private val generatorIn: DataGenerator) : - RecipeProvider(generatorIn.packOutput), IConditionBuilder { +open class MainModRecipeProvider( + private val generatorIn: DataGenerator, + private val lookup: CompletableFuture +) : RecipeProvider(generatorIn.packOutput, lookup), IConditionBuilder { - constructor(`this`: MainModRecipeProvider) : this(`this`.generatorIn) + constructor(`this`: MainModRecipeProvider) : this(`this`.generatorIn, `this`.lookup) - override fun buildRecipes(pWriter: Consumer) { - ArmourCraftingTableRecipeProvider(this, pWriter).build() - FurnaceRecipeProvider(this, pWriter).build() - NormalCraftingTableRecipeProvider(this, pWriter).build() - ToolCraftingTableRecipeProvider(this, pWriter).build() - NewSmithingTableRecipeProvider(this, pWriter).build() - IngotFusionTollEnhancerRecipeProvider(this, pWriter).build() + override fun buildRecipes(recipeOutput: RecipeOutput) { + ArmourCraftingTableRecipeProvider(this, recipeOutput).build() + FurnaceRecipeProvider(this, recipeOutput).build() + NormalCraftingTableRecipeProvider(this, recipeOutput).build() + ToolCraftingTableRecipeProvider(this, recipeOutput).build() + NewSmithingTableRecipeProvider(this, recipeOutput).build() + IngotFusionTollEnhancerRecipeProvider(this, recipeOutput).build() } open fun modId(path: String): ResourceLocation { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomArmourCraftingTableRecipeBuilder.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomArmourCraftingTableRecipeBuilder.kt index 7637afb0..391bdd79 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomArmourCraftingTableRecipeBuilder.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomArmourCraftingTableRecipeBuilder.kt @@ -25,16 +25,13 @@ import com.google.gson.JsonArray import com.google.gson.JsonObject import io.github.realyusufismail.armourandtoolsmod.blocks.armour.book.CustomArmourCraftingBookCategory import io.github.realyusufismail.armourandtoolsmod.core.init.RecipeSerializerInit +import io.github.realyusufismail.realyusufismailcore.recipe.util.EnchantmentsAndLevels import java.util.* -import java.util.function.Consumer -import net.minecraft.advancements.Advancement -import net.minecraft.advancements.AdvancementRewards -import net.minecraft.advancements.CriterionTriggerInstance -import net.minecraft.advancements.RequirementsStrategy +import net.minecraft.advancements.* import net.minecraft.advancements.critereon.RecipeUnlockedTrigger import net.minecraft.data.recipes.FinishedRecipe -import net.minecraft.data.recipes.RecipeBuilder.ROOT_RECIPE_ADVANCEMENT import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item @@ -42,13 +39,13 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.item.enchantment.Enchantment import net.minecraft.world.level.ItemLike -import net.minecraftforge.registries.ForgeRegistries +import net.neoforged.neoforge.registries.ForgeRegistries /** @see net.minecraft.data.recipes.ShapedRecipeBuilder */ object CustomArmourCraftingTableRecipeBuilder { private val rows: MutableList = Lists.newArrayList() private val key: MutableMap = Maps.newLinkedHashMap() - private var advancement: Advancement.Builder? = null + private val criteria: MutableMap> = Maps.newLinkedHashMap() private var group: String? = null private var bookCategory: CustomArmourCraftingBookCategory? = null @@ -77,7 +74,6 @@ object CustomArmourCraftingTableRecipeBuilder { this.result = itemLike.asItem() this.count = count this.bookCategory = bookCategory - this.advancement = Advancement.Builder.advancement() return this } @@ -115,9 +111,9 @@ object CustomArmourCraftingTableRecipeBuilder { fun unlockedBy( creterionId: String, - criterionTriggerInstance: CriterionTriggerInstance, + criterion: Criterion<*>, ): CustomArmourCraftingTableRecipeBuilder { - advancement?.addCriterion(creterionId, criterionTriggerInstance) + this.criteria.put(creterionId, criterion) return this } @@ -149,16 +145,19 @@ object CustomArmourCraftingTableRecipeBuilder { } fun save( - finishedRecipeConsumer: Consumer, + recipeOutput: RecipeOutput, resourceLocation: ResourceLocation, ) { ensureValid(resourceLocation) - advancement - ?.parent(ROOT_RECIPE_ADVANCEMENT) - ?.addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(resourceLocation)) - ?.rewards(AdvancementRewards.Builder.recipe(resourceLocation)) - ?.requirements(RequirementsStrategy.OR) - finishedRecipeConsumer.accept( + + val advancementBuilder: Advancement.Builder? = + recipeOutput + .advancement() + .addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(resourceLocation)) + .rewards(AdvancementRewards.Builder.recipe(resourceLocation)) + .requirements(AdvancementRequirements.Strategy.OR) + + recipeOutput.accept( Result( bookCategory ?: throw IllegalStateException("Recipe category is not set"), resourceLocation, @@ -167,8 +166,9 @@ object CustomArmourCraftingTableRecipeBuilder { group ?: "", rows, key, - advancement ?: throw IllegalStateException("Advancement is not set"), - resourceLocation.withPrefix("recipes/" + recipeCategory!!.folderName + "/"), + advancementBuilder!!.build( + resourceLocation.withPrefix( + "recipes/" + this.recipeCategory!!.folderName + "/")), showNotification, enchantmentsAndLevels, hideFlags)) @@ -183,7 +183,6 @@ object CustomArmourCraftingTableRecipeBuilder { recipeCategory = null count = null result = null - advancement = null } private fun ensureValid(resourceLocation: ResourceLocation) { @@ -216,7 +215,7 @@ object CustomArmourCraftingTableRecipeBuilder { ("Shaped recipe " + resourceLocation + " only takes in a single item - should it be a shapeless recipe instead?")) - } else if (advancement?.criteria?.isEmpty() == true) { + } else if (criteria.isEmpty() == true) { throw IllegalStateException("No way of obtaining recipe $resourceLocation") } } @@ -230,11 +229,10 @@ object CustomArmourCraftingTableRecipeBuilder { group: String, pattern: List, key: Map, - advancement: Advancement.Builder, - advancementId: ResourceLocation, - showNotification: Boolean, - val enchantmentsAndLevels: EnchantmentsAndLevels, - val hideFlags: Boolean, + advancement: AdvancementHolder, + private val showNotification: Boolean, + private val enchantmentsAndLevels: EnchantmentsAndLevels, + private val hideFlags: Boolean, ) : FinishedRecipe { override fun serializeRecipeData(jsonObject: JsonObject) { if (group.isNotEmpty()) { @@ -249,7 +247,7 @@ object CustomArmourCraftingTableRecipeBuilder { jsonObject.add("pattern", jsonarray) val jsonObject1 = JsonObject() for (entry: Map.Entry in key.entries) { - jsonObject1.add(entry.key.toString(), entry.value.toJson()) + jsonObject1.add(entry.key.toString(), entry.value.toJson(false)) } jsonObject.add("key", jsonObject1) val jsonObject2 = JsonObject() @@ -281,20 +279,16 @@ object CustomArmourCraftingTableRecipeBuilder { jsonObject.add("result", jsonObject2) } - override fun getType(): RecipeSerializer<*> { - return RecipeSerializerInit.CUSTOM_ARMOUR_CRAFTER.get() - } - - override fun getId(): ResourceLocation { - return id + override fun id(): ResourceLocation { + return advancement.id() } - override fun serializeAdvancement(): JsonObject? { - return advancement.serializeToJson() + override fun type(): RecipeSerializer<*> { + return RecipeSerializerInit.CUSTOM_ARMOUR_CRAFTER.get() } - override fun getAdvancementId(): ResourceLocation { - return advancementId + override fun advancement(): AdvancementHolder { + return advancement } private val id: ResourceLocation @@ -303,8 +297,7 @@ object CustomArmourCraftingTableRecipeBuilder { private val group: String private val pattern: List private val key: Map - private val advancement: Advancement.Builder - private val advancementId: ResourceLocation + private val advancement: AdvancementHolder init { this.id = id @@ -314,7 +307,6 @@ object CustomArmourCraftingTableRecipeBuilder { this.pattern = pattern this.key = key this.advancement = advancement - this.advancementId = advancementId } } } diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomToolCraftingTableRecipeBuilder.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomToolCraftingTableRecipeBuilder.kt index fc98b8d0..84169a36 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomToolCraftingTableRecipeBuilder.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/CustomToolCraftingTableRecipeBuilder.kt @@ -25,17 +25,14 @@ import com.google.gson.JsonArray import com.google.gson.JsonObject import io.github.realyusufismail.armourandtoolsmod.blocks.tool.book.CustomToolsCraftingBookCategory import io.github.realyusufismail.armourandtoolsmod.core.init.RecipeSerializerInit +import io.github.realyusufismail.realyusufismailcore.recipe.util.EnchantmentsAndLevels import java.util.* -import java.util.function.Consumer -import net.minecraft.advancements.Advancement -import net.minecraft.advancements.AdvancementRewards -import net.minecraft.advancements.CriterionTriggerInstance -import net.minecraft.advancements.RequirementsStrategy +import net.minecraft.advancements.* import net.minecraft.advancements.critereon.RecipeUnlockedTrigger import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeBuilder -import net.minecraft.data.recipes.RecipeBuilder.ROOT_RECIPE_ADVANCEMENT import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item @@ -43,13 +40,13 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.item.enchantment.Enchantment import net.minecraft.world.level.ItemLike -import net.minecraftforge.registries.ForgeRegistries +import net.neoforged.neoforge.registries.ForgeRegistries /** @see net.minecraft.data.recipes.ShapedRecipeBuilder */ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { private val rows: MutableList = Lists.newArrayList() private val key: MutableMap = Maps.newLinkedHashMap() - private var advancement: Advancement.Builder? = null + private val criteria: MutableMap> = Maps.newLinkedHashMap() private var group: String? = null private var bookCategory: CustomToolsCraftingBookCategory? = null @@ -79,7 +76,6 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { this.result = itemLike.asItem() this.count = count this.bookCategory = bookCategory - this.advancement = Advancement.Builder.advancement() return this } @@ -117,9 +113,9 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { override fun unlockedBy( creterionId: String, - criterionTriggerInstance: CriterionTriggerInstance, + criterion: Criterion<*>, ): CustomToolCraftingTableRecipeBuilder { - advancement?.addCriterion(creterionId, criterionTriggerInstance) + this.criteria[creterionId] = criterion return this } @@ -133,13 +129,6 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { return this } - fun addEnchantments( - enchantmentsAndLevels: EnchantmentsAndLevels - ): CustomToolCraftingTableRecipeBuilder { - this.enchantmentsAndLevels.addAll(enchantmentsAndLevels) - return this - } - fun hideFlags(hideFlags: Int): CustomToolCraftingTableRecipeBuilder { this.hideFlags = hideFlags return this @@ -155,16 +144,19 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { } override fun save( - finishedRecipeConsumer: Consumer, + recipeOutput: RecipeOutput, resourceLocation: ResourceLocation, ) { ensureValid(resourceLocation) - advancement - ?.parent(ROOT_RECIPE_ADVANCEMENT) - ?.addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(resourceLocation)) - ?.rewards(AdvancementRewards.Builder.recipe(resourceLocation)) - ?.requirements(RequirementsStrategy.OR) - finishedRecipeConsumer.accept( + + val advancementBuilder: Advancement.Builder = + recipeOutput + .advancement() + .addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(resourceLocation)) + .rewards(AdvancementRewards.Builder.recipe(resourceLocation)) + .requirements(AdvancementRequirements.Strategy.OR) + + recipeOutput.accept( Result( bookCategory ?: throw IllegalStateException("Recipe category is not set"), resourceLocation, @@ -173,8 +165,9 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { group ?: "", rows, key, - advancement ?: throw IllegalStateException("Advancement is not set"), - resourceLocation.withPrefix("recipes/" + recipeCategory!!.folderName + "/"), + advancementBuilder.build( + resourceLocation.withPrefix( + "recipes/" + this.recipeCategory!!.folderName + "/")), showNotification, enchantmentsAndLevels, hideFlags)) @@ -189,7 +182,6 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { recipeCategory = null count = null result = null - advancement = null } private fun ensureValid(resourceLocation: ResourceLocation) { @@ -222,7 +214,7 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { ("Shaped recipe " + resourceLocation + " only takes in a single item - should it be a shapeless recipe instead?")) - } else if (advancement?.criteria?.isEmpty() == true) { + } else if (criteria.isEmpty()) { throw IllegalStateException("No way of obtaining recipe $resourceLocation") } } @@ -236,11 +228,10 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { group: String, pattern: List, key: Map, - advancement: Advancement.Builder, - advancementId: ResourceLocation, - showNotification: Boolean, - enchantmentsAndLevels: EnchantmentsAndLevels, - hideFlags: Int = 0, + advancement: AdvancementHolder, + private val showNotification: Boolean, + private val enchantmentsAndLevels: EnchantmentsAndLevels, + private val hideFlags: Int = 0, ) : FinishedRecipe { override fun serializeRecipeData(jsonObject: JsonObject) { if (group.isNotEmpty()) { @@ -255,7 +246,7 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { jsonObject.add("pattern", jsonarray) val jsonObject1 = JsonObject() for (entry: Map.Entry in key.entries) { - jsonObject1.add(entry.key.toString(), entry.value.toJson()) + jsonObject1.add(entry.key.toString(), entry.value.toJson(false)) } jsonObject.add("key", jsonObject1) val jsonObject2 = JsonObject() @@ -288,20 +279,16 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { jsonObject.add("result", jsonObject2) } - override fun getType(): RecipeSerializer<*> { - return RecipeSerializerInit.CUSTOM_TOOL_CRAFTER.get() + override fun id(): ResourceLocation { + return advancement.id() } - override fun getId(): ResourceLocation { - return id - } - - override fun serializeAdvancement(): JsonObject? { - return advancement.serializeToJson() + override fun type(): RecipeSerializer<*> { + return RecipeSerializerInit.CUSTOM_TOOL_CRAFTER.get() } - override fun getAdvancementId(): ResourceLocation { - return advancementId + override fun advancement(): AdvancementHolder? { + return advancement } private val id: ResourceLocation @@ -310,8 +297,7 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { private val group: String private val pattern: List private val key: Map - private val advancement: Advancement.Builder - private val advancementId: ResourceLocation + private val advancement: AdvancementHolder init { this.id = id @@ -321,7 +307,6 @@ object CustomToolCraftingTableRecipeBuilder : RecipeBuilder { this.pattern = pattern this.key = key this.advancement = advancement - this.advancementId = advancementId } } } diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/EnchantmentsAndLevels.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/EnchantmentsAndLevels.kt deleted file mode 100644 index 518be3bb..00000000 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/EnchantmentsAndLevels.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2023 RealYusufIsmail. - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * - * you may not use this file except in compliance with the License. - * - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.realyusufismail.armourandtoolsmod.datagen.recipe.builder - -import net.minecraft.world.item.enchantment.Enchantment - -class EnchantmentsAndLevels : MutableMap by mutableMapOf() { - - fun add(enchantment: net.minecraft.world.item.enchantment.Enchantment, level: Int) { - put(enchantment, level) - } - - fun addAll(enchantmentsAndLevels: EnchantmentsAndLevels) { - putAll(enchantmentsAndLevels) - } -} diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/IngotFusionTollEnhancerRecipeBuilder.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/IngotFusionTollEnhancerRecipeBuilder.kt index e2fd9c47..32aad339 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/IngotFusionTollEnhancerRecipeBuilder.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/builder/IngotFusionTollEnhancerRecipeBuilder.kt @@ -18,23 +18,21 @@ */ package io.github.realyusufismail.armourandtoolsmod.datagen.recipe.builder +import com.google.common.collect.Maps import com.google.gson.JsonObject import io.github.realyusufismail.armourandtoolsmod.blocks.infusion.book.IngotFusionTollEnhancerRecipeBookCategory import io.github.realyusufismail.armourandtoolsmod.core.init.RecipeSerializerInit import java.util.* -import java.util.function.Consumer -import net.minecraft.advancements.Advancement -import net.minecraft.advancements.AdvancementRewards -import net.minecraft.advancements.RequirementsStrategy -import net.minecraft.advancements.critereon.InventoryChangeTrigger +import net.minecraft.advancements.* import net.minecraft.advancements.critereon.RecipeUnlockedTrigger import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.RecipeSerializer -import net.minecraftforge.registries.ForgeRegistries +import net.neoforged.neoforge.registries.ForgeRegistries class IngotFusionTollEnhancerRecipeBuilder( private val recipeCategory: IngotFusionTollEnhancerRecipeBookCategory, @@ -43,42 +41,45 @@ class IngotFusionTollEnhancerRecipeBuilder( private val ingredient3: Ingredient, private val result: ItemStack, ) { - private val advancementBuilder = Advancement.Builder.advancement() + private val criteria: MutableMap> = Maps.newLinkedHashMap() fun unlockedBy( - criterionId: String, - criterion: InventoryChangeTrigger.TriggerInstance + creterionId: String, + criterion: Criterion<*>, ): IngotFusionTollEnhancerRecipeBuilder { - advancementBuilder.addCriterion(criterionId, criterion) + this.criteria[creterionId] = criterion return this } - fun save(consumer: Consumer, rl: ResourceLocation) { + fun save(recipeOutput: RecipeOutput, rl: ResourceLocation) { try { ensureValid(rl) - if (advancementBuilder.criteria.isNotEmpty()) - advancementBuilder - .parent(ResourceLocation("recipes/root")) - .addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(rl)) - .rewards(AdvancementRewards.Builder.recipe(rl)) - .requirements(RequirementsStrategy.OR) - consumer.accept( - Result( - recipeCategory, - ingredient1, - ingredient2, - ingredient3, - result, - advancementBuilder, - rl.withPrefix("recipes/" + recipeCategory.serializedName + "/"), - rl)) + + if (criteria.isNotEmpty()) { + val advancementBuilder: Advancement.Builder = + recipeOutput + .advancement() + .addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(rl)) + .rewards(AdvancementRewards.Builder.recipe(rl)) + .requirements(AdvancementRequirements.Strategy.OR) + + recipeOutput.accept( + Result( + recipeCategory, + ingredient1, + ingredient2, + ingredient3, + result, + advancementBuilder.build( + rl.withPrefix("recipes/" + this.recipeCategory.serializedName + "/")))) + } } catch (e: IllegalStateException) { throw IllegalStateException("Could not create recipe: $rl", e) } } private fun ensureValid(rl: ResourceLocation) { - check(advancementBuilder.criteria.isNotEmpty()) { "Can not obtain recipe: $rl" } + check(criteria.isNotEmpty()) { "Can not obtain recipe: $rl" } } /** @@ -99,16 +100,18 @@ class IngotFusionTollEnhancerRecipeBuilder( val ingredient2: Ingredient, val ingredient3: Ingredient, val result: ItemStack, - val advancementBuilder: Advancement.Builder, - val advancementId: ResourceLocation, - val id: ResourceLocation + val advancementHolder: AdvancementHolder ) : FinishedRecipe { override fun serializeRecipeData(json: JsonObject) { json.addProperty("category", recipeCategory.serializedName) json.add("result", serializeResult(result)) - json.add("ingredient1", ingredient1.toJson()) - json.add("ingredient2", ingredient2.toJson()) - json.add("ingredient3", ingredient3.toJson()) + json.add("ingredient1", ingredient1.toJson(false)) + json.add("ingredient2", ingredient2.toJson(false)) + json.add("ingredient3", ingredient3.toJson(false)) + } + + override fun id(): ResourceLocation { + return advancementHolder.id } private fun serializeResult(stack: ItemStack): JsonObject { @@ -121,20 +124,12 @@ class IngotFusionTollEnhancerRecipeBuilder( return json } - override fun getId(): ResourceLocation { - return id - } - - override fun getType(): RecipeSerializer<*> { + override fun type(): RecipeSerializer<*> { return RecipeSerializerInit.INGOT_FUSION_TOLL_ENHANCER_RECIPE.get() } - override fun serializeAdvancement(): JsonObject { - return advancementBuilder.serializeToJson() - } - - override fun getAdvancementId(): ResourceLocation { - return advancementId + override fun advancement(): AdvancementHolder { + return advancementHolder } } diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/ArmourCraftingTableRecipeProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/ArmourCraftingTableRecipeProvider.kt index def3541f..1a4fd544 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/ArmourCraftingTableRecipeProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/ArmourCraftingTableRecipeProvider.kt @@ -23,14 +23,13 @@ import io.github.realyusufismail.armourandtoolsmod.core.init.ItemInit import io.github.realyusufismail.armourandtoolsmod.core.init.TagsInit import io.github.realyusufismail.armourandtoolsmod.datagen.recipe.MainModRecipeProvider import io.github.realyusufismail.armourandtoolsmod.datagen.recipe.builder.CustomArmourCraftingTableRecipeBuilder -import java.util.function.Consumer -import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.world.item.Items class ArmourCraftingTableRecipeProvider( private val mainModRecipeProvider: MainModRecipeProvider, - private val consumer: Consumer, + private val consumer: RecipeOutput, ) : MainModRecipeProvider(mainModRecipeProvider) { private val hasItem = "has_item" diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/FurnaceRecipeProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/FurnaceRecipeProvider.kt index c20eabf4..6b0c9391 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/FurnaceRecipeProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/FurnaceRecipeProvider.kt @@ -24,14 +24,13 @@ import io.github.realyusufismail.armourandtoolsmod.core.util.bName import io.github.realyusufismail.armourandtoolsmod.core.util.name import io.github.realyusufismail.armourandtoolsmod.datagen.recipe.MainModRecipeProvider import io.github.realyusufismail.realyusufismailcore.recipe.YusufSimpleCookingRecipeBuilder -import java.util.function.Consumer -import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.world.item.crafting.Ingredient class FurnaceRecipeProvider( private val mainModRecipeProvider: MainModRecipeProvider, - private val consumer: Consumer, + private val consumer: RecipeOutput, ) : MainModRecipeProvider(mainModRecipeProvider) { private val hasItem = "has_item" diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/IngotFusionTollEnhancerRecipeProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/IngotFusionTollEnhancerRecipeProvider.kt index 496cf7ee..f8dfb067 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/IngotFusionTollEnhancerRecipeProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/IngotFusionTollEnhancerRecipeProvider.kt @@ -22,13 +22,12 @@ import io.github.realyusufismail.armourandtoolsmod.blocks.infusion.book.IngotFus import io.github.realyusufismail.armourandtoolsmod.core.init.ItemInit import io.github.realyusufismail.armourandtoolsmod.datagen.recipe.MainModRecipeProvider import io.github.realyusufismail.armourandtoolsmod.datagen.recipe.builder.IngotFusionTollEnhancerRecipeBuilder -import java.util.function.Consumer -import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.world.item.ItemStack class IngotFusionTollEnhancerRecipeProvider( private val mainModRecipeProvider: MainModRecipeProvider, - private val pWriter: Consumer + private val pWriter: RecipeOutput ) : MainModRecipeProvider(mainModRecipeProvider) { fun build() { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/NewSmithingTableRecipeProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/NewSmithingTableRecipeProvider.kt index 48b9682b..db7f3ccd 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/NewSmithingTableRecipeProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/NewSmithingTableRecipeProvider.kt @@ -21,16 +21,15 @@ package io.github.realyusufismail.armourandtoolsmod.datagen.recipe.provider import io.github.realyusufismail.armourandtoolsmod.ArmourAndToolsMod import io.github.realyusufismail.armourandtoolsmod.core.init.ItemInit import io.github.realyusufismail.armourandtoolsmod.datagen.recipe.MainModRecipeProvider -import java.util.function.Consumer -import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.SmithingTrimRecipeBuilder import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient class NewSmithingTableRecipeProvider( private val mainModRecipeProvider: MainModRecipeProvider, - private val pWriter: Consumer + private val pWriter: RecipeOutput ) : MainModRecipeProvider(mainModRecipeProvider) { fun build() { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/NormalCraftingTableRecipeProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/NormalCraftingTableRecipeProvider.kt index ba225ee0..eaf7da26 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/NormalCraftingTableRecipeProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/NormalCraftingTableRecipeProvider.kt @@ -23,9 +23,8 @@ import io.github.realyusufismail.armourandtoolsmod.core.util.name import io.github.realyusufismail.armourandtoolsmod.datagen.recipe.MainModRecipeProvider import io.github.realyusufismail.realyusufismailcore.recipe.YusufShapedRecipeBuilder import io.github.realyusufismail.realyusufismailcore.recipe.YusufShapelessRecipeBuilder -import java.util.function.Consumer -import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.tags.BlockTags import net.minecraft.tags.BlockTags.BASE_STONE_OVERWORLD import net.minecraft.tags.ItemTags @@ -34,7 +33,7 @@ import net.minecraft.world.level.block.Blocks class NormalCraftingTableRecipeProvider( private val mainModRecipeProvider: MainModRecipeProvider, - private val pWriter: Consumer + private val pWriter: RecipeOutput ) : MainModRecipeProvider(mainModRecipeProvider) { fun build() { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/ToolCraftingTableRecipeProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/ToolCraftingTableRecipeProvider.kt index be0a3ac2..2f2c4af8 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/ToolCraftingTableRecipeProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/recipe/provider/ToolCraftingTableRecipeProvider.kt @@ -23,15 +23,14 @@ import io.github.realyusufismail.armourandtoolsmod.core.init.ItemInit import io.github.realyusufismail.armourandtoolsmod.core.init.TagsInit import io.github.realyusufismail.armourandtoolsmod.datagen.recipe.MainModRecipeProvider import io.github.realyusufismail.armourandtoolsmod.datagen.recipe.builder.CustomToolCraftingTableRecipeBuilder -import java.util.function.Consumer -import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.world.item.Items import net.minecraft.world.item.enchantment.Enchantments class ToolCraftingTableRecipeProvider( private val mainModRecipeProvider: MainModRecipeProvider, - private val consumer: Consumer, + private val consumer: RecipeOutput, ) : MainModRecipeProvider(mainModRecipeProvider) { private val hasItem = "has_item" diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/spirit/ArmourAndTollsModSpriteSourceProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/spirit/ArmourAndTollsModSpriteSourceProvider.kt index c8c431a7..1bfa76e6 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/spirit/ArmourAndTollsModSpriteSourceProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/spirit/ArmourAndTollsModSpriteSourceProvider.kt @@ -22,17 +22,23 @@ import com.google.common.collect.ImmutableMap import io.github.realyusufismail.armourandtoolsmod.ArmourAndToolsMod import io.github.realyusufismail.armourandtoolsmod.ArmourAndToolsMod.ArmorAndToolsMod.MOD_ID import java.util.* +import java.util.concurrent.CompletableFuture import net.minecraft.client.renderer.texture.atlas.sources.PalettedPermutations import net.minecraft.client.renderer.texture.atlas.sources.SingleFile +import net.minecraft.core.HolderLookup import net.minecraft.data.PackOutput import net.minecraft.resources.ResourceLocation -import net.minecraftforge.common.data.ExistingFileHelper -import net.minecraftforge.common.data.SpriteSourceProvider +import net.neoforged.neoforge.common.data.ExistingFileHelper +import net.neoforged.neoforge.common.data.SpriteSourceProvider /** Makes sure that the textures are loaded from the correct location. */ -class ArmourAndTollsModSpriteSourceProvider(output: PackOutput, exFileHelper: ExistingFileHelper) : - SpriteSourceProvider(output, exFileHelper, MOD_ID) { - override fun addSources() { +class ArmourAndTollsModSpriteSourceProvider( + output: PackOutput, + exFileHelper: ExistingFileHelper, + lookup: CompletableFuture +) : SpriteSourceProvider(output, lookup, MOD_ID, exFileHelper) { + + override fun gather() { val blockAtlas = atlas(BLOCKS_ATLAS) val armorTrimsAtlas = atlas(ResourceLocation("armor_trims")) diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/tags/ModBlockTagsProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/tags/ModBlockTagsProvider.kt index 3158da9c..b686f0f6 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/tags/ModBlockTagsProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/tags/ModBlockTagsProvider.kt @@ -28,8 +28,8 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.tags.BlockTags import net.minecraft.tags.TagKey import net.minecraft.world.level.block.Block -import net.minecraftforge.common.data.BlockTagsProvider -import net.minecraftforge.common.data.ExistingFileHelper +import net.neoforged.neoforge.common.data.BlockTagsProvider +import net.neoforged.neoforge.common.data.ExistingFileHelper class ModBlockTagsProvider( generatorIn: DataGenerator, diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/tags/ModItemTagsProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/tags/ModItemTagsProvider.kt index 93efac25..6e92d713 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/tags/ModItemTagsProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/tags/ModItemTagsProvider.kt @@ -25,8 +25,8 @@ import java.util.concurrent.CompletableFuture import net.minecraft.core.HolderLookup import net.minecraft.data.DataGenerator import net.minecraft.data.tags.ItemTagsProvider -import net.minecraftforge.common.data.BlockTagsProvider -import net.minecraftforge.common.data.ExistingFileHelper +import net.neoforged.neoforge.common.data.BlockTagsProvider +import net.neoforged.neoforge.common.data.ExistingFileHelper class ModItemTagsProvider( generatorIn: DataGenerator, diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/texture/ModBlockStateProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/texture/ModBlockStateProvider.kt index b4c7e1f0..f21244e9 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/texture/ModBlockStateProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/texture/ModBlockStateProvider.kt @@ -24,9 +24,9 @@ import net.minecraft.data.PackOutput import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Blocks -import net.minecraftforge.client.model.generators.BlockStateProvider -import net.minecraftforge.common.data.ExistingFileHelper -import net.minecraftforge.registries.ForgeRegistries +import net.neoforged.neoforge.client.model.generators.BlockStateProvider +import net.neoforged.neoforge.common.data.ExistingFileHelper +import net.neoforged.neoforge.registries.ForgeRegistries class ModBlockStateProvider(output: PackOutput, exFileHelper: ExistingFileHelper) : BlockStateProvider(output, MOD_ID, exFileHelper) { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/texture/ModItemStateProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/texture/ModItemStateProvider.kt index 39ad817b..fda1b140 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/texture/ModItemStateProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/texture/ModItemStateProvider.kt @@ -26,12 +26,12 @@ import net.minecraft.data.PackOutput import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.Item import net.minecraft.world.item.ItemDisplayContext -import net.minecraftforge.client.model.generators.ItemModelBuilder -import net.minecraftforge.client.model.generators.ItemModelProvider -import net.minecraftforge.client.model.generators.ModelFile -import net.minecraftforge.client.model.generators.ModelFile.UncheckedModelFile -import net.minecraftforge.client.model.generators.loaders.SeparateTransformsModelBuilder -import net.minecraftforge.common.data.ExistingFileHelper +import net.neoforged.neoforge.client.model.generators.ItemModelBuilder +import net.neoforged.neoforge.client.model.generators.ItemModelProvider +import net.neoforged.neoforge.client.model.generators.ModelFile +import net.neoforged.neoforge.client.model.generators.ModelFile.UncheckedModelFile +import net.neoforged.neoforge.client.model.generators.loaders.SeparateTransformsModelBuilder +import net.neoforged.neoforge.common.data.ExistingFileHelper class ModItemStateProvider(output: PackOutput, exFileHelper: ExistingFileHelper) : ItemModelProvider(output, MOD_ID, exFileHelper) { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/world/ModWorldGenProvider.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/world/ModWorldGenProvider.kt index 5c20e52b..05d1b4e3 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/world/ModWorldGenProvider.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/datagen/world/ModWorldGenProvider.kt @@ -26,7 +26,7 @@ import net.minecraft.core.HolderLookup import net.minecraft.core.RegistrySetBuilder import net.minecraft.core.registries.Registries import net.minecraft.data.PackOutput -import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider +import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider class ModWorldGenProvider( output: PackOutput, diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/hammer/HammerItem.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/hammer/HammerItem.kt index d3d2fcb2..ea542db5 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/hammer/HammerItem.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/hammer/HammerItem.kt @@ -35,8 +35,8 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.ToolAction -import net.minecraftforge.common.ToolActions +import net.neoforged.neoforge.common.ToolAction +import net.neoforged.neoforge.common.ToolActions /** @see SwordItem */ open class HammerItem( @@ -79,15 +79,11 @@ open class HammerItem( override fun getDestroySpeed(pStack: ItemStack, pState: BlockState): Float { val hammerLevel = this.hammerLevel - return getDestroySpeed(hammerLevel, pStack, pState) + return getDestroySpeed(hammerLevel, pState) } - private fun getDestroySpeed( - hammerLevel: HammerLevel, - pStack: ItemStack, - pState: BlockState - ): Float { - val block = pState.block + private fun getDestroySpeed(hammerLevel: HammerLevel, pState: BlockState): Float { + pState.block return if (pState.`is`(Blocks.COBWEB)) { 15.0f } else { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/hammer/Mjolnir.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/hammer/Mjolnir.kt index da11c490..157a02a5 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/hammer/Mjolnir.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/hammer/Mjolnir.kt @@ -32,7 +32,7 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Tier import net.minecraft.world.level.Level -import net.minecraftforge.client.extensions.common.IClientItemExtensions +import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions open class Mjolnir( tier: Tier = CustomToolMaterial.MJOLNIR, diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/shield/ArmourToolsModShieldItem.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/shield/ArmourToolsModShieldItem.kt index ab3c83c1..d204cc82 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/shield/ArmourToolsModShieldItem.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/shield/ArmourToolsModShieldItem.kt @@ -23,7 +23,7 @@ import java.util.function.Consumer import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ShieldItem import net.minecraft.world.item.Tier -import net.minecraftforge.client.extensions.common.IClientItemExtensions +import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions class ArmourToolsModShieldItem(durability: Int, private val tier: Tier) : ShieldItem(Properties().stacksTo(1).durability(durability)) { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/trident/AqumarineTridentItem.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/trident/AqumarineTridentItem.kt index eff82d77..9da6d294 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/trident/AqumarineTridentItem.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/trident/AqumarineTridentItem.kt @@ -26,7 +26,7 @@ import java.util.function.Consumer import net.minecraft.world.entity.LivingEntity import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level -import net.minecraftforge.client.extensions.common.IClientItemExtensions +import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions open class AqumarineTridentItem : ArmourToolsModTridentItem( diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/trident/ArmourToolsModTridentItem.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/trident/ArmourToolsModTridentItem.kt index ebe7443b..481ef77c 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/trident/ArmourToolsModTridentItem.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/items/trident/ArmourToolsModTridentItem.kt @@ -154,7 +154,7 @@ abstract class ArmourToolsModTridentItem( pEntityLiving.startAutoSpinAttack(20) if (pEntityLiving.onGround()) { val f6 = 1.1999999f - pEntityLiving.move(MoverType.SELF, Vec3(0.0, 1.1999999, 0.0)) + pEntityLiving.move(MoverType.SELF, Vec3(0.0, f6.toDouble(), 0.0)) } val soundevent: SoundEvent = if (j >= 3) { diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/recipe/armour/CustomArmourCraftingTableShapedRecipe.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/recipe/armour/CustomArmourCraftingTableShapedRecipe.kt index 8316b7d4..7803a1fd 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/recipe/armour/CustomArmourCraftingTableShapedRecipe.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/recipe/armour/CustomArmourCraftingTableShapedRecipe.kt @@ -19,38 +19,35 @@ package io.github.realyusufismail.armourandtoolsmod.recipe.armour import com.google.common.annotations.VisibleForTesting -import com.google.common.collect.Maps import com.google.common.collect.Sets -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.google.gson.JsonSyntaxException +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult import io.github.realyusufismail.armourandtoolsmod.blocks.armour.CustomArmourCraftingTableContainer import io.github.realyusufismail.armourandtoolsmod.blocks.armour.book.CustomArmourCraftingBookCategory import io.github.realyusufismail.armourandtoolsmod.core.init.BlockInit import io.github.realyusufismail.armourandtoolsmod.core.init.RecipeSerializerInit +import io.github.realyusufismail.armourandtoolsmod.recipe.codec.CustomArmourCraftingTableRawShapedRecipe +import kotlin.math.max +import kotlin.math.min import net.minecraft.core.NonNullList import net.minecraft.core.RegistryAccess import net.minecraft.network.FriendlyByteBuf -import net.minecraft.resources.ResourceLocation -import net.minecraft.util.GsonHelper import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.level.Level -import net.minecraftforge.common.ForgeHooks -import net.minecraftforge.common.crafting.CraftingHelper -import net.minecraftforge.common.crafting.IShapedRecipe +import net.neoforged.neoforge.common.CommonHooks +import net.neoforged.neoforge.common.crafting.IShapedRecipe +import org.apache.commons.lang3.NotImplementedException class CustomArmourCraftingTableShapedRecipe( - private val id: ResourceLocation, - private val group: String, - private val recipeCategory: CustomArmourCraftingBookCategory, - private val width: Int, - private val height: Int, - private val recipeItems: NonNullList, + val gr: String, + val recipeCategory: CustomArmourCraftingBookCategory, + val width: Int, + val height: Int, + val recipeItems: NonNullList, override val result: ItemStack, - private val showNotification: Boolean, + val showNotification: Boolean, ) : CustomArmourCraftingTableRecipe, IShapedRecipe { /** Used to check if a recipe matches current crafting inventory */ @@ -119,17 +116,13 @@ class CustomArmourCraftingTableShapedRecipe( /** Recipes with equal group are combined into one button in the recipe book */ override fun getGroup(): String { - return this.group + return this.gr } override fun getIngredients(): NonNullList { return this.recipeItems } - override fun getId(): ResourceLocation { - return this.id - } - override fun getToastSymbol(): ItemStack { return ItemStack(BlockInit.CUSTOM_ARMOUR_CRAFTING_TABLE.get()) } @@ -160,24 +153,26 @@ class CustomArmourCraftingTableShapedRecipe( nonnulllist .stream() .filter { ingredient: Ingredient -> !ingredient.isEmpty } - .anyMatch { ingredient: Ingredient? -> ForgeHooks.hasNoElements(ingredient) } + .anyMatch { ingredient: Ingredient? -> CommonHooks.hasNoElements(ingredient) } } companion object { - private var MAX_WIDTH = 3 - private var MAX_HEIGHT = 3 + @JvmField var MAX_WIDTH = 3 + + @JvmField var MAX_HEIGHT = 3 @VisibleForTesting - fun shrink(vararg pToShrink: String?): Array { + @JvmStatic + fun shrink(p_301102_: List): Array { var i = Int.MAX_VALUE var j = 0 var k = 0 var l = 0 - for (i1 in pToShrink.indices) { - val s = pToShrink[i1] - i = i.coerceAtMost(firstNonSpace(s!!)) + for (i1 in p_301102_.indices) { + val s = p_301102_[i1] + i = min(i.toDouble(), firstNonSpace(s).toDouble()).toInt() val j1 = lastNonSpace(s) - j = j.coerceAtLeast(j1) + j = max(j.toDouble(), j1.toDouble()).toInt() if (j1 < 0) { if (k == i1) { ++k @@ -187,12 +182,12 @@ class CustomArmourCraftingTableShapedRecipe( l = 0 } } - return if (pToShrink.size == l) { + return if (p_301102_.size == l) { arrayOfNulls(0) } else { - val astring = arrayOfNulls(pToShrink.size - l - k) + val astring = arrayOfNulls(p_301102_.size - l - k) for (k1 in astring.indices) { - astring[k1] = pToShrink[k1 + k]?.substring(i, j + 1) + astring[k1] = p_301102_[k1 + k].substring(i, j + 1) } astring } @@ -213,129 +208,55 @@ class CustomArmourCraftingTableShapedRecipe( } return i } + } - fun patternFromJson(pPatternArray: JsonArray): Array { - val astring = arrayOfNulls(pPatternArray.size()) - if (astring.size > MAX_HEIGHT) { - throw JsonSyntaxException("Invalid pattern: too many rows, $MAX_HEIGHT is maximum") - } else if (astring.isEmpty()) { - throw JsonSyntaxException("Invalid pattern: empty pattern not allowed") - } else { - for (i in astring.indices) { - val s = GsonHelper.convertToString(pPatternArray.get(i), "pattern[$i]") - if (s.length > MAX_WIDTH) { - throw JsonSyntaxException( - "Invalid pattern: too many columns, $MAX_WIDTH is maximum") - } - if (i > 0 && astring[0]!!.length != s.length) { - throw JsonSyntaxException( - "Invalid pattern: each row must be the same width") - } - astring[i] = s - } - return astring - } - } + class Serializer : RecipeSerializer { - /** Returns a key json object as a Java HashMap. */ - fun keyFromJson(pKeyEntry: JsonObject): MutableMap { - val map: MutableMap = Maps.newHashMap() - for (entry: Map.Entry in pKeyEntry.entrySet()) { - if (entry.key.length != 1) { - throw JsonSyntaxException( - "Invalid key entry: '" + - entry.key + - "' is an invalid symbol (must be 1 character only).") + private val CODEC = + CustomArmourCraftingTableRawShapedRecipe.CODEC.flatXmap({ + p_301248_: CustomArmourCraftingTableRawShapedRecipe -> + val astring = shrink(p_301248_.pattern) + val i = astring[0]!!.length + val j = astring.size + val nonnulllist = NonNullList.withSize(i * j, Ingredient.EMPTY) + val set: MutableSet = Sets.newHashSet(p_301248_.key.keys) + for (k in astring.indices) { + val s = astring[k] + for (l in 0 until s!!.length) { + val s1 = s.substring(l, l + 1) + val ingredient = + (if (s1 == " ") Ingredient.EMPTY else p_301248_.key[s1]) + ?: return@flatXmap DataResult.error< + CustomArmourCraftingTableShapedRecipe> { + "Pattern references symbol '$s1' but it's not defined in the key" + } + set.remove(s1) + nonnulllist[l + i * k] = ingredient + } } - if ((" " == entry.key)) { - throw JsonSyntaxException("Invalid key entry: ' ' is a reserved symbol.") + if (set.isNotEmpty()) { + return@flatXmap DataResult.error { + "Key defines symbols that aren't used in pattern: $set" + } + } else { + val shapedrecipe = + CustomArmourCraftingTableShapedRecipe( + p_301248_.group, + p_301248_.category, + i, + j, + nonnulllist, + p_301248_.result, + p_301248_.showNotification) + return@flatXmap DataResult.success( + shapedrecipe) } - map[entry.key] = Ingredient.fromJson(entry.value) + }) { _: CustomArmourCraftingTableShapedRecipe -> + throw NotImplementedException("Serializing ShapedRecipe is not implemented yet.") } - map[" "] = Ingredient.EMPTY - return map - } - - fun itemStackFromJson(pStackObject: JsonObject): ItemStack { - return CraftingHelper.getItemStack(pStackObject, true, true) - } - fun dissolvePattern( - pPattern: Array, - pKeys: Map, - pPatternWidth: Int, - pPatternHeight: Int, - ): NonNullList { - val nonnulllist = NonNullList.withSize(pPatternWidth * pPatternHeight, Ingredient.EMPTY) - val set: MutableSet = Sets.newHashSet(pKeys.keys) - set.remove(" ") - for (i in pPattern.indices) { - for (j in 0 until (pPattern[i]?.length ?: 0)) { - val s = pPattern[i]?.substring(j, j + 1) - val ingredient = - pKeys[s] - ?: throw JsonSyntaxException( - ("Pattern references symbol '" + - s + - "' but it's not defined in the key")) - set.remove(s) - nonnulllist[j + pPatternWidth * i] = ingredient - } - } - if (set.isNotEmpty()) { - throw JsonSyntaxException("Key defines symbols that aren't used in pattern: $set") - } else { - return nonnulllist - } - } - } - - class Serializer : RecipeSerializer { - override fun fromJson( - pRecipeId: ResourceLocation, - pJson: JsonObject, - ): CustomArmourCraftingTableShapedRecipe { - val s: String = GsonHelper.getAsString(pJson, "group", "")!! - - val map: Map = keyFromJson(GsonHelper.getAsJsonObject(pJson, "key")) - - val craftingbookcategory = - CustomArmourCraftingBookCategory.CODEC.byName( - GsonHelper.getAsString(pJson, "category", null as String?), - CustomArmourCraftingBookCategory.MISC) - - val astring: Array = - shrink(*patternFromJson(GsonHelper.getAsJsonArray(pJson, "pattern"))) - - val i = astring[0]?.length - val j = astring.size - val nonnulllist: NonNullList = dissolvePattern(astring, map, i!!, j) - - val itemstack: ItemStack = - itemStackFromJson(GsonHelper.getAsJsonObject(pJson, "result")) - - val flag = GsonHelper.getAsBoolean(pJson, "show_notification", true) - - return CustomArmourCraftingTableShapedRecipe( - pRecipeId, s, craftingbookcategory, i, j, nonnulllist, itemstack, flag) - } - - override fun fromNetwork( - pRecipeId: ResourceLocation, - pBuffer: FriendlyByteBuf, - ): CustomArmourCraftingTableShapedRecipe { - val i = pBuffer.readVarInt() - val j = pBuffer.readVarInt() - val s = pBuffer.readUtf() - val nonnulllist = NonNullList.withSize(i * j, Ingredient.EMPTY) - nonnulllist.replaceAll { Ingredient.fromNetwork(pBuffer) } - val itemstack = pBuffer.readItem() - val craftingbookcategory = - pBuffer.readEnum(CustomArmourCraftingBookCategory::class.java) - val flag = pBuffer.readBoolean() - - return CustomArmourCraftingTableShapedRecipe( - pRecipeId, s, craftingbookcategory, i, j, nonnulllist, itemstack, flag) + override fun codec(): Codec { + return CODEC } override fun toNetwork( @@ -344,12 +265,29 @@ class CustomArmourCraftingTableShapedRecipe( ) { pBuffer.writeVarInt(pRecipe.width) pBuffer.writeVarInt(pRecipe.height) - pBuffer.writeUtf(pRecipe.group) + pBuffer.writeUtf(pRecipe.gr) for (ingredient: Ingredient in pRecipe.recipeItems) { ingredient.toNetwork(pBuffer) } pBuffer.writeItem(pRecipe.result) pBuffer.writeBoolean(pRecipe.showNotification) } + + override fun fromNetwork( + p_44106_: FriendlyByteBuf + ): CustomArmourCraftingTableShapedRecipe? { + val i = p_44106_.readVarInt() + val j = p_44106_.readVarInt() + val s = p_44106_.readUtf() + val nonnulllist = NonNullList.withSize(i * j, Ingredient.EMPTY) + nonnulllist.replaceAll { Ingredient.fromNetwork(p_44106_) } + val itemstack = p_44106_.readItem() + val craftingbookcategory = + p_44106_.readEnum(CustomArmourCraftingBookCategory::class.java) + val flag = p_44106_.readBoolean() + + return CustomArmourCraftingTableShapedRecipe( + s, craftingbookcategory, i, j, nonnulllist, itemstack, flag) + } } } diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/recipe/tool/CustomToolCraftingTableShapedRecipe.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/recipe/tool/CustomToolCraftingTableShapedRecipe.kt index 9ffa8cb7..1a66c519 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/recipe/tool/CustomToolCraftingTableShapedRecipe.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/recipe/tool/CustomToolCraftingTableShapedRecipe.kt @@ -19,31 +19,28 @@ package io.github.realyusufismail.armourandtoolsmod.recipe.tool import com.google.common.annotations.VisibleForTesting -import com.google.common.collect.Maps import com.google.common.collect.Sets -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.google.gson.JsonSyntaxException +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult import io.github.realyusufismail.armourandtoolsmod.blocks.tool.CustomToolCraftingTableContainer import io.github.realyusufismail.armourandtoolsmod.blocks.tool.book.CustomToolsCraftingBookCategory import io.github.realyusufismail.armourandtoolsmod.core.init.BlockInit import io.github.realyusufismail.armourandtoolsmod.core.init.RecipeSerializerInit +import io.github.realyusufismail.armourandtoolsmod.recipe.codec.CustomToolCraftingTableRawShapedRecipe +import kotlin.math.max +import kotlin.math.min import net.minecraft.core.NonNullList import net.minecraft.core.RegistryAccess import net.minecraft.network.FriendlyByteBuf -import net.minecraft.resources.ResourceLocation -import net.minecraft.util.GsonHelper import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.level.Level -import net.minecraftforge.common.ForgeHooks -import net.minecraftforge.common.crafting.CraftingHelper -import net.minecraftforge.common.crafting.IShapedRecipe +import net.neoforged.neoforge.common.CommonHooks +import net.neoforged.neoforge.common.crafting.IShapedRecipe +import org.apache.commons.lang3.NotImplementedException class CustomToolCraftingTableShapedRecipe( - private val id: ResourceLocation, private val group: String, private val recipeCategory: CustomToolsCraftingBookCategory, private val width: Int, @@ -126,10 +123,6 @@ class CustomToolCraftingTableShapedRecipe( return this.recipeItems } - override fun getId(): ResourceLocation { - return this.id - } - override fun category(): CustomToolsCraftingBookCategory { return recipeCategory } @@ -152,7 +145,7 @@ class CustomToolCraftingTableShapedRecipe( nonnulllist .stream() .filter { ingredient: Ingredient -> !ingredient.isEmpty } - .anyMatch { ingredient: Ingredient? -> ForgeHooks.hasNoElements(ingredient) } + .anyMatch { ingredient: Ingredient? -> CommonHooks.hasNoElements(ingredient) } } override fun getRecipeWidth(): Int { @@ -164,20 +157,23 @@ class CustomToolCraftingTableShapedRecipe( } companion object { - private var MAX_WIDTH = 3 - private var MAX_HEIGHT = 3 + + @JvmField var MAX_WIDTH = 3 + + @JvmField var MAX_HEIGHT = 3 @VisibleForTesting - fun shrink(vararg pToShrink: String?): Array { + @JvmStatic + fun shrink(p_301102_: List): Array { var i = Int.MAX_VALUE var j = 0 var k = 0 var l = 0 - for (i1 in pToShrink.indices) { - val s = pToShrink[i1] - i = i.coerceAtMost(firstNonSpace(s!!)) + for (i1 in p_301102_.indices) { + val s = p_301102_[i1] + i = min(i.toDouble(), firstNonSpace(s).toDouble()).toInt() val j1 = lastNonSpace(s) - j = j.coerceAtLeast(j1) + j = max(j.toDouble(), j1.toDouble()).toInt() if (j1 < 0) { if (k == i1) { ++k @@ -187,12 +183,12 @@ class CustomToolCraftingTableShapedRecipe( l = 0 } } - return if (pToShrink.size == l) { + return if (p_301102_.size == l) { arrayOfNulls(0) } else { - val astring = arrayOfNulls(pToShrink.size - l - k) + val astring = arrayOfNulls(p_301102_.size - l - k) for (k1 in astring.indices) { - astring[k1] = pToShrink[k1 + k]?.substring(i, j + 1) + astring[k1] = p_301102_[k1 + k].substring(i, j + 1) } astring } @@ -213,129 +209,51 @@ class CustomToolCraftingTableShapedRecipe( } return i } + } - fun patternFromJson(pPatternArray: JsonArray): Array { - val astring = arrayOfNulls(pPatternArray.size()) - if (astring.size > MAX_HEIGHT) { - throw JsonSyntaxException("Invalid pattern: too many rows, $MAX_HEIGHT is maximum") - } else if (astring.isEmpty()) { - throw JsonSyntaxException("Invalid pattern: empty pattern not allowed") - } else { - for (i in astring.indices) { - val s = GsonHelper.convertToString(pPatternArray.get(i), "pattern[$i]") - if (s.length > MAX_WIDTH) { - throw JsonSyntaxException( - "Invalid pattern: too many columns, $MAX_WIDTH is maximum") - } - if (i > 0 && astring[0]!!.length != s.length) { - throw JsonSyntaxException( - "Invalid pattern: each row must be the same width") + class Serializer : RecipeSerializer { + private val CODEC = + CustomToolCraftingTableRawShapedRecipe.CODEC.flatXmap({ + p_301248_: CustomToolCraftingTableRawShapedRecipe -> + val astring = shrink(p_301248_.pattern) + val i = astring[0]!!.length + val j = astring.size + val nonnulllist = NonNullList.withSize(i * j, Ingredient.EMPTY) + val set: MutableSet = Sets.newHashSet(p_301248_.key.keys) + for (k in astring.indices) { + val s = astring[k] + for (l in 0 until s!!.length) { + val s1 = s.substring(l, l + 1) + val ingredient = + (if (s1 == " ") Ingredient.EMPTY else p_301248_.key[s1]) + ?: return@flatXmap DataResult.error< + CustomToolCraftingTableShapedRecipe> { + "Pattern references symbol '$s1' but it's not defined in the key" + } + set.remove(s1) + nonnulllist[l + i * k] = ingredient } - astring[i] = s - } - return astring - } - } - - /** Returns a key json object as a Java HashMap. */ - fun keyFromJson(pKeyEntry: JsonObject): MutableMap { - val map: MutableMap = Maps.newHashMap() - for (entry: Map.Entry in pKeyEntry.entrySet()) { - if (entry.key.length != 1) { - throw JsonSyntaxException( - "Invalid key entry: '" + - entry.key + - "' is an invalid symbol (must be 1 character only).") - } - if ((" " == entry.key)) { - throw JsonSyntaxException("Invalid key entry: ' ' is a reserved symbol.") } - map[entry.key] = Ingredient.fromJson(entry.value) - } - map[" "] = Ingredient.EMPTY - return map - } - - fun itemStackFromJson(pStackObject: JsonObject): ItemStack { - return CraftingHelper.getItemStack(pStackObject, true, true) - } - - fun dissolvePattern( - pPattern: Array, - pKeys: Map, - pPatternWidth: Int, - pPatternHeight: Int, - ): NonNullList { - val nonnulllist = NonNullList.withSize(pPatternWidth * pPatternHeight, Ingredient.EMPTY) - val set: MutableSet = Sets.newHashSet(pKeys.keys) - set.remove(" ") - for (i in pPattern.indices) { - for (j in 0 until (pPattern[i]?.length ?: 0)) { - val s = pPattern[i]?.substring(j, j + 1) - val ingredient = - pKeys[s] - ?: throw JsonSyntaxException( - ("Pattern references symbol '" + - s + - "' but it's not defined in the key")) - set.remove(s) - nonnulllist[j + pPatternWidth * i] = ingredient + if (set.isNotEmpty()) { + return@flatXmap DataResult.error { + "Key defines symbols that aren't used in pattern: $set" + } + } else { + val shapedrecipe = + CustomToolCraftingTableShapedRecipe( + p_301248_.group, + p_301248_.category, + i, + j, + nonnulllist, + p_301248_.result, + p_301248_.showNotification) + return@flatXmap DataResult.success( + shapedrecipe) } + }) { _: CustomToolCraftingTableShapedRecipe -> + throw NotImplementedException("Serializing ShapedRecipe is not implemented yet.") } - if (set.isNotEmpty()) { - throw JsonSyntaxException("Key defines symbols that aren't used in pattern: $set") - } else { - return nonnulllist - } - } - } - - class Serializer : RecipeSerializer { - override fun fromJson( - pRecipeId: ResourceLocation, - pJson: JsonObject, - ): CustomToolCraftingTableShapedRecipe { - val s: String = GsonHelper.getAsString(pJson, "group", "")!! - - val map: Map = keyFromJson(GsonHelper.getAsJsonObject(pJson, "key")) - - val astring: Array = - shrink(*patternFromJson(GsonHelper.getAsJsonArray(pJson, "pattern"))) - - val i = astring[0]?.length - val j = astring.size - val nonnulllist: NonNullList = dissolvePattern(astring, map, i!!, j) - - val itemstack: ItemStack = - itemStackFromJson(GsonHelper.getAsJsonObject(pJson, "result")) - - val craftingbookcategory = - CustomToolsCraftingBookCategory.CODEC.byName( - GsonHelper.getAsString(pJson, "category", null as String?), - CustomToolsCraftingBookCategory.MISC) - - val flag = GsonHelper.getAsBoolean(pJson, "show_notification", true) - - return CustomToolCraftingTableShapedRecipe( - pRecipeId, s, craftingbookcategory, i, j, nonnulllist, itemstack, flag) - } - - override fun fromNetwork( - pRecipeId: ResourceLocation, - pBuffer: FriendlyByteBuf, - ): CustomToolCraftingTableShapedRecipe { - val i = pBuffer.readVarInt() - val j = pBuffer.readVarInt() - val s = pBuffer.readUtf() - val nonnulllist = NonNullList.withSize(i * j, Ingredient.EMPTY) - nonnulllist.replaceAll { Ingredient.fromNetwork(pBuffer) } - val itemstack = pBuffer.readItem() - val craftingbookcategory = pBuffer.readEnum(CustomToolsCraftingBookCategory::class.java) - val flag = pBuffer.readBoolean() - - return CustomToolCraftingTableShapedRecipe( - pRecipeId, s, craftingbookcategory, i, j, nonnulllist, itemstack, flag) - } override fun toNetwork( pBuffer: FriendlyByteBuf, @@ -352,5 +270,24 @@ class CustomToolCraftingTableShapedRecipe( pBuffer.writeItem(pRecipe.result) pBuffer.writeBoolean(pRecipe.showNotification) } + + override fun codec(): Codec { + return CODEC + } + + override fun fromNetwork(p_44106_: FriendlyByteBuf): CustomToolCraftingTableShapedRecipe? { + val i = p_44106_.readVarInt() + val j = p_44106_.readVarInt() + val s = p_44106_.readUtf() + val nonnulllist = NonNullList.withSize(i * j, Ingredient.EMPTY) + nonnulllist.replaceAll { Ingredient.fromNetwork(p_44106_) } + val itemstack = p_44106_.readItem() + val craftingbookcategory = + p_44106_.readEnum(CustomToolsCraftingBookCategory::class.java) + val flag = p_44106_.readBoolean() + + return CustomToolCraftingTableShapedRecipe( + s, craftingbookcategory, i, j, nonnulllist, itemstack, flag) + } } } diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/util/KeyBinding.kt b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/util/KeyBinding.kt index 4dd4d1d5..d2c40400 100644 --- a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/util/KeyBinding.kt +++ b/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/util/KeyBinding.kt @@ -20,7 +20,7 @@ package io.github.realyusufismail.armourandtoolsmod.util import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.KeyMapping -import net.minecraftforge.client.settings.KeyConflictContext +import net.neoforged.neoforge.client.settings.KeyConflictContext import org.lwjgl.glfw.GLFW object KeyBinding { diff --git a/neoforge/src/main/resources/META-INF/accesstransformer.cfg b/neoforge/src/main/resources/META-INF/accesstransformer.cfg index 2fe93e02..e24b600a 100644 --- a/neoforge/src/main/resources/META-INF/accesstransformer.cfg +++ b/neoforge/src/main/resources/META-INF/accesstransformer.cfg @@ -1,3 +1,3 @@ -protected net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer f_172547_ # blockEntityRenderDispatcher -protected net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer f_172548_ # entityModelSet +protected net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer blockEntityRenderDispatcher +protected net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer entityModelSet public net.minecraft.client.renderer.texture.atlas.sources.PalettedPermutations (Ljava/util/List;Lnet/minecraft/resources/ResourceLocation;Ljava/util/Map;)V # \ 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 index dd099775..83265a1b 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -14,16 +14,16 @@ This Minecraft mod adds new armours and tools, as well as new dimensions and bos # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. [[dependencies.armourandtoolsmod]] -modId = "forge" +modId = "neoforge" mandatory = true -versionRange = "[47.1,)" +versionRange = "[20.2, 20.3)" ordering = "NONE" side = "BOTH" [[dependencies.armourandtoolsmod]] modId = "minecraft" mandatory = true -versionRange = "[1.20.1, 1.21)" +versionRange = "[1.20.2, 1.21)" ordering = "NONE" side = "BOTH" diff --git a/neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_disabled.png b/neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..ce267cea3bb8eb6f75885a73fe208c95c5fcc72e GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^Qa~)g!VDyT{V$pgq_hHjLR^9L|NsAw9XrEakt5tl6B!gPq|)G>|( zhUYWclt20$_G*4;bNR!jEte7$&L6#Thk!0&@O1TaS?83{1OS^iV7LGP literal 0 HcmV?d00001 diff --git a/neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_disabled_highlighted.png b/neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_disabled_highlighted.png new file mode 100644 index 0000000000000000000000000000000000000000..b0b152179edc10a943c118d96c80413479603609 GIT binary patch literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^Qa~)g!VDyT{V$pgq;vy(LR^9L|NsBD*y?mlI=Oz^ zEf>!edwcu(`ue`UzLu7j#fukvdU^&125#TJJuNLw{#{fqP(y>Ki(^PdT(W=*(;=R7 z$2bzWp3hWO{&?on?MV-9Hurq{v@J!!|KyE`lNO7U+|rM;D4h4W>2Y&Lc4+1C9$tre z8-)U?XRVD|t3 literal 0 HcmV?d00001 diff --git a/neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_enabled.png b/neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_enabled.png new file mode 100644 index 0000000000000000000000000000000000000000..20c49931fa799304e0cb4825e32c824e351a8809 GIT binary patch literal 243 zcmeAS@N?(olHy`uVBq!ia0vp^Qa~)g!VDyT{V$pgq;vy(LR`0R-@fi>)#AmA8+N$& z_4T#1wA9zvr=_JSwuc1<1}eu#dwP1>+uQT0s{(aw*=k?_q#8Y4978H@B@4JP1@Q>U za$Mkk{&kMSqpvcbEg7GGl_~TF(hp6`Wjr|xOFNrC^jOPjF5TJkhWXPh>sh*1a!WNU z-?M$z>9MwwJL_|c_gSe#bV-TLi8))Ut7SW`-(h@WsFJJC{@G!{dq(HVyW9f&r`A?C nKH0QSTsA>&)9UN@T$vaoiqj&*-_2bEbPR*1tDnm{r-UW|iLY8{ literal 0 HcmV?d00001 diff --git a/neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_enabled_highlighted.png b/neoforge/src/main/resources/assets/armourandtoolsmod/textures/gui/sprites/recipe_book/ingot_fusion_toll_enhancer_filter_enabled_highlighted.png new file mode 100644 index 0000000000000000000000000000000000000000..8bb51faeb6a432ccd861b8155c9ea6c4304ce18d GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^Qa~)g!VDyT{V$pgq;vy(LR^9L|Ns9RcDQ#;I=Oz^ zEf>!edwcu(`ue`UzLu7j#fukvdU^&125#TJJuNNm!19n(poS(-7srr_xMTqrrb9gE zj&US#J)fzn{PE1C+mjyJZ0`B?X? sL%Resw$BPNX~_osH?J;R=)u6?GSOOQ@|yoqK-VyMy85}Sb4q9e0L7$eWdHyG literal 0 HcmV?d00001 diff --git a/neoforge/src/main/temp_remove/Info.md b/neoforge/src/main/temp_remove/Info.md new file mode 100644 index 00000000..50108da3 --- /dev/null +++ b/neoforge/src/main/temp_remove/Info.md @@ -0,0 +1 @@ +Files located here are temporary removed due to changes in version thus waiting for update. \ No newline at end of file diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/JEIRecipeTypes.kt b/neoforge/src/main/temp_remove/JEIRecipeTypes.kt similarity index 100% rename from neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/init/JEIRecipeTypes.kt rename to neoforge/src/main/temp_remove/JEIRecipeTypes.kt diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/integration/ArmourAndToolsModJEIPlugin.kt b/neoforge/src/main/temp_remove/integration/ArmourAndToolsModJEIPlugin.kt similarity index 100% rename from neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/integration/ArmourAndToolsModJEIPlugin.kt rename to neoforge/src/main/temp_remove/integration/ArmourAndToolsModJEIPlugin.kt diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/integration/armour/CustomArmourCraftingTableJEIRecipeCategory.kt b/neoforge/src/main/temp_remove/integration/armour/CustomArmourCraftingTableJEIRecipeCategory.kt similarity index 100% rename from neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/integration/armour/CustomArmourCraftingTableJEIRecipeCategory.kt rename to neoforge/src/main/temp_remove/integration/armour/CustomArmourCraftingTableJEIRecipeCategory.kt diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/integration/fusion/IngotFusionTollEnhancerJEIRecipeCategory.kt b/neoforge/src/main/temp_remove/integration/fusion/IngotFusionTollEnhancerJEIRecipeCategory.kt similarity index 100% rename from neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/integration/fusion/IngotFusionTollEnhancerJEIRecipeCategory.kt rename to neoforge/src/main/temp_remove/integration/fusion/IngotFusionTollEnhancerJEIRecipeCategory.kt diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/integration/generic/GenericCraftingTableJEIRecipeCategory.kt b/neoforge/src/main/temp_remove/integration/generic/GenericCraftingTableJEIRecipeCategory.kt similarity index 100% rename from neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/integration/generic/GenericCraftingTableJEIRecipeCategory.kt rename to neoforge/src/main/temp_remove/integration/generic/GenericCraftingTableJEIRecipeCategory.kt diff --git a/neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/integration/tool/CustomToolCraftingTableJEIRecipeCategory.kt b/neoforge/src/main/temp_remove/integration/tool/CustomToolCraftingTableJEIRecipeCategory.kt similarity index 100% rename from neoforge/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/integration/tool/CustomToolCraftingTableJEIRecipeCategory.kt rename to neoforge/src/main/temp_remove/integration/tool/CustomToolCraftingTableJEIRecipeCategory.kt