Skip to content

Commit

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

Map<Integer, List<Integer>> priorityMap = new HashMap<>();
// Contains the ItemStack used for each downgrade. Used for the insufficient level message.
Map<LivingUpgrade, ItemStack> downgradeItemStacksMap= new HashMap<>();

LazyOptional<IItemHandler> capability = tile.getCapability(ForgeCapabilities.ITEM_HANDLER, accessDir);
if (capability.isPresent())
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -171,15 +175,15 @@ 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;
LivingUpgrade lastSkippedDowngrade = null;
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;
lastSkippedDowngrade = downgrade;
continue;
}

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

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

0 comments on commit 7f94c06

Please sign in to comment.