Skip to content

Commit

Permalink
Only set the result if it has changed, Fix #1490
Browse files Browse the repository at this point in the history
  • Loading branch information
Daunbawang committed Dec 7, 2016
1 parent 95cbc46 commit fa5aebc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Expand Up @@ -50,6 +50,8 @@ public ItemRecipeFormedScriptEvent() {
}

public static ItemRecipeFormedScriptEvent instance;

public boolean resultChanged;
public dItem result;
public dList recipe;
public CraftingInventory inventory;
Expand All @@ -67,11 +69,7 @@ public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
String eItem = CoreUtilities.getXthArg(0, lower);

if (!tryItem(result, eItem)) {
return false;
}

return true;
return tryItem(result, eItem);
}

@Override
Expand All @@ -93,6 +91,7 @@ public void destroy() {
public boolean applyDetermination(ScriptContainer container, String determination) {
if (dItem.matches(determination)) {
result = dItem.valueOf(determination);
resultChanged = true;
}

return super.applyDetermination(container, determination);
Expand Down Expand Up @@ -139,12 +138,13 @@ public void onRecipeFormed(PrepareItemCraftEvent event) {
}
}
player = dEntity.getPlayerFrom(humanEntity);
resultChanged = false;
cancelled = false;
fire();
if (cancelled) {
inventory.setResult(null);
}
else {
else if (resultChanged) {
inventory.setResult(result.getItemStack());
}
}
Expand Down
Expand Up @@ -381,7 +381,7 @@ public void run() {
if (event.cancelled) {
inventory.setResult(null);
}
else {
else if (event.resultChanged) {
// If this was a valid match, set the crafting's result
inventory.setResult(event.result.getItemStack());
}
Expand Down

0 comments on commit fa5aebc

Please sign in to comment.