diff --git a/common/src/main/java/generations/gg/generations/core/generationscore/common/util/PokemonFunctions.kt b/common/src/main/java/generations/gg/generations/core/generationscore/common/util/PokemonFunctions.kt index 283d69dec..b34f4df70 100644 --- a/common/src/main/java/generations/gg/generations/core/generationscore/common/util/PokemonFunctions.kt +++ b/common/src/main/java/generations/gg/generations/core/generationscore/common/util/PokemonFunctions.kt @@ -17,9 +17,11 @@ import com.cobblemon.mod.common.util.asTranslated import com.cobblemon.mod.common.util.toNbtList import generations.gg.generations.core.generationscore.common.world.item.StatueSpawnerItem import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.ListTag import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag import net.minecraft.network.chat.Component +import net.minecraft.network.chat.MutableComponent import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack @@ -138,3 +140,14 @@ fun Pokemon.removeIfBelongs(player: Player): Boolean { return belongsTo(player) && storeCoordinates.get()?.remove() == true } +fun ItemStack.setLore(lore: List?): ItemStack { + val compoundtag = getOrCreateTagElement(ItemStack.TAG_DISPLAY) + if (lore != null) { + lore.map { if (it is MutableComponent) it else it.toString().text() }.map { Component.Serializer.toJson(it) }.map { StringTag.valueOf(it) } + .toCollection(ListTag()).let { compoundtag.put(ItemStack.TAG_LORE, it) } + } else { + compoundtag.remove(ItemStack.TAG_LORE) + } + return this +} + diff --git a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/DnaSplicer.kt b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/DnaSplicer.kt index a67700efa..815e59771 100644 --- a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/DnaSplicer.kt +++ b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/DnaSplicer.kt @@ -24,6 +24,11 @@ class DnaSplicer(properties: Properties): PokemonStoringItem(properties) { if (pokemonInStack == null && (pokemon.isSpecies("zekrom") || pokemon.isSpecies("reshiram"))) { if (pokemon.removeIfBelongs(player)) { stack.savePokemon(pokemon) + + var list = mutableListOf() + list.add(pokemon) + stack.setLore(list) + player.level().playSound(null, entity, SoundEvents.ENDERMAN_TELEPORT, SoundSource.MASTER, 1.0f, 1.0f) player.sendSystemMessage("generations_core.pokemon.encoded".asTranslated(pokemon.getDisplayName().string)) diff --git a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/PokemonStoringItem.kt b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/PokemonStoringItem.kt index bb7c35405..4011319d0 100644 --- a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/PokemonStoringItem.kt +++ b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/PokemonStoringItem.kt @@ -6,6 +6,7 @@ import com.cobblemon.mod.common.api.text.text import generations.gg.generations.core.generationscore.common.util.add import generations.gg.generations.core.generationscore.common.util.getPokemon import generations.gg.generations.core.generationscore.common.util.removePokemon +import generations.gg.generations.core.generationscore.common.util.setLore import generations.gg.generations.core.generationscore.common.world.item.GenerationsCobblemonInteractions.PokemonInteraction import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerPlayer @@ -31,8 +32,6 @@ abstract class PokemonStoringItem(properties: Properties) : Item(properties), Po tooltipComponents: MutableList, isAdvanced: TooltipFlag, ) { - stack.getPokemon()?.run { tooltipComponents.add(this) } - super.appendHoverText(stack, level, tooltipComponents, isAdvanced) } @@ -44,10 +43,12 @@ abstract class PokemonStoringItem(properties: Properties) : Item(properties), Po storage.getParty((player as ServerPlayer)).add(pokemon) item.shrink(1) item.removePokemon() + item.setLore(mutableListOf()) player.level().playSound(null, player, SoundEvents.ENDERMAN_TELEPORT, SoundSource.MASTER, 1.0f, 1.0f) return InteractionResultHolder.sidedSuccess(item, false) } } return super.use(level, player, usedHand) } + } diff --git a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/TimeCapsule.kt b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/TimeCapsule.kt index ad9856eb4..f7fab25b8 100644 --- a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/TimeCapsule.kt +++ b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/TimeCapsule.kt @@ -1,26 +1,35 @@ package generations.gg.generations.core.generationscore.common.world.item +import com.cobblemon.mod.common.Cobblemon.storage import com.cobblemon.mod.common.api.text.plus import com.cobblemon.mod.common.entity.pokemon.PokemonEntity import com.cobblemon.mod.common.pokemon.Species import dev.architectury.registry.item.ItemPropertiesRegistry import generations.gg.generations.core.generationscore.common.GenerationsCore -import generations.gg.generations.core.generationscore.common.util.getPokemon -import generations.gg.generations.core.generationscore.common.util.removeIfBelongs -import generations.gg.generations.core.generationscore.common.util.savePokemon +import generations.gg.generations.core.generationscore.common.util.* import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.network.chat.Component +import net.minecraft.network.chat.MutableComponent import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundEvents import net.minecraft.sounds.SoundSource +import net.minecraft.world.InteractionHand +import net.minecraft.world.InteractionResultHolder import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.Level class TimeCapsule(properties: Properties) : PokemonStoringItem(properties) { override fun processInteraction(player: ServerPlayer, entity: PokemonEntity, stack: ItemStack): Boolean { val pokemon = entity.pokemon return if (pokemon.removeIfBelongs(player)) { stack.savePokemon(pokemon) + + var list = mutableListOf() + list.add(pokemon) + stack.setLore(list) + player.level().playSound( null, entity,