mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-11-26 10:08:53 -05:00
Changed heldItemVisible to optional
This commit is contained in:
1 parent
8febe77edb
commit
96a9844fa4
4 files changed
+8
-32
No files matched your search
@@ -82,7 +82,6 @@ object CobblemonSchemas {
|
||||
builder.addFixer(ShoulderStateJsonFix(schema1))
|
||||
builder.addFixer(NicknameFix(schema1))
|
||||
builder.addFixer(RaisedPPStagesFix(schema1))
|
||||
builder.addFixer(HeldItemVisibleFix(schema1))
|
||||
}
|
||||
|
||||
private class CobblemonDataFixerCodec<R>(private val baseCodec: Codec<R>, private val typeReference: TypeReference) : Codec<R> {
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* 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.datafixer.fix
|
||||
|
||||
import com.cobblemon.mod.common.util.DataKeys
|
||||
import com.mojang.datafixers.schemas.Schema
|
||||
import com.mojang.serialization.Dynamic
|
||||
|
||||
class HeldItemVisibleFix(outputSchema: Schema) : PokemonFix(outputSchema) {
|
||||
override fun fixPokemonData(dynamic: Dynamic<*>): Dynamic<*> {
|
||||
if (dynamic.get(DataKeys.HELD_ITEM_VISIBLE).result().isPresent) {
|
||||
return dynamic
|
||||
}
|
||||
return dynamic.set(DataKeys.HELD_ITEM_VISIBLE, dynamic.createBoolean(true))
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -22,7 +22,7 @@ internal data class ClientPokemonP3(
|
||||
val originalTrainer: Optional<String>,
|
||||
val originalTrainerName: Optional<String>,
|
||||
val aspects: Set<String>,
|
||||
val heldItemVisible: Boolean
|
||||
val heldItemVisible: Optional<Boolean>
|
||||
) : Partial<Pokemon> {
|
||||
|
||||
override fun into(other: Pokemon): Pokemon {
|
||||
@@ -30,7 +30,7 @@ internal data class ClientPokemonP3(
|
||||
this.originalTrainer.ifPresent { other.originalTrainer = it }
|
||||
this.originalTrainerName.ifPresent { other.originalTrainerName = it }
|
||||
other.forcedAspects = this.aspects
|
||||
other.heldItemVisible = this.heldItemVisible
|
||||
this.heldItemVisible.ifPresent { other.heldItemVisible = it }
|
||||
return other
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ internal data class ClientPokemonP3(
|
||||
Codec.STRING.optionalFieldOf(DataKeys.POKEMON_ORIGINAL_TRAINER).forGetter(ClientPokemonP3::originalTrainer),
|
||||
Codec.STRING.optionalFieldOf(DataKeys.POKEMON_ORIGINAL_TRAINER_NAME).forGetter(ClientPokemonP3::originalTrainerName),
|
||||
Codec.list(Codec.STRING).optionalFieldOf(DataKeys.POKEMON_FORCED_ASPECTS, emptyList()).xmap({ it.toSet() }, { it.toMutableList() }).forGetter(ClientPokemonP3::aspects),
|
||||
Codec.BOOL.fieldOf(DataKeys.HELD_ITEM_VISIBLE).forGetter(ClientPokemonP3::heldItemVisible)
|
||||
Codec.BOOL.optionalFieldOf(DataKeys.HELD_ITEM_VISIBLE).forGetter(ClientPokemonP3::heldItemVisible)
|
||||
).apply(instance, ::ClientPokemonP3)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ internal data class ClientPokemonP3(
|
||||
Optional.ofNullable(pokemon.originalTrainer),
|
||||
Optional.ofNullable(pokemon.originalTrainerName),
|
||||
pokemon.aspects + pokemon.forcedAspects,
|
||||
pokemon.heldItemVisible
|
||||
Optional.ofNullable(pokemon.heldItemVisible)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ internal data class PokemonP3(
|
||||
val originalTrainer: Optional<String>,
|
||||
val forcedAspects: Set<String>,
|
||||
val features: List<CompoundTag>,
|
||||
val heldItemVisible: Boolean
|
||||
val heldItemVisible: Optional<Boolean>
|
||||
) : Partial<Pokemon> {
|
||||
|
||||
override fun into(other: Pokemon): Pokemon {
|
||||
@@ -54,7 +54,7 @@ internal data class PokemonP3(
|
||||
other.features.removeIf { it.name == feature.name }
|
||||
other.features.add(feature)
|
||||
}
|
||||
other.heldItemVisible = this.heldItemVisible
|
||||
this.heldItemVisible.ifPresent { other.heldItemVisible = it }
|
||||
return other
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ internal data class PokemonP3(
|
||||
Codec.STRING.optionalFieldOf(DataKeys.POKEMON_ORIGINAL_TRAINER).forGetter(PokemonP3::originalTrainer),
|
||||
Codec.list(Codec.STRING).optionalFieldOf(DataKeys.POKEMON_FORCED_ASPECTS, emptyList()).forGetter { it.forcedAspects.toMutableList() },
|
||||
Codec.list(CompoundTag.CODEC).optionalFieldOf(FEATURES, emptyList()).forGetter(PokemonP3::features),
|
||||
Codec.BOOL.fieldOf(DataKeys.HELD_ITEM_VISIBLE).forGetter(PokemonP3::heldItemVisible)
|
||||
Codec.BOOL.optionalFieldOf(DataKeys.HELD_ITEM_VISIBLE).forGetter(PokemonP3::heldItemVisible)
|
||||
).apply(instance) { originalTrainerType, originalTrainer, forcedAspects, features, heldItemVisible -> PokemonP3(originalTrainerType, originalTrainer, forcedAspects.toSet(), features, heldItemVisible) }
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ internal data class PokemonP3(
|
||||
nbt.putString(FEATURE_ID, feature.name)
|
||||
feature.saveToNBT(nbt)
|
||||
},
|
||||
pokemon.heldItemVisible
|
||||
Optional.ofNullable(pokemon.heldItemVisible)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user