secondary recipes for powered furnaces + microwaving pattern drives to erase them
This commit is contained in:
parent
c4a5653330
commit
55363f5f6a
@ -49,6 +49,7 @@ import ru.dbotthepony.mc.otm.datagen.recipes.addBlastingRecipes
|
||||
import ru.dbotthepony.mc.otm.datagen.recipes.addCraftingTableRecipes
|
||||
import ru.dbotthepony.mc.otm.datagen.recipes.addDecorativesRecipes
|
||||
import ru.dbotthepony.mc.otm.datagen.recipes.addMatterEntanglerRecipes
|
||||
import ru.dbotthepony.mc.otm.datagen.recipes.addMicrowaveRecipes
|
||||
import ru.dbotthepony.mc.otm.datagen.recipes.addPlatePressRecipes
|
||||
import ru.dbotthepony.mc.otm.datagen.recipes.addShapelessRecipes
|
||||
import ru.dbotthepony.mc.otm.datagen.recipes.addOreSmeltingRecipes
|
||||
@ -569,6 +570,7 @@ object DataGen {
|
||||
}
|
||||
|
||||
addPlatePressRecipes(recipeProvider)
|
||||
addMicrowaveRecipes(recipeProvider)
|
||||
|
||||
lootModifier.lambda {
|
||||
addLootModifiers(it)
|
||||
|
@ -1,40 +0,0 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import com.google.common.collect.Lists
|
||||
import net.minecraft.data.recipes.FinishedRecipe
|
||||
import net.minecraft.data.recipes.RecipeCategory
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.data.recipes.SimpleCookingRecipeBuilder
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import net.minecraft.world.level.ItemLike
|
||||
import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
|
||||
private fun RecipeOutput.addRecyclingRecipe(inputs: Collection<ItemLike>, result: Item, name: String) {
|
||||
val inputStacks = inputs.map(::ItemStack)
|
||||
|
||||
SimpleCookingRecipeBuilder.smelting(
|
||||
Ingredient.of(inputStacks.stream()),
|
||||
RecipeCategory.MISC, result, 0f, 200
|
||||
).also { r -> inputs.forEach { r.unlockedBy(it) } }.save(this, modLocation("smelting/${name}"))
|
||||
|
||||
SimpleCookingRecipeBuilder.blasting(
|
||||
Ingredient.of(inputStacks.stream()),
|
||||
RecipeCategory.MISC, result, 0f, 100
|
||||
).also { r -> inputs.forEach { r.unlockedBy(it) } }.save(this, modLocation("blasting/${name}"))
|
||||
}
|
||||
|
||||
fun addBlastingRecipes(consumer: RecipeOutput) {
|
||||
SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItems.MIRROR_COMPOUND), RecipeCategory.MISC, MItems.MIRROR, 0.1f, 100).unlockedBy(MItems.MIRROR_COMPOUND).save(consumer)
|
||||
|
||||
SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates"))
|
||||
SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 50).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates_blasting"))
|
||||
|
||||
consumer.addRecyclingRecipe(MItems.TRITANIUM_TOOLS, MItems.TRITANIUM_NUGGET, "tritanium_nugget_from_tools")
|
||||
consumer.addRecyclingRecipe(MItems.SIMPLE_TRITANIUM_ARMOR, MItems.TRITANIUM_NUGGET, "tritanium_nugger_from_armor")
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import net.minecraft.data.recipes.RecipeCategory
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.data.recipes.SimpleCookingRecipeBuilder
|
||||
import net.minecraft.util.valueproviders.ConstantFloat
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import net.minecraft.world.level.ItemLike
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
|
||||
private fun RecipeOutput.addRecyclingRecipe(inputs: Collection<ItemLike>, result: Item, name: String) {
|
||||
val inputStacks = inputs.map(::ItemStack)
|
||||
|
||||
SimpleCookingRecipeBuilder.smelting(
|
||||
Ingredient.of(inputStacks.stream()),
|
||||
RecipeCategory.MISC, result, 0f, 200
|
||||
).also { r -> inputs.forEach { r.unlockedBy(it) } }.save(this, modLocation("smelting/${name}"))
|
||||
|
||||
SimpleCookingRecipeBuilder.blasting(
|
||||
Ingredient.of(inputStacks.stream()),
|
||||
RecipeCategory.MISC, result, 0f, 100
|
||||
).also { r -> inputs.forEach { r.unlockedBy(it) } }.save(this, modLocation("blasting/${name}"))
|
||||
}
|
||||
|
||||
fun addBlastingRecipes(consumer: RecipeOutput) {
|
||||
SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItems.MIRROR_COMPOUND), RecipeCategory.MISC, MItems.MIRROR, 0.1f, 100).unlockedBy(
|
||||
MItems.MIRROR_COMPOUND).save(consumer)
|
||||
|
||||
SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(
|
||||
MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates"))
|
||||
SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 50).unlockedBy(
|
||||
MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates_blasting"))
|
||||
|
||||
consumer.addRecyclingRecipe(MItems.TRITANIUM_TOOLS, MItems.TRITANIUM_NUGGET, "tritanium_nugget_from_tools")
|
||||
consumer.addRecyclingRecipe(MItems.SIMPLE_TRITANIUM_ARMOR, MItems.TRITANIUM_NUGGET, "tritanium_nugger_from_armor")
|
||||
}
|
||||
|
||||
fun addOreSmeltingRecipes(consumer: RecipeOutput) {
|
||||
SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("smelting/tritanium_ingot_from_ore_block"))
|
||||
SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("blasting/tritanium_ingot_from_ore_block"))
|
||||
|
||||
SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, modLocation("smelting/tritanium_ingot_from_raw_ore"))
|
||||
SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, modLocation("blasting/tritanium_ingot_from_raw_ore"))
|
||||
|
||||
SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 200).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, modLocation("smelting/tritanium_ingot_from_dust"))
|
||||
SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, modLocation("blasting/tritanium_ingot_from_dust"))
|
||||
}
|
||||
|
||||
fun addMicrowaveRecipes(provider: MatteryRecipeProvider) {
|
||||
provider.microwave("pattern_drive_normal_erase", Ingredient.of(MItems.PATTERN_DRIVE_NORMAL), Ingredient.of(MItems.PATTERN_DRIVE_NORMAL), workTicks = 30 * 20, experience = ConstantFloat.of(0f))
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import net.minecraft.world.item.crafting.Ingredient
|
||||
import net.minecraft.world.level.ItemLike
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||
import ru.dbotthepony.mc.otm.recipe.MicrowaveRecipe
|
||||
import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
@ -117,4 +118,10 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat
|
||||
callback.accept(PlatePressRecipe(ingredient, result, count, workTicks, experience = experience).toFinished(modLocation("plate_$id")))
|
||||
}
|
||||
}
|
||||
|
||||
fun microwave(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) {
|
||||
exec { it, callback ->
|
||||
callback.accept(MicrowaveRecipe(ingredient, result, count, workTicks, experience = experience).toFinished(modLocation("microwave/$id")))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import net.minecraft.data.recipes.FinishedRecipe
|
||||
import net.minecraft.data.recipes.RecipeCategory
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.data.recipes.SimpleCookingRecipeBuilder
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import java.util.function.Consumer
|
||||
|
||||
fun addOreSmeltingRecipes(consumer: RecipeOutput) {
|
||||
SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("smelting/tritanium_ingot_from_ore_block"))
|
||||
SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("blasting/tritanium_ingot_from_ore_block"))
|
||||
|
||||
SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, modLocation("smelting/tritanium_ingot_from_raw_ore"))
|
||||
SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, modLocation("blasting/tritanium_ingot_from_raw_ore"))
|
||||
|
||||
SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 200).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, modLocation("smelting/tritanium_ingot_from_dust"))
|
||||
SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, modLocation("blasting/tritanium_ingot_from_dust"))
|
||||
}
|
@ -20,14 +20,18 @@ import ru.dbotthepony.mc.otm.capability.CombinedItemHandler
|
||||
import ru.dbotthepony.mc.otm.capability.UpgradeType
|
||||
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
|
||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||
import ru.dbotthepony.mc.otm.config.MachinesConfig
|
||||
import ru.dbotthepony.mc.otm.config.WorkerBalanceValues
|
||||
import ru.dbotthepony.mc.otm.container.CombinedContainer
|
||||
import ru.dbotthepony.mc.otm.container.HandlerFilter
|
||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||
import ru.dbotthepony.mc.otm.container.UpgradeContainer
|
||||
import ru.dbotthepony.mc.otm.container.balance
|
||||
import ru.dbotthepony.mc.otm.core.collect.filter
|
||||
import ru.dbotthepony.mc.otm.core.collect.maybe
|
||||
import ru.dbotthepony.mc.otm.core.immutableList
|
||||
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
|
||||
import ru.dbotthepony.mc.otm.recipe.MatteryCookingRecipe
|
||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
|
||||
class PoweredFurnaceBlockEntity(
|
||||
@ -35,6 +39,7 @@ class PoweredFurnaceBlockEntity(
|
||||
blockPos: BlockPos,
|
||||
blockState: BlockState,
|
||||
val recipeType: RecipeType<out AbstractCookingRecipe>,
|
||||
val secondaryRecipeType: (() -> RecipeType<out MatteryCookingRecipe>)?,
|
||||
val config: WorkerBalanceValues
|
||||
) : MatteryWorkerBlockEntity<ItemJob>(type, blockPos, blockState, ItemJob.CODEC, 2) {
|
||||
override val upgrades = UpgradeContainer(this::markDirtyFast, 2, UpgradeType.BASIC_PROCESSING)
|
||||
@ -135,6 +140,29 @@ class PoweredFurnaceBlockEntity(
|
||||
|
||||
val level = level as? ServerLevel ?: return JobContainer.failure()
|
||||
|
||||
if (secondaryRecipeType != null) {
|
||||
val recipe = level.recipeManager
|
||||
.byType(secondaryRecipeType.invoke() as RecipeType<MatteryCookingRecipe>)
|
||||
.values
|
||||
.iterator()
|
||||
.filter { it.value.matches(inputs[id], 0) }
|
||||
.maybe()?.value
|
||||
|
||||
if (recipe != null) {
|
||||
val toProcess = inputs[id][0].count.coerceAtMost(1 + upgrades.processingItems)
|
||||
|
||||
inputs[id][0].shrink(toProcess)
|
||||
inputs[id].setChanged(id)
|
||||
|
||||
return JobContainer.success(
|
||||
ItemJob(
|
||||
recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess),
|
||||
recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier,
|
||||
MachinesConfig.PLATE_PRESS.energyConsumption * toProcess,
|
||||
experience = recipe.experience.sample(level.random) * toProcess))
|
||||
}
|
||||
}
|
||||
|
||||
return level.recipeManager.getRecipeFor(recipeType as RecipeType<AbstractCookingRecipe>, inputs[id], level).map {
|
||||
val output = it.value.assemble(inputs[id], level.registryAccess())
|
||||
val toProcess = inputs[id][0].count.coerceAtMost(upgrades.processingItems + 1)
|
||||
|
@ -22,16 +22,18 @@ import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.getShapeForEachState
|
||||
import ru.dbotthepony.mc.otm.config.WorkerBalanceValues
|
||||
import ru.dbotthepony.mc.otm.core.get
|
||||
import ru.dbotthepony.mc.otm.recipe.MatteryCookingRecipe
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShape
|
||||
|
||||
class PoweredFurnaceBlock(
|
||||
val type: () -> BlockEntityType<PoweredFurnaceBlockEntity>,
|
||||
val recipeType: RecipeType<out AbstractCookingRecipe>,
|
||||
val secondaryRecipeType: (() -> RecipeType<out MatteryCookingRecipe>)?,
|
||||
val config: WorkerBalanceValues,
|
||||
shape: BlockShape?
|
||||
) : RotatableMatteryBlock(), EntityBlock {
|
||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): PoweredFurnaceBlockEntity {
|
||||
return PoweredFurnaceBlockEntity(type.invoke(), p_153215_, p_153216_, recipeType, config)
|
||||
return PoweredFurnaceBlockEntity(type.invoke(), p_153215_, p_153216_, recipeType, secondaryRecipeType, config)
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
|
@ -10,8 +10,8 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
|
||||
import ru.dbotthepony.mc.otm.compat.jei.MicrowaveRecipeCategory
|
||||
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
|
||||
import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu
|
||||
import ru.dbotthepony.mc.otm.registry.MMenus
|
||||
|
||||
class PoweredFurnaceScreen(menu: PoweredFurnaceMenu, inventory: Inventory, title: Component) :
|
||||
@ -44,8 +44,8 @@ class PoweredFurnaceScreen(menu: PoweredFurnaceMenu, inventory: Inventory, title
|
||||
}
|
||||
|
||||
MMenus.POWERED_SMOKER -> {
|
||||
a.setRecipeType { listOf(RecipeTypes.SMOKING) }
|
||||
b.setRecipeType { listOf(RecipeTypes.SMOKING) }
|
||||
a.setRecipeType { listOf(MicrowaveRecipeCategory.recipeType, RecipeTypes.SMOKING) }
|
||||
b.setRecipeType { listOf(MicrowaveRecipeCategory.recipeType, RecipeTypes.SMOKING) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu
|
||||
import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu
|
||||
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
|
||||
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
|
||||
import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.registry.MRecipes
|
||||
@ -62,6 +63,7 @@ class JEIPlugin : IModPlugin {
|
||||
registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.SMELTING_UPGRADE), RecipeTypes.SMELTING)
|
||||
registration.addRecipeCatalyst(ItemStack(MItems.POWERED_BLAST_FURNACE), RecipeTypes.BLASTING)
|
||||
registration.addRecipeCatalyst(ItemStack(MItems.POWERED_SMOKER), RecipeTypes.SMOKING)
|
||||
registration.addRecipeCatalyst(ItemStack(MItems.POWERED_SMOKER), MicrowaveRecipeCategory.recipeType)
|
||||
registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.CRAFTING_UPGRADE), RecipeTypes.CRAFTING)
|
||||
registration.addRecipeCatalyst(ItemStack(MItems.ITEM_MONITOR), RecipeTypes.CRAFTING)
|
||||
registration.addRecipeCatalyst(ItemStack(MItems.PLATE_PRESS), PlatePressRecipeCategory.recipeType)
|
||||
@ -82,6 +84,7 @@ class JEIPlugin : IModPlugin {
|
||||
registration.addRecipeCategories(PlatePressRecipeCategory)
|
||||
registration.addRecipeCategories(PainterRecipeCategory)
|
||||
registration.addRecipeCategories(MatterEntanglerRecipeCategory)
|
||||
registration.addRecipeCategories(MicrowaveRecipeCategory)
|
||||
}
|
||||
|
||||
override fun registerRecipes(registration: IRecipeRegistration) {
|
||||
@ -90,6 +93,7 @@ class JEIPlugin : IModPlugin {
|
||||
registration.addRecipes(PlatePressRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PLATE_PRESS).filter { !it.value.isIncomplete }.map { it.value })
|
||||
registration.addRecipes(PainterRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PAINTER).filter { !it.value.isIncomplete }.map { it.value })
|
||||
registration.addRecipes(MatterEntanglerRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.MATTER_ENTANGLER).filter { !it.value.isIncomplete }.map { it.value })
|
||||
registration.addRecipes(MicrowaveRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.MICROWAVE).filter { !it.value.isIncomplete }.map { it.value })
|
||||
}
|
||||
|
||||
override fun registerRecipeTransferHandlers(registration: IRecipeTransferRegistration) {
|
||||
@ -100,6 +104,7 @@ class JEIPlugin : IModPlugin {
|
||||
registration.addRecipeTransferHandler(simpleTransferInfo0(PainterRecipeCategory.recipeType, PainterMenu::inputSlot))
|
||||
registration.addRecipeTransferHandler(simpleTransferInfo0(PlatePressRecipeCategory.recipeType, PlatePressMenu::inputSlot))
|
||||
registration.addRecipeTransferHandler(simpleTransferInfo(PlatePressRecipeCategory.recipeType, TwinPlatePressMenu::inputSlots))
|
||||
registration.addRecipeTransferHandler(simpleTransferInfo(MicrowaveRecipeCategory.recipeType, PoweredFurnaceMenu::inputSlots))
|
||||
}
|
||||
|
||||
override fun registerGuiHandlers(registration: IGuiHandlerRegistration) {
|
||||
|
@ -0,0 +1,115 @@
|
||||
package ru.dbotthepony.mc.otm.compat.jei
|
||||
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder
|
||||
import mezz.jei.api.gui.drawable.IDrawable
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView
|
||||
import mezz.jei.api.recipe.IFocusGroup
|
||||
import mezz.jei.api.recipe.RecipeIngredientRole
|
||||
import mezz.jei.api.recipe.RecipeType
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
||||
import ru.dbotthepony.mc.otm.client.render.draw
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
import ru.dbotthepony.mc.otm.core.math.RGBAColor
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
import ru.dbotthepony.mc.otm.recipe.MicrowaveRecipe
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
object MicrowaveRecipeCategory : IRecipeCategory<MicrowaveRecipe>, IDrawable {
|
||||
const val X_INPUT = 6f
|
||||
const val Y_INPUT = 11f
|
||||
|
||||
const val X_OUTPUT = 56f
|
||||
const val Y_OUTPUT = 11f
|
||||
|
||||
const val X_ARROW = 29f
|
||||
const val Y_ARROW = 12f
|
||||
|
||||
private val type = RecipeType(ResourceLocation(OverdriveThatMatters.MOD_ID, "microwave"), MicrowaveRecipe::class.java)
|
||||
|
||||
override fun getRecipeType(): RecipeType<MicrowaveRecipe> {
|
||||
return type
|
||||
}
|
||||
|
||||
override fun getTitle(): Component {
|
||||
return MItems.POWERED_SMOKER.description
|
||||
}
|
||||
|
||||
override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) {
|
||||
@Suppress("name_shadowing")
|
||||
val xOffset = xOffset.toFloat()
|
||||
|
||||
@Suppress("name_shadowing")
|
||||
val yOffset = yOffset.toFloat()
|
||||
|
||||
AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_INPUT + xOffset, Y_INPUT + yOffset)
|
||||
AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_OUTPUT + xOffset, Y_OUTPUT + yOffset)
|
||||
ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics, X_ARROW + xOffset, Y_ARROW + yOffset)
|
||||
|
||||
ProgressGaugePanel.GAUGE_FOREGROUND.renderPartial(
|
||||
graphics,
|
||||
X_ARROW + xOffset,
|
||||
Y_ARROW + yOffset,
|
||||
width = (((System.currentTimeMillis() % 4000L) / 4000f) * ProgressGaugePanel.GAUGE_FOREGROUND.width).roundToInt().toFloat())
|
||||
}
|
||||
|
||||
override fun draw(
|
||||
recipe: MicrowaveRecipe,
|
||||
recipeSlotsView: IRecipeSlotsView,
|
||||
graphics: GuiGraphics,
|
||||
mouseX: Double,
|
||||
mouseY: Double
|
||||
) {
|
||||
graphics.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK)
|
||||
|
||||
val average = recipe.experience.toString()
|
||||
|
||||
if (average != "0.0") {
|
||||
graphics.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getWidth(): Int {
|
||||
return 80
|
||||
}
|
||||
|
||||
override fun getHeight(): Int {
|
||||
return 40
|
||||
}
|
||||
|
||||
override fun getBackground(): IDrawable {
|
||||
return this
|
||||
}
|
||||
|
||||
private val iconField by lazy {
|
||||
JEIPlugin.helpers.guiHelper.createDrawableItemStack(ItemStack(MItems.POWERED_SMOKER))
|
||||
}
|
||||
|
||||
override fun getIcon(): IDrawable {
|
||||
return iconField
|
||||
}
|
||||
|
||||
override fun setRecipe(builder: IRecipeLayoutBuilder, recipe: MicrowaveRecipe, focuses: IFocusGroup) {
|
||||
builder.addSlot(RecipeIngredientRole.INPUT, X_INPUT.toInt() + 1, Y_INPUT.toInt() + 1)
|
||||
.addIngredients(recipe.input)
|
||||
|
||||
val first = recipe.output.items.firstOrNull { it.item.registryName?.namespace == OverdriveThatMatters.MOD_ID }
|
||||
|
||||
if (first == null)
|
||||
builder.addSlot(RecipeIngredientRole.OUTPUT, X_OUTPUT.toInt() + 1, Y_OUTPUT.toInt() + 1)
|
||||
.addIngredients(recipe.output)
|
||||
else
|
||||
builder.addSlot(RecipeIngredientRole.OUTPUT, X_OUTPUT.toInt() + 1, Y_OUTPUT.toInt() + 1)
|
||||
.addIngredients(Ingredient.of(first))
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package ru.dbotthepony.mc.otm.recipe
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.core.NonNullList
|
||||
import net.minecraft.core.RegistryAccess
|
||||
import net.minecraft.data.recipes.FinishedRecipe
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.util.valueproviders.ConstantFloat
|
||||
import net.minecraft.util.valueproviders.FloatProvider
|
||||
import net.minecraft.world.Container
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraft.world.item.crafting.*
|
||||
import net.minecraft.world.level.Level
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.container.get
|
||||
import ru.dbotthepony.mc.otm.core.isActuallyEmpty
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer
|
||||
import ru.dbotthepony.mc.otm.data.minRange
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.registry.MRecipes
|
||||
|
||||
abstract class MatteryCookingRecipe(
|
||||
val input: Ingredient,
|
||||
val output: Ingredient,
|
||||
val count: Int = 1,
|
||||
val workTime: Int = 200,
|
||||
val experience: FloatProvider = ConstantFloat.ZERO
|
||||
) : Recipe<Container> {
|
||||
override fun matches(container: Container, level: Level): Boolean {
|
||||
if (isIncomplete)
|
||||
return false
|
||||
|
||||
return input.test(container[0])
|
||||
}
|
||||
|
||||
fun matches(container: Container, slot: Int): Boolean {
|
||||
if (isIncomplete)
|
||||
return false
|
||||
|
||||
return input.test(container[slot])
|
||||
}
|
||||
|
||||
private val outputStack: ItemStack by lazy {
|
||||
if (isIncomplete) {
|
||||
ItemStack.EMPTY
|
||||
} else {
|
||||
val items = output.items
|
||||
val bestMatch = items.firstOrNull { it.item.registryName?.namespace == OverdriveThatMatters.MOD_ID } ?: items[0]
|
||||
bestMatch.copy().also { it.count = this.count }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getIngredients(): NonNullList<Ingredient> {
|
||||
if (isIncomplete)
|
||||
return super.getIngredients()
|
||||
|
||||
return NonNullList.of(Ingredient.EMPTY, input)
|
||||
}
|
||||
|
||||
override fun isIncomplete(): Boolean = input.isActuallyEmpty || output.isActuallyEmpty
|
||||
|
||||
override fun assemble(container: Container, registry: RegistryAccess): ItemStack = outputStack.copy()
|
||||
|
||||
override fun canCraftInDimensions(width: Int, height: Int): Boolean = true
|
||||
|
||||
override fun getResultItem(registry: RegistryAccess): ItemStack = outputStack
|
||||
|
||||
abstract fun toFinished(id: ResourceLocation): FinishedRecipe
|
||||
}
|
||||
|
||||
class MicrowaveRecipe(
|
||||
input: Ingredient,
|
||||
output: Ingredient,
|
||||
count: Int = 1,
|
||||
workTime: Int = 200,
|
||||
experience: FloatProvider = ConstantFloat.ZERO
|
||||
) : MatteryCookingRecipe(input, output, count, workTime, experience) {
|
||||
override fun getType(): RecipeType<*> = MRecipes.MICROWAVE
|
||||
override fun getToastSymbol(): ItemStack = ItemStack(MItems.POWERED_SMOKER)
|
||||
override fun getSerializer(): RecipeSerializer<*> = SERIALIZER
|
||||
override fun toFinished(id: ResourceLocation): FinishedRecipe = SERIALIZER.toFinished(this, id)
|
||||
|
||||
companion object {
|
||||
val SERIALIZER = Codec2RecipeSerializer<MicrowaveRecipe> { context ->
|
||||
RecordCodecBuilder.create {
|
||||
it.group(
|
||||
context.ingredients.fieldOf("input").forGetter(MicrowaveRecipe::input),
|
||||
context.ingredients.fieldOf("output").forGetter(MicrowaveRecipe::output),
|
||||
Codec.INT.minRange(1).optionalFieldOf("count", 1).forGetter(MicrowaveRecipe::count),
|
||||
Codec.INT.minRange(0).optionalFieldOf("workTime", 200).forGetter(MicrowaveRecipe::workTime),
|
||||
FloatProvider.CODEC.optionalFieldOf("experience", ConstantFloat.ZERO).forGetter(MicrowaveRecipe::experience)
|
||||
).apply(it, ::MicrowaveRecipe)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -93,9 +93,9 @@ object MBlocks {
|
||||
val CHEMICAL_GENERATOR: Block by registry.register(MNames.CHEMICAL_GENERATOR) { ChemicalGeneratorBlock() }
|
||||
val PLATE_PRESS: Block by registry.register(MNames.PLATE_PRESS) { PlatePressBlock() }
|
||||
val TWIN_PLATE_PRESS: Block by registry.register(MNames.TWIN_PLATE_PRESS) { PlatePressBlock(isTwin = true) }
|
||||
val POWERED_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_FURNACE, RecipeType.SMELTING, MachinesConfig.POWERED_FURNACE, BlockShapes.POWERED_FURNACE) }
|
||||
val POWERED_BLAST_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_BLAST_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_BLAST_FURNACE, RecipeType.BLASTING, MachinesConfig.POWERED_BLAST_FURNACE, BlockShapes.POWERED_BLAST_FURNACE) }
|
||||
val POWERED_SMOKER: PoweredFurnaceBlock by registry.register(MNames.POWERED_SMOKER) { PoweredFurnaceBlock(MBlockEntities::POWERED_SMOKER, RecipeType.SMOKING, MachinesConfig.POWERED_SMOKER, null) }
|
||||
val POWERED_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_FURNACE, RecipeType.SMELTING, null, MachinesConfig.POWERED_FURNACE, BlockShapes.POWERED_FURNACE) }
|
||||
val POWERED_BLAST_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_BLAST_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_BLAST_FURNACE, RecipeType.BLASTING, null, MachinesConfig.POWERED_BLAST_FURNACE, BlockShapes.POWERED_BLAST_FURNACE) }
|
||||
val POWERED_SMOKER: PoweredFurnaceBlock by registry.register(MNames.POWERED_SMOKER) { PoweredFurnaceBlock(MBlockEntities::POWERED_SMOKER, RecipeType.SMOKING, MRecipes::MICROWAVE, MachinesConfig.POWERED_SMOKER, null) }
|
||||
val MATTER_RECYCLER: Block by registry.register(MNames.MATTER_RECYCLER) { MatterRecyclerBlock() }
|
||||
val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() }
|
||||
val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() }
|
||||
|
@ -8,13 +8,7 @@ import net.minecraftforge.registries.DeferredRegister
|
||||
import net.minecraftforge.registries.ForgeRegistries
|
||||
import net.minecraftforge.registries.RegistryObject
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.recipe.EnergyContainerRecipe
|
||||
import ru.dbotthepony.mc.otm.recipe.ExplosiveHammerPrimingRecipe
|
||||
import ru.dbotthepony.mc.otm.recipe.IMatterEntanglerRecipe
|
||||
import ru.dbotthepony.mc.otm.recipe.MatterEntanglerRecipe
|
||||
import ru.dbotthepony.mc.otm.recipe.PainterRecipe
|
||||
import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe
|
||||
import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe
|
||||
import ru.dbotthepony.mc.otm.recipe.*
|
||||
|
||||
@Suppress("SameParameterValue")
|
||||
object MRecipes {
|
||||
@ -41,6 +35,7 @@ object MRecipes {
|
||||
val PLATE_PRESS by register<PlatePressRecipe>("plate_press")
|
||||
val PAINTER by register<PainterRecipe>("painter")
|
||||
val MATTER_ENTANGLER by register<IMatterEntanglerRecipe>("matter_entangler")
|
||||
val MICROWAVE by register<MicrowaveRecipe>("microwave")
|
||||
|
||||
init {
|
||||
serializers.register("plate_press") { PlatePressRecipe.SERIALIZER }
|
||||
@ -51,5 +46,6 @@ object MRecipes {
|
||||
serializers.register("matter_entangler") { MatterEntanglerRecipe.SERIALIZER }
|
||||
serializers.register("matter_entangler_energetic") { MatterEntanglerRecipe.ENERGY_SERIALIZER }
|
||||
serializers.register("matter_entangler_matter") { MatterEntanglerRecipe.MATTER_SERIALIZER }
|
||||
serializers.register("microwave") { MicrowaveRecipe.SERIALIZER }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user