Fixed spellbook still consuming items even if you haven't crafted anything

This commit is contained in:
Sollace 2019-02-15 17:36:03 +02:00
parent f59c1833e3
commit 4dffafda01
2 changed files with 31 additions and 21 deletions

View file

@ -78,10 +78,12 @@ public class ContainerSpellBook extends Container {
if (!crafted.isEmpty()) {
current = SpellRegistry.instance().enchantStack(current, crafted);
resultSlot.setCrafted(true);
player.playSound(SoundEvents.BLOCK_NOTE_CHIME, 1, 1);
} else {
current = SpellRegistry.instance().disenchantStack(current);
resultSlot.setCrafted(false);
player.playSound(SoundEvents.BLOCK_NOTE_BASS, 1, 1);
}

View file

@ -20,6 +20,8 @@ public class SlotEnchantingResult extends SlotEnchanting {
private IPageUnlockListener listener;
private boolean crafted;
public SlotEnchantingResult(IPageUnlockListener listener, IPageOwner owner, InventorySpellBook craftMatric, IInventory inventory, int index, int xPosition, int yPosition) {
super(inventory, index, xPosition, yPosition);
this.owner = owner;
@ -31,8 +33,13 @@ public class SlotEnchantingResult extends SlotEnchanting {
this.listener = listener;
}
public void setCrafted(boolean crafted) {
this.crafted = crafted;
}
@Override
public ItemStack onTake(EntityPlayer player, ItemStack stack) {
if (crafted) {
onCrafting(stack);
ItemStack current = craftMatrix.getCraftResultMatrix().getStackInSlot(0);
@ -65,6 +72,7 @@ public class SlotEnchantingResult extends SlotEnchanting {
}
}
}
}
return super.onTake(player, stack);
}