Skip to content

Commit

Permalink
need to rewrite custom crafting table
Browse files Browse the repository at this point in the history
  • Loading branch information
RealYusufIsmail committed Feb 10, 2024
1 parent 0fcdfbc commit 9c075f0
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 46 deletions.
4 changes: 4 additions & 0 deletions neoforge/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

# [1.20.4-2.0.0.beta12] - 2024-2-10

### Reintroduced support for JEI for Neo Forge. It should now work as intended with no issues.

# [1.20.4-2.0.0.beta11] - 2024-1-11

### Ported to 1.20.4 and fixed final issue with Thor's hammer. It should now work as intended with no issues.
Expand Down
7 changes: 3 additions & 4 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ 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
// 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"])
compileOnly("mezz.jei:jei-${mcVersion}-common-api:" + properties["jeiVersion"])
compileOnly("mezz.jei:jei-${mcVersion}-forge-api:" + properties["jeiVersion"])
runtimeOnly("mezz.jei:jei-${mcVersion}-neoforge:" + properties["jeiVersion"])

// lombok
compileOnly("org.projectlombok:lombok:" + properties["lombokVersion"])
Expand Down
6 changes: 3 additions & 3 deletions neoforge/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kotlin.code.style=official
org.gradle.jvmargs=-Xmx4G
org.gradle.daemon=false

modVersion = 1.20.4-2.0.0.beta11
modVersion = 1.20.4-2.0.0.beta12
mcVersion = 1.20.4
projectId = 480779
modId = temporalsmith
Expand All @@ -12,9 +12,9 @@ modId = temporalsmith
# neogradle.subsystems.parchment.minecraftVersion=1.20.3
# neogradle.subsystems.parchment.mappingsVersion=2023.12.31

neoForgeVersion = 20.4.83-beta
neoForgeVersion = 20.4.157-beta
kotlinForForgeVersion = 4.10.0
logbackVersion = 1.4.14
junitVersion = 5.10.0
coreVersion = 1.20.4-1.2.0
jeiVersion = 16.0.0.28
jeiVersion = 17.3.0.48
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package io.github.realyusufismail.temporalsmith.core.init

import io.github.realyusufismail.temporalsmith.temporalsmith
import io.github.realyusufismail.temporalsmith.TemporalSmith.TemporalSmith.MOD_ID
import io.github.realyusufismail.temporalsmith.recipe.armour.CustomArmourCraftingTableRecipe
import io.github.realyusufismail.temporalsmith.recipe.infusion.IngotFusionTollEnhancerRecipe
import io.github.realyusufismail.temporalsmith.recipe.tool.CustomToolCraftingTableRecipe
Expand All @@ -27,19 +27,19 @@ import mezz.jei.api.recipe.RecipeType
object JEIRecipeTypes {
val toolCrafting: RecipeType<CustomToolCraftingTableRecipe> =
RecipeType.create(
temporalsmith.MOD_ID,
MOD_ID,
"custom_tool_crafting_table",
CustomToolCraftingTableRecipe::class.java)

val armourCrafting: RecipeType<CustomArmourCraftingTableRecipe> =
RecipeType.create(
temporalsmith.MOD_ID,
MOD_ID,
"custom_armour_crafting_table",
CustomArmourCraftingTableRecipe::class.java)

val ingotFusionTollEnhancer: RecipeType<IngotFusionTollEnhancerRecipe> =
RecipeType.create(
temporalsmith.MOD_ID,
MOD_ID,
"ingot_fusion_toll_enhancer",
IngotFusionTollEnhancerRecipe::class.java)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 RealYusufIsmail.
* Copyright 2024 RealYusufIsmail.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,7 +18,7 @@
*/
package io.github.realyusufismail.temporalsmith.integration

import io.github.realyusufismail.temporalsmith.temporalsmith
import io.github.realyusufismail.temporalsmith.TemporalSmith
import io.github.realyusufismail.temporalsmith.core.init.BlockInit
import io.github.realyusufismail.temporalsmith.core.init.JEIRecipeTypes
import io.github.realyusufismail.temporalsmith.core.init.RecipeTypeInit
Expand All @@ -37,9 +37,8 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.world.item.ItemStack

@JeiPlugin
class temporalsmithJEIPlugin : IModPlugin {
private val pluginId: ResourceLocation =
temporalsmith.getModIdAndName("armour_and_tools_mod_plugin")
class ModJEIPlugin : IModPlugin {
private val pluginId: ResourceLocation = TemporalSmith.getModIdAndName("temporalsmith_plugin")

override fun registerCategories(registration: IRecipeCategoryRegistration) {
registration.addRecipeCategories(
Expand All @@ -50,13 +49,31 @@ class temporalsmithJEIPlugin : IModPlugin {

override fun registerRecipes(registration: IRecipeRegistration) {
val recipeManager = Minecraft.getInstance().level!!.recipeManager

val recipesTool = recipeManager.getAllRecipesFor(RecipeTypeInit.TOOL_CRAFTING.get())
val recipesArmour = recipeManager.getAllRecipesFor(RecipeTypeInit.ARMOUR_CRAFTING.get())
val recipesIngotFusionTollEnhancer =
recipeManager.getAllRecipesFor(RecipeTypeInit.INGOT_FUSION_TOLL_ENHANCER.get())
registration.addRecipes(toolCraftingTableRecipeType, recipesTool)
registration.addRecipes(armourCraftingTableRecipeType, recipesArmour)
registration.addRecipes(ingotFusionTollEnhancerRecipeType, recipesIngotFusionTollEnhancer)

val recipeToolList = mutableListOf<CustomToolCraftingTableRecipe>()
val recipeArmourList = mutableListOf<CustomArmourCraftingTableRecipe>()
val recipeIngotFusionTollEnhancerList = mutableListOf<IngotFusionTollEnhancerRecipe>()

for (recipe in recipesTool) {
recipeToolList.add(recipe.value())
}

for (recipe in recipesArmour) {
recipeArmourList.add(recipe.value())
}

for (recipe in recipesIngotFusionTollEnhancer) {
recipeIngotFusionTollEnhancerList.add(recipe.value())
}

registration.addRecipes(toolCraftingTableRecipeType, recipeToolList)
registration.addRecipes(armourCraftingTableRecipeType, recipeArmourList)
registration.addRecipes(ingotFusionTollEnhancerRecipeType, recipeIngotFusionTollEnhancerList)
}

override fun registerRecipeCatalysts(registration: IRecipeCatalystRegistration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/
package io.github.realyusufismail.temporalsmith.integration.armour

import io.github.realyusufismail.temporalsmith.temporalsmith
import io.github.realyusufismail.temporalsmith.TemporalSmith.TemporalSmith.getModIdAndName
import io.github.realyusufismail.temporalsmith.blocks.CustomArmourCraftingTable
import io.github.realyusufismail.temporalsmith.core.init.BlockInit
import io.github.realyusufismail.temporalsmith.integration.temporalsmithJEIPlugin
import io.github.realyusufismail.temporalsmith.integration.ModJEIPlugin
import io.github.realyusufismail.temporalsmith.integration.generic.GenericCraftingTableJEIRecipeCategory
import io.github.realyusufismail.temporalsmith.recipe.armour.CustomArmourCraftingTableRecipe
import java.util.*
Expand All @@ -38,7 +38,7 @@ class CustomArmourCraftingTableJEIRecipeCategory(guiHelper: IGuiHelper) :
guiHelper, BlockInit.CUSTOM_ARMOUR_CRAFTING_TABLE.get()) {

override fun getRecipeType(): RecipeType<CustomArmourCraftingTableRecipe> {
return temporalsmithJEIPlugin.armourCraftingTableRecipeType
return ModJEIPlugin.armourCraftingTableRecipeType
}

override fun getTitle(): Component {
Expand Down Expand Up @@ -85,6 +85,6 @@ class CustomArmourCraftingTableJEIRecipeCategory(guiHelper: IGuiHelper) :
}

companion object {
val UID = temporalsmith.getModIdAndName("custom_armour_crafting_table")
val UID = getModIdAndName("custom_armour_crafting_table")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/
package io.github.realyusufismail.temporalsmith.integration.fusion

import io.github.realyusufismail.temporalsmith.temporalsmith
import io.github.realyusufismail.temporalsmith.TemporalSmith.TemporalSmith.getModIdAndName
import io.github.realyusufismail.temporalsmith.blocks.IngotFusionTollEnhancer
import io.github.realyusufismail.temporalsmith.blocks.infusion.IngotFusionTollEnhancerBlockEntity
import io.github.realyusufismail.temporalsmith.core.init.BlockInit
import io.github.realyusufismail.temporalsmith.integration.temporalsmithJEIPlugin
import io.github.realyusufismail.temporalsmith.integration.ModJEIPlugin
import io.github.realyusufismail.temporalsmith.recipe.infusion.IngotFusionTollEnhancerRecipe
import mezz.jei.api.constants.VanillaTypes
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder
Expand All @@ -38,7 +38,7 @@ import net.minecraft.world.item.ItemStack
class IngotFusionTollEnhancerJEIRecipeCategory(guiHelper: IGuiHelper) :
IRecipeCategory<IngotFusionTollEnhancerRecipe> {
private val fusionJEIGuiLocation =
temporalsmith.getModIdAndName(
getModIdAndName(
"textures/gui/container/ingot_fusion_toll_enhancer_jei.png")
private val bg: IDrawable
private val ic: IDrawable
Expand All @@ -60,7 +60,7 @@ class IngotFusionTollEnhancerJEIRecipeCategory(guiHelper: IGuiHelper) :
* @since 9.5.0
*/
override fun getRecipeType(): RecipeType<IngotFusionTollEnhancerRecipe> {
return temporalsmithJEIPlugin.ingotFusionTollEnhancerRecipeType
return ModJEIPlugin.ingotFusionTollEnhancerRecipeType
}

/**
Expand Down Expand Up @@ -120,6 +120,6 @@ class IngotFusionTollEnhancerJEIRecipeCategory(guiHelper: IGuiHelper) :
}

companion object {
val UID = temporalsmith.getModIdAndName("ingot_fusion_toll_enhancer_jei")
val UID = getModIdAndName("ingot_fusion_toll_enhancer_jei")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package io.github.realyusufismail.temporalsmith.integration.generic

import io.github.realyusufismail.temporalsmith.temporalsmith
import io.github.realyusufismail.temporalsmith.TemporalSmith.TemporalSmith.getModIdAndName
import mezz.jei.api.constants.VanillaTypes
import mezz.jei.api.gui.drawable.IDrawable
import mezz.jei.api.helpers.IGuiHelper
Expand All @@ -31,7 +31,7 @@ abstract class GenericCraftingTableJEIRecipeCategory<T>(guiHelper: IGuiHelper, v
protected val bg: IDrawable
protected val ic: IDrawable
private val craftingTableGuiLocation =
temporalsmith.getModIdAndName("textures/gui/container/custom_crafting_table_Jei.png")
getModIdAndName("textures/gui/container/custom_crafting_table_Jei.png")
private val w = 173
private val h = 69

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
*/
package io.github.realyusufismail.temporalsmith.integration.tool

import io.github.realyusufismail.temporalsmith.temporalsmith
import io.github.realyusufismail.temporalsmith.TemporalSmith
import io.github.realyusufismail.temporalsmith.TemporalSmith.TemporalSmith.logger
import io.github.realyusufismail.temporalsmith.blocks.CustomToolCraftingTable
import io.github.realyusufismail.temporalsmith.core.init.BlockInit
import io.github.realyusufismail.temporalsmith.integration.temporalsmithJEIPlugin
import io.github.realyusufismail.temporalsmith.integration.ModJEIPlugin
import io.github.realyusufismail.temporalsmith.integration.generic.GenericCraftingTableJEIRecipeCategory
import io.github.realyusufismail.temporalsmith.recipe.tool.CustomToolCraftingTableRecipe
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder
Expand All @@ -37,7 +38,7 @@ class CustomToolCraftingTableJEIRecipeCategory(private val guiHelper: IGuiHelper
guiHelper, BlockInit.CUSTOM_TOOL_CRAFTING_TABLE.get()) {

override fun getRecipeType(): RecipeType<CustomToolCraftingTableRecipe> {
return temporalsmithJEIPlugin.toolCraftingTableRecipeType
return ModJEIPlugin.toolCraftingTableRecipeType
}

override fun getTitle(): Component {
Expand Down Expand Up @@ -65,17 +66,17 @@ class CustomToolCraftingTableJEIRecipeCategory(private val guiHelper: IGuiHelper
val ingredients = recipe.ingredients

// Define variables for each slot and add ingredients if they are not empty
val slots =
arrayOf(
Pair(30, 16),
Pair(48, 16),
Pair(66, 16),
Pair(30, 34),
Pair(48, 34),
Pair(66, 34),
Pair(30, 52),
Pair(48, 52),
Pair(66, 52))
val slots = arrayOf(
Pair(30, 16), // Top-left slot (x=30, y=16)
Pair(48, 16), // Top-middle slot (x=48, y=16)
Pair(66, 16), // Top-right slot (x=66, y=16)
Pair(30, 34), // Middle-left slot (x=30, y=34)
Pair(48, 34), // Center slot (x=48, y=34)
Pair(66, 34), // Middle-right slot (x=66, y=34)
Pair(30, 52), // Bottom-left slot (x=30, y=52)
Pair(48, 52), // Bottom-middle slot (x=48, y=52)
Pair(66, 52) // Bottom-right slot (x=66, y=52)
)

for (i in 0 until minOf(ingredients.size, slots.size)) {
val (x, y) = slots[i]
Expand All @@ -89,6 +90,6 @@ class CustomToolCraftingTableJEIRecipeCategory(private val guiHelper: IGuiHelper
}

companion object {
val UID = temporalsmith.getModIdAndName("custom_tool_crafting_table")
val UID = TemporalSmith.getModIdAndName("custom_tool_crafting_table")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ interface CustomToolCraftingTableRecipe : Recipe<CustomToolCraftingTableContaine
override fun getIngredients(): NonNullList<Ingredient>

val result: ItemStack

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ import io.github.realyusufismail.temporalsmith.core.init.BlockInit
import io.github.realyusufismail.temporalsmith.core.init.RecipeSerializerInit
import io.github.realyusufismail.temporalsmith.recipe.common.CustomCraftingTableShapedRecipe
import io.github.realyusufismail.temporalsmith.recipe.pattern.CustomCraftingTableRecipePattern
import net.minecraft.core.NonNullList
import net.minecraft.network.FriendlyByteBuf
import net.minecraft.util.ExtraCodecs
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.crafting.Ingredient
import net.minecraft.world.item.crafting.RecipeSerializer

class CustomToolCraftingTableShapedRecipe(
Expand Down
1 change: 0 additions & 1 deletion neoforge/src/main/temp_remove/Info.md

This file was deleted.

0 comments on commit 9c075f0

Please sign in to comment.