Recipe Event API

This commit is contained in:
Kam committed 2025-07-23 23:14:29 -04:00
1 parent 4dcaaf9577
commit b083e05f16
2 files changed
+16 -4

No files matched your search

+1 -1
Submodule src/api updated: b60245f21a...bd03e27c47.
@@ -2,11 +2,12 @@ package noppes.npcs.scripted.event;
import cpw.mods.fml.common.eventhandler.Cancelable;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.event.IRecipeEvent;
import noppes.npcs.api.item.IItemStack;
import noppes.npcs.controllers.data.RecipeScript;
import noppes.npcs.scripted.event.player.PlayerEvent;
public class RecipeScriptEvent extends PlayerEvent {
public class RecipeScriptEvent extends PlayerEvent implements IRecipeEvent {
public final Object recipe;
public final IItemStack[] items;
public final boolean isAnvil;
@@ -18,20 +19,23 @@ public class RecipeScriptEvent extends PlayerEvent {
this.isAnvil = anvil;
}
@Override
public Object getRecipe() {
return recipe;
}
@Override
public IItemStack[] getItems() {
return items;
}
@Override
public boolean isAnvil() {
return isAnvil;
}
@Cancelable
public static class Pre extends RecipeScriptEvent {
public static class Pre extends RecipeScriptEvent implements IRecipeEvent.Pre {
private String message = "";
private int xpCost = 0;
private int materialUsage = 0;
@@ -40,27 +44,33 @@ public class RecipeScriptEvent extends PlayerEvent {
super(player, recipe, isAnvil, items);
}
@Override
public void setMessage(String message) {
this.message = message == null ? "" : message;
}
@Override
public String getMessage() {
return message;
}
@Override
public int getXpCost() {
return xpCost;
}
@Override
public void setXpCost(int xpCost) {
if (this.isAnvil)
this.xpCost = xpCost;
}
@Override
public int getMaterialUsage() {
return materialUsage;
}
@Override
public void setMaterialUsage(int materialUsage) {
if (this.isAnvil)
this.materialUsage = materialUsage;
@@ -71,7 +81,7 @@ public class RecipeScriptEvent extends PlayerEvent {
}
}
public static class Post extends RecipeScriptEvent {
public static class Post extends RecipeScriptEvent implements IRecipeEvent.Post {
private IItemStack result;
public Post(IPlayer player, Object recipe, boolean isAnvil, IItemStack[] items, IItemStack result) {
@@ -79,10 +89,12 @@ public class RecipeScriptEvent extends PlayerEvent {
this.result = result;
}
@Override
public IItemStack getCraft() {
return result;
}
@Override
public void setResult(IItemStack stack) {
this.result = stack;
}