Skip to content

Commit

Permalink
Fix at spam issue with time capsules.
Browse files Browse the repository at this point in the history
  • Loading branch information
Waterpicker committed Dec 6, 2024
1 parent 62eaef0 commit a86eb5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import com.mojang.blaze3d.platform.Lighting
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.PoseStack
import generations.gg.generations.core.generationscore.common.client.model.RareCandyBone
import generations.gg.generations.core.generationscore.common.util.getRenderablePokemon
import generations.gg.generations.core.generationscore.common.world.item.StatueSpawnerItem
import generations.gg.generations.core.generationscore.common.world.item.TimeCapsule
import generations.gg.generations.core.generationscore.common.world.item.TimeCapsule.Companion.getRenderablePokmon
import net.minecraft.client.renderer.LightTexture
import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.texture.OverlayTexture
Expand All @@ -28,7 +28,7 @@ object TimeCapsuleItemRenderer : CobblemonBuiltinItemRenderer {
override fun render(stack: ItemStack, mode: ItemDisplayContext, matrices: PoseStack, vertexConsumers: MultiBufferSource, light: Int, overlay: Int,
) {
if (stack.item is TimeCapsule || stack.item is StatueSpawnerItem || stack.item is PokemonItem) {
val (species, aspects) = (if(stack.item is PokemonItem) (stack.item as PokemonItem).getSpeciesAndAspects(stack) else stack.getRenderablePokmon()) ?: return
val (species, aspects) = (if(stack.item is PokemonItem) (stack.item as PokemonItem).getSpeciesAndAspects(stack) else stack.getRenderablePokemon()?.let { it.species to it.aspects }) ?: return

matrices.pushPose()
val model = PokemonModelRepository.getPoser(species.resourceIdentifier, aspects)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ class TimeCapsule(properties: Properties) : PokemonStoringItem(properties) {


companion object {
fun ItemStack.getRenderablePokmon(): Pair<Species, Set<String>>? = this.getPokemon()?.let { it.species to it.aspects }

fun registerItemProperty() {
ItemPropertiesRegistry.register(
GenerationsItems.TIME_CAPSULE.get(), GenerationsCore.id("has_pokemon")
) { itemStack: ItemStack, clientLevel: ClientLevel?, livingEntity: LivingEntity?, i: Int ->
if (itemStack.getRenderablePokmon() == null) 0f else 1f
if (itemStack.getRenderablePokemon() == null) 0f else 1f
}
}
}
Expand Down

0 comments on commit a86eb5f

Please sign in to comment.