Skip to content

Commit

Permalink
fix edge case of smithing retain with layered item scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 25, 2022
1 parent c91b96a commit 3fb2d1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Expand Up @@ -669,21 +669,16 @@ public void onItemSmithing(PrepareSmithingEvent event) {
for (String retainable : retain) {
switch (retainable) {
case "display":
if (!originalMeta.hasDisplayName()) {
newMeta.setDisplayName(null);
}
else {
if (originalMeta.hasDisplayName()) {
String originalName = NMSHandler.itemHelper.getDisplayName(new ItemTag(inputItem));
NMSHandler.itemHelper.setDisplayName(got, originalName);
ItemScriptContainer origScript = getItemScriptContainer(inputItem);
if (origScript == null || !originalName.equals(NMSHandler.itemHelper.getDisplayName(origScript.getItemFrom()))) {
NMSHandler.itemHelper.setDisplayName(got, originalName);
}
}
newMeta = got.getItemMeta();
break;
case "enchantments":
if (newMeta.hasEnchants()) {
for (Enchantment enchant : new ArrayList<>(newMeta.getEnchants().keySet())) {
newMeta.removeEnchant(enchant);
}
}
if (originalMeta.hasEnchants()) {
for (Map.Entry<Enchantment, Integer> enchant : originalMeta.getEnchants().entrySet()) {
newMeta.addEnchant(enchant.getKey(), enchant.getValue(), true);
Expand Down
Expand Up @@ -102,9 +102,6 @@ else if (args.hasFlag('t')) {
if (args.hasValueFlag("delay") && args.getFlag("delay").matches("\\d+") && args.getFlagInteger("delay") > 0) {
trait.setDelay(args.getFlagInteger("delay"));
}
Messaging.sendInfo(sender, npc.getName() + (trait.isPushable() ? " is" : " is not") + " currently pushable" +
(trait.isReturnable() && trait.isPushable() ? " and will return when pushed after '" + trait.getDelay() + "' seconds." : "."));
return;
}
else if (args.length() > 2) {
Messaging.send(sender, "");
Expand Down

0 comments on commit 3fb2d1b

Please sign in to comment.