Make all valid books work with shift-clicking and hopper insertion

This commit is contained in:
Electroblob77
2020-05-16 18:33:53 +01:00
parent cda9947e17
commit 594c546f11
2 changed files with 10 additions and 5 deletions
@@ -3,7 +3,6 @@ package electroblob.wizardry.inventory;
import electroblob.wizardry.Settings;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.block.BlockBookshelf;
import electroblob.wizardry.item.ItemSpellBook;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.tileentity.TileEntityBookshelf;
import net.minecraft.entity.player.EntityPlayer;
@@ -83,7 +82,7 @@ public class ContainerBookshelf extends Container {
int minSlotId = 0;
int maxSlotId = BlockBookshelf.SLOT_COUNT - 1;
if(!(stack.getItem() instanceof ItemSpellBook)) return ItemStack.EMPTY;
if(!isBook(stack)) return ItemStack.EMPTY;
if(!this.mergeItemStack(stack, minSlotId, maxSlotId + 1, false)){
return ItemStack.EMPTY;
@@ -106,6 +105,11 @@ public class ContainerBookshelf extends Container {
return remainder;
}
/** Returns true if the given stack counts as a book and can be placed in a bookshelf, false if not. */
public static boolean isBook(ItemStack stack){
return validItems.contains(stack.getItem()) || Settings.containsMetaItem(Wizardry.settings.bookItems, stack);
}
/**
* Adds the given item to the set of items that can be put in a bookshelf. This method should be called from the
* {@code init()} phase.
@@ -149,7 +153,7 @@ public class ContainerBookshelf extends Container {
@Override
public boolean isItemValid(ItemStack stack){
return validItems.contains(stack.getItem()) || Settings.containsMetaItem(Wizardry.settings.bookItems, stack);
return isBook(stack);
}
}