mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-11-02 06:19:55 -05:00
Compare commits
34
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9eeeab340c | ||
|
|
9163046b45 | ||
|
|
325d1af484 | ||
|
|
6ae71f28e6 | ||
|
|
5687a71de4 | ||
|
|
8199f8d7c2 | ||
|
|
6b39251d65 | ||
|
|
cd03e6f8c4 | ||
|
|
a1b53f90ad | ||
|
|
c0677c6353 | ||
|
|
d5b5e1055b | ||
|
|
06732e89fd | ||
|
|
304f368ae1 | ||
|
|
9e8d6a4f39 | ||
|
|
e22eeafdea | ||
|
|
662efa55c6 | ||
|
|
efb9e538f3 | ||
|
|
47e9491e4e | ||
|
|
c4713b522b | ||
|
|
42c711cfc7 | ||
|
|
1296acd151 | ||
|
|
1a5ef95879 | ||
|
|
681d5f8bcc | ||
|
|
a52d8452b4 | ||
|
|
e65298b587 | ||
|
|
f8c09b8e26 | ||
|
|
5d1019afd5 | ||
|
|
f36f126a2b | ||
|
|
eb9bd116b2 | ||
|
|
da40245fa6 | ||
|
|
70bf4d6654 | ||
|
|
080a5b9c74 | ||
|
|
b0be0b2dca | ||
|
|
d8300436c9 |
No files matched your search
@@ -194,6 +194,19 @@
|
||||
### Changes
|
||||
- Changed pokemon caught and seen count to update based on the current pokedex being looked
|
||||
- Renamed `chargeGainedPerTick` config to `secondsToChargeHealingMachine`.
|
||||
- Added config setting `maxPokedexScanningDetectionRange` to control from what distance the player can scan Pokémon using the Pokédex.
|
||||
- Added the `is_standing_on_blocks(depth, blocks...)` MoLang function, which returns whether the specified entity is standing on a specific block or set of blocks. Example usage: `q.is_standing_on_blocks(2, minecraft:sand)`
|
||||
- Added config setting `hideUnimplementedPokemonInThePokedex` which hides unimplemented Pokémon from the Pokédex when set to true.
|
||||
- Added molang particle queries for getting distance to targeted entities
|
||||
- Added debug renderer for poseable entity locators
|
||||
- Added time zone as a config option
|
||||
- Added optional boolean to use time zone for MoLang function "date_local_time" and "date_of"
|
||||
- Added "irlDateRange" and "irlTimeRange" as a condition for spawning
|
||||
- Added an optional MoValue to either use system timezone when set as true, or use the supplied string as a timezone for MoLang functions `date_local_time` and `date_of`. If the timezone supplied fails to parse this function now returns `0.0`.
|
||||
|
||||
### Additions
|
||||
- Added time zone as a config option
|
||||
- Added optional boolean to use time zone for MoLang function "date_local_time" and "date_of"
|
||||
- Made Blocks of Gold count as Big Nuggets when held by a Pokémon (for Fling functionality)
|
||||
- Players can now eat Sweet and Tart Apples, Whipped Dreams, and the Alcremie Sweets.
|
||||
- Updated Sweet and Tart Apple sprites
|
||||
@@ -398,6 +411,7 @@
|
||||
- Added `q.has_argument(<argument_name>, [argument_value])` MoLang function to several battle-related action effect contexts.
|
||||
- Added `q.has_argument_at(<index>, [argument_value])` MoLang function to several battle-related action effect contexts.
|
||||
- Added `q.hit_count` MoLang function to move action effect contexts.
|
||||
- Added `is_included`, `to_lower`, `to_upper`, and `string_length` as available Molang functions.
|
||||
|
||||
## [1.6.1 (January 26th, 2025)](#1-6-1)
|
||||
|
||||
|
||||
@@ -143,6 +143,12 @@ import net.minecraft.world.level.levelgen.Heightmap
|
||||
import net.minecraft.world.level.pathfinder.PathType
|
||||
import net.minecraft.world.phys.AABB
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import java.time.Instant
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.ZoneOffset
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Holds a bunch of useful MoLang trickery that can be used or extended in API
|
||||
@@ -168,6 +174,20 @@ object MoLangFunctions {
|
||||
val replace = params.getString(2)
|
||||
return@Function StringValue(text.replace(search, replace))
|
||||
},
|
||||
"is_included" to java.util.function.Function { params ->
|
||||
val text = params.getString(0)
|
||||
val search = params.getString(1)
|
||||
return@Function DoubleValue(text.contains(search))
|
||||
},
|
||||
"to_lower" to java.util.function.Function { params ->
|
||||
return@Function StringValue(params.getString(0).lowercase())
|
||||
},
|
||||
"to_upper" to java.util.function.Function { params ->
|
||||
return@Function StringValue(params.getString(0).uppercase())
|
||||
},
|
||||
"string_length" to java.util.function.Function { params ->
|
||||
return@Function DoubleValue(params.getString(0).length)
|
||||
},
|
||||
"is_blank" to java.util.function.Function { params ->
|
||||
val arg = params.get<MoValue>(0)
|
||||
return@Function DoubleValue((arg is StringValue && (arg.value.isBlank() || arg.value.toDoubleOrNull() == 0.0)) || (arg is DoubleValue && arg.value == 0.0))
|
||||
@@ -275,16 +295,44 @@ object MoLangFunctions {
|
||||
DoubleValue(System.currentTimeMillis())
|
||||
},
|
||||
// the rest of the world use dd/MM/yyyy grow up america (this comment was generated by copilot)
|
||||
"date_local_time" to java.util.function.Function { _ ->
|
||||
val time = System.currentTimeMillis()
|
||||
val date = java.util.Date(time)
|
||||
val formatted = java.text.SimpleDateFormat("DD/MM/YYYY").format(date)
|
||||
"date_local_time" to java.util.function.Function { params ->
|
||||
val useTimeZone = params.get<MoValue>(0)
|
||||
var timezone: ZoneId? = null
|
||||
if (useTimeZone is DoubleValue){
|
||||
timezone = if (useTimeZone.value == 1.0) Cobblemon.config.timeZoneId else null
|
||||
} else if (useTimeZone is StringValue){
|
||||
try {
|
||||
timezone = ZoneId.of(useTimeZone.value)
|
||||
} catch (_: Exception) {
|
||||
Cobblemon.LOGGER.error("Error parsing timezone: ${useTimeZone.value}")
|
||||
return@Function DoubleValue.ZERO
|
||||
}
|
||||
}
|
||||
|
||||
val date: LocalDateTime = if (timezone != null) LocalDateTime.now(timezone) else LocalDateTime.now()
|
||||
val formatted = DateTimeFormatter.ofPattern("dd/MM/uuuu").format(date)
|
||||
StringValue(formatted)
|
||||
},
|
||||
"date_of" to java.util.function.Function { params ->
|
||||
val time = params.getDouble(0).toLong()
|
||||
val useTimeZone = params.get<MoValue>(1)
|
||||
var timezone: ZoneId? = null
|
||||
if (useTimeZone is DoubleValue){
|
||||
timezone = if (useTimeZone.value == 1.0) Cobblemon.config.timeZoneId else null
|
||||
} else if (useTimeZone is StringValue){
|
||||
try {
|
||||
timezone = ZoneId.of(useTimeZone.value)
|
||||
} catch (_: Exception) {
|
||||
Cobblemon.LOGGER.error("Error parsing timezone: ${useTimeZone.value}")
|
||||
return@Function DoubleValue.ZERO
|
||||
}
|
||||
}
|
||||
|
||||
val date = java.util.Date(time)
|
||||
val formatted = java.text.SimpleDateFormat("DD/MM/YYYY").format(date)
|
||||
val instant: Instant = date.toInstant()
|
||||
val formatted = DateTimeFormatter.ofPattern("dd/MM/uuuu").format(LocalDateTime.ofInstant(instant,
|
||||
timezone ?: ZoneOffset.systemDefault()
|
||||
))
|
||||
StringValue(formatted)
|
||||
},
|
||||
"date_is_after" to java.util.function.Function { params ->
|
||||
@@ -646,7 +694,7 @@ object MoLangFunctions {
|
||||
map
|
||||
}
|
||||
)
|
||||
val itemStackFunctions = mutableListOf<(ItemStack, RegistryAccess) -> HashMap<String, java.util.function.Function<MoParams, Any>>>(
|
||||
val itemStackFunctions = mutableListOf<(ItemStack, RegistryAccess) -> java.util.HashMap<String, java.util.function.Function<MoParams, Any>>>(
|
||||
{ stack, registryAccess ->
|
||||
val itemRegistry = registryAccess.registryOrThrow(Registries.ITEM)
|
||||
val holder = itemRegistry.wrapAsHolder(stack.item)
|
||||
@@ -665,7 +713,7 @@ object MoLangFunctions {
|
||||
}
|
||||
)
|
||||
|
||||
val entityFunctions: MutableList<(Entity) -> HashMap<String, java.util.function.Function<MoParams, Any>>> = mutableListOf(
|
||||
val entityFunctions: MutableList<(Entity) -> java.util.HashMap<String, java.util.function.Function<MoParams, Any>>> = mutableListOf(
|
||||
{ entity ->
|
||||
val map = hashMapOf<String, java.util.function.Function<MoParams, Any>>()
|
||||
map.put("uuid") { _ -> StringValue(entity.uuid.toString()) }
|
||||
@@ -903,7 +951,7 @@ object MoLangFunctions {
|
||||
}
|
||||
)
|
||||
|
||||
val livingEntityFunctions: MutableList<(LivingEntity) -> HashMap<String, java.util.function.Function<MoParams, Any>>> = mutableListOf<(LivingEntity) -> HashMap<String, java.util.function.Function<MoParams, Any>>>(
|
||||
val livingEntityFunctions: MutableList<(LivingEntity) -> java.util.HashMap<String, java.util.function.Function<MoParams, Any>>> = mutableListOf<(LivingEntity) -> java.util.HashMap<String, java.util.function.Function<MoParams, Any>>>(
|
||||
{ entity ->
|
||||
val map = hashMapOf<String, java.util.function.Function<MoParams, Any>>()
|
||||
map.put("is_living_entity") { DoubleValue.ONE }
|
||||
@@ -1972,7 +2020,7 @@ object MoLangFunctions {
|
||||
}
|
||||
)
|
||||
|
||||
val pokemonPropertiesFunctions: MutableList<(PokemonProperties) -> HashMap<String, java.util.function.Function<MoParams, Any>>> = mutableListOf(
|
||||
val pokemonPropertiesFunctions: MutableList<(PokemonProperties) -> java.util.HashMap<String, java.util.function.Function<MoParams, Any>>> = mutableListOf(
|
||||
{ props ->
|
||||
val map = hashMapOf<String, java.util.function.Function<MoParams, Any>>()
|
||||
|
||||
@@ -2030,7 +2078,7 @@ object MoLangFunctions {
|
||||
}
|
||||
)
|
||||
|
||||
val evolutionFunctions: MutableList<(Evolution) -> HashMap<String, java.util.function.Function<MoParams, Any>>> = mutableListOf(
|
||||
val evolutionFunctions: MutableList<(Evolution) -> java.util.HashMap<String, java.util.function.Function<MoParams, Any>>> = mutableListOf(
|
||||
{ evolution ->
|
||||
val map = hashMapOf<String, java.util.function.Function<MoParams, Any>>()
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.spawning
|
||||
|
||||
import java.time.LocalDate
|
||||
|
||||
open class IrlDateRange (
|
||||
val startDate: LocalDate,
|
||||
val stopDate: LocalDate? = null
|
||||
) {
|
||||
operator fun contains(date: LocalDate): Boolean {
|
||||
return if(stopDate != null) {
|
||||
(startDate.isEqual(date) || startDate.isBefore(date)) && (stopDate.isAfter(date) || stopDate.isEqual(date))
|
||||
} else {
|
||||
startDate.isEqual(date)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.spawning
|
||||
|
||||
import java.time.LocalTime
|
||||
|
||||
open class IrlTimeRange(
|
||||
val startTime: LocalTime,
|
||||
val stopTime: LocalTime
|
||||
) {
|
||||
operator fun contains(time: LocalTime): Boolean {
|
||||
return (time.isAfter(startTime) || time == startTime) && time.isBefore(stopTime)
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,8 @@ object SpawnLoader {
|
||||
.registerTypeAdapter(NPCClass::class.java, NPCClassReferenceAdapter)
|
||||
.registerTypeAdapter(Expression::class.java, ExpressionAdapter)
|
||||
.registerTypeAdapter(ExpressionLike::class.java, ExpressionLikeAdapter)
|
||||
.registerTypeAdapter(IrlTimeRange::class.java, IrlTimeRangeAdapter)
|
||||
.registerTypeAdapter(IrlDateRange::class.java, IrlDateRangeAdapter)
|
||||
.create()
|
||||
|
||||
var deserializingConditionClass: Class<out SpawningCondition<*>>? = null
|
||||
|
||||
+15
@@ -8,7 +8,10 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.spawning.condition
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.conditional.RegistryLikeCondition
|
||||
import com.cobblemon.mod.common.api.spawning.IrlDateRange
|
||||
import com.cobblemon.mod.common.api.spawning.IrlTimeRange
|
||||
import com.cobblemon.mod.common.api.spawning.MoonPhaseRange
|
||||
import com.cobblemon.mod.common.api.spawning.TimeRange
|
||||
import com.cobblemon.mod.common.api.spawning.position.SpawnablePosition
|
||||
@@ -21,6 +24,8 @@ import net.minecraft.tags.TagKey
|
||||
import net.minecraft.world.level.biome.Biome
|
||||
import net.minecraft.world.level.levelgen.WorldgenRandom
|
||||
import net.minecraft.world.level.levelgen.structure.Structure
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalTime
|
||||
|
||||
/**
|
||||
* The root of spawning conditions that can be applied to a spawnable position. What type
|
||||
@@ -58,6 +63,8 @@ abstract class SpawningCondition<T : SpawnablePosition> {
|
||||
var timeRange: TimeRange? = null
|
||||
var structures: MutableList<Either<ResourceLocation, TagKey<Structure>>>? = null
|
||||
var isSlimeChunk: Boolean? = null
|
||||
var irlTimeRange: IrlTimeRange? = null
|
||||
var irlDateRange: IrlDateRange? = null
|
||||
var markers: MutableList<String>? = null
|
||||
|
||||
@Transient
|
||||
@@ -129,6 +136,10 @@ abstract class SpawningCondition<T : SpawnablePosition> {
|
||||
|
||||
val random = Random(seed)
|
||||
return random.nextInt(10) == 0*/
|
||||
} else if (irlTimeRange != null && !irlTimeRange!!.contains(LocalTime.now(Cobblemon.config.timeZoneId))){
|
||||
return false
|
||||
} else if (irlDateRange != null && !irlDateRange!!.contains(LocalDate.now(Cobblemon.config.timeZoneId))){
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
@@ -160,6 +171,10 @@ abstract class SpawningCondition<T : SpawnablePosition> {
|
||||
return false
|
||||
if (structures != null && structures!!.any { it == null })
|
||||
return false
|
||||
if(irlTimeRange != null && irlTimeRange!!.stopTime.isBefore(irlTimeRange!!.startTime))
|
||||
return false
|
||||
if(irlDateRange != null && irlDateRange!!.stopDate != null && irlDateRange!!.stopDate!!.isBefore(irlDateRange!!.startDate))
|
||||
return false
|
||||
return true
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -758,6 +758,8 @@ open class PosableModel(@Transient override val rootPart: Bone) : ModelFrame {
|
||||
yRot = Mth.lerp(state.getPartialTicks(), entity.yBodyRotO, entity.yBodyRot)
|
||||
yRot = 180f - Mth.wrapDegrees(yRot)
|
||||
}
|
||||
//For some reason locators are positioned upside-down so this fixes that
|
||||
matrixStack.mulPose(Axis.ZP.rotationDegrees(180f))
|
||||
} else if (entity is EmptyPokeBallEntity) {
|
||||
scale = 0.7F
|
||||
yRot = Mth.lerp(state.getPartialTicks(), entity.yRot, entity.yRotO)
|
||||
@@ -773,9 +775,6 @@ open class PosableModel(@Transient override val rootPart: Bone) : ModelFrame {
|
||||
matrixStack.scale(scale, scale, scale)
|
||||
matrixStack.mulPose(Axis.YP.rotationDegrees(yRot))
|
||||
|
||||
//For some reason locators are positioned upside-down so this fixes that
|
||||
matrixStack.mulPose(Axis.ZP.rotationDegrees(180f))
|
||||
|
||||
locatorAccess.update(matrixStack, entity, scale, state.locatorStates, isRoot = true)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ enum class Category(val lang: String) {
|
||||
Pokedex("pokedex"),
|
||||
Storage("storage"),
|
||||
Starter("starter"),
|
||||
System("system"),
|
||||
Interface("interface"),
|
||||
Riding("riding"),
|
||||
Debug("debug"),
|
||||
|
||||
@@ -16,8 +16,11 @@ import com.cobblemon.mod.common.config.constraint.IntConstraint
|
||||
import com.cobblemon.mod.common.pokeball.catching.calculators.CobblemonCaptureCalculator
|
||||
import com.cobblemon.mod.common.util.adapters.CaptureCalculatorAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.IntRangeAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.ZoneIdAdapter
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import java.time.ZoneId
|
||||
import java.time.ZoneOffset
|
||||
import kotlin.reflect.full.memberProperties
|
||||
import kotlin.reflect.jvm.isAccessible
|
||||
|
||||
@@ -29,6 +32,7 @@ class CobblemonConfig {
|
||||
.registerTypeAdapter(IntRange::class.java, IntRangeAdapter)
|
||||
.registerTypeAdapter(ItemDropMethod::class.java, ItemDropMethod.adapter)
|
||||
.registerTypeAdapter(CaptureCalculator::class.java, CaptureCalculatorAdapter)
|
||||
.registerTypeHierarchyAdapter(ZoneId::class.java, ZoneIdAdapter)
|
||||
.create()
|
||||
}
|
||||
|
||||
@@ -263,6 +267,9 @@ class CobblemonConfig {
|
||||
@CobblemonConfigField(Category.Pokedex, lang = "hide_unimplemented_pokemon_in_the_pokedex")
|
||||
var hideUnimplementedPokemonInThePokedex = false
|
||||
|
||||
@CobblemonConfigField(Category.System, lang = "time_zone_id")
|
||||
var timeZoneId: ZoneId = ZoneOffset.systemDefault()
|
||||
|
||||
@CobblemonConfigField(Category.Interface, lang = "summary_pokemon_follow_cursor")
|
||||
var summaryPokemonFollowCursor = true
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.util.adapters
|
||||
|
||||
import com.cobblemon.mod.common.api.spawning.IrlDateRange
|
||||
import com.google.gson.JsonDeserializationContext
|
||||
import com.google.gson.JsonDeserializer
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonPrimitive
|
||||
import com.google.gson.JsonSerializationContext
|
||||
import com.google.gson.JsonSerializer
|
||||
import java.lang.reflect.Type
|
||||
import java.time.LocalDate
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
object IrlDateRangeAdapter: JsonSerializer<IrlDateRange>, JsonDeserializer<IrlDateRange> {
|
||||
val dateFormat: DateTimeFormatter = DateTimeFormatter.ofPattern("M/d")
|
||||
//parsing dates requires a year instead of just assuming this year so we do jank
|
||||
val dateFormatWithYear: DateTimeFormatter = DateTimeFormatter.ofPattern("uuuu/M/d")
|
||||
|
||||
override fun serialize(
|
||||
src: IrlDateRange,
|
||||
typeOfSrc: Type,
|
||||
context: JsonSerializationContext
|
||||
): JsonElement {
|
||||
return if(src.stopDate != null){
|
||||
JsonPrimitive(src.startDate.format(dateFormat) + "-" + src.stopDate.format(dateFormat))
|
||||
} else {
|
||||
JsonPrimitive(src.startDate.format(dateFormat))
|
||||
}
|
||||
}
|
||||
|
||||
override fun deserialize(
|
||||
json: JsonElement,
|
||||
typeOfT: Type,
|
||||
context: JsonDeserializationContext
|
||||
): IrlDateRange {
|
||||
val year = LocalDate.now().year.toString()
|
||||
|
||||
return if(json.asString.contains("-")){
|
||||
val dateStrings = json.asString.split("-")
|
||||
IrlDateRange(
|
||||
startDate = LocalDate.parse(year + "/" + dateStrings[0], dateFormatWithYear),
|
||||
stopDate = LocalDate.parse(year + "/" + dateStrings[1], dateFormatWithYear)
|
||||
)
|
||||
} else {
|
||||
IrlDateRange(
|
||||
startDate = LocalDate.parse(year + "/" + json.asString, dateFormatWithYear)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.util.adapters
|
||||
|
||||
import com.cobblemon.mod.common.api.spawning.IrlTimeRange
|
||||
import com.google.gson.JsonDeserializationContext
|
||||
import com.google.gson.JsonDeserializer
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonPrimitive
|
||||
import com.google.gson.JsonSerializationContext
|
||||
import com.google.gson.JsonSerializer
|
||||
import java.lang.reflect.Type
|
||||
import java.time.LocalTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
object IrlTimeRangeAdapter: JsonSerializer<IrlTimeRange>, JsonDeserializer<IrlTimeRange> {
|
||||
val timeFormat: DateTimeFormatter = DateTimeFormatter.ofPattern("H:mm")
|
||||
|
||||
override fun serialize(
|
||||
src: IrlTimeRange,
|
||||
typeOfSrc: Type,
|
||||
context: JsonSerializationContext
|
||||
): JsonElement {
|
||||
return JsonPrimitive(src.startTime.format(timeFormat) + "-" + src.stopTime.format(timeFormat))
|
||||
}
|
||||
|
||||
override fun deserialize(
|
||||
json: JsonElement,
|
||||
typeOfT: Type,
|
||||
context: JsonDeserializationContext
|
||||
): IrlTimeRange {
|
||||
val timeStrings = json.asString.split("-")
|
||||
return IrlTimeRange(
|
||||
startTime = LocalTime.parse(timeStrings[0], timeFormat),
|
||||
stopTime = LocalTime.parse(timeStrings[1], timeFormat)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.util.adapters
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.google.gson.JsonDeserializationContext
|
||||
import com.google.gson.JsonDeserializer
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonPrimitive
|
||||
import com.google.gson.JsonSerializationContext
|
||||
import com.google.gson.JsonSerializer
|
||||
import java.lang.reflect.Type
|
||||
import java.time.ZoneId
|
||||
import java.time.ZoneOffset
|
||||
|
||||
|
||||
/**
|
||||
* A type adapter for [ZoneOffset]s.
|
||||
* This will never fail to deserialize and will instead default to the System's default time zone and log an error message.
|
||||
*
|
||||
* @author JPAK
|
||||
* @since December 26, 2024
|
||||
*/
|
||||
object ZoneIdAdapter: JsonSerializer<ZoneId>, JsonDeserializer<ZoneId> {
|
||||
override fun serialize(
|
||||
src: ZoneId,
|
||||
typeOfSrc: Type,
|
||||
context: JsonSerializationContext
|
||||
): JsonElement {
|
||||
return JsonPrimitive(src.id)
|
||||
}
|
||||
|
||||
override fun deserialize(
|
||||
json: JsonElement,
|
||||
typeOfT: Type,
|
||||
context: JsonDeserializationContext
|
||||
): ZoneId {
|
||||
return try {
|
||||
ZoneId.of(json.asString)
|
||||
} catch (_: Exception) {
|
||||
Cobblemon.LOGGER.error("Failed to load ZoneId from the ID {}, defaulting to the system time zone", json.asString)
|
||||
ZoneOffset.systemDefault()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2382,6 +2382,7 @@
|
||||
"cobblemon.config.ui.category.interface": "Interface",
|
||||
"cobblemon.config.ui.category.riding": "Riding",
|
||||
"cobblemon.config.ui.category.debug": "Debug",
|
||||
"cobblemon.config.ui.category.system": "System",
|
||||
|
||||
"cobblemon.config.ui.max_pokemon_level": "Max Pokémon Level",
|
||||
"cobblemon.config.ui.max_pokemon_level.tooltip": "The maximum level Pokémon can get to.",
|
||||
@@ -2564,6 +2565,8 @@
|
||||
"cobblemon.config.ui.despawner_max_age_ticks.tooltip": "The age (in game ticks) a Pokémon must reach before it can be despawned at the near distance boundary.",
|
||||
"cobblemon.config.ui.enable_debug_keys": "Enable Debug Keys",
|
||||
"cobblemon.config.ui.enable_debug_keys.tooltip": "Enables additional commands and chat logging to assist with implementing Pokémon (see the wiki for a list of commands).",
|
||||
"cobblemon.config.ui.time_zone_id": "Time Zone Id",
|
||||
"cobblemon.config.ui.time_zone_id.tooltip": "Time Zone to use for some MoLangs and IRL time zone dates. Server Side only.",
|
||||
|
||||
"cobblemon.config.ui.allow_starter_on_join": "Allow Starter on Join",
|
||||
"cobblemon.config.ui.prompt_starter_once_only": "Prompt Starter Once Only",
|
||||
|
||||
+21
-5
@@ -2,7 +2,7 @@
|
||||
"type": "minecraft:chest",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"rolls": 3,
|
||||
"bonus_rolls": 0.0,
|
||||
"entries": [
|
||||
{
|
||||
@@ -12,8 +12,8 @@
|
||||
"add": false,
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 3.0,
|
||||
"min": 9.0
|
||||
"max": 1.0,
|
||||
"min": 3.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
@@ -29,12 +29,28 @@
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 1.0,
|
||||
"min": 3.0
|
||||
"min": 1.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
],
|
||||
"name": "cobblemon:rare_candy",
|
||||
"name": "cobblemon:exp_candy_m",
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"functions": [
|
||||
{
|
||||
"add": false,
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 1.0,
|
||||
"min": 1.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
],
|
||||
"name": "minecraft:golden_apple",
|
||||
"weight": 10
|
||||
}
|
||||
]
|
||||
|
||||
+22
-6
@@ -2,7 +2,7 @@
|
||||
"type": "minecraft:chest",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"rolls": 6,
|
||||
"bonus_rolls": 0.0,
|
||||
"entries": [
|
||||
{
|
||||
@@ -12,8 +12,8 @@
|
||||
"add": false,
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 6.0,
|
||||
"min": 18.0
|
||||
"max": 1.0,
|
||||
"min": 3.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
@@ -28,13 +28,29 @@
|
||||
"add": false,
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 3.0,
|
||||
"min": 5.0
|
||||
"max": 1.0,
|
||||
"min": 2.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
],
|
||||
"name": "cobblemon:rare_candy",
|
||||
"name": "cobblemon:exp_candy_m",
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"functions": [
|
||||
{
|
||||
"add": false,
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 1.0,
|
||||
"min": 2.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
],
|
||||
"name": "minecraft:golden_apple",
|
||||
"weight": 10
|
||||
}
|
||||
]
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ t.wander_control = q.entity.get_wander_control_memory();
|
||||
t.wander_control.reset();
|
||||
|
||||
t.wander_control.set_allow_land((q.entity.behaviour.moving.walk.can_walk && !q.entity.behaviour.moving.walk.avoids_land) || (!q.entity.behaviour.moving.walk.can_walk && q.entity.behaviour.moving.fly.can_fly));
|
||||
t.wander_control.set_allow_water(q.entity.behaviour.moving.swim.can_swim && !q.entity.behaviour.moving.swim.avoids_water);
|
||||
t.wander_control.set_allow_water(q.entity.behaviour.moving.swim.can_swim_in_water && !q.entity.behaviour.moving.swim.avoids_water);
|
||||
t.wander_control.set_allow_air(q.entity.behaviour.moving.fly.can_fly && !q.entity.behaviour.moving.walk.can_walk);
|
||||
|
||||
t.wander_control.set_walk_speed(0.35);
|
||||
Binary file not shown.
Reference in new issue
Block a user