mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 21:17:32 +00:00
Merge pull request #182 from KAMKEEL/rvcol3-codex/fix-item-duplication-on-pre-event-cancel
Fix recipe pre-event pickup checks
This commit is contained in:
2 files changed
+37
-31
No files matched your search
@@ -273,19 +273,21 @@ public class ContainerAnvilRepair extends Container {
|
||||
|
||||
public boolean preEvent(EntityPlayer player) {
|
||||
preChecked = true;
|
||||
RecipeAnvil recipe = container.currentRecipe;
|
||||
if (recipe != null) {
|
||||
ItemStack[] items = new ItemStack[]{
|
||||
container.anvilMatrix.getStackInRowAndColumn(0, 0),
|
||||
container.anvilMatrix.getStackInRowAndColumn(1, 0)
|
||||
};
|
||||
canPickup = !EventHooks.onRecipeScriptPre(player, recipe.getScriptHandler(), recipe, items);
|
||||
if (!canPickup) {
|
||||
container.updateRepairResult();
|
||||
preChecked = false; // reset for next attempt
|
||||
if (!container.worldObj.isRemote) {
|
||||
RecipeAnvil recipe = container.currentRecipe;
|
||||
if (recipe != null) {
|
||||
ItemStack[] items = new ItemStack[]{
|
||||
container.anvilMatrix.getStackInRowAndColumn(0, 0),
|
||||
container.anvilMatrix.getStackInRowAndColumn(1, 0)
|
||||
};
|
||||
canPickup = !EventHooks.onRecipeScriptPre(player, recipe.getScriptHandler(), recipe, items);
|
||||
if (!canPickup) {
|
||||
container.updateRepairResult();
|
||||
preChecked = false; // reset for next attempt
|
||||
}
|
||||
} else {
|
||||
canPickup = true;
|
||||
}
|
||||
} else {
|
||||
canPickup = true;
|
||||
}
|
||||
return canPickup;
|
||||
}
|
||||
@@ -317,7 +319,7 @@ public class ContainerAnvilRepair extends Container {
|
||||
container.anvilMatrix.getStackInRowAndColumn(0, 0),
|
||||
container.anvilMatrix.getStackInRowAndColumn(1, 0)
|
||||
};
|
||||
if (recipe != null) {
|
||||
if (!container.worldObj.isRemote && recipe != null) {
|
||||
container.updateRepairResult();
|
||||
stack = EventHooks.onRecipeScriptPost(player, recipe.getScriptHandler(), recipe, items, stack);
|
||||
}
|
||||
|
||||
@@ -174,19 +174,21 @@ public class ContainerCarpentryBench extends Container {
|
||||
|
||||
public boolean preEvent(EntityPlayer player) {
|
||||
preChecked = true;
|
||||
RecipeCarpentry recipe = container.currentRecipe;
|
||||
if (recipe != null) {
|
||||
ItemStack[] items = new ItemStack[matrix.getSizeInventory()];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = matrix.getStackInSlot(i);
|
||||
if (!container.worldObj.isRemote) {
|
||||
RecipeCarpentry recipe = container.currentRecipe;
|
||||
if (recipe != null) {
|
||||
ItemStack[] items = new ItemStack[matrix.getSizeInventory()];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = matrix.getStackInSlot(i);
|
||||
}
|
||||
canPickup = !EventHooks.onRecipeScriptPre(player, recipe.getScriptHandler(), recipe, items);
|
||||
if (!canPickup) {
|
||||
container.onCraftMatrixChanged(matrix);
|
||||
preChecked = false; // reset for next attempt
|
||||
}
|
||||
} else {
|
||||
canPickup = true;
|
||||
}
|
||||
canPickup = !EventHooks.onRecipeScriptPre(player, recipe.getScriptHandler(), recipe, items);
|
||||
if (!canPickup) {
|
||||
container.onCraftMatrixChanged(matrix);
|
||||
preChecked = false; // reset for next attempt
|
||||
}
|
||||
} else {
|
||||
canPickup = true;
|
||||
}
|
||||
return canPickup;
|
||||
}
|
||||
@@ -207,13 +209,15 @@ public class ContainerCarpentryBench extends Container {
|
||||
}
|
||||
if (!canPickup)
|
||||
return;
|
||||
RecipeCarpentry recipe = container.currentRecipe;
|
||||
if (recipe != null) {
|
||||
ItemStack[] items = new ItemStack[matrix.getSizeInventory()];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = matrix.getStackInSlot(i);
|
||||
if (!container.worldObj.isRemote) {
|
||||
RecipeCarpentry recipe = container.currentRecipe;
|
||||
if (recipe != null) {
|
||||
ItemStack[] items = new ItemStack[matrix.getSizeInventory()];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = matrix.getStackInSlot(i);
|
||||
}
|
||||
stack = EventHooks.onRecipeScriptPost(player, recipe.getScriptHandler(), recipe, items, stack);
|
||||
}
|
||||
stack = EventHooks.onRecipeScriptPost(player, recipe.getScriptHandler(), recipe, items, stack);
|
||||
}
|
||||
preChecked = false;
|
||||
canPickup = true;
|
||||
|
||||
Reference in new issue
Block a user