Skip to content

Commit

Permalink
Add Error Messages to the Downgrade Ritual
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
VT-14 committed Oct 10, 2023
1 parent e573e39 commit 802379a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/generated/resources/assets/bloodmagic/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,7 +73,6 @@ public void performRitual(IMasterRitualStone masterRitualStone)

if (selectedPlayer == null)
{

return;
}

Expand Down Expand Up @@ -171,18 +171,21 @@ public void performRitual(IMasterRitualStone masterRitualStone)
// downgrade. 0 means nothing is added.
Map<LivingUpgrade, Integer> pointDifferentialMap = new HashMap<LivingUpgrade, Integer>();
int totalDifferentialPoints = 0;
boolean notEnoughKeyItems = false;
for (Entry<LivingUpgrade, Integer> entry : downgradeMap.entrySet())
{
LivingUpgrade downgrade = entry.getKey();
int playerDowngradeLevel = playerStats.getLevel(downgrade.getKey());
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;
}

Expand All @@ -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<Integer> slotOrderList = new ArrayList<>();

List<Integer> priorityList = new ArrayList<>(priorityMap.keySet());
Expand Down

0 comments on commit 802379a

Please sign in to comment.