mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-10-21 06:36:25 -04:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e7f70dc13 | ||
|
|
5612f09713 | ||
|
|
c197aeb9d8 | ||
|
|
2ce1b465d4 | ||
|
|
1e35b7c1ae | ||
|
|
d4f2070d1f | ||
|
|
dcc162fd98 | ||
|
|
2287c7718e |
@@ -2,6 +2,14 @@
|
||||
## [1.8.0 (MONTH Xth, 2026)](#1-8-0)
|
||||
|
||||
### Additions
|
||||
- Added riding statistics: `Distance by Pokémon on Land`, `Distance by Pokémon in Air` and `Distance by Pokémon in Liquid`.
|
||||
- Added the Partner Mark, which party Pokémon have a very small chance to earn as the player walks, provided they have enough friendship.
|
||||
- Added trades for Saccharine Saplings, Hearty Grains, Chipped Pot, and Masterpiece Teacup to the Wandering Trader.
|
||||
- Added brewing recipe for Throat Spray.
|
||||
- Added mood particles! Pokémon now visually react to certain actions:
|
||||
- Angry particles when attacking a mob.
|
||||
- Annoyed particles when a player tries to feed them while they’re already full.
|
||||
- Sweat droplets when they run out of stamina while being ridden.
|
||||
- Added config options to award experience to fainted Pokémon for opponents they helped defeat (`awardExperienceToFaintedPokemon`) and to still award experience for defeated enemies even after battle loss/forfeit (`awardExperienceOnBattleLoss`)
|
||||
- Party Overlay Exp Gained Animation will now display the amount of EXP the Pokémon gained
|
||||
- Added a toast to notify players of how they can scroll through their party. Did you know you can hold R and scroll instead of using arrow keys??!
|
||||
|
||||
+7
-3
@@ -92,13 +92,17 @@ interface PokemonAndMoveSelectingItem {
|
||||
}
|
||||
|
||||
fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon): Boolean {
|
||||
if (stack.`is`(CobblemonItemTags.POKE_FOOD)) {
|
||||
return !pokemon.isFull()
|
||||
if (pokemon.entity == null && stack.`is`(CobblemonItemTags.POKE_FOOD) && pokemon.isFull()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
fun canUseOnBattlePokemon(stack: ItemStack, battlePokemon: BattlePokemon): Boolean = bagItem!!.canUse(stack, battlePokemon.actor.battle, battlePokemon)
|
||||
fun canUseOnBattlePokemon(stack: ItemStack, battlePokemon: BattlePokemon): Boolean {
|
||||
return bagItem!!.canUse(stack, battlePokemon.actor.battle, battlePokemon)
|
||||
}
|
||||
|
||||
fun canUseOnMove(stack: ItemStack, pokemon: Pokemon, move: Move): Boolean = canUseOnMove(stack, move)
|
||||
fun canUseOnMove(stack: ItemStack, move: Move): Boolean
|
||||
|
||||
|
||||
@@ -107,13 +107,16 @@ interface PokemonSelectingItem {
|
||||
}
|
||||
|
||||
fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon): Boolean {
|
||||
if (stack.`is`(CobblemonItemTags.POKE_FOOD)) {
|
||||
return !pokemon.isFull()
|
||||
if (pokemon.entity == null && stack.`is`(CobblemonItemTags.POKE_FOOD) && pokemon.isFull()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
fun canUseOnBattlePokemon(stack: ItemStack, battlePokemon: BattlePokemon): Boolean = bagItem!!.canUse(stack, battlePokemon.actor.battle, battlePokemon)
|
||||
fun canUseOnBattlePokemon(stack: ItemStack, battlePokemon: BattlePokemon): Boolean {
|
||||
return bagItem!!.canUse(stack, battlePokemon.actor.battle, battlePokemon)
|
||||
}
|
||||
|
||||
fun interactWithSpecificBattle(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon): InteractionResultHolder<ItemStack> {
|
||||
return if (canUseOnBattlePokemon(stack, battlePokemon)) {
|
||||
|
||||
+3
-2
@@ -54,8 +54,9 @@ object PokemonMoLangFunctions : AbstractMoLangFunctionHolder<Pokemon>() {
|
||||
}
|
||||
map["feed_pokemon"] = { params ->
|
||||
val amount = params.getDouble(0)
|
||||
val playSound = params.getBooleanOrNull(1) ?: true
|
||||
pokemon.feedPokemon(amount.toInt(), playSound)
|
||||
val playSound = params.getBooleanOrNull(1) != false
|
||||
val playMoodParticles = params.getBooleanOrNull(2) != false
|
||||
DoubleValue(pokemon.feedPokemon(amount.toInt(), playSound, playMoodParticles))
|
||||
}
|
||||
map["behaviour"] = { pokemon.form.behaviour.struct }
|
||||
map["behavior"] = { pokemon.form.behaviour.struct } // Inferior
|
||||
|
||||
@@ -44,6 +44,7 @@ object ActionEffects : JsonDataRegistry<ActionEffectTimeline> {
|
||||
ActionEffectKeyframe.register<EntityMoLangActionEffectKeyframe>("entity_molang")
|
||||
ActionEffectKeyframe.register<MoLangActionEffectKeyframe>("molang")
|
||||
ActionEffectKeyframe.register<ParallelActionEffectKeyframe>("parallel")
|
||||
ActionEffectKeyframe.register<LoopActionEffectKeyframe>("loop")
|
||||
ActionEffectKeyframe.register<CanInterruptActionEffectKeyframe>("can_interrupt")
|
||||
ActionEffectKeyframe.register<CannotInterruptActionEffectKeyframe>("cannot_interrupt")
|
||||
ActionEffectKeyframe.register<RemoveHoldsActionEffectKeyframe>("remove_holds")
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.api.moves.animations.keyframes
|
||||
|
||||
import com.cobblemon.mod.common.api.moves.animations.ActionEffectContext
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
class LoopActionEffectKeyframe(
|
||||
val keyframe: ActionEffectKeyframe = PauseActionEffectKeyframe()
|
||||
) : ConditionalActionEffectKeyframe() {
|
||||
override fun playWhenTrue(context: ActionEffectContext): CompletableFuture<Unit> {
|
||||
val future = CompletableFuture<Unit>()
|
||||
runIteration(context, future)
|
||||
return future
|
||||
}
|
||||
|
||||
private fun runIteration(context: ActionEffectContext, future: CompletableFuture<Unit>) {
|
||||
context.currentKeyframes.add(keyframe)
|
||||
keyframe.play(context)
|
||||
.thenRun { context.currentKeyframes.remove(keyframe) }
|
||||
.thenAccept {
|
||||
if (condition.resolveBoolean(context.runtime)) {
|
||||
runIteration(context, future)
|
||||
} else {
|
||||
future.complete(Unit)
|
||||
}
|
||||
}
|
||||
.exceptionally {
|
||||
future.completeExceptionally(it)
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,10 @@
|
||||
package com.cobblemon.mod.common.entity.ai
|
||||
|
||||
import com.bedrockk.molang.Expression
|
||||
import com.cobblemon.mod.common.CobblemonMemories
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.getMemorySafely
|
||||
import com.cobblemon.mod.common.util.mainThreadRuntime
|
||||
import com.cobblemon.mod.common.util.resolveInt
|
||||
import com.cobblemon.mod.common.util.withQueryValue
|
||||
@@ -29,12 +32,23 @@ object FleeFromAttackerTask {
|
||||
Trigger { _, entity, _ ->
|
||||
val hurtByEntity = it.get(hurtByEntity)
|
||||
val avoidTarget = it.tryGet(avoidTarget).orElse(null)
|
||||
if (avoidTarget != null && avoidTarget == hurtByEntity.uuid) {
|
||||
|
||||
if (avoidTarget != null && avoidTarget == hurtByEntity) {
|
||||
return@Trigger false
|
||||
}
|
||||
|
||||
mainThreadRuntime.withQueryValue("entity", entity.asMostSpecificMoLangValue())
|
||||
val avoidDurationTicks = mainThreadRuntime.resolveInt(avoidDurationTicks)
|
||||
|
||||
val pokemonEntity = entity as? PokemonEntity
|
||||
pokemonEntity?.let {
|
||||
it.after(1.0f) {
|
||||
it.playMoodParticle("mood_stress")
|
||||
}
|
||||
}
|
||||
|
||||
entity.brain.setMemoryWithExpiry(MemoryModuleType.AVOID_TARGET, hurtByEntity, avoidDurationTicks.toLong())
|
||||
|
||||
return@Trigger true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
package com.cobblemon.mod.common.entity.ai
|
||||
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.ai.behavior.OneShot
|
||||
import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder
|
||||
@@ -24,10 +25,16 @@ object GetAngryAtAttackerTask {
|
||||
Trigger { _, entity, _ ->
|
||||
val hurtByEntity = it.get(hurtByEntity)
|
||||
val angryAt = it.tryGet(angryAt).orElse(null)
|
||||
|
||||
if (angryAt != null && angryAt == hurtByEntity.uuid) {
|
||||
return@Trigger false
|
||||
}
|
||||
|
||||
val becomingAngry = angryAt == null
|
||||
entity.brain.setMemory(MemoryModuleType.ANGRY_AT, hurtByEntity.uuid)
|
||||
if (becomingAngry) {
|
||||
(entity as PokemonEntity?)?.playMoodParticle("mood_anger_steam")
|
||||
}
|
||||
return@Trigger true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,9 @@ import com.cobblemon.mod.common.api.molang.MoLangFunctions.addPokemonFunctions
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.addStandardFunctions
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.setup
|
||||
import com.cobblemon.mod.common.api.molang.ObjectValue
|
||||
import com.cobblemon.mod.common.api.moves.animations.ActionEffectContext
|
||||
import com.cobblemon.mod.common.api.moves.animations.ActionEffects
|
||||
import com.cobblemon.mod.common.api.moves.animations.UsersProvider
|
||||
import com.cobblemon.mod.common.api.net.serializers.PlatformTypeDataSerializer
|
||||
import com.cobblemon.mod.common.api.net.serializers.PoseTypeDataSerializer
|
||||
import com.cobblemon.mod.common.api.net.serializers.RideBoostsDataSerializer
|
||||
@@ -425,6 +428,9 @@ open class PokemonEntity(
|
||||
|
||||
var occupiedSeats = mutableMapOf<Seat, Entity>()
|
||||
|
||||
var moodParticleLock = false
|
||||
var playedZeroStaminaParticle = false
|
||||
|
||||
init {
|
||||
delegate.initialize(this)
|
||||
delegate.changePokemon(pokemon)
|
||||
@@ -904,6 +910,27 @@ open class PokemonEntity(
|
||||
return future
|
||||
}
|
||||
|
||||
fun playMoodParticle(particleName: String) {
|
||||
if (moodParticleLock) return
|
||||
|
||||
val actionEffect = ActionEffects.actionEffects[cobblemonResource(particleName)] ?: return
|
||||
|
||||
cry()
|
||||
|
||||
val context = ActionEffectContext(
|
||||
actionEffect = actionEffect,
|
||||
providers = mutableListOf(UsersProvider(this)),
|
||||
runtime = runtime,
|
||||
level = level()
|
||||
)
|
||||
actionEffect.run(context)
|
||||
|
||||
moodParticleLock = true
|
||||
after(5.0f) {
|
||||
moodParticleLock = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun saveWithoutId(nbt: CompoundTag): CompoundTag {
|
||||
val tethering = this.tethering
|
||||
if (tethering != null) {
|
||||
@@ -2300,6 +2327,8 @@ open class PokemonEntity(
|
||||
ifRidingAvailable { _, _, state ->
|
||||
state.stamina.set(entityData.get(RIDE_STAMINA))
|
||||
}
|
||||
|
||||
playedZeroStaminaParticle = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2328,12 +2357,26 @@ open class PokemonEntity(
|
||||
|
||||
override fun tickRidden(driver: Player, movementInput: Vec3) {
|
||||
super.tickRidden(driver, movementInput)
|
||||
|
||||
ifRidingAvailable { behaviour, settings, state ->
|
||||
behaviour.tick(settings, state, this, driver, movementInput)
|
||||
if (entityData.get(RIDE_STAMINA) == -1F) {
|
||||
state.stamina.set(1F, forced = true)
|
||||
}
|
||||
|
||||
if (!level().isClientSide) {
|
||||
val stamina = state.stamina.get()
|
||||
|
||||
if (stamina <= 0f) {
|
||||
if (!playedZeroStaminaParticle) {
|
||||
playMoodParticle("mood_stress")
|
||||
playedZeroStaminaParticle = true
|
||||
}
|
||||
} else {
|
||||
playedZeroStaminaParticle = false
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide) {
|
||||
val pose = behaviour.pose(settings, state, this)
|
||||
if (pose != this.entityData.get(POSE_TYPE)) {
|
||||
|
||||
+5
@@ -44,6 +44,11 @@ class DefendOwnerSensor : Sensor<PokemonEntity>(10) {
|
||||
return@findClosest false
|
||||
}.map { mob -> mob as LivingEntity }
|
||||
|
||||
val previousAttacker = entity.brain.getMemorySafely(CobblemonMemories.NEAREST_VISIBLE_ATTACKER)
|
||||
val isNewAttacker = nearestAttacker.isPresent && previousAttacker.isEmpty
|
||||
entity.brain.setMemory(CobblemonMemories.NEAREST_VISIBLE_ATTACKER, nearestAttacker)
|
||||
if (isNewAttacker) {
|
||||
entity.playMoodParticle("mood_anger_steam")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -9,6 +9,7 @@
|
||||
package com.cobblemon.mod.common.entity.pokemon.ai.tasks
|
||||
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.getMemorySafely
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.Mob
|
||||
import net.minecraft.world.entity.ai.behavior.OneShot
|
||||
@@ -60,7 +61,12 @@ object AttackHostileMobsTask {
|
||||
}
|
||||
|
||||
if (hostile != null) {
|
||||
val isNewTarget = currentTarget == null
|
||||
entity.brain.setMemory(MemoryModuleType.ATTACK_TARGET, hostile)
|
||||
if (isNewTarget) {
|
||||
(entity as? PokemonEntity)?.playMoodParticle("mood_anger_steam")
|
||||
}
|
||||
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ class EatHeldItemTask(entity: PokemonEntity) : Behavior<PokemonEntity>(
|
||||
}
|
||||
this.timelastEaten = time
|
||||
if (itemConfig != null && itemConfig.fullnessValue > 0) {
|
||||
entity.pokemon.feedPokemon(itemConfig.fullnessValue, false)
|
||||
entity.pokemon.feedPokemon(itemConfig.fullnessValue, false, false)
|
||||
}
|
||||
// Check if the result item is something that should be dropped
|
||||
resultItemStack = entity.pokemon.heldItem()
|
||||
|
||||
@@ -13,7 +13,9 @@ import com.cobblemon.mod.common.api.apricorn.Apricorn
|
||||
import com.cobblemon.mod.common.api.item.PokemonSelectingItem
|
||||
import com.cobblemon.mod.common.api.riding.stats.RidingStat
|
||||
import com.cobblemon.mod.common.client.pot.CookingQuality
|
||||
import com.cobblemon.mod.common.net.messages.client.effect.SpawnSnowstormEntityParticlePacket
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
@@ -92,7 +94,9 @@ class AprijuiceItem(val type: Apricorn): CobblemonItem(Properties().stacksTo(16)
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
pokemon.feedPokemon(1)
|
||||
if (!pokemon.feedPokemon(1)) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
val boosts = getBoosts(stack)
|
||||
pokemon.addRideBoosts(boosts.mapValues { it.value.toFloat() })
|
||||
|
||||
@@ -96,8 +96,9 @@ class PokePuffItem : Item(Properties().stacksTo(64)), PokemonSelectingItem {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
// Feed the Pokémon 4 fullness points
|
||||
pokemon.feedPokemon(4)
|
||||
if (!pokemon.feedPokemon(4)) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
val friendshipChange = PokePuffUtils.calculateFriendshipChange(stack, pokemon.nature)
|
||||
|
||||
|
||||
+9
-7
@@ -54,14 +54,16 @@ class FriendshipRaisingBerryItem(block: BerryBlock, val stat: Stat) : BerryItem(
|
||||
val evLowerAmount = max(genericRuntime.resolveInt(CobblemonMechanics.berries.evLowerAmount), 0)
|
||||
val decreasedEVs = pokemon.evs.add(stat, -evLowerAmount, ItemEvSource(player, stack, pokemon)) != 0
|
||||
|
||||
return if (increasedFriendship || decreasedEVs) {
|
||||
pokemon.feedPokemon(1)
|
||||
|
||||
stack.consume(1, player)
|
||||
InteractionResultHolder.success(stack)
|
||||
} else {
|
||||
InteractionResultHolder.pass(stack)
|
||||
if (!increasedFriendship && !decreasedEVs) {
|
||||
return InteractionResultHolder.pass(stack)
|
||||
}
|
||||
|
||||
if (!pokemon.feedPokemon(1)) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
stack.consume(1, player)
|
||||
return InteractionResultHolder.success(stack)
|
||||
}
|
||||
|
||||
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
|
||||
|
||||
@@ -54,7 +54,10 @@ class HealingBerryItem(block: BerryBlock, val amount: () -> ExpressionLike): Ber
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
pokemon.feedPokemon(1)
|
||||
if (!pokemon.feedPokemon(1)) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
pokemon.currentHealth = Integer.min(pokemon.currentHealth + genericRuntime.resolveInt(amount(), pokemon), pokemon.maxHealth)
|
||||
stack.consume(1, player)
|
||||
return InteractionResultHolder.success(stack)
|
||||
@@ -62,7 +65,7 @@ class HealingBerryItem(block: BerryBlock, val amount: () -> ExpressionLike): Ber
|
||||
|
||||
override fun applyToBattlePokemon(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon) {
|
||||
super.applyToBattlePokemon(player, stack, battlePokemon)
|
||||
battlePokemon.originalPokemon.feedPokemon(1)
|
||||
battlePokemon.originalPokemon.feedPokemon(1, playMoodParticle = false)
|
||||
}
|
||||
|
||||
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
|
||||
|
||||
@@ -48,21 +48,26 @@ class PPRestoringBerryItem(block: BerryBlock, val amount: () -> ExpressionLike):
|
||||
&& super.canUseOnPokemon(stack, pokemon)
|
||||
|
||||
override fun applyToPokemon(player: ServerPlayer, stack: ItemStack, pokemon: Pokemon, move: Move) {
|
||||
if (canUseOnPokemon(stack, pokemon) && canUseOnMove(stack, move)) {
|
||||
pokemon.feedPokemon(1)
|
||||
val moveToRecover = pokemon.moveSet.find { it.template == move.template }
|
||||
if (moveToRecover != null && moveToRecover.currentPp < moveToRecover.maxPp) {
|
||||
moveToRecover.currentPp =
|
||||
min(moveToRecover.maxPp, moveToRecover.currentPp + genericRuntime.resolveInt(amount(), pokemon))
|
||||
if (!canUseOnPokemon(stack, pokemon) && canUseOnMove(stack, move)) {
|
||||
return
|
||||
}
|
||||
|
||||
stack.consume(1, player)
|
||||
}
|
||||
if (!pokemon.feedPokemon(1)) {
|
||||
return
|
||||
}
|
||||
|
||||
val moveToRecover = pokemon.moveSet.find { it.template == move.template }
|
||||
if (moveToRecover != null && moveToRecover.currentPp < moveToRecover.maxPp) {
|
||||
moveToRecover.currentPp =
|
||||
min(moveToRecover.maxPp, moveToRecover.currentPp + genericRuntime.resolveInt(amount(), pokemon))
|
||||
|
||||
stack.consume(1, player)
|
||||
}
|
||||
}
|
||||
|
||||
override fun applyToBattlePokemon(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon, move: Move) {
|
||||
super.applyToBattlePokemon(player, stack, battlePokemon, move)
|
||||
battlePokemon.originalPokemon.feedPokemon(1)
|
||||
battlePokemon.originalPokemon.feedPokemon(1, playMoodParticle = false)
|
||||
}
|
||||
|
||||
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
|
||||
|
||||
+4
-2
@@ -59,7 +59,9 @@ class PortionHealingBerryItem(block: BerryBlock, val canCauseConfusion: Boolean,
|
||||
}
|
||||
|
||||
// count these berries as multiple feedings due to the amount they heal
|
||||
pokemon.feedPokemon(5)
|
||||
if (!pokemon.feedPokemon(5)) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
var amount = Integer.min(pokemon.currentHealth + (genericRuntime.resolveFloat(portion(), pokemon) * pokemon.maxHealth).toInt(), pokemon.maxHealth)
|
||||
CobblemonEvents.POKEMON_HEALED.postThen(PokemonHealedEvent(pokemon, amount, this), { cancelledEvent -> return InteractionResultHolder.fail(stack)}) { event ->
|
||||
@@ -73,7 +75,7 @@ class PortionHealingBerryItem(block: BerryBlock, val canCauseConfusion: Boolean,
|
||||
|
||||
override fun applyToBattlePokemon(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon) {
|
||||
super.applyToBattlePokemon(player, stack, battlePokemon)
|
||||
battlePokemon.originalPokemon.feedPokemon(5)
|
||||
battlePokemon.originalPokemon.feedPokemon(5, playMoodParticle = false)
|
||||
}
|
||||
|
||||
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
|
||||
|
||||
+12
-8
@@ -58,19 +58,23 @@ class StatusCuringBerryItem(block: BerryBlock, vararg val status: Status): Berry
|
||||
stack: ItemStack,
|
||||
pokemon: Pokemon
|
||||
): InteractionResultHolder<ItemStack>? {
|
||||
return if (canUseOnPokemon(stack, pokemon)) {
|
||||
pokemon.feedPokemon(1)
|
||||
pokemon.status = null
|
||||
stack.consume(1, player)
|
||||
InteractionResultHolder.success(stack)
|
||||
} else {
|
||||
InteractionResultHolder.fail(stack)
|
||||
if (!canUseOnPokemon(stack, pokemon)) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
if (!pokemon.feedPokemon(1)) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
pokemon.status = null
|
||||
stack.consume(1, player)
|
||||
|
||||
return InteractionResultHolder.success(stack)
|
||||
}
|
||||
|
||||
override fun applyToBattlePokemon(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon) {
|
||||
super.applyToBattlePokemon(player, stack, battlePokemon)
|
||||
battlePokemon.originalPokemon.feedPokemon(1)
|
||||
battlePokemon.originalPokemon.feedPokemon(1, playMoodParticle = false)
|
||||
}
|
||||
|
||||
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
|
||||
|
||||
@@ -53,7 +53,10 @@ class BerryJuiceItem : CobblemonItem(Properties()), PokemonSelectingItem, Healin
|
||||
if (!canUseOnPokemon(stack, pokemon)) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
pokemon.feedPokemon(1)
|
||||
|
||||
if (!pokemon.feedPokemon(1)) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
var amount = Integer.min(pokemon.currentHealth + 20, pokemon.maxHealth)
|
||||
CobblemonEvents.POKEMON_HEALED.postThen(PokemonHealedEvent(pokemon, amount, this), { cancelledEvent -> return InteractionResultHolder.fail(stack)}) { event ->
|
||||
@@ -74,7 +77,9 @@ class BerryJuiceItem : CobblemonItem(Properties()), PokemonSelectingItem, Healin
|
||||
|
||||
override fun applyToBattlePokemon(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon) {
|
||||
super.applyToBattlePokemon(player, stack, battlePokemon)
|
||||
battlePokemon.originalPokemon.feedPokemon(1)
|
||||
|
||||
battlePokemon.originalPokemon.feedPokemon(1, playMoodParticle = false)
|
||||
|
||||
if (!player.hasInfiniteMaterials()) {
|
||||
val woodenBowlItemStack = ItemStack(Items.BOWL)
|
||||
if (!player.inventory.add(woodenBowlItemStack)) {
|
||||
|
||||
+3
-1
@@ -33,7 +33,9 @@ class FreshStartMochiItem : CobblemonItem(Properties()), PokemonSelectingItem {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
pokemon.feedPokemon(1)
|
||||
if (!pokemon.feedPokemon(1)) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
pokemon.evs.forEach {
|
||||
pokemon.setEV(it.key, 0)
|
||||
|
||||
@@ -24,7 +24,9 @@ class MochiItem(stat: Stats): EVIncreaseItem(stat, 4) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
pokemon.feedPokemon(1)
|
||||
if (!pokemon.feedPokemon(1)) {
|
||||
return InteractionResultHolder.fail(stack)
|
||||
}
|
||||
|
||||
return super.applyToPokemon(player, stack, pokemon)
|
||||
}
|
||||
|
||||
@@ -985,6 +985,10 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
this.recall()
|
||||
}
|
||||
|
||||
fun playMoodParticle(particleName: String) {
|
||||
entity?.playMoodParticle(particleName)
|
||||
}
|
||||
|
||||
fun heal() {
|
||||
CobblemonEvents.POKEMON_HEALED.postThen(PokemonHealedEvent(this)) { event ->
|
||||
this.currentHealth = maxHealth
|
||||
@@ -1056,23 +1060,13 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
else -> 0 // For weights less than 0.1
|
||||
}
|
||||
|
||||
fun feedPokemon(feedCount: Int, playSound: Boolean = true) {
|
||||
// play sounds from the entity first (itemstack is consumed outside of this function)
|
||||
if (this.entity != null && playSound) {
|
||||
val fullnessPercent = ((this.currentFullness).toFloat() / (this.getMaxFullness()).toFloat()) * (.5f)
|
||||
|
||||
if (this.currentFullness >= this.getMaxFullness()) {
|
||||
this.entity?.playSound(CobblemonSounds.BERRY_EAT_FULL, 1F, 1F)
|
||||
}
|
||||
else {
|
||||
this.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F + fullnessPercent)
|
||||
}
|
||||
}
|
||||
fun feedPokemon(feedCount: Int, playSound: Boolean = true, playMoodParticle: Boolean = true): Boolean {
|
||||
playFullnessEffects(playSound, playMoodParticle)
|
||||
|
||||
// if it is already full we don't need to do anything
|
||||
// TODO this can happen when feeding in battle since we are temporarily ignoring fullness checks for pp/hp/status berries
|
||||
if (isFull()) {
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
this.currentFullness = (this.currentFullness + feedCount).coerceIn(0, this.getMaxFullness())
|
||||
@@ -1081,6 +1075,31 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
if (this.currentFullness == 1) {
|
||||
this.resetMetabolismCycle()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private fun playFullnessEffects(playSound: Boolean = true, playMoodParticle: Boolean = true) {
|
||||
if (!playSound && !playMoodParticle) return
|
||||
|
||||
val pokemonEntity = entity ?: return
|
||||
val fullnessPercent = ((this.currentFullness).toFloat() / (this.getMaxFullness()).toFloat()) * (.5f)
|
||||
|
||||
if (!isFull()) {
|
||||
if (playSound) {
|
||||
pokemonEntity.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F + fullnessPercent)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (playSound) {
|
||||
pokemonEntity.playSound(CobblemonSounds.BERRY_EAT_FULL, 1F, 1F)
|
||||
|
||||
if (playMoodParticle) {
|
||||
pokemonEntity.playMoodParticle("mood_annoyed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// decrease a pokemon's Fullness value by a certain amount
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"format_version": "1.10.0",
|
||||
"particle_effect": {
|
||||
"description": {
|
||||
"identifier": "cobblemon:mood_anger_steam",
|
||||
"basic_render_parameters": {
|
||||
"material": "particles_alpha",
|
||||
"texture": "textures/particles/mood/steam_center_double"
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"minecraft:emitter_rate_instant": {
|
||||
"num_particles": 1
|
||||
},
|
||||
"minecraft:emitter_lifetime_once": {
|
||||
"active_time": 1
|
||||
},
|
||||
"minecraft:emitter_shape_point": {
|
||||
"offset": [0, "math.clamp((v.entity_radius*1.2),0.48,0.96)*0.75", 0]
|
||||
},
|
||||
"minecraft:particle_lifetime_expression": {
|
||||
"max_lifetime": 1
|
||||
},
|
||||
"minecraft:particle_initial_speed": 0,
|
||||
"minecraft:particle_motion_dynamic": {},
|
||||
"minecraft:particle_appearance_billboard": {
|
||||
"size": ["math.clamp((v.entity_radius*1.5),0.9,2.4)", "math.clamp((v.entity_radius*0.5),0.3,0.8)"],
|
||||
"facing_camera_mode": "rotate_xyz",
|
||||
"uv": {
|
||||
"texture_width": 48,
|
||||
"texture_height": 176,
|
||||
"flipbook": {
|
||||
"base_UV": [0, 0],
|
||||
"size_UV": [48, 16],
|
||||
"step_UV": [0, 16],
|
||||
"max_frame": 11,
|
||||
"stretch_to_lifetime": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"format_version": "1.10.0",
|
||||
"particle_effect": {
|
||||
"description": {
|
||||
"identifier": "cobblemon:mood_anger_veins",
|
||||
"basic_render_parameters": {
|
||||
"material": "particles_alpha",
|
||||
"texture": "textures/particles/mood/vein_red"
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"minecraft:emitter_initialization": {
|
||||
"creation_expression": "v.particle_size = math.clamp((v.entity_radius*0.75),0.15,0.4);"
|
||||
},
|
||||
"minecraft:emitter_rate_instant": {
|
||||
"num_particles": 1
|
||||
},
|
||||
"minecraft:emitter_lifetime_once": {
|
||||
"active_time": 1
|
||||
},
|
||||
"minecraft:emitter_shape_point": {
|
||||
"direction": ["math.random(-1,1)", 1.5, "math.random(-1,1)"]
|
||||
},
|
||||
"minecraft:particle_lifetime_expression": {
|
||||
"max_lifetime": 1.25
|
||||
},
|
||||
"minecraft:particle_initial_spin": {
|
||||
"rotation": "math.random_integer(-1,2)*90"
|
||||
},
|
||||
"minecraft:particle_initial_speed": "v.particle_size*13",
|
||||
"minecraft:particle_motion_dynamic": {
|
||||
"linear_acceleration": [0, 0.75, 0],
|
||||
"linear_drag_coefficient": "v.particle_size*15"
|
||||
},
|
||||
"minecraft:particle_appearance_billboard": {
|
||||
"size": ["math.clamp((v.entity_radius*0.75),0.15,0.3)", "math.clamp((v.entity_radius*0.75),0.15,0.3)"],
|
||||
"facing_camera_mode": "rotate_xyz",
|
||||
"uv": {
|
||||
"texture_width": 22,
|
||||
"texture_height": 11,
|
||||
"flipbook": {
|
||||
"base_UV": [0, 0],
|
||||
"size_UV": [11, 11],
|
||||
"step_UV": [11, 0],
|
||||
"frames_per_second": 6,
|
||||
"max_frame": 2,
|
||||
"loop": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"minecraft:particle_motion_collision": {},
|
||||
"minecraft:particle_appearance_lighting": {},
|
||||
"minecraft:particle_appearance_tinting": {
|
||||
"color": {
|
||||
"interpolant": "v.particle_age/v.particle_lifetime",
|
||||
"gradient": {
|
||||
"0.86": "#ffffffff",
|
||||
"1.0": "#FF000000"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"format_version": "1.10.0",
|
||||
"particle_effect": {
|
||||
"description": {
|
||||
"identifier": "cobblemon:mood_annoyed",
|
||||
"basic_render_parameters": {
|
||||
"material": "particles_alpha",
|
||||
"texture": "textures/particles/mood/scribble_purple"
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"minecraft:emitter_initialization": {
|
||||
"creation_expression": "v.particle_size = math.clamp((v.entity_radius*0.75),0.2,0.5);"
|
||||
},
|
||||
"minecraft:emitter_rate_instant": {
|
||||
"num_particles": 1
|
||||
},
|
||||
"minecraft:emitter_lifetime_once": {
|
||||
"active_time": 2
|
||||
},
|
||||
"minecraft:emitter_shape_point": {
|
||||
"direction": [0, 1, 0]
|
||||
},
|
||||
"minecraft:particle_lifetime_expression": {
|
||||
"max_lifetime": 1
|
||||
},
|
||||
"minecraft:particle_initial_speed": "v.particle_size*10",
|
||||
"minecraft:particle_motion_dynamic": {
|
||||
"linear_drag_coefficient": 3
|
||||
},
|
||||
"minecraft:particle_appearance_billboard": {
|
||||
"size": ["math.clamp((v.entity_radius*0.75),0.2,0.5)", "math.clamp((v.entity_radius*0.75),0.2,0.5)"],
|
||||
"facing_camera_mode": "rotate_xyz",
|
||||
"uv": {
|
||||
"texture_width": 168,
|
||||
"texture_height": 14,
|
||||
"flipbook": {
|
||||
"base_UV": [0, 0],
|
||||
"size_UV": [14, 14],
|
||||
"step_UV": [14, 0],
|
||||
"frames_per_second": 10,
|
||||
"max_frame": 12
|
||||
}
|
||||
}
|
||||
},
|
||||
"minecraft:particle_appearance_lighting": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"format_version": "1.10.0",
|
||||
"particle_effect": {
|
||||
"description": {
|
||||
"identifier": "cobblemon:mood_stress",
|
||||
"basic_render_parameters": {
|
||||
"material": "particles_alpha",
|
||||
"texture": "textures/particles/mood/sweat_blue"
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"minecraft:emitter_initialization": {
|
||||
"creation_expression": "v.particle_height = math.clamp((v.entity_radius*1.2),0.48,0.96);"
|
||||
},
|
||||
"minecraft:emitter_rate_instant": {
|
||||
"num_particles": 1
|
||||
},
|
||||
"minecraft:emitter_lifetime_looping": {
|
||||
"active_time": 1
|
||||
},
|
||||
"minecraft:emitter_shape_point": {
|
||||
"offset": [0, "math.clamp((v.entity_radius*1.2),0.48,0.96)*0.75", 0]
|
||||
},
|
||||
"minecraft:particle_lifetime_expression": {
|
||||
"max_lifetime": 0.45
|
||||
},
|
||||
"minecraft:particle_initial_speed": 0,
|
||||
"minecraft:particle_motion_dynamic": {},
|
||||
"minecraft:particle_appearance_billboard": {
|
||||
"size": ["math.clamp((v.entity_radius*1.2),0.48,0.96)", "math.clamp((v.entity_radius*0.65),0.26,0.52)"],
|
||||
"facing_camera_mode": "rotate_xyz",
|
||||
"uv": {
|
||||
"texture_width": 216,
|
||||
"texture_height": 13,
|
||||
"flipbook": {
|
||||
"base_UV": [0, 0],
|
||||
"size_UV": [24, 13],
|
||||
"step_UV": [24, 0],
|
||||
"max_frame": 9,
|
||||
"stretch_to_lifetime": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"minecraft:particle_appearance_lighting": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 979 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 744 B |
Binary file not shown.
|
After Width: | Height: | Size: 589 B |
Binary file not shown.
|
After Width: | Height: | Size: 290 B |
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"timeline": [
|
||||
{
|
||||
"type": "entity_particles",
|
||||
"effect": "cobblemon:mood_anger_steam",
|
||||
"locators": ["head", "top"]
|
||||
},
|
||||
{
|
||||
"type": "loop",
|
||||
"condition": "q.entity.has_memory_value('minecraft:angry_at') || q.entity.has_memory_value('minecraft:attack_target') || q.entity.has_memory_value('cobblemon:nearest_visible_attacker')",
|
||||
"keyframe": {
|
||||
"type": "sequence",
|
||||
"keyframes": [
|
||||
{
|
||||
"type": "entity_particles",
|
||||
"effect": "cobblemon:mood_anger_veins",
|
||||
"locators": ["head", "top"]
|
||||
},
|
||||
{
|
||||
"type": "pause",
|
||||
"pause": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"timeline": [
|
||||
{
|
||||
"type": "entity_particles",
|
||||
"effect": "cobblemon:mood_annoyed",
|
||||
"locators": ["head", "top"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"timeline": [
|
||||
{
|
||||
"type": "entity_particles",
|
||||
"effect": "cobblemon:mood_stress",
|
||||
"locators": ["head", "top"]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user