forked from mirrors/cobblemon
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17ea2bb80f |
@@ -55,6 +55,8 @@ object CobblemonCriteria : PlatformRegistry<Registry<CriterionTrigger<*>>, Resou
|
||||
|
||||
val CAST_POKE_ROD = this.create("cast_poke_rod", SimpleCriterionTrigger(CastPokeRodCriterionCondition.CODEC))
|
||||
|
||||
val REEL_IN_POKEMON = this.create("reel_in_pokemon", SimpleCriterionTrigger(ReelInPokemonCriterionCondition.CODEC))
|
||||
|
||||
// Advancement criteria for [grow_tumblestone.json]
|
||||
val PLANT_TUMBLESTONE = this.create("plant_tumblestone", SimpleCriterionTrigger(PlantTumblestoneCriterion.CODEC))
|
||||
|
||||
|
||||
+8
-7
@@ -15,19 +15,20 @@ import java.util.Optional
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.advancements.critereon.EntityPredicate
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
|
||||
class CastPokeRodCriterionCondition(
|
||||
playerCtx: Optional<ContextAwarePredicate>,
|
||||
val hasBait: Boolean
|
||||
): SimpleCriterionCondition<Boolean>(playerCtx) {
|
||||
playerCtx: Optional<ContextAwarePredicate>,
|
||||
val baitId: Optional<ResourceLocation>
|
||||
) : SimpleCriterionCondition<ResourceLocation?>(playerCtx) {
|
||||
companion object {
|
||||
val CODEC: Codec<CastPokeRodCriterionCondition> = RecordCodecBuilder.create { it.group(
|
||||
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(CastPokeRodCriterionCondition::playerCtx),
|
||||
PrimitiveCodec.BOOL.fieldOf("hasBait").forGetter(CastPokeRodCriterionCondition::hasBait)
|
||||
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(CastPokeRodCriterionCondition::playerCtx),
|
||||
ResourceLocation.CODEC.optionalFieldOf("baitId").forGetter(CastPokeRodCriterionCondition::baitId)
|
||||
).apply(it, ::CastPokeRodCriterionCondition) }
|
||||
}
|
||||
|
||||
override fun matches(player: ServerPlayer, context: Boolean): Boolean {
|
||||
return hasBait == context
|
||||
override fun matches(player: ServerPlayer, context: ResourceLocation?): Boolean {
|
||||
return baitId.isEmpty || baitId.get() == context
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.cobblemon.mod.common.advancement.criterion
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import java.util.Optional
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.advancements.critereon.EntityPredicate
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
|
||||
class ReelInPokemonCriterionCondition(
|
||||
playerCtx: Optional<ContextAwarePredicate>,
|
||||
val pokemonId: Optional<String>
|
||||
) : SimpleCriterionCondition<String?>(playerCtx) {
|
||||
companion object {
|
||||
val CODEC: Codec<ReelInPokemonCriterionCondition> = RecordCodecBuilder.create { it.group(
|
||||
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(ReelInPokemonCriterionCondition::playerCtx),
|
||||
Codec.STRING.optionalFieldOf("pokemonId").forGetter(ReelInPokemonCriterionCondition::pokemonId)
|
||||
).apply(it, ::ReelInPokemonCriterionCondition) }
|
||||
}
|
||||
|
||||
override fun matches(player: ServerPlayer, context: String?): Boolean {
|
||||
println("Matching pokemonId: ${pokemonId.orElse("null")}, context: $context")
|
||||
return pokemonId.isEmpty || pokemonId.get() == context
|
||||
}
|
||||
}
|
||||
+5
@@ -12,6 +12,7 @@ import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonEntities
|
||||
import com.cobblemon.mod.common.CobblemonSounds
|
||||
import com.cobblemon.mod.common.ModAPI
|
||||
import com.cobblemon.mod.common.advancement.CobblemonCriteria
|
||||
import com.cobblemon.mod.common.api.events.CobblemonEvents
|
||||
import com.cobblemon.mod.common.api.events.fishing.BobberBucketChosenEvent
|
||||
import com.cobblemon.mod.common.api.events.fishing.BobberSpawnPokemonEvent
|
||||
@@ -707,6 +708,10 @@ class PokeRodFishingBobberEntity(type: EntityType<out PokeRodFishingBobberEntity
|
||||
// create accessory splash particle when you fish something up
|
||||
particleEntityHandler(this, ResourceLocation.fromNamespaceAndPath("cobblemon","accessory_fish_splash"))
|
||||
|
||||
if (player is ServerPlayer) {
|
||||
CobblemonCriteria.REEL_IN_POKEMON.trigger(player, spawnedPokemon.pokemon.species.resourceIdentifier.toString())
|
||||
}
|
||||
|
||||
if (spawnedPokemon.pokemon.species.weight.toDouble() < 900.0) { // if weight value of Pokemon is less than 200 lbs (in hectograms) which we store weight as) then reel it in to the player
|
||||
// play sound for small splash when this weight class is fished up
|
||||
level().playSound(null, this.blockPosition(), CobblemonSounds.FISHING_SPLASH_SMALL, SoundSource.BLOCKS, 1.0F, 1.0F)
|
||||
|
||||
@@ -224,7 +224,8 @@ class PokerodItem(val pokeRodId: ResourceLocation, settings: Properties) : Fishi
|
||||
{ event -> return InteractionResultHolder.fail(itemStack) },
|
||||
{ event ->
|
||||
world.addFreshEntity(bobberEntity)
|
||||
CobblemonCriteria.CAST_POKE_ROD.trigger(user as ServerPlayer, baitOnRod != null)
|
||||
val bait = getBaitOnRod(itemStack)
|
||||
CobblemonCriteria.CAST_POKE_ROD.trigger(user as ServerPlayer, bait?.item)
|
||||
|
||||
CobblemonEvents.POKEROD_CAST_POST.post(
|
||||
PokerodCastEvent.Post(itemStack, bobberEntity, getBaitStackOnRod(itemStack))
|
||||
|
||||
@@ -1333,6 +1333,10 @@
|
||||
"advancements.cobblemon.craft_rod.description": "Craft a Poké Rod using a Poké Rod Smithing Template",
|
||||
"advancements.cobblemon.use_bait": "A Berry Good Lure",
|
||||
"advancements.cobblemon.use_bait.description": "Use a berry as bait for your Poké Rod",
|
||||
"advancements.cobblemon.use_bait.oran": "Oran't you glad I'm here",
|
||||
"advancements.cobblemon.use_bait.oran.description": "Use an oran berry as bait for your Poké Rod",
|
||||
"advancements.cobblemon.reel_in_pokemon.magikarp": "Karptastic",
|
||||
"advancements.cobblemon.reel_in_pokemon.magikarp.description": "Reel-in a Magikarp with a pokerod",
|
||||
"advancements.cobblemon.craft_master_rod": "Masterful Dedication",
|
||||
"advancements.cobblemon.craft_master_rod.description": "Craft a Poké Rod using a Master Ball",
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"display": {
|
||||
"icon": {
|
||||
"id": "cobblemon:oran_berry"
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.cobblemon.use_bait.oran"
|
||||
},
|
||||
"description": {
|
||||
"translate": "advancements.cobblemon.use_bait.oran.description"
|
||||
}
|
||||
},
|
||||
"parent": "cobblemon:craft_rod",
|
||||
"criteria": {
|
||||
"has_specific_bait": {
|
||||
"trigger": "cobblemon:cast_poke_rod",
|
||||
"conditions": {
|
||||
"baitId": "cobblemon:oran_berry"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"display": {
|
||||
"icon": {
|
||||
"id": "cobblemon:pokemon_model",
|
||||
"components": {
|
||||
"cobblemon:pokemon_item": {"species":"cobblemon:magikarp"}
|
||||
}
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.cobblemon.reel_in_pokemon.magikarp"
|
||||
},
|
||||
"description": {
|
||||
"translate": "advancements.cobblemon.reel_in_pokemon.magikarp.description"
|
||||
}
|
||||
},
|
||||
"parent": "cobblemon:use_bait",
|
||||
"criteria": {
|
||||
"reel_in_pokemon": {
|
||||
"trigger": "cobblemon:reel_in_pokemon",
|
||||
"conditions": {
|
||||
"pokemonId": "cobblemon:magikarp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user