use of forestry.storage.BackpackMode in project ForestryMC by ForestryMC.
the class ItemBackpack method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, @Nullable World world, List<String> list, ITooltipFlag flag) {
super.addInformation(itemstack, world, list, flag);
int occupied = ItemInventory.getOccupiedSlotCount(itemstack);
BackpackMode mode = getMode(itemstack);
String infoKey = mode.getUnlocalizedInfo();
if (infoKey != null) {
list.add(Translator.translateToLocal(infoKey));
}
list.add(Translator.translateToLocal("for.gui.slots").replaceAll("%USED", String.valueOf(occupied)).replaceAll("%SIZE", String.valueOf(getBackpackSize())));
}
use of forestry.storage.BackpackMode in project ForestryMC by ForestryMC.
the class ItemBackpack method switchMode.
private static void switchMode(ItemStack itemstack) {
BackpackMode mode = getMode(itemstack);
int nextMode = mode.ordinal() + 1;
if (!Config.enableBackpackResupply && nextMode == BackpackMode.RESUPPLY.ordinal()) {
nextMode++;
}
nextMode %= BackpackMode.values().length;
itemstack.setItemDamage(nextMode);
}
use of forestry.storage.BackpackMode in project ForestryMC by ForestryMC.
the class ItemBackpack method evaluateTileHit.
private boolean evaluateTileHit(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side) {
// Shift right-clicking on an inventory tile will attempt to transfer
// items contained in the backpack
IItemHandler inventory = getInventoryHit(world, pos, side);
// Process only inventories
if (inventory != null) {
// Must have inventory slots
if (inventory.getSlots() <= 0) {
return true;
}
if (!world.isRemote) {
// Create our own backpack inventory
ItemInventoryBackpack backpackInventory = new ItemInventoryBackpack(player, getBackpackSize(), stack);
BackpackMode mode = getMode(stack);
if (mode == BackpackMode.RECEIVE) {
receiveFromChest(backpackInventory, inventory);
} else {
transferToChest(backpackInventory, inventory);
}
}
return true;
}
return false;
}
Aggregations