mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 06:52:21 +00:00
Create First Push of Recipe Events
This commit is contained in:
1 parent
2860cc5cf3
commit
bacfb5eba0
15 files changed
+671
-57
No files matched your search
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.api.handler.data.IAnvilRecipe;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.data.RecipeAnvil;
|
||||
@@ -25,6 +26,8 @@ public class ContainerAnvilRepair extends Container {
|
||||
public int repairCost = 0;
|
||||
public int repairMaterialConsumed = 0;
|
||||
|
||||
private RecipeAnvil currentRecipe;
|
||||
|
||||
public ContainerAnvilRepair(InventoryPlayer playerInv, World world, int x, int y, int z) {
|
||||
this.worldObj = world;
|
||||
this.posX = x;
|
||||
@@ -109,6 +112,8 @@ public class ContainerAnvilRepair extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
currentRecipe = matchingRecipe;
|
||||
|
||||
ItemStack output = null;
|
||||
if (matchingRecipe != null) {
|
||||
if (!matchingRecipe.availability.isAvailable(player)) {
|
||||
@@ -272,6 +277,19 @@ public class ContainerAnvilRepair extends Container {
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
|
||||
RecipeAnvil recipe = container.currentRecipe;
|
||||
ItemStack[] items = new ItemStack[]{
|
||||
container.anvilMatrix.getStackInRowAndColumn(0, 0),
|
||||
container.anvilMatrix.getStackInRowAndColumn(1, 0)
|
||||
};
|
||||
if (recipe != null) {
|
||||
if (EventHooks.onRecipeScriptPre(player, recipe.getScriptHandler(), recipe, items)) {
|
||||
return;
|
||||
}
|
||||
container.updateRepairResult();
|
||||
stack = EventHooks.onRecipeScriptPost(player, recipe.getScriptHandler(), recipe, items, stack);
|
||||
}
|
||||
|
||||
if (player.experienceTotal < container.repairCost) {
|
||||
container.updateRepairResult();
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user