From 802379ad2a4f7ae565ff7f26d9ddb68bfb18ecf2 Mon Sep 17 00:00:00 2001 From: VT-14 Date: Mon, 9 Oct 2023 20:27:32 -0400 Subject: [PATCH 1/3] Add Error Messages to the Downgrade Ritual This gives clear indications to the player about what is going wrong for the most commonly seen issues. * A Training Bracelet is blocking the Downgrade. * The player doesn't have enough of the Key Item (message appears if what they already have is >= what is in the chest, most likely they have level 1 and only 1 Key item in the chest). * The player doesn't have enough Upgrade Points in the chest to apply the Downgrades they are requesting. --- .../assets/bloodmagic/lang/en_us.json | 3 +++ .../common/data/GeneratorLanguage.java | 3 +++ .../ritual/types/RitualLivingDowngrade.java | 18 +++++++++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/generated/resources/assets/bloodmagic/lang/en_us.json b/src/generated/resources/assets/bloodmagic/lang/en_us.json index f8d39db29..b103e6411 100644 --- a/src/generated/resources/assets/bloodmagic/lang/en_us.json +++ b/src/generated/resources/assets/bloodmagic/lang/en_us.json @@ -118,6 +118,9 @@ "chat.bloodmagic.ritual.notValid": "You feel that these runes are not configured correctly...", "chat.bloodmagic.ritual.prevent": "The ritual is actively resisting you!", "chat.bloodmagic.ritual.weak": "You feel a push, but are too weak to perform this ritual.", + "chat.bloodmagic.ritualLivingDowngrade.notEnoughKeyItems": "You sense you need more of a \"Key Item\" to apply a stronger Downgrade.", + "chat.bloodmagic.ritualLivingDowngrade.notEnoughPoints": "You sense you will need more Upgrade Points to apply these Downgrades.", + "chat.bloodmagic.ritualLivingDowngrade.trainingBraceletBlock": "Your Training Bracelet shakes as it prevents the downgrade from being applied.", "chat.bloodmagic.routing.distance": "Invalid - link distance greater than 16 blocks!", "chat.bloodmagic.routing.link": "Linked nodes together.", "chat.bloodmagic.routing.link.master": "Linked node to master!", diff --git a/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java b/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java index bd37526a2..bbade904d 100644 --- a/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java +++ b/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java @@ -935,6 +935,9 @@ protected void addTranslations() add("chat.bloodmagic.ritual.activate", "A rush of energy flows through the ritual!"); add("chat.bloodmagic.ritual.notValid", "You feel that these runes are not configured correctly..."); add("chat.bloodmagic.diviner.blockedBuild", "Unable to replace block at %d, %d, %d."); + add("chat.bloodmagic.ritualLivingDowngrade.trainingBraceletBlock", "Your Training Bracelet shakes as it prevents the downgrade from being applied."); + add("chat.bloodmagic.ritualLivingDowngrade.notEnoughKeyItems", "You sense you need more of a \"Key Item\" to apply a stronger Downgrade."); + add("chat.bloodmagic.ritualLivingDowngrade.notEnoughPoints", "You sense you will need more Upgrade Points to apply these Downgrades."); // GUI add("gui.bloodmagic.empty", "Empty"); diff --git a/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java index 178c0957b..7be16b609 100644 --- a/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java +++ b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java @@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.network.chat.Component; import net.minecraft.world.Container; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LightningBolt; @@ -72,7 +73,6 @@ public void performRitual(IMasterRitualStone masterRitualStone) if (selectedPlayer == null) { - return; } @@ -171,6 +171,7 @@ public void performRitual(IMasterRitualStone masterRitualStone) // downgrade. 0 means nothing is added. Map pointDifferentialMap = new HashMap(); int totalDifferentialPoints = 0; + boolean notEnoughKeyItems = false; for (Entry entry : downgradeMap.entrySet()) { LivingUpgrade downgrade = entry.getKey(); @@ -178,11 +179,13 @@ public void performRitual(IMasterRitualStone masterRitualStone) int wantedLevel = Math.min(entry.getValue(), downgrade.getLevel(Integer.MAX_VALUE)); if (playerDowngradeLevel >= wantedLevel) { + notEnoughKeyItems = true; continue; } if (!LivingUtil.canTrain(selectedPlayer, downgrade, playerDowngradeLevel, wantedLevel)) { + selectedPlayer.displayClientMessage(Component.translatable("chat.bloodmagic.ritualLivingDowngrade.trainingBraceletBlock"), true); return; } @@ -201,14 +204,19 @@ public void performRitual(IMasterRitualStone masterRitualStone) } } - if (availablePoints < totalDifferentialPoints || priorityMap.isEmpty() || pointDifferentialMap.isEmpty()) + if (availablePoints < totalDifferentialPoints) { - // Can't upgrade! Not enough points - // TODO: Add smoke particles to indicate this? - + selectedPlayer.displayClientMessage(Component.translatable("chat.bloodmagic.ritualLivingDowngrade.notEnoughPoints"), true); + return; + } + if (priorityMap.isEmpty() || pointDifferentialMap.isEmpty()) + { + if (notEnoughKeyItems) + selectedPlayer.displayClientMessage(Component.translatable("chat.bloodmagic.ritualLivingDowngrade.notEnoughKeyItems"), true); return; } + List slotOrderList = new ArrayList<>(); List priorityList = new ArrayList<>(priorityMap.keySet()); From 7f94c06701a0453dec81a4c8916115916b3e8e1a Mon Sep 17 00:00:00 2001 From: VT-14 Date: Tue, 10 Oct 2023 11:16:08 -0400 Subject: [PATCH 2/3] Improved Downgrade Ritual Error Messages Changed the notEnoughKeyItems message to display the item's default name rather than the generic "Key Item". Minor grammar tweak to make it work. Changed the Training Bracelet's message from "shakes" to "vibrates." --- .../assets/bloodmagic/lang/en_us.json | 4 ++-- .../common/data/GeneratorLanguage.java | 4 ++-- .../ritual/types/RitualLivingDowngrade.java | 21 ++++++++++++++----- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/generated/resources/assets/bloodmagic/lang/en_us.json b/src/generated/resources/assets/bloodmagic/lang/en_us.json index b103e6411..bb22b028b 100644 --- a/src/generated/resources/assets/bloodmagic/lang/en_us.json +++ b/src/generated/resources/assets/bloodmagic/lang/en_us.json @@ -118,9 +118,9 @@ "chat.bloodmagic.ritual.notValid": "You feel that these runes are not configured correctly...", "chat.bloodmagic.ritual.prevent": "The ritual is actively resisting you!", "chat.bloodmagic.ritual.weak": "You feel a push, but are too weak to perform this ritual.", - "chat.bloodmagic.ritualLivingDowngrade.notEnoughKeyItems": "You sense you need more of a \"Key Item\" to apply a stronger Downgrade.", + "chat.bloodmagic.ritualLivingDowngrade.notEnoughKeyItems": "You sense you need more %s to apply a stronger Downgrade.", "chat.bloodmagic.ritualLivingDowngrade.notEnoughPoints": "You sense you will need more Upgrade Points to apply these Downgrades.", - "chat.bloodmagic.ritualLivingDowngrade.trainingBraceletBlock": "Your Training Bracelet shakes as it prevents the downgrade from being applied.", + "chat.bloodmagic.ritualLivingDowngrade.trainingBraceletBlock": "Your Training Bracelet vibrates as it prevents the downgrade from being applied.", "chat.bloodmagic.routing.distance": "Invalid - link distance greater than 16 blocks!", "chat.bloodmagic.routing.link": "Linked nodes together.", "chat.bloodmagic.routing.link.master": "Linked node to master!", diff --git a/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java b/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java index bbade904d..0c648fff9 100644 --- a/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java +++ b/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java @@ -935,8 +935,8 @@ protected void addTranslations() add("chat.bloodmagic.ritual.activate", "A rush of energy flows through the ritual!"); add("chat.bloodmagic.ritual.notValid", "You feel that these runes are not configured correctly..."); add("chat.bloodmagic.diviner.blockedBuild", "Unable to replace block at %d, %d, %d."); - add("chat.bloodmagic.ritualLivingDowngrade.trainingBraceletBlock", "Your Training Bracelet shakes as it prevents the downgrade from being applied."); - add("chat.bloodmagic.ritualLivingDowngrade.notEnoughKeyItems", "You sense you need more of a \"Key Item\" to apply a stronger Downgrade."); + add("chat.bloodmagic.ritualLivingDowngrade.trainingBraceletBlock", "Your Training Bracelet vibrates as it prevents the downgrade from being applied."); + add("chat.bloodmagic.ritualLivingDowngrade.notEnoughKeyItems", "You sense you need more %s to apply a stronger Downgrade."); add("chat.bloodmagic.ritualLivingDowngrade.notEnoughPoints", "You sense you will need more Upgrade Points to apply these Downgrades."); // GUI diff --git a/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java index 7be16b609..4ccfe9ea3 100644 --- a/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java +++ b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java @@ -100,6 +100,8 @@ public void performRitual(IMasterRitualStone masterRitualStone) Direction accessDir = Direction.DOWN; Map> priorityMap = new HashMap<>(); + // Contains the ItemStack used for each downgrade. Used for the insufficient level message. + Map downgradeItemStacksMap= new HashMap<>(); LazyOptional capability = tile.getCapability(ForgeCapabilities.ITEM_HANDLER, accessDir); if (capability.isPresent()) @@ -115,6 +117,7 @@ public void performRitual(IMasterRitualStone masterRitualStone) { int wantedLevel = getLevelFromStack(invStack); downgradeMap.put(downgrade, downgradeMap.getOrDefault(downgrade, 0) + wantedLevel); + downgradeItemStacksMap.put(downgrade, invStack); } int priority = getPriorityFromStack(invStack); @@ -142,6 +145,7 @@ public void performRitual(IMasterRitualStone masterRitualStone) { int wantedLevel = getLevelFromStack(invStack); downgradeMap.put(downgrade, downgradeMap.getOrDefault(downgrade, 0) + wantedLevel); + downgradeItemStacksMap.put(downgrade, invStack); } int priority = getPriorityFromStack(invStack); @@ -171,7 +175,7 @@ public void performRitual(IMasterRitualStone masterRitualStone) // downgrade. 0 means nothing is added. Map pointDifferentialMap = new HashMap(); int totalDifferentialPoints = 0; - boolean notEnoughKeyItems = false; + LivingUpgrade lastSkippedDowngrade = null; for (Entry entry : downgradeMap.entrySet()) { LivingUpgrade downgrade = entry.getKey(); @@ -179,7 +183,7 @@ public void performRitual(IMasterRitualStone masterRitualStone) int wantedLevel = Math.min(entry.getValue(), downgrade.getLevel(Integer.MAX_VALUE)); if (playerDowngradeLevel >= wantedLevel) { - notEnoughKeyItems = true; + lastSkippedDowngrade = downgrade; continue; } @@ -211,12 +215,19 @@ public void performRitual(IMasterRitualStone masterRitualStone) } if (priorityMap.isEmpty() || pointDifferentialMap.isEmpty()) { - if (notEnoughKeyItems) - selectedPlayer.displayClientMessage(Component.translatable("chat.bloodmagic.ritualLivingDowngrade.notEnoughKeyItems"), true); + if (lastSkippedDowngrade != null) + { + String itemName = downgradeItemStacksMap.get(lastSkippedDowngrade).getItem().getDefaultInstance().getDisplayName().getString(); + int lastCharIndex = itemName.length() - 1; + if (itemName.charAt(0) == '[' && itemName.charAt(lastCharIndex) == ']') + { + itemName = itemName.substring(1, lastCharIndex); // remove the brackets around the item name. + } + selectedPlayer.displayClientMessage(Component.translatable("chat.bloodmagic.ritualLivingDowngrade.notEnoughKeyItems", itemName), true); + } return; } - List slotOrderList = new ArrayList<>(); List priorityList = new ArrayList<>(priorityMap.keySet()); From 793bc9febd0df3143a86bc0b6b5a971a4a8610ba Mon Sep 17 00:00:00 2001 From: VT-14 Date: Tue, 10 Oct 2023 11:39:31 -0400 Subject: [PATCH 3/3] Downgrade - Missing Inventory Add an error message for the Downgrade Ritual for when the inventory is missing. --- src/generated/resources/assets/bloodmagic/lang/en_us.json | 1 + .../java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java | 1 + .../wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java | 1 + 3 files changed, 3 insertions(+) diff --git a/src/generated/resources/assets/bloodmagic/lang/en_us.json b/src/generated/resources/assets/bloodmagic/lang/en_us.json index bb22b028b..4f43ba4cd 100644 --- a/src/generated/resources/assets/bloodmagic/lang/en_us.json +++ b/src/generated/resources/assets/bloodmagic/lang/en_us.json @@ -118,6 +118,7 @@ "chat.bloodmagic.ritual.notValid": "You feel that these runes are not configured correctly...", "chat.bloodmagic.ritual.prevent": "The ritual is actively resisting you!", "chat.bloodmagic.ritual.weak": "You feel a push, but are too weak to perform this ritual.", + "chat.bloodmagic.ritualLivingDowngrade.missingInventory": "No inventory found at %d, %d, %d.", "chat.bloodmagic.ritualLivingDowngrade.notEnoughKeyItems": "You sense you need more %s to apply a stronger Downgrade.", "chat.bloodmagic.ritualLivingDowngrade.notEnoughPoints": "You sense you will need more Upgrade Points to apply these Downgrades.", "chat.bloodmagic.ritualLivingDowngrade.trainingBraceletBlock": "Your Training Bracelet vibrates as it prevents the downgrade from being applied.", diff --git a/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java b/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java index 0c648fff9..42b3da424 100644 --- a/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java +++ b/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java @@ -938,6 +938,7 @@ protected void addTranslations() add("chat.bloodmagic.ritualLivingDowngrade.trainingBraceletBlock", "Your Training Bracelet vibrates as it prevents the downgrade from being applied."); add("chat.bloodmagic.ritualLivingDowngrade.notEnoughKeyItems", "You sense you need more %s to apply a stronger Downgrade."); add("chat.bloodmagic.ritualLivingDowngrade.notEnoughPoints", "You sense you will need more Upgrade Points to apply these Downgrades."); + add("chat.bloodmagic.ritualLivingDowngrade.missingInventory", "No inventory found at %d, %d, %d."); // GUI add("gui.bloodmagic.empty", "Empty"); diff --git a/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java index 4ccfe9ea3..5402dd02b 100644 --- a/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java +++ b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualLivingDowngrade.java @@ -89,6 +89,7 @@ public void performRitual(IMasterRitualStone masterRitualStone) if (tile == null) { + selectedPlayer.displayClientMessage(Component.translatable("chat.bloodmagic.ritualLivingDowngrade.missingInventory", chestPos.getX(), chestPos.getY(), chestPos.getZ()), true); return; }