Skip to content

Commit

Permalink
fix(cores): tooltip crash #14
Browse files Browse the repository at this point in the history
  • Loading branch information
SirEdvin committed Jul 21, 2023
1 parent b0ed1cb commit 5968251
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 30 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.1] - 2023-07-21

### Fixed

- Automata core tooltip crash #14

## [1.1.0] - 2023-07-20

### Added
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("site.siredvin.root") version "0.4.5"
id("site.siredvin.release") version "0.4.5"
id("site.siredvin.root") version "0.4.6"
id("site.siredvin.release") version "0.4.6"
}

subprojectShaking {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx4G
org.gradle.warning.mode = all
minecraftVersion = 1.20.1
# Mod Properties
modVersion = 1.1.0
modVersion = 1.1.1
mavenGroup = site.siredvin
modBaseName = turtlematic
archivesBaseName = turtlematic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
package site.siredvin.turtlematic.api

import net.minecraft.nbt.CompoundTag
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.ItemLike
import site.siredvin.peripheralium.util.Pair
import site.siredvin.turtlematic.common.recipe.SoulHarvestRecipe
import site.siredvin.turtlematic.common.recipe.SoulHarvestRecipeRegistry

interface ISoulFeedableItem {
interface ISoulFeedableItem : ItemLike {
fun consumeEntitySoul(stack: ItemStack, player: Player, entity: LivingEntity): Pair<ItemStack?, String?>
fun getActiveRecipe(stack: ItemStack): SoulHarvestRecipe?
fun getActiveRecipe(stack: ItemStack): SoulHarvestRecipe? {
val tag: CompoundTag? = stack.tag
if (tag != null && !tag.isEmpty) {
val consumedData = tag.getCompound(SoulHarvestRecipeRegistry.CONSUMER_ENTITY_COMPOUND)
if (!consumedData.isEmpty) {
val recipeName = consumedData.allKeys.firstOrNull() ?: return null
return SoulHarvestRecipeRegistry.searchRecipe(this.asItem(), recipeName)
}
}
return null
}
fun getEntityRepresentation(stack: ItemStack, recipe: SoulHarvestRecipe): List<RecipeEntityRepresentation>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package site.siredvin.turtlematic.common.items

import net.minecraft.nbt.CompoundTag
import net.minecraft.network.chat.Component
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
Expand Down Expand Up @@ -61,15 +60,6 @@ class AutomataCore : BaseAutomataCore(AutomataCoreTier.TIER1, { TurtlematicConfi
return Pair.onlyRight("This item cannot hold soul of this entity")
}

override fun getActiveRecipe(stack: ItemStack): SoulHarvestRecipe? {
val tag: CompoundTag? = stack.tag
if (tag != null && !tag.isEmpty) {
val consumedData = tag.getCompound(CONSUMER_ENTITY_COMPOUND)
return SoulHarvestRecipeRegistry.searchRecipe(this, consumedData.allKeys.first())
}
return null
}

override fun getEntityRepresentation(stack: ItemStack, recipe: SoulHarvestRecipe): List<RecipeEntityRepresentation> {
val consumedData = stack.tag!!.getCompound(CONSUMER_ENTITY_COMPOUND)
return recipe.ingredients.map {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package site.siredvin.turtlematic.common.items

import net.minecraft.nbt.CompoundTag
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
Expand All @@ -25,15 +24,6 @@ class ForgedAutomataCore : DescriptiveItem(Properties().stacksTo(1).fireResistan
return Pair.onlyRight("This item cannot hold soul of this entity")
}

override fun getActiveRecipe(stack: ItemStack): SoulHarvestRecipe? {
val tag: CompoundTag? = stack.tag
if (tag != null && !tag.isEmpty) {
val consumedData = tag.getCompound(SoulHarvestRecipeRegistry.CONSUMER_ENTITY_COMPOUND)
return SoulHarvestRecipeRegistry.searchRecipe(this, consumedData.allKeys.first())
}
return null
}

override fun getEntityRepresentation(stack: ItemStack, recipe: SoulHarvestRecipe): List<RecipeEntityRepresentation> {
val consumedData = stack.tag!!.getCompound(SoulHarvestRecipeRegistry.CONSUMER_ENTITY_COMPOUND)
return recipe.ingredients.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ object SoulHarvestRecipeRegistry {
if (!RECIPE_REGISTRY.containsKey(targetItem)) {
return null
}
val recipe = RECIPE_REGISTRY[targetItem]!!.stream().filter { it.isSuitable(name) }.findAny()
if (recipe.isEmpty) {
return null
}
return recipe.get()
return RECIPE_REGISTRY[targetItem]!!.find { it.isSuitable(name) }
}

fun injectAutomataCoreRecipes() {
Expand Down

0 comments on commit 5968251

Please sign in to comment.