From 3aea09b793cbed1d9b59c4023d54843dbdff178d Mon Sep 17 00:00:00 2001 From: hlam9 Date: Fri, 13 Mar 2026 15:06:56 -0700 Subject: [PATCH] lunar shrine consume fix and zygarde cell delete function --- .vscode/settings.json | 3 + .../common/world/entity/ZygardeCellEntity.kt | 15 ++-- .../level/block/shrines/LunarShrineBlock.kt | 2 +- .../dialogues/zygarde_cube.json | 69 ++++++++++++++++--- 4 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..8f2b7113d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.compile.nullAnalysis.mode": "disabled" +} \ No newline at end of file diff --git a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/entity/ZygardeCellEntity.kt b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/entity/ZygardeCellEntity.kt index 85f6f31ee..ac95609f5 100644 --- a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/entity/ZygardeCellEntity.kt +++ b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/entity/ZygardeCellEntity.kt @@ -1,5 +1,7 @@ package generations.gg.generations.core.generationscore.common.world.entity +import com.cobblemon.mod.common.api.dialogue.Dialogues +import com.cobblemon.mod.common.util.openDialogue import generations.gg.generations.core.generationscore.common.GenerationsCore import generations.gg.generations.core.generationscore.common.client.render.rarecandy.BlockObjectInstance import generations.gg.generations.core.generationscore.common.client.render.rarecandy.instanceOrNull @@ -37,10 +39,16 @@ class ZygardeCellEntity : Entity { } override fun interact(player: Player, hand: InteractionHand): InteractionResult { - if(hand != InteractionHand.MAIN_HAND) return InteractionResult.PASS; - val serverPlayer = player.instanceOrNull() ?: return InteractionResult.PASS; + if (hand != InteractionHand.MAIN_HAND) return InteractionResult.PASS + val serverPlayer = player.instanceOrNull() ?: return InteractionResult.PASS val stack = player.mainHandItem.takeIf { it.`is`(GenerationsItems.ZYGARDE_CUBE) } ?: return InteractionResult.PASS + if (serverPlayer.isShiftKeyDown) { + val dialogue = Dialogues.dialogues[GenerationsCore.id("zygarde_cell")] ?: return InteractionResult.PASS + serverPlayer.openDialogue(dialogue) + return InteractionResult.SUCCESS + } + //Note: I'm treating Boolean? like a tristate here. True and null allow while false doesn't. This is to allow an alternate overflow message when taking a cell when full. val allowed = if(stack.damageValue != ZygardeCubeItem.FULL) true else if(GenerationsCore.CONFIG.legendary.enableZygardeCubeOverflow) null else false if (allowed != false) { @@ -58,7 +66,6 @@ class ZygardeCellEntity : Entity { 1.0f ) - remove(RemovalReason.DISCARDED) player.cooldowns.addCooldown(stack.item, 20) @@ -81,4 +88,4 @@ class ZygardeCellEntity : Entity { override fun isPickable(): Boolean { return true } -} +} \ No newline at end of file diff --git a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/level/block/shrines/LunarShrineBlock.kt b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/level/block/shrines/LunarShrineBlock.kt index 4989b7bf1..de2f05e37 100644 --- a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/level/block/shrines/LunarShrineBlock.kt +++ b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/level/block/shrines/LunarShrineBlock.kt @@ -90,7 +90,7 @@ class LunarShrineBlock(properties: Properties) : ShrineBlock(properties = proper // player.getItemInHand(hand).shrink(1) PokemonUtil.spawn(key.createProperties(70), level, shrine.blockPos.above()) - return ItemInteractionResult.SUCCESS + return ItemInteractionResult.CONSUME } } } diff --git a/common/src/main/resources/data/generations_core/dialogues/zygarde_cube.json b/common/src/main/resources/data/generations_core/dialogues/zygarde_cube.json index a4a5b3ae7..9876af8ad 100644 --- a/common/src/main/resources/data/generations_core/dialogues/zygarde_cube.json +++ b/common/src/main/resources/data/generations_core/dialogues/zygarde_cube.json @@ -34,6 +34,15 @@ "isVisible": "q.player.has_in_party('cobblemon:zygarde')", "action": "q.dialogue.set_page('select_zygarde_dissolve');" }, + { + "text": "Delete Cells", + "value": "delete_cells", + "isVisible": "q.player.selected_item.damage > 0", + "action": [ + "v.cells_to_delete = q.player.selected_item.damage;", + "q.dialogue.set_page('confirm_delete_cells');" + ] + }, { "text": "Close", "value": "close", @@ -42,6 +51,48 @@ ] } }, + { + "id": "confirm_delete_cells", + "speaker": "player", + "lines": [ + "Are you sure? This cannot be undone!", + { + "type": "expression", + "expression": "'All ' + v.cells_to_delete + ' cells will be permanently deleted.'" + } + ], + "input": { + "type": "option", + "options": [ + { + "text": "Yes, delete them", + "value": "confirm", + "action": [ + "q.player.selected_item.damage(-v.cells_to_delete);", + "q.dialogue.set_page('cells_deleted');" + ] + }, + { + "text": "No, keep them", + "value": "cancel", + "action": "q.dialogue.set_page('main_menu');" + } + ] + } + }, + { + "id": "cells_deleted", + "speaker": "player", + "lines": [ + "All cells have been deleted from your Zygarde Cube." + ], + "input": { + "type": "auto-continue", + "delay": 2, + "allowSkip": false, + "action": "q.dialogue.close();" + } + }, { "id": "select_zygarde_modify", "speaker": "player", @@ -501,20 +552,20 @@ "action": [ "v.form = '10%';", "v.cells_needed = 10;", - "v.ability = 'aurabreak';", - "v.ability_string_cheese = 'Aura Break';", + "v.ability = 'aurabreak';", + "v.ability_string_cheese = 'Aura Break';", "q.dialogue.set_page('confirm_create');" ] }, - { + { "text": "10% PowerConstruct", "value": "60", "isVisible": "q.player.selected_item.damage >= 60", "action": [ "v.form = '10%';", "v.cells_needed = 60;", - "v.ability = 'powerconstruct';", - "v.ability_string_cheese = 'Power Construct';", + "v.ability = 'powerconstruct';", + "v.ability_string_cheese = 'Power Construct';", "q.dialogue.set_page('confirm_create');" ] }, @@ -525,8 +576,8 @@ "action": [ "v.form = '50%';", "v.cells_needed = 50;", - "v.ability = 'aurabreak';", - "v.ability_string_cheese = 'Aura Break';", + "v.ability = 'aurabreak';", + "v.ability_string_cheese = 'Aura Break';", "q.dialogue.set_page('confirm_create');" ] }, @@ -537,8 +588,8 @@ "action": [ "v.form = '50%';", "v.cells_needed = 100;", - "v.ability = 'powerconstruct';", - "v.ability_string_cheese = 'Power Construct';", + "v.ability = 'powerconstruct';", + "v.ability_string_cheese = 'Power Construct';", "q.dialogue.set_page('confirm_create');" ] },