diff --git a/CHANGELOG.md b/CHANGELOG.md index 59745d1d91..8e1d045530 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,8 @@ - Restructured Botany Pots integration folder structure - Decrease default pastured mon wander radius to 32. - Factor in the weight of pokemon when calculating pushing forces between hitboxes. -- Remade the Starter Selection Screen with new assets +- Remade the Starter Selection Screen with new assets +- Refactored berry trees to be less impactful on TPS (more performant) ### Fixes - Fixes https://gitlab.com/cable-mc/cobblemon/-/issues/1943 @@ -31,6 +32,7 @@ - Fix occasional crash on retrieving revived fossils - [Various Submarine Ride Fixes](https://gitlab.com/cable-mc/cobblemon/-/merge_requests/2157) - Fix Pastured mons despawning and running away. + - Fix Apricorn trees crashing when other mods bonemeal it ### Developer diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/block/ApricornBlock.kt b/common/src/main/kotlin/com/cobblemon/mod/common/block/ApricornBlock.kt index 81ebda374c..4c8b2a447c 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/block/ApricornBlock.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/block/ApricornBlock.kt @@ -133,7 +133,10 @@ class ApricornBlock(settings: Properties, val apricorn: Apricorn) : HorizontalDi override fun isBonemealSuccess(world: Level, random: RandomSource, pos: BlockPos, state: BlockState) = true override fun performBonemeal(world: ServerLevel, random: RandomSource, pos: BlockPos, state: BlockState) { - world.setBlock(pos, state.setValue(AGE, state.getValue(AGE) + 1), 2) + val curAge = state.getValue(AGE) + val newAge = curAge + 1 + if (newAge > MAX_AGE) return + world.setBlock(pos, state.setValue(AGE, newAge), UPDATE_CLIENTS) } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { @@ -186,17 +189,17 @@ class ApricornBlock(settings: Properties, val apricorn: Apricorn) : HorizontalDi * This uses [Block.dropResources] to handle the drops. * It will also reset the [BlockState] of this block at the given location to the start of growth. * - * @param world The [World] the apricorn is in. + * @param world The [Level] the apricorn is in. * @param state The [BlockState] of the apricorn. * @param pos The [BlockPos] of the apricorn. * @return The [BlockState] after harvest. */ fun harvest(world: Level, state: BlockState, pos: BlockPos): BlockState { // Uses loot tables, to change the drops use 'data/cobblemon/loot_tables/blocks/_apricorn.json' - Block.dropResources(state, world, pos) + dropResources(state, world, pos) // Don't use default as we want to keep the facing val resetState = state.setValue(AGE, MIN_AGE) - world.setBlock(pos, resetState, Block.UPDATE_CLIENTS) + world.setBlock(pos, resetState, UPDATE_CLIENTS) return resetState }