Skip to content

Commit

Permalink
Remove custom recipe implementation attempt that doesn't seem to have…
Browse files Browse the repository at this point in the history
… ever worked properly.
  • Loading branch information
davidcernat committed Oct 20, 2013
1 parent e5549e6 commit 40487cb
Showing 1 changed file with 0 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,43 +155,6 @@ public void boundDropItem(PlayerDropItemEvent event) {
}
}

@EventHandler
public void craftItem(CraftItemEvent event) {
// Run a script on craft of an item script
if (isItemscript(event.getRecipe().getResult())) {
if (!(event.getWhoClicked() instanceof Player)) return;

dItem item = new dItem(event.getRecipe().getResult());
ItemScriptContainer script = null;
for (String itemLore : item.getItemStack().getItemMeta().getLore())
if (itemLore.startsWith(dItem.itemscriptIdentifier)) // Note: Update this when the id: is stored differently
script = ScriptRegistry.getScriptContainerAs(itemLore.substring(5), ItemScriptContainer.class);

if (script == null) {
dB.echoDebug("Tried to craft non-existent script!");
return;
}

for (int i = 0; i < 9; i++) {
if (!script.getRecipe().get(i).identify().equalsIgnoreCase(
(new dItem(event.getInventory().getMatrix()[i])).identify())) { // This probably can be compared more efficiently...
dB.echoDebug("Ignoring craft attempt using "
+ (new dItem(event.getInventory().getMatrix()[i])).identify()
+ " instead of " + script.getRecipe().get(i).identify());
event.setCancelled(true);
return;
}
}

Map<String, Object> context = new HashMap<String, Object>();
String determination = doEvents(Arrays.asList("craft"),
null, (Player) event.getWhoClicked(), context);

if (determination.toUpperCase().startsWith("CANCELLED"))
event.setCancelled(true);
}
}

@EventHandler
public void dropItem(PlayerDropItemEvent event) {
// Run a script on drop of an item script
Expand Down

1 comment on commit 40487cb

@davidcernat
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this event, if you had a recipe that required an itemscript item, you would see that recipe's result when you tried to craft it using a regular version of that itemscript's material, but you could only complete the crafting if you were actually using the itemscript item itself.

That itself is not a major issue, because it only prevented you from crafting something that appeared to be craftable and provided no explanation for it.

The major issue is this lovely error:

http://pastebin.com/jACJKLTS

Which you got whenever Denizen loaded the itemscript with the recipe before it loaded the itemscript required in that recipe.

Note: the above information reflects the state of affairs from a few days ago, from before I ever touched the recipe code myself.

Will replace with a better implementation.

Please sign in to comment.