Placeable Vitamins Experiment A

Need coder feedback regarding this
Makes Mochi and Feathers require clicking in the air or directly on a Pokemon, if it thinks it can place as a block it prevents usage
This commit is contained in:
dhi_holo
2026-08-04 19:25:13 +10:00
parent e40d2ee806
commit c2e87e4cfa
5 changed files with 17 additions and 10 deletions
@@ -650,17 +650,17 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val EXPERIENCE_CANDY_XL = candyItem("exp_candy_xl") { _, _ -> CandyItem.DEFAULT_XL_CANDY_YIELD }
@JvmField
val CALCIUM = create("calcium", VitaminItem(Stats.SPECIAL_ATTACK))
val CALCIUM = create("calcium", VitaminItem(Stats.SPECIAL_ATTACK, CobblemonBlocks.CALCIUM))
@JvmField
val CARBOS = create("carbos", VitaminItem(Stats.SPEED))
val CARBOS = create("carbos", VitaminItem(Stats.SPEED, CobblemonBlocks.CARBOS))
@JvmField
val HP_UP = create("hp_up", VitaminItem(Stats.HP))
val HP_UP = create("hp_up", VitaminItem(Stats.HP, CobblemonBlocks.HP_UP))
@JvmField
val IRON = create("iron", VitaminItem(Stats.DEFENCE))
val IRON = create("iron", VitaminItem(Stats.DEFENCE, CobblemonBlocks.IRON))
@JvmField
val PROTEIN = create("protein", VitaminItem(Stats.ATTACK))
val PROTEIN = create("protein", VitaminItem(Stats.ATTACK, CobblemonBlocks.PROTEIN))
@JvmField
val ZINC = create("zinc", VitaminItem(Stats.SPECIAL_DEFENCE))
val ZINC = create("zinc", VitaminItem(Stats.SPECIAL_DEFENCE, CobblemonBlocks.ZINC))
@JvmField
val HEALTH_MOCHI = create("health_mochi", MochiItem(Stats.HP))
@JvmField
@@ -20,14 +20,18 @@ import net.minecraft.sounds.SoundEvent
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemNameBlockItem
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.Blocks
abstract class EVIncreaseItem(
val stat: Stat,
val evIncreaseAmount: Int,
) : CobblemonItem(Properties()), PokemonSelectingItem {
block: Block? = Blocks.AIR
) : ItemNameBlockItem(block, Properties()), PokemonSelectingItem {
override val bagItem = null
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = pokemon.evs.getOrDefault(stat) < EVs.MAX_STAT_VALUE &&
super.canUseOnPokemon(stack, pokemon)
@@ -11,7 +11,8 @@ package com.cobblemon.mod.common.item.interactive
import com.cobblemon.mod.common.CobblemonSounds
import com.cobblemon.mod.common.api.pokemon.stats.Stat
import net.minecraft.sounds.SoundEvent
import net.minecraft.world.level.block.Blocks
class FeatherItem(stat: Stat) : EVIncreaseItem(stat, 1) {
class FeatherItem(stat: Stat) : EVIncreaseItem(stat, 1, Blocks.AIR) {
override val sound: SoundEvent = CobblemonSounds.MEDICINE_FEATHER_USE
}
@@ -15,8 +15,9 @@ import net.minecraft.server.level.ServerPlayer
import net.minecraft.sounds.SoundEvent
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.block.Blocks
class MochiItem(stat: Stats): EVIncreaseItem(stat, 4) {
class MochiItem(stat: Stats): EVIncreaseItem(stat, 4, Blocks.AIR) {
override val sound: SoundEvent = CobblemonSounds.MOCHI_USE
override fun applyToPokemon(player: ServerPlayer, stack: ItemStack, pokemon: Pokemon): InteractionResultHolder<ItemStack> {
@@ -11,7 +11,8 @@ package com.cobblemon.mod.common.item.interactive
import com.cobblemon.mod.common.CobblemonSounds
import com.cobblemon.mod.common.api.pokemon.stats.Stats
import net.minecraft.sounds.SoundEvent
import net.minecraft.world.level.block.Block
class VitaminItem(stat: Stats) : EVIncreaseItem(stat, 10) {
class VitaminItem(stat: Stats, block: Block) : EVIncreaseItem(stat, 10, block) {
override val sound: SoundEvent = CobblemonSounds.MEDICINE_PILLS_USE
}